Browse Source

Merge pull request #735 from raheelx/ShiftDragCloning

Shift drag cloning
JoshEngebretson 9 years ago
parent
commit
114dff219a

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

@@ -38,8 +38,9 @@ namespace AtomicEditor
 {
 {
 
 
 
 
-Gizmo3D::Gizmo3D(Context* context) : Object(context),
-    dragging_(false)
+    Gizmo3D::Gizmo3D(Context* context) : Object(context),
+        dragging_(false),
+        cloning_(false)
 {
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     ResourceCache* cache = GetSubsystem<ResourceCache>();
 
 
@@ -184,6 +185,16 @@ void Gizmo3D::Use()
     Ray cameraRay = view3D_->GetCameraRay();
     Ray cameraRay = view3D_->GetCameraRay();
     float scale = gizmoNode_->GetScale().x_;
     float scale = gizmoNode_->GetScale().x_;
 
 
+    // Clones an object when it's dragged while holding down Shift
+    bool dragShift = input->GetMouseButtonDown(MOUSEB_LEFT) && input->GetKeyDown(KEY_SHIFT);
+
+    if (dragShift && !cloning_)
+    {
+        cloning_ = true;
+        selection_->Copy();
+        selection_->Paste();
+    }
+
     // Recalculate axes only when not left-dragging
     // Recalculate axes only when not left-dragging
     bool drag = input->GetMouseButtonDown(MOUSEB_LEFT);// && (Abs(input->GetMouseMoveX()) > 3 || Abs(input->GetMouseMoveY()) > 3);
     bool drag = input->GetMouseButtonDown(MOUSEB_LEFT);// && (Abs(input->GetMouseMoveX()) > 3 || Abs(input->GetMouseMoveY()) > 3);
     if (!drag)
     if (!drag)
@@ -194,6 +205,8 @@ void Gizmo3D::Use()
             dragging_ = false;
             dragging_ = false;
         }
         }
 
 
+        cloning_ = false;
+
         CalculateGizmoAxes();
         CalculateGizmoAxes();
     }
     }
 
 

+ 1 - 0
Source/AtomicEditor/Editors/SceneEditor3D/Gizmo3D.h

@@ -184,6 +184,7 @@ private:
     AxisMode axisMode_;
     AxisMode axisMode_;
 
 
     bool dragging_;
     bool dragging_;
+    bool cloning_;
 
 
     // snap settings
     // snap settings
     float snapTranslationX_;
     float snapTranslationX_;