Detach all childern via enqueue?

Hi!

I’m trying to load a new Scene.

First thing I do is removing all Objects from the old one using:



[java]

rootNode.detachAllChildren();

[/java]



After getting this Exception:



[java]

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!

[/java]



and reading about several other people having the same problem i’ve put the command into the simpleUpdate method but that didn’t work either, same error.



AFTER that i read about this solution in the documentation:



[java]

mainApp.enqueue(new Callable<Spatial>() {



public Spatial call() throws Exception {

return geo.rotate(rot);

}



});

[/java]



But the return statement requiers a Spatial and the detach() method returns nothing.



I tried to solve this for hours but I’m stuck at this problem…



Any advice?

@benkibitzer said:
and reading about several other people having the same problem i've put the command into the simpleUpdate method but that didn't work either, same error.


Nope. Then you didn't really move it to simpleUpdate(). Something else must have still been executing it outside the render thread. Or you've setup your rootNode in a weird way.

Unless you called simpleUpdate() yourself manually or something which is a super-big no no.

The Callable thing is basic Java. If you don't need to return something then don't. Make it a Callable and just return null. But all enqueuing it is going to do is make it run during update... which is exactly what moving it to simpleUpdate() should have done.

Other than that, we don't have enough information to help. Are you calling these things from different threads? Maybe the problem is something else completely.

Okay I got it.

Sorry for asking and finding the problem just some minutes later -.-

It was (how you said)

something else completely.

I added water (in the Model editor) to the Spatial that caused the problem. Somehow.
So the water has to be removed from the viewport first.
Removing all the Spatials works now.
But I'm confused about that the water is still displayed after
[java]viewPort.removeProcessor(waterProcessor);[/java]

And the fps is slowed down to 0