You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// The number type to use for tessellation
using Coord = double;
// The index type. Defaults to uint32_t, but you can also pass uint16_t if you know that your
// data won't have more than 65536 vertices.
using N = uint32_t;
// Create array
using Point = std::array<Coord, 2>;
std::vector<std::vector<Point>> polygon;
// Fill polygon structure with actual data. Any winding order works.
// The first polyline defines the main polygon.
polygon.push_back({{-1.095, -1.025}, {1.095, -1.025},{1.095, 1.025},{-1.095, 1.025}});
// Following polylines define holes.
polygon.push_back({{0.425, -0.965},{0.425, 0.965},{1.035, 0.965},{1.035, -0.965}});
polygon.push_back({{-1.035, -0.965},{-1.035, 0.965},{0.365, 0.965},{0.365, -0.965}});
// Run tessellation
// Returns array of indices that refer to the vertices of the input polygon.
// e.g: the index 6 would refer to {25, 75} in this example.
// Three subsequent indices form a triangle. Output triangles are clockwise.
std::vector<N> indices = mapbox::earcut<N>(polygon);
it's a rectangle with two rectangular holes, leaving only a small space in between those holes. It appears earcut 'cuts' this space ( see screenshot ). Is this expected behavior or can this be fixed?
The text was updated successfully, but these errors were encountered:
This is valid behaviour for this library. It's been created mostly to create triangles for graphics rendering, less so for strictly valid triangulation for e.g. navmeshing. Libtess might give you more accurate results (with a performance penalty).
To reproduce please check this code:
it's a rectangle with two rectangular holes, leaving only a small space in between those holes. It appears earcut 'cuts' this space ( see screenshot ). Is this expected behavior or can this be fixed?
The text was updated successfully, but these errors were encountered: