void ReadAnimatedPose() { foreach (AnimatedPair pair in animatedPairs) { pair.currentPose = AnimatedPose.Read(pair.TargetBone); } }
static Vector3 CalculateAngularVelocity(AnimatedPose previousPose, AnimatedPose newPose, float dt) { Quaternion deltaRotation = newPose.localRotation * Quaternion.Inverse(previousPose.localRotation); deltaRotation.ToAngleAxis(out float deltaAngle, out Vector3 axis); if (deltaAngle > 180) { deltaAngle -= 360f; } return(Mathf.Deg2Rad * deltaAngle / dt * axis.normalized); }
void DoPoweredPositionMatching(AnimatedPair pair, BoneProfile boneProfile, float dt) { float alpha = boneProfile.positionAlpha; float dampingRatio = boneProfile.positionDampingRatio; Rigidbody rigidbody = pair.RagdollBone.Rigidbody; AnimatedPose targetPose = pair.currentPose; Vector3 acceleration = AnimationMatching.GetAccelerationFromPositionSpring(rigidbody.position, targetPose.worldPosition, rigidbody.velocity, pair.poseLinearVelocity, alpha, dampingRatio, rigidbody.mass, dt); LimitAcceleration(ref acceleration, boneProfile.maxLinearAcceleration); rigidbody.AddForce(acceleration, ForceMode.Acceleration); }
static Vector3 CalculateLinearVelocity(AnimatedPose previousPose, AnimatedPose newPose, float dt) { return((newPose.worldPosition - previousPose.worldPosition) / dt); }