tinypbrt 1.1.1
pbrt-v4 scene file parser for C11 with a header-only C++20 wrapper
Loading...
Searching...
No Matches
transform.hpp
Go to the documentation of this file.
1#pragma once
2#ifndef _TINYPBRT_TRANSFORM_HPP_
3#define _TINYPBRT_TRANSFORM_HPP_
4
6
8
9#include <tuple>
10
13
14namespace tpbrt {
24 struct transform_handle : detail::wrapper<transform_handle, tpbrt_transform_handle_t> {
26 using wrapper::wrapper;
27
29 [[nodiscard]] constexpr transform_idx_t transform_idx() const noexcept { return _native->transform_idx; }
30
32 [[nodiscard]] constexpr auto reflect() const noexcept { return std::make_tuple(transform_idx()); }
33 };
34
39 struct transform_animated : detail::wrapper<transform_animated, tpbrt_transform_animated_t> {
41 using wrapper::wrapper;
42
44 [[nodiscard]] constexpr transform_handle start_transform() const noexcept { return _native->start_transform; }
45
47 [[nodiscard]] constexpr transform_handle end_transform() const noexcept { return _native->end_transform; }
48
50 [[nodiscard]] constexpr auto reflect() const noexcept { return std::make_tuple(start_transform(), end_transform()); }
51 };
52
59 struct transforms_list : array<tpbrt_transforms_list_t, mat4, &tpbrt_transforms_list_t::transforms> {
61 using array::array;
62
64 using array::at;
65
67 using array::operator[];
68
70 [[nodiscard]] result<element_type> at(const transform_handle handle) const noexcept {
71 return detail::find_in<element_type, tpbrt_mat4_t>(tpbrt_get_transform, _native, handle.native());
72 }
73
75 [[nodiscard]] result<element_type> operator[](const transform_handle handle) const noexcept { return at(handle); }
76 };
77
85 [[nodiscard]] inline result<mat4> get_transform(const transforms_list list, const transform_handle handle) noexcept {
86 return list.at(handle);
87 }
88} // namespace tpbrt
89#endif // _TINYPBRT_TRANSFORM_HPP_
tpbrt_transform_idx_t transform_idx_t
Transform index.
Definition fwd.hpp:235
result< mat4 > get_transform(const transforms_list list, const transform_handle handle) noexcept
Returns transform to which handle is provided.
Definition transform.hpp:85
tpbrt_error_t tpbrt_get_transform(const tpbrt_transforms_list_t *transforms, tpbrt_transform_handle_t handle, const tpbrt_mat4_t **transform)
Returns pointer to transform to which handle is provided.
Definition accelerator.hpp:14
Generic C++ array view with type conversion (a non owning view on memory owned by the C library).
Definition common.hpp:448
constexpr result< element_type > at(const size_t index) const noexcept
Returns element on given index or error::INDEX_OUT_OF_RANGE.
Definition common.hpp:519
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_transform_animated_t.
Definition transform.hpp:39
constexpr transform_handle start_transform() const noexcept
Returns start_transform value.
Definition transform.hpp:44
constexpr auto reflect() const noexcept
Conversion to tuple.
Definition transform.hpp:50
constexpr transform_handle end_transform() const noexcept
Returns end_transform value.
Definition transform.hpp:47
C++ wrapper for tpbrt_transform_handle_t.
Definition transform.hpp:24
constexpr transform_idx_t transform_idx() const noexcept
Returns transform_idx value.
Definition transform.hpp:29
constexpr auto reflect() const noexcept
Conversion to tuple.
Definition transform.hpp:32
C++ wrapper for tpbrt_transforms_list_t.
Definition transform.hpp:59
result< element_type > operator[](const transform_handle handle) const noexcept
Returns transform pointed by given handle.
Definition transform.hpp:75
result< element_type > at(const transform_handle handle) const noexcept
Returns transform pointed by given handle.
Definition transform.hpp:70