I need Kinematic to Kinematic collision

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

I need Kinematic to Kinematic collision

Post by imtrobin »

Hi

I have a situation here. I have a building that does not move, so I set that to kinematic (nonDynamic) Entity. I have a plane I control, also kinematic, which I will turn to a dynamic entity after I collide with the building. So I would need kinematic to kinematic collision detection. That's how I could setup in PhysX, kinematic do not affect each other but collision detection are still generated but I can't do that now. What would be the better way to set it up?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: I need Kinematic to Kinematic collision

Post by Norbo »

For kinematic objects, you can make either them or a stand-in version of the object a detector and gather information that way. Otherwise, you could gather the collision pairs of an intangible stand-in object and perform specific queries on the gathered entities.

However, using a dynamic object could make things a lot easier in general until the entity interaction systems are revamped. You could turn off the dynamic entity's gravity (isAffectedByGravity flag on an entity) and do the same things you're doing now to kinematic objects, changing velocities/position as you see fit. You would no longer need it to change to dynamic on impact since it is already.
imtrobin
Posts: 101
Joined: Thu Jun 11, 2009 3:03 am

Re: I need Kinematic to Kinematic collision

Post by imtrobin »

This is probably similar to the kinematic entity with terrain thread. So you are saying to make another detecter entity to follow the kinematic entity?

If isAffectedByGravity =false, the plane entity is still affected by forces and torque, no? I'm using it like a kinematic controller, so it must not be affeced by other forces other than player's input. In PhysX, we cannot change positions of a dynamic entity, that's how I was "taught" to use a kinematic. Would the dynamic entity be ok e.g for a animated moving platform that floats in the air? This wouldn't be possible in PhysX without kinematic.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: I need Kinematic to Kinematic collision

Post by Norbo »

Yes, it is similar; making a detector follow the object would do it.

If you didn't need to worry about interactions much, using a kinematic object for what you want to do would make sense in the current version. However, since pretty much all of the problems you are encountering revolve around interaction, the few downsides associated with using a dynamic object in such a way could be dealt with.

If your plane is dynamic, it will indeed be affected by other forces/torques. However, while flying around, there aren't really any external forces to worry about unless there are other collisions (which could be disabled using nonCollidableEntities). Dynamic objects can still be teleported around using move/moveTo/centerPosition/internalCenterPosition. It may not be generally recommended to do so, but in this case it seems like it would be better than dealing with the alternative. When a collision happens that you want to respond to, you would need to stop trying to teleport the entity and ensure that its velocities are correct to allow for a correct collision response.

In that particular platform example, it would indeed be possible to use a dynamic object. There may be some additional difficulties if you choose to have objects fall onto and interact with that platform (to keep it stable you'd need to use constraints most likely), but otherwise it would be fine.
imtrobin
Posts: 101
Joined: Thu Jun 11, 2009 3:03 am

Re: I need Kinematic to Kinematic collision

Post by imtrobin »

I think I will use a detector to follow the kinematic. There are too many entities to add into the noncollidingentities as the game has a lot of entities.

For the platform it is still more ideal to have a kinematic that is able to have collision response. I hope this can be addressed in future versions.
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: I need Kinematic to Kinematic collision

Post by Norbo »

Just to be completely clear, you can have a kinematic platform with collision response.

The problems being encountered all revolve around getting kinematics to 'collide' (generate contacts) with kinematics, and secondarily getting objects like the StaticTriangleGroup and Terrain to produce triangles when a kinematic object approaches.

For the first problem:
-To create contacts between two kinematic entities currently, one must be a detector.
-Another approach to find collisions between kinematic entities is to create a dynamic intangible entity which follows one of the kinematic objects around and collects collision pairs with other nearby entities. There are multiple collision queries available in the Toolbox static class which can be then used to examine the collision pair entities.
-Another approach to find collisions between kinematic entities is to create a dynamic detector entity which follows one of the kinematic objects around. The difference between this approach and the dynamic intangible entity based approach is that, to determine the correct contacts, the detector entity must have the same geometry as the normal entity that it is following.

For the second problem, since using any active dynamic entity will trigger StaticTriangleGroups/Terrains to produce triangles:
-Use a dynamic entity instead of a kinematic entity
-Use an intangible dynamic entity which follows a kinematic entity
-Use a detector dynamic entity which follows a kinematic entity

Note that all of the solutions for the second problem are solutions for the first problem as well.

All of this stems from the fact that the engine's interaction rules weren't designed to directly address kinematic-kinematic interaction as dynamic interaction was the preferred method. With the upcoming generalization of this system, this sort of thing will be significantly easier.
imtrobin
Posts: 101
Joined: Thu Jun 11, 2009 3:03 am

Re: I need Kinematic to Kinematic collision

Post by imtrobin »

Great to hear that. I think for now, it seems the easiest to have a dynamic detector to follow the kinematic entity, and have the collision response there.
Post Reply