【发布时间】:2010-04-10 08:11:52
【问题描述】:
单步调试,BBox对象在函数入口处是没问题的,但是一进入函数,vfptr对象就指向0xccccc。我不明白。
- 这是什么原因造成的?
- 当对象不是从其他类派生时,为什么那里有一个虚拟表引用。 (虽然,它驻留在我的 Player 类继承的 GameObject 中,我从玩家内部检索 BBox。但是,为什么 BBox 有引用?不应该是应该在该引用中维护的玩家吗?)
对于 1;一些代码供参考:
A.我从玩家那里检索边界框。这将按预期返回一个边界框。然后我将它的地址发送到 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);
谁能告诉我为什么会这样?另外,如果您希望我发布更多代码,请告诉我。
谢谢!
【问题讨论】:
-
你所说的“出局”是什么意思?
-
@Eli: 对象在到达 GetGridCells(..) 时超出了范围