Havok Support Team:
Section 2.6.3 Page 303 of the manual ("The State Machine" inside "Character Controll") sates:
"As you can see references to new states are managed appropriately by the state manager.
Once you have registered your state you create a context for each character you wish to control"
This implies that the same hkpCharacterStateManager toghether with hkpCharacterState can be shared among many characters, saving memory, slightly improving initialization time, and better cache utilization.
And the code seems to agree with that. In fact, hkpCharacterContext accepts a const hkpCharacterStateManager pointer in it's constructor
However, hkpCharacterStateJumping is the only default state that does NOT comply with that statement.
It's member variable hkpCharacterStateJumping::m_jumpCounter is updated per character.
This has the following problems when sharing:
1) A custom multithreaded implementation could blow up
2) Even single threaded, I actually found the bug when one of my characters jumped and started flying up, never leaving the jumping state, and after that no other unit sharing the same state was able to enter the jumping state, it immediately went to ground state. Interestingly in one of the tests, if another unit tried to jump, the other unit flying around stopped flying and started falling, but then the other unit got stuck in jumping state, levitating in the air a few cm above the ground. This happens when two or more units jump at more or less the same time.
Note the problem seen in 2) was fixed immediately after stopping sharing the state managers.
1) Move hkpCharacterStateJumping::m_jumpCounter into hkpCharacterContext which is more appropiate.
2) If hkpCharacterStateManager isn't supposed to be shared, modify the manual to make this explicit. Also hkpCharacterContext's input shouldn't be const, it is missleading and/or mark m_jumpCounter as mutable.
Note this bug means there's a const_cast somewhere (or worse, C-style cast) which might be sign of other bugs.
My apologies if this bug has been fixed in latest Havok 2010.1; but I'm sure you'll understand in middle of development and I can't just switch middleware so easily.
I would love being able to share the managers mainly for the memory benefits, but for now stop sharing them works as a workaround to this bug.
PS: Just to be clear, there is no crash, so there is no call stack to report. Plus I've been detailed enough about the bug causes. There is no crash but units start flying (wrong behaviour) never leaving jumping state. Even if hkpCharacterStateMgrs aren't supposed to be shared, I still consider this a bug for the reasons mentioned in 2) in Recomendations