Hi, I'm trying to add rigid bodies in a loop as in the Rope Bridge demo. I have a wrapper class which attaches a graphical representation to them. If I try and add 20 of them all is fine, 40 and above and I hit an accessCheck breakpoint, even though I am not steppingmultiThreaded, and I thought I had markedForWrite and unmarked correctly.The breakpoint is hit when physicsWorld->stepDeltaTime(secTime): Here is how the body is created.
void OgreRigidBody::createBoxHavokRigidBody()
{
hkpConvexShape * shape = new hkpBoxShape(mSize, 0.0f);
hkpRigidBodyCinfo boxInfo;
boxInfo.m_shape = shape;
boxInfo.m_position = mPosition;
boxInfo.m_contactPointCallbackDelay = 0;
//fill in the rest of boxInfo
createAttributes(boxInfo);
mHavokBody = new hkpRigidBody(boxInfo);
mHavokWorld->markForWrite();
mHavokWorld->addEntity(mHavokBody);
mHavokWorld->unmarkForWrite();
mHavokBody->;removeReference();
shape->removeReference();
}
Here is createAttributes:
void OgreRigidBody::createAttributes(hkpRigidBodyCinfo & boxInfo) {
boxInfo.m_mass = mMass;
hkpMassProperties massProperties; hkpInertiaTensorComputer::computeBoxVolumeMassProperties(mSize, boxInfo.m_mass, massProperties);
boxInfo.m_mass = massProperties.m_mass;
boxInfo.m_centerOfMass = massProperties.m_centerOfMass;
boxInfo.m_inertiaTensor = massProperties.m_inertiaTensor;
boxInfo.m_solverDeactivation = boxInfo.SOLVER_DEACTIVATION_MEDIUM;
boxInfo.m_motionType = mBodyType == Box ? hkpMotion::MOTION_BOX_INERTIA : hkpMotion::MOTION_SPHERE_INERTIA;
boxInfo.m_linearDamping = mLinDamp;
boxInfo.m_angularDamping = mAngDamp; }
Here is the loop that creates the bodies
for( int i = 0; i < iNum; i++ )
{
OgreHavokBodyAttributes boxAttr;
boxAttr.SceneMgr = sceneMgr;
boxAttr.World = physics.GetPhysicsWorld();
boxAttr.BodyType = OgreHavok::Box;
boxAttr.BodyName = "BridgeBlock" + StringConverter::toString(iNum);
boxAttr.Size = halfExtents;
boxAttr.Position = basePos;
boxAttr.MeshName = "cube.1m.mesh";
boxAttr.MaterialName = "";
boxAttr.Mass = 20;
boxAttr.angDamp = 2.0f;
boxAttr.linDamp = 0.5f;
boxAttr.angDamp = hkpMotion::MOTION_SPHERE_INERTIA;
bridgePieces.push_back(new OgreRigidBody(boxAttr));
rb = bridgePieces.back()->getRigidBodyPtr();
rb->setCollisionFilterInfo( filter->calcFilterInfo( ROPE_BRIDGE ) );
Here is the call stack. HavokTest.exe!hkMultiThreadCheck::accessCheck() Line 254 + 0x71 bytes C++ HavokTest.exe!hkpWorld::getMemoryWatchDog() Line 2855 C++ HavokTest.exe!hkpSimulation::stepDeltaTime() Line 377 + 0xe bytes C++ HavokTest.exe!hkpWorld::stepDeltaTime() Line 2437 C++ HavokTest.exe!Physics::Simulate(float secTime) Line 192 + 0x11 bytes C++ HavokTest.exe!HavokTest::frameRenderingQueued(const Ogre::FrameEvent & evt) Line 144 C++
void Physics::Simulate(float secTime)
{
if(secTime>0.00001)// time of zero causes an exception
hkpStepResult hr= physicsWorld->stepDeltaTime( secTime );
stepVisualDebugger(secTime);
}
The solution may be quite simple, the rope bridge had been working perfectly(I've removed statements from the above sample to trackdown the error). I then tried to add multithreaded and included in my Havok includes, almost instantly things fell apart. I have since commented this out, and cleaned the solution multiple times, to no avail. This collection of rigid bodies are the only things in the world, their graphical update is not being called(read the position of the rigid body and applied it to the Ogre node).



