Fixed animations not playing correctly

This commit is contained in:
smallmodel 2023-10-23 14:46:44 +02:00
parent 4d7fcb77c2
commit 31f2573b28
No known key found for this signature in database
GPG key ID: 9F2D623CEDF08512

View file

@ -726,19 +726,19 @@ void SimpleActor::EventGetCrossblendTime(Event *ev)
void SimpleActor::StartCrossBlendAnimSlot(int slot) void SimpleActor::StartCrossBlendAnimSlot(int slot)
{ {
if (!m_weightType[slot]) { if (m_weightType[slot] == ANIM_WEIGHT_NONE) {
return; return;
} }
switch (m_weightType[slot]) { switch (m_weightType[slot]) {
case ANIM_WEIGHT_AIM: case ANIM_WEIGHT_MOTION:
m_weightType[slot] = 4; m_weightType[slot] = ANIM_WEIGHT_CROSSBLEND_2;
break; break;
case ANIM_WEIGHT_SAY: case ANIM_WEIGHT_SAY:
m_weightType[slot] = 5; m_weightType[slot] = ANIM_WEIGHT_CROSSBLEND_DIALOG;
break; break;
default: default:
m_weightType[slot] = 3; m_weightType[slot] = ANIM_WEIGHT_CROSSBLEND_1;
break; break;
} }
@ -750,7 +750,7 @@ void SimpleActor::StartMotionAnimSlot(int slot, int anim, float weight)
{ {
slot = GetMotionSlot(slot); slot = GetMotionSlot(slot);
m_weightType[slot] = ANIM_WEIGHT_AIM; m_weightType[slot] = ANIM_WEIGHT_MOTION;
m_weightCrossBlend[slot] = 0.0; m_weightCrossBlend[slot] = 0.0;
m_weightBase[slot] = weight; m_weightBase[slot] = weight;
NewAnim(anim, slot, 1.0); NewAnim(anim, slot, 1.0);
@ -764,7 +764,7 @@ void SimpleActor::StartAimMotionAnimSlot(int slot, int anim)
{ {
slot = GetMotionSlot(slot); slot = GetMotionSlot(slot);
m_weightType[slot] = ANIM_WEIGHT_AIM; m_weightType[slot] = ANIM_WEIGHT_MOTION;
m_weightCrossBlend[slot] = 0.0; m_weightCrossBlend[slot] = 0.0;
NewAnim(anim, slot, 1.0); NewAnim(anim, slot, 1.0);
@ -820,7 +820,7 @@ void SimpleActor::SetBlendedWeight(int slot)
if (m_weightCrossBlend[slot] < 1.0) { if (m_weightCrossBlend[slot] < 1.0) {
float w; float w;
w = (3.0 - m_weightCrossBlend[slot] * 2) * Square(m_weightCrossBlend[slot]); w = (3.0 - m_weightCrossBlend[slot] - m_weightCrossBlend[slot]) * Square(m_weightCrossBlend[slot]);
SetWeight(slot, m_weightBase[slot] * w); SetWeight(slot, m_weightBase[slot] * w);
} else { } else {
m_weightCrossBlend[slot] = 1.0; m_weightCrossBlend[slot] = 1.0;
@ -1279,12 +1279,15 @@ bool SimpleActor::UpdateSelectedAnimation(void)
if (m_csNextAnimString != STRING_NULL) { if (m_csNextAnimString != STRING_NULL) {
if (!m_bNextForceStart && m_pAnimThread && m_eAnimMode == m_eNextAnimMode if (!m_bNextForceStart && m_pAnimThread && m_eAnimMode == m_eNextAnimMode
&& (m_fPathGoalTime > level.time || m_Anim.IsFile(m_csNextAnimString))) { && (m_fPathGoalTime > level.time || m_Anim.IsFile(m_csNextAnimString))) {
// Clear the next animation
m_eNextAnimMode = -1; m_eNextAnimMode = -1;
if (!m_bStartPathGoalEndAnim) { if (!m_bStartPathGoalEndAnim) {
return false; return false;
} }
m_bStartPathGoalEndAnim = false; m_bStartPathGoalEndAnim = false;
if (!m_Anim.IsFile(m_csPathGoalEndAnimScript)) {
if (m_Anim.IsFile(m_csPathGoalEndAnimScript)) {
return false; return false;
} }
@ -1295,7 +1298,7 @@ bool SimpleActor::UpdateSelectedAnimation(void)
m_Anim.TrySetScript(m_csNextAnimString); m_Anim.TrySetScript(m_csNextAnimString);
} else { } else {
if (!m_bNextForceStart && m_pAnimThread && m_eAnimMode == m_eNextAnimMode && m_Anim == m_NextAnimLabel) { if (!m_bNextForceStart && m_pAnimThread && m_eAnimMode == m_eNextAnimMode && m_Anim == m_NextAnimLabel) {
m_bStartPathGoalEndAnim = true; m_bStartPathGoalEndAnim = false;
m_eNextAnimMode = -1; m_eNextAnimMode = -1;
return false; return false;
} }
@ -1304,6 +1307,7 @@ bool SimpleActor::UpdateSelectedAnimation(void)
} }
m_eAnimMode = m_eNextAnimMode; m_eAnimMode = m_eNextAnimMode;
if (m_eAnimMode != ANIM_MODE_PATH_GOAL) { if (m_eAnimMode != ANIM_MODE_PATH_GOAL) {
m_csPathGoalEndAnimScript = STRING_EMPTY; m_csPathGoalEndAnimScript = STRING_EMPTY;
} }