Преглед изворни кода

Fixed animation not updating if AnimatedModel was invisible while an animation played to the end.
Fixed event subscription error in TestSceneOld.

Lasse Öörni пре 12 година
родитељ
комит
085d26aa98
2 измењених фајлова са 6 додато и 3 уклоњено
  1. 0 1
      Bin/Data/Scripts/TestSceneOld.as
  2. 6 2
      Engine/Graphics/AnimatedModel.cpp

+ 0 - 1
Bin/Data/Scripts/TestSceneOld.as

@@ -44,7 +44,6 @@ void Start()
     SubscribeToEvent("MouseButtonUp", "HandleMouseButtonUp");
     SubscribeToEvent("MouseButtonUp", "HandleMouseButtonUp");
     SubscribeToEvent("PostRenderUpdate", "HandlePostRenderUpdate");
     SubscribeToEvent("PostRenderUpdate", "HandlePostRenderUpdate");
     SubscribeToEvent("PhysicsCollision", "HandlePhysicsCollision");
     SubscribeToEvent("PhysicsCollision", "HandlePhysicsCollision");
-    SubscribeToEvent("PhysicsPostStep", "HandlePhysicsPostStep");
 }
 }
 
 
 void InitScene()
 void InitScene()

+ 6 - 2
Engine/Graphics/AnimatedModel.cpp

@@ -191,7 +191,7 @@ void AnimatedModel::Update(const FrameInfo& frame)
     // Update animation here
     // Update animation here
     if (!animationDirty_ && !animationOrderDirty_)
     if (!animationDirty_ && !animationOrderDirty_)
         return;
         return;
-
+    
     // If node was invisible last frame, need to decide animation LOD distance here
     // If node was invisible last frame, need to decide animation LOD distance here
     // If headless, retain the current animation distance (should be 0)
     // If headless, retain the current animation distance (should be 0)
     if (frame.camera_ && abs((int)frame.frameNumber_ - (int)viewFrameNumber_) > 1)
     if (frame.camera_ && abs((int)frame.frameNumber_ - (int)viewFrameNumber_) > 1)
@@ -251,6 +251,10 @@ void AnimatedModel::UpdateBatches(const FrameInfo& frame)
 
 
 void AnimatedModel::UpdateGeometry(const FrameInfo& frame)
 void AnimatedModel::UpdateGeometry(const FrameInfo& frame)
 {
 {
+    // If model was invisible and did not update animation in the meanwhile, update now
+    if (animationDirty_)
+        UpdateAnimation(frame);
+
     if (morphsDirty_)
     if (morphsDirty_)
         UpdateMorphs();
         UpdateMorphs();
 
 
@@ -260,7 +264,7 @@ void AnimatedModel::UpdateGeometry(const FrameInfo& frame)
 
 
 UpdateGeometryType AnimatedModel::GetUpdateGeometryType()
 UpdateGeometryType AnimatedModel::GetUpdateGeometryType()
 {
 {
-    if (morphsDirty_)
+    if (animationDirty_ || morphsDirty_)
         return UPDATE_MAIN_THREAD;
         return UPDATE_MAIN_THREAD;
     else if (skinningDirty_)
     else if (skinningDirty_)
         return UPDATE_WORKER_THREAD;
         return UPDATE_WORKER_THREAD;