An Odin port of libtess2 — Eric Veach's sweep-line polygon tessellator — with no C dependencies, plus a higher-level package for boolean operations and polygon offsetting.
libtess2/
├── src/ package libtess2_port — the core tessellator (faithful port)
│ ├── tesselator.odin public types & API (Tesselator, WindingRule, ElementType, …)
│ ├── tess.odin setup, output, default allocator
│ ├── sweep.odin sweep-line algorithm
│ ├── mesh.odin half-edge mesh (Euler operators)
│ ├── geom.odin geometric predicates
│ ├── dict.odin active-edge dictionary
│ ├── priorityq.odin event priority queue
│ └── bucketalloc.odin bucket allocator
├── libtess2.odin package libtess2 — ergonomic wrapper (begin/add/end, tesselate_*)
├── polygon.odin package libtess2 — boolean ops & offsetting on top of the wrapper
├── tests/ package tests — @(test) suites (run with `odin test`)
└── examples/demo/ raylib visual demo
The libtess2 package (root) wraps the src core. Most users only need the root
package; import the src package directly for low-level control.
odin test ./tests # run the test suites
odin run examples/demo # raylib visual demo (boolean ops & offsets)import lt "path/to/libtess2"
shapes := [][][2]f64{
{{0,0}, {2,0}, {2,2}, {0,2}}, // CCW
{{1,1}, {3,1}, {3,3}, {1,3}}, // CCW
}
union_result := lt.union_polygons(shapes)
defer lt.delete_contours(union_result)
triangles := lt.triangulate_polygons(shapes)
defer delete(triangles)Boolean ops (union_polygons, intersect_polygons, xor_polygons,
difference_polygons) return contour sets ([][][2]f64); triangulate_polygons
returns a flat [][3][2]f64. Offsetting is available via
offset_polygon_miter, offset_polygon_round, and offset_polygon_bevel.