I have a discrete dynamics world with a static plane as as floor, a few dynamic objects and a kinematic object as the player. I'm iterating over all contact manifolds and I can't detect the collisions between the kinematic object and the floor (the other collisions are detected fine).
Do I need to do something different to detect this kind of collisions or am I doing something wrong?
Collision between kinematic and static objects
-
- Posts: 79
- Joined: Tue Sep 26, 2006 1:10 pm
Re: Collision between kinematic and static objects
I believe you have to detect collision between kinematic and static objects by your self. Maybe you can find some inspiration in the character control demo?
-
- Posts: 10
- Joined: Mon Oct 27, 2008 9:31 am
Re: Collision between kinematic and static objects
The character demo uses a ghost object to detect collisions. In my case it needs to interact with dynamic objects so it has to be kinematic.
-
- Posts: 133
- Joined: Wed Jul 27, 2005 1:05 pm
- Location: Berkeley, CA
Re: Collision between kinematic and static objects
Jonan,
The kinematic character controller does interact with dynamic objects. Dynamic objects will bounce off the KCC and the KCC will move around dynamic objects. The KCC could be extended to say "kick" the dynamic objects instead of moving around them (like static walls.) Kinematic objects are essentially programmatically animated objects, it is up to you to program the behaviour you want when using them.
HTH,
John
The kinematic character controller does interact with dynamic objects. Dynamic objects will bounce off the KCC and the KCC will move around dynamic objects. The KCC could be extended to say "kick" the dynamic objects instead of moving around them (like static walls.) Kinematic objects are essentially programmatically animated objects, it is up to you to program the behaviour you want when using them.
HTH,
John
-
- Posts: 10
- Joined: Mon Oct 27, 2008 9:31 am
Re: Collision between kinematic and static objects
Really? I thought ghost objects only detected their own collisions and didn't interact with rigid bodies so this had to be done manually.John McCutchan wrote:The kinematic character controller does interact with dynamic objects.
In fact, in the CharacterDemo the character doesn't interact with dynamic objects. I've just tried it and when colliding with a dynamic body this message is displayed:
CharacterDemo: ./src/LinearMath/btQuaternion.h:188: btQuaternion& btQuaternion::operator/=(const btScalar&): Assertion `s != btScalar(0.0)' failed.
Aborted
-
- Posts: 5
- Joined: Fri Apr 18, 2008 11:20 am
Re: Collision between kinematic and static objects
When you shoot a bullet at the character in the character demo, the app crashes.
-
- Posts: 10
- Joined: Mon Oct 27, 2008 9:31 am
Re: Collision between kinematic and static objects
That's my point.Xilliah wrote:When you shoot a bullet at the character in the character demo, the app crashes.
I need my character to interact with both dynamic and static objects, but I can't manage to detect the collisions between static and kinematic objects
-
- Posts: 19
- Joined: Fri Sep 05, 2008 8:54 pm
Re: Collision between kinematic and static objects
In my personal experience there are a few things which have to be done in order to trigger collision detection between kinematic & static objects and to populate the contact manifold with these objects as well included
The mass has to be set to some value for these objects and then the collision filter mask has to be enabled by the following piece of code....after the rigid body has been added to the world
float mass = 10; // or some valid value
btRigidBody::btRigidBodyConstructionInfo rbdinfo( mass,
motionstate,
shape,
localInertia );
btRigidBody* rbdobj = new btRigidBody( rbdinfo );
world->addRigidBody( rbdobj );
it rbdobj is of type btRigidBody *
btBroadphaseProxy *bproxy = rbdobj->getBroadphaseHandle();
if( bproxy ) {
bproxy->m_collisionFilterGroup = short( btBroadphaseProxy::DefaultFilter );
bproxy->m_collisionFilterMask = short( btBroadphaseProxy::AllFilter );
}
bullet doesn't add objects to the simulation island if both objects in the manifold are kinematic/static, so either you can turn off using islands in the solver info or you have to modify btCollisionObject::mergesSimulationIslands() has to return true if you want to do collision responses....all this is basically treating Static/Kinematic collisions as a regular Dynamic/Dynamic collision but they dont have their velocities or positions updated.
at this point the manifolds have the proper collision information.
hope this helps.
Thanks,
Ram.
The mass has to be set to some value for these objects and then the collision filter mask has to be enabled by the following piece of code....after the rigid body has been added to the world
float mass = 10; // or some valid value
btRigidBody::btRigidBodyConstructionInfo rbdinfo( mass,
motionstate,
shape,
localInertia );
btRigidBody* rbdobj = new btRigidBody( rbdinfo );
world->addRigidBody( rbdobj );
it rbdobj is of type btRigidBody *
btBroadphaseProxy *bproxy = rbdobj->getBroadphaseHandle();
if( bproxy ) {
bproxy->m_collisionFilterGroup = short( btBroadphaseProxy::DefaultFilter );
bproxy->m_collisionFilterMask = short( btBroadphaseProxy::AllFilter );
}
bullet doesn't add objects to the simulation island if both objects in the manifold are kinematic/static, so either you can turn off using islands in the solver info or you have to modify btCollisionObject::mergesSimulationIslands() has to return true if you want to do collision responses....all this is basically treating Static/Kinematic collisions as a regular Dynamic/Dynamic collision but they dont have their velocities or positions updated.
at this point the manifolds have the proper collision information.
hope this helps.
Thanks,
Ram.
-
- Posts: 5
- Joined: Wed Jan 14, 2009 1:14 pm
Re: Collision between kinematic and static objects
I'm getting the same problem with the same exception being thrown. This is the second thread I've seen with people with this problem. Is there any solutions?Xilliah wrote:When you shoot a bullet at the character in the character demo, the app crashes.
I compiled the demo using MSVC 9 and the Debug build. The other demos work fine. Please help.
-
- Posts: 5
- Joined: Wed Jan 14, 2009 1:14 pm
Re: Collision between kinematic and static objects
Ok I think I've solved it, all you have to do is change the code on line 87 of the CharacterDemo.cpp file fromJonan wrote:Really? I thought ghost objects only detected their own collisions and didn't interact with rigid bodies so this had to be done manually.John McCutchan wrote:The kinematic character controller does interact with dynamic objects.
In fact, in the CharacterDemo the character doesn't interact with dynamic objects. I've just tried it and when colliding with a dynamic body this message is displayed:CharacterDemo: ./src/LinearMath/btQuaternion.h:188: btQuaternion& btQuaternion::operator/=(const btScalar&): Assertion `s != btScalar(0.0)' failed.
Aborted
Code: Select all
m_ghostObject->setCollisionFlags (btCollisionObject::CF_CHARACTER_OBJECT);
Code: Select all
m_ghostObject->setCollisionFlags (btCollisionObject::CF_KINEMATIC_OBJECT);