I am quite new to mesh striders but I have modified it to fit into my program, the trouble is, when I create a Rigidbody with a btBvhTriangleMeshShape and set the third parameter to false, the object does not collide with anything. When i set it to true, the program crashes, pointing to btQuantizedBvh.h to this line:
Code: Select all
SIMD_FORCE_INLINE void quantize(unsigned short* out, const btVector3& point,int isMax) const
...........
out[0] = (unsigned short) (((unsigned short)(v.getX()) & 0xfffe));
When logging the CollisionShape's calculateSerializeBufferSize() result, I get a value of 60, when using ogrehead.mesh as the model (http://tatis3.springnote.com/pages/1004 ... nts/422906). not sure if this is saying anything?
Here are the functions in my code that i think matter, can post more later if necessary:
The class which creates and holds pointers to the bullet classes for creating the rigidbody
Code: Select all
class bulObj {
public:
bulObj(){
type =-1;
}
//~bulObj();
void newRigid(int obid, int instid, objectTable * obTblPtr, renderSystem * rsyPtr, btDiscreteDynamicsWorld * wrld, ogreMeshStrider * strid){//, std::string meshLoc){
objID = obid;
instID = instid;
dynamicz = wrld;
objTblPtr = obTblPtr;
rsysPtr = rsyPtr;
ogMeshStrd = strid;
if(type != -1){;
//break;
}
else{
type = 0;
testobj = new bulletPhysMState(objID, instID, objTblPtr, rsysPtr);
mass =1;
fallIntertia = btVector3(0,0,0);
//fallShape = new btGImpactMeshShape(ogMeshStrd);
//fallShape = new btSphereShape(1);
fallShape = new btBvhTriangleMeshShape(ogMeshStrd,true,false);
fallShape->calculateLocalInertia(mass,fallIntertia);
btRigidBody::btRigidBodyConstructionInfo fallRigidBodyCI(mass,testobj,fallShape,fallIntertia);
fallRigidBody = new btRigidBody(fallRigidBodyCI);
dynamicz->addRigidBody(fallRigidBody);
}
}
private:
btScalar mass;
btVector3 fallIntertia;
int objID, instID;
int type; // 0 Rigidbody
bulletPhysMState* testobj;
btCollisionShape* fallShape;
btRigidBody* fallRigidBody;
renderSystem * rsysPtr;
objectTable * objTblPtr;
btDiscreteDynamicsWorld * dynamicz;
ogreMeshStrider * ogMeshStrd;
};
In this code, I am confident that the objTblPtr code is working correctly. It is something I have designed myself to handle positions of objects so that I can keep Ogre and Bullet as separate as possible.
Code: Select all
std::map <int, bulObj*> bulObjMap;
std::map <int, ogreMeshStrider*> meshSMap;
void addMesh(int objid, int instid){
if(meshSMap.find(objid) == meshSMap.end()){
Ogre::Mesh * ogMesh = rsysPtr->getMesh(objTblPtr->getInstGFXID(objid, instid));
meshSMap[objid] = new ogreMeshStrider(ogMesh);
}
}
//the code which calls the create rigid body routine shown earlier. returns the integer ID of the rigidbody for
//one of my own systems to handle
int newRigidB(int objID, int instID){
int tmp =0;
while(bulObjMap.find(tmp) != bulObjMap.end()){
tmp++;
}
bulObjMap[tmp]->newRigid(objID, instID, objTblPtr, rsysPtr, dynamicsWorld, meshSMap[objID]);
return tmp;
}
Does anybody have any suggestions?