44 [&](
entity::id transform_eid,
auto& transform,
auto& stack)
47 transform.world = transform.local;
53 while (
registry.valid(constraint_eid))
64 handle_constraint(transform, constraint_eid, dt);
67 constraint_eid = node->
next;
81 if (!transform || !stack)
85 transform->world = transform->local;
91 while (
registry.valid(constraint_eid))
102 handle_constraint(*transform, constraint_eid, 0.0f);
105 constraint_eid = node->
next;
113 [](
const auto& lhs,
const auto& rhs)
123 handle_copy_translation_constraint(transform, *constraint);
125 handle_copy_rotation_constraint(transform, *constraint);
127 handle_copy_scale_constraint(transform, *constraint);
129 handle_copy_transform_constraint(transform, *constraint);
131 handle_track_to_constraint(transform, *constraint);
133 handle_three_dof_constraint(transform, *constraint);
135 handle_pivot_constraint(transform, *constraint);
137 handle_child_of_constraint(transform, *constraint);
139 handle_spring_to_constraint(transform, *constraint, dt);
141 handle_spring_translation_constraint(transform, *constraint, dt);
143 handle_spring_rotation_constraint(transform, *constraint, dt);
145 handle_ease_to_constraint(transform, *constraint, dt);
153 if (target_transform)
165 if (target_transform)
177 if (target_transform)
179 const auto& target_scale = target_transform->
world.
scale;
196 if (target_transform)
208 if (target_transform)
239 if (target_transform)
243 const float a = constraint.
t / constraint.
duration;
261 if (target_transform)
275 constraint.
spring.solve(dt);
291 if (target_transform)
325 constraint.
spring.solve(dt);
344 if (target_transform)
constraint_system(entity::registry ®istry)
virtual void update(float t, float dt)
Perform's a system's update() function.
void evaluate(entity::id entity_id)
Manually evaluates an entity's constraints.
Abstract base class for updatable systems.
entity::registry & registry
Registry on which the system operate.
entt::registry registry
Component registry type.
entt::entity id
Entity ID type.
quaternion< T > normalize(const quaternion< T > &q)
Normalizes a quaternion.
quaternion< T > angle_axis(T angle, const vec3< T > &axis)
Creates a rotation from an angle and axis.
quaternion< T > look_rotation(const vec3< T > &forward, vec3< T > up)
Creates a unit quaternion rotation using forward and up vectors.
constexpr matrix< T, N, M > sub(const matrix< T, N, M > &a, const matrix< T, N, M > &b) noexcept
Subtracts a matrix from another matrix.
Makes the entity a child of the target entity.
entity::id target
Target entity ID.
Causes an ordered stack of constraints to be applied to an entity.
entity::id head
ID of the entity containing the first constraint stack node.
int priority
Priority number, with lower priorities evaluated first.
Single node in a constraint stack.
bool active
Enables or disables the constraint.
entity::id next
ID of the entity containing the next constraint in the constraint stack.
Copies the rotation of a target entity.
entity::id target
Target entity ID.
Copies the scale of a target entity.
entity::id target
Target entity ID.
Copies the translation of a target entity.
bool copy_z
Copy Z translation.
bool invert_z
Invert the copied Z translation.
bool copy_x
Copy X translation.
bool copy_y
Copy Y translation.
bool invert_x
Invert the copied X translation.
bool offset
Add the copied translation.
entity::id target
Target entity ID.
bool invert_y
Invert the copied Y translation.
Eases toward a target entity.
entity::id target
Target entity ID.
math::fvec3 start
Start position.
float duration
Total duration of the ease.
float t
Elapsed time since ease began.
math::fvec3(* function)(const math::fvec3 &, const math::fvec3 &, float)
Pointer to the interpolation function.
Quaternion composed of a real scalar part and imaginary vector part.
constexpr element_type & x() noexcept
Returns a reference to the first element.
constexpr element_type & y() noexcept
Returns a reference to the second element.
constexpr element_type & z() noexcept
Returns a reference to the third element.
Pivots around a target entity.
entity::id target
Target entity ID.
math::fvec3 offset
Pivot point offset.
physics::numeric_spring< math::fvec3, float > spring
Yaw, pitch, and roll angle spring.
Springs to a target entity.
physics::numeric_spring< math::fvec4, float > rotation
Rotation spring.
physics::numeric_spring< math::fvec3, float > translation
Translation spring.
bool spring_rotation
Spring rotation.
bool spring_translation
Spring translation.
entity::id target
Target entity ID.
physics::numeric_spring< math::fvec3, float > spring
Translation spring.
Builds rotation from 3DoF angles.
float yaw
Yaw rotation angle, in radians.
float pitch
Pitch rotation angle, in radians.
float roll
Roll rotation angle, in radians.
Rotates a transform to face a target.
math::fvec3 up
Up direction vector.
entity::id target
Target entity ID.