Farseer Physics Engine

advertisement
Farseer Physics Engine
Revision History
Red items indicate possible breaking change.
Farseer Physics 2.1.2








Performance improvement (Thanks to dreamcreamer)
Added Vertices.GetConvexHull() (Thanks to Cowdozer)
Renamed CollisionHelper to RayHelper
RayHelper.LineSegmentAllGeomIntersect(Vector2, Vector2, Physicsimulator, bool,
List<Vector2>) now returns a list of GeomPointPair.
Fixed bug where the geometry position and rotation was not reset when
ResetDynamics() was called.
Reduced garbage in some situations (Thanks Ultima2876 and roonda)
Added RemoveFromPhysicsSimulator() to Path class.
Removed CreateRope() from ComplexFactory
Farseer Physics 2.1.1








PhysicsSimulator.MaxContactsToDetect is now static
Fixed bug that would cause instabilities when stacking.
Added Geom.IgnoreCollisionWith(Geom)
Fixed bug in Vertices.CreateCapsule() (Details here)
Controllers now take Update(float dt, float dtReal) instead of Update(float dt)
Fixed bug in Water XNA Sample where the water was not drawn right
Fixed bug where the Scaling controller would not get updated
Copying geometries now work again. (Thanks to DDtMM for reporting the problem)
Farseer Physics 2.1








New narrow phase algorithm
o SAT (Separate Axis Theorem) has been implemented
o You can now choose which narrow phase to use
Decoupled narrow phase design
o The engine supports both Distance Grid and the SAT algorithm for narrow phase
o It’s now possible to implement your own improved algorithms.
Improved raycast helper to help make line-geom, line-aabb, line-line collisions.
Vertices union/clipping
o You can now add and subtract polygon using the new unit/clipping tools
New samples
o Samples to show of vertices union/clipping and raycast helper
o New ragdoll sample
o New water sample in XNA
o Whole Simple samples package now also in WPF
More code documentation
o A lot more documentation in our codes makes it easier to understand and use.
Weld Joint
o Grouping joint to allow several geometries to function as a single geometry.
Auto-divide geometries




Ragdoll sample
Support for multi-polygon texture
o New algorithm that support multiple polygons from one texture – even with
holes.
Minor special case performance improvements.
API changes
o We have implemented a bunch of API changes that break backwards
compatibility. You will also have to recompile if you use dynamic DLLs.
Farseer Physics 2.0.1







Changed default max contacts detected and resolved to 10 and 4
o Increased precision in collision detections
Fixed bug in ApplyImpuse():
o Bug 20155
Fixed bug in DrawingHelper.CreateLineTexture():
o Bug 20201
Support for switching between static and nonstatic bodies
o Bug 20264
Changed rotation behavior.
o Rotation now returns 0 when it should be 0.
o Revolutions should also be more precise now.
Renamed GettingStarted samples to SimpleSamples
Changed the number of pyramid blocks in Silverlight version
Farseer Physics 2.0.0












Refactoring joints and springs
New samples
o Multithreading
o Inactivity controller
o Object cache
o Path Generator (Tank track and chains demo)
o Water
o Wind and explosions
More documentation
o Including interactive samples to demonstrate springs and joints
o Very extensive. Includes performance tips and tricks.
o Online version at: Farseer Physics 2.0 Manual
Removed MOIForRectangle from the BodyFactory
o Use BodyFactory.CreateRectangleBody() instead.
Removed SetBroadPhaseCollider(IBroadPhaseCollider broadPhaseCollider)
o Added the property "IBroadPhaseCollider BroadPhaseCollider" instead.
Added OnBroadPhaseCollision event to the IBroadPhaseCollider interface. It
fires before constructing arbiters.
Renamed Collision delegate to OnCollision.
Added OnSeparation delegate to Geom class
Fixed bug in samples that caused Dispose() to be ignored in some cases.
Fixed all bugs waiting in the bug reporting system
Changed properties to be public fields. This forces you to recompile your application.
Added IsSensor property to Geom class. Use this to make the geometry
behave as a sensor.
Sensors detects collisions but does not calculate impulses and is static. (not able
to move).
Added ComplexFactory for creating complex structures
o Includes creating rope and chains.
Added Path Generator
o You can create bodies along a path and link the bodies together. This is used
with the chain/rope factory.
Texture to polygon
o Convert your texture to a uint array and Farseer Physics will create a Vertices list
of polygons around your texture.
Support for ellipse shape
o New Vertices.CreateEllipse() and ellipse factories for both bodies and geometries.
o DrawingHelper class in XNA samples now support ellipse textures.
o




Farseer Physics 2.0.0 Alpha








Code cleanup and refactoring
Garbage removal
o Gives a small performance increase.
Renamed/Created namespaces
Fixed spelling errors
o Easy to fix
Documentation on common properties, methods and classes.
Support for new platforms
o XNA 3.0 Beta
o Silverlight 2.0 RC0
o .NET 3.0 in general
Rename of Collision event to OnCollision
Update of samples to use this version.
o Samples also had cleanup and refactoring
o Easier to understand
FarseerPhysics 1.0.0.6




Changed PhysicsSimulator.Clear() to call
“ConstructPhysicsSimulator(gravity)”
o Seemed like a better way to “reset” the engine.
Added QuadraticDrag option to Body
o Quadratic drag is useful for bodies that travel at high speeds. With quadratic
drag, the drag applied to a body is proportional to its speed squared rather than
just its speed like the normal linear drag.
o Added Body.IsQuadraticDragEnabled property to enabled/disable quadratic
drag. It is disable by default. There is a small performance hit when it’s enabled.
o Added Body.QuadraticDragCoeficient. This will only be used if quadratic drag
is enabled.
o Made changes to Body.ApplyDrag to apply quadratic drag if enabled.
Added PhysicsSimulator.Enabled property.
o Setting this to false will block the physics engine from updating. Essentially
pauses the physics engine.
Added a check to Grid.Intersect to avoid a divide by zero situation.
if (normal.X != 0 || normal.Y != 0)
{
Vector2.Normalize(ref normal, out normal);
feature = new Feature(vector, normal, distance);
return true;
}

Changed the way breakpoints are handled in joints and springs.
o Previously the joint was disposed whenever the breakpoint was reached (see
below)
if (Math.Abs(jointError) > breakpoint) { Dispose(); }
o
Now when the breakpoint is reached the joint is simply disabled (instead of
Disposing) and a “Broke” event is thrown.
if (Enabled && Math.Abs(jointError) > breakpoint)
{
Enabled= false;
if (Broke != null) Broke(this, new EventArgs());
}

Defined a Broke event in all joints and springs (see above for how it’s
triggered)
FarseerPhysics 1.0.0.5










Renamed delegate Body.OnChangedHandler to Body.UpdatedEventHandler
o May require name fix in your code.
Renamed Body.OnUpdated to Body.Updated
o May require name fix in your code.
o This was done to conform to naming guidelines for .Net frameworks.
Renamed Event Body.OnDisposed to Body.Disposed
o See above for fix-up guide and reason.
Renamed Geom. CollisionHandlerDelegate to Geom.CollisionEventHandler
o May require name fix in your code.
o Conforming to .Net framework naming guidlines
Renamed Geom.CollisionHandler to Geom.Collision
o May require name fix in your code.
o Conforming to .Net framework naming guidelines
Renamed GeomList.GeomAddedRemovedDelegate to
GeomList.ContentsChangedEventHandler
o May require name fix in your code.
o Conforming to .Net framework naming guidelines
Renamed GeomList.GeomAddedHandler to GeomList.Added
o May require name fix in your code.
o Conforming to .Net framework naming guidelines
Renamed GeomList.GeomRemovedHandler to GeomList.Removed
o May require name fix in your code.
o Conforming to .Net framework naming guidelines
Made name changes similar to GeomList to BodyList, ControllerList, and
JointList
Modified FluidDragController
o Previously, the FluidDragController used an AABB to describe where the ‘fluid’
drag should take affect. In order to make the fluid drag controller more flexible
and able to use ‘shapes’ other than an AABB, I changed it to use an
‘IFluidContainer’ interface instead. (see below)
o Probably not many using this as it’s new and undocumented







Added LinkedList, LinkedList.Node and Stack collection classes to new
namespace Collections.Generic.
o These were added for the Silverlight version of the engine since they do not exist
in the new Silvelight 2.0 beta.
o The XNA version will still use the native .Net version of these collections.
o Thanks to Bill Reiss for adding these classes and fixing up the SelectiveSweep
and SweepAndPrune broad phase colliders to use them.
Added IFluidContainer interface
o This interface defines 2 methods
 Intersect(AABB aabb) determines a sort of broad phase intersection
 Contains(ref Vector2 vector) determines if a point is contained by the
FluidContainer
o Any class that implements these 2 methods can be used by the
FluidDragController.
Added AABBFluidContainer
o Implements the IFluidContainer interface for AABBs.
Added WaveController
o Implements IFluidContainer
o Controls the generation of 2D rolling waves
Added new ‘Controllers’ namespace
o I expect to develop more and more controllers and felt a namespace was in
order.
o Springs, the Base Controller class, and Controller Factory will remain in the
Dynamics namespace. The Controllers namepace is more for higher level things
like waves and water physics.
Added “Enabled” bit to controllers so they can be turned on and off
Added the following methods to the Calculator class
o Note:These were provided by ‘sickbattery’ from the codeplex forums. I have not had
a chance to test them so let me know if you find any issues with them
o public static float VectorToRadians(Vector2 vector)
o
public static Vector2 RadiansToVector(float radians)
o
public static void RadiansToVector(float radians, ref Vector2 vector)
o
public static void RotateVector(ref Vector2 vector, float radians)
o
public static Vector2 LinearBezierCurve(Vector2 start, Vector2 end, float t)
o
public static Vector2 QuadraticBezierCurve(Vector2 start, Vector2 curve, Vector2
end, float t)
o
public static Vector2 QuadraticBezierCurve(Vector2 start, Vector2 curve, Vector2
end, float t, ref float radians)
o
public static Vector2 CubicBezierCurve2(Vector2 start, Vector2 startPoitsTo,
Vector2 end, Vector2 endPointsTo, float t)
o
public static Vector2 CubicBezierCurve2(Vector2 start, Vector2 startPoitsTo,
Vector2 end, Vector2 endPointsTo, float t, ref float radians)
o
public static Vector2 CubicBezierCurve2(Vector2 start, float startPointDirection,
float startPointLength, Vector2 end, float endPointDirection, float
endPointLength, float t, ref float radians)
o
public static Vector2 CubicBezierCurve(Vector2 start, Vector2 curve1, Vector2
curve2, Vector2 end, float t)
o
public static Vector2 CubicBezierCurve(Vector2 start, Vector2 curve1, Vector2
curve2, Vector2 end, float t, ref float radians)
o
public static Vector2 InterpolateNormal(Vector2 vector1, Vector2 vector2, float t)
o
public static void InterpolateNormal(Vector2 vector1, Vector2 vector2, float t, out
Vector2 vector)
o
public static void InterpolateNormal(ref Vector2 vector1, Vector2 vector2, float t)
o
public static float InterpolateRotation(float radians1, float radians2, float t)

Added Body.ClearImpulse()
o This is similar to ClearForce() and ClearTorque()
o When you create a pool of bodies this helps “Reset” the body when it is released
to the pool.

Added Body.ResetDynamics()
o
o
This method will reset position and motion properties of the body.
Useful when creating pools of re-usable bodies. It would be used when releasing
bodies back into a pool.
FarseerPhysics 1.0.0.4

Small change to Vertices.Translate(). Given a vector, this method was doing a
subtraction for the translation where it should have been adding. If you were using this
method you will need to negate the vector you were passing in to this method.

Changed Vertices.CalculateMomentOfInertia() to Vertices.GetMomentOfInertia() to match
naming convention used by other methods in the class. If using this method you will
need to do a global find/replace.

Changed Vertices.GetMomentOfInertia to center the verts on its centroid prior to
calculating the moment of inertia. It made more sense to do this. The underlying vertice
values are not changed permanently by this method only for the calculation.

Added BodyFactory.CreatePolygonBody(..., Vertices vertices, ...) overload. This method
takes a set of vertices and uses them to calculate the moment of inertia so the user
doesn't need to do this themselves.
o Example: the code below will create a body with it’s MomentOfInertia
automatically calculated to be that of the triangle defined by the vertices passed
in. In the past you would have had to call verts.CalculateMomentOfInertia, then
set that explicitly on the Body after it was created.
verts = new Vertices();
verts.Add(ConvertUnits.ToSimUnits(200, 200));
verts.Add(ConvertUnits.ToSimUnits(100, 200));
verts.Add(ConvertUnits.ToSimUnits(100, 300));
testBody = BodyFactory.Instance.CreatePolygonBody(physicsSimulator, verts, 1);

Changed GeomFactory.CreatePolygonGeom(..). This method will now automatically align
the centroid (center of mass) of the geom with the associated body position unless an
offset is provided in which case the geom’s centroid will be offset from the body by the
amount of the offset.
o Previously this method caused a lot of confusion if the vertices were not defined
relative to 0,0. With this change, verts can now be defined anywhere and this
method will fix up the verts so they act as though they were created relative to
0,0.

Changed the way Body rotation, totalRotations, and revolutions are tracked and clamped.
o This change was suggested by ‘yota’ in the CodePlex Issue Tracker.
o The rotation of a body is now clamped as follows: 0 <= rotation < 2Pi. (It use
to be -2Pi < rotation < 2Pi)
o In addition, the revolutions are more accuratly tracked if a large rotation value is
passed in to the Body.Rotation property. Thanks again to yota for this fix.
o Finally, Body.revolutions, which was a private internal variable in Body now has a
property accesor.

Fixed linear drag bug found by michael_brooks11 from the codeplex forums.
o Linear drag was not being computed properly.
o See this post for more info:
https://www.codeplex.com/Thread/View.aspx?ProjectName=FarseerPhysics&Thr
eadId=21087
o You may need to adjust existing ‘LinearDrag’ settings for your bodies due to this
change.
-------------------------------ARCHIVED REVISION HISTORY---------------------------FarseerPhysics 1.0.0.3
----------------------SMALL BREAKING CHANGE (eassy to fix up)
--Added a FrictionType property to PhysicsSimulator. You can now choose between FrictionType.Minimum and
FrictionType.Average. The first will cause the fiction between 2 bodies to be the min of the two, the second will use the average. In
previous versions only minimum was used. Now the engine defaults to use average. If you want the engine to work the way it has
been, simply set this property to minimum.
-Added BioSlayers fix to SelectiveSweep.
-Changed the Arbiter to take a PhysicsSimulator rather than a bunch of fields. All the fields were in the PhysicsSimulator.
FarseerPhysics 1.0.0.2
-----------------------BREAKING CHANGES
--Changed Body.GetVelocityAtPoint to Body.GetVelocityAtLocalPoint. This was to differentiate if from the new method
Body.GetVelocityAtWorldPoint
-Added Body.GetVelocityAtWorldPoint and Body.ApplyForceAtWorldPoint methods.
-Update Broadphase Collision As follows:
--Add IBroadPhaseCollider interface
--Created a BruteForceCollider that implements IBroadPhaseCollider.
--Added SweepAndPruneCollider that implements IBroadPhaseCollider (Thanks Andy Jones)
--Added SelectiveSweepCollider that implements IBroadPhaseCollider (Thanks BioSlayer)
--Made SelectiveSweepCollider the default. While I found the SweepAndPruneCollider faster in most cases, SelectiveSweep seems
for forgiving in general situations.
--Added SetBroadPhaseCollider(IBroadPhaseCollider) to PhysicsSimulator.
--All the broad phase stuff is still somewhat in flux. It could change again in the future.
-Added a Demo8: Broad Phase Collision Stress Test.
-Renamed Calculator.PiX2 to Calculator.TwoPi to be consistent with XNS math library.
-Added FluidDragController to simulate rigid bodies in water or other liquids.
-Added a number of LineIntersection methods. Used to test intersection two lines or lines an Geoms. The methods can be found in the
new CollisionHelper class. (Thanks to Jeremy Bell for the code.)
FarseerPhysics 1.0.0.1
----------------------BREAKING CHANGE:
-Geometry object name was changed to Geom. I know this might cause some temporay headaches but 'Geometry' conflicts with a
Geometry object in Silverlight and long term I think this is the right decision.
-PhysicsSimulator
Added new SweepAndPrune BroadPhaseCollision option. This option can be toggled by setting
PhysicsSimulator.BroadPhaseCollider.
Default is brute force until SweepAndPrune can be optimized.
-PhysicsSimulator.ProcessRemovedItems:
Added code to remove any arbiters associated with geometries that are being removed from the simulator.
-PhysicsSimulator.ProcessAddedItems:
Changed the order the ProcessXXX methods were called. Put ProcessAddedItems 1st to avoid confusion when add/remove is called
without calling update in between.
-Mathematics.Calculator:
Added DegreesToRadians method.
-Collision.Vertices
Added CalculateMomentOfInertia() to make it easy to get the moment of inertia for a polygon
Fixed a nasty collision bug that would appear with semi-complex geometries.
-Global
Did some performance tuning by replacing some existing method calls with inline logic.
-RevoluteJoint
Changed default biasFactor to .2 from .8. For stability purposes.
-Body
Changed the ApplyImpulse logic to store impulses applied externally and have the PhysicsSimulator apply the summed impules all at
once.
Joints and Arbiter now call internal method "ApplyImmediateImpulse"
FarseerPhysics 1.0.0.0
-------------------------First Release
Download