Crash when calling new hkpWorld

Crash when calling new hkpWorld

Ritratto di ixnehc
I'm working on Havok initializing,I copy the codes from the demos,and it crashes at new hkpWorld(): hkMemoryRouter* memoryRouter = hkMemoryInitUtil::initDefault( hkMallocAllocator::m_defaultMallocAllocator, hkMemorySystem::FrameInfo( 5000* 1024 ) ); hkResult result=hkBaseSystem::init( memoryRouter, NULL); if (result==HK_SUCCESS) { hkpWorldCinfo info; info.setBroadPhaseWorldSize(100.0f); info.setupSolverInfo( hkpWorldCinfo::SOLVER_TYPE_4ITERS_MEDIUM ); hkpWorld *world= new hkpWorld( info ); } Do I miss something?
4 post / 0 new
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione
Ritratto di havok_josh
Hi ixnehc- There are a couple things: 1. You need to specify an errorReport function. You can't simply pass in NULL. The simplest thing is to define a function that forwards to printf (as shown in the SimpleConsoleMain standalone demo):
static void HK_CALL errorReport(const char* msg, void*)

{

printf("%s", msg);

}
Once you have that defined, your hkBaseSystem::init line looks like:
hkBaseSystem::init( memoryRouter, errorReport);
2. Your hkpWorld is "scoped" to the if(result==HK_SUCCESS) {...} block. In order to use that variable outside of the if-block, you must do this:
hkpWorld* world;

if (result==HK_SUCCESS) {

...

world = new hkpWorld(info);

}
Otherwise, the world variable will go "out of scope" when you exit the if-block and subsequent code will not be able to use it! This sort of thing is checked at compile time. 3. Take a look at the code in: Demo\StandAloneDemos\ConsoleExample\SimpleConsoleMain.cpp to see the absolute minimum required to configure Havok. If you do all that and still have problems, I can help you better if you tell me exactly which demo you copied your code from. Also, more information on what is reported when a crash occurs would be useful. -Josh
Josh Developer Support Engineer Havok www.havok.com
Ritratto di ixnehc

Hi Josh: Thank you for replying. It's just a testing code,so I donot care about the "out of scope" thing. It still crashes when I supply a error handler function. My codes is very same with in the SimpleConsoleMain.cpp,except for some Multithread poolstuff,is that important? I trace the assembly and find the location it crashes:
05F02EE5 call dword ptr [hkpBroadPhase::s_createSweepAndPruneBroadPhaseFunction (6903FE0h)]

The value of hkpBroadPhase::s_createSweepAndPruneBroadPhaseFunction is 0x00000000.Seems not been correctly initialized. Do I miss something?

Ritratto di ixnehc

Hi: Problem solved.It seems I missed a PRODUCT define.After I add the following line,it works correct. #define HK_FEATURE_PRODUCT_PHYSICS Thank you for concerning.

Accedere per lasciare un commento.