Preferred method for dealing with fast moving Rigid Bodies?

Preferred method for dealing with fast moving Rigid Bodies?

Hey all,

I'm having trouble dealing with a rigid body attached to a fairly quick moving animated bone. The best way to illustrate the problem is to think of a baseball player at bat.

Frame 0: Player has the bat in a wind up position.

Frame 1: Player has the bat perpendicular to him (mid swing).

Frame 2: Player has the bat in a follow through motion.

Currently, before I update the Rigid body (the bat in my example above), I've simply been setting it's transform to the bone's world transform and setting the linear velocity of the body to the difference between it's previous position and it's new position. That solution works if the animation is slow enough (because the velocities generated are fairly small and you get more updates) - but it's definitely not ideal and doesn't work at all if the animation is quick, it also doesn't really capture the arc like movement of the animation.

What is the preferred way for dealing with a rigid body with quick movement? I've been reading about hkSweptTransform but wasn't sure if I was barking up the right tree and would appreciate some official direction. :)

3 post / 0 nuovi
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione

Hi Matt,

It is almost always a bad idea to set the position of a rigid body directly. Have a look at section "Setting Positions and Rotations" in the user guide for why.

From what you've described it sounds like hkpKeyFrameUtility::applyHardKeyFrame(...) is what you are looking for (using the position and orientation of bone of the hand that the bat is attached to). Physics\Api\Dynamics\RigidBodies\Keyframing Demo has a very simple example of using this function. If you've any other questions, just let us know.

Amy Developer Support Engineer Havok www.havok.com

Thanks for the reply, Amy.

I dug more into the documentation and saw the keyframe utils. I converted to using that and the collision is better, but it's still occassionally not registering as it goes through the player's volume. I now believe that the issue is because I'm currently using hkpCharacterProxy to represent a character instead of the suggested hkpCharacterRigidBody - so I'm in the midst of changing over to use that so the character is actually in the physics scene.

But again, I appreciate the response.

Lascia un commento

Eseguire l'accesso per aggiungere un commento. Non siete membri? Iscriviti oggi