tiny.geometry.Storage
Defined in tiny.geometry.
Caller-owned memory for one tree.
API (8)
Actions
Public operations.
allocfitsfreenodeCapacity: A tree has at most one leaf per triangle, so at most2 n - 1nodes.
Fields and members
Public fields and members.
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;Complete caller list for Storage.alloc
7 direct callers.
lib.geometry.src.bvh.test_a_built_tree_bounds_its_node_count_and_depth[function] — test source atlib/geometry/src/bvh.zig:673in nearest public ownerlib.geometry.src.bvhlib.geometry.src.bvh.test_a_tree_too_deep_for_the_query_stack_is_refused[function] — test source atlib/geometry/src/bvh.zig:706in nearest public ownerlib.geometry.src.bvhlib.geometry.src.bvh.test_an_empty_mesh_builds_a_tree_that_answers_nothing[function] — test source atlib/geometry/src/bvh.zig:728in nearest public ownerlib.geometry.src.bvhlib.geometry.src.bvh.test_an_overlap_with_a_small_buffer_keeps_the_lowest_indices[function] — test source atlib/geometry/src/bvh.zig:739in nearest public ownerlib.geometry.src.bvhlib.geometry.src.bvh.test_the_tree_answers_a_ray_on_a_shared_edge_with_the_lower_index[function] — test source atlib/geometry/src/bvh.zig:692in nearest public ownerlib.geometry.src.bvhlib.geometry.src.test.BuildIsDeterministic.property[function] — private source atlib/geometry/src/test.zig:166in nearest public ownerlib.geometry.src.testlib.geometry.src.test.Fixture.build[function] — private source atlib/geometry/src/test.zig:88in nearest public ownerlib.geometry.src.test
Audit
| Definitions | 5 |
|---|---|
| Public names | 5 |
| Members | 4 |
| Version | 26.7.0 |
| Revision | daab053ee433 |