The following are some things I've figured out in using Havok myself. I can verify that the described methods work.
- Havok needs to run within a single scope.
- The physics engine initialization/destruction, physics world initialization/destruction, yadda yadda, any calls to Havok need to all take place withing a single block scope. What I mean by this is think of Havok as being another game loop. You can put Havok into the same while(running){} loop as your game or give it it's own thread, but either way it's a running thing that demands everything happen withing one block.
- You can of course break things up into methods and functions, but they must be called within this loop block. Sub-scopes are also of course fine, just keep it withing the big one.
- Some things will need to be initialized locally and cannot be declared as a class member. If you have a class member pointer to some havok thing and it gives an access violation error when you initialize it then sorry but you probably need to move the dudette's declaration into the local scope of it's use.
I'll continue to add things here. These "gotcha"s can really slow down development so hopefully you'll be able to absorb whats posted here and avoid the problems yourself.
Update:
So a question I posted on the Intel Havok forums was answered and it's related to the scoping and access violation errors. Here is the response...
"Hi, this looks like a fairly common problem. Here's a another thread with the same issue: http://software.intel.com/en-us/forums/showthread.php?t=80707 (see 3rd post). And the same kind of issue here: http://software.intel.com/en-us/forums/showpost.php?p=178103
The problem is your hkMallocAllocator is going out of scope. Since this is just in your main thread the easiest solution is mentioned in the first post - switch to using 'hkMallocAllocator::m_defaultMallocAllocator' which already exists at a global scope and will not be destructed for the duration of the application.
-Tyler
PS. I'm going to go ahead an change the Havok demos that use the stack allocated hkAllocators in main() to use hkMallocAllocator::m_defaultMallocAllocator instead since it seems to be causing a lot of confusion."
Update:
So a question I posted on the Intel Havok forums was answered and it's related to the scoping and access violation errors. Here is the response...
"Hi, this looks like a fairly common problem. Here's a another thread with the same issue: http://software.intel.com/en-us/forums/showthread.php?t=80707 (see 3rd post). And the same kind of issue here: http://software.intel.com/en-us/forums/showpost.php?p=178103
The problem is your hkMallocAllocator is going out of scope. Since this is just in your main thread the easiest solution is mentioned in the first post - switch to using 'hkMallocAllocator::m_defaultMallocAllocator' which already exists at a global scope and will not be destructed for the duration of the application.
-Tyler
PS. I'm going to go ahead an change the Havok demos that use the stack allocated hkAllocators in main() to use hkMallocAllocator::m_defaultMallocAllocator instead since it seems to be causing a lot of confusion."
No comments:
Post a Comment