13 std::shared_ptr<material> material_ptr,
15 uint32_t submesh_index)
16 : mesh_ptr(
std::move(mesh_ptr))
17 , material_ptr(
std::move(material_ptr))
18 , lod_index(lod_index)
19 , submesh_index(submesh_index)
26 uint32_t submesh_index)
27 : mesh_ptr(mesh_handle.get())
28 , material_ptr(material_handle.get())
29 , lod_index(lod_index)
30 , submesh_index(submesh_index)
53 std::ostringstream oss;
55 oss <<
"mesh=" <<
static_cast<const void*
>(
mesh_ptr.get());
56 oss <<
", material=" <<
static_cast<const void*
>(
material_ptr.get());
67 std::optional<shadow_cutout_state> cutout_state)
70 , submesh_index(submesh)
72 , cutout(
std::move(cutout_state))
78auto compare_float(
float lhs,
float rhs) -> std::strong_ordering
82 return std::strong_ordering::less;
86 return std::strong_ordering::greater;
88 return std::strong_ordering::equal;
91auto compare_shadow_cutout(
const std::optional<shadow_cutout_state>&
a,
92 const std::optional<shadow_cutout_state>&
b) -> std::strong_ordering
94 if(
a.has_value() !=
b.has_value())
96 return a.has_value() ? std::strong_ordering::greater : std::strong_ordering::less;
100 return std::strong_ordering::equal;
103 const shadow_cutout_state& lhs = *
a;
104 const shadow_cutout_state& rhs = *
b;
105 if(lhs.color_map.get() != rhs.color_map.get())
107 return lhs.color_map.get() < rhs.color_map.get() ? std::strong_ordering::less
108 : std::strong_ordering::greater;
110 if(
const auto cmp = compare_float(lhs.alpha_test_value, rhs.alpha_test_value); cmp != 0)
114 if(
const auto cmp = compare_float(lhs.base_color.value.r, rhs.base_color.value.r); cmp != 0)
118 if(
const auto cmp = compare_float(lhs.base_color.value.g, rhs.base_color.value.g); cmp != 0)
122 if(
const auto cmp = compare_float(lhs.base_color.value.b, rhs.base_color.value.b); cmp != 0)
126 if(
const auto cmp = compare_float(lhs.base_color.value.a, rhs.base_color.value.a); cmp != 0)
130 if(
const auto cmp = compare_float(lhs.tiling.x, rhs.tiling.x); cmp != 0)
134 return compare_float(lhs.tiling.y, rhs.tiling.y);
140 if(mesh_ptr.get() != other.mesh_ptr.get())
142 return mesh_ptr.get() < other.mesh_ptr.get() ? std::strong_ordering::less : std::strong_ordering::greater;
144 if(lod_index != other.lod_index)
146 return lod_index < other.lod_index ? std::strong_ordering::less : std::strong_ordering::greater;
148 if(submesh_index != other.submesh_index)
150 return submesh_index < other.submesh_index ? std::strong_ordering::less : std::strong_ordering::greater;
152 if(cull != other.cull)
154 return cull < other.cull ? std::strong_ordering::less : std::strong_ordering::greater;
156 return compare_shadow_cutout(cutout, other.cutout);
161 return (*this <=> other) == 0;
193 return cutout.has_value();
198 std::ostringstream oss;
199 oss <<
"shadow_batch_key{mesh=" <<
static_cast<const void*
>(
mesh_ptr.get());
201 oss <<
", cutout=" << (
cutout.has_value() ?
"yes" :
"no") <<
"}";
207 uint32_t submesh_index,
211 std::optional<shadow_cutout_state> cutout;
214 cull = material_ptr->get_cull_type();
217 const auto& pbr =
static_cast<const pbr_material&
>(*material_ptr);
218 if(!pbr.casts_shadow())
222 if(pbr.uses_alpha_cutout())
224 cutout = pbr.make_shadow_cutout_state();
Main class representing a 3D mesh with support for different LODs, submeshes, and skinning.
Class for physically-based rendering (PBR) materials.
Hash specialization for batch_key to enable use in std::unordered_map.
auto make_shadow_batch_key(const std::shared_ptr< mesh > &mesh_ptr, uint32_t lod_index, uint32_t submesh_index, const std::shared_ptr< material > &material_ptr) -> shadow_batch_key
Build a shadow batch key from mesh geometry and optional material cutout metadata.
cull_type
Enum representing the type of culling to be used.
@ counter_clockwise
Cull counter-clockwise faces.
void hash_combine(std::size_t &seed, const T &v)
Thread-safe handle to an asset.
batch_key()=default
Default constructor.
auto hash() const noexcept -> size_t
Generate hash value for this batch key.
auto to_string() const -> std::string
Convert batch key to string for debugging.
auto is_valid() const -> bool
Check if this batch key is valid.
std::shared_ptr< material > material_ptr
Shared pointer to the material.
uint32_t lod_index
Level of detail index.
std::shared_ptr< mesh > mesh_ptr
Shared pointer to the mesh geometry.
uint32_t submesh_index
Submesh index within the mesh.
Batch key for shadow depth passes — geometry-first, optional cutout bucket.
auto hash() const noexcept -> size_t
std::shared_ptr< mesh > mesh_ptr
auto is_valid() const -> bool
std::optional< shadow_cutout_state > cutout
auto uses_alpha_cutout() const -> bool
auto operator==(const shadow_batch_key &other) const -> bool
shadow_batch_key()=default
auto to_string() const -> std::string
auto operator<=>(const shadow_batch_key &other) const -> std::strong_ordering