Skip to documentation
SLOP

tiny.rig.part

Reference tiny.rig part

Defined in tiny.rig.

Parts: what each joint draws.

API (6)

Actions

Public operations.

Types and contracts

Public types and contracts.

Values and defaults

Public values and defaults.

No direct callersNo direct callstiny.rigpart
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Called byCallsNo direct callstest; no linkfun.rig.src.parttest: slots swap parts and fixed part...partresolve
Static calls · unresolved targets: 0 · external targets: 0.

Source: fun/rig/src/part.zig

zig
//! Parts: what each joint draws.//!//! A part is an index into the caller's table of meshes. A joint draws a//! fixed part, nothing, or whichever part a slot currently selects, as a//! stop-motion face swaps eyes and mouths. A clip's part channels, or the//! caller, write each slot's choice; `resolve` turns choices into the part//! each joint draws.const std = @import("std");const assert = std.debug.assert;pub const Part = u16;pub const none: Part = std.math.maxInt(Part);pub const Slot = struct {    /// The parts a choice indexes.    parts: []const Part,    /// The chosen part, or `none` for a choice past the slot's parts.    pub fn select(slot: Slot, choice: u8) Part {        if (choice >= slot.parts.len) return none;        return slot.parts[choice];    }};pub const Attachment = union(enum) {    nothing,    part: Part,    slot: u16,};/// The part each joint draws, `none` where it draws nothing.pub fn resolve(    attachments: []const Attachment,    slots: []const Slot,    choices: []const u8,    out: []Part,) void {    assert(choices.len == slots.len);    assert(out.len == attachments.len);    for (attachments, out) |attachment, *drawn| {        drawn.* = switch (attachment) {            .nothing => none,            .part => |fixed| fixed,            .slot => |index| blk: {                assert(index < slots.len);                break :blk slots[index].select(choices[index]);            },        };    }}test "slots swap parts and fixed parts stay" {    const slots = [_]Slot{.{ .parts = &.{ 10, 11, 12 } }};    const attachments = [_]Attachment{ .nothing, .{ .part = 3 }, .{ .slot = 0 } };    var out: [3]Part = undefined;    resolve(&attachments, &slots, &.{2}, &out);    try std.testing.expectEqualSlices(Part, &.{ none, 3, 12 }, &out);    resolve(&attachments, &slots, &.{7}, &out);    try std.testing.expectEqual(none, out[2]);}

Source: fun/rig/src/root.zig:24

zig
pub const part = @import("part.zig");

Audit

Definitions7
Public names7
Members4
Version26.7.0
Revisiondaab053ee433