Antkeeper  0.0.1
constraint-system.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Christopher J. Howard
3  *
4  * This file is part of Antkeeper source code.
5  *
6  * Antkeeper source code is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Antkeeper source code is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef ANTKEEPER_GAME_CONSTRAINT_SYSTEM_HPP
21 #define ANTKEEPER_GAME_CONSTRAINT_SYSTEM_HPP
22 
37 #include <engine/entity/id.hpp>
38 
39 
44  public updatable_system
45 {
46 public:
49 
50  virtual void update(float t, float dt);
51 
57  void evaluate(entity::id entity_id);
58 
59 private:
60  void on_constraint_stack_update(entity::registry& registry, entity::id constraint_stack_eid);
61 
62  void handle_constraint(transform_component& transform, entity::id constraint_eid, float dt);
63  void handle_child_of_constraint(transform_component& transform, const child_of_constraint& constraint);
64  void handle_copy_rotation_constraint(transform_component& transform, const copy_rotation_constraint& constraint);
65  void handle_copy_scale_constraint(transform_component& transform, const copy_scale_constraint& constraint);
66  void handle_copy_transform_constraint(transform_component& transform, const copy_transform_constraint& constraint);
67  void handle_copy_translation_constraint(transform_component& transform, const copy_translation_constraint& constraint);
68  void handle_ease_to_constraint(transform_component& transform, ease_to_constraint& constraint, float dt);
69  void handle_pivot_constraint(transform_component& transform, const pivot_constraint& constraint);
70  void handle_spring_rotation_constraint(transform_component& transform, spring_rotation_constraint& constraint, float dt);
71  void handle_spring_to_constraint(transform_component& transform, spring_to_constraint& constraint, float dt);
72  void handle_spring_translation_constraint(transform_component& transform, spring_translation_constraint& constraint, float dt);
73  void handle_three_dof_constraint(transform_component& transform, const three_dof_constraint& constraint);
74  void handle_track_to_constraint(transform_component& transform, const track_to_constraint& constraint);
75 };
76 
77 
78 #endif // ANTKEEPER_GAME_CONSTRAINT_SYSTEM_HPP
Applies constraint stacks to transform components.
constraint_system(entity::registry &registry)
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.
Definition: registry.hpp:28
entt::entity id
Entity ID type.
Definition: id.hpp:28
Makes the entity a child of the target entity.
Copies the rotation of a target entity.
Copies the scale of a target entity.
Copies the transform of a target entity.
Copies the translation of a target entity.
Eases toward a target entity.
Pivots around a target entity.
Springs to a target entity.
Builds rotation from 3DoF angles.
Rotates a transform to face a target.