Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script error (RefineSubRoutine) when trying to build a mesh #4

Open
gujhack opened this issue Apr 29, 2020 · 1 comment
Open

Script error (RefineSubRoutine) when trying to build a mesh #4

gujhack opened this issue Apr 29, 2020 · 1 comment

Comments

@gujhack
Copy link

gujhack commented Apr 29, 2020

I've generated a list of Vector2 from a Voronoi generator.
Each Vector2 is a vertex of a Voronoi cell, ordered clockwise.
The triangulation builds a few meshes, then I get this error:

NullReferenceException: Object reference not set to an instance of an object
mattatz.Triangulation2DSystem.Triangulation2D.RefineSubRoutine (System.Single angle, System.Single threshold) (at Assets/scripts/Triangulation2D/Triangulation2D.cs:331)
mattatz.Triangulation2DSystem.Triangulation2D.Refine (System.Single angle, System.Single threshold) (at Assets/scripts/Triangulation2D/Triangulation2D.cs:320)
mattatz.Triangulation2DSystem.Triangulation2D.Triangulate (UnityEngine.Vector2[] points, System.Single angle, System.Single threshold) (at Assets/scripts/Triangulation2D/Triangulation2D.cs:181)
mattatz.Triangulation2DSystem.Triangulation2D..ctor (mattatz.Triangulation2DSystem.Polygon2D polygon, System.Single angle, System.Single threshold) (at Assets/scripts/Triangulation2D/Triangulation2D.cs:44)
Region..ctor (UnityEngine.Vector2 spawn, System.Collections.Generic.List`1[T] vertices) (at Assets/scripts/Region.cs:23)
VoronoiDemo.Generate () (at Assets/scripts/VoronoiDemo.cs:80)
VoronoiDemo.OnValidate () (at Assets/scripts/VoronoiDemo.cs:51)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
@Oppodelldog
Copy link

Hi, I had the same issue, for now I locally just added a guard clause to RefineSubRoutine if "skinny is null", that worked so far.
Did not dig deeper, but I prepared a sample for reproduction:

Hope this helps in analyzing and fixing.

        private void ReproduceIssue4()
        {
            var data = new[]
            {
                new Vector2(-43.819f,388.151f),
                new Vector2(-38.41f,400.137f),
                new Vector2(-28.355f,401.522f),
                new Vector2(46.671f,400.616f),
                new Vector2(56.05f,397.882f),
                new Vector2(56.05f,376.922f),
                new Vector2(45.996f,375.537f),
                new Vector2(-34.44f,385.418f),
            };

            (new Triangulation2D(new Polygon2D(data))).Build();
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants