GeometryBatchFactory.optimize and detachChild()

Hello everyone!

I have been struggling with this problem for a couple of days and can’t get it to work on my own :frowning:



I have a couple of Boxes optimized with the GeometryBatchFactory (less object count) and want to delete one of them:



testObject.optimize((results.getClosestCollision()).getGeometry());

//this returns the box i want to remove

this.getVisibleNode().detachChild(geometry);



This works perfectly, but I need to optimize it, so that i have fewer objects:

GeometryBatchFactory.optimize(this.getVisibleNode());

When I do it like this, i can’t remove any boxes anymore (obviously because it is 1 big object now).

I don’t want to detachallchildren and re-attach them again (lagg)…

Is there any other way to get this working?



Thank you in advance



Greetings, Dustin

Attaching and detaching is not an expensive operation, especially not compared to optimizing.

Thank you normen for your answer!

The implementation has been rewritten completely and it works perfectly now :slight_smile:

I have a related problem, have a node were a lot of nodes are attached that use the same model/material. To speed things up I used GeometryBatchFactory.optimize, works like a charm. The problem is than sometimes I want remove some of the placed objects. How would I do that ?