Request for capsules/cylinders fix

BenM

04-01-2011 02:41:43

I posted a problem here which I had creating CylinderCollisionShapes and CapsuleCollisionShapes. However, I just found the answer to the problem.

I'd still like to draw attention to OgreBulletCollisionCollisionsCapsuleShape.cpp:

The constructor of an OgreBullet capsule consists of an if / else if / else if structure. If the axis passed to it is equal to a Unit X Vector, the bullet shape is constructed one way; if a Unit Y vector, another way; and if a Unit Z Vector, a third way.
However, if someone (like me just now) passes as the third parameter a Vector3 which is equivalent to none of these unit vectors, mShape goes uninitialised. And the problem isn't obvious, since the code compiles and everything. I thought for ages that it was just one part of the mShape going uninitialised.

In this instance, would it be a problem to add a default 'catch' to the code, to make sure mShape is initialised, or to throw some sort of error? e.g. if the vector passed is equal to none of the 3 unit vectors, make it default to Unit X or something.

Just for reference, here is my original post.

Is anybody else unable to add capsule and cylinder collision shapes?

I used the exact same methods to create cubes and spheres, but used CylinderCollisionShape and CapsuleCollisionShape.

They are constructed fine, as are the rigid bodies I'm trying to attach them to, but whenever I call setShape() on the RigidBody, it causes an error. Debugging shows btCollisionShape::getShapeType() is returning no value (or possibly a bad value), causing the program to crash. I think Bullet has somehow failed to initialise m_shapeType. Curiously, even when I disable the problematic debugDrawer which I thought was behind it, it still crashes when I try to create the shape (but again, spheres and cubes work fine).

Technical details of debug trace:
The problem starts at line 80 of OgreBulletDynamicsRigidBody.cpp, where showDebugShape is called. I can then trace the problem to OgreBulletCollisionsObject, where the showDebugShape() function calls "new DebugCollisionShape(mShape)", then "shape->drawWireFrame(this)" in OgreBulletCollisionsDebugShape, and it eventually bottoms out in the isConvex() function in btCollisionShape.h, which calls getShapeType() and fails.

Has anybody else had a problem like this? I'm using the stable Ogre 1-7-2, bullet 2.76, and the latest OgreBullet.

Fish

06-01-2011 13:30:20

This constructor issue has been discussed here: viewtopic.php?f=12&t=13540&p=76140#p76133 . As soon as someone submits a patch to the patch tracker I'll be happy to merge it in.

- Fish