I just started the long complicated task of integrating Havok Physics and Possibly Animation into my Custom Built Ogre3D Game Engine. I have created a Physics System with in a dll that handles all of the Havok related tasks. I then took and created a test Console Application to test out the Physics engine. Everything seems to initialize correctly however when I go to step the Simulation I get all kinds of errors:
------------------------------------------------------------------
Havok - Build (20120119)
Version 2011.3.0-r1
Base system initialized.
------------------------------------------------------------------
Havok License Keys:
Physics : PcXs (expires PERPETUAL)
Animation : PcXs (expires PERPETUAL)
------------------------------------------------------------------
World\\BroadPhaseBorder\\hkpBroadPhaseBorder.cpp(164): [0xF013323D] Assert: Entity
left the broadphase. See hkpWorldCinfo::BroadPhaseBorderBehaviour for details.S
tack trace is:
y:\\build\\20120119_200004_pcxsperpetualkeycode\\source\\common\\base\\system\\error\\hk
defaulterror.cpp(137):'hkDefaultError::message'
y:\\build\\20120119_200004_pcxsperpetualkeycode\\source\\physics\\dynamics\\world\\broa
dphaseborder\\hkpbroadphaseborder.cpp(164):'hkpBroadPhaseBorder::maxPositionExcee
dedCallback'
y:\\build\\20120119_200004_pcxsperpetualkeycode\\source\\physics\\dynamics\\world\\broa
dphaseborder\\hkpbroadphaseborder.cpp(125):'hkpBroadPhaseBorder::collidableAddedC
allback'
y:\\build\\20120119_200004_pcxsperpetualkeycode\\source\\physics\\dynamics\\phantom\\hk
pphantom.inl(31):'hkpPhantom::fireCollidableAdded'
y:\\build\\20120119_200004_pcxsperpetualkeycode\\source\\physics\\dynamics\\phantom\\hk
paabbphantom.cpp(254):'hkpAabbPhantom::addOverlappingCollidable'
y:\\build\\20120119_200004_pcxsperpetualkeycode\\source\\physics\\dynamics\\world\\util
\\broadphase\\hkpbroadphaseborderlistener.cpp(35):'hkpBroadPhaseBorderListener::ad
dCollisionPair'
y:\\build\\20120119_200004_pcxsperpetualkeycode\\source\\physics\\collide\\dispatch\\br
oadphase\\hkptypedbroadphasedispatcher.cpp(50):'hkpTypedBroadPhaseDispatcher::add
Pairs'
y:\\build\\20120119_200004_pcxsperpetualkeycode\\source\\physics\\dynamics\\world\\simu
lation\\continuous\\hkpcontinuoussimulation.inl(53):'hkpContinuousSimulation::remo
veAndAddPairs'
y:\\build\\20120119_200004_pcxsperpetualkeycode\\source\\physics\\dynamics\\world\\simu
lation\\continuous\\hkpcontinuoussimulation.cpp(950):'hkpContinuousSimulation::col
lideEntitiesBroadPhaseContinuous'
y:\\build\\20120119_200004_pcxsperpetualkeycode\\source\\physics\\dynamics\\world\\simu
lation\\continuous\\hkpcontinuoussimulation.cpp(693):'hkpContinuousSimulation::col
lideInternal'
y:\\build\\20120119_200004_pcxsperpetualkeycode\\source\\physics\\dynamics\\world\\simu
lation\\hkpsimulation.cpp(187):'hkpSimulation::collide'
y:\\build\\20120119_200004_pcxsperpetualkeycode\\source\\physics\\dynamics\\world\\simu
lation\\hkpsimulation.cpp(367):'hkpSimulation::stepDeltaTime'
y:\\build\\20120119_200004_pcxsperpetualkeycode\\source\\physics\\dynamics\\world\\hkpw
orld.cpp(2417):'hkpWorld::stepDeltaTime'
c:\\users\\james\\documents\\visual studio 2010\\projects\\game\\physicssystem\\physicss
ystem.cpp(97):'PhysicsSystem::Tick'
c:\\users\\james\\documents\\visual studio 2010\\projects\\game\\physicstest\\physicstes
t.cpp(16):'wmain'
f:\\dd\\vctools\\crt_bld\\self_x86\\crt\\src\\crtexe.c(552):'__tmainCRTStartup'
f:\\dd\\vctools\\crt_bld\\self_x86\\crt\\src\\crtexe.c(370):'wmainCRTStartup'
(null)(0):'BaseThreadInitThunk'
(null)(0):'RtlInitializeExceptionChain'
(null)(0):'RtlInitializeExceptionChain'
I copied the code from one of the step by step stand alone demos and just placed the code into different methods.
// PhysicsSystem.cpp : Defines the exported functions for the DLL application.
//
#include "stdafx.h"
#include "PhysicsSystem.h"
#include
using namespace std;
// This is the constructor of a class that has been exported.
// see PhysicsSystem.h for the class definition
PhysicsSystem::PhysicsSystem()
{
return;
}
PhysicsSystem::~PhysicsSystem()
{
// Release the reference on the world
world->removeReference();
hkBaseSystem::quit();
hkMemoryInitUtil::quit();
}
PhysicsSystem* PhysicsSystem::Singleton()
{
static PhysicsSystem* instance;
if(!instance)
instance = new PhysicsSystem();
return instance;
}
void PhysicsSystem::InitiatePhysicsWorld()
{
memoryRouter = hkMemoryInitUtil::initDefault( &baseMalloc, hkMemorySystem::FrameInfo(1024 * 1024) );
hkBaseSystem::init( memoryRouter, errorReport );
{
hkpWorldCinfo info;
info.setBroadPhaseWorldSize(3000);
world = new hkpWorld( info );
// Register all collision agents
// It's important to register collision agents before adding any entities to the world.
hkpAgentRegisterUtil::registerAllAgents( world->getCollisionDispatcher() );
}
}
void PhysicsSystem::PhysicsTest()
{
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);
// No longer need the reference on the boxShape, as the rigidBody now owns it
boxShape->removeReference();
}
this->AddEntityToSimulation(rigidBody);
// No longer need the ref of rigidBody - as the world now owns it
rigidBody->removeReference();
}
void PhysicsSystem::RemoveEntityFromSimulation(hkpEntity* entity)
{
world->removeEntity(entity);
}
void PhysicsSystem::AddEntityToSimulation(hkpEntity* entity)
{
world->addEntity(entity);
}
hkpWorld* PhysicsSystem::GetPhysicsWorld()
{
return world;
}
void PhysicsSystem::Tick(float deltaTime)
{
world->stepDeltaTime(deltaTime);
//const hkArray& activeIslands = world->getActiveSimulationIslands();
//for (int i = 0; i < activeIslands.getSize(); ++i)
//{
// const hkArray& entities = activeIslands[i]->getEntities();
// for (int j = 0; j < entities.getSize(); ++j)
// {
// hkpRigidBody* rigidBody = hkpGetRigidBody(entities[j]->getCollidable());
// if (rigidBody != nullptr)
// {
// //sync code here
// //cout << "My Position is: X -" << rigidBody->getPosition().x << "\\n";
// }
// }
//}
}
// Keycode
#include
// Productfeatures
// We're using only physics - we undef products even if the keycode is present so
// that we don't get the usual initialization for these products.
#undef HK_FEATURE_PRODUCT_AI
#undef HK_FEATURE_PRODUCT_ANIMATION
#undef HK_FEATURE_PRODUCT_CLOTH
#undef HK_FEATURE_PRODUCT_DESTRUCTION
#undef HK_FEATURE_PRODUCT_BEHAVIOR
// Also we're not using any serialization/versioning so we don't need any of these.
#define HK_EXCLUDE_FEATURE_SerializeDeprecatedPre700
#define HK_EXCLUDE_FEATURE_RegisterVersionPatches
//#define HK_EXCLUDE_FEATURE_RegisterReflectedClasses
#define HK_EXCLUDE_FEATURE_MemoryTracker
// This include generates an initialization function based on the products
// and the excluded features.
#include



