Giter Site home page Giter Site logo

Comments (11)

OskarSigvardsson avatar OskarSigvardsson commented on September 2, 2024 1

Thanks for the kind words! I've tested it a bit more and I feel comfortable enough with the fix, so I've merged it to master.

from unity-quickhull.

OskarSigvardsson avatar OskarSigvardsson commented on September 2, 2024

I've never used ProBuilder, but if you can provide me with the mesh, I can test it myself to see what's going on. Are you saying that the vertex is not on the inside of the generated mesh?

If you can access a Mesh instance in the source code from ProBuilder, you can use AssetDatabase.CreateAsset to save it to a file. You can also just iterate through the vertices and print them out and provide them that way.

from unity-quickhull.

StepanMynarik avatar StepanMynarik commented on September 2, 2024

I've never used ProBuilder, but if you can provide me with the mesh, I can test it myself to see what's going on. Are you saying that the vertex is not on the inside of the generated mesh?

If you can access a Mesh instance in the source code from ProBuilder, you can use AssetDatabase.CreateAsset to save it to a file. You can also just iterate through the vertices and print them out and provide them that way.

Thank you for the quick response.
I will send you the vertices later today when I get in the office. Thanks for the tips.

Off-topic - ProBuilder is pretty nice for insanely quick test mesh creation. Specially for someone like me, who doesn't really know how to Blender :)
It has been acquired by Unity and you can get it for free from the package manager.
Just saying, maybe you could find a use for it as well :)
I could never properly test our character controller without it.

from unity-quickhull.

OskarSigvardsson avatar OskarSigvardsson commented on September 2, 2024

Yeah, I've seen it, it looks very cool I used to work in game-dev using Unity, and if ProBuilder had been part of Unity then I would have used it for everything. Nowadays I've got a different job, and my Unity time is mostly spent on side-projects like this one, so I haven't really gotten the opportunity to properly try it out.

from unity-quickhull.

StepanMynarik avatar StepanMynarik commented on September 2, 2024

I found out something interesting.
First I noticed there is an Export Mesh option in ProBuilder. So I exported the mesh and, for good measure, tried to process it again (even though it has same shape and size). The issue was not present :O

This is how the exported mesh (same shape and size as the original) data look like:
Before running through quickhull:
(0.0, 0.2, 0.0)
(0.0, 0.0, 0.0)
(6.1, 0.0, 0.0)
(6.1, 0.2, 0.0)
(6.1, 0.2, 0.0)
(6.1, 0.0, 0.0)
(6.1, 0.0, -6.6)
(6.1, 0.2, -6.6)
(6.1, 0.2, -6.6)
(6.1, 0.0, -6.6)
(0.0, 0.0, -6.6)
(0.0, 0.2, -6.6)
(0.0, 0.2, -6.6)
(0.0, 0.0, -6.6)
(0.0, 0.0, 0.0)
(0.0, 0.2, 0.0)
(0.0, 0.2, -6.6)
(0.0, 0.2, 0.0)
(6.1, 0.2, 0.0)
(6.1, 0.2, -6.6)
(0.0, 0.0, 0.0)
(0.0, 0.0, -6.6)
(6.1, 0.0, -6.6)
(6.1, 0.0, 0.0)
After running through quickhull:
(0.0, 0.2, 0.0)
(0.0, 0.0, 0.0)
(6.1, 0.0, 0.0)
(0.0, 0.0, -6.6)
(6.1, 0.0, -6.6)
(6.1, 0.2, -6.6)
(0.0, 0.2, -6.6)
(6.1, 0.2, 0.0)

And this is how the original mesh data look like (notice the AFTER section where vertex [6.1, 0.0, 0.0] is duplicate and the position it should represent is missing, so the original box shape is not kept):
Before running through quickhull:
(0.0, 0.0, 0.0)
(6.1, 0.0, 0.0)
(0.0, 0.2, 0.0)
(6.1, 0.2, 0.0)
(6.1, 0.0, 0.0)
(6.1, 0.0, -6.6)
(6.1, 0.2, 0.0)
(6.1, 0.2, -6.6)
(6.1, 0.0, -6.6)
(0.0, 0.0, -6.6)
(6.1, 0.2, -6.6)
(0.0, 0.2, -6.6)
(0.0, 0.0, -6.6)
(0.0, 0.0, 0.0)
(0.0, 0.2, -6.6)
(0.0, 0.2, 0.0)
(0.0, 0.2, 0.0)
(6.1, 0.2, 0.0)
(0.0, 0.2, -6.6)
(6.1, 0.2, -6.6)
(0.0, 0.0, -6.6)
(6.1, 0.0, -6.6)
(0.0, 0.0, 0.0)
(6.1, 0.0, 0.0)
After running through quickhull:
(0.0, 0.0, 0.0)
(6.1, 0.0, 0.0)
(0.0, 0.2, 0.0)
(6.1, 0.0, 0.0)
(0.0, 0.2, -6.6)
(6.1, 0.0, -6.6)
(6.1, 0.2, -6.6)
(0.0, 0.0, -6.6)

I believe the meshes differ in vertex order only? Not sure though. I hope this helps in searching for the cause of this issue.
Feel free to ask more in case I forgot to mention something.

from unity-quickhull.

OskarSigvardsson avatar OskarSigvardsson commented on September 2, 2024

Yeah, I see the issue. That is weird. I'll investigate.

from unity-quickhull.

OskarSigvardsson avatar OskarSigvardsson commented on September 2, 2024

It's definitely some issue with duplicate vertices, because if you pass the points through this thing before passing it on to the calculator, it fixes the issue:

    void RemoveDuplicates(List<Vector3> points) {
        for (int i = 0; i < points.Count - 1; i++) {
            for (int j = i + 1; j < points.Count; j++) {
                if ((points[i] - points[j]).magnitude < 0.00001f) {
                    points.RemoveAt(j--);
                }
            }
        }
    }

That's obviously not the fastest thing in the world (being O(n^2) and all), but if you want a quick fix, that'll probably work (let me know if it doesn't). I'll look into the algorithm itself and see what's going on, but that might take longer, no promises on a deadline. I didn't really consider the case of duplicate points when I developed it, but I don't immediately see why it's an issue (or why vertex order would make a difference). I'll have to fire up the debugger and see what's going on.

from unity-quickhull.

StepanMynarik avatar StepanMynarik commented on September 2, 2024

I will weld (I think that's the right term?) the vertices prior to calculating the convex mesh then, no problem.

I do this at runtime, so getting it fixed would be nice, but I understand. I go into it with no expectations ;)

Good luck on the hunt!

from unity-quickhull.

OskarSigvardsson avatar OskarSigvardsson commented on September 2, 2024

Yeah, I agree, it needs to be fixed. I'll leave the issue open until I have time to deal with it.

from unity-quickhull.

OskarSigvardsson avatar OskarSigvardsson commented on September 2, 2024

Hey @StepanMynarik , I think I figured out what was wrong, it has to do with the AreCoplanar test. I've pushed a fix in a branch and created a pull request, but I need to a little more testing before I feel comfortable merging it.

The problem is that when I created this thing it was just for a personal project, so I didn't write proper unit tests. Now it turns out people are using it and I've become terrified of making any change, even though I'm like 97% sure on this one. I need to do some more testing before merging it (maybe even write some of those unit tests!), but in the meantime, I'd appreciate it if you could take it out for a test run in your project and let me know how it works.

from unity-quickhull.

StepanMynarik avatar StepanMynarik commented on September 2, 2024

Hi @OskarSigvardsson , you legend you!
I absolutely get it. The very same thing with dem unit tests happens to me often. Maybe I should just write them in the very beginning always when it makes sense. Writing them later is always a pain, a pain I usually avoid.

I just tested it myself and it seems to work perfectly. I will now keep using it and let you know if there are any issues on any other meshes we use.

You truly are a legend!

EDIT: Let me close this task then, as the original issue seems to be solved perfectly.

from unity-quickhull.

Related Issues (7)

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.