-
Notifications
You must be signed in to change notification settings - Fork 65
Open
Description
While using this awesome library me and my team came across this problem. The code is taken from a unit test that reproduces the issue. Executable code can be found under [TesselationProblemExample].(https://github.com/sqeezy/TesselationProblemExample).
LibTessDotNet.Double was used for this example.
var tess = new Tess();
ContourOrientation positiveOrientation = ContourOrientation.Clockwise;
ContourOrientation negativeOrientation = ContourOrientation.CounterClockwise;
ContourVertex a = new(new Vec3(-48.13525763898019, -4.495359229766127E-14, 0));
ContourVertex b = new(new Vec3(-48.135257638980185, -27.24424809648011, 0));
ContourVertex c = new(new Vec3(47.367221005276186, -27.24424809648011, 0));
ContourVertex d = new(new Vec3(47.36722100527618, -4.495359229766127E-14, 0));
ContourVertex f = new(new Vec3(-34.571100634798604, -4.459276981465809E-14, 0));
ContourVertex e = new(new Vec3(-48.13525763898021, -11.279901577469582, 0));
var positiveRectangle = new List<ContourVertex> { a, b, c, d };
var negativeTriangle = new List<ContourVertex> { a, f, e };
tess.AddContour(positiveRectangle, positiveOrientation);
tess.AddContour(negativeTriangle, negativeOrientation);
tess.Tessellate(WindingRule.Positive, ElementType.Polygons, 3, (_, _, _) => null, new Vec3(0, 0, 1));
// The result contains the 4 vertices of positiveRectangle. Expected would be that the shared point 'a' is removed and 'e' and 'f' are added
Assert.Equal(5, tess.Vertices.Length);
// For a polygon of 5 vertices, three triangles would be expected
Assert.Equal(3, tess.ElementCount);
// The shared corner should be removed but isn't
Assert.DoesNotContain(a, tess.Vertices);I could not think of a reason why this operation does not work as expected. Even if some points of the triangle are outside of the rectangle, the shape should never be ignored completely.
Metadata
Metadata
Assignees
Labels
No labels
