CreatingContact event fires, but ContactCreated doesn't

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Abuzer
Posts: 20
Joined: Thu Jan 19, 2012 4:12 pm

CreatingContact event fires, but ContactCreated doesn't

Post by Abuzer »

Hi,

I'm relatively new to BEPU, so I might be missing something really simple.

In my app, I added a new collidable shape type to BEPU that is similar to the terrain shape and is not movable. When I assign an event handler to this collidable's Events.CreatingContact, it calls the function as expected, but when I assign an event handler to Events.ContactCreated, it never gets called. I should also mention that similarly, when I use Events.DetectingInitialCollision, it fires off, but Events.InitialCollisionDetected doesn't which makes me think that there's something wrong with the way the deferred events are supposed to fire off, probably related to the way I'm using it...

Any info on this issue would be appreciated.

Thanks
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: CreatingContact event fires, but ContactCreated doesn't

Post by Norbo »

This can happen when the DeferredEventDispatcher doesn't know about the deferred event creator (the collidable's event manager). For whatever reason, when the collidable is being added to the Space, the event manager isn't being handed over. Is it set up after the fact in a way that would bypass the dispatcher? Is the event manager actually owned by another object, perhaps child objects, which the deferred event dispatcher does not know about directly?

You could try giving the event manager directly to the space's DeferredEventDispatcher and see if it yells about it already being added or if it is fixed.
Abuzer
Posts: 20
Joined: Thu Jan 19, 2012 4:12 pm

Re: CreatingContact event fires, but ContactCreated doesn't

Post by Abuzer »

Thanks for the quick response.

My other uses of the deferred events work fine in the cases I'm assigning them to event handlers on compound collidables. As far as I checked, it only seems to be problematic with my new collidable type.

I didn't mess with the event manager, so I don't know why there would be a disconnect between the event creator and the dispatcher. I didn't try it, but I wonder if the Terrain type has the same "problem" (perhaps because it's a static collidable - just a wild guess).

When it comes to these deferred events, I'm hoping that the order I add a handler to a collision event vs adding the collidable to the space does not matter...

I'll debug into the guts of BEPU to see where it's bailing out of the event callback because I realize it's tough for you to try to guess what might be busted if something is wrong in the new collidable type I personally added.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: CreatingContact event fires, but ContactCreated doesn't

Post by Norbo »

but I wonder if the Terrain type has the same "problem" (perhaps because it's a static collidable - just a wild guess).
You'd be right :) It's fixed now in the development version by giving the static objects the IDeferredEventCreatorOwner implementation.
Abuzer
Posts: 20
Joined: Thu Jan 19, 2012 4:12 pm

Re: CreatingContact event fires, but ContactCreated doesn't

Post by Abuzer »

Yup. I was just typing a reply for the same fix, but you beat me to the punch :)

Thanks a bunch.
Post Reply