Has anyone ran into a problem where the btGhostObjects pair array isn't initialized correctly?
I've been trying to set up a simply demo of a ghostObject and one rigid body passing through it.
My ghostObj->getNumOverlappingPairs() always return me the value of 0xcdcdcdcd.
this is my set up code for the ghostObj
Code: Select all
//create ghost object
ghostObj = new btGhostObject();
btCollisionShape* shape = new btBoxShape(btVector3(5,5,5));
ghostObj->setCollisionShape(shape);
btTransform trans;
trans.setIdentity();
trans.setOrigin(btVector3(0,6,0));
//btQuaternion quat;
//quat.setEuler(45,45,45);
//trans.setRotation(quat);
ghostObj->setWorldTransform(trans);
ghostObj->setCollisionFlags(ghostObj->getCollisionFlags() | btCollisionObject::CF_NO_CONTACT_RESPONSE);
ghostObj->getOverlappingPairs().size(); //this returns value of 0xcdcdcdcd and not 0
czGetDynamicsWorld()->addCollisionObject(ghostObj);
czGetDynamicsWorld()->getBroadphase()->getOverlappingPairCache()->setInternalGhostPairCallback(new btGhostPairCallback());
I do a quick test of the size() function and it returns a corrupt value there
My overlapping test is this:
Code: Select all
int numObjectsInGhost = 0;
numObjectsInGhost = ghostObj->getNumOverlappingObjects(); //numObjectsInGhost is set to 0xcdcdcdcd
czPrintf("number of objects inside ghost: %d\n", numObjectsInGhost);
for(int i=0; i<numObjectsInGhost;++i)
{
btCollisionObject* obj = ghostObj->getOverlappingObject(i);
czPrintf("obj[%d] = %p\n",i, obj);
}
Now for the very scary part. If I set a break point at:
numObjectsInGhost = ghostObj->getNumOverlappingObjects();
Then step into this function, I am brought to this:
Code: Select all
int getNumOverlappingObjects() const
{
return m_overlappingObjects.size();
}
Mousing over overlappingObjects shows me that m_size is in fact 0, and when I break the program when the rigid body is inside the ghost it shows it as 1. So it looks like it works, but then I step into the size() function which brings me to
Code: Select all
/// return the number of elements in the array
SIMD_FORCE_INLINE int size() const
{
return m_size;
}
and guess what m_size if? it 0xcdcdcdcd!!! I don't really understand. I went into my Memory watcher and put in the address of m_overlappingObjects. Doing this I see that the first 4 bytes are in deed 0xcdcdcdcd. This leads me to believe that m_allocator is corrupted somehow since that is the only thing that is declared before m_size.
Just for extra info I'm using Microsoft Visual Studio 2008. When I mouse over that m_overlappingObjects when the rigid body is not in the ghostObj this is the full results:
m_allocator {...}
m_size 0
m_capacity 0
m_data 0x00000000
m_ownMemory true
When I mouse over with the rigid body inside it I get this:
m_allocator {...}
m_size 1
m_capacity 1
m_data 0x00281bb0 //Yes that IS the address of my rigidBody
m_ownMemory true
but m_overlappingObjects.size() always returns the value of 0xcdcdcdcd (which is -842150451 in case your wondering).
I'm so lost as to why this doesn't work ):
~GameQ