BUG in Havok hkpCharacterStateJumping (Havok 7.1.0 r1, later versions unknown)

BUG in Havok hkpCharacterStateJumping (Havok 7.1.0 r1, later versions unknown)

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.

Recomendations:
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.

Cheers
Matias

Edit:
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

Matias N. Goldberg Intel Havok Physics Innovation Contest Winner * Most Innovative Use of Physics in a Game (2nd Place) * Best Physics Knowledge Base Entry (2nd Place)
5 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

There's 'Changes' list in 2010 release, you dont have to install it to check if its fixed...

Downloaded 788MB just to see the change log.

I don't see anything in the Release Notes related to this bug, and I see m_jumpCounter is still in the wrong class; so it's very likely the problem still persists.

Matias N. Goldberg Intel Havok Physics Innovation Contest Winner * Most Innovative Use of Physics in a Game (2nd Place) * Best Physics Knowledge Base Entry (2nd Place)

Hi,Yes, this is a known issue withhkpCharacterStateJumping. Unfortunatly, it still hasn't been addressed in current versions of Havok.-Vincent

Thanks for the quick response! I wasn't expecting a reply until next week :)

If this was already a known issue it would be nice if that would be stated somewhere, specially since the manual encourages sharing.

When I started suspecting of Havok (my first guess there was something wrong in my end) I had to debug the disassembly. That wasn't funny at all (God bless data breakpoints)

Anyway, Havok is still a great piece of well written software which is allowing me to do stuff I've only been dreaming for a long time, so I'm thankful we have free access to it. Plus I've done a quick profile and sharing doesn't give any noticeable memory saving even with hundreds units, revealing I have more important memory consuming sections that needs my attention.

But I would appreciate if these issues are described in the manual or at least in the hkpCharacterStateJump definition as a comment.

By the way, I accidentally hit the 3 star as "rating your reply" and the forum doesn't let me undo it.

Cheers

Matias N. Goldberg Intel Havok Physics Innovation Contest Winner * Most Innovative Use of Physics in a Game (2nd Place) * Best Physics Knowledge Base Entry (2nd Place)

Leave a Comment

Please sign in to add a comment. Not a member? Join today