Unravel Engine C++ Reference
Loading...
Searching...
No Matches
batch_key.h
Go to the documentation of this file.
1#pragma once
2
4
5#include <cstdint>
6#include <memory>
7#include <string>
8
9namespace unravel
10{
11class mesh;
12class material;
13
22{
24 std::shared_ptr<mesh> mesh_ptr;
25
27 std::shared_ptr<material> material_ptr;
28
30 uint32_t lod_index = 0;
31
33 uint32_t submesh_index = 0;
34
38 batch_key() = default;
39
47 batch_key(std::shared_ptr<mesh> mesh_ptr,
48 std::shared_ptr<material> material_ptr,
49 uint32_t lod_index,
50 uint32_t submesh_index);
51
59 batch_key(const asset_handle<mesh>& mesh_handle,
60 const asset_handle<material>& material_handle,
61 uint32_t lod_index,
62 uint32_t submesh_index);
63
69 auto operator<=>(const batch_key& other) const = default;
70
76 auto operator==(const batch_key& other) const -> bool = default;
77
82 auto hash() const noexcept -> size_t;
83
88 auto is_valid() const -> bool;
89
94 auto to_string() const -> std::string;
95};
96
97} // namespace unravel
98
102namespace std
103{
104template<>
106{
107 auto operator()(const unravel::batch_key& key) const noexcept -> size_t
108 {
109 return key.hash();
110 }
111};
112}
Hash specialization for batch_key to enable use in std::unordered_map.
Represents a handle to an asset, providing access and management functions.
auto operator()(const unravel::batch_key &key) const noexcept -> size_t
Definition batch_key.h:107
Batch key structure for grouping compatible draw calls.
Definition batch_key.h:22
batch_key()=default
Default constructor.
auto hash() const noexcept -> size_t
Generate hash value for this batch key.
Definition batch_key.cpp:32
auto operator<=>(const batch_key &other) const =default
Three-way comparison operator for sorting and equality.
auto is_valid() const -> bool
Check if this batch key is valid.
Definition batch_key.cpp:44
std::shared_ptr< material > material_ptr
Shared pointer to the material.
Definition batch_key.h:27
uint32_t lod_index
Level of detail index.
Definition batch_key.h:30
std::shared_ptr< mesh > mesh_ptr
Shared pointer to the mesh geometry.
Definition batch_key.h:24
uint32_t submesh_index
Submesh index within the mesh.
Definition batch_key.h:33
auto operator==(const batch_key &other) const -> bool=default
Equality comparison operator.