Browse Source

Better lock mouse editing (#130)

When using right click and wheel click on l3d, the mouse is now lock which is better to move and rotate the camera around.
Remove the lock mouse feature when editing gizmo in translation mode. The object follows perfectly the cursor, it is more intuitive.
Jed974 4 years ago
parent
commit
128c20c998
2 changed files with 4 additions and 1 deletions
  1. 2 1
      hide/view/l3d/Gizmo.hx
  2. 2 0
      hide/view/l3d/Level3D.hx

+ 2 - 1
hide/view/l3d/Gizmo.hx

@@ -113,7 +113,8 @@ class Gizmo extends h3d.scene.Object {
 	}
 	}
 
 
 	public function startMove(mode: TransformMode, ?duplicating=false) {
 	public function startMove(mode: TransformMode, ?duplicating=false) {
-		mouseLock = true;
+		if (mode == Scale || mode == RotateX || mode == RotateY || mode == RotateZ)
+			mouseLock = true;
 		moving = true;
 		moving = true;
 		if(onStartMove != null) onStartMove(mode);
 		if(onStartMove != null) onStartMove(mode);
 		var startMat = getAbsPos().clone();
 		var startMat = getAbsPos().clone();

+ 2 - 0
hide/view/l3d/Level3D.hx

@@ -42,12 +42,14 @@ class CamController extends h3d.scene.CameraController {
 			pushStartX = pushX = e.relX;
 			pushStartX = pushX = e.relX;
 			pushStartY = pushY = e.relY;
 			pushStartY = pushY = e.relY;
 			startPush = new h2d.col.Point(pushX, pushY);
 			startPush = new h2d.col.Point(pushX, pushY);
+			@:privateAccess scene.window.mouseLock = true;
 		case ERelease, EReleaseOutside:
 		case ERelease, EReleaseOutside:
 			if( pushing == e.button ) {
 			if( pushing == e.button ) {
 				pushing = -1;
 				pushing = -1;
 				startPush = null;
 				startPush = null;
 				if( e.kind == ERelease && haxe.Timer.stamp() - pushTime < 0.2 && hxd.Math.distance(e.relX - pushStartX,e.relY - pushStartY) < 5 )
 				if( e.kind == ERelease && haxe.Timer.stamp() - pushTime < 0.2 && hxd.Math.distance(e.relX - pushStartX,e.relY - pushStartY) < 5 )
 					onClick(e);
 					onClick(e);
+				@:privateAccess scene.window.mouseLock = false;
 			}
 			}
 		case EMove:
 		case EMove:
 			switch( pushing ) {
 			switch( pushing ) {