11 constexpr float k_epsilon = 1.0e-6F;
13 float uniform_scale(
const glm::vec3& from,
const glm::vec3& to,
bool largest)
15 const std::array<std::pair<float, float>, 3> axes { {
23 for (
const auto& [source, target] : axes) {
24 if (source <= k_epsilon) {
27 const float ratio = target /
source;
35 const Kinesis::AABB3D& source,
36 const Kinesis::AABB3D& target,
41 const glm::vec3 from =
source.extent();
42 const glm::vec3 to = target.extent();
45 case FitMode::CONTAIN:
51 case FitMode::STRETCH:
53 case FitMode::TILE_MIRRORED:
62 std::shared_ptr<Buffers::VKBuffer> buf,
67 , m_look { .buf =
std::move(buf), .transform =
std::make_shared<glm::mat4>(1.0F) }
72 "Mantle needs a buffer");
78 "Mantle fits tiling modes as STRETCH: tiling has no meaning for geometry");
84 "Mantle leaves the buffer where it is: no geometry could be read from it");
113 "Mantle::refit kept the previous geometry: no geometry could be read from the buffer");
#define MF_ERROR(comp, ctx,...)
#define MF_WARN(comp, ctx,...)
Expanse::CrossingFn on_enter
Expanse::CrossingFn on_exit
std::function< void(uint32_t)> CrossingFn
const std::optional< Kinesis::AABB3D > & bounds() const
The box, if set.
virtual void set_bounds(const Kinesis::AABB3D &bounds)
Set or replace the box.
A defined region of space with a containment test and crossing actions.
void refit()
Read the buffer's geometry again and place it to match.
std::optional< Kinesis::AABB3D > m_local
Portal::Graphics::FitMode m_fit
void begin_evaluate() override
Called at the start of every evaluate(), before any position is tested.
void set_bounds(const Kinesis::AABB3D &bounds) override
Set or replace the box and place the buffer to match.
Mantle(const Kinesis::AABB3D &bounds, std::shared_ptr< Buffers::VKBuffer > buf, Portal::Graphics::FitMode fit=Portal::Graphics::FitMode::STRETCH, CrossingFn on_enter={}, CrossingFn on_exit={})
Build from a box and a buffer.
@ Init
Engine/subsystem initialization.
@ Runtime
General runtime operations (default fallback)
@ Nexus
Spatial indexing and scheduling for user-defined behaviour.
std::vector< ResolvedSequence > resolve(const VisionQuery &query)
Resolve a VisionQuery into the ResolvedSequences needed to satisfy every active intent.
glm::mat4 box_transform(const AABB3D &source, const AABB3D &target)
Transform that scales and translates one box onto another.
Tendency< D, float > scale(const Tendency< D, float > &t, float factor)
Uniform scaling of a scalar-output tendency.
void place_attachment(Attachment &attachment)
Place every render processor of the buffer that is not placed yet.
void release_attachment(Attachment &attachment)
Give every placed render processor back the geometry transform it had.
std::optional< Kinesis::AABB3D > read_bounds(const std::shared_ptr< Buffers::VKBuffer > &buf, const std::optional< uint32_t > &collection)
Bounds of a buffer's geometry in its own stored coordinates.
FitMode
How a source extent is mapped onto a destination extent.
@ TILE_MIRRORED
Source repeated, every other tile mirrored.
@ TILE
Source repeated at its own size.
static AABB3D from_center(const glm::vec3 &c, const glm::vec3 &half) noexcept
Construct from a center point and half-extents.
Axis-aligned bounding box in 3D world space.
std::shared_ptr< Buffers::VKBuffer > buf
std::shared_ptr< glm::mat4 > transform