1.3.64
 
Loading...
Searching...
No Matches
helios::RayTracingGeometry Struct Reference

Geometry data for ray tracing (backend-agnostic) More...

#include <RayTracingTypes.h>

Public Member Functions

size_t getPerPrimitiveBufferSize () const
 Get expected buffer size for per-primitive data.
 
size_t getUUIDLookupBufferSize () const
 Get expected buffer size for UUID→position lookup table.
 
void validate () const
 Validate geometry buffer consistency (debug builds only)
 

Data Fields

std::vector< float > transform_matrices
 Transform matrices (16 floats per primitive, row-major)
 
std::vector< uintprimitive_types
 Primitive type: 0=patch, 1=triangle, 2=disk, 3=tile, 4=voxel, 5=bbox.
 
std::vector< uintprimitive_UUIDs
 UUID for each primitive (for result mapping)
 
std::vector< uintprimitive_IDs
 Primitive ID within parent object (for sub-patch calculations)
 
std::vector< uintobject_IDs
 Parent object ID for each primitive.
 
std::vector< helios::int2object_subdivisions
 Object subdivisions (for mapping)
 
std::vector< char > twosided_flags
 Two-sided flag (1=two-sided, 0=one-sided)
 
std::vector< float > solid_fractions
 Solid fraction (0-1, for porous surfaces)
 
std::vector< uintprimitive_positions
 
PrimitiveTypeGeometry patches
 Patch data (4 vertices per patch)
 
PrimitiveTypeGeometry triangles
 Triangle data (3 vertices per triangle)
 
PrimitiveTypeGeometry tiles
 Tile data (4 vertices per tile)
 
PrimitiveTypeGeometry voxels
 Voxel data (8 vertices per voxel)
 
PrimitiveTypeGeometry bboxes
 Bounding box data (8 vertices per bbox)
 
std::vector< helios::vec3disk_centers
 Disk center positions.
 
std::vector< float > disk_radii
 Disk radii.
 
std::vector< helios::vec3disk_normals
 Disk normal vectors.
 
std::vector< uintdisk_UUIDs
 Disk UUIDs.
 
size_t disk_count = 0
 Number of disks.
 
std::vector< bool > mask_data
 Flattened 3D mask data [mask_id][y][x].
 
std::vector< helios::int2mask_sizes
 Size (width, height) for each mask.
 
std::vector< int > mask_IDs
 Mask ID for each primitive (-1 if no mask)
 
std::vector< helios::vec2uv_data
 Flattened 2D UV coordinates [primitive][vertex].
 
std::vector< int > uv_IDs
 UV data start index for each primitive (-1 if no UVs)
 
helios::vec2 periodic_flag
 Periodic boundary flags (x, y directions)
 
size_t primitive_count = 0
 Total number of primitives (all types)
 
size_t patch_count = 0
 Number of patches.
 
size_t triangle_count = 0
 Number of triangles.
 
size_t tile_count = 0
 Number of tiles.
 
size_t voxel_count = 0
 Number of voxels.
 
size_t bbox_count = 0
 Number of bounding boxes.
 
uint bbox_UUID_base = 0
 Starting UUID for bboxes (max_real_UUID + 1)
 
UUIDPositionMapper mapper
 

Detailed Description

Geometry data for ray tracing (backend-agnostic)

All geometry data for 6 primitive types: patch, triangle, disk, tile, voxel, bbox. Data is organized per-primitive and per-type.

Definition at line 40 of file RayTracingTypes.h.

Member Function Documentation

◆ getPerPrimitiveBufferSize()

size_t helios::RayTracingGeometry::getPerPrimitiveBufferSize ( ) const
inline

Get expected buffer size for per-primitive data.

Returns
primitive_count

Use when allocating buffers indexed by position (0..primitive_count-1). CRITICAL: Use this instead of Nobjects to avoid buffer undersizing bugs!

Buffers to size with this:

  • transform_matrices: size = getPerPrimitiveBufferSize() * 16
  • object_subdivisions: size = getPerPrimitiveBufferSize()
  • primitive_IDs: size = getPerPrimitiveBufferSize() ← NOT Nobjects!
  • twosided_flags, solid_fractions, object_IDs: size = getPerPrimitiveBufferSize()

Historical bug (commit 53ca9687d): primitive_IDs sized by Nobjects instead of Nprimitives

Definition at line 111 of file RayTracingTypes.h.

◆ getUUIDLookupBufferSize()

size_t helios::RayTracingGeometry::getUUIDLookupBufferSize ( ) const
inline

Get expected buffer size for UUID→position lookup table.

Returns
max(primitive_UUIDs) + 1

The lookup table is a SPARSE array indexed by UUID value. Must be sized to accommodate the highest UUID, not the primitive count!

Example: If UUIDs are [10, 42, 100], size must be 101, not 3. Entries for non-existent UUIDs contain UINT_MAX.

Definition at line 125 of file RayTracingTypes.h.

◆ validate()

void helios::RayTracingGeometry::validate ( ) const

Validate geometry buffer consistency (debug builds only)

Comprehensive validation of all indexing invariants. Catches buffer sizing errors BEFORE GPU upload, preventing crashes and silent corruption.

Validates:

  • All per-primitive buffers have size == primitive_count
  • All per-type buffers match their type counts
  • UUID→position mapping is bidirectionally consistent
  • primitive_positions table is correctly sized (max_UUID + 1)
  • Object subdivisions are valid (>= 1)

Call this at the START of every backend's updateGeometry() method.

Exceptions
helios_runtime_errorwith detailed message if validation fails
Note
Compiled out in release builds (ifndef NDEBUG) - zero production cost

Historical bugs this prevents:

  • Buffer sized by Nobjects instead of Nprimitives (commit 53ca9687d)
  • Wrong primitive_positions size
  • Inconsistent type counts

Definition at line 23 of file RayTracingTypes.cpp.

Field Documentation

◆ bbox_count

size_t helios::RayTracingGeometry::bbox_count = 0

Number of bounding boxes.

Definition at line 88 of file RayTracingTypes.h.

◆ bbox_UUID_base

uint helios::RayTracingGeometry::bbox_UUID_base = 0

Starting UUID for bboxes (max_real_UUID + 1)

Definition at line 89 of file RayTracingTypes.h.

◆ bboxes

PrimitiveTypeGeometry helios::RayTracingGeometry::bboxes

Bounding box data (8 vertices per bbox)

Definition at line 63 of file RayTracingTypes.h.

◆ disk_centers

std::vector<helios::vec3> helios::RayTracingGeometry::disk_centers

Disk center positions.

Definition at line 66 of file RayTracingTypes.h.

◆ disk_count

size_t helios::RayTracingGeometry::disk_count = 0

Number of disks.

Definition at line 70 of file RayTracingTypes.h.

◆ disk_normals

std::vector<helios::vec3> helios::RayTracingGeometry::disk_normals

Disk normal vectors.

Definition at line 68 of file RayTracingTypes.h.

◆ disk_radii

std::vector<float> helios::RayTracingGeometry::disk_radii

Disk radii.

Definition at line 67 of file RayTracingTypes.h.

◆ disk_UUIDs

std::vector<uint> helios::RayTracingGeometry::disk_UUIDs

Disk UUIDs.

Definition at line 69 of file RayTracingTypes.h.

◆ mapper

UUIDPositionMapper helios::RayTracingGeometry::mapper

Definition at line 92 of file RayTracingTypes.h.

◆ mask_data

std::vector<bool> helios::RayTracingGeometry::mask_data

Flattened 3D mask data [mask_id][y][x].

Definition at line 73 of file RayTracingTypes.h.

◆ mask_IDs

std::vector<int> helios::RayTracingGeometry::mask_IDs

Mask ID for each primitive (-1 if no mask)

Definition at line 75 of file RayTracingTypes.h.

◆ mask_sizes

std::vector<helios::int2> helios::RayTracingGeometry::mask_sizes

Size (width, height) for each mask.

Definition at line 74 of file RayTracingTypes.h.

◆ object_IDs

std::vector<uint> helios::RayTracingGeometry::object_IDs

Parent object ID for each primitive.

Definition at line 47 of file RayTracingTypes.h.

◆ object_subdivisions

std::vector<helios::int2> helios::RayTracingGeometry::object_subdivisions

Object subdivisions (for mapping)

Definition at line 48 of file RayTracingTypes.h.

◆ patch_count

size_t helios::RayTracingGeometry::patch_count = 0

Number of patches.

Definition at line 84 of file RayTracingTypes.h.

◆ patches

PrimitiveTypeGeometry helios::RayTracingGeometry::patches

Patch data (4 vertices per patch)

Definition at line 59 of file RayTracingTypes.h.

◆ periodic_flag

helios::vec2 helios::RayTracingGeometry::periodic_flag

Periodic boundary flags (x, y directions)

Definition at line 80 of file RayTracingTypes.h.

◆ primitive_count

size_t helios::RayTracingGeometry::primitive_count = 0

Total number of primitives (all types)

Definition at line 83 of file RayTracingTypes.h.

◆ primitive_IDs

std::vector<uint> helios::RayTracingGeometry::primitive_IDs

Primitive ID within parent object (for sub-patch calculations)

Definition at line 46 of file RayTracingTypes.h.

◆ primitive_positions

std::vector<uint> helios::RayTracingGeometry::primitive_positions

< Maps UUID to array position: primitive_positions[UUID] = array_index Size: max_UUID + 1 (sparse array, entries for non-existent UUIDs = UINT_MAX) Enables CUDA to convert UUID to array position for buffer indexing

Definition at line 56 of file RayTracingTypes.h.

◆ primitive_types

std::vector<uint> helios::RayTracingGeometry::primitive_types

Primitive type: 0=patch, 1=triangle, 2=disk, 3=tile, 4=voxel, 5=bbox.

Definition at line 44 of file RayTracingTypes.h.

◆ primitive_UUIDs

std::vector<uint> helios::RayTracingGeometry::primitive_UUIDs

UUID for each primitive (for result mapping)

Definition at line 45 of file RayTracingTypes.h.

◆ solid_fractions

std::vector<float> helios::RayTracingGeometry::solid_fractions

Solid fraction (0-1, for porous surfaces)

Definition at line 50 of file RayTracingTypes.h.

◆ tile_count

size_t helios::RayTracingGeometry::tile_count = 0

Number of tiles.

Definition at line 86 of file RayTracingTypes.h.

◆ tiles

PrimitiveTypeGeometry helios::RayTracingGeometry::tiles

Tile data (4 vertices per tile)

Definition at line 61 of file RayTracingTypes.h.

◆ transform_matrices

std::vector<float> helios::RayTracingGeometry::transform_matrices

Transform matrices (16 floats per primitive, row-major)

Definition at line 43 of file RayTracingTypes.h.

◆ triangle_count

size_t helios::RayTracingGeometry::triangle_count = 0

Number of triangles.

Definition at line 85 of file RayTracingTypes.h.

◆ triangles

PrimitiveTypeGeometry helios::RayTracingGeometry::triangles

Triangle data (3 vertices per triangle)

Definition at line 60 of file RayTracingTypes.h.

◆ twosided_flags

std::vector<char> helios::RayTracingGeometry::twosided_flags

Two-sided flag (1=two-sided, 0=one-sided)

Definition at line 49 of file RayTracingTypes.h.

◆ uv_data

std::vector<helios::vec2> helios::RayTracingGeometry::uv_data

Flattened 2D UV coordinates [primitive][vertex].

Definition at line 76 of file RayTracingTypes.h.

◆ uv_IDs

std::vector<int> helios::RayTracingGeometry::uv_IDs

UV data start index for each primitive (-1 if no UVs)

Definition at line 77 of file RayTracingTypes.h.

◆ voxel_count

size_t helios::RayTracingGeometry::voxel_count = 0

Number of voxels.

Definition at line 87 of file RayTracingTypes.h.

◆ voxels

PrimitiveTypeGeometry helios::RayTracingGeometry::voxels

Voxel data (8 vertices per voxel)

Definition at line 62 of file RayTracingTypes.h.


The documentation for this struct was generated from the following files: