From b90d093ef014959c84f8133f9e2c4c124a063ea9 Mon Sep 17 00:00:00 2001 From: "nor..67" Date: Thu, 10 Nov 2011 01:01:15 +0000 Subject: [PATCH] SDK: - fix threading in SceneToolController git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8626 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../scene/controller/SceneToolController.java | 32 +++++++++++++++---- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/sdk/jme3-core/src/com/jme3/gde/core/scene/controller/SceneToolController.java b/sdk/jme3-core/src/com/jme3/gde/core/scene/controller/SceneToolController.java index 266b0da6d..a8697a789 100644 --- a/sdk/jme3-core/src/com/jme3/gde/core/scene/controller/SceneToolController.java +++ b/sdk/jme3-core/src/com/jme3/gde/core/scene/controller/SceneToolController.java @@ -97,7 +97,6 @@ public class SceneToolController implements AppState { //cursor.attachChild(cursorArrowX); cursor.attachChild(cursorArrowY); //cursor.attachChild(cursorArrowZ); - toolsNode.attachChild(cursor); //grid grid = new Geometry("grid", new Grid(20, 20, 1.0f)); @@ -203,11 +202,17 @@ public class SceneToolController implements AppState { if (mesh == null) { return; } - Geometry selectionGeometry = new Geometry("selection_geometry_sceneviewer", mesh); + final Geometry selectionGeometry = new Geometry("selection_geometry_sceneviewer", mesh); selectionGeometry.setMaterial(blueMat); selectionGeometry.setLocalTransform(geom.getWorldTransform()); - toolsNode.attachChild(selectionGeometry); selectionShape = selectionGeometry; + SceneApplication.getApplication().enqueue(new Callable() { + + public Object call() throws Exception { + toolsNode.attachChild(selectionGeometry); + return null; + } + }); } protected void attachBoxSelection(Spatial geom) { @@ -219,12 +224,18 @@ public class SceneToolController implements AppState { WireBox wireBox = new WireBox(); wireBox.fromBoundingBox(bbox); selctionShapeOffset.set(bbox.getCenter()).subtractLocal(geom.getWorldTranslation()); - Geometry selectionGeometry = new Geometry("selection_geometry_sceneviewer", wireBox); + final Geometry selectionGeometry = new Geometry("selection_geometry_sceneviewer", wireBox); selectionGeometry.setMaterial(blueMat); selectionGeometry.setLocalTransform(geom.getWorldTransform()); selectionGeometry.setLocalTranslation(bbox.getCenter()); - toolsNode.attachChild(selectionGeometry); selectionShape = selectionGeometry; + SceneApplication.getApplication().enqueue(new Callable() { + + public Object call() throws Exception { + toolsNode.attachChild(selectionGeometry); + return null; + } + }); } } @@ -250,12 +261,18 @@ public class SceneToolController implements AppState { if (control == null) { return; } - Spatial selectionGeometry = DebugShapeFactory.getDebugShape(control.getCollisionShape()); + final Spatial selectionGeometry = DebugShapeFactory.getDebugShape(control.getCollisionShape()); if (selectionGeometry != null) { selectionGeometry.setMaterial(blueMat); selectionGeometry.setLocalTransform(geom.getWorldTransform()); - toolsNode.attachChild(selectionGeometry); selectionShape = selectionGeometry; + SceneApplication.getApplication().enqueue(new Callable() { + + public Object call() throws Exception { + toolsNode.attachChild(selectionGeometry); + return null; + } + }); } } @@ -342,6 +359,7 @@ public class SceneToolController implements AppState { } public void stateAttached(AppStateManager asm) { + toolsNode.attachChild(cursor); // throw new UnsupportedOperationException("Not supported yet."); }