Hey Guys,
first: your Work here is Amazing! Thanks for this great Engine.
I am really impressed how fast the BatchNode is. But i have some issues.
I making an Dungeon Keeper like game. The hole Map is an BatchNode organized as an Grid and the Workers can influence the Maps Spatials:
Sometimes i get an java.lang.IndexOutOfBoundsException at java.nio.Buffer.checkBounds(Buffer.java:559). I am not 100% Sure if it cames from the adding or my stupid deleting “trys”.
Some code for you: I have an Update Loop outside the app, but it´s enquened in the App as an Callable like this:
[java]_app.enqueue(new MyCallAction(objectList, staticvisuals));[/java]
The App is my JMonkey Application and created like that:
[java]
_app = new MonkeyApp(_scaleApp, scale, areaSize.getXAsFloat(), isGrid, shader, camera);
AppSettings settings = new AppSettings(true);
_app.setPauseOnLostFocus(false);
_app.setSettings(settings);
_app.createCanvas();
_app.startCanvas();
_context = (JmeCanvasContext)_app.getContext();
canvas_ = _context.getCanvas();
canvas_.setSize(settings.getWidth(), settings.getHeight());
canvasSize = canvas_.getSize();
[/java]
It all works fine. Just sometimes. especially when i have lots of Workers in my Scene who influence the map i got the Error.
When a new Spatial is added to the Batchnode i do this (inside the MyCallAction):
[java]
sVisualsBatch.attachChild(objectNode);
sVisualsBatch.batch();
[/java]
And to remove:
[java]
Spatial toRemove = sVisualsBatch.getChild(id.toString());
toRemove.setLocalScale(0);
sVisualsBatch.updateGeometricState();
[/java]
First: Why i get the stupid error only when i have lots of actors on my Map?
Second: What is an better Solution to “delete” Spatials from a BatchNode? I dont find anything about that in the documentation. Its just said you can also remove Spatials but is more Expensive than on a Normal Node.
When i just call one of these or both, NOTHING happens.
[java]
sVisualsBatch.detachChild(toRemove);
toRemove.removeFromParent();
[/java]
So please have mercy and give me a hint how to Smart remove Meshes/Spatials from a BatchNode
Greetings,
Philip