aster2013 10 years ago
parent
commit
7aa6b9d6e0
1 changed files with 7 additions and 10 deletions
  1. 7 10
      Source/Urho3D/Urho2D/AnimatedSprite2D.cpp

+ 7 - 10
Source/Urho3D/Urho2D/AnimatedSprite2D.cpp

@@ -236,23 +236,23 @@ void AnimatedSprite2D::OnWorldBoundingBoxUpdate()
     boundingBox_.Clear();
     worldBoundingBox_.Clear();
 
-    for (unsigned i = 0; i < sourceBatches_[0].vertices_.Size(); ++i)
-        worldBoundingBox_.Merge(sourceBatches_[0].vertices_[i].position_);
+    const Vector<SourceBatch2D>& sourceBatches = GetSourceBatches();
+    for (unsigned i = 0; i < sourceBatches[0].vertices_.Size(); ++i)
+        worldBoundingBox_.Merge(sourceBatches[0].vertices_[i].position_);
 
     boundingBox_ = worldBoundingBox_.Transformed(node_->GetWorldTransform().Inverse());
 }
 
 void AnimatedSprite2D::UpdateSourceBatches()
 {
-    sourceBatchesDirty_ = false;
-
 #ifdef URHO3D_SPINE
     if (skeleton_ && animationState_)
         UpdateSourceBatchesSpine();
 #endif
     if (spriterInstance_ && spriterInstance_->GetAnimation())
         UpdateSourceBatchesSpriter();
-    
+
+    sourceBatchesDirty_ = false;   
 }
 
 void AnimatedSprite2D::HandleScenePostUpdate(StringHash eventType, VariantMap& eventData)
@@ -316,6 +316,7 @@ void AnimatedSprite2D::UpdateSpineAnimation(float timeStep)
     spSkeleton_updateWorldTransform(skeleton_);
 
     sourceBatchesDirty_ = true;
+    worldBoundingBoxDirty_ = true;
 }
 
 void AnimatedSprite2D::UpdateSourceBatchesSpine()
@@ -411,8 +412,6 @@ void AnimatedSprite2D::UpdateSourceBatchesSpine()
             }
         }
     }
-
-    worldBoundingBoxDirty_ = true;
 }
 #endif
 
@@ -445,9 +444,9 @@ void AnimatedSprite2D::UpdateSpriterAnimation(float timeStep)
 {
     spriterInstance_->Update(timeStep * speed_);
     sourceBatchesDirty_ = true;
+    worldBoundingBoxDirty_ = true;
 }
 
-
 void AnimatedSprite2D::UpdateSourceBatchesSpriter()
 {
     const Matrix3x4& nodeWorldTransform = GetNode()->GetWorldTransform();
@@ -517,8 +516,6 @@ void AnimatedSprite2D::UpdateSourceBatchesSpriter()
         vertices.Push(vertex2);
         vertices.Push(vertex3);
     }
-
-    worldBoundingBoxDirty_ = true;
 }
 
 void AnimatedSprite2D::Dispose()