Browse Source

Update node attributes when editing with gizmo.

Lasse Öörni 14 years ago
parent
commit
4fe4cd6df0
2 changed files with 35 additions and 14 deletions
  1. 24 14
      Bin/Data/Scripts/Editor/EditorGizmo.as
  2. 11 0
      Bin/Data/Scripts/Editor/EditorNodeWindow.as

+ 24 - 14
Bin/Data/Scripts/Editor/EditorGizmo.as

@@ -155,13 +155,18 @@ void UseGizmo()
             if (gizmoAxisZ.selected)
             if (gizmoAxisZ.selected)
                 adjust += gizmoAxisZ.axisRay.direction * (gizmoAxisZ.t - gizmoAxisZ.lastT);
                 adjust += gizmoAxisZ.axisRay.direction * (gizmoAxisZ.t - gizmoAxisZ.lastT);
 
 
-            for (uint i = 0; i < editNodes.length; ++i)
+            if (adjust.length > M_EPSILON)
             {
             {
-                Node@ node = editNodes[i];
-                Vector3 nodeAdjust = adjust;
-                if (node.parent !is null)
-                    nodeAdjust = node.parent.WorldToLocal(Vector4(nodeAdjust, 0.0));
-                node.position = node.position + nodeAdjust;
+                for (uint i = 0; i < editNodes.length; ++i)
+                {
+                    Node@ node = editNodes[i];
+                    Vector3 nodeAdjust = adjust;
+                    if (node.parent !is null)
+                        nodeAdjust = node.parent.WorldToLocal(Vector4(nodeAdjust, 0.0));
+                    node.position = node.position + nodeAdjust;
+                }
+
+                UpdateNodeAttributes();
             }
             }
         }
         }
         else if (moveMode == OBJ_ROTATE)
         else if (moveMode == OBJ_ROTATE)
@@ -174,15 +179,20 @@ void UseGizmo()
             if (gizmoAxisZ.selected)
             if (gizmoAxisZ.selected)
                 adjust.z = (gizmoAxisZ.d - gizmoAxisZ.lastD) * rotSensitivity / scale;
                 adjust.z = (gizmoAxisZ.d - gizmoAxisZ.lastD) * rotSensitivity / scale;
 
 
-            for (uint i = 0; i < editNodes.length; ++i)
+            if (adjust.length > M_EPSILON)
             {
             {
-                /// \todo When multiple nodes selected, rotate them around the gizmo
-                Node@ node = editNodes[i];
-                Quaternion rotQuat(adjust);
-                if (axisMode == AXIS_WORLD)
-                    node.rotation = rotQuat * node.rotation;
-                else
-                    node.rotation = node.rotation * rotQuat;
+                for (uint i = 0; i < editNodes.length; ++i)
+                {
+                    /// \todo When multiple nodes selected, rotate them around the gizmo
+                    Node@ node = editNodes[i];
+                    Quaternion rotQuat(adjust);
+                    if (axisMode == AXIS_WORLD)
+                        node.rotation = rotQuat * node.rotation;
+                    else
+                        node.rotation = node.rotation * rotQuat;
+                }
+                
+                UpdateNodeAttributes();
             }
             }
         }
         }
     }
     }

+ 11 - 0
Bin/Data/Scripts/Editor/EditorNodeWindow.as

@@ -167,6 +167,17 @@ void UpdateAttributes(bool fullUpdate)
     }
     }
 }
 }
 
 
+void UpdateNodeAttributes()
+{
+    if (nodeWindow !is null)
+    {
+        Array<Serializable@> nodes;
+        if (editNode !is null)
+            nodes.Push(editNode);
+        UpdateAttributes(nodes, nodeWindow.GetChild("NodeAttributeList", true), false);
+    }
+}
+
 void UpdateAttributes(Array<Serializable@>@ serializables, ListView@ list, bool fullUpdate)
 void UpdateAttributes(Array<Serializable@>@ serializables, ListView@ list, bool fullUpdate)
 {
 {
     // If attributes have changed structurally, do a full update
     // If attributes have changed structurally, do a full update