I am quite desperate about a random crash. The memory could not be "read" error.
I would be very happy for any help. Thank you.
HRESULT CSceneNode::UpdateAll()
{
D3DXMATRIX backup_local_tm = ei.world_tm;
Update();
SceneNodeIterator begin=FirstChild();
SceneNodeIterator end=LastChild();
for (;begin!=end;begin++)
{
(*begin)->UpdateAll(); // Here is the random Crash !!!
}
ei.world_tm = backup_local_tm;
return S_OK;
}
HRESULT CSceneNode::Update()
{
if (!pretransformed)
{
ei.world_tm=*physics->GetMatrix()*ei.world_tm;
SetTmMat(&ei.world_tm);
}
return S_OK;
}
void CSceneNode::SetTmMat(D3DXMATRIX* m)
{
tm_mat= *m;
if (bound) bound->TransformIntoWorldCoordinates();
hasInverseTM=false;
}
//----- in SceneNode.h
D3DXMATRIX tm_mat;
CBoundingVolume *bound;
//----- in CBoundingVolume.h
void CBoundingVolume::TransformIntoWorldCoordinates()
{
if (!(init && owner )) return;
REPORTR(rlReport, init && owner, return);
int i;
for (i=0;i<8;i++) D3DXVec3TransformCoord (&wVerts[i], &verts[i], owner->GetTmMat());
for (i=0;i<3;i++) D3DXVec3TransformNormal(&wAxis[i], &axis[i], owner->GetTmMat());
D3DXVec3TransformCoord(&wCenter, ¢er, owner->GetTmMat());
}
// inside ei is
D3DXMATRIX world_tm;
//----- in physics.h
class EXPORTDECL CPhysics
public:
Physics();
virtual ~CPhysics() {}
virtual D3DXMATRIX *GetMatrix() {return &staticTM;}
//----- in physics.cpp
CPhysics::CPhysics()
{
animated=0;
staticTM=identityMatrix;
}
CPhysics* CPhysics::CreateNew()
{
return new CPhysics;
}