Farseer Physics Engine 3.2 - Released!

Coordinator
Jan 1, 2011 at 9:59 PM

Go get the new version: Download Farseer Physics Engine 3.2

Jan 1, 2011 at 10:26 PM

Hurray!  I just sent in a donation for you.  Keep up the awesome work.

Jan 2, 2011 at 8:40 AM

Ah very nice. Just a couple of questions: What does the density variable in the PolygonShape constructor do and what is the purpouse of the bool for the 'BeginContact' delegate?

Coordinator
Jan 2, 2011 at 1:46 PM

Density is what is used to calculate the mass of an object. Mass is calculated as the density * area.

The density variable has been moved from fixtures to shapes in order to facilitate better shape-caching as properties of the shape now only has to be calculated once.

The bool in BeginContact determines if the contact should be deleted or not. Basically you cancel the collision or let it collide. Return false to cancel the collision.

Jan 2, 2011 at 4:09 PM
Genbox wrote:

Density is what is used to calculate the mass of an object. Mass is calculated as the density * area.

The density variable has been moved from fixtures to shapes in order to facilitate better shape-caching as properties of the shape now only has to be calculated once.

The bool in BeginContact determines if the contact should be deleted or not. Basically you cancel the collision or let it collide. Return false to cancel the collision.

Ah, very cool. I presume endcontact is never called if begincontact returns false?

Coordinator
Jan 2, 2011 at 4:17 PM

That is correct as the contact is never created. However, the time of impact implementation also uses contacts, so BeginContact and EndContact can be called multiple times on the same body.

Jan 3, 2011 at 1:39 AM

Wow, great update :)

Very Very Nice.

Jan 3, 2011 at 3:24 AM

What's the difference between the XNA download and the Xbox360 download? 

Coordinator
Jan 3, 2011 at 4:01 AM

Nothing really. The only difference being that VS2010 have some trouble with the System.Data reference when converting a XNA project to Xbox360.

Jan 3, 2011 at 8:06 AM

thanks for your work, guys.

Jan 3, 2011 at 5:06 PM

Great job!

I just updated to FPE3.2 and I'm finding an assert error when removing bodies that are attached between them (a body and then another body which is attached to it), it seems that is something related to the joints, as the assert message fires up in the RemoveJoint() method (as if I were removing the same joint twice).

 

The strangest thing is that the error doesn't seem to happen if I debug and stepmanually run the step with F5 :/

Jan 4, 2011 at 5:27 AM

I also ran into that problem, and just commented the line out. You can also compile in release mode and it will be ignored.

In this new release when you remove something it gets added to a "ToRemove" list, and removed during update. When a body is removed all joints connected to the body are removed with it, and so they can get added to the list twice.

It is safe to comment it out. If genbox decides its appropriate, then i think it should be removed or improved in a future release.

Whats happening when you step manually is a bug. I havent noticed it myself, but saw this discussion after a quick search.

Jan 4, 2011 at 7:12 AM

Thanks Robertdodd! I indeed commented the line to temporary solve the problem, but it seems I will leave it commented :) 

Coordinator
Jan 6, 2011 at 11:26 PM

The data structure used is a hashset and thus the joint will only be removed once from the world. I created the assert to note the user about the removal of the same joint more than once, as it might be an implementation error.

When removing a body, all attached joints will be removed too. The joints should not get removed more than once internally in the engine.

Jan 22, 2011 at 8:19 PM
Genbox wrote:

The data structure used is a hashset and thus the joint will only be removed once from the world. I created the assert to note the user about the removal of the same joint more than once, as it might be an implementation error.

When removing a body, all attached joints will be removed too. The joints should not get removed more than once internally in the engine.

Sorry, but I just ran into this problem and it's a bug.  Below is code which shows the problem. This is not a realistic example, just enough to show the problem.

I know i can compile for release and it will go away or just comment out the line, but you should know it's a Bug.

On the second step you will get the assert (if in debug mode).  

 

		[Test]
public void Joints()
{
const float BodyWidth = 0.4f;
const float BodyHeight = 0.5f;
const float HeightOffset = 0.2f;
World world = new World(Vector2.Zero);

Body body1 = BodyFactory.CreateBody(world);
{
body1.BodyType = BodyType.Dynamic;
Vertices rectangleVertices = PolygonTools.CreateRectangle(BodyHeight, BodyWidth);
PolygonShape shape = new PolygonShape(rectangleVertices, 1.0f);
Fixture fixture = body1.CreateFixture(shape);
}
Body body2 = BodyFactory.CreateBody(world);
{
body2.BodyType = BodyType.Dynamic;
Vertices rectangleVertices = PolygonTools.CreateRectangle(BodyHeight, BodyWidth);
PolygonShape shape = new PolygonShape(rectangleVertices, 1.0f);
Fixture fixture = body2.CreateFixture(shape);
}
var joint = new RevoluteJoint(body1,body2,new Vector2(0,0),new Vector2(0,0));
world.AddJoint(joint);
world.Step(0.1f);
world.RemoveBody(body1);
world.RemoveBody(body2);
world.Step(0.1f);
}

 

Jan 22, 2011 at 9:56 PM

I found an issue in Farseer 3.2 for Silverlight and I'm not sure what causes it.

Seems to be a problem around the ComputeAABB function or rather the paramters supplied to the funtion when using polygons.

In the ComputeAABB the funtion MathUtils.Multiply fails with the message:

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

You can download a sample project from my site that demonstrates the problem:

http://www.casualgames.nu/download/InventionCompetition.zip

If you use Farseer 3.1 it works without any issue.

 


Coordinator
Jan 22, 2011 at 10:39 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
Jan 22, 2011 at 10:39 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
Jan 22, 2011 at 10:41 PM

I've copied the two issues described by jnkramer3 and Fredrik_ to the issue list.