Builtin Library
- ..
- .metadata209 B
- README.md2.1 KB
- ids.module
- init.luau8.7 KB
README.md
core.select (procNode)
Keep the elements of a geometry a mask picks and drop the rest, renumbering the links between points, vertices and primitives.
Built from math.ne over the mask, compact (the kept elements and the inverse map), core.owner, gather, a segmented reduce (segments = primitive.count) or, with device, a scatter of the vertices' marks, scatter, attribute.carry for every class and scan for the new run starts. Keeping points drops every primitive that loses a vertex; keeping primitives keeps their vertices and, by default, the points those vertices read; points set to "all" keeps every point.
Inputs
geometry(Geometry). The geometry to filter.class(one of point, primitive). Default"point". Which elements the mask is over.points(one of used, all). Default"used". For class "primitive": which points stay, the points the kept primitives use or every point.mask(Value). Default1. A column or field over the class's elements: an element is kept where the value is not 0. The mask is written onto the class and read back, so a field is evaluated over this geometry's elements: a field reading the geometry's own attributes (g.field.position(),g.element.P,g.element.point.N) reads this geometry's.device(Bool). Defaultfalse. Whether the counts of what is kept stay on the device. Off, the three live counts are read back together and the result is the exact size of what is kept. On, the result holds the points, vertices and primitives the geometry is allocated for and counts the kept ones there, and nothing is read back; whatever reads the result reads the live counts.
Outputs
geometry: the kept elements with the links renumbered.
Example
local grid = g.mesh.grid({ size = { x = 2, z = 2 }, cells = { x = 2, z = 2 } })
local left = g.core.select({ geometry = grid, class = "point", mask = g.compare(g.field.position({ geometry = grid }).x, "lt", 0.5) })
The six points with x below 0.5 stay, with the four triangles they still make whole.