mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 06:44:06 +02:00
Reduce foot sliding for tall and short avatars.
Scale the desiredVelocity of the animation blends to account for limb length. i.e. a short avatar should have a faster walk cycle to move at the same speed as a tall avatar
This commit is contained in:
parent
0a72805874
commit
effadd38a6
1 changed files with 18 additions and 7 deletions
|
@ -504,12 +504,19 @@ bool Rig::getRelativeDefaultJointTranslation(int index, glm::vec3& translationOu
|
|||
static const std::vector<float> FORWARD_SPEEDS = { 0.4f, 1.3f, 4.5f }; // m/s
|
||||
static const std::vector<float> BACKWARD_SPEEDS = { 0.6f, 1.05f }; // m/s
|
||||
static const std::vector<float> LATERAL_SPEEDS = { 0.2f, 0.5f }; // m/s
|
||||
static const float DEFAULT_AVATAR_EYE_HEIGHT = 1.65f; // movement speeds are for characters of this eye-height. ~170 cm tall.
|
||||
|
||||
void Rig::computeMotionAnimationState(float deltaTime, const glm::vec3& worldPosition, const glm::vec3& worldVelocity, const glm::quat& worldRotation, CharacterControllerState ccState) {
|
||||
|
||||
glm::vec3 front = worldRotation * IDENTITY_FRONT;
|
||||
glm::vec3 workingVelocity = worldVelocity;
|
||||
|
||||
// TODO: account for avatar scaling
|
||||
int eyeJoint = indexOfJoint("LeftEye");
|
||||
int toeJoint = indexOfJoint("LeftToeBase");
|
||||
const float AVATAR_EYE_HEIGHT = (eyeJoint >= 0 && toeJoint >= 0) ? getAbsoluteDefaultPose(eyeJoint).trans.y - getAbsoluteDefaultPose(toeJoint).trans.y : DEFAULT_AVATAR_EYE_HEIGHT;
|
||||
const float AVATAR_HEIGHT_RATIO = DEFAULT_AVATAR_EYE_HEIGHT / AVATAR_EYE_HEIGHT;
|
||||
|
||||
{
|
||||
glm::vec3 localVel = glm::inverse(worldRotation) * workingVelocity;
|
||||
|
||||
|
@ -529,18 +536,22 @@ void Rig::computeMotionAnimationState(float deltaTime, const glm::vec3& worldPos
|
|||
float moveBackwardAlpha = 0.0f;
|
||||
float moveLateralAlpha = 0.0f;
|
||||
|
||||
// calcuate the animation alpha and timeScale values based on current speeds and animation reference speeds.
|
||||
calcAnimAlpha(_averageForwardSpeed.getAverage(), FORWARD_SPEEDS, &moveForwardAlpha);
|
||||
calcAnimAlpha(-_averageForwardSpeed.getAverage(), BACKWARD_SPEEDS, &moveBackwardAlpha);
|
||||
calcAnimAlpha(fabsf(_averageLateralSpeed.getAverage()), LATERAL_SPEEDS, &moveLateralAlpha);
|
||||
float averageForwardSpeed = AVATAR_HEIGHT_RATIO * _averageForwardSpeed.getAverage();
|
||||
float averageBackwardSpeed = -averageForwardSpeed;
|
||||
float averageLateralSpeed = AVATAR_HEIGHT_RATIO * fabsf(_averageLateralSpeed.getAverage());
|
||||
|
||||
_animVars.set("moveForwardSpeed", _averageForwardSpeed.getAverage());
|
||||
// calcuate the animation alpha and timeScale values based on current speeds and animation reference speeds.
|
||||
calcAnimAlpha(averageForwardSpeed, FORWARD_SPEEDS, &moveForwardAlpha);
|
||||
calcAnimAlpha(averageBackwardSpeed, BACKWARD_SPEEDS, &moveBackwardAlpha);
|
||||
calcAnimAlpha(averageLateralSpeed, LATERAL_SPEEDS, &moveLateralAlpha);
|
||||
|
||||
_animVars.set("moveForwardSpeed", averageForwardSpeed);
|
||||
_animVars.set("moveForwardAlpha", moveForwardAlpha);
|
||||
|
||||
_animVars.set("moveBackwardSpeed", -_averageForwardSpeed.getAverage());
|
||||
_animVars.set("moveBackwardSpeed", averageBackwardSpeed);
|
||||
_animVars.set("moveBackwardAlpha", moveBackwardAlpha);
|
||||
|
||||
_animVars.set("moveLateralSpeed", fabsf(_averageLateralSpeed.getAverage()));
|
||||
_animVars.set("moveLateralSpeed", averageLateralSpeed);
|
||||
_animVars.set("moveLateralAlpha", moveLateralAlpha);
|
||||
|
||||
const float MOVE_ENTER_SPEED_THRESHOLD = 0.2f; // m/sec
|
||||
|
|
Loading…
Reference in a new issue