2#ifndef _TINYPBRT_SCENE_HPP_
3#define _TINYPBRT_SCENE_HPP_
44 struct scene_view : detail::wrapper<scene_view, tpbrt_scene_t> {
46 using wrapper::wrapper;
55 [[nodiscard]]
constexpr tpbrt::film film() const noexcept {
return _native->film; }
73 [[nodiscard]]
constexpr float_t end_time() const noexcept {
return _native->end_time; }
100 [[nodiscard]]
constexpr auto reflect() const noexcept {
116 void operator()(
tpbrt_scene_t*
const c_scene)
const noexcept {
123 std::unique_ptr<tpbrt_scene_t, deleter> _owned;
126 explicit scene(std::unique_ptr<tpbrt_scene_t, deleter> owned) noexcept :
scene_view(*owned), _owned(std::move(owned)) {}
129 template<
class Loader>
130 [[nodiscard]]
static result<scene> _load(
const Loader& loader) {
131 auto owned = std::unique_ptr<tpbrt_scene_t, deleter>(
new tpbrt_scene_t {});
133 if (
const auto err =
static_cast<error>(loader(owned.get())); err !=
error::NONE) {
134 delete owned.release();
137 return scene(std::move(owned));
184 const std::string& working_directory =
".") {
210 const std::string& working_directory =
".") {
222 const std::string& working_directory =
".") {
Scene loaded from a pbrt-v4 file or string, owning all its memory (move only, freed in the destructor...
Definition scene.hpp:112
scene & operator=(scene &&other) noexcept=default
Moves scene (the scene held before is freed).
scene(scene &&other) noexcept=default
Moves scene (views created from other stay valid, they point to the same heap memory).
~scene()=default
Frees the scene.
scene & operator=(const scene &)=delete
Scene owns C memory, so it cannot be copied.
static result< scene > load_from_file(const std::string &filepath)
Loads scene from given file.
Definition scene.hpp:161
static result< scene > load_from_memory(const char_t *const data, const std::string &working_directory=".")
Loads scene from memory (provided null-terminated string).
Definition scene.hpp:183
scene(const scene &)=delete
Scene owns C memory, so it cannot be copied.
static result< scene > load_from_memory(const std::string &data, const std::string &working_directory=".")
Loads scene from memory (provided string).
Definition scene.hpp:171
tpbrt_char_t char_t
Char type.
Definition fwd.hpp:29
error
Error type (used as result type where success = TPBRT_ERROR_NONE = 0).
Definition error.hpp:25
@ INVALID_POINTER
Provided NULL where it is not allowed.
@ NONE
No error -> Success.
tpbrt_float_t float_t
Float type.
Definition fwd.hpp:97
result< scene > load_scene_from_memory(const std::string &data, const std::string &working_directory=".")
Loads scene from memory (provided string).
Definition scene.hpp:209
result< scene > load_scene_from_file(const std::string &filepath)
Loads scene from given file.
Definition scene.hpp:198
tpbrt_error_t tpbrt_scene_load_from_memory(const tpbrt_char_t *data, const tpbrt_char_t *working_directory, tpbrt_scene_t *out_scene)
Loads scene from memory (provided string).
void tpbrt_scene_free(tpbrt_scene_t *scene)
Free all scene resources.
tpbrt_error_t tpbrt_scene_load_from_file(const tpbrt_char_t *filepath, tpbrt_scene_t *out_scene)
Loads scene from given file.
Definition accelerator.hpp:14
C++ wrapper for tpbrt_accelerator_t.
Definition accelerator.hpp:138
C++ wrapper for tpbrt_camera_t.
Definition camera.hpp:313
C++ wrapper for tpbrt_film_t.
Definition film.hpp:170
C++ wrapper for tpbrt_filter_t.
Definition filter.hpp:108
C++ wrapper for tpbrt_integrator_t.
Definition integrator.hpp:336
C++ wrapper for tpbrt_lights_list_t.
Definition light.hpp:460
C++ wrapper for tpbrt_materials_list_t.
Definition material.hpp:907
C++ wrapper for tpbrt_objects_instances_list_t.
Definition object_instance.hpp:40
C++ wrapper for tpbrt_objects_list_t.
Definition object.hpp:65
C++ wrapper for tpbrt_options_t.
Definition options.hpp:22
Result of an operation: either a value or an error code (similar to C++23 std::expected).
Definition error.hpp:165
C++ wrapper for tpbrt_sampler_t.
Definition sampler.hpp:215
C++ wrapper for tpbrt_scene_t (a non owning view, e.g.
Definition scene.hpp:44
constexpr tpbrt::options options() const noexcept
Returns options value.
Definition scene.hpp:49
constexpr tpbrt::lights_list lights() const noexcept
Returns lights value.
Definition scene.hpp:85
constexpr tpbrt::film film() const noexcept
Returns film value.
Definition scene.hpp:55
constexpr float_t end_time() const noexcept
Returns end_time value.
Definition scene.hpp:73
constexpr tpbrt::materials_list materials() const noexcept
Returns materials value.
Definition scene.hpp:79
constexpr tpbrt::transforms_list transforms() const noexcept
Returns transforms value.
Definition scene.hpp:97
constexpr tpbrt::medias_list medias() const noexcept
Returns medias value.
Definition scene.hpp:82
constexpr tpbrt::objects_instances_list instances() const noexcept
Returns instances value.
Definition scene.hpp:94
constexpr tpbrt::sampler sampler() const noexcept
Returns sampler value.
Definition scene.hpp:64
constexpr tpbrt::camera camera() const noexcept
Returns camera value.
Definition scene.hpp:52
constexpr auto reflect() const noexcept
Conversion to tuple.
Definition scene.hpp:100
constexpr float_t start_time() const noexcept
Returns start_time value.
Definition scene.hpp:67
constexpr tpbrt::filter filter() const noexcept
Returns filter value.
Definition scene.hpp:70
constexpr tpbrt::integrator integrator() const noexcept
Returns integrator value.
Definition scene.hpp:58
constexpr tpbrt::accelerator accelerator() const noexcept
Returns accelerator value.
Definition scene.hpp:61
constexpr tpbrt::shapes_list shapes() const noexcept
Returns shapes value.
Definition scene.hpp:88
constexpr tpbrt::objects_list objects() const noexcept
Returns objects value.
Definition scene.hpp:91
constexpr tpbrt::textures_list textures() const noexcept
Returns textures value.
Definition scene.hpp:76
C++ wrapper for tpbrt_shapes_list_t.
Definition shape.hpp:511
C++ wrapper for tpbrt_textures_list_t.
Definition texture.hpp:933
PBRT scene representation.
Definition scene.h:38