Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

geometry.weld

Merge points closer than distance into one and renumber every primitive onto the survivors. With match "position", the triangles the merge collapsed onto a repeated point and the points no triangle reaches are dropped: the shared topology a smooth shading normal is averaged across. With match "position+normal", only the points whose normals also agree merge, which removes the duplicate seams a join leaves while keeping hard edges. Reports the counts before and after.

Inputs

  • geometry (Geometry). The geometry whose coincident points are merged. With match "position" a point kept stands where the lowest-numbered point merged into it stands, and with "position+normal" at the mean of the points merged into it; every primitive that used one of them uses it.
  • distance (Float, default 0.0001, above 0). Points within this distance of each other merge, chains of them as one group. Raising it past the shortest edge collapses that edge, and the triangles that lose two corners to one survivor are dropped as degenerate. With match "position+normal" the same figure in radians bounds how far apart two normals may be.
  • match (String, default "position", one of "position", "position+normal"). What two points must share to merge.
  • attributes (String, default "average", one of "average", "first"). Where a merged point's normal, uv and other attributes come from when match is "position": "average" takes the mean over the points merged into it (the normal made unit length again, or the lowest-numbered member's where the normals cancel; a whole number the whole part of the mean; a text the lowest-numbered member's), "first" keeps the lowest-numbered member's.

Outputs

  • geometry (Geometry). The welded geometry.
  • stats (Data). distance, vertexCountBefore, vertexCountAfter, mergedVertices, orphansRemoved, triangleCountBefore, triangleCountAfter and degenerateRemoved. With match "position+normal", orphansRemoved and degenerateRemoved are 0.
local welded = g.geometry.weld({ geometry = g.mesh.box({}), distance = 0.001 })