Git Product home page Git Product logo

coacd's People

Contributors

abdealtheria avatar colin97 avatar eliphatfs avatar fbxiang avatar fire avatar isebasus avatar sarahweiii avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coacd's Issues

Crash when decomposing

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.
image

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.

Problem encounted in generating collision shape

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!

image
model.obj.zip

error: variable or field ‘debug’ declared void 13 | inline void debug(spdlog::string_view_t fmt, const Args &...args)

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

Three point form of Plane, most likely mistake

class Plane
{
    bool pFlag;       // whether three point form exists
    vec3d p0, p1, p2; // three point form

The code has a value modification of these fields (in clip.cpp) but they are never used.
image

CPP Error after processing several examples

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!

output format

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

Triangle.h is not MIT

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 certain parameters of example objs, there may be assert failed in the C++ Windows compiled version.

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
image

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.)
image

If someone encounters a similar problem, I would really appreciate it if they could reply.

Remove syntax in the output file

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!

When building CoAcd can't link to the standard math library on Macos

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!

relationship between concavity threshold and actual distance

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)

Does CoACD use manifold plus?

The number of faces is 4x larger compared to vhacd in a test model

out.glb is coacd result, 25 piceces, 1254 triangles
image

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
image

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')

source model:
image

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.

Strange decomposition on simple case.

housetest1
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.

Slimmer C++ dependencies?

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 🙂 🌍

How to compiling for windows

This project is amazing. Now i have troubles compiling for windows. I hope you can help me.
The whole process I list here:

  1. git clone https://github.com/SarahWeiii/CoACD.git
  2. cd CoACD
  3. mkdir build
  4. cmake ..
    After those i got the CoACD.sln:
    image
    Then I compiled "main" project,but got some errors:
    image
    Please give me some tips, Thanks!

Crashes when building with Visual Studio 2019 on Windows 11

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.

Threshold too high

I am trying to compute the convex decomposition of a mechanism but the threshold parameter is too high and does not allow to obtain a usable result.
Original file

Decomposed file

What can I do to obtain a better result?

Usage on Apple Silicon

Hi,

Would it be possible to install / build from source on apple silicon / arm64?

Thank you!

Specifying max # hulls and max # vertices per hull

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

Another crash during decomposing in debug mode

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

image

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

Reduce number of vertices in each convex hull

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:

image

AllocatorFooChar missing error when building from source

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

Splitting into multiple files for Mujoco

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.