Hi there,
i want to use Havok Physics to create a simple scene with multiple rigid bodies. The main-loop to create the rb's looks like this:
for( int i = 0; i < 100; i++ ) {
hkpRigidBody* rigidBody;
{
// Create a box 1 by 2 by 3
hkVector4 halfExtents; halfExtents.set(0.5f, 1.0f, 1.5f);
hkpBoxShape* boxShape = new hkpBoxShape(halfExtents);
hkpRigidBodyCinfo bodyCinfo;
bodyCinfo.m_shape = boxShape;
// Calculate the mass properties for the shape
const hkReal boxMass = 10.0f;
hkpMassProperties massProperties;
hkpInertiaTensorComputer::computeShapeVolumeMassProperties(boxShape, boxMass, massProperties);
bodyCinfo.setMassProperties(massProperties);
// Create the rigid body
rigidBody = new hkpRigidBody(bodyCinfo); // crash after 7th body
// No longer need the reference on the boxShape, as the rigidBody now owns it
boxShape->removeReference();
}
// Add the rigidBody to the world
world->addEntity(rigidBody);
// No longer need the ref of rigidBody - as the world now owns it
//rigidBody->removeReference();
}
The code was taken from the step-by-step exsample. In the 8th iteration of the loop the programm crashs and the MS Visual Studio 2010 Debugger show that message:
Unhandled exception at 0x0195029c in Application.exe: 0xC0000005: Access violation reading location 0xccccccd8.
Call Stack:
Application.exe!hkLargeBlockAllocator::blockAlloc(int bytes) Line 735 + 0x11 bytes C++
Application.exe!hkMemoryAllocator::bufAlloc(int & reqBytesInOut) Line 25 C++
Application.exe!hkFreeList::addSpace() Line 703 C++
Application.exe!hkFreeListAllocator::blockAllocBatch(void * * blocksOut, int nblocks, int nbytes) Line 616 + 0x84 bytes C++
Application.exe!hkThreadMemory::onRowEmpty(int rowIndex) Line 165 C++
Application.exe!hkThreadMemory::blockAlloc(int nbytes) Line 241 C++
Application.exe!hkpSimpleContactConstraintAtomUtil::allocateAtom(int numReservedContactPoints, int numExtraUserDatasA, int numExtraUserDatasB, int maxNumContactPoints) Line 86 C++
Application.exe!hkpSimpleContactConstraintData::hkpSimpleContactConstraintData(hkpConstraintInstance * constraint, hkpRigidBody * bodyA, hkpRigidBody * bodyB) Line 128 C++
Application.exe!hkpSimpleConstraintContactMgr::hkpSimpleConstraintContactMgr(hkpWorld * sm, hkpRigidBody * bodyA, hkpRigidBody * bodyB) Line 68 + 0x53 bytes C++
Application.exe!hkpSimpleConstraintContactMgr::Factory::createContactMgr(const hkpCollidable & a, const hkpCollidable & b, const hkpCollisionInput & input) Line 655 + 0x63 bytes C++
Application.exe!hkpWorldAgentUtil::addAgent(hkpLinkedCollidable * collA, hkpLinkedCollidable * collB, const hkpProcessCollisionInput & input) Line 110 C++
Application.exe!hkpEntityEntityBroadPhaseListener::addCollisionPair(hkpTypedBroadPhaseHandlePair & pair) Line 57 + 0xe bytes C++
Application.exe!hkpTypedBroadPhaseDispatcher::addPairs(hkpTypedBroadPhaseHandlePair * newPairs, int numNewPairs, const hkpCollidableCollidableFilter * filter) Line 52 C++
Application.exe!hkpWorldOperationUtil::addEntityBP(hkpWorld * world, hkpEntity * entity) Line 173 C++
Application.exe!hkpWorld::addEntity(hkpEntity * entity, hkpEntityActivation initialActivationState) Line 891 C++
> Application.exe!Benchmark01_Havok::CreateScene() Line 162 C++
Application.exe!main(int argc, char * * argv) Line 387 + 0x15 bytes C++
Application.exe!__tmainCRTStartup() Line 555 + 0x19 bytes C
Application.exe!mainCRTStartup() Line 371 C
kernel32.dll!7735339a()
[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]
ntdll.dll!77a19ed2()
ntdll.dll!77a19ea5()
The initialization of the Havok Physics Engine is exactly the same as in the example code. I use the "Debug multithreaded" libraries. Do i need to change some compiler/linker options?
Greetings Tobi



