From a768d52b3aa2b7e79dfa92da90740c15abe4fc5d Mon Sep 17 00:00:00 2001 From: "C. J. Howard" Date: Fri, 21 Oct 2022 17:48:01 +0800 Subject: [PATCH] Remove dependencies on math.hpp, remove some obsolete systems --- src/animation/ease.hpp | 2 +- src/color/aces.hpp | 3 +- src/color/cat.hpp | 3 +- src/color/cct.hpp | 2 +- src/color/illuminant.hpp | 2 +- src/color/rgb.hpp | 3 +- src/color/srgb.hpp | 2 +- src/color/ucs.hpp | 2 +- src/color/xyy.hpp | 2 +- src/color/xyz.hpp | 2 +- src/entity/commands.cpp | 4 +- src/game/ant/morphogenesis.cpp | 2 + src/game/ant/swarm.cpp | 1 + src/game/component/cavity.hpp | 2 +- src/game/component/samara.hpp | 39 ----------- src/game/component/snap.hpp | 40 ------------ src/game/component/transform.hpp | 2 +- src/game/context.hpp | 4 -- src/game/state/boot.cpp | 10 --- src/game/state/main-menu.cpp | 1 + src/game/state/nuptial-flight.cpp | 15 ----- src/game/system/collision.cpp | 1 + src/game/system/constraint.cpp | 2 + src/game/system/painting.cpp | 1 - src/game/system/samara.cpp | 61 ------------------ src/game/system/samara.hpp | 39 ----------- src/game/system/snapping.cpp | 93 --------------------------- src/game/system/snapping.hpp | 40 ------------ src/game/system/steering.cpp | 1 + src/geom/aabb.hpp | 4 +- src/geom/bounding-volume.hpp | 2 +- src/geom/mesh-functions.cpp | 2 +- src/geom/plane.hpp | 2 +- src/geom/projection.hpp | 2 +- src/geom/ray.hpp | 2 +- src/geom/sphere.hpp | 2 +- src/geom/view-frustum.hpp | 3 +- src/math/matrix.hpp | 24 ++++--- src/render/context.hpp | 1 + src/render/passes/bloom-pass.cpp | 1 - src/render/passes/material-pass.cpp | 1 + src/render/passes/shadow-map-pass.cpp | 4 +- src/render/renderer.cpp | 3 +- src/scene/camera.cpp | 1 + src/scene/directional-light.cpp | 3 +- src/scene/object.cpp | 2 +- src/scene/spot-light.cpp | 3 +- 47 files changed, 64 insertions(+), 379 deletions(-) delete mode 100644 src/game/component/samara.hpp delete mode 100644 src/game/component/snap.hpp delete mode 100644 src/game/system/samara.cpp delete mode 100644 src/game/system/samara.hpp delete mode 100644 src/game/system/snapping.cpp delete mode 100644 src/game/system/snapping.hpp diff --git a/src/animation/ease.hpp b/src/animation/ease.hpp index 5f40c33..6dfa7a8 100644 --- a/src/animation/ease.hpp +++ b/src/animation/ease.hpp @@ -51,7 +51,7 @@ #ifndef ANTKEEPER_EASE_HPP #define ANTKEEPER_EASE_HPP -#include "math/math.hpp" +#include "math/interpolation.hpp" #include /** diff --git a/src/color/aces.hpp b/src/color/aces.hpp index a127ca1..95eec2b 100644 --- a/src/color/aces.hpp +++ b/src/color/aces.hpp @@ -21,7 +21,8 @@ #define ANTKEEPER_COLOR_ACES_HPP #include "color/rgb.hpp" -#include "math/math.hpp" +#include "math/matrix.hpp" +#include "math/vector.hpp" namespace color { diff --git a/src/color/cat.hpp b/src/color/cat.hpp index 8f4fcb2..2baa62f 100644 --- a/src/color/cat.hpp +++ b/src/color/cat.hpp @@ -20,7 +20,8 @@ #ifndef ANTKEEPER_COLOR_CAT_HPP #define ANTKEEPER_COLOR_CAT_HPP -#include "math/math.hpp" +#include "math/matrix.hpp" +#include "math/vector.hpp" namespace color { diff --git a/src/color/cct.hpp b/src/color/cct.hpp index 6178530..eb27213 100644 --- a/src/color/cct.hpp +++ b/src/color/cct.hpp @@ -20,9 +20,9 @@ #ifndef ANTKEEPER_COLOR_CCT_HPP #define ANTKEEPER_COLOR_CCT_HPP -#include "math/math.hpp" #include "ucs.hpp" #include "xyy.hpp" +#include "math/vector.hpp" namespace color { diff --git a/src/color/illuminant.hpp b/src/color/illuminant.hpp index 0b134ec..6800c16 100644 --- a/src/color/illuminant.hpp +++ b/src/color/illuminant.hpp @@ -20,7 +20,7 @@ #ifndef ANTKEEPER_COLOR_ILLUMINANT_HPP #define ANTKEEPER_COLOR_ILLUMINANT_HPP -#include "math/math.hpp" +#include "math/vector.hpp" namespace color { diff --git a/src/color/rgb.hpp b/src/color/rgb.hpp index f1ed816..3562127 100644 --- a/src/color/rgb.hpp +++ b/src/color/rgb.hpp @@ -21,7 +21,8 @@ #define ANTKEEPER_COLOR_RGB_HPP #include "color/cat.hpp" -#include "math/math.hpp" +#include "math/matrix.hpp" +#include "math/vector.hpp" namespace color { diff --git a/src/color/srgb.hpp b/src/color/srgb.hpp index a43e429..5e2d861 100644 --- a/src/color/srgb.hpp +++ b/src/color/srgb.hpp @@ -22,7 +22,7 @@ #include "color/rgb.hpp" #include "color/illuminant.hpp" -#include "math/math.hpp" +#include "math/vector.hpp" #include namespace color { diff --git a/src/color/ucs.hpp b/src/color/ucs.hpp index 98a5048..f666e11 100644 --- a/src/color/ucs.hpp +++ b/src/color/ucs.hpp @@ -20,7 +20,7 @@ #ifndef ANTKEEPER_COLOR_UCS_HPP #define ANTKEEPER_COLOR_UCS_HPP -#include "math/math.hpp" +#include "math/vector.hpp" namespace color { diff --git a/src/color/xyy.hpp b/src/color/xyy.hpp index 11b4379..2f8dc02 100644 --- a/src/color/xyy.hpp +++ b/src/color/xyy.hpp @@ -20,7 +20,7 @@ #ifndef ANTKEEPER_COLOR_XYY_HPP #define ANTKEEPER_COLOR_XYY_HPP -#include "math/math.hpp" +#include "math/vector.hpp" namespace color { diff --git a/src/color/xyz.hpp b/src/color/xyz.hpp index 6c4dc6c..0601f59 100644 --- a/src/color/xyz.hpp +++ b/src/color/xyz.hpp @@ -20,7 +20,7 @@ #ifndef ANTKEEPER_COLOR_XYZ_HPP #define ANTKEEPER_COLOR_XYZ_HPP -#include "math/math.hpp" +#include "math/vector.hpp" namespace color { diff --git a/src/entity/commands.cpp b/src/entity/commands.cpp index 6152fc8..4ad4faa 100644 --- a/src/entity/commands.cpp +++ b/src/entity/commands.cpp @@ -20,10 +20,12 @@ #include "entity/commands.hpp" #include "game/component/model.hpp" #include "game/component/transform.hpp" -#include "game/component/snap.hpp" #include "game/component/parent.hpp" #include "game/component/celestial-body.hpp" #include "game/component/terrain.hpp" +#include "math/quaternion-type.hpp" +#include "math/quaternion-operators.hpp" +#include "math/quaternion-functions.hpp" #include namespace entity { diff --git a/src/game/ant/morphogenesis.cpp b/src/game/ant/morphogenesis.cpp index 94a72be..e588a07 100644 --- a/src/game/ant/morphogenesis.cpp +++ b/src/game/ant/morphogenesis.cpp @@ -20,6 +20,8 @@ #include "game/ant/morphogenesis.hpp" #include "render/material.hpp" #include "render/vertex-attribute.hpp" +#include "math/transform-operators.hpp" +#include "math/quaternion-operators.hpp" #include #include diff --git a/src/game/ant/swarm.cpp b/src/game/ant/swarm.cpp index d87828a..680bcbd 100644 --- a/src/game/ant/swarm.cpp +++ b/src/game/ant/swarm.cpp @@ -23,6 +23,7 @@ #include "game/component/model.hpp" #include "game/component/picking.hpp" #include "resources/resource-manager.hpp" +#include "math/quaternion-operators.hpp" #include "config.hpp" #include #include diff --git a/src/game/component/cavity.hpp b/src/game/component/cavity.hpp index 666e450..51043de 100644 --- a/src/game/component/cavity.hpp +++ b/src/game/component/cavity.hpp @@ -20,7 +20,7 @@ #ifndef ANTKEEPER_GAME_COMPONENT_CAVITY_HPP #define ANTKEEPER_GAME_COMPONENT_CAVITY_HPP -#include "math/math.hpp" +#include "utility/fundamental-types.hpp" namespace game { namespace component { diff --git a/src/game/component/samara.hpp b/src/game/component/samara.hpp deleted file mode 100644 index f7a5bcf..0000000 --- a/src/game/component/samara.hpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2021 Christopher J. Howard - * - * This file is part of Antkeeper source code. - * - * Antkeeper source code is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Antkeeper source code is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Antkeeper source code. If not, see . - */ - -#ifndef ANTKEEPER_GAME_COMPONENT_SAMARA_HPP -#define ANTKEEPER_GAME_COMPONENT_SAMARA_HPP - -#include "utility/fundamental-types.hpp" - -namespace game { -namespace component { - -struct samara -{ - float3 direction; - float angle; - float chirality; -}; - -} // namespace component -} // namespace game - -#endif // ANTKEEPER_GAME_COMPONENT_SAMARA_HPP - diff --git a/src/game/component/snap.hpp b/src/game/component/snap.hpp deleted file mode 100644 index 9b6f78f..0000000 --- a/src/game/component/snap.hpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2021 Christopher J. Howard - * - * This file is part of Antkeeper source code. - * - * Antkeeper source code is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Antkeeper source code is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Antkeeper source code. If not, see . - */ - -#ifndef ANTKEEPER_GAME_COMPONENT_SNAP_HPP -#define ANTKEEPER_GAME_COMPONENT_SNAP_HPP - -#include "geom/ray.hpp" - -namespace game { -namespace component { - -struct snap -{ - geom::ray ray; - bool relative; - bool warp; - bool autoremove; -}; - -} // namespace component -} // namespace game - -#endif // ANTKEEPER_GAME_COMPONENT_SNAP_HPP - diff --git a/src/game/component/transform.hpp b/src/game/component/transform.hpp index dd7f005..eb93f7a 100644 --- a/src/game/component/transform.hpp +++ b/src/game/component/transform.hpp @@ -20,7 +20,7 @@ #ifndef ANTKEEPER_GAME_COMPONENT_TRANSFORM_HPP #define ANTKEEPER_GAME_COMPONENT_TRANSFORM_HPP -#include "math/math.hpp" +#include "math/transform-type.hpp" namespace game { namespace component { diff --git a/src/game/context.hpp b/src/game/context.hpp index 6ec4d47..80605f0 100644 --- a/src/game/context.hpp +++ b/src/game/context.hpp @@ -91,11 +91,9 @@ namespace game class collision; class constraint; class locomotion; - class snapping; class camera; class nest; class render; - class samara; class proteome; class steering; class spring; @@ -281,9 +279,7 @@ struct context game::system::constraint* constraint_system; game::system::locomotion* locomotion_system; game::system::steering* steering_system; - game::system::snapping* snapping_system; game::system::render* render_system; - game::system::samara* samara_system; game::system::subterrain* subterrain_system; game::system::terrain* terrain_system; game::system::vegetation* vegetation_system; diff --git a/src/game/state/boot.cpp b/src/game/state/boot.cpp index 4ecbc97..b91d6d9 100644 --- a/src/game/state/boot.cpp +++ b/src/game/state/boot.cpp @@ -61,9 +61,7 @@ #include "game/system/collision.hpp" #include "game/system/constraint.hpp" #include "game/system/locomotion.hpp" -#include "game/system/snapping.hpp" #include "game/system/render.hpp" -#include "game/system/samara.hpp" #include "game/system/subterrain.hpp" #include "game/system/terrain.hpp" #include "game/system/vegetation.hpp" @@ -860,12 +858,6 @@ void boot::setup_systems() // Setup collision system ctx.collision_system = new game::system::collision(*ctx.entity_registry); - // Setup samara system - ctx.samara_system = new game::system::samara(*ctx.entity_registry); - - // Setup snapping system - ctx.snapping_system = new game::system::snapping(*ctx.entity_registry); - // Setup behavior system ctx.behavior_system = new game::system::behavior(*ctx.entity_registry); @@ -1131,10 +1123,8 @@ void boot::setup_loop() // Update entity systems ctx.terrain_system->update(t, dt); //ctx.vegetation_system->update(t, dt); - ctx.snapping_system->update(t, dt); ctx.subterrain_system->update(t, dt); ctx.collision_system->update(t, dt); - ctx.samara_system->update(t, dt); ctx.behavior_system->update(t, dt); ctx.steering_system->update(t, dt); ctx.locomotion_system->update(t, dt); diff --git a/src/game/state/main-menu.cpp b/src/game/state/main-menu.cpp index 045b9bc..e1c858e 100644 --- a/src/game/state/main-menu.cpp +++ b/src/game/state/main-menu.cpp @@ -40,6 +40,7 @@ #include "game/component/model.hpp" #include "game/component/steering.hpp" #include "game/component/transform.hpp" +#include "math/projection.hpp" #include namespace game { diff --git a/src/game/state/nuptial-flight.cpp b/src/game/state/nuptial-flight.cpp index 89df43c..c6d73dd 100644 --- a/src/game/state/nuptial-flight.cpp +++ b/src/game/state/nuptial-flight.cpp @@ -76,21 +76,6 @@ nuptial_flight::nuptial_flight(game::context& ctx): ctx.logger->push_task("Entering nuptial flight state"); - - math::matrix m = - { - 1, 2, 3, - 4, 5, 6, - 7, 8, 9 - }; - - auto m2 = math::matrix::one(); - auto m3 = math::matrix(m2); - - std::cout << "m: " << m << std::endl; - std::cout << "m2: " << m2 << std::endl; - std::cout << "m3: " << m3 << std::endl; - // Init selected picking flag selected_picking_flag = std::uint32_t{1} << (sizeof(std::uint32_t) * 8 - 1); selected_eid = entt::null; diff --git a/src/game/system/collision.cpp b/src/game/system/collision.cpp index 9b26c2d..a66344d 100644 --- a/src/game/system/collision.cpp +++ b/src/game/system/collision.cpp @@ -22,6 +22,7 @@ #include "game/component/picking.hpp" #include "geom/primitive/intersection.hpp" #include "geom/primitive/plane.hpp" +#include "math/transform-operators.hpp" #include namespace game { diff --git a/src/game/system/constraint.cpp b/src/game/system/constraint.cpp index 312ac3a..c5334ed 100644 --- a/src/game/system/constraint.cpp +++ b/src/game/system/constraint.cpp @@ -19,6 +19,8 @@ #include "game/system/constraint.hpp" #include "game/component/constraint-stack.hpp" +#include "math/quaternion-operators.hpp" +#include "math/transform-operators.hpp" namespace game { namespace system { diff --git a/src/game/system/painting.cpp b/src/game/system/painting.cpp index b14d823..d65f1c5 100644 --- a/src/game/system/painting.cpp +++ b/src/game/system/painting.cpp @@ -23,7 +23,6 @@ #include "game/component/tool.hpp" #include "event/event-dispatcher.hpp" #include "resources/resource-manager.hpp" -#include "math/math.hpp" #include "render/material.hpp" #include "render/model.hpp" #include "utility/fundamental-types.hpp" diff --git a/src/game/system/samara.cpp b/src/game/system/samara.cpp deleted file mode 100644 index f66fbbb..0000000 --- a/src/game/system/samara.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) 2021 Christopher J. Howard - * - * This file is part of Antkeeper source code. - * - * Antkeeper source code is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Antkeeper source code is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Antkeeper source code. If not, see . - */ - -#include "samara.hpp" -#include "game/component/transform.hpp" -#include "game/component/samara.hpp" -#include "entity/id.hpp" -#include "math/math.hpp" -#include "utility/fundamental-types.hpp" - -namespace game { -namespace system { - -samara::samara(entity::registry& registry): - updatable(registry) -{} - -void samara::update(double t, double dt) -{ - registry.view().each( - [&](entity::id entity_id, auto& samara, auto& transform) - { - samara.angle += samara.chirality * math::radians(360.0f * 6.0f) * dt; - - transform.local.translation += samara.direction * 20.0f * (float)dt; - transform.local.rotation = - math::angle_axis(samara.angle, float3{0, 1, 0}) * - math::angle_axis(math::radians(20.0f), float3{1, 0, 0}) * - ((samara.chirality < 0.0f) ? math::angle_axis(math::radians(180.0f), float3{0, 0, -1}) : math::quaternion{1, 0, 0, 0}); - - if (transform.local.translation.y() < 0.0f) - { - const float zone = 200.0f; - transform.local.translation.x() = math::random(-zone, zone); - transform.local.translation.y() = math::random(100.0f, 150.0f); - transform.local.translation.z() = math::random(-zone, zone); - transform.warp = true; - - samara.chirality = (math::random(0.0f, 1.0f) < 0.5f) ? -1.0f : 1.0f; - } - }); -} - -} // namespace system -} // namespace game diff --git a/src/game/system/samara.hpp b/src/game/system/samara.hpp deleted file mode 100644 index 140bcc7..0000000 --- a/src/game/system/samara.hpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2021 Christopher J. Howard - * - * This file is part of Antkeeper source code. - * - * Antkeeper source code is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Antkeeper source code is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Antkeeper source code. If not, see . - */ - -#ifndef ANTKEEPER_GAME_SYSTEM_SAMARA_HPP -#define ANTKEEPER_GAME_SYSTEM_SAMARA_HPP - -#include "game/system/updatable.hpp" - -namespace game { -namespace system { - -class samara: public updatable -{ -public: - samara(entity::registry& registry); - virtual void update(double t, double dt); -}; - -} // namespace system -} // namespace game - -#endif // ANTKEEPER_GAME_SYSTEM_SAMARA_HPP - diff --git a/src/game/system/snapping.cpp b/src/game/system/snapping.cpp deleted file mode 100644 index 1bee797..0000000 --- a/src/game/system/snapping.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2021 Christopher J. Howard - * - * This file is part of Antkeeper source code. - * - * Antkeeper source code is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Antkeeper source code is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Antkeeper source code. If not, see . - */ - -#include "snapping.hpp" -#include "game/component/collision.hpp" -#include "game/component/snap.hpp" -#include "game/component/transform.hpp" -#include "entity/id.hpp" -#include "utility/fundamental-types.hpp" - -namespace game { -namespace system { - -snapping::snapping(entity::registry& registry): - updatable(registry) -{} - -void snapping::update(double t, double dt) -{ - registry.view().each( - [&](entity::id entity_id, auto& snap_transform, auto& snap) - { - bool intersection = false; - float a = std::numeric_limits::infinity(); - float3 pick; - - geom::ray snap_ray = snap.ray; - if (snap.relative) - { - snap_ray.origin += snap_transform.local.translation; - snap_ray.direction = snap_transform.local.rotation * snap_ray.direction; - } - - this->registry.view().each( - [&](entity::id entity_id, auto& collision_transform, auto& collision) - { - // Transform ray into local space of collision component - math::transform inverse_transform = math::inverse(collision_transform.local); - float3 origin = inverse_transform * snap_ray.origin; - float3 direction = math::normalize(math::conjugate(collision_transform.local.rotation) * snap_ray.direction); - geom::ray transformed_ray = {origin, direction}; - - // Broad phase AABB test - auto aabb_result = geom::ray_aabb_intersection(transformed_ray, collision.bounds); - if (!std::get<0>(aabb_result)) - { - return; - } - - // Narrow phase mesh test - auto mesh_result = collision.mesh_accelerator.query_nearest(transformed_ray); - if (mesh_result) - { - intersection = true; - if (mesh_result->t < a) - { - a = mesh_result->t; - pick = snap_ray.extrapolate(a); - } - } - }); - - if (intersection) - { - snap_transform.local.translation = pick; - snap_transform.warp = snap.warp; - - if (snap.autoremove) - { - this->registry.remove(entity_id); - } - } - }); -} - -} // namespace system -} // namespace game diff --git a/src/game/system/snapping.hpp b/src/game/system/snapping.hpp deleted file mode 100644 index 5ae180d..0000000 --- a/src/game/system/snapping.hpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2021 Christopher J. Howard - * - * This file is part of Antkeeper source code. - * - * Antkeeper source code is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Antkeeper source code is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Antkeeper source code. If not, see . - */ - -#ifndef ANTKEEPER_GAME_SYSTEM_SNAPPING_HPP -#define ANTKEEPER_GAME_SYSTEM_SNAPPING_HPP - -#include "game/system/updatable.hpp" - -namespace game { -namespace system { - -class snapping: - public updatable -{ -public: - snapping(entity::registry& registry); - virtual void update(double t, double dt); -}; - -} // namespace system -} // namespace game - -#endif // ANTKEEPER_GAME_SYSTEM_SNAPPING_HPP - diff --git a/src/game/system/steering.cpp b/src/game/system/steering.cpp index b69cf04..2a51f0c 100644 --- a/src/game/system/steering.cpp +++ b/src/game/system/steering.cpp @@ -23,6 +23,7 @@ #include "entity/id.hpp" #include "ai/steering/behavior/wander.hpp" #include "ai/steering/behavior/seek.hpp" +#include "math/quaternion-operators.hpp" #include "config.hpp" namespace game { diff --git a/src/geom/aabb.hpp b/src/geom/aabb.hpp index 732d337..2ba2315 100644 --- a/src/geom/aabb.hpp +++ b/src/geom/aabb.hpp @@ -22,7 +22,9 @@ #include "bounding-volume.hpp" #include "sphere.hpp" -#include "math/math.hpp" +#include "math/vector.hpp" +#include "math/matrix.hpp" +#include "math/transform-type.hpp" #include namespace geom { diff --git a/src/geom/bounding-volume.hpp b/src/geom/bounding-volume.hpp index 7fcec5c..ffb835c 100644 --- a/src/geom/bounding-volume.hpp +++ b/src/geom/bounding-volume.hpp @@ -20,7 +20,7 @@ #ifndef ANTKEEPER_GEOM_BOUNDING_VOLUME_HPP #define ANTKEEPER_GEOM_BOUNDING_VOLUME_HPP -#include "math/math.hpp" +#include "math/vector.hpp" #include namespace geom { diff --git a/src/geom/mesh-functions.cpp b/src/geom/mesh-functions.cpp index 52f3b04..5d57c5b 100644 --- a/src/geom/mesh-functions.cpp +++ b/src/geom/mesh-functions.cpp @@ -18,7 +18,7 @@ */ #include "mesh-functions.hpp" -#include "math/math.hpp" +#include "utility/fundamental-types.hpp" #include namespace geom { diff --git a/src/geom/plane.hpp b/src/geom/plane.hpp index eb252b0..fb8b236 100644 --- a/src/geom/plane.hpp +++ b/src/geom/plane.hpp @@ -20,7 +20,7 @@ #ifndef ANTKEEPER_GEOM_PLANE_HPP #define ANTKEEPER_GEOM_PLANE_HPP -#include "math/math.hpp" +#include "math/vector.hpp" namespace geom { diff --git a/src/geom/projection.hpp b/src/geom/projection.hpp index 86bc782..2b6bea7 100644 --- a/src/geom/projection.hpp +++ b/src/geom/projection.hpp @@ -20,7 +20,7 @@ #ifndef ANTKEEPER_GEOM_PROJECTION_HPP #define ANTKEEPER_GEOM_PROJECTION_HPP -#include "math/math.hpp" +#include "math/vector.hpp" namespace geom { diff --git a/src/geom/ray.hpp b/src/geom/ray.hpp index fc113d6..f15e54c 100644 --- a/src/geom/ray.hpp +++ b/src/geom/ray.hpp @@ -20,7 +20,7 @@ #ifndef ANTKEEPER_GEOM_RAY_HPP #define ANTKEEPER_GEOM_RAY_HPP -#include "math/math.hpp" +#include "math/vector.hpp" namespace geom { diff --git a/src/geom/sphere.hpp b/src/geom/sphere.hpp index 02c3c69..93fff28 100644 --- a/src/geom/sphere.hpp +++ b/src/geom/sphere.hpp @@ -22,7 +22,7 @@ #include "geom/bounding-volume.hpp" #include "geom/aabb.hpp" -#include "math/math.hpp" +#include "math/vector.hpp" #include namespace geom { diff --git a/src/geom/view-frustum.hpp b/src/geom/view-frustum.hpp index ebfa09f..7304066 100644 --- a/src/geom/view-frustum.hpp +++ b/src/geom/view-frustum.hpp @@ -21,7 +21,8 @@ #define ANTKEEPER_GEOM_VIEW_FRUSTUM_HPP #include "geom/convex-hull.hpp" -#include "math/math.hpp" +#include "math/vector.hpp" +#include "math/matrix.hpp" #include namespace geom { diff --git a/src/math/matrix.hpp b/src/math/matrix.hpp index 4fea00b..2c83a4f 100644 --- a/src/math/matrix.hpp +++ b/src/math/matrix.hpp @@ -31,7 +31,7 @@ namespace math { /** - * *n*-by-*m* column-major matrix. + * *n* by *m* column-major matrix. * * @tparam T Matrix element data type. * @tparam N Number of columns. @@ -90,11 +90,11 @@ struct matrix /// @} /** - * Returns a reference to the element at a given index, in column-major order. + * Returns a reference to the element at a given column-major index. * - * @param i Index of a matrix element. + * @param i Column-major index of a matrix element. * - * @return Reference to the element at index @p i. + * @return Reference to the element at column-major index @p i. */ /// @{ constexpr inline T& element(std::size_t i) noexcept @@ -131,15 +131,19 @@ struct matrix } /// @} - /// Returns a pointer to the column vector array. + /** + * Returns a pointer to the first element. + * + * @warning If column_vector_type is not a POD type, elements may not be stored contiguously. + */ /// @{ - constexpr inline column_vector_type* data() noexcept + constexpr inline element_type* data() noexcept { - return columns; + return &columns[0][0]; }; - constexpr inline const column_vector_type* data() const noexcept + constexpr inline const element_type* data() const noexcept { - return columns; + return &columns[0][0]; }; /// @} @@ -249,7 +253,7 @@ struct matrix * @tparam P Target number of columns. * @tparam O Target number of rows. * - * @return *p*-by-*o* matrix. + * @return *p by *o* matrix. */ template constexpr inline explicit operator matrix() const noexcept diff --git a/src/render/context.hpp b/src/render/context.hpp index 15311bc..882f548 100644 --- a/src/render/context.hpp +++ b/src/render/context.hpp @@ -23,6 +23,7 @@ #include "geom/plane.hpp" #include "geom/bounding-volume.hpp" #include "utility/fundamental-types.hpp" +#include "math/transform-operators.hpp" #include namespace scene diff --git a/src/render/passes/bloom-pass.cpp b/src/render/passes/bloom-pass.cpp index abcabec..b79a76f 100644 --- a/src/render/passes/bloom-pass.cpp +++ b/src/render/passes/bloom-pass.cpp @@ -32,7 +32,6 @@ #include "gl/texture-filter.hpp" #include "render/vertex-attribute.hpp" #include "render/context.hpp" -#include "math/math.hpp" #include #include diff --git a/src/render/passes/material-pass.cpp b/src/render/passes/material-pass.cpp index dbd1fbb..d8092bc 100644 --- a/src/render/passes/material-pass.cpp +++ b/src/render/passes/material-pass.cpp @@ -42,6 +42,7 @@ #include "scene/point-light.hpp" #include "scene/spot-light.hpp" #include "config.hpp" +#include "math/quaternion-operators.hpp" #include #include diff --git a/src/render/passes/shadow-map-pass.cpp b/src/render/passes/shadow-map-pass.cpp index fea52a2..f844167 100644 --- a/src/render/passes/shadow-map-pass.cpp +++ b/src/render/passes/shadow-map-pass.cpp @@ -32,7 +32,9 @@ #include "geom/view-frustum.hpp" #include "geom/aabb.hpp" #include "config.hpp" -#include "math/math.hpp" +#include "math/vector.hpp" +#include "math/matrix.hpp" +#include "math/quaternion-operators.hpp" #include #include diff --git a/src/render/renderer.cpp b/src/render/renderer.cpp index f56fa8f..ff54494 100644 --- a/src/render/renderer.cpp +++ b/src/render/renderer.cpp @@ -28,9 +28,10 @@ #include "scene/text.hpp" #include "render/model.hpp" #include "gl/drawing-mode.hpp" -#include "math/math.hpp" +#include "math/matrix.hpp" #include "geom/projection.hpp" #include "config.hpp" +#include "math/quaternion-operators.hpp" #include #include diff --git a/src/scene/camera.cpp b/src/scene/camera.cpp index d77e1e6..a6c7327 100644 --- a/src/scene/camera.cpp +++ b/src/scene/camera.cpp @@ -21,6 +21,7 @@ #include "config.hpp" #include "math/constants.hpp" #include "math/interpolation.hpp" +#include "math/quaternion-operators.hpp" namespace scene { diff --git a/src/scene/directional-light.cpp b/src/scene/directional-light.cpp index 58a029b..d75ffe6 100644 --- a/src/scene/directional-light.cpp +++ b/src/scene/directional-light.cpp @@ -19,7 +19,8 @@ #include "directional-light.hpp" #include "config.hpp" -#include "math/math.hpp" +#include "math/quaternion-operators.hpp" +#include "math/interpolation.hpp" namespace scene { diff --git a/src/scene/object.cpp b/src/scene/object.cpp index 0aa7c3f..723c7c2 100644 --- a/src/scene/object.cpp +++ b/src/scene/object.cpp @@ -18,7 +18,7 @@ */ #include "scene/object.hpp" -#include "math/math.hpp" +#include "math/interpolation.hpp" namespace scene { diff --git a/src/scene/spot-light.cpp b/src/scene/spot-light.cpp index c4ba065..418176d 100644 --- a/src/scene/spot-light.cpp +++ b/src/scene/spot-light.cpp @@ -19,7 +19,8 @@ #include "spot-light.hpp" #include "config.hpp" -#include "math/math.hpp" +#include "math/quaternion-operators.hpp" +#include "math/interpolation.hpp" #include namespace scene {