單步執行調試器時,BBox對象在函數的入口處沒問題,但一旦進入函數,vfptr對象就會指向0xccccc。我不明白。爲什麼這個對象弄出來並被刪除?
- 這是什麼原因造成的?
- 當對象不是從其他類派生時,爲什麼在那裏存在一個虛擬表引用。 (儘管它駐留在我的Player類繼承的GameObject中,並且我從玩家內部檢索了BBox,但是,爲什麼BBox有參考價值?難道它不應該是參與者應該維護的玩家嗎?)
For 1;一些供參考的代碼:
答:我從播放器中檢索邊界框。按預期返回一個邊界框。然後我將它的地址發送給GetGridCells。
const BoundingBox& l_Bbox = l_pPlayer->GetBoundingBox();
boost::unordered_set < Cell*, CellPHash >& l_GridCells = GetGridCells (&l_Bbox);
B.這是a_pBoundingBox變得瘋狂並且得到垃圾值的地方。
boost::unordered_set< Cell*, CellPHash > CollisionMgr::GetGridCells(const BoundingBox *a_pBoundingBox)
{
我認爲下面的代碼也是相關的,所以我在此堅持反正這裏:
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);
任何人都可以請給我一些想法,爲什麼發生這種情況?另外,如果你想讓我發佈更多的代碼,請讓我知道。
謝謝!
什麼叫「一根筋了」是什麼意思? – 2010-04-10 08:21:17
@Eli:當它到達GetGridCells時,對象超出範圍(..) 我不好使用正確的術語。 – brainydexter 2010-04-10 10:38:51