kmammou / v-hacd

Automatically exported from code.google.com/p/v-hacd

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Subpar results for simple shapes

Vanilagy opened this issue · comments

Hey, I'm playing around with this library (awesome efforts, btw) to see if it's suited for my project - been playing around with the python version. However, the results I get seem... strange.

image
Here's a simple Torus. After p.vhacd(name_in, name_out, name_log, alpha=0.0,gamma=0.0,resolution=200000,concavity=0,depth=32,planeDownsampling=1,convexhullDownsampling=1,maxNumVerticesPerCH=1024 ), I get

image

Doesn't look to great.

Another example:
image

After p.vhacd(name_in, name_out, name_log, alpha=0.0,gamma=0.0,resolution=50000,concavity=0,depth=32,planeDownsampling=1,convexhullDownsampling=1,maxNumVerticesPerCH=1024 ), I get

image

The bunny has turned into a blocky, disconnected mess.

What gives? Am I using the lib wrong? Is the python version outdated?

This is what convex decomposition means. It's an approximation. It takes a set of simple shapes and approximates the original mesh but it can only ever be just that, an approximation. I'm currently in the process of refactoring the code base and I will do my best to improve things, but you will still always get results somewhat like this due to the fact that it's an approximation.

Ok, I see the issue. I have already fixed some of these problems on another branch.

I was able to repro these bad approximations using the master branch.

However, if you switch to the branch: performance-improvements

If you switch to the 'performance-improvements' branch you will need to build the library from source as no binaries are provided. It's also many many times faster than the 'master' branch version.

You get much better results.

feedback1

feedback2

I made some more examples using the 'performance-improvements' branch with more convex hull allowance. I think these results are quite satisfactory.

Examples:

feedback3
feedback4
feedback5
feedback6
feedback7
feedback8

I came across this library about two years or so ago and am using it my game engine now for building collision meshes for physics simulation. However, to be honest, the results from the master branch are often simply not good enough.

However, when you take the code from the performance-improvements branch, both the performance and the results are really awesome and exactly what I need. So I can only recommend to switch to that branch instead, I didn't encounter any issues with it. I'm very happy to hear that work on it continues and am looking forward to even better results and performance.

Thanks for the positive feedback. The new version I'm working on will be a single header file and one CPP. It will run much faster than even the performance improvement branch. It produces much better and consistent results as well. I'm only working on it in my 'spare' time, but I am working on it. Once completed the old versions will be completely deprecated.

@jratcliff63367

Oh, that's cool, I was aware of the performance branch but assumed it only improves performance, not results. I plan on using this in a web app, so I guess I will compile that .h file to WASM - should work fine. I can see if I can get it to work.

Also, I'm a bit confused by all the other options besides concavity. I feel like concavity should be the only thing I should think about as a user, right? It's like a slider between a full convex hull and the original input. My question is, how exactly do I understand concavity and should I care about all the options, at all?

Also, on the master branch, it was basically impossible for me to use settings that yield back the original input.

I found https://blog.roblox.com/2020/07/search-better-convex-decomposition/ today, they seem to have improved their HACD algorithm a lot too. Is your performance branch basically comparable to this?

The new version will have different and better documented tuning parameters.

With the version you have, really the only things that really matter are maximum number of convex hulls and voxel resolution.

The others, concavity, alpha, and beta, and other stuff aren't really that relevant.

As I said, the new version will be much more robust and predictable. It works solely based on volume conservation.

Awesome! So, the new version is ready enough for usage basically? What's missing before you feel like it's ready for master?

I previously made a prototype of the new implementation to prove to myself that it would work and now it's just a matter of coding it up. Part of my goal is to remove all of the old legacy code, especially the bullet code, and replace it with my own convex hull implementation.

Awesome. Really cool that you're doing this; there's barely any OSS projects out there for 3D decomp. Keep it up!

I found https://blog.roblox.com/2020/07/search-better-convex-decomposition/ today, they seem to have improved their HACD algorithm a lot too. Is your performance branch basically comparable to this?

That Ro-HACD looks good though, especially how it closely match the source mesh

I believe the new version4 release should be comparable. The performance branch and all other branches are now deprecated. Do you have any sample models you would like me to test against version4?

It's great to see v4 be out. Could you test the two shapes I sent at the beginning of this thread, so the torus and the bunny?

Here is an example results I see for the torus and bunny with version4
bunny
torus

Please watch this YouTube video I made to show how to use the tuning parameters and what expected results should look like:

https://youtu.be/Sa1NE-St8iA