浏览代码

Remove all instances of Drawable2D from materialDirtyDrawables_ when it is being removed from the scene. Fixes #618.

Lasse Öörni 11 年之前
父节点
当前提交
62b3d6987f
共有 1 个文件被更改,包括 12 次插入0 次删除
  1. 12 0
      Source/Urho3D/Urho2D/Renderer2D.cpp

+ 12 - 0
Source/Urho3D/Urho2D/Renderer2D.cpp

@@ -215,12 +215,24 @@ void Renderer2D::RemoveDrawable(Drawable2D* drawable)
         return;
         return;
 
 
     drawables_.Remove(drawable);
     drawables_.Remove(drawable);
+
+    // Drawable may be on the dirty list multiple times; remove all instances
+    for (;;)
+    {
+        PODVector<Drawable2D*>::Iterator i = materialDirtyDrawables_.Find(drawable);
+        if (i != materialDirtyDrawables_.End())
+            materialDirtyDrawables_.Erase(i);
+        else
+            break;
+    }
+
     materialDirtyDrawables_.Remove(drawable);
     materialDirtyDrawables_.Remove(drawable);
     orderDirty_ = true;
     orderDirty_ = true;
 }
 }
 
 
 void Renderer2D::MarkMaterialDirty(Drawable2D* drawable)
 void Renderer2D::MarkMaterialDirty(Drawable2D* drawable)
 {
 {
+    // Note: this may cause the drawable to appear on the dirty list multiple times
     materialDirtyDrawables_.Push(drawable);
     materialDirtyDrawables_.Push(drawable);
 }
 }