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

Cache results objects for complex shapes? #91

Open DennisSmolek opened 1 year ago

DennisSmolek commented 1 year ago

Right now the Operations groups/hierarchy etc have to be completely rerun for for the entire stack each time it’s evaluated.

so really big objects end up having to include all previous brushes/mesh data and be processed each time.

one idea:

let’s say there are 10 operation steps, and you are transforming step #7. You could run a truncated steps 1-6, and save the result. Then use that result each subsequent pass. I think if all something like addition you could also run steps 8-10 and generate a brush for that section as well. This would make a transformation of any size just 3 brushes instead of 10.

plus the results discard unused geometry data so hypothetically run much faster.

Another idea would be to cache by hierarchy.

so for a body for example, a arm/leg etc would cache the results.

This might not be something for the library to do directly persay, But would be a good example on how to use it in production

I’m going to try to make some tests

gkjohnson commented 1 year ago

Yeah ideally when running Evaluator.evaluateHierarchy we'd only rerun nodes that needed it - that was the intent behind that function, anyway, when I first made a pass at it. But it needs to be revisited. And even then we should only need to run nodes where bounding overlap has meaningfully changed.

I have a tendency to start too many projects so I haven't been putting any time into CSG, at the moment. I have some work I need to do on the pathtracer and then maybe I'll take a look at this project again. But of course help is always appreciated if you want to look into any of this!