gkjohnson / three-bvh-csg

A flexible, memory compact, fast and dynamic CSG implementation on top of three-mesh-bvh
MIT License
552 stars 45 forks source link

Correct way to combine multiple meshes? #86

Closed John-Dean closed 1 year ago

John-Dean commented 1 year ago

Hi there,

I'm looking to use the ADDITION operation with multiple meshes. I see in your example: https://gkjohnson.github.io/three-bvh-csg/examples/bundle/simple.html this has the output I expect.

The example combines 2 meshes; a sphere and a cube.

What would be the correct process for combining say 5 meshes (let's name them A B C D E)?

Is there a way of combining all 5 in 1 in a single command? Or do you have to do (((A+B) + C) + D) + E? Or is ( (A+B) + (C+D) ) + E more efficient?

I'm just trying to understand the best way to approach this problem when the number of meshes grows to a few thousand.

Many thanks, John

gkjohnson commented 1 year ago

Hello! Performance is still in progress and there are still some implementation quirks affecting speed but that aside I have not benchmarked or done any notional computation complexity comparisons for the types of operational hierarchy differences your asking. My gut says there's value to keeping the operations hierarchy shallow rather than deep but I can't be sure.

If you'd like to contribute a benchmark (see benchmark folder) or some kind of computational breakdown to figure this out and contribute it back it would be good to have!