This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void InitializeHavok() { | |
InitMemory(); | |
InitPhysicalWorld(); | |
if (g_bVdbEnabled) | |
InitVDB(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void InitMemory() { | |
#if defined(HK_COMPILER_HAS_INTRINSICS_IA32) && | |
HK_CONFIG_SIMD == HK_CONFIG_SIMD_ENABLED | |
// Flush all denormal/subnormal numbers to zero. | |
// Operations on denormals are very slow, | |
// up to 100 times slower than normal numbers. | |
_MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void OnError(const char* msg, void* userArgGivenToInit) { | |
std::cerr < < "Report: " < < msg < < std::endl; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int totalNumThreadsUsed; | |
// Get the number of physical threads available on the system | |
hkHardwareInfo hwInfo; | |
hkGetHardwareInfo(hwInfo); | |
totalNumThreadsUsed = hwInfo.m_numThreads; | |
// We use one less than this for our thread pool, because we must also use this thread for our simulation | |
hkCpuJobThreadPoolCinfo threadPoolCinfo; | |
threadPoolCinfo.m_numThreads = totalNumThreadsUsed - 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hkJobQueueCinfo info; | |
info.m_jobQueueHwSetup.m_numCpuThreads = totalNumThreadsUsed; | |
g_pJobQueue = new hkJobQueue(info); | |
hkMonitorStream::getInstance().resize(200000); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void InitPhysicalWorld() { | |
g_pWorldInfo.m_simulationType = hkpWorldCinfo::SIMULATION_TYPE_MULTITHREADED; | |
g_pWorldInfo.m_broadPhaseBorderBehaviour = hkpWorldCinfo::BROADPHASE_BORDER_REMOVE_ENTITY; | |
g_pWorld = new hkpWorld(g_pWorldInfo); | |
g_pWorld->m_wantDeactivation = false; | |
g_pWorld->markForWrite(); | |
hkpAgentRegisterUtil::registerAllAgents( g_pWorld->getCollisionDispatcher() ); | |
g_pWorld->registerWithJobQueue( g_pJobQueue ); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void InitVDB() { | |
hkArray contexts; | |
{ | |
g_pContext = new hkpPhysicsContext(); | |
hkpPhysicsContext::registerAllPhysicsProcesses(); | |
g_pContext->addWorld(g_pWorld); | |
contexts.pushBack(g_pContext); | |
g_pWorld->unmarkForWrite(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void StepHavok() { | |
g_pWorld->stepMultithreaded( g_pJobQueue, g_pThreadPool, timeStep); | |
if(g_bVdbEnabled) | |
StepVDB(); | |
hkMonitorStream::getInstance().reset(); | |
g_pThreadPool->clearTimerData(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void StepVDB() { | |
g_pContext->syncTimers(g_pThreadPool); | |
g_pVdb->step(timeStep); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void ShutdownHavok() { | |
g_pWorld->markForWrite(); | |
g_pWorld->removeReference(); | |
delete g_pJobQueue; | |
// Clean up the thread pool | |
g_pThreadPool->removeReference(); | |
if (g_bVdbEnabled) |
OlderNewer