Unravel Engine C++ Reference
Loading...
Searching...
No Matches
reflection_probe.cpp
Go to the documentation of this file.
3
6
7namespace unravel
8{
10{
11 auto box_predicate_entt = entt::property_predicate<bool>(
12 [](const entt::meta_any& obj)
13 {
14 auto data = obj.try_cast<reflection_probe>();
15 return data->type == probe_type::box;
16 });
17 auto sphere_predicate_entt = entt::property_predicate<bool>(
18 [](const entt::meta_any& obj)
19 {
20 auto data = obj.try_cast<reflection_probe>();
21 return data->type == probe_type::sphere;
22 });
23 // EnTT meta registration mirroring RTTR
24 entt::meta_factory<probe_type>{}
25 .type("probe_type"_hs)
27 entt::attribute{"name", "probe_type"},
28 entt::attribute{"pretty_name", "Probe Type"},
29 })
30 .data<probe_type::box>("box"_hs)
32 entt::attribute{"name", "box"},
33 entt::attribute{"pretty_name", "Box"}
34 })
35 .data<probe_type::sphere>("sphere"_hs)
37 entt::attribute{"name", "sphere"},
38 entt::attribute{"pretty_name", "Sphere"}
39 });
40
41 entt::meta_factory<reflect_method>{}
42 .type("reflect_method"_hs)
44 entt::attribute{"name", "reflect_method"},
45 entt::attribute{"pretty_name", "Reflect Method"},
46 })
47 .data<reflect_method::environment>("environment"_hs)
49 entt::attribute{"name", "environment"},
50 entt::attribute{"pretty_name", "Environment"}
51 })
52 .data<reflect_method::static_only>("static_only"_hs)
54 entt::attribute{"name", "static_only"},
55 entt::attribute{"pretty_name", "Static Only"}
56 });
57
58 entt::meta_factory<probe_update_mode>{}
59 .type("probe_update_mode"_hs)
61 entt::attribute{"name", "probe_update_mode"},
62 entt::attribute{"pretty_name", "Update Mode"},
63 })
64 .data<probe_update_mode::on_demand>("on_demand"_hs)
66 entt::attribute{"name", "on_demand"},
67 entt::attribute{"pretty_name", "On Demand"}
68 })
69 .data<probe_update_mode::once>("once"_hs)
71 entt::attribute{"name", "once"},
72 entt::attribute{"pretty_name", "Once"}
73 })
74 .data<probe_update_mode::realtime>("realtime"_hs)
76 entt::attribute{"name", "realtime"},
77 entt::attribute{"pretty_name", "Realtime"}
78 });
79
80 entt::meta_factory<probe_resolution>{}
81 .type("probe_resolution"_hs)
83 entt::attribute{"name", "probe_resolution"},
84 entt::attribute{"pretty_name", "Resolution"},
85 })
86 .data<probe_resolution::res_16>("res_16"_hs)
88 entt::attribute{"name", "res_16"},
89 entt::attribute{"pretty_name", "16"},
90 })
91 .data<probe_resolution::res_32>("res_32"_hs)
93 entt::attribute{"name", "res_32"},
94 entt::attribute{"pretty_name", "32"},
95 })
96 .data<probe_resolution::res_64>("res_64"_hs)
98 entt::attribute{"name", "res_64"},
99 entt::attribute{"pretty_name", "64"},
100 })
101 .data<probe_resolution::res_128>("res_128"_hs)
103 entt::attribute{"name", "res_128"},
104 entt::attribute{"pretty_name", "128"},
105 })
106 .data<probe_resolution::res_256>("res_256"_hs)
108 entt::attribute{"name", "res_256"},
109 entt::attribute{"pretty_name", "256"},
110 })
111 .data<probe_resolution::res_512>("res_512"_hs)
113 entt::attribute{"name", "res_512"},
114 entt::attribute{"pretty_name", "512"},
115 });
116
117 entt::meta_factory<reflection_probe::box>{}
118 .type("box"_hs)
120 entt::attribute{"name", "box"},
121 entt::attribute{"pretty_name", "Box"},
122 })
123 .data<&reflection_probe::box::extents>("extents"_hs)
125 entt::attribute{"name", "extents"},
126 entt::attribute{"pretty_name", "Extents"}
127 })
128 .data<&reflection_probe::box::transition_distance>("transition_distance"_hs)
130 entt::attribute{"name", "transition_distance"},
131 entt::attribute{"pretty_name", "Transition Distance"},
132 entt::attribute{"min", 0.0f},
133 });
134
135 entt::meta_factory<reflection_probe::sphere>{}
136 .type("sphere"_hs)
138 entt::attribute{"name", "sphere"},
139 entt::attribute{"pretty_name", "Sphere"},
140 })
141 .data<&reflection_probe::sphere::range>("range"_hs)
143 entt::attribute{"name", "range"},
144 entt::attribute{"pretty_name", "Range"},
145 entt::attribute{"min", 0.0f},
146 });
147
148 entt::meta_factory<reflection_probe>{}
149 .type("reflection_probe"_hs)
151 entt::attribute{"name", "reflection_probe"},
152 entt::attribute{"pretty_name", "Reflection Probe"},
153 })
154 .data<&reflection_probe::type>("type"_hs)
156 entt::attribute{"name", "type"},
157 entt::attribute{"pretty_name", "Type"}
158 })
159 .data<&reflection_probe::method>("method"_hs)
161 entt::attribute{"name", "method"},
162 entt::attribute{"pretty_name", "Method"}
163 })
164 .data<&reflection_probe::intensity>("intensity"_hs)
166 entt::attribute{"name", "intensity"},
167 entt::attribute{"pretty_name", "Intensity"},
168 entt::attribute{"min", 0.1f},
169 entt::attribute{"max", 3.0f},
170 })
171 .data<&reflection_probe::box_data>("box_data"_hs)
173 entt::attribute{"name", "box_data"},
174 entt::attribute{"pretty_name", "Box"},
175 entt::attribute{"predicate", box_predicate_entt},
176 })
177 .data<&reflection_probe::sphere_data>("sphere_data"_hs)
179 entt::attribute{"name", "sphere_data"},
180 entt::attribute{"pretty_name", "Sphere"},
181 entt::attribute{"predicate", sphere_predicate_entt},
182 });
183}
184
186{
187 try_save(ar, ser20::make_nvp("type", obj.type));
188 try_save(ar, ser20::make_nvp("method", obj.method));
189 try_save(ar, ser20::make_nvp("intensity", obj.intensity));
190 if(obj.type == probe_type::box)
191 {
192 try_save(ar, ser20::make_nvp("extents", obj.box_data.extents));
193 try_save(ar, ser20::make_nvp("transition_distance", obj.box_data.transition_distance));
194 }
195 else
196 {
197 try_save(ar, ser20::make_nvp("range", obj.sphere_data.range));
198 }
199}
202
204{
205 try_load(ar, ser20::make_nvp("type", obj.type));
206 try_load(ar, ser20::make_nvp("method", obj.method));
207 try_load(ar, ser20::make_nvp("intensity", obj.intensity));
208 if(obj.type == probe_type::box)
209 {
210 try_load(ar, ser20::make_nvp("extents", obj.box_data.extents));
211 try_load(ar, ser20::make_nvp("transition_distance", obj.box_data.transition_distance));
212 }
213 else
214 {
215 try_load(ar, ser20::make_nvp("range", obj.sphere_data.range));
216 }
217}
220} // namespace unravel
auto property_predicate(property_predicate_t< T > predicate) -> property_predicate_t< T >
Definition reflection.h:89
attributes::value_type attribute
Definition reflection.h:19
std::map< std::string, meta_any > attributes
Definition reflection.h:18
BinaryInputArchive iarchive_binary_t
simd::JSONOutputArchive oarchive_associative_t
BinaryOutputArchive oarchive_binary_t
simd::JSONInputArchive iarchive_associative_t
@ sphere
Sphere type reflection probe.
@ box
Box type reflection probe.
#define REFLECT(cls)
Definition reflection.h:149
#define SAVE_INSTANTIATE(cls, Archive)
#define LOAD(cls)
auto try_save(Archive &ar, ser20::NameValuePair< T > &&t, const hpp::source_location &loc=hpp::source_location::current()) -> bool
#define LOAD_INSTANTIATE(cls, Archive)
#define SAVE(cls)
auto try_load(Archive &ar, ser20::NameValuePair< T > &&t, const hpp::source_location &loc=hpp::source_location::current()) -> bool
Structure representing a reflection probe.
probe_type type
Type of the reflection probe.