Selaa lähdekoodia

- cleanup state detaching in WoI

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10410 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
nor..67 12 vuotta sitten
vanhempi
commit
cb1920eaff
1 muutettua tiedostoa jossa 9 lisäystä ja 3 poistoa
  1. 9 3
      engine/src/test/jme3test/games/WorldOfInception.java

+ 9 - 3
engine/src/test/jme3test/games/WorldOfInception.java

@@ -260,12 +260,10 @@ public class WorldOfInception extends SimpleApplication implements AnalogListene
                     return;
                 } else if (currentActiveChild != null && currentActiveChild.getPositionInParent().equals(vector3f)) {
                     //TODO: doing this here causes problems when close to multiple pois
-                    logger.log(Level.INFO, "Detach child {0}", currentActiveChild);
                     rootNode.getChild(i).setCullHint(Spatial.CullHint.Inherit);
-                    stateManager.detach(currentActiveChild);
-                    currentActiveChild = null;
                 }
             }
+            checkActiveChild(null);
             curScaleAmount = 0;
             rootNode.setLocalScale(1);
             rootNode.setLocalTranslation(playerPos.negate());
@@ -276,6 +274,14 @@ public class WorldOfInception extends SimpleApplication implements AnalogListene
 
         private void checkActiveChild(Vector3f vector3f) {
             AppStateManager stateManager = application.getStateManager();
+            if(vector3f == null){
+                if(currentActiveChild != null){
+                    logger.log(Level.INFO, "Detach child {0}", currentActiveChild);
+                    stateManager.detach(currentActiveChild);
+                    currentActiveChild = null;
+                }
+                return;
+            }
             if (currentActiveChild == null) {
                 currentActiveChild = new InceptionLevel(this, vector3f);
                 stateManager.attach(currentActiveChild);