What replaced BulletSharp.ContactAdded?

233 views Asked by At

I recently updated my project's physics library (BulletSharp) from 2.80 to 2.82 and I was left with a bunch of invalid calls (had around 20 build errors in the debug drawer). I've fixed nearly all of them apart from a collision detection call.

From CollisionReporter.cs:

PhysicsMain.PreSimulate += new PhysicsSimulateEvent(PreSimulate);
PhysicsMain.PostSimulate += new PhysicsSimulateEvent(PostSimulate);
PhysicsMain.ContactAdded += new ContactAdded(ManifoldPoint_ContactAdded);
LevelManager.OnLevelUnload += new LevelEvent(OnLevelUnload);

Which then calls this from the CreateWorld() function in PhysicsMain.cs:

ManifoldPoint.ContactAdded += new ContactAdded(ManifoldPoint_ContactAdded);

I've also got this line near the top of PhysicsMain.cs:

public static event ContactAdded ContactAdded;

I should also point out ManifoldPoint_ContactAdded() is a boolean.

bool ManifoldPoint_ContactAdded(ManifoldPoint point, ... ) {

The problem I'm having with it is Bullet (BulletSharp anyway) stopped using BulletSharp.ContentAdded which broke the calls. The documentation offers no insight as to what replaces them instead.

Does anybody know what I have to use instead of BulletSharp.ContactAdded?

Edit: This seems to throw a "no overload matches delegate" error in PhysicsMain.cs.

PhysicsMain.ContactMade += ContactMade;

I think this is to blame:

public static event /*ContactAdded*/ ContactAddedEventHandler ContactMade;
1

There are 1 answers

3
Andres Traks On BEST ANSWER

The ContactAdded delegate was renamed to ContactAddedEventHandler to match .NET standards. You only need to write the name of the handler method though, so both of these are correct:

ManifoldPoint.ContactAdded += new ContactAddedEventHandler(ManifoldPoint_ContactAdded);
ManifoldPoint.ContactAdded += ManifoldPoint_ContactAdded;

Events in .NET typically don't return any values, because several methods could be hooked up to the event and return different values. This is different from C++ where a single method is set as the handler. Since Bullet doesn't currently use the bool return value, void is used instead. So your method should be void and not return any value.

I think BulletSharp only recently got to a point in development where such breaking changes could be considered a bad thing. Sorry about that anyway.