sarahweiii / coacd Goto Github PK
View Code? Open in Web Editor NEW[SIGGRAPH2022] Approximate Convex Decomposition for 3D Meshes with Collision-Aware Concavity and Tree Search
Home Page: https://colin97.github.io/CoACD/
License: MIT License
[SIGGRAPH2022] Approximate Convex Decomposition for 3D Meshes with Collision-Aware Concavity and Tree Search
Home Page: https://colin97.github.io/CoACD/
License: MIT License
I have a model of a cottage and the library is crashing when I try to decompose it. I am not sure if i'm doing something wrong.
Here is the .obj file for the cottage example.
Here is a minimal code example that builds all of the verts/indices and attempts to decompose them.
I was originally trying with preprocess = "" but even with preprocess = "auto" it still crashes so I think the cause is something else.
Thank you very much for your library!
Edit: When testing it out, it seems like if I increase the threadhold to 0.2 it will work, but obviously it produces results that are less than desirable with a threshold that high and even with the increased threshold preprocess must be on or it crashes.
Hello, thanks for your exciting work! When attempting to generate a collision shape, I've run into an error on occasion. Could you possibly provide some assistance with this?
[2023-10-17 20:55:47.905] [CoACD] [info] threshold 0.05
[2023-10-17 20:55:47.905] [CoACD] [info] max # convex hull -1
[2023-10-17 20:55:47.905] [CoACD] [info] preprocess mode auto
[2023-10-17 20:55:47.905] [CoACD] [info] preprocess resolution 50
[2023-10-17 20:55:47.905] [CoACD] [info] pca false
[2023-10-17 20:55:47.905] [CoACD] [info] mcts max depth 3
[2023-10-17 20:55:47.905] [CoACD] [info] mcts nodes 20
[2023-10-17 20:55:47.905] [CoACD] [info] mcts iterations 150
[2023-10-17 20:55:47.905] [CoACD] [info] merge true
[2023-10-17 20:55:47.905] [CoACD] [info] seed 0
[2023-10-17 20:55:47.908] [CoACD] [info] - Manifold Check
[2023-10-17 20:55:48.089] [CoACD] [info] [1/3] Edge check finish
python: /project/src/intersection.h:663: static void threeyd::moeller::TriangleIntersects::isect2(const TemplatedVec&, const TemplatedVec&, const TemplatedVec&, threeyd::moeller::TriangleIntersects::declfloat, threeyd::moeller::TriangleIntersects::declfloat, threeyd::moeller::TriangleIntersects::declfloat, threeyd::moeller::TriangleIntersects::declfloat, threeyd::moeller::TriangleIntersects::declfloat, threeyd::moeller::TriangleIntersects::declfloat, threeyd::moeller::TriangleIntersects::declfloat&, threeyd::moeller::TriangleIntersects::declfloat&, TemplatedVec&, TemplatedVec&) [with TemplatedVec = coacd::IntersectVector3; threeyd::moeller::TriangleIntersects::declfloat = float]: Assertion `d0 != d1' failed.
I believe the issue may stem from my mesh being cut from the complete object. Could you kindly provide some guidance on how to resolve this problem? Thank you!
when I try to "make",it occurs.
/home/ustc/PycharmProjects/CoACD/src/logger.h:13:21: error: variable or field ‘debug’ declared void
13 | inline void debug(spdlog::string_view_t fmt, const Args &...args)
| ^~~~~
/home/ustc/PycharmProjects/CoACD/src/logger.h:13:35: error: ‘string_view_t’ is not a member of ‘spdlog’
13 | inline void debug(spdlog::string_view_t fmt, const Args &...args)
| ^~~~~~~~~~~~~
/home/ustc/PycharmProjects/CoACD/src/logger.h:13:54: error: expected primary-expression before ‘const’
13 | inline void debug(spdlog::string_view_t fmt, const Args &...args)
| ^~~~~
/home/ustc/PycharmProjects/CoACD/src/logger.h:19:21: error: variable or field ‘info’ declared void
19 | inline void info(spdlog::string_view_t fmt, const Args &...args)
| ^~~~
/home/ustc/PycharmProjects/CoACD/src/logger.h:19:34: error: ‘string_view_t’ is not a member of ‘spdlog’
19 | inline void info(spdlog::string_view_t fmt, const Args &...args)
| ^~~~~~~~~~~~~
/home/ustc/PycharmProjects/CoACD/src/logger.h:19:53: error: expected primary-expression before ‘const’
19 | inline void info(spdlog::string_view_t fmt, const Args &...args)
| ^~~~~
/home/ustc/PycharmProjects/CoACD/src/logger.h:25:21: error: variable or field ‘warn’ declared void
25 | inline void warn(spdlog::string_view_t fmt, const Args &...args)
| ^~~~
/home/ustc/PycharmProjects/CoACD/src/logger.h:25:34: error: ‘string_view_t’ is not a member of ‘spdlog’
25 | inline void warn(spdlog::string_view_t fmt, const Args &...args)
| ^~~~~~~~~~~~~
/home/ustc/PycharmProjects/CoACD/src/logger.h:25:53: error: expected primary-expression before ‘const’
25 | inline void warn(spdlog::string_view_t fmt, const Args &...args)
| ^~~~~
/home/ustc/PycharmProjects/CoACD/src/logger.h:31:21: error: variable or field ‘error’ declared void
31 | inline void error(spdlog::string_view_t fmt, const Args &...args)
| ^~~~~
/home/ustc/PycharmProjects/CoACD/src/logger.h:31:35: error: ‘string_view_t’ is not a member of ‘spdlog’
31 | inline void error(spdlog::string_view_t fmt, const Args &...args)
| ^~~~~~~~~~~~~
/home/ustc/PycharmProjects/CoACD/src/logger.h:31:54: error: expected primary-expression before ‘const’
31 | inline void error(spdlog::string_view_t fmt, const Args &...args)
| ^~~~~
/home/ustc/PycharmProjects/CoACD/src/logger.h:37:21: error: variable or field ‘critical’ declared void
37 | inline void critical(spdlog::string_view_t fmt, const Args &...args)
| ^~~~~~~~
/home/ustc/PycharmProjects/CoACD/src/logger.h:37:38: error: ‘string_view_t’ is not a member of ‘spdlog’
37 | inline void critical(spdlog::string_view_t fmt, const Args &...args)
| ^~~~~~~~~~~~~
/home/ustc/PycharmProjects/CoACD/src/logger.h:37:57: error: expected primary-expression before ‘const’
37 | inline void critical(spdlog::string_view_t fmt, const Args &...args)
| ^~~~~
CMakeFiles/_coacd.dir/build.make:110: recipe for target 'CMakeFiles/_coacd.dir/src/clip.cpp.o' failed
make[2]: *** [CMakeFiles/_coacd.dir/src/clip.cpp.o] Error 1
CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/_coacd.dir/all' failed
make[1]: *** [CMakeFiles/_coacd.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
Looking into this.
Hi,
Do you know what settings allows me to see the preprocessed mesh without the CoACD algorithm generation?
Wanted to debug the preprocessor.
Thank you for open-sourcing this tool. It has been very helpful to run CD on some meshes that I have.
I was trying to decompose some meshes that I have, from an open-source dataset. After processing about ~200-300 meshes in a python
for loop, I received this error:
python: /workspace/coacd/src/process.cpp:112: double coacd::MergeConvexHulls(coacd::Model&, std::vector<coacd::Model>&, std::vector<coacd::Model>&, coacd::Params&, double, double): Assertion `p1 < costSize' failed
I've seen this error about 2-3 times at this point. For context, I'm trying to decompose the mesh with these parameters:
coacd.run_coacd(
mesh=mesh,
threshold=0.05,
max_convex_hull=10,
merge=True,
)
Please let me know if some of these parameters are incompatible or if this is a known bug for certain meshes.
Thank you!
Hi thanks for sharing this great work, I'm using CoACD to replace VHACD to build some robot simulation envs, but I found that when I specify the output to be .wrl format, the output is still in .obj format, and I'm wondering is there a way to save saperate cvx hulls so I can load them saperately to the simulator? Thanks
So, just as an FYI. This library is labeled as being MIT license. However, it uses 'Triangle.h' which is not at all compliant with an MIT license. So anyone who tries to use this library will have license issues due to that. The code will not work without 'Triangle.h' so really the library as a whole cannot be used in any commercial product or is otherwise not compliant with the strict restrictions found in 'Triangle.h'
For example, using these parameters will result in an error (CDT's commit id is cf4df31):
-i .\examples\Kettle.obj -o .\examples\Kettle_compiled.obj -t 0.05 -pm off -c 4 -pr 50 -s 1234
In addition, I found that setting breakpoints on the code of COACD is always ineffective when using VS or Rider on Windows. (breakpoints cannot be hit in the code of the submodule or CoACD itself.)
If someone encounters a similar problem, I would really appreciate it if they could reply.
Hi!
I'm using CoACD to preprocess my obj
model to get higher resolution and compact collision meshes.
I found the output obj
file containing the syntax, like o geometry_1
and o geometry_2
, which split the whole mesh into small pieces. When the output obj
model is imported into MuJoCo
, the above syntax seems to prevent the model from being fully loaded, and all geometric elements after the place where the first syntax appears are not displayed.
Is there any way to remove these syntaxes without changing them manually? Thanks in advance!
Can't link to the standard math library on the mac machine or on the cloud.
https://github.com/fire/CoACD/actions/runs/6448697326/job/17506251288
-- ----------------------------------------------------
-- ----------- Configuring OpenVDBBinaries ------------
-- ----------------------------------------------------
-- Performing Test EIGEN_COMPILER_SUPPORT_CPP11
-- Performing Test EIGEN_COMPILER_SUPPORT_CPP11 - Failed
-- Performing Test COMPILER_SUPPORT_std=cpp03
-- Performing Test COMPILER_SUPPORT_std=cpp03 - Failed
-- Performing Test standard_math_library_linked_to_automatically
-- Performing Test standard_math_library_linked_to_automatically - Failed
-- Performing Test standard_math_library_linked_to_as_m
CMake Error at build/_deps/eigen-src/CMakeLists.txt:108 (message):
-- Performing Test standard_math_library_linked_to_as_m - Failed
Can't link to the standard math library. Please report to the Eigen
developers, telling them about your platform.
-- Configuring incomplete, errors occurred!
hi, I wanted to use this approximate convex decomposition to implement mesh offsetting, but I think I need the concavity metric to be exactly 2r + small delta where r is the offset distance. It seems that the concavity threshold we give can only be within 0.01 to 1, I wonder how that maps to actual distance?
(I am not familiar with geometry so I am not sure if I understand the metrics correctly)
Can you clarify?
I wish to use CoACD but any licenses in the source file that are non opensource licensed means the whole system is non opensource.
https://github.com/SarahWeiii/CoACD#license
Can you separate the non opensource code to a different folder so I can strip it?
out.glb is coacd result, 25 piceces, 1254 triangles
code:
import coacd
import trimesh
import numpy as np
input_file = './input.obj'
mesh = trimesh.load(input_file, force="mesh")
mesh = coacd.Mesh(mesh.vertices, mesh.faces)
parts = coacd.run_coacd(mesh, merge=True, threshold=0.05, resolution=2000, preprocess_resolution=50) # a list of convex hulls.
mesh_parts = []
for vs, fs in parts:
mesh_parts.append(trimesh.Trimesh(vs, fs))
scene = trimesh.Scene()
np.random.seed(0)
for p in mesh_parts:
p.visual.vertex_colors[:, :3] = (np.random.rand(3) * 255).astype(np.uint8)
scene.add_geometry(p)
scene.export('./out.glb')
out2.glb is vhacd, 27 piceces, 374 triangles
code:
import trimesh
import numpy as np
input_file = './input.obj'
mesh = trimesh.load(input_file, force="mesh")
parts = trimesh.interfaces.vhacd.convex_decomposition(mesh, maxhulls=10)
#print(parts)
#mesh_parts = []
#for vs, fs in parts:
# mesh_parts.append(trimesh.Trimesh(vs, fs))
scene = trimesh.Scene()
np.random.seed(0)
for p in parts:
p.visual.vertex_colors[:, :3] = (np.random.rand(3) * 255).astype(np.uint8)
scene.add_geometry(p)
scene.export('./out2.glb')
files:
test.zip
I feel like the triangles are mainly on the smooth edges. Is there a way to make the edges of the model sharper?
P.S. windows verison seems not work, tested on 2 computers, windows11 anaconda python 3.10.
Here's a simple test case.
househullbug1.zip
In the picture, the original model is on the right, and the convex decomposition
is on the left.
Three of the walls, and the ground slab, were convex in the input.
Yet they were subdivided into four parts with more complex geometry.
The fourth wall has a door cutout and a window cutout.
Those disappeared completely during convex decomposition.
This is unexpected.
Hi CoACD!
Yuval here from the MuJoCo dev team. Like many others, we are really impressed by CoACD outputs and are enthusiastically recommending it to our users at every opportunity.
We were delighted to discover that you now have a C++ API. Including optional automatic CoACD pre-processing would really improve our user's lives. However, we then saw that your dependencies include extremely large packages like openvdb and boost. We work very hard to keep MuJoCo's dependencies to the absolute minimum, and indeed all of our dependencies are very small and have no dependencies themselves.
Do you have any plans to reduce your dependency payload?
If yes, please let us know.
We would love to help spread your excellent algorithms to the physics-simulating, open-source world 🙂 🌍
This project is amazing. Now i have troubles compiling for windows. I hope you can help me.
The whole process I list here:
Hi,
I wanted to try this out on Windows 11 where cmake creates a Visual Studio 2019 project.
But when trying to run it the app crashes. Visual studio also reports potential errors in the code at multiple places.
The error is in triangle.h, line 13988: vertexloop[0] = vertices[i][0];
The vertexloop seems to be allocated incorrectly.
Even after I tried doing a brute malloc instead of the pool it crashed elsewhere.
I tried it on the bottle model.
Hi,
Would it be possible to install / build from source on apple silicon / arm64?
Thank you!
Hi,
Thanks a lot for your work on CoACD and for releasing it on GitHub and on PyPI! We have recently started using it instead of V-HACD and have been observing an incredible improvement in the results we get.
We have just one issue: for our use case, which involves using Isaac Sim's GPU dynamics, we need all of our convex decompositions to have fewer than 64 convex hulls, and each of those convex hulls needs to have less than 60 vertices. In V-HACD parameters exist for both of these, which makes it keep reducing until these are reached.
Is there any way we could do this in CoACD?
Thanks,
Cem
For some reason, the top row value is outside of the size of the costMatrix std::vector when I am decomposing this model in debug mode.
The size of the vector is 4005, and the top_row value is 4005.
https://github.com/SarahWeiii/CoACD/blob/main/src/process.cpp#L181
Model: https://drive.google.com/file/d/1Z1TG8CQqk_eUBzhLKfzvWFQh8ACBlSRN/view?usp=share_link
Code example: (Too long for pastebin)
https://drive.google.com/file/d/1eG44C6UPMUqGZjLxwxXyjIVD6zIzuabh/view?usp=share_link
I was wondering if there is a way to reduce the number of vertices of each convex hull.
Compared to VHACD I get a lot more vertices per convex hull with COACD. Although I am quite impressed with the quality of the decomposition of COACD, the high number of vertices will affect collision checking too just like having too many convex hulls.
Here is an example. Compare for instance the VHACD2 MEDIUM case that has 8 convex hulls with 369 vertices and the COACD LOW case that has a similar 7 convex hulls but with 10 times more vertices:
Getting this errror when building
Errors << CoACD:make /home/ubuntu/workspace/logs/CoACD/build.make.000.log In file included from /home/ubuntu/workspace/build/CoACD/_deps/tbb-src/test/conformance/conformance_allocators.cpp:21: /home/ubuntu/workspace/build/CoACD/_deps/tbb-src/test/common/allocator_test_common.h: In instantiation of ‘void TestAllocator(TestName, const Allocator&) [with Allocator = std::pmr::polymorphic_allocator<void>]’: /home/ubuntu/workspace/build/CoACD/_deps/tbb-src/test/conformance/conformance_allocators.cpp:86:123: required from here /home/ubuntu/workspace/build/CoACD/_deps/tbb-src/test/common/allocator_test_common.h:284:15: error: no class template named ‘rebind’ in ‘class std::pmr::polymorphic_allocator<void>’ 284 | using AllocatorFooChar = typename Allocator::template rebind<FooChar>::other; | ^~~~~~~~~~~~~~~~ compilation terminated due to -Wfatal-errors. make[2]: *** [_deps/tbb-build/test/CMakeFiles/conformance_allocators.dir/build.make:76: _deps/tbb-build/test/CMakeFiles/conformance_allocators.dir/conformance/conformance_allocators.cpp.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:8391: _deps/tbb-build/test/CMakeFiles/conformance_allocators.dir/all] Error 2 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:156: all] Error 2
env:wls2-ubutun22
I've already installed dependencies,but the error(tbb is missing) occurred
Is there an easy way to create multiple files by specifying a folder directory and output format where each file has one convex hull.
Mujoco treats all meshes from the same file as a single convex hole and splitting it into multiple files solves this problem.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.