Ver código fonte

Shift+Drag Duplicating - Issue #378

raheelx 9 anos atrás
pai
commit
762c3d2a13

+ 18 - 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>();
 
@@ -184,6 +185,16 @@ void Gizmo3D::Use()
     Ray cameraRay = view3D_->GetCameraRay();
     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
     bool drag = input->GetMouseButtonDown(MOUSEB_LEFT);// && (Abs(input->GetMouseMoveX()) > 3 || Abs(input->GetMouseMoveY()) > 3);
     if (!drag)
@@ -193,6 +204,11 @@ void Gizmo3D::Use()
             scene_->SendEvent(E_SCENEEDITEND);
             dragging_ = false;
         }
+		
+		if (cloning_)
+		{
+			cloning_ = false;
+		}
 
         CalculateGizmoAxes();
     }

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

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