Scene data source

Scene data structure takes a form similar to mitsuba. A scene file describes the scene geometry, materials, and media. It also specifies emitters and sensor configuration, as well as the integrator that should be used to compute the light transport in the scene.

Currently, only an XML data source is supported, though it is easy to implement additional data sources if needed. Backward compatibility is not maintained for scene files; scene files need to be manually ported to new versions of wave_tracer.


class loader_t

Handles queueing and synchronizing the loading of scene element. Generic class: overloads are expected to provide the data source.

Subclassed by wt::scene::loader::xml::xml_loader_t

Public Types

using shared_element_ptr_t = std::shared_ptr<scene::scene_element_t>
using shared_scene_element_task_t = std::shared_future<shared_element_ptr_t>

Public Functions

loader_t(std::string name, const wt_context_t &ctx, std::optional<progress_callback_t> callbacks = {})
inline virtual ~loader_t()
void wait_shapes() const

Block and wait for loading of all shapes to complete.

std::vector<std::shared_ptr<shape_t>> &get_shapes()

Block and retrieve list of all shapes.

inline const auto &get_name() const noexcept
inline bool has_errors() const noexcept

Returns TRUE if errors occurred during loading.

std::unique_ptr<scene_t> get()

Blocks and wait for loader to complete, then constructs the scene. Only thread safe with sensors’, sampler’s and shapes’ waiters and getter. NOT thread safe with wait().

void wait() const

Blocks and wait for loader to complete. Only thread safe with sensors’, sampler’s and shapes’ waiters and getter. NOT thread safe with get().

inline std::optional<const node_t*> get_node_with_id(const std::string &id) const noexcept

Get the node with specified id. Nested nodes are ignored.

template<std::derived_from<scene::scene_element_t> T>
inline std::shared_ptr<T> get_scene_element(const std::string &id)
template<std::invocable F>
inline void enqueue_loading_task(const scene_element_t *resource, const std::string&, F &&func)

Enqueues an arbitrary auxiliary task as part of scene loading. This is intended for heavy tasks, like loading large resources from disk. Scene loading will wait for these auxiliary tasks to complete. These tasks are not scheduled on the threadpool to avoid deadlocks on waits.

inline void register_resource_dependency(const scene_element_t *resource, const scene_element_t *dependency)

Notifies the loader that resource depends on dependency. When complete_loading_tasks_for_resource() is called on resource, it will also block and wait for any tasks queued by dependency.

inline void complete_loading_tasks_for_resource(const scene_element_t *resource)

Waits and completes all auxiliary deferred loading tasks for a particular resource are done. Blocking operation.

virtual std::string node_description(const node_t &node) const noexcept = 0

template<std::derived_from<loader::loader_t> SceneLoader, std::derived_from<ads::construction::ads_constructor_t> ADSCtor>
class scene_bootstrap_t : public wt::scene::scene_bootstrap_generic_t

Helper that constructs a scene and its accelerating data structure (ADS).

Template Parameters:
  • SceneLoader – scene loader type.

  • ADSCtor – ADS constructor type.

Public Functions

inline scene_bootstrap_t(std::string name, std::istream &scene_source, const wt::wt_context_t &ctx, const loader::user_defines_t &defines = {}, std::optional<bootstrap_progress_callback_t> callbacks = {})
inline scene_bootstrap_t(std::string name, const std::filesystem::path &scene_path, const wt::wt_context_t &ctx, const loader::user_defines_t &defines = {}, std::optional<bootstrap_progress_callback_t> callbacks = {})
inline virtual ~scene_bootstrap_t()
scene_bootstrap_t(scene_bootstrap_t&&) noexcept = default
inline virtual std::unique_ptr<scene_t> get_scene() && override

Blocks and waits for scene loading to complete, and returns the constructed scene object.

inline virtual std::unique_ptr<ads::ads_t> get_ads() && override

Blocks and waits for ADS construction to complete, and returns the constructed ADS object.

inline virtual const loader::loader_t *get_scene_loader() const noexcept override

Returns the scene loader object.

inline virtual void wait() const override

Blocks and waits for scene loading and ADS construction to complete.