我正在尝试从另一个类访问私有静态变量 (*PhysicsEngine:: _world ->setDebugDrawer(&debugDraw);*)。
一级:
namespace GameEngine
{
class PhysicsEngine
{
private:
// Pointer to Bullet's World simulation
static btDynamicsWorld* _world;
二等:
bool Game::initialise()
{
_device = irr::createDevice(irr::video::EDT_OPENGL,
_dimensions,
16,
false,
false,
false,
&inputHandler);
if(!_device)
{
std::cerr << "Error creating device" << std::endl;
return false;
}
_device->setWindowCaption(_caption.c_str());
//////////////
DebugDraw debugDraw(game._device);
debugDraw.setDebugMode(
btIDebugDraw::DBG_DrawWireframe |
btIDebugDraw::DBG_DrawAabb |
btIDebugDraw::DBG_DrawContactPoints |
//btIDebugDraw::DBG_DrawText |
//btIDebugDraw::DBG_DrawConstraintLimits |
btIDebugDraw::DBG_DrawConstraints //|
);
PhysicsEngine::_world->setDebugDrawer(&debugDraw);
如果我公开 _world,我会在 Bullet01.exe 中的 0x00EC6910 处得到未处理的异常:0xC0000005:访问冲突读取位置 0x00000000。