Collision Information

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
ronbunny
Posts: 3
Joined: Thu Oct 13, 2011 12:18 pm

Collision Information

Post by ronbunny »

which function can i do to check for overlapping bounding volumes?

CollisionRules.AddRule(toAdd, toAdd2, CollisionRule.NoBroadPhase);
toAdd.CollisionInformation.OverlappedCollidables.Contains(toAdd2.CollisionInformation) -> can i use this ?

i do not want them to have physics collision response but i want to do some other stuffs (if statement) when they overlap.
etc.. door portal..
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Collision Information

Post by Norbo »

You can indeed use the entity.CollisionInformation.OverlappedCollidables.Contains method to test if the collidables overlap.

Note that an 'overlapped' collidable means that the bounding boxes overlap. The pair does not necessarily have contacts.

In order to look at only collidables with which your object has contacts, go through the entity.CollisionInformation.Pairs list and look at the pair.Contacts.Count. If there's more than 1 contact, then they are colliding (with some subtleties that can usually be ignored).

If you were wondering, OverlappedCollidables is built on top of the that Pairs collection. The OverlappedCollidables enumerable goes through the list and returns the collidable in the pair that isn't the entity.CollisionInformation. In other words, it finds the 'opposing' collidable.
CollisionRules.AddRule(toAdd, toAdd2, CollisionRule.NoBroadPhase);
This will prevent the broad phase from creating a pair between the objects. In other words, toAdd2 will never be in the OverlappedCollidables of toAdd or vice versa.

If you want contacts to be created but no collision response, then CollisionRule.NoSolver would be the best option.
i want to do some other stuffs (if statement) when they overlap.
etc.. door portal..
Collision events might make this easier. They can be accessed in the entity.CollisionInformation.Events. More information can be found here: http://bepuphysics.codeplex.com/wikipag ... umentation
Post Reply