Hello,
following my previous thread about pausing the game using my own rootnode,
I got this error I cant resolve
SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.IllegalStateException: Scene graph is not properly updated for rendering.
State was changed after rootNode.updateGeometricState() call.
Make sure you do not modify the scene from another thread!
Problem spatial name: myRootNode
it happens when user clicks the mouse (dropping an object on the ground)
the whole logic is in a custom appstate (PlayerAppState) initialized as follow
@Override
public void simpleInitApp()
{
//-------------------------------------------------------------------------------------------------------------------------------
ScreenshotAppState screenShotState = new ScreenshotAppState("screenshots"+File.separator);
this.stateManager.attach(screenShotState);
//-------------------------------------------------------------------------------------------------------------------------------
myRootNode= new Node("myRootNode");
viewPort.attachScene(myRootNode);
//-------------------------------------------------------------------------------------------------------------------------------
bulletAppState = new BulletAppState();
bulletAppState.setThreadingType(BulletAppState.ThreadingType.PARALLEL);
stateManager.attach(bulletAppState);
bulletAppState.setDebugEnabled(DEBUG_PHYSICS);
//-------------------------------------------------------------------------------------------------------------------------------
Factory.Init(myRootNode, sceneDataBundle, assetManager, bulletAppState);
gameState= new GameAppState(myRootNode,sceneDataBundle); stateManager.attach(gameState);
SceneParser.Parse("assets/models/"+"level.xml",myRootNode,cam,this,sceneDataBundle,assetManager,bulletAppState,this,DEBUG_NAVMESH);
if(sceneDataBundle.cameraNodes.size()>0)
{
if(sceneDataBundle.navMeshes.size()>0)
{
Node cameraNode = sceneDataBundle.cameraNodes.get(0);
Vector3f camPos =cameraNode.getLocalTranslation();
NavigationMesh naviMesh = sceneDataBundle.FindCurrentNavMesh(camPos);
NavigationCell startCell = naviMesh.FindClosestCell(cameraNode.getLocalTranslation());
startCell.MapVectorHeightToCell(camPos);
playerAppState = new PlayerAppState(camPos,cam,myRootNode,sceneDataBundle); stateManager.attach(playerAppState);
computerAppState = new ComputerAppState(myRootNode,sceneDataBundle); stateManager.attach(computerAppState);
hudAppState=new HudAppState(myRootNode,sceneDataBundle); stateManager.attach(hudAppState);
scenarioAppState= new GameScenarioAppState(myRootNode,sceneDataBundle); stateManager.attach(scenarioAppState);
myRootNodeAppState = new MyRootNodeAppState(myRootNode); stateManager.attach(myRootNodeAppState);
...
so here is the flow when I click (onAction is inside PlayerAppState)
public void onAction(String name, boolean value, float tpf)
{
if (name.equals("LeftClick"))
{
if(value)
{
if(playerController.isCarrying())
{
//------------------------------------------------------- drop
Vector3f pos=playerController.GetDroppingPosition();
if(pos!=null)
{
Node node =playerController.getCurrentProp();
PropController controller = node.getUserData("Controller");
rootNode.attachChild(node);
node.setLocalTranslation(pos);
playerController.PopProp();
controller.AfterDroppedOnGround();
app.getStateManager().getState(ScenarioAppState.class).DropObject((PropController) node.getUserData("Controller"));
}
}
}
so a call to DropObject is causing the issue
void DropObject(final PropController controller)
{
if(listener!=null)
{
app.enqueue(new Callable()
{
public Object call() throws Exception
{
ZoneController zone=sceneDataBundle.FindCollisionZone(controller.getBoundingSphereGhostControl().getOverlappingObjects());
listener.onDroppedObject(controller,zone,ScenarioAppState.this);
return null;
}
});
}
}
the listener point to this : (the culprit beeing .CreateContainer call)
public void onDroppedObject(PropController controller,ZoneController zone,ScenarioAppState scenario)
{
switch(state)
{
case WAIT_FOR_YELLOW_BERRIES:
{
if(currentZone!=null)
if(zone==currentZone)
if(controller instanceof YellowBerriesController)
{
scenario.ShowDialogText(characterController,THANKS_GIVE_POTION);
ContainerInterface potionController = scenario.CreateContainer(currentZone.getPosition(),GlassContainerController.class,ManaPotionController.class);
scenario.FocusProp(potionController);
}
}break;
}
}
wich leads here :
public static AIController Instanciate(Vector3f pos,SceneDataBundle sceneDataBundle,Node rootNode,AssetManager assetManager,BulletAppState bulletAppState)
{
GlassContainerController controller=null;
Spatial model = LoadAsset("potion.j3o",assetManager);
if(model!=null)
{
Node glassContainer= new Node("GlassContainer");
rootNode.attachChild(glassContainer);
}
return controller;
}
and the gui update
void ShowDialogText(CharacterController ctl,String dialogID)
{
String characterName=ctl.getName();
//System.out.println("dialog");
HashMap<String, CharacterDialog> dialogs=characterDialogs.get(characterName);
if(dialogs!=null)
{
CharacterDialog characterDialog=dialogs.get(dialogID);
if(characterDialog!=null)
{
String finalDialog=ReplaceTextVars(characterDialog.dialog,characterName);
app.getStateManager().getState(HudAppState.class).setDialogText(finalDialog);
}
else
System.out.println("Error, cannot find dialog '"+dialogID+"'");
}
else
System.out.println("Error, cannot find character dialogs for '"+characterName+"'");
lastCharacter=ctl;
lastDialogID=dialogID;
app.getStateManager().getState(HudAppState.class).ShowDialogButton(true);
eraseDialogTextOnResume=true;
WaitForPlayer();
}
here is my own rootNode appstate
public class MyRootNodeAppState extends AbstractAppState
{
private final Node myRootNode;
public MyRootNodeAppState(Node myRootNode) {
this.myRootNode=myRootNode;
}
@Override
public void update(float tpf) {
myRootNode.updateLogicalState(tpf);
myRootNode.updateGeometricState();
}
}
I tried to put the 2 update lines in render(), but it gives the same error (also it has no tpf value…)
also, in debug mode, the whole thing does not cause the error directly, it is once I go back to the application that I get the error
can someone check this out ?
thanks