MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Mantle.hpp
Go to the documentation of this file.
1#pragma once
2
5
7
8namespace MayaFlux::Nexus {
9
10class StateEncoder;
11
12/**
13 * @class Mantle
14 * @brief An Expanse that is a box with a buffer that already exists as its visible body.
15 *
16 * The box is the authority. The buffer's geometry is read once, when the Mantle
17 * is built and on refit(), and the buffer is placed so that geometry fills the
18 * box according to the fit mode. The placement is a geometry transform source on
19 * every render processor the buffer has, so it follows set_bounds, and with it
20 * bind_bounds, without being pushed. It is the reverse of Hull, where the buffer
21 * is the authority and the region follows it.
22 *
23 * The fit modes are Portal::Graphics::FitMode read for a box. STRETCH scales each
24 * axis independently. CONTAIN scales uniformly until the geometry fits inside
25 * the box, COVER until it covers the box, and CENTER does not scale. Tiling has
26 * no meaning for geometry and is treated as STRETCH.
27 *
28 * The buffer is neither registered nor written to. Releasing the Mantle gives
29 * each processor back the transform it had. Two placements on one buffer stack,
30 * as two attachments do. Only the box is encoded, so a decoded Mantle is a plain
31 * boxed Expanse and the look must be made again.
32 */
33class MAYAFLUX_API Mantle : public Expanse {
34public:
35 /**
36 * @brief Build from a box and a buffer. Blocks for a ComputeMeshBuffer.
37 * @param bounds World-space box.
38 * @param buf Buffer to place. Must not be null.
39 * @param fit How the buffer's geometry fills the box.
40 * @param on_enter Fired with the entity id when it enters. May be empty.
41 * @param on_exit Fired with the entity id when it leaves. May be empty.
42 */
43 Mantle(const Kinesis::AABB3D& bounds,
44 std::shared_ptr<Buffers::VKBuffer> buf,
45 Portal::Graphics::FitMode fit = Portal::Graphics::FitMode::STRETCH,
47 CrossingFn on_exit = {});
48
49 ~Mantle() override;
50
51 Mantle(const Mantle&) = delete;
52 Mantle& operator=(const Mantle&) = delete;
53 Mantle(Mantle&&) = delete;
54 Mantle& operator=(Mantle&&) = delete;
55
56 /** @brief Set or replace the box and place the buffer to match. */
57 void set_bounds(const Kinesis::AABB3D& bounds) override;
58
59 /**
60 * @brief Read the buffer's geometry again and place it to match.
61 *
62 * For a deforming mesh. Blocks for a ComputeMeshBuffer, so call it off the
63 * graphics thread. The previous geometry is kept if nothing can be read.
64 */
65 void refit();
66
67protected:
68 void begin_evaluate() override;
69
70private:
71 friend class StateEncoder;
72
73 void refresh();
74
77 std::optional<Kinesis::AABB3D> m_local;
78};
79
80} // namespace MayaFlux::Nexus
Expanse::CrossingFn on_enter
Definition Decoder.cpp:518
Expanse::CrossingFn on_exit
Definition Decoder.cpp:519
std::function< void(uint32_t)> CrossingFn
Definition Expanse.hpp:58
A defined region of space with a containment test and crossing actions.
Definition Expanse.hpp:55
std::optional< Kinesis::AABB3D > m_local
Definition Mantle.hpp:77
Mantle(const Mantle &)=delete
Mantle(Mantle &&)=delete
Mantle & operator=(Mantle &&)=delete
Mantle & operator=(const Mantle &)=delete
Portal::Graphics::FitMode m_fit
Definition Mantle.hpp:76
An Expanse that is a box with a buffer that already exists as its visible body.
Definition Mantle.hpp:33
Serializes Fabric state to an EXR texture and JSON schema.
Definition Encoder.hpp:25
FitMode
How a source extent is mapped onto a destination extent.
Axis-aligned bounding box in 3D world space.
Definition Bounds.hpp:188
State of one Agent attached to an existing buffer.