|
@@ -46,6 +46,9 @@ public class MoveTool extends SceneEditTool {
|
|
private final Quaternion YZ = new Quaternion().fromAngleAxis(-FastMath.PI/2, new Vector3f(0,1,0));
|
|
private final Quaternion YZ = new Quaternion().fromAngleAxis(-FastMath.PI/2, new Vector3f(0,1,0));
|
|
private final Quaternion XZ = new Quaternion().fromAngleAxis(FastMath.PI/2, new Vector3f(1,0,0));
|
|
private final Quaternion XZ = new Quaternion().fromAngleAxis(FastMath.PI/2, new Vector3f(1,0,0));
|
|
|
|
|
|
|
|
+ //temp vars
|
|
|
|
+ private Quaternion rot = new Quaternion();
|
|
|
|
+ private Vector3f newPos = new Vector3f();
|
|
|
|
|
|
public MoveTool() {
|
|
public MoveTool() {
|
|
axisPickType = AxisMarkerPickType.axisAndPlane;
|
|
axisPickType = AxisMarkerPickType.axisAndPlane;
|
|
@@ -114,33 +117,31 @@ public class MoveTool extends SceneEditTool {
|
|
|
|
|
|
if (toolController.getSelectedSpatial() == null)
|
|
if (toolController.getSelectedSpatial() == null)
|
|
return;
|
|
return;
|
|
- TempVars vars = TempVars.get();
|
|
|
|
|
|
+
|
|
if (pickedPlane == null) {
|
|
if (pickedPlane == null) {
|
|
pickedPlane = pickAxisMarker(camera, screenCoord, axisPickType);
|
|
pickedPlane = pickAxisMarker(camera, screenCoord, axisPickType);
|
|
if (pickedPlane == null)
|
|
if (pickedPlane == null)
|
|
return;
|
|
return;
|
|
startLoc = toolController.getSelectedSpatial().getLocalTranslation().clone();
|
|
startLoc = toolController.getSelectedSpatial().getLocalTranslation().clone();
|
|
- Quaternion rot = vars.quat1.set(toolController.getSelectedSpatial().getWorldRotation());
|
|
|
|
|
|
+ rot = rot.set(toolController.getSelectedSpatial().getWorldRotation());
|
|
if (pickedPlane.equals(new Vector3f(1,1,0)))
|
|
if (pickedPlane.equals(new Vector3f(1,1,0)))
|
|
plane.setLocalRotation(rot.multLocal(XY));
|
|
plane.setLocalRotation(rot.multLocal(XY));
|
|
else if (pickedPlane.equals(new Vector3f(1,0,1)))
|
|
else if (pickedPlane.equals(new Vector3f(1,0,1)))
|
|
plane.setLocalRotation(rot.multLocal(XZ));
|
|
plane.setLocalRotation(rot.multLocal(XZ));
|
|
else if (pickedPlane.equals(new Vector3f(0,1,1)))
|
|
else if (pickedPlane.equals(new Vector3f(0,1,1)))
|
|
- plane.setLocalRotation(rot.multLocal(YZ));
|
|
|
|
|
|
+ plane.setLocalRotation(rot.multLocal(YZ));
|
|
plane.setLocalTranslation(startLoc);
|
|
plane.setLocalTranslation(startLoc);
|
|
}
|
|
}
|
|
|
|
|
|
Vector3f planeHit = pickWorldLocation(camera, screenCoord, plane, null);
|
|
Vector3f planeHit = pickWorldLocation(camera, screenCoord, plane, null);
|
|
- if (planeHit == null){
|
|
|
|
- vars.release();
|
|
|
|
|
|
+ if (planeHit == null){
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
Spatial selected = toolController.getSelectedSpatial();
|
|
Spatial selected = toolController.getSelectedSpatial();
|
|
Spatial parent = selected.getParent();
|
|
Spatial parent = selected.getParent();
|
|
|
|
|
|
-
|
|
|
|
- Vector3f newPos =vars.vect1;
|
|
|
|
|
|
+
|
|
if( parent == null ){
|
|
if( parent == null ){
|
|
//we are moving the root node, move is computed in local translation
|
|
//we are moving the root node, move is computed in local translation
|
|
if (offset == null){
|
|
if (offset == null){
|
|
@@ -166,7 +167,7 @@ public class MoveTool extends SceneEditTool {
|
|
selected.setLocalTranslation(newPos);
|
|
selected.setLocalTranslation(newPos);
|
|
lastLoc.set(newPos);
|
|
lastLoc.set(newPos);
|
|
}
|
|
}
|
|
- vars.release();
|
|
|
|
|
|
+
|
|
RigidBodyControl control = toolController.getSelectedSpatial().getControl(RigidBodyControl.class);
|
|
RigidBodyControl control = toolController.getSelectedSpatial().getControl(RigidBodyControl.class);
|
|
if (control != null) {
|
|
if (control != null) {
|
|
control.setPhysicsLocation(toolController.getSelectedSpatial().getWorldTranslation());
|
|
control.setPhysicsLocation(toolController.getSelectedSpatial().getWorldTranslation());
|