Kinematic Trigger box bug.

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
imtrobin
Posts: 101
Joined: Thu Jun 11, 2009 3:03 am

Kinematic Trigger box bug.

Post by imtrobin »

Hi

I seem to encounter a bug with kinematic box triggers. I have it defined like so

centerOfMassOffset = "0, 0, 0"
height = "30"
isAffectedByGravity = "false"
isAlwaysActive = "true"
isTrigger = "true"
isTangible = "true"
length = "350"
mass = "0"
width = "50"

And i register the eventhooks on EventHandlerInitialCollisionDetected and EventHandlerCollisionEnded. When I collide a kinematic entity on it, the events are fired wrongly when I use Displayobject to see the collision debug physics. I can get a CollisionEnd event even though I'm still inside the box. If I use a kinematic sphere trigger, there is no problem.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Kinematic Trigger box bug.

Post by Norbo »

The problem may be partly caused by the size of the box (which is quite large). Some entity type pairs are more stable than others. Spheres, with other spheres, boxes, or triangles, are extremely stable due to their special cases. Box-box also has a special case, but is probably not as universally stable as sphere-based special cases.

You can try enabling and disabling the special cases in the space.simulationSettings.use...SpecialCase flags. Note that in v0.10.0, these were replaced by a public dictionary containing entity type pairs associated with collision handler methods for extensibility.

Another thing to watch out for in general (not necessarily causing your current problem) is the possibility that an entity can move out of both collision and bounding box overlap in a single frame. This will trigger some deferred events, like collision ended, where the collision pair is invalid. To address this, v0.10.0 includes an 'immediate' version of every event and changes some of the deferred event parameters to be safer.
imtrobin
Posts: 101
Joined: Thu Jun 11, 2009 3:03 am

Re: Kinematic Trigger box bug.

Post by imtrobin »

I'm collide a sphere kinematic entity with the box kinematic trigger entity. I set the special case, no difference. I think there's a bug somewhere because the trigger is generating an collision and exit with itself once at start of the program. The sphere kinematic trigger don't have this problem.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Kinematic Trigger box bug.

Post by Norbo »

I can't think of any reason why that would happen other than objects being added to the space initially in collision. When a new entity is added to the DynamicBinaryHierarchy broadphase, it collects collision pairs so it is possible that there are collision pairs created at the beginning even if you move the objects away from each other immediately afterward.

A stripped down reproduction case would help me diagnose the problem.
imtrobin
Posts: 101
Joined: Thu Jun 11, 2009 3:03 am

Re: Kinematic Trigger box bug.

Post by imtrobin »

The self colliding was a false alarm, sorry about that. It was related to this issue and I had inserted a update call in between moving the entities.

http://www.bepu-games.com/forums/viewto ... ?f=4&t=513

However, I'm still having the problem. The kinematic trigger is the box, the kinematic sphere is going down from the top. These are the centerposition of the entities when the trigger is fired

EventRunwayCollisionEnter:
box trigger {X:6865.7 Y:0 Z:7495.7}
sphere {X:6865.7 Y:25.04716 Z:7495.7}

EventRunwayCollisionExit:
box trigger {X:6865.7 Y:0 Z:7495.7}
sphere {X:6865.7 Y:14.91115 Z:7495.7}

The dimensions are box height = 30, sphere radius = 10. You can see the enter is correct, but the Exit should not be fired.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Kinematic Trigger box bug.

Post by Norbo »

I was able to replicate this when space.simulationSettings.useSpecialCaseBoxSphere = true, but not after I disabled it. The special case for box-sphere actually gets rid of contacts when the center position of the sphere is contained within the box, accounting for the strange behavior. I should be able to get this fixed for v0.10.0. In the mean time, try disabling the box-sphere special case.
imtrobin
Posts: 101
Joined: Thu Jun 11, 2009 3:03 am

Re: Kinematic Trigger box bug.

Post by imtrobin »

Another similar issue, I have the setup, a dynamic box and a kinematic sphere trigger. When the box falls through the trigger, there are two enter/leave events although they only go through each other once.

The box is placed directly on top of the trigger and falls through it once.

Code: Select all

                Entity box = new Box (new Vector3 (400, 1900, 400), 10, 10, 20, 20);
                box.isAlwaysActive = true;
                box.isTangible = true;
                space_.add (box);

                // set position
                //box.centerPosition = new Vector3 (400, 800, 400);

                box.activate ();

                sphere_ = new Sphere (new Vector3 (400, 1200, 400), 3.5f, 2);
                sphere_.isAlwaysActive = true;
                sphere_.makeNonDynamic ();
                sphere_.isTangible = true;
                sphere_.isAffectedByGravity = false;
                sphere_.isDetector = true;
                sphere_.addEventHook (new EventHandlerInitialCollisionDetected (EventInitialCollisionDetected));
                sphere_.addEventHook (new EventHandlerCollisionEnded (EventCollisionEnded));
                space_.add (sphere_);


imtrobin
Posts: 101
Joined: Thu Jun 11, 2009 3:03 am

Re: Kinematic Trigger box bug.

Post by imtrobin »

great. I didn't see your reply when I posted the other setup
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Kinematic Trigger box bug.

Post by Norbo »

I believe that is the same issue as before with the box-sphere special case. The box touches the sphere, overlaps the center, then moves back out to a touching state. During the overlap, there is no contact. The enter and exit each have contacts, triggering double enter-exit events.

Edit:
:D
Post Reply