[ODE] Crash in dCollide .. might have to do with object copying...?
jeff at jeffkershner.com
Tue Aug 29 11:54:46 MST 2006
I am getting a crash in dCollide that I think has to do with vector copying.
I have a class PhysicsObject which represents a trimesh in ODE. When my
script loads a trimesh, I collect the vertex and index buffers and create a
physics object like this and add it to my list:
// Dynamically create buffers on the heap
float* pVertexBuffer = new float[vb_size];
unsigned int* pIndexBuffer = new unsigned int[ib_size];
// Copy the vertices and indices into the buffers
if (pbj.Initialize(pVertexBuffer, vb_size, pIndexBuffer, ib_size))
delete  pVertexBuffer;
delete  pIndexBuffer;
My PhysicsObject::Initialize creates two new buffers and copies the vertex
and index buffer into its own arrays and creates the trimesh:
m_pVertexBuffer = new float[m_VBSize];
m_pIndexBuffer = new unsigned int[m_IBSize];
// Copy data into the arrays
// Create the trimesh
// dGeomTriMeshDataCreate, dGeomTriMeshdataBuildSimple, dCreateTriMesh
When m_PhysicsObjectList.push_back(obj) is called, I have a copy constructor
to do a deep copy of my dynamically allocated arrays. So in my copy
constructor creates two new dynamically allocated buffers and copies the VB
and the IB. Then it recreates the trimesh with the new vertex buffers and
Finally each PhysicsObject has a destructor that deletes the buffers and
destroys the trimesh.
Does this operation look correct?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ODE