BatchedMesh: Deleting instances and geometry

Hi everyone,

I’m currently exploring the BatchedMesh class and have a question about deleting instances and geometries.

In my use-case I have a dynamically changing scene in which new geometries are added to a BatchedMesh. Afterwards instances of the geometry are generated (analogous to the example here).

Subsequently instances may be removed and I currently have a logic to delete geometries once there is no instance using it anymore. However the deleteGeometry call fails with an error as it attempts to delete instances that have previously already been deleted.

Looking at the code, it seems like deleteInstance mainly sets the active property on the corresponding instanceInfo entry to false (link). But that property is not used to check whether to again delete the instance when deleting the geometry. And then validateInstanceId fails.

Is this behavior intended or do I misunderstand something?

Thanks for any input,

djz

Looking at the code, it seems like deleteInstance mainly sets the active property on the corresponding instanceInfo entry to false (link).

It looks like this may be a bug introduced with throwing error when an id is no longer valid. TBH I’m not sure how I feel about throwing errors like this if an instance isn’t valid but that’s another issue.

If you’d like to make a PR for checking “active” before deleting an instance that would be great.