Unravel Engine C++ Reference
Loading...
Searching...
No Matches
unravel::batch_key Struct Reference

Batch key structure for grouping compatible draw calls. More...

#include <batch_key.h>

Public Member Functions

 batch_key ()=default
 Default constructor.
 
 batch_key (std::shared_ptr< mesh > mesh_ptr, std::shared_ptr< material > material_ptr, uint32_t lod_index, uint32_t submesh_index)
 Constructor with shared pointers.
 
 batch_key (const asset_handle< mesh > &mesh_handle, const asset_handle< material > &material_handle, uint32_t lod_index, uint32_t submesh_index)
 Constructor with asset handles (convenience)
 
auto operator<=> (const batch_key &other) const =default
 Three-way comparison operator for sorting and equality.
 
auto operator== (const batch_key &other) const -> bool=default
 Equality comparison operator.
 
auto hash () const noexcept -> size_t
 Generate hash value for this batch key.
 
auto is_valid () const -> bool
 Check if this batch key is valid.
 
auto to_string () const -> std::string
 Convert batch key to string for debugging.
 

Public Attributes

std::shared_ptr< meshmesh_ptr
 Shared pointer to the mesh geometry.
 
std::shared_ptr< materialmaterial_ptr
 Shared pointer to the material.
 
uint32_t lod_index = 0
 Level of detail index.
 
uint32_t submesh_index = 0
 Submesh index within the mesh.
 

Detailed Description

Batch key structure for grouping compatible draw calls.

Objects with identical batch keys can be rendered together in a single instanced draw call, significantly reducing CPU overhead. Uses shared_ptr to support both asset handles and material/mesh instances.

Definition at line 21 of file batch_key.h.

Constructor & Destructor Documentation

◆ batch_key() [1/3]

unravel::batch_key::batch_key ( )
default

Default constructor.

◆ batch_key() [2/3]

unravel::batch_key::batch_key ( std::shared_ptr< mesh > mesh_ptr,
std::shared_ptr< material > material_ptr,
uint32_t lod_index,
uint32_t submesh_index )

Constructor with shared pointers.

Parameters
mesh_ptrShared pointer to mesh geometry
material_ptrShared pointer to material
lod_indexLevel of detail index (0 = highest detail)
submesh_indexSubmesh index within the mesh (0-based)

Definition at line 10 of file batch_key.cpp.

◆ batch_key() [3/3]

unravel::batch_key::batch_key ( const asset_handle< mesh > & mesh_handle,
const asset_handle< material > & material_handle,
uint32_t lod_index,
uint32_t submesh_index )

Constructor with asset handles (convenience)

Parameters
mesh_handleAsset handle to mesh geometry
material_handleAsset handle to material
lod_indexLevel of detail index (0 = highest detail)
submesh_indexSubmesh index within the mesh (0-based)

Definition at line 21 of file batch_key.cpp.

Member Function Documentation

◆ hash()

auto unravel::batch_key::hash ( ) const -> size_t
noexcept

Generate hash value for this batch key.

Returns
Hash value suitable for use in hash tables

Definition at line 32 of file batch_key.cpp.

◆ is_valid()

auto unravel::batch_key::is_valid ( ) const -> bool

Check if this batch key is valid.

Returns
True if both mesh and material pointers are valid

Definition at line 44 of file batch_key.cpp.

◆ operator<=>()

auto unravel::batch_key::operator<=> ( const batch_key & other) const
default

Three-way comparison operator for sorting and equality.

Parameters
otherOther batch key to compare with
Returns
Comparison result

◆ operator==()

auto unravel::batch_key::operator== ( const batch_key & other) const -> bool=default
default

Equality comparison operator.

Parameters
otherOther batch key to compare with
Returns
True if keys are equal

◆ to_string()

auto unravel::batch_key::to_string ( ) const -> std::string

Convert batch key to string for debugging.

Returns
String representation of the batch key

Definition at line 49 of file batch_key.cpp.

Member Data Documentation

◆ lod_index

uint32_t unravel::batch_key::lod_index = 0

Level of detail index.

Definition at line 30 of file batch_key.h.

◆ material_ptr

std::shared_ptr<material> unravel::batch_key::material_ptr

Shared pointer to the material.

Definition at line 27 of file batch_key.h.

◆ mesh_ptr

std::shared_ptr<mesh> unravel::batch_key::mesh_ptr

Shared pointer to the mesh geometry.

Definition at line 24 of file batch_key.h.

◆ submesh_index

uint32_t unravel::batch_key::submesh_index = 0

Submesh index within the mesh.

Definition at line 33 of file batch_key.h.


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