Skip to content

Commit 57a8949

Browse files
authored
bugfix(anim): Fix single animation updates (#1702)
1 parent 3b78b63 commit 57a8949

File tree

4 files changed

+46
-38
lines changed

4 files changed

+46
-38
lines changed

Generals/Code/Libraries/Source/WWVegas/WW3D2/animobj.cpp

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,12 @@ void Animatable3DObjClass::Render(RenderInfoClass & rinfo)
286286
return;
287287
}
288288

289-
if (!Is_Hierarchy_Valid() || Are_Sub_Object_Transforms_Dirty()) {
289+
//
290+
// Force the hierarchy to be recalculated for single animations.
291+
//
292+
const bool isSingleAnim = CurMotionMode == SINGLE_ANIM && ModeAnim.AnimMode != ANIM_MODE_MANUAL;
293+
294+
if (isSingleAnim || !Is_Hierarchy_Valid() || Are_Sub_Object_Transforms_Dirty()) {
290295
Update_Sub_Object_Transforms();
291296
}
292297
}
@@ -307,7 +312,12 @@ void Animatable3DObjClass::Special_Render(SpecialRenderInfoClass & rinfo)
307312
{
308313
if (HTree == NULL) return;
309314

310-
if (!Is_Hierarchy_Valid()) {
315+
//
316+
// Force the hierarchy to be recalculated for single animations.
317+
//
318+
const bool isSingleAnim = CurMotionMode == SINGLE_ANIM && ModeAnim.AnimMode != ANIM_MODE_MANUAL;
319+
320+
if (isSingleAnim || !Is_Hierarchy_Valid()) {
311321
Update_Sub_Object_Transforms();
312322
}
313323
}
@@ -805,7 +815,7 @@ void Animatable3DObjClass::Update_Sub_Object_Transforms(void)
805815
ModeInterp.PrevFrame1 = AnimatedSoundMgrClass::Trigger_Sound(ModeInterp.Motion1, ModeInterp.PrevFrame1, ModeInterp.Frame1, HTree->Get_Transform(ModeInterp.Motion1->Get_Embedded_Sound_Bone_Index()));
806816
}
807817

808-
break;
818+
break;
809819

810820
case MULTIPLE_ANIM:
811821
{
@@ -1025,19 +1035,13 @@ void Animatable3DObjClass::Single_Anim_Progress (void)
10251035
//
10261036
// Update the current frame (only works in "SINGLE_ANIM" mode!)
10271037
//
1028-
if (CurMotionMode == SINGLE_ANIM) {
1038+
WWASSERT(CurMotionMode == SINGLE_ANIM);
10291039

1030-
//
1031-
// Update the frame number and sync time
1032-
//
1033-
ModeAnim.PrevFrame = ModeAnim.Frame;
1034-
ModeAnim.Frame = Compute_Current_Frame(&ModeAnim.animDirection);
1035-
1036-
//
1037-
// Force the hierarchy to be recalculated
1038-
//
1039-
Set_Hierarchy_Valid (false);
1040-
}
1040+
//
1041+
// Update the frame number and sync time
1042+
//
1043+
ModeAnim.PrevFrame = ModeAnim.Frame;
1044+
ModeAnim.Frame = Compute_Current_Frame(&ModeAnim.animDirection);
10411045
}
10421046

10431047

Generals/Code/Libraries/Source/WWVegas/WW3D2/animobj.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class Animatable3DObjClass : public CompositeRenderObjClass
113113

114114
//
115115
// Simple bone evaluation methods for when the caller doesn't want
116-
// to update the heirarchy, but needs to know the transform of
116+
// to update the hierarchy, but needs to know the transform of
117117
// a bone at a given frame.
118118
//
119119
virtual bool Simple_Evaluate_Bone(int boneindex, Matrix3D *tm) const;
@@ -153,14 +153,14 @@ class Animatable3DObjClass : public CompositeRenderObjClass
153153
void Combo_Update( const Matrix3D & root,
154154
HAnimComboClass *anim);
155155

156-
// flag to kep track of whether the hierarchy tree transforms are currently valid
156+
// flag to keep track of whether the hierarchy tree transforms are currently valid
157157
bool Is_Hierarchy_Valid(void) const { return IsTreeValid; }
158158
void Set_Hierarchy_Valid(bool onoff) const { IsTreeValid = onoff; }
159159

160-
// Progress anims for single anim (loop and once)
160+
// Progress animations for single anim (loop and once)
161161
void Single_Anim_Progress( void );
162162

163-
// Release any anims
163+
// Release any animations
164164
void Release( void );
165165

166166
protected:

GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/animobj.cpp

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,12 @@ void Animatable3DObjClass::Render(RenderInfoClass & rinfo)
286286
return;
287287
}
288288

289-
if (!Is_Hierarchy_Valid() || Are_Sub_Object_Transforms_Dirty()) {
289+
//
290+
// Force the hierarchy to be recalculated for single animations.
291+
//
292+
const bool isSingleAnim = CurMotionMode == SINGLE_ANIM && ModeAnim.AnimMode != ANIM_MODE_MANUAL;
293+
294+
if (isSingleAnim || !Is_Hierarchy_Valid() || Are_Sub_Object_Transforms_Dirty()) {
290295
Update_Sub_Object_Transforms();
291296
}
292297
}
@@ -307,7 +312,12 @@ void Animatable3DObjClass::Special_Render(SpecialRenderInfoClass & rinfo)
307312
{
308313
if (HTree == NULL) return;
309314

310-
if (!Is_Hierarchy_Valid()) {
315+
//
316+
// Force the hierarchy to be recalculated for single animations.
317+
//
318+
const bool isSingleAnim = CurMotionMode == SINGLE_ANIM && ModeAnim.AnimMode != ANIM_MODE_MANUAL;
319+
320+
if (isSingleAnim || !Is_Hierarchy_Valid()) {
311321
Update_Sub_Object_Transforms();
312322
}
313323
}
@@ -804,7 +814,7 @@ void Animatable3DObjClass::Update_Sub_Object_Transforms(void)
804814
ModeInterp.PrevFrame1 = AnimatedSoundMgrClass::Trigger_Sound(ModeInterp.Motion1, ModeInterp.PrevFrame1, ModeInterp.Frame1, HTree->Get_Transform(ModeInterp.Motion1->Get_Embedded_Sound_Bone_Index()));
805815
}
806816

807-
break;
817+
break;
808818

809819
case MULTIPLE_ANIM:
810820
{
@@ -1033,19 +1043,13 @@ void Animatable3DObjClass::Single_Anim_Progress (void)
10331043
//
10341044
// Update the current frame (only works in "SINGLE_ANIM" mode!)
10351045
//
1036-
if (CurMotionMode == SINGLE_ANIM) {
1046+
WWASSERT(CurMotionMode == SINGLE_ANIM);
10371047

1038-
//
1039-
// Update the frame number and sync time
1040-
//
1041-
ModeAnim.PrevFrame = ModeAnim.Frame;
1042-
ModeAnim.Frame = Compute_Current_Frame(&ModeAnim.animDirection);
1043-
1044-
//
1045-
// Force the hierarchy to be recalculated
1046-
//
1047-
Set_Hierarchy_Valid (false);
1048-
}
1048+
//
1049+
// Update the frame number and sync time
1050+
//
1051+
ModeAnim.PrevFrame = ModeAnim.Frame;
1052+
ModeAnim.Frame = Compute_Current_Frame(&ModeAnim.animDirection);
10491053
}
10501054

10511055

GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/animobj.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class Animatable3DObjClass : public CompositeRenderObjClass
113113

114114
//
115115
// Simple bone evaluation methods for when the caller doesn't want
116-
// to update the heirarchy, but needs to know the transform of
116+
// to update the hierarchy, but needs to know the transform of
117117
// a bone at a given frame.
118118
//
119119
virtual bool Simple_Evaluate_Bone(int boneindex, Matrix3D *tm) const;
@@ -153,14 +153,14 @@ class Animatable3DObjClass : public CompositeRenderObjClass
153153
void Combo_Update( const Matrix3D & root,
154154
HAnimComboClass *anim);
155155

156-
// flag to kep track of whether the hierarchy tree transforms are currently valid
156+
// flag to keep track of whether the hierarchy tree transforms are currently valid
157157
bool Is_Hierarchy_Valid(void) const { return IsTreeValid; }
158158
void Set_Hierarchy_Valid(bool onoff) const { IsTreeValid = onoff; }
159159

160-
// Progress anims for single anim (loop and once)
160+
// Progress animations for single anim (loop and once)
161161
void Single_Anim_Progress( void );
162162

163-
// Release any anims
163+
// Release any animations
164164
void Release( void );
165165

166166
protected:

0 commit comments

Comments
 (0)