Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

debug.validate (procNode)

Validate a Geometry, answering a Data report of any issues: an index outside the point range, a NaN position coordinate, and the triangles naming one point twice. The checks are reductions on the device, read back once into the report. Wire it after a node that builds or edits topology to catch a broken link before it reaches a mesh.

Inputs

  • value (Geometry). The Geometry checked. A vertex pointing outside the point range and a NaN position coordinate each contribute at most one entry to issues, at the first position found; every triangle naming one point twice is counted in full as degenerateTriangles. valid says issues came back empty.

Outputs

  • report: the Data report { kind = "Geometry", vertexCount, triangleCount, degenerateTriangles, issues, valid }. vertexCount is the number of points and triangleCount the number of triangles its primitives make. issues lists "index out of range at position <n>" (the 1-based place of the first vertex whose point is outside the range) and "NaN vertex coordinate at position <n>" (the 1-based place of the first NaN in the flat list of coordinates). valid is true when issues is empty; a degenerate triangle is counted and leaves valid as it is.

Example

local report = g.debug.validate({ value = g.mesh.box({}) })

The box reports { kind = "Geometry", vertexCount = 24, triangleCount = 12, degenerateTriangles = 0, issues = {}, valid = true }. A geometry whose first vertex names point 99 of nine reports issues = { "index out of range at position 1" } and valid = false.