Closed onitake closed 3 weeks ago
Awesome thanks for the PR!! Few quick thoughts:
trimesh.util.has_module
for the autodetection? It seems pretty much the same idea as here.trimesh.boolean.reduce_cascade
and trimesh.util.chain
into their own trimesh.iteration
submodule for the "materially similar to functions in itertools
" stuff. I'll do that on merge which should reduce circular import problems.Is there a side effect of try: import manifold3d
? Because we could also pick the default by using the first one that isn't an ExceptionWrapper
:
# which backend boolean engines
_engines = {
"manifold": boolean_manifold,
"blender": interfaces.blender.boolean,
"junk": ExceptionWrapper(ValueError("nah")),
}
_engines[None] = next(
(v for v in _engines.values() if not isinstance(v, ExceptionWrapper)), None
)
Looks like it didn't quite work as well as I had hoped.
Thanks for the pointers, I'll take a look at has_module
.
No worries! I'll play around with it in my branch a bit. Thanks for the PR!!
Closes: #2306
As announced, here's a patch that refactors the boolean engine autodetection.
I had to refactor a few things to make the two engines behave the same way and avoid circular imports.
reduce_cascade
is now inutil.py
. I assumed that this is needed in other places, so I didn't move it into the new interfaces.manifold module.interfaces.blender
andinterfaces.manifold
are now dynamic imports. This avoids a circular import loop and allows autodetection at load time.