Builtin Library
- ..
- README.md2.4 KB
- bindings.yaml1.8 KB
- shader.wgsl6.3 KB
README.md
topology
Mesh edit operations over a geometry's linkage (vertex.pt, primitive.vstart,
primitive.vcount), selected by the OP specialization (split_edge, collapse_edge, insert_face, delete_face, split_vertex), each stage by STAGE (count, write): split an edge (insert a point),
collapse an edge (merge two points and drop the faces that degenerate), insert a
face, delete a face, split a vertex (give a group of corners a point of their own).
Each operation runs in two stages with an exclusive prefix sum between them. The count
stage writes cnt, how many output vertices each primitive contributes (insert_face
appends one entry per new face after the np primitives). The caller's exclusive prefix sum
of cnt is off. The write stage writes the output vertices' points (o_pt) and where
each came from (o_src). The output primitives are off as run starts and cnt as run
lengths; a primitive with an empty run is gone, and core.select removes it. split_vertex
runs per vertex instead: cnt[v] is 1 for the first vertex of each group, the groups'
new points are numbered from npts in order of their off, and o_pt[v] / o_src[v]
are written at the vertex's own slot. The shader's header states the records each
operation reads in rec.
The params are np, nv and npts (the input's primitives, vertices and points),
nnew (the faces insert_face appends), wrap (1 when runs wrap from their last vertex
to their first) and minv (the fewest vertices a primitive keeps after a collapse). The
caller binds nv_out, the output vertex count o_pt and o_src are sized by (the total
of the prefix sum). The dispatch is one thread per primitive, per primitive and new face
for insert_face, and per vertex for split_vertex.
The operation's records come from the edge table: for split edge, the point
for each split edge gathered to the vertex slots through edges' side slots
(both faces of an edge name the same point); for collapse, the point each
point becomes, from an independent set of edges. The point an inserted
vertex or a split vertex stands for is carried by the output maps: o_src names the vertex
whose attributes an output vertex takes (negative when it is new, with ~v the
vertex a split inserted after), and the compaction of the records names each
new point's source. Integers are 32-bit words, exact.
geometry.decimate runs collapse_edge.