Skip to content

Inconsistent results for tessellation #9

@JSeligstein

Description

@JSeligstein

Hey there. I am generating a random shape through the following process:

  • Choose n points around a circle with random radius r from (minR, maxR)
  • Create a spline connecting those points
  • Create a polygon by sampling that spline at m points around the circle.

I'm then passing that shape into tessellation with maxEdge being 0.5, though I've seen similar results at 1.0.

I get relatively inconsistent results. Sometimes, it tessellates beautifully:

image

Sometimes, it half is tessellated, half is fanned:

image
image
image

Sometimes it just gets full fan treatment:

image

No code has changed between these screenshots, but the random shape has obviously changed. I would expect closer to the first one for all results.

// returns Vector2[] polygon
var polygon = section.splineToPolygon();
var iGeom = IntGeom.DefGeom;
var extraPoints = new NativeArray<IntVector>(0, Allocator.Temp);

// copied from sample code
var pShape = ToPlainShape(polygon, null, iGeom, Allocator.Temp);
var delaunay = pShape.Delaunay(iGeom.Int(0.f5), extraPoints, Allocator.Temp);
delaunay.Tessellate(iGeom, 1.0f);

extraPoints.Dispose();
            
var triangles = delaunay.Indices(Allocator.Temp);
_triangles.AddRange(triangles);

var vertices = delaunay.Vertices(Allocator.Temp, iGeom, 0);
foreach (var vtx in vertices) {
    _vertices.Add(new Vector3(vtx.x, 0f, vtx.y)-this._worldPos);
}

delaunay.Dispose();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions