Skip to documentation
SLOP

tiny.geometry.Storage

Reference tiny.geometry Storage

Defined in tiny.geometry.

Caller-owned memory for one tree.

API (8)

Actions

Public operations.

Fields and members

Public fields and members.

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

Source

Source: lib/geometry/src/bvh.zig:85

zig
/// Caller-owned memory for one tree. `centroids` is build scratch, and the/// finished tree borrows the other three.pub const Storage = struct {    nodes: []Node,    triangles: []Triangle,    order: []u32,    centroids: []Vec3,    /// A tree has at most one leaf per triangle, so at most `2 n - 1` nodes.    pub fn nodeCapacity(triangle_count: usize) usize {        if (triangle_count == 0) return 1;        return 2 * triangle_count - 1;    }    pub fn alloc(gpa: Allocator, triangle_count: usize) Allocator.Error!Storage {        assert(triangle_count <= triangle_mesh.max_triangles);        const nodes = try gpa.alloc(Node, nodeCapacity(triangle_count));        errdefer gpa.free(nodes);        const triangles = try gpa.alloc(Triangle, triangle_count);        errdefer gpa.free(triangles);        const order = try gpa.alloc(u32, triangle_count);        errdefer gpa.free(order);        const centroids = try gpa.alloc(Vec3, triangle_count);        return .{ .nodes = nodes, .triangles = triangles, .order = order, .centroids = centroids };    }    pub fn free(storage: Storage, gpa: Allocator) void {        gpa.free(storage.centroids);        gpa.free(storage.order);        gpa.free(storage.triangles);        gpa.free(storage.nodes);    }    pub fn fits(storage: Storage, triangle_count: usize) bool {        return storage.nodes.len >= nodeCapacity(triangle_count) and            storage.triangles.len >= triangle_count and            storage.order.len >= triangle_count and            storage.centroids.len >= triangle_count;    }};

Source: lib/geometry/src/root.zig:30

zig
pub const Storage = bvh.Storage;
Called byCallstest sourcelib.geometry.src.bvhtest: a built tree bounds its node co...test sourcelib.geometry.src.bvhtest: a tree too deep for the query s...test sourcelib.geometry.src.bvhtest: an empty mesh builds a tree tha...test sourcelib.geometry.src.bvhtest: an overlap with a small buffer ...test sourcelib.geometry.src.bvhtest: the tree answers a ray on a sha...+2 moreStoragenodeCapacityStoragealloc
Static calls · unresolved targets: 0 · external targets: 2.
Called byCallsNo direct callersStoragenodeCapacityStoragefits
Static calls · unresolved targets: 0 · external targets: 0.
Called byCallsNo direct callsBvhbuildtiny.geometryFixedStorageStorageallocStoragefitstest sourcelib.geometry.src.bvhtest: a built tree bounds its node co...StoragenodeCapacity
Static calls · unresolved targets: 0 · external targets: 0.

Complete caller list for Storage.alloc

7 direct callers.

Audit

Definitions5
Public names5
Members4
Version26.7.0
Revisiondaab053ee433