mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-07 18:02:31 +02:00
Merge pull request #16351 from dooglifeSF/transition-locomotion-to-idle-based-on-input-and-speed
Fix sliding when stopping from run.
This commit is contained in:
commit
71ef645781
3 changed files with 72 additions and 53 deletions
|
@ -5251,7 +5251,7 @@
|
|||
{
|
||||
"easingType": "easeInOutQuad",
|
||||
"id": "idle",
|
||||
"interpDuration": 20,
|
||||
"interpDuration": 15,
|
||||
"interpTarget": 20,
|
||||
"interpType": "evaluateBoth",
|
||||
"transitions": [
|
||||
|
@ -5383,8 +5383,8 @@
|
|||
{
|
||||
"easingType": "easeInOutQuad",
|
||||
"id": "idleSettle",
|
||||
"interpDuration": 15,
|
||||
"interpTarget": 15,
|
||||
"interpDuration": 13,
|
||||
"interpTarget": 14,
|
||||
"interpType": "snapshotPrev",
|
||||
"transitions": [
|
||||
{
|
||||
|
@ -5477,7 +5477,7 @@
|
|||
"transitions": [
|
||||
{
|
||||
"state": "idleSettle",
|
||||
"var": "isNotInput"
|
||||
"var": "isNotInputSlow"
|
||||
},
|
||||
{
|
||||
"state": "WALKBWD",
|
||||
|
@ -5541,7 +5541,7 @@
|
|||
"transitions": [
|
||||
{
|
||||
"state": "idleSettle",
|
||||
"var": "isNotInput"
|
||||
"var": "isNotInputSlow"
|
||||
},
|
||||
{
|
||||
"state": "WALKFWD",
|
||||
|
@ -5605,7 +5605,7 @@
|
|||
"transitions": [
|
||||
{
|
||||
"state": "idleSettle",
|
||||
"var": "isNotInput"
|
||||
"var": "isNotInputSlow"
|
||||
},
|
||||
{
|
||||
"state": "WALKFWD",
|
||||
|
@ -5669,7 +5669,7 @@
|
|||
"transitions": [
|
||||
{
|
||||
"state": "idleSettle",
|
||||
"var": "isNotInput"
|
||||
"var": "isNotInputSlow"
|
||||
},
|
||||
{
|
||||
"state": "WALKFWD",
|
||||
|
|
|
@ -1433,6 +1433,69 @@ void Rig::computeMotionAnimationState(float deltaTime, const glm::vec3& worldPos
|
|||
}
|
||||
_lastEnableInverseKinematics = _enableInverseKinematics;
|
||||
|
||||
|
||||
//stategraph vars based on input
|
||||
const float INPUT_DEADZONE_THRESHOLD = 0.05f;
|
||||
const float SLOW_SPEED_THRESHOLD = 1.5f;
|
||||
|
||||
if (fabsf(_previousControllerParameters.inputX) <= INPUT_DEADZONE_THRESHOLD &&
|
||||
fabsf(_previousControllerParameters.inputZ) <= INPUT_DEADZONE_THRESHOLD) {
|
||||
// no WASD input
|
||||
if (fabsf(forwardSpeed) <= SLOW_SPEED_THRESHOLD && fabsf(lateralSpeed) <= SLOW_SPEED_THRESHOLD) {
|
||||
_animVars.set("isInputForward", false);
|
||||
_animVars.set("isInputBackward", false);
|
||||
_animVars.set("isInputRight", false);
|
||||
_animVars.set("isInputLeft", false);
|
||||
_animVars.set("isNotInput", true);
|
||||
_animVars.set("isNotInputSlow", true);
|
||||
|
||||
} else {
|
||||
_animVars.set("isInputForward", false);
|
||||
_animVars.set("isInputBackward", false);
|
||||
_animVars.set("isInputRight", false);
|
||||
_animVars.set("isInputLeft", false);
|
||||
_animVars.set("isNotInput", true);
|
||||
_animVars.set("isNotInputSlow", false);
|
||||
}
|
||||
} else if (fabsf(_previousControllerParameters.inputZ) >= fabsf(_previousControllerParameters.inputX)) {
|
||||
if (_previousControllerParameters.inputZ > 0.0f) {
|
||||
// forward
|
||||
_animVars.set("isInputForward", true);
|
||||
_animVars.set("isInputBackward", false);
|
||||
_animVars.set("isInputRight", false);
|
||||
_animVars.set("isInputLeft", false);
|
||||
_animVars.set("isNotInput", false);
|
||||
_animVars.set("isNotInputSlow", false);
|
||||
} else {
|
||||
// backward
|
||||
_animVars.set("isInputForward", false);
|
||||
_animVars.set("isInputBackward", true);
|
||||
_animVars.set("isInputRight", false);
|
||||
_animVars.set("isInputLeft", false);
|
||||
_animVars.set("isNotInput", false);
|
||||
_animVars.set("isNotInputSlow", false);
|
||||
}
|
||||
} else {
|
||||
if (_previousControllerParameters.inputX > 0.0f) {
|
||||
// right
|
||||
_animVars.set("isInputForward", false);
|
||||
_animVars.set("isInputBackward", false);
|
||||
_animVars.set("isInputRight", true);
|
||||
_animVars.set("isInputLeft", false);
|
||||
_animVars.set("isNotInput", false);
|
||||
_animVars.set("isNotInputSlow", false);
|
||||
} else {
|
||||
// left
|
||||
_animVars.set("isInputForward", false);
|
||||
_animVars.set("isInputBackward", false);
|
||||
_animVars.set("isInputRight", false);
|
||||
_animVars.set("isInputLeft", true);
|
||||
_animVars.set("isNotInput", false);
|
||||
_animVars.set("isNotInputSlow", false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
_lastForward = forward;
|
||||
_lastPosition = worldPosition;
|
||||
|
@ -2161,50 +2224,6 @@ void Rig::updateFromControllerParameters(const ControllerParameters& params, flo
|
|||
}
|
||||
}
|
||||
|
||||
//deadzone constant
|
||||
const float INPUT_DEADZONE_THRESHOLD = 0.05f;
|
||||
|
||||
if (fabsf(params.inputX) <= INPUT_DEADZONE_THRESHOLD && fabsf(params.inputZ) <= INPUT_DEADZONE_THRESHOLD) {
|
||||
// no WASD input
|
||||
_animVars.set("isInputForward", false);
|
||||
_animVars.set("isInputBackward", false);
|
||||
_animVars.set("isInputRight", false);
|
||||
_animVars.set("isInputLeft", false);
|
||||
_animVars.set("isNotInput", true);
|
||||
} else if (fabsf(params.inputZ) >= fabsf(params.inputX)) {
|
||||
if (params.inputZ > 0.0f) {
|
||||
// forward
|
||||
_animVars.set("isInputForward", true);
|
||||
_animVars.set("isInputBackward", false);
|
||||
_animVars.set("isInputRight", false);
|
||||
_animVars.set("isInputLeft", false);
|
||||
_animVars.set("isNotInput", false);
|
||||
} else {
|
||||
// backward
|
||||
_animVars.set("isInputForward", false);
|
||||
_animVars.set("isInputBackward", true);
|
||||
_animVars.set("isInputRight", false);
|
||||
_animVars.set("isInputLeft", false);
|
||||
_animVars.set("isNotInput", false);
|
||||
}
|
||||
} else {
|
||||
if (params.inputX > 0.0f) {
|
||||
// right
|
||||
_animVars.set("isInputForward", false);
|
||||
_animVars.set("isInputBackward", false);
|
||||
_animVars.set("isInputRight", true);
|
||||
_animVars.set("isInputLeft", false);
|
||||
_animVars.set("isNotInput", false);
|
||||
} else {
|
||||
// left
|
||||
_animVars.set("isInputForward", false);
|
||||
_animVars.set("isInputBackward", false);
|
||||
_animVars.set("isInputRight", false);
|
||||
_animVars.set("isInputLeft", true);
|
||||
_animVars.set("isNotInput", false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
_headEnabled = params.primaryControllerFlags[PrimaryControllerType_Head] & (uint8_t)ControllerFlags::Enabled;
|
||||
bool leftHandEnabled = params.primaryControllerFlags[PrimaryControllerType_LeftHand] & (uint8_t)ControllerFlags::Enabled;
|
||||
|
|
|
@ -88,8 +88,8 @@ public:
|
|||
AnimPose secondaryControllerPoses[NumSecondaryControllerTypes]; // rig space
|
||||
uint8_t secondaryControllerFlags[NumSecondaryControllerTypes];
|
||||
bool isTalking;
|
||||
float inputX;
|
||||
float inputZ;
|
||||
float inputX = 0.0f;
|
||||
float inputZ = 0.0f;
|
||||
bool reactionEnabledFlags[NUM_AVATAR_BEGIN_END_REACTIONS];
|
||||
bool reactionTriggers[NUM_AVATAR_TRIGGER_REACTIONS];
|
||||
HFMJointShapeInfo hipsShapeInfo;
|
||||
|
|
Loading…
Reference in a new issue