SarahWeiii / CoACD

[SIGGRAPH2022] Approximate Convex Decomposition for 3D Meshes with Collision-Aware Concavity and Tree Search
https://colin97.github.io/CoACD/
MIT License
482 stars 64 forks source link

Crash when decomposing #34

Closed Pindrought closed 1 year ago

Pindrought commented 1 year ago

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.

SarahWeiii commented 1 year ago

Do you have error info?

Pindrought commented 1 year ago

When using a threshold of 0.05, I am seeing this. image

image

There is an empty vector and it looks like it is trying to access the first element which doesn't exist.

I think because of this image

I changed it to the following and I am no longer crashing.

VertexDataSource(const std::vector<Vector3<T>>& vec) : m_ptr(vec.data()), m_count(vec.size()) {

}
eliphatfs commented 1 year ago

The two expressions should be compiled into the same binary theoretically; perhaps this actually relates to a bug with your specific version of Visual Studio/MSVC. The input object is doing well on the 1.0.0 official release.

Pindrought commented 1 year ago

I'm using the latest version of MSVC/the latest compiler.

eliphatfs commented 1 year ago

This is a problem in the upstream quickhull library, we could fix it here temporarily and report to its author(s)

Pindrought commented 1 year ago

Thanks for the clarification I didn't realize that was from a different library.