scene loader

Scene loading facilities.


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. Scene loading will wait for these auxiliary tasks to complete. These tasks are not scheduled on the threadpool to wait 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

class xml_loader_t : public wt::scene::loader::loader_t

Scene loader from an XML data source.

Public Functions

xml_loader_t(std::string name, const wt_context_t &ctx, std::istream &xml, const defaults_defines_t &defines = {}, std::optional<progress_callback_t> callbacks = {})
virtual ~xml_loader_t()
inline virtual std::string node_description(const node_t &node) const noexcept override

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::defaults_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::defaults_defines_t &defines = {}, std::optional<bootstrap_progress_callback_t> callbacks = {})
inline virtual ~scene_bootstrap_t()
scene_bootstrap_t(scene_bootstrap_t&&) = 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.