23#include "guillaume/systems/hand_motion.hpp"
55 this->getLogger().info()
56 <<
"HandMotion::update: event received: " << *handMotionEvent;
58 auto ray = handMotionEvent->getAim().toForwardRay();
62 auto &handHoverInteraction =
65 const bool isIntersecting =
68 ray, transform.getPose(), bound,
72 if (!handHoverInteraction.isHovered()) {
73 handHoverInteraction.setHovered(
true);
74 if (
const auto onHover =
75 handHoverInteraction.getOnHoverHandler()) {
82 if (handHoverInteraction.isHovered()) {
83 handHoverInteraction.setHovered(
false);
84 if (
const auto onUnhover =
85 handHoverInteraction.getOnUnhoverHandler()) {
std::size_t Identifier
The key under which an entity's components are stored. Systems and components refer to entities by th...
SystemFiller(Phase phase)
ecs::ComponentRegistry & getComponentRegistry(void)
Get the component registry of the scene being processed.
ComponentType & getComponent(const ecs::Entity::Identifier &entityIdentifier)
Get a component of an entity from the bound registry, to read or modify it.
Hands each engine event to the listeners subscribed to its type.
void consumeNextEvent(void)
EventManager(EventBus &eventBus)
std::shared_ptr< EventType > getLastEvent(void)
void prepare(void) override
Take the next pending hand motion event, once per frame.
void cleanup(void) override
Does nothing.
HandMotion(event::EventBus &eventBus)
Create the system, in the Event phase, and subscribe it to hand motion events.
virtual void update(const ecs::Entity::Identifier &entityIdentifier) override
Test the hand ray against one entity and update its hovered flag, calling the hover or unhover handle...
~HandMotion(void)
Destructor.
Free functions the input systems share to decide whether a pointer or hand ray hits an entity.
State. Every class here is plain data attached to an entity.
The entity-component-system core, independent of any widget.
Delivery of engine events to the systems that subscribed to them.
Rules. Every class here runs each frame on the entities that have the components it declares.
bool hitTest(const utility::graphic::RayF &ray, const utility::graphic::PoseF &pose, const components::Bound &bound, const utility::math::Vector2F &margin)
Whether a ray crosses the rectangle of an entity, grown by a margin.
utility::math::Vector2F hitMargin(const ecs::ComponentRegistry ®istry, const ecs::Entity::Identifier &entityIdentifier)
Extra hit area of an entity around its Bound, in dp.
bool isInteractive(const ecs::ComponentRegistry ®istry, const ecs::Entity::Identifier &entityIdentifier)
Whether an entity accepts input.