Error while detaching children

Ok I don’t know what is the problem, but I am detaching lots of object 1 by 1 from some node and I get following error:



Exception in thread “LWJGL Renderer Thread” java.lang.IndexOutOfBoundsException: Index: 244, Size: 244

at java.util.ArrayList.RangeCheck(Unknown Source)

at java.util.ArrayList.get(Unknown Source)

at com.jme3.scene.Node.updateGeometricState(Node.java:184)

at com.jme3.scene.Node.updateGeometricState(Node.java:185)

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

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

at com.jme3.system.lwjgl.LwjglCanvas.runLoop(LwjglCanvas.java:192)

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

at java.lang.Thread.run(Unknown Source)





Any ideas why? :slight_smile:

Here’s the relevant code:

for (int i = 0, cSize = children.size(); i < cSize; i++) {

Spatial child = children.get(i);

child.updateGeometricState();

}


There’s only one explanation: You’re detaching things outside the render thread :stuck_out_tongue:

You might be right. I am rendering in AWT canvas (based on TestCanvas), and I detach or attach children to my nodes, based on what user clicks in a Swing window. Till now I didn’t have any problems while testing (found out that it only happens when lots of children is detached). Any ideas how to overcome this? :slight_smile:

Its similar to using the AWT event queue, you create a Callable that is executed on the opengl thread. I posted an example snippet here.

Cheers,

Normen

Thats cool, thanks! :slight_smile: