Browse Source

Update inspector based on gizmo movement

Josh Engebretson 10 years ago
parent
commit
87f394fcc7

+ 55 - 2
Script/AtomicEditor/ui/frames/inspector/NodeInspector.ts

@@ -10,7 +10,59 @@ class NodeInspector extends ScriptWidget {
 
 
         super();
         super();
 
 
-        this.subscribeToEvent(this, "WidgetEvent", (data) => this.handleWidgetEvent(data));
+        this.subscribeToEvent(this, "WidgetEvent", (ev) => this.handleWidgetEvent(ev));
+        this.subscribeToEvent("GizmoMoved", (ev) => this.handleGizmoModed(ev));
+        this.subscribeToEvent("Update", (ev) => this.handleUpdate(ev));
+
+    }
+
+    handleUpdate(ev) {
+
+        // to keep from spamming UI update we have a little delta on the gizmo updates
+        if (!this.node) {
+            this.gizmoMoved = false;
+            return;
+        }
+
+        if (this.gizmoMoved) {
+
+            if (this.updateDelta > 1.0) {
+
+                this.updateDelta = 0.0;
+
+            }
+            else {
+
+                this.updateDelta -= ev.timeStep;
+
+            }
+
+            if (this.updateDelta <= 0) {
+
+                for (var i in this.bindings) {
+
+                    this.bindings[i].setWidgetValueFromObject();
+
+                }
+
+                this.gizmoMoved = false;
+                this.updateDelta = 0;
+
+            }
+
+
+        }
+
+    }
+
+
+    handleGizmoModed(ev) {
+
+        if (!this.node) return;
+
+        this.gizmoMoved = true;
+
+        this.updateDelta += .3;
 
 
     }
     }
 
 
@@ -260,7 +312,8 @@ class NodeInspector extends ScriptWidget {
     node: Atomic.Node;
     node: Atomic.Node;
     nodeLayout: Atomic.UILayout;
     nodeLayout: Atomic.UILayout;
     bindings: Array<DataBinding>;
     bindings: Array<DataBinding>;
-
+    gizmoMoved = false;
+    updateDelta = 0;
 
 
 }
 }
 
 

+ 3 - 2
Source/AtomicEditor/Editors/SceneEditor3D/Gizmo3D.cpp

@@ -11,6 +11,7 @@
 
 
 #include <Atomic/Input/Input.h>
 #include <Atomic/Input/Input.h>
 
 
+#include "SceneEditor3DEvents.h"
 #include "Gizmo3D.h"
 #include "Gizmo3D.h"
 
 
 namespace AtomicEditor
 namespace AtomicEditor
@@ -133,8 +134,6 @@ void Gizmo3D::Update(Vector<Node *> &editNodes)
 
 
     Use();
     Use();
     Position();
     Position();
-
-
 }
 }
 
 
 void Gizmo3D::CalculateGizmoAxes()
 void Gizmo3D::CalculateGizmoAxes()
@@ -343,6 +342,8 @@ void Gizmo3D::Moved()
     gizmoAxisX_.Moved();
     gizmoAxisX_.Moved();
     gizmoAxisY_.Moved();
     gizmoAxisY_.Moved();
     gizmoAxisZ_.Moved();
     gizmoAxisZ_.Moved();
+
+    SendEvent(E_GIZMOMOVED);
 }
 }
 
 
 
 

+ 4 - 0
Source/AtomicEditor/Editors/SceneEditor3D/SceneEditor3DEvents.h

@@ -12,5 +12,9 @@ EVENT(E_GIZMOEDITMODECHANGED, GizmoEditModeChanged)
     PARAM(P_MODE, MODE);            // int
     PARAM(P_MODE, MODE);            // int
 }
 }
 
 
+EVENT(E_GIZMOMOVED, GizmoMoved)
+{
+
+}
 
 
 }
 }