@@ -15,9 +15,8 @@ namespace nbl::ext::MitsubaLoader
1515class CElementIntegrator final : public IElement
1616{
1717 public:
18- enum Type
18+ enum Type : uint8_t
1919 {
20- INVALID,
2120 AO,
2221 DIRECT,
2322 PATH,
@@ -35,8 +34,33 @@ class CElementIntegrator final : public IElement
3534 VPL,
3635 IRR_CACHE,
3736 MULTI_CHANNEL,
38- FIELD_EXTRACT
37+ FIELD_EXTRACT,
38+ INVALID
3939 };
40+ static inline core::unordered_map<core::string,Type,core::CaseInsensitiveHash,core::CaseInsensitiveEquals> compStringToTypeMap ()
41+ {
42+ return {
43+ {" ao" , Type::AO},
44+ {" direct" , Type::DIRECT},
45+ {" path" , Type::PATH},
46+ {" volpath_simple" , Type::VOL_PATH_SIMPLE},
47+ {" volpath" , Type::VOL_PATH},
48+ {" bdpt" , Type::BDPT},
49+ {" photonmapper" , Type::PHOTONMAPPER},
50+ {" ppm" , Type::PPM},
51+ {" sppm" , Type::SPPM},
52+ {" pssmlt" , Type::PSSMLT},
53+ {" mlt" , Type::MLT},
54+ {" erpt" , Type::ERPT},
55+ {" ptracer" , Type::ADJ_P_TRACER},
56+ {" adaptive" , Type::ADAPTIVE},
57+ {" vpl" , Type::VPL},
58+ {" irrcache" , Type::IRR_CACHE},
59+ {" multichannel" , Type::MULTI_CHANNEL},
60+ {" field" , Type::FIELD_EXTRACT}
61+ };
62+ }
63+
4064 struct AmbientOcclusion
4165 {
4266 int32_t shadingSamples = 1 ;
@@ -49,8 +73,8 @@ class CElementIntegrator final : public IElement
4973 };
5074 struct DirectIllumination : EmitterHideableBase
5175 {
52- int32_t emitterSamples = 0xdeadbeefu ;
53- int32_t bsdfSamples = 0xdeadbeefu ;
76+ int32_t emitterSamples = static_cast < int32_t >( 0xdeadbeefu ) ;
77+ int32_t bsdfSamples = static_cast < int32_t >( 0xdeadbeefu ) ;
5478 bool strictNormals = false ;
5579 };
5680 struct MonteCarloTracingBase
@@ -161,7 +185,7 @@ class CElementIntegrator final : public IElement
161185 }
162186
163187 Type field;
164- SPropertyElementData undefined;
188+ SPropertyElementData undefined; // TODO: test destructor runs
165189 };
166190 struct MetaIntegrator
167191 {
@@ -198,74 +222,89 @@ class CElementIntegrator final : public IElement
198222 {
199223 }
200224
201- inline CElementIntegrator& operator =(const CElementIntegrator& other)
225+ template <typename Visitor>
226+ inline void visit (Visitor&& visitor)
202227 {
203- IElement::operator =(other);
204- type = other.type ;
205228 switch (type)
206229 {
207230 case CElementIntegrator::Type::AO:
208- ao = other. ao ;
231+ visitor (ao) ;
209232 break ;
210233 case CElementIntegrator::Type::DIRECT:
211- direct = other. direct ;
234+ visitor ( direct) ;
212235 break ;
213236 case CElementIntegrator::Type::PATH:
214- path = other. path ;
237+ visitor ( path) ;
215238 break ;
216239 case CElementIntegrator::Type::VOL_PATH_SIMPLE:
217- volpath_simple = other. volpath_simple ;
240+ visitor ( volpath_simple) ;
218241 break ;
219242 case CElementIntegrator::Type::VOL_PATH:
220- volpath = other. volpath ;
243+ visitor ( volpath) ;
221244 break ;
222245 case CElementIntegrator::Type::BDPT:
223- bdpt = other. bdpt ;
246+ visitor ( bdpt) ;
224247 break ;
225248 case CElementIntegrator::Type::PHOTONMAPPER:
226- photonmapper = other. photonmapper ;
249+ visitor ( photonmapper) ;
227250 break ;
228251 case CElementIntegrator::Type::PPM:
229- ppm = other. ppm ;
252+ visitor ( ppm) ;
230253 break ;
231254 case CElementIntegrator::Type::SPPM:
232- sppm = other. sppm ;
255+ visitor ( sppm) ;
233256 break ;
234257 case CElementIntegrator::Type::PSSMLT:
235- pssmlt = other. pssmlt ;
258+ visitor ( pssmlt) ;
236259 break ;
237260 case CElementIntegrator::Type::MLT:
238- mlt = other. mlt ;
261+ visitor ( mlt) ;
239262 break ;
240263 case CElementIntegrator::Type::ERPT:
241- erpt = other. erpt ;
264+ visitor ( erpt) ;
242265 break ;
243266 case CElementIntegrator::Type::ADJ_P_TRACER:
244- ptracer = other. ptracer ;
267+ visitor ( ptracer) ;
245268 break ;
246269 case CElementIntegrator::Type::ADAPTIVE:
247- adaptive = other. adaptive ;
270+ visitor ( adaptive) ;
248271 break ;
249272 case CElementIntegrator::Type::VPL:
250- vpl = other. vpl ;
273+ visitor ( vpl) ;
251274 break ;
252275 case CElementIntegrator::Type::IRR_CACHE:
253- irrcache = other. irrcache ;
276+ visitor ( irrcache) ;
254277 break ;
255278 case CElementIntegrator::Type::MULTI_CHANNEL:
256- multichannel = other. multichannel ;
279+ visitor ( multichannel) ;
257280 break ;
258281 case CElementIntegrator::Type::FIELD_EXTRACT:
259- field = other. field ;
282+ visitor ( field) ;
260283 break ;
261284 default :
262285 break ;
263286 }
287+ }
288+ template <typename Visitor>
289+ inline void visit (Visitor&& visitor) const
290+ {
291+ const_cast <CElementIntegrator*>(this )->visit ([&]<typename T>(T& var)->void
292+ {
293+ visitor (const_cast <const T&>(var));
294+ }
295+ );
296+ }
297+
298+ inline CElementIntegrator& operator =(const CElementIntegrator& other)
299+ {
300+ IElement::operator =(other);
301+ type = other.type ;
302+ IElement::copyVariant (this ,&other);
264303 return *this ;
265304 }
266305
267306 bool addProperty (SNamedPropertyElement&& _property, system::logger_opt_ptr logger) override ;
268- bool onEndTag (asset::IAssetLoader::IAssetLoaderOverride* _override, CMitsubaMetadata* globalMetadata ) override ;
307+ bool onEndTag (CMitsubaMetadata* globalMetadata, system::logger_opt_ptr logger ) override ;
269308 inline IElement::Type getType () const override { return IElement::Type::INTEGRATOR; }
270309 inline std::string getLogName () const override { return " integrator" ; }
271310
0 commit comments