Stepping through the debugger, the BBox object is okay at the entry of the function, but as soon as it enters the function, the vfptr object points to 0xccccc. I don't get it.
- What is causing this ?
- Why is there a virtual table reference in there when the object is not derived from other class. (Though, it resides in GameObject from which my Player class inherits and I retrieve the BBox from within player. But, why does the BBox have the reference ? Shouldn't it be player who should be maintained in that reference ?)
For 1; some code for reference:
A. I retrieve the bounding box from player. This returns a bounding box as expected. I then send its address to GetGridCells.
const BoundingBox& l_Bbox = l_pPlayer->GetBoundingBox();
boost::unordered_set < Cell*, CellPHash >& l_GridCells = GetGridCells ( &l_Bbox );
B. This is where a_pBoundingBox goes crazy and gets that garbage value.
boost::unordered_set< Cell*, CellPHash > CollisionMgr::GetGridCells(const BoundingBox *a_pBoundingBox)
{
I think the following code is also pertinent, so I'm sticking this in here anyways:
const BoundingBox& Player::GetBoundingBox(void)
{
return BoundingBox( &GetBoundingSphere() );
}
const BoundingSphere& Player::GetBoundingSphere(void)
{
BoundingSphere& l_BSphere = m_pGeomMesh->m_BoundingSphere;
l_BSphere.m_Center = GetPosition();
return l_BSphere;
}
// BoundingBox Constructor
BoundingBox(const BoundingSphere* a_pBoundingSphere);
Can anyone please give me some idea as to why this is happening? Also, if you want me to post more code, please do let me know.
Thanks!