|
@@ -86,6 +86,8 @@ class SplineEditor {
|
|
var gizmos : Array<hrt.tools.Gizmo> = [];
|
|
var gizmos : Array<hrt.tools.Gizmo> = [];
|
|
var newSplinePointViewer : NewSplinePointViewer;
|
|
var newSplinePointViewer : NewSplinePointViewer;
|
|
|
|
|
|
|
|
+ var grid : h3d.scene.Object;
|
|
|
|
+
|
|
public function new( prefab : Spline, undo : hide.ui.UndoHistory ){
|
|
public function new( prefab : Spline, undo : hide.ui.UndoHistory ){
|
|
this.prefab = prefab;
|
|
this.prefab = prefab;
|
|
this.undo = undo;
|
|
this.undo = undo;
|
|
@@ -143,7 +145,7 @@ class SplineEditor {
|
|
if( !prefab.loop && (closestPt.next == null || closestPt.prev == null) ) {
|
|
if( !prefab.loop && (closestPt.next == null || closestPt.prev == null) ) {
|
|
var camera = @:privateAccess prefab.local3d.getScene().camera;
|
|
var camera = @:privateAccess prefab.local3d.getScene().camera;
|
|
var ray = camera.rayFromScreen(mouseX, mouseY);
|
|
var ray = camera.rayFromScreen(mouseX, mouseY);
|
|
- var normal = closestPt.next == null ? closestPt.prev.getAbsPos().up().toPoint() : closestPt.next.getAbsPos().up().toPoint();
|
|
|
|
|
|
+ var normal = getClosestPlanNormal();
|
|
var point = closestPt.next == null ? closestPt.prev.getAbsPos().getPosition().toPoint() : closestPt.next.getAbsPos().getPosition().toPoint();
|
|
var point = closestPt.next == null ? closestPt.prev.getAbsPos().getPosition().toPoint() : closestPt.next.getAbsPos().getPosition().toPoint();
|
|
var plane = h3d.col.Plane.fromNormalPoint(normal, point);
|
|
var plane = h3d.col.Plane.fromNormalPoint(normal, point);
|
|
var pt = ray.intersect(plane);
|
|
var pt = ray.intersect(plane);
|
|
@@ -153,6 +155,33 @@ class SplineEditor {
|
|
return closestPt;
|
|
return closestPt;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ Used to get the normal of the plan that is the more parallel to the viewport
|
|
|
|
+ **/
|
|
|
|
+ function getClosestPlanNormal() {
|
|
|
|
+ var camera = @:privateAccess prefab.local3d.getScene().camera;
|
|
|
|
+ var x = new h3d.Vector(1,0,0);
|
|
|
|
+ var y = new h3d.Vector(0,1,0);
|
|
|
|
+ var z = new h3d.Vector(0,0,1);
|
|
|
|
+
|
|
|
|
+ var normal = x;
|
|
|
|
+ var dot = Math.abs(camera.getForward().dot(x));
|
|
|
|
+
|
|
|
|
+ var tmpDot = Math.abs(camera.getForward().dot(y));
|
|
|
|
+ if (tmpDot > dot) {
|
|
|
|
+ normal = y;
|
|
|
|
+ dot = tmpDot;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ tmpDot = Math.abs(camera.getForward().dot(z));
|
|
|
|
+ if (tmpDot > dot) {
|
|
|
|
+ normal = z;
|
|
|
|
+ dot = tmpDot;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return normal;
|
|
|
|
+ }
|
|
|
|
+
|
|
function getClosestPointFromMouse( mouseX : Float, mouseY : Float) : SplinePointData {
|
|
function getClosestPointFromMouse( mouseX : Float, mouseY : Float) : SplinePointData {
|
|
|
|
|
|
if(prefab == null || prefab.local3d == null || prefab.local3d.getScene() == null )
|
|
if(prefab == null || prefab.local3d == null || prefab.local3d.getScene() == null )
|
|
@@ -519,11 +548,26 @@ class SplineEditor {
|
|
newSplinePointViewer.visible = true;
|
|
newSplinePointViewer.visible = true;
|
|
|
|
|
|
var npt = getNewPointPosition(s2d.mouseX, s2d.mouseY);
|
|
var npt = getNewPointPosition(s2d.mouseX, s2d.mouseY);
|
|
|
|
+
|
|
|
|
+ if (grid != null) {
|
|
|
|
+ grid.remove();
|
|
|
|
+ grid = null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var normal = getClosestPlanNormal();
|
|
|
|
+ var closest = getClosestPointFromMouse(s2d.mouseX, s2d.mouseY);
|
|
|
|
+ grid = editContext.scene.editor.createGrid(closest.pos , normal, 200, 1, normal * 0.2);
|
|
|
|
+
|
|
newSplinePointViewer.update(npt);
|
|
newSplinePointViewer.update(npt);
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
if( newSplinePointViewer != null )
|
|
if( newSplinePointViewer != null )
|
|
newSplinePointViewer.visible = false;
|
|
newSplinePointViewer.visible = false;
|
|
|
|
+
|
|
|
|
+ if (grid != null) {
|
|
|
|
+ grid.remove();
|
|
|
|
+ grid = null;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
if( K.isDown( K.SHIFT ) ) {
|
|
if( K.isDown( K.SHIFT ) ) {
|