Unravel Engine C++ Reference
Loading...
Searching...
No Matches
reflection_probe.h
Go to the documentation of this file.
1#pragma once
2#include <engine/engine_export.h>
3
4#include <math/math.h>
5
6#include <cstdint>
7
8namespace unravel
9{
13enum class probe_type : std::uint8_t
14{
16 box = 0,
18 sphere = 1
19};
20
24enum class reflect_method : std::uint8_t
25{
27 environment = 0,
29 static_only = 1
30};
31
36{
40 struct box
41 {
43 math::vec3 extents = {5.0, 5.0f, 5.0f};
45 float transition_distance = 1.0f;
46 };
47
51 struct sphere
52 {
54 float range = 5.0f;
55 };
56
57 auto get_face_extents(uint32_t face, const math::transform& transform) const -> float
58 {
59 const auto& scale = transform.get_scale();
60
62 {
63 auto max_scale = math::max(scale.x, math::max(scale.y, scale.z));
64 return sphere_data.range * max_scale;
65 }
66
68 {
69 auto scaled_extents = box_data.extents * scale;
70 return math::max(scaled_extents.x, math::max(scaled_extents.y, scaled_extents.z));
71 }
72
73 return {};
74 }
75
76 auto get_max_range() const -> float
77 {
79 {
80 return sphere_data.range;
81 }
82 else if(type == probe_type::box)
83 {
84 return math::max(box_data.extents.x, math::max(box_data.extents.y, box_data.extents.z));
85 }
86 return 0.0f;
87 }
88
94 float intensity = 1.0f;
99};
100
108inline auto operator==(const reflection_probe& pr1, const reflection_probe& pr2) -> bool
109{
110 return pr1.type == pr2.type && pr1.method == pr2.method &&
111 math::equal(pr1.intensity, pr2.intensity, math::epsilon<float>()) &&
112 math::all(math::equal(pr1.box_data.extents, pr2.box_data.extents, math::epsilon<float>())) &&
113 math::equal(pr1.box_data.transition_distance, pr2.box_data.transition_distance, math::epsilon<float>()) &&
114 math::equal(pr1.sphere_data.range, pr2.sphere_data.range, math::epsilon<float>());
115}
116
124inline auto operator!=(const reflection_probe& pr1, const reflection_probe& pr2) -> bool
125{
126 return !(pr1 == pr2);
127}
128
129} // namespace unravel
General purpose transformation class designed to maintain each component of the transformation separa...
Definition transform.hpp:27
float scale
Definition hub.cpp:25
probe_type
Enum class representing the type of reflection probe.
@ sphere
Sphere type reflection probe.
@ box
Box type reflection probe.
reflect_method
Enum class representing the reflection method.
@ environment
Environment reflection method.
@ static_only
Static-only reflection method.
auto operator!=(const reflection_probe &pr1, const reflection_probe &pr2) -> bool
Inequality operator for reflection_probe.
auto operator==(const reflection_probe &pr1, const reflection_probe &pr2) -> bool
Equality operator for reflection_probe.
Structure representing box projection data.
math::vec3 extents
Extents of the box projection.
float transition_distance
Transition distance for the box projection.
Structure representing sphere projection data.
float range
Range of the sphere projection.
Structure representing a reflection probe.
auto get_face_extents(uint32_t face, const math::transform &transform) const -> float
auto get_max_range() const -> float
probe_type type
Type of the reflection probe.
reflect_method method
Reflection method.
box box_data
Data describing box projection.
sphere sphere_data
Data describing sphere projection.