Desc:
I’m building a scene that digs a hole when the button at the top right of the scene clicked, and when the wireframe mesh moved and the btn clicked again, it digs another hole.
Firstly I tried to use subtractInPlace again and again on the same csg, but it goes too much slower after 3 clicks.
Then I looked at MergeMeshes, expecting using it to get a merged mesh of all holes to dig, and subtract the csg with it being faster, but the result looks wrong.
Also, it’s also acceptable if a way is found making csg faster with multiple subtractInPlace.
Here are playgrounds tuned for faster reproduction of this:
Expected(but very slow):
There’s unfortunately nothing that can be done (except maybe using another algorithm to compute CSG). CSG creates many faces very quickly, so after you’ve applied CSG a few times, your mesh can contain a lot of faces and it becomes exponentially slower to apply new CSG operations.
I don’t know if the current CSG algorithm can be improved, it’s an external contribution I think, so it’s hard to know. But we already had this problem in the past with no good solution.
I’m not sure what you mean by having merge meshes work with CSG… Merge meshes simply merge the vertex buffers of multiple meshes into a single mesh, so in the end you end up with a regular mesh.
I made a merged mesh from meshes in different positions, expecting that subtract a csg created from the merged mesh would result like running subtractInPlace multiple on csgs from meshes in different positions, but fails.