Problems with AbstractAppState

I have problems with the use of AbstrasctAppState clase. I just use the root node methods to attach the node of the spatial in him, and i never update manualy the scene (all this in the clase who have the extend of AbstractAppState).



The error is next:



State was changed after rootNode.updateGeometricState() call.

Make sure you do not modify the scene from another thread!

Problem spatial name: Root Node

at com.jme3.scene.Spatial.checkCulling(Spatial.java:260)

at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:649)

at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:642)

at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:976)

at com.jme3.renderer.RenderManager.render(RenderManager.java:1031)

at com.jme3.app.SimpleApplication.update(SimpleApplication.java:251)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)

at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)

at java.lang.Thread.run(Thread.java:722)



another, but similar to the previous…



State was changed after rootNode.updateGeometricState() call.

Make sure you do not modify the scene from another thread!

Problem spatial name: null

at com.jme3.scene.Spatial.checkCulling(Spatial.java:260)

at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:649)

at com.jme3.renderer.RenderManager.renderSubScene(RenderManager.java:667)

at com.jme3.renderer.RenderManager.renderScene(RenderManager.java:642)

at com.jme3.renderer.RenderManager.renderViewPort(RenderManager.java:976)

at com.jme3.renderer.RenderManager.render(RenderManager.java:1031)

at com.jme3.app.SimpleApplication.update(SimpleApplication.java:251)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:151)

at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:185)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:228)

at java.lang.Thread.run(Thread.java:722)



Thanks in advance :slight_smile:

You are changing the state of the scene outside the render thread. You should queue modifications you want to do. Another thing is that,if you are using AppState, don’t call them, wait for them to be called in the proper thread that you should face no problem.

Read the threading tutorial in the documentation…

maybe calling

updateLogicalState(timePerFrame);

updateGeometricState();

on the custom nodes in the overridden update(…) method of your implementation of the AbstrasctAppState class helps?

I don’t think this has anything to do with AbstractAppState specifically. There is something that you are doing that is modifying the scene graph outside of update. We can’t see the code so we can’t point to it.

@mwohlf said:
maybe calling
updateLogicalState(timePerFrame);
updateGeometricState();
on the custom nodes in the overridden update(..) method of your implementation of the AbstrasctAppState class helps?


Unless you are controlling your own root nodes then this is completely unnecessary and is only temporarily hiding whatever bug is actually lurking in the OP's code.

I have some methods in the AbstractApp who modify the local translation of the Spatial directly… i think this is the problem :P. I am now moving these modifications to the “update” method.



Thanks all!

@khedrak said:
I have some methods in the AbstractApp who modify the local translation of the Spatial directly... i think this is the problem :P. I am now moving these modifications to the "update" method.

Thanks all!


It's ok if the app state modifies the scene graph as long as it does it in update() and not render().

for an app state, it is safe to modify the scene graph in:
initialize()
update()
cleanup()
2 Likes

Thanks all, this now works :slight_smile: