Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

core.weld (procNode)

Merge the points of a geometry that stand within a distance of each other, joining the primitives that used them.

Built from core.spatial (the points near each point), the hash_hook kernel folded a fixed number of rounds (every point takes the smallest point number of the points joined to it; the number of rounds is twice the bits of the number of points the geometry holds, so nothing is read back), compact, scatter with a mean fold for the merged positions (with place "first" the carried position stands), attribute.carry for every other attribute (a merged point takes the values of the lowest-numbered point of its group) and gather to renumber vertex.pt. With match set to "position+normal" two points merge only when their N normals differ by no more than angle degrees. Every pair within the distance ends in one group, so a chain of points each within the distance of the next merges whole.

Inputs

  • geometry (Geometry). The geometry welded.
  • distance (Number). Default 0.0001. Above 0. Points closer than this merge.
  • match (one of position, position+normal). Default "position". What has to agree: position alone, or position and the N point normal.
  • angle (Number). Default 1.0. 0 to 180. For "position+normal": how far apart two normals may be, in degrees, and still merge.
  • place (one of mean, first). Default "mean". Where a merged point stands: at the mean of its group, or at the position of the lowest-numbered point of the group (the point attribute.carry takes the other attributes from).

Outputs

  • geometry: the welded geometry.
  • map: for each point of the input, the number of the welded point it merged into, as a column as long as the input's points.

A graph's call g.core.weld({ ... }) gives a table of both outputs by name, so a graph that welds a geometry and works on the result reads g.core.weld({ ... }).geometry; map carries a value of every input point onto the welded points, for example as the index of a core.scatter.

Example

local grid = g.mesh.grid({ size = { x = 2, z = 2 }, cells = { x = 2, z = 2 } })
local doubled = g.core.concat({ geometries = { grid, grid } })
local welded = g.core.weld({ geometry = doubled, distance = 0.001 })

welded.geometry holds the nine merged points and welded.map sends the points of both copies to 0 to 8.