kaworu1986
19-06-2008 12:29:13
I am using OgreODE for collision detection in the platform game I am making and am encountering a huge issue: after stepping the world I get some callbacks with collision information, however not all collisions are being detected.
More specifically, collisions between objects in the level,represented as static box geometries, and the terrain, a static trimesh , are being detected (a lot of times per every object, I might add), while collisions between the static boxes aren't.
Does anyone have ideas regarding what I am doing wrong?
If it can help, I am only using the library for collision detection (I always return false in the callbacks)
rewb0rn
19-06-2008 13:39:02
so by static you mean they have no bodies? Have your turned on the debug boxes to see if they really intersect? Also make sure that you don't use an extra space for the boxes that doesn't detect internal collisions. (setInternalCollisions(bool))
kaworu1986
19-06-2008 13:51:25
Well, I mean static as in I am creating them using the EntityInformer::createSingleStaticBox method, but I am also not creating bodies for them.
If my understanding of how ODE works is correct I would only need bodies if I wanted ODE to handle collision response according to its physical simulation.
So far, I am using a single space, the default one, to hold all the geometries.
Happy-Howard
19-06-2008 14:02:08
Since you crossposted I'll add my comment to this thread instead.
Did you specify the category bitfield and the collision bitfield in the correct way on the geometries? Take a look at this sample code
enum QueryFlags
{
ANY_QUERY_MASK = 1<<0,
GEOMETRY_QUERY_MASK = 1<<2,
STATIC_GEOMETRY_QUERY_MASK = 1<<4
};
OgreOde::Geometry* geometry = 0;
OgreOde::EntityInformer ei(pEntity);
geometry = ei.createStaticTriangleMesh(OgreOde::World::getSingletonPtr()->getDefaultSpace());
geometry->setCategoryBitfield(STATIC_GEOMETRY_QUERY_MASK);
geometry->setCollisionBitfield(GEOMETRY_QUERY_MASK);
The OgreOde::Geometry in this example is of the category "STATIC_GEOMETRY_QUERY_MASK" and will only collide with object of the category "GEOMETRY_QUERY_MASK". Should this object collide with another of the category "STATIC_GEOMETRY_QUERY_MASK" the callback would not be called.
See
http://opende.sourceforge.net/mediawiki-1.6.10/index.php/Manual_%28Collision_Detection%29#Category_and_Collide_Bitfields to learn about the category and collision bitfields.
(a lot of times per every object, I might add)
This is normal. As long as two geometries has contact the callback will be called. ODE (or OgreOde for that matter) has no concept of "beginCollision" or "endCollision". You have to write that for your self.
kaworu1986
19-06-2008 14:40:46
Thanks for your reply! While what you suggested didn't solve my problem, it will be useful in avoiding callbacks I don't need to deal with.
After some more mucking about in the code, I have found out that the reason why geometries don't collide is that they aren't moved around along with the entities visually representing them.
I had thought setting the geometries as user object to their respective entities accomplished just that, but it seems I was mistaken.
The problem now becomes to sync their positions: while OgreODE::geometries have a setposition method, it seems that calling it (outside of the callback, of course) has the effect of preventing ODE from initiating callbacks.
Do I then have to create bodies for ODE geometries just to move them around the scene? The way I understood it was that I needed to do so only if I wanted ODE to handle the physics simulation.
Happy-Howard
19-06-2008 14:56:12
it seems that calling it (outside of the callback, of course) has the effect of preventing ODE from initiating callbacks.
I haven't had that problem at all... you shouldn't have to create bodies.
kaworu1986
19-06-2008 15:24:55
Gave the method another try and it worked ^^! I really don't know what I was doing wrong before.
Anyways, thanks to both of you for the help! I was going crazy over this issue.