Răsfoiți Sursa

Bugfix: Animation gizmo now shows correct bounds of the animated object

BearishSun 8 ani în urmă
părinte
comite
bf5437064f
1 a modificat fișierele cu 18 adăugiri și 8 ștergeri
  1. 18 8
      Source/MBansheeEditor/Windows/Animation/AnimationGizmo.cs

+ 18 - 8
Source/MBansheeEditor/Windows/Animation/AnimationGizmo.cs

@@ -25,14 +25,24 @@ namespace BansheeEditor
             Gizmos.Color = Color.Green;
             Gizmos.Transform = Matrix4.Identity;
 
-            Matrix4 parentTfrm;
-            if (so.Parent != null)
-                parentTfrm = so.Parent.WorldTransform;
-            else
-                parentTfrm = Matrix4.Identity;
-
-            AABox bounds = animation.Bounds;
-            bounds.TransformAffine(parentTfrm);
+            AABox bounds = new AABox();
+
+            bool useAnimBounds = animation.UseBounds;
+            if (!useAnimBounds)
+            {
+                Renderable renderable = so.GetComponent<Renderable>();
+
+                if (renderable != null)
+                    bounds = renderable.Bounds.Box;
+                else
+                    useAnimBounds = true;
+            }
+
+            if (useAnimBounds)
+            {
+                bounds = animation.Bounds;
+                bounds.TransformAffine(so.WorldTransform);
+            }
 
             Gizmos.DrawWireCube(bounds.Center, bounds.Size * 0.5f);
         }