SDK :
- Select tool does not keep its own instance of the selected spatial, it nows use the ToolController.selectedSpatial, for better selection synchronisation between sceneExplorer and sceneViewer git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9649 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
32152741cc
commit
116ced422b
@ -43,8 +43,6 @@ import org.openide.util.Lookup;
|
|||||||
*/
|
*/
|
||||||
public class SelectTool extends SceneEditTool {
|
public class SelectTool extends SceneEditTool {
|
||||||
|
|
||||||
protected Spatial selected;
|
|
||||||
|
|
||||||
private enum State {
|
private enum State {
|
||||||
|
|
||||||
translate, rotate, scale
|
translate, rotate, scale
|
||||||
@ -89,6 +87,7 @@ public class SelectTool extends SceneEditTool {
|
|||||||
public void keyPressed(KeyInputEvent kie) {
|
public void keyPressed(KeyInputEvent kie) {
|
||||||
|
|
||||||
checkModificatorKeys(kie); // alt,shift,ctrl
|
checkModificatorKeys(kie); // alt,shift,ctrl
|
||||||
|
Spatial selected = toolController.getSelectedSpatial();
|
||||||
|
|
||||||
if (selected == null) {
|
if (selected == null) {
|
||||||
return; // only do anything if a spatial is selected
|
return; // only do anything if a spatial is selected
|
||||||
@ -146,6 +145,7 @@ public class SelectTool extends SceneEditTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void clearState(boolean resetSelected) {
|
private void clearState(boolean resetSelected) {
|
||||||
|
Spatial selected = toolController.getSelectedSpatial();
|
||||||
if (resetSelected && selected != null) {
|
if (resetSelected && selected != null) {
|
||||||
// reset the transforms
|
// reset the transforms
|
||||||
if (startRot != null) {
|
if (startRot != null) {
|
||||||
@ -267,6 +267,7 @@ public class SelectTool extends SceneEditTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkStateKey(KeyInputEvent kie) {
|
private boolean checkStateKey(KeyInputEvent kie) {
|
||||||
|
Spatial selected = toolController.getSelectedSpatial();
|
||||||
if (kie.getKeyCode() == KeyInput.KEY_G) {
|
if (kie.getKeyCode() == KeyInput.KEY_G) {
|
||||||
currentState = State.translate;
|
currentState = State.translate;
|
||||||
MoveManager moveManager = Lookup.getDefault().lookup(MoveManager.class);
|
MoveManager moveManager = Lookup.getDefault().lookup(MoveManager.class);
|
||||||
@ -390,6 +391,7 @@ public class SelectTool extends SceneEditTool {
|
|||||||
@Override
|
@Override
|
||||||
public void actionPrimary(Vector2f screenCoord, boolean pressed, final JmeNode rootNode, DataObject dataObject) {
|
public void actionPrimary(Vector2f screenCoord, boolean pressed, final JmeNode rootNode, DataObject dataObject) {
|
||||||
if (!pressed) {
|
if (!pressed) {
|
||||||
|
Spatial selected = toolController.getSelectedSpatial();
|
||||||
// left mouse released
|
// left mouse released
|
||||||
if (!wasDraggingL) {
|
if (!wasDraggingL) {
|
||||||
// left mouse pressed
|
// left mouse pressed
|
||||||
@ -430,6 +432,7 @@ public class SelectTool extends SceneEditTool {
|
|||||||
@Override
|
@Override
|
||||||
public void actionSecondary(final Vector2f screenCoord, boolean pressed, final JmeNode rootNode, DataObject dataObject) {
|
public void actionSecondary(final Vector2f screenCoord, boolean pressed, final JmeNode rootNode, DataObject dataObject) {
|
||||||
if (pressed) {
|
if (pressed) {
|
||||||
|
Spatial selected = toolController.getSelectedSpatial();
|
||||||
// mouse down
|
// mouse down
|
||||||
|
|
||||||
if (moving != null) {
|
if (moving != null) {
|
||||||
@ -560,6 +563,7 @@ public class SelectTool extends SceneEditTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void doMouseScale(Vector3f axis, Vector2f screenCoord, JmeNode rootNode, JmeSpatial selectedSpatial) {
|
private void doMouseScale(Vector3f axis, Vector2f screenCoord, JmeNode rootNode, JmeSpatial selectedSpatial) {
|
||||||
|
Spatial selected = toolController.getSelectedSpatial();
|
||||||
// scale based on the original mouse position and original model-to-screen position
|
// scale based on the original mouse position and original model-to-screen position
|
||||||
// and compare that to the distance from the new mouse position and the original distance
|
// and compare that to the distance from the new mouse position and the original distance
|
||||||
if (startMouseCoord == null) {
|
if (startMouseCoord == null) {
|
||||||
@ -593,6 +597,7 @@ public class SelectTool extends SceneEditTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void doMouseRotate(Vector3f axis, Vector2f screenCoord, JmeNode rootNode, JmeSpatial selectedSpatial) {
|
private void doMouseRotate(Vector3f axis, Vector2f screenCoord, JmeNode rootNode, JmeSpatial selectedSpatial) {
|
||||||
|
Spatial selected = toolController.getSelectedSpatial();
|
||||||
if (startMouseCoord == null) {
|
if (startMouseCoord == null) {
|
||||||
startMouseCoord = screenCoord.clone();
|
startMouseCoord = screenCoord.clone();
|
||||||
}
|
}
|
||||||
@ -628,6 +633,7 @@ public class SelectTool extends SceneEditTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void duplicateSelected() {
|
private void duplicateSelected() {
|
||||||
|
Spatial selected = toolController.getSelectedSpatial();
|
||||||
if (selected == null) {
|
if (selected == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -659,6 +665,7 @@ public class SelectTool extends SceneEditTool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void deleteSelected() {
|
private void deleteSelected() {
|
||||||
|
Spatial selected = toolController.getSelectedSpatial();
|
||||||
if (selected == null) {
|
if (selected == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user