29 #include <engine/config.hpp>
39 [&](
entity::id entity_id,
auto& steering,
auto& transform,
auto& locomotion,
const auto& body_component)
41 auto& agent = steering.agent;
42 auto& body = *body_component.body;
45 agent.position = transform.local.translation;
46 agent.orientation = transform.local.rotation;
47 agent.velocity = body.get_linear_velocity();
51 if (steering.wander_weight)
54 force +=
ai::steering::behavior::wander_3d(agent, steering.wander_noise * dt, steering.wander_distance, steering.wander_radius, steering.wander_angle, steering.wander_angle2) * steering.wander_weight;
56 if (steering.seek_weight)
62 if (steering.sum_weights)
64 force /= steering.sum_weights;
73 component.force = force;
82 agent.forward = agent.orientation * config::global_forward;
83 agent.up = agent.orientation * config::global_up;
90 [&agent](
auto& component)
92 component.local.rotation = agent.orientation;
steering_system(entity::registry ®istry)
virtual void update(float t, float dt)
Perform's a system's update() function.
Abstract base class for updatable systems.
entity::registry & registry
Registry on which the system operate.
math::fvec3 wander_3d(const agent &agent, float noise, float distance, float radius, float &theta, float &phi)
Steers an agent in a continuously shifting random direction.
math::fvec3 seek(const agent &agent, const math::fvec3 &target)
Attempts to steer an agent so that it moves toward a target.
entt::registry registry
Component registry type.
entt::entity id
Entity ID type.
quaternion< T > look_rotation(const vec3< T > &forward, vec3< T > up)
Creates a unit quaternion rotation using forward and up vectors.
constexpr T sqr_length(const quaternion< T > &q) noexcept
Calculates the square length of a quaternion.
vector< T, N > sqrt(const vector< T, N > &x)
Takes the square root of each element.
Winged aerial locomotion.