Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit3bb1da2647

README.md

rigStructure

The shape of a skeleton, read from a .rig document or a live Skeleton: parents and children, the rest pose's world positions and rotations (rest scale included), and the questions an avatar type asks of that shape. A structure is memoized by the content hash of the bones it was built from, so reading the same skeleton twice builds it once.

local rigStructure = require("@builtin::modules.rigStructure")
local s = rigStructure.fromDoc(asset.resolve("PolygonSyntyCharacter", "rig"):doc())
local hips = rigStructure.lca(s, s.byName["Ankle_L"], s.byName["Ankle_R"])
print(s.bones[hips].name, rigStructure.reach(s, hips, { 0, 1, 0 }))
CallAnswers
fromDoc(doc) / fromBones(bones)The structure: bones, n, byName, parent (0 for a root), children, depth, order (parents first), gPos, gRot, gScale, hash. Indices are 1-based.
hash(doc)The content hash over names, parents and rest transforms.
subtree(s, i) / leaves(s, i)The bones below i, and its leaves.
path(s, from, to)The bones from from down to to, or nil when to is not below it.
lca(s, a, b)The deepest bone both descend from.
reach(s, i, dir)How far the subtree at i reaches along dir.
extremity(s, i, origin)The subtree bone farthest from origin.
chainLength(s, from, to)Summed link lengths from from down to to.
mirrorScore(s, a, b, origin, side)0..1: how well subtree b reflects onto subtree a across the plane through origin with normal side, and how alike their lengths are.
extent(s, dir)Lowest and highest projections of any bone onto dir.

A bone whose parents loop back on themselves is cut from its parent and read as a root, so every walk over a structure ends.