From 352ee2083b116f07b6df474b1a1ac6b93fd71064 Mon Sep 17 00:00:00 2001 From: "nor..67" Date: Tue, 8 May 2012 00:55:01 +0000 Subject: [PATCH] SDK: - Make SceneEditor Controller good example of the async AWT/GL therading model of the SDK git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9355 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../scenecomposer/SceneEditorController.java | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneEditorController.java b/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneEditorController.java index 65c4603b6..dcf318486 100644 --- a/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneEditorController.java +++ b/sdk/jme3-scenecomposer/src/com/jme3/gde/scenecomposer/SceneEditorController.java @@ -54,7 +54,8 @@ import org.openide.util.Exceptions; import org.openide.util.Lookup; /** - * + * Example of a class that edits the scene, logic happens on the AWT side, + * do.. methods do not use global variables. * @author normenhansen */ @SuppressWarnings("unchecked") @@ -210,11 +211,10 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen } Vector3f after = new Vector3f(localTranslation); selected.setLocalTranslation(localTranslation); - AbstractSceneExplorerNode selectedSpat = this.selectedSpat; - moveUndo(selected, before, after, selectedSpat); + moveUndo(selected, before, after); } - private void moveUndo(final Spatial spatial, final Vector3f before, final Vector3f after, final AbstractSceneExplorerNode parentNode) { + private void moveUndo(final Spatial spatial, final Vector3f before, final Vector3f after) { if (spatial != null && before != null) { Lookup.getDefault().lookup(SceneUndoRedoManager.class).addEdit(this, new AbstractUndoableSceneEdit() { @@ -261,10 +261,10 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen Vector3f before = new Vector3f(selected.getLocalTranslation()); selected.setLocalTranslation(before.add(translation)); Vector3f after = new Vector3f(selected.getLocalTranslation()); - nudgeUndo(selected, before, after, selectedSpat); + nudgeUndo(selected, before, after); } - private void nudgeUndo(final Spatial spatial, final Vector3f before, final Vector3f after, final AbstractSceneExplorerNode parentNode) { + private void nudgeUndo(final Spatial spatial, final Vector3f before, final Vector3f after) { if (spatial != null && before != null) { Lookup.getDefault().lookup(SceneUndoRedoManager.class).addEdit(this, new AbstractUndoableSceneEdit() { @@ -311,10 +311,10 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen Quaternion before = new Quaternion(selected.getLocalRotation()); selected.rotate(rotation); Quaternion after = new Quaternion(selected.getLocalRotation()); - rotateUndo(selected, before, after, selectedSpat); + rotateUndo(selected, before, after); } - private void rotateUndo(final Spatial spatial, final Quaternion before, final Quaternion after, final AbstractSceneExplorerNode parentNode) { + private void rotateUndo(final Spatial spatial, final Quaternion before, final Quaternion after) { if (spatial != null && before != null) { Lookup.getDefault().lookup(SceneUndoRedoManager.class).addEdit(this, new AbstractUndoableSceneEdit() { @@ -422,8 +422,7 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen parent.attachChild(selected); } refreshSelected(); - AbstractSceneExplorerNode selectedSpat = this.selectedSpat; - addControlUndo(parent, control, selectedSpat); + addControlUndo(parent, control, jmeRootNode); } public void createDynamicPhysicsMeshForSelectedSpatial(final float weight) { @@ -463,8 +462,7 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen parent.attachChild(selected); } refreshSelected(); - AbstractSceneExplorerNode selectedSpat = this.selectedSpat; - addControlUndo(parent, control, selectedSpat); + addControlUndo(parent, control, jmeRootNode); } public void createCharacterControlForSelectedSpatial(final boolean auto, final float radius, final float height) { @@ -509,8 +507,7 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen parent.attachChild(selected); } refreshSelected(); - AbstractSceneExplorerNode selectedSpat = this.selectedSpat; - addControlUndo(parent, control, selectedSpat); + addControlUndo(parent, control, jmeRootNode); } private void addControlUndo(final Node undoParent, final Control undoControl, final AbstractSceneExplorerNode parentNode) { @@ -583,7 +580,7 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen } } refreshSelected(); - addSpatialUndo(selected, linkNode, null, selectedSpat); + addSpatialUndo(selected, linkNode, null, jmeRootNode); } catch (Exception ex) { Confirmation msg = new NotifyDescriptor.Confirmation( "Error importing " + file.getName() + "\n" + ex.toString(), @@ -632,7 +629,7 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen selected.worldToLocal(location, localVec); linkNode.setLocalTranslation(localVec); } - addSpatialUndo(selected, linkNode, null, selectedSpat); + addSpatialUndo(selected, linkNode, null, jmeRootNode); } refreshSelected(); } catch (Exception ex) { @@ -682,7 +679,7 @@ public class SceneEditorController implements PropertyChangeListener, NodeListen } } refreshSelected(); - addSpatialUndo(selected, file, null, selectedSpat); + addSpatialUndo(selected, file, null, jmeRootNode); } catch (Exception ex) { Confirmation msg = new NotifyDescriptor.Confirmation( "Error importing " + file.getName() + "\n" + ex.toString(),