I'm looking for a way to notify objects in my world of collision with another object without having them move or be physically affected by the contact. This should be easy (it probably is and I'm just missing it); I thought I could achieve this by settting my CollisionObjectType to a CO_GHOST_OBJECT and setting btCollisionObject::CF_NO_CONTACT_RESPONSE flag when creating my sphere collision, but it doesn't seem to change anything.
Am I missing something?
Thanks in advance.
Want a collision detection notification without the physics
-
- Posts: 14
- Joined: Mon Feb 23, 2009 9:01 am
-
- Posts: 229
- Joined: Sun Sep 30, 2007 7:58 am
Re: Want a collision detection notification without the physics
Hi,
you don't need actually a ghost object for that. Just setting NO RESPONSE is enough. You can get the contact manifolds but no interaction will occur. Be also sure to make that object kinematic so that physics doesn't affects it.
Ghost objects are only needed if you want to keep track about all contacts without having to go through all manifolds.
you don't need actually a ghost object for that. Just setting NO RESPONSE is enough. You can get the contact manifolds but no interaction will occur. Be also sure to make that object kinematic so that physics doesn't affects it.
Ghost objects are only needed if you want to keep track about all contacts without having to go through all manifolds.
-
- Posts: 14
- Joined: Mon Feb 23, 2009 9:01 am
Re: Want a collision detection notification without the physics
Thanks that worked perfectly!
---- EDIT ----
The above did not end up working. The explanation is in the 6th post in this thread.
---- EDIT END ----
One more question: I'm trying to simulate an explosion blast zone by creating btSphereShape, with a size of 1.0, and updating its local scaling (from 1.0 to 1300.0) over a period of a couple of seconds. This worked fine with my old (non kinematic) object, but now that the object is kinematic it seems to ignore the scaling and remains at its size of 1.0.
Does anyone know if anything special needs to be done to scale a kinematic object?
---- EDIT ----
The above did not end up working. The explanation is in the 6th post in this thread.
---- EDIT END ----
One more question: I'm trying to simulate an explosion blast zone by creating btSphereShape, with a size of 1.0, and updating its local scaling (from 1.0 to 1300.0) over a period of a couple of seconds. This worked fine with my old (non kinematic) object, but now that the object is kinematic it seems to ignore the scaling and remains at its size of 1.0.
Does anyone know if anything special needs to be done to scale a kinematic object?
Last edited by wbaldwin on Thu Jul 02, 2009 10:11 am, edited 2 times in total.
-
- Posts: 229
- Joined: Sun Sep 30, 2007 7:58 am
Re: Want a collision detection notification without the physics
Hi,
i'm not sure if this works at all (scaling at runtime). If yes, then the problem could be that the kinematic object is set to inactive state. If this is the case then its AABB is no more updated. You can call updateAABB or set it active. Maybe this helps.
i'm not sure if this works at all (scaling at runtime). If yes, then the problem could be that the kinematic object is set to inactive state. If this is the case then its AABB is no more updated. You can call updateAABB or set it active. Maybe this helps.
-
- Posts: 14
- Joined: Mon Feb 23, 2009 9:01 am
Re: Want a collision detection notification without the physics
I didn't really get the scaling to work all that well, so just wrote up my own simple collision detection for explosions which basically did the trick.
I have one different but related quesion: how would one go about setting up a situation where when a kinematic object collides into a character controller no collision physics occur, but the objects are notified of the collision?
In my shooting game I'm using character controllers for all of the player and enemy characters, and the bullets are all kinematic. I can't make the character controllers kinematic as well, because I need the collision physics to be present when characters collide into themselves and other objects located throughout the stage.
Thanks in advance!
I have one different but related quesion: how would one go about setting up a situation where when a kinematic object collides into a character controller no collision physics occur, but the objects are notified of the collision?
In my shooting game I'm using character controllers for all of the player and enemy characters, and the bullets are all kinematic. I can't make the character controllers kinematic as well, because I need the collision physics to be present when characters collide into themselves and other objects located throughout the stage.
Thanks in advance!
-
- Posts: 14
- Joined: Mon Feb 23, 2009 9:01 am
Re: Want a collision detection notification without the physics
I've realized that the above response of "setting the btCollisionObject::CF_NO_CONTACT_RESPONSE flag on an object and making it kinematic" indeed does not give me my desired result.
When a kinematic object is set to no contact response, it is alerted of any contact, but still responds to the collision (this is true for ACTIVE_TAG, ISLAND_SLEEPING, WANTS_DEACTIVATION, and DISABLE_DEACTIVATION). Setting the activation state to DISABLE_SIMULATION stops the object from responding to collision, which is what I want, but then the contact is alerted only an extremely small percentage of the time.
All I want is to be alerted of collision without any physical action being taken on the object.
Please help. Thanks in advance, its really appreciated.
When a kinematic object is set to no contact response, it is alerted of any contact, but still responds to the collision (this is true for ACTIVE_TAG, ISLAND_SLEEPING, WANTS_DEACTIVATION, and DISABLE_DEACTIVATION). Setting the activation state to DISABLE_SIMULATION stops the object from responding to collision, which is what I want, but then the contact is alerted only an extremely small percentage of the time.
All I want is to be alerted of collision without any physical action being taken on the object.
Please help. Thanks in advance, its really appreciated.
-
- Posts: 6
- Joined: Wed Jun 01, 2011 1:41 pm
Re: Want a collision detection notification without the phys
Sorry for the revive, but I am facing the excact problem, and I cant seem to find a solution.
Here is what I am doing:
initiating an object:
The result is that the physichs still work on the object, meaning if I shoot a bullet the bullet will push the target away, which is not what I want.
Here is what I am doing:
initiating an object:
Code: Select all
ghostObject = new btPairCachingGhostObject();
bulletCollisionShape = new btSphereShape(1.0f);
ghostObject->setCollisionShape(bulletCollisionShape);
ghostObject->setCollisionFlags(ghostObject->getCollisionFlags() | btCollisionObject::CF_KINEMATIC_OBJECT | btCollisionObject::CF_NO_CONTACT_RESPONSE);
bulletDynamicsWorld->addCollisionObject(ghostObject, btBroadphaseProxy::CharacterFilter, btBroadphaseProxy::CharacterFilter|btBroadphaseProxy::StaticFilter|btBroadphaseProxy::DefaultFilter);
-
- Posts: 4
- Joined: Wed Jun 15, 2011 2:43 pm
-
- Posts: 6
- Joined: Wed Jun 01, 2011 1:41 pm
Re: Want a collision detection notification without the phys
It didn't.
However, I found out the problem wasn't in ghost object afterall, it was in its action; the btKinematicCharacterController.
to fix this: http://bulletphysics.org/Bullet/phpBB3/ ... 984d83e599
However, I found out the problem wasn't in ghost object afterall, it was in its action; the btKinematicCharacterController.
to fix this: http://bulletphysics.org/Bullet/phpBB3/ ... 984d83e599
-
- Posts: 11
- Joined: Wed Jun 22, 2011 3:15 pm
Re: Want a collision detection notification without the phys
How about....
Instead of of using the Bullet SDK provided btGhostPairCallback to report overlaps to the Ghost objects, try creating a narrow phase callback that listens for Ghost Objects and filters them out of the narrow phase step...
void CustomNearCallback( btBroadphasePair& collisionPair,
btCollisionDispatcher& dispatcher,
const btDispatcherInfo& dispatchInfo)
{
btCollisionObject* colObj0 = (btCollisionObject*) collisionPair.m_pProxy0->m_clientObject;
btCollisionObject* colObj1 = (btCollisionObject*) collisionPair.m_pProxy1->m_clientObject;
btGhostObject* ghost0 = btGhostObject::upcast(colObj0);
btGhostObject* ghost1 = btGhostObject::upcast(colObj1);
if (!ghost0 && !ghost1)
{
dispatcher.defaultNearCallback(collisionPair, dispatcher, dispatchInfo); // ghosts will not affect other rigidbodies
}
else
{
// add your ghost overlap callbacks here so ghostObjects can
// ghost(0/1)->addOverlappingObjectInternal(proxy1, proxy0);
}
}
..
mDispatcher->setNearCallback(CustomNearCallback);
Instead of of using the Bullet SDK provided btGhostPairCallback to report overlaps to the Ghost objects, try creating a narrow phase callback that listens for Ghost Objects and filters them out of the narrow phase step...
void CustomNearCallback( btBroadphasePair& collisionPair,
btCollisionDispatcher& dispatcher,
const btDispatcherInfo& dispatchInfo)
{
btCollisionObject* colObj0 = (btCollisionObject*) collisionPair.m_pProxy0->m_clientObject;
btCollisionObject* colObj1 = (btCollisionObject*) collisionPair.m_pProxy1->m_clientObject;
btGhostObject* ghost0 = btGhostObject::upcast(colObj0);
btGhostObject* ghost1 = btGhostObject::upcast(colObj1);
if (!ghost0 && !ghost1)
{
dispatcher.defaultNearCallback(collisionPair, dispatcher, dispatchInfo); // ghosts will not affect other rigidbodies
}
else
{
// add your ghost overlap callbacks here so ghostObjects can
// ghost(0/1)->addOverlappingObjectInternal(proxy1, proxy0);
}
}
..
mDispatcher->setNearCallback(CustomNearCallback);
-
- Posts: 11
- Joined: Wed Jun 22, 2011 3:15 pm
Re: Want a collision detection notification without the phys
... or you can leave ghost->addOverlappingObjectInternal(proxy1, proxy0) out of the narrow phase callback completely and still rely on the btGhostPairCallback provided by Bullet.
That will be more efficient.
Cheers
That will be more efficient.
Cheers
-
- Posts: 6
- Joined: Wed Aug 08, 2012 7:24 pm
Re: Want a collision detection notification without the phys
A simple solution can be found at the bottom of : http://bulletphysics.org/mediawiki-1.5. ... d_Triggers
It worked for me while using ghost objects as a trigger volume:
mBody->setCollisionFlags(mBody->getCollisionFlags()|btCollisionObject::CF_NO_CONTACT_RESPONSE);
Cheers,
It worked for me while using ghost objects as a trigger volume:
mBody->setCollisionFlags(mBody->getCollisionFlags()|btCollisionObject::CF_NO_CONTACT_RESPONSE);
Cheers,