diff --git a/core/include/cubos/core/geom/plane.hpp b/core/include/cubos/core/geom/plane.hpp deleted file mode 100644 index 66e008a44d..0000000000 --- a/core/include/cubos/core/geom/plane.hpp +++ /dev/null @@ -1,37 +0,0 @@ -/// @file -/// @brief Class @ref cubos::core::geom::Plane. -/// @ingroup core-geom - -#pragma once - -#include - -#include -#include - -namespace cubos::core::geom -{ - /// @brief Represents a plane shape. - /// @ingroup core-geom - struct Plane - { - glm::vec3 normal{0.0F, 1.0F, 0.0F}; ///< Normal of the plane. - }; -} // namespace cubos::core::geom - -namespace cubos::core::data::old -{ - inline void serialize(Serializer& ser, const geom::Plane& plane, const char* name) - { - ser.beginObject(name); - ser.write(plane.normal, "normal"); - ser.endObject(); - } - - inline void deserialize(Deserializer& des, geom::Plane& plane) - { - des.beginObject(); - des.read(plane.normal); - des.endObject(); - } -} // namespace cubos::core::data::old diff --git a/core/include/cubos/core/geom/simplex.hpp b/core/include/cubos/core/geom/simplex.hpp deleted file mode 100644 index dd9200ee74..0000000000 --- a/core/include/cubos/core/geom/simplex.hpp +++ /dev/null @@ -1,82 +0,0 @@ -/// @file -/// @brief Class @ref cubos::core::geom::Simplex. -/// @ingroup core-geom - -#pragma once - -#include - -#include - -#include -#include - -namespace cubos::core::geom -{ - /// @brief Represents a simplex shape, which may either be empty, a point, a line, a triangle - /// or a tetrahedron. - /// @ingroup core-geom - struct Simplex - { - /// @todo We should implement something like `boost::static_vector` for this. See #419. - std::vector points{}; ///< Points of the simplex. - - /// @brief Constructs an empty simplex. - /// @return Empty simplex. - static Simplex empty() - { - return {{}}; - } - - /// @brief Constructs a point simplex. - /// @param p Point. - /// @return Point simplex. - static Simplex point(const glm::vec3& p) - { - return {{p}}; - } - - /// @brief Constructs a line simplex. - /// @param p1 First point. - /// @param p2 Second point. - /// @return Line simplex. - static Simplex line(const glm::vec3& p1, const glm::vec3& p2) - { - return {{p1, p2}}; - } - - /// @brief Constructs a triangle simplex. - /// @param p1 First point. - /// @param p2 Second point. - /// @param p3 Third point. - /// @return Triangle simplex. - static Simplex triangle(const glm::vec3& p1, const glm::vec3& p2, const glm::vec3& p3) - { - return {{p1, p2, p3}}; - } - - /// @brief Constructs a tetrahedron simplex. - /// @param p1 First point. - /// @param p2 Second point. - /// @param p3 Third point. - /// @param p4 Fourth point. - /// @return Tetrahedron simplex. - static Simplex tetrahedron(const glm::vec3& p1, const glm::vec3& p2, const glm::vec3& p3, const glm::vec3& p4) - { - return {{p1, p2, p3, p4}}; - } - }; -} // namespace cubos::core::geom - -namespace cubos::core::data::old -{ - inline void serialize(Serializer& ser, const geom::Simplex& simplex, const char* name) - { - ser.write(simplex.points, name); - } - - inline void deserialize(Deserializer& des, geom::Simplex& simplex) - { - des.read(simplex.points); - } -} // namespace cubos::core::data::old diff --git a/engine/include/cubos/engine/collisions/broad_phase_collisions.hpp b/engine/include/cubos/engine/collisions/broad_phase_collisions.hpp index 85c7e2c2c6..25f15d4fe1 100644 --- a/engine/include/cubos/engine/collisions/broad_phase_collisions.hpp +++ b/engine/include/cubos/engine/collisions/broad_phase_collisions.hpp @@ -34,14 +34,7 @@ namespace cubos::engine { BoxBox = 0, BoxCapsule, - BoxPlane, - BoxSimplex, CapsuleCapsule, - CapsulePlane, - CapsuleSimplex, - PlanePlane, - PlaneSimplex, - SimplexSimplex, Count ///< Number of collision types. }; diff --git a/engine/include/cubos/engine/collisions/colliders/plane.hpp b/engine/include/cubos/engine/collisions/colliders/plane.hpp deleted file mode 100644 index 1f8377e28b..0000000000 --- a/engine/include/cubos/engine/collisions/colliders/plane.hpp +++ /dev/null @@ -1,28 +0,0 @@ -/// @file -/// @brief Component @ref cubos::engine::PlaneCollider. -/// @ingroup collisions-plugin - -#pragma once - -#include - -namespace cubos::engine -{ - /// @brief Component which adds a plane collider to an entity. - /// - /// - Zero thickness: Not suitable for dynamic objects, but can be used for static objects. - /// - Positive margin: Requires a positive margin. Defined in physics-space units. - /// - /// @ingroup collisions-plugin - struct [[cubos::component("cubos/plane_collider", VecStorage)]] PlaneCollider - { - glm::vec3 offset{0.0F}; ///< Offset of the collider. - cubos::core::geom::Plane shape; ///< Plane shape of the collider. - - /// @brief Margin of the collider. Needed for creating the AABB. - /// - /// The collider margin is absolute so the collider's transform won't affect it. Shouldn't - /// be changed without good reason. - float margin = 0.04F; - }; -} // namespace cubos::engine diff --git a/engine/include/cubos/engine/collisions/colliders/simplex.hpp b/engine/include/cubos/engine/collisions/colliders/simplex.hpp deleted file mode 100644 index 022d1e3f87..0000000000 --- a/engine/include/cubos/engine/collisions/colliders/simplex.hpp +++ /dev/null @@ -1,33 +0,0 @@ -/// @file -/// @brief Component @ref cubos::engine::SimplexCollider. -/// @ingroup collisions-plugin - -#pragma once - -#include - -namespace cubos::engine -{ - /// @brief Component which adds a simplex collider to an entity. - /// - /// - Convex: For any 2 points inside the shape, the line segment connecting those points lies - /// inside the shape. - /// - Positive margin: Requires a positive margin to round off sharp corners. Defined in - /// physics-space units. - /// - Zero thickness (up to 3 points): Not suitable for dynamic objects, but can be used for - /// static objects. - /// - /// @ingroup collisions-plugin - struct [[cubos::component("cubos/simplex", VecStorage)]] SimplexCollider - { - glm::vec3 offset{0.0F}; ///< Offset of the collider. - cubos::core::geom::Simplex shape; ///< Simplex shape of the collider. - - /// @brief Margin of the collider. Needed for collision stability. - /// - /// The collider margin avoids collision errors by rounding off sharp corners. Shouldn't be - /// changed without good reason, it's preferable to move the simplex corners to account for - /// it. - float margin = 0.04F; - }; -} // namespace cubos::engine diff --git a/engine/include/cubos/engine/collisions/plugin.hpp b/engine/include/cubos/engine/collisions/plugin.hpp index 5ffd36dabc..c29c5a7a66 100644 --- a/engine/include/cubos/engine/collisions/plugin.hpp +++ b/engine/include/cubos/engine/collisions/plugin.hpp @@ -21,8 +21,6 @@ namespace cubos::engine /// ## Components /// - @ref BoxCollider - holds the box collider data. /// - @ref CapsuleCollider - holds the capsule collider data. - /// - @ref PlaneCollider - holds the plane collider data. - /// - @ref SimplexCollider - holds the simplex collider data. /// /// ## Events /// - @ref CollisionEvent - (TODO) emitted when a collision occurs. diff --git a/engine/src/cubos/engine/collisions/broad_phase.cpp b/engine/src/cubos/engine/collisions/broad_phase.cpp index 47a7a3990b..f83586ddb3 100644 --- a/engine/src/cubos/engine/collisions/broad_phase.cpp +++ b/engine/src/cubos/engine/collisions/broad_phase.cpp @@ -45,13 +45,6 @@ void updateCapsuleAABBs(Query, Read, Write, Read, Write> query, - Write collisions) -{ - (void)query; - (void)collisions; -} - void updateMarkers(Query> query, Write collisions) { // TODO: This is parallelizable. @@ -98,59 +91,22 @@ void sweep(Write collisions) } } -CollisionType getCollisionType(bool box, bool capsule, bool plane, bool simplex) +CollisionType getCollisionType(bool box, bool capsule) { if (box && capsule) { return CollisionType::BoxCapsule; } - if (box && plane) - { - return CollisionType::BoxPlane; - } - - if (box && simplex) - { - return CollisionType::BoxSimplex; - } - if (box) { return CollisionType::BoxBox; } - if (capsule && plane) - { - return CollisionType::CapsulePlane; - } - - if (capsule && simplex) - { - return CollisionType::CapsuleSimplex; - } - - if (capsule) - { - return CollisionType::CapsuleCapsule; - } - - if (plane && simplex) - { - return CollisionType::PlaneSimplex; - } - - if (plane) - { - return CollisionType::PlanePlane; - } - - return CollisionType::SimplexSimplex; + return CollisionType::CapsuleCapsule; } -void findPairs(Query, OptRead, OptRead, OptRead, - Read> - query, +void findPairs(Query, OptRead, Read> query, Write collisions) { collisions->clearCandidates(); @@ -159,14 +115,13 @@ void findPairs(Query, OptRead, OptReadsweepOverlapMaps[axis]) { - auto [box, capsule, plane, simplex, aabb] = query[entity].value(); + auto [box, capsule, aabb] = query[entity].value(); for (auto& other : overlaps) { - auto [otherBox, otherCapsule, otherPlane, otherSimplex, otherAabb] = query[other].value(); + auto [otherBox, otherCapsule, otherAabb] = query[other].value(); // TODO: Should this be inside the if statement? - auto type = getCollisionType(box || otherBox, capsule || otherCapsule, plane || otherPlane, - simplex || otherSimplex); + auto type = getCollisionType(box || otherBox, capsule || otherCapsule); switch (axis) { diff --git a/engine/src/cubos/engine/collisions/broad_phase.hpp b/engine/src/cubos/engine/collisions/broad_phase.hpp index d3cb66c6b0..acb1520180 100644 --- a/engine/src/cubos/engine/collisions/broad_phase.hpp +++ b/engine/src/cubos/engine/collisions/broad_phase.hpp @@ -9,8 +9,6 @@ #include #include #include -#include -#include #include using cubos::core::ecs::Commands; @@ -24,8 +22,6 @@ using cubos::engine::BroadPhaseCollisions; using cubos::engine::CapsuleCollider; using cubos::engine::ColliderAABB; using cubos::engine::LocalToWorld; -using cubos::engine::PlaneCollider; -using cubos::engine::SimplexCollider; /// @brief Adds collision tracking to all new entities with colliders. template @@ -51,10 +47,6 @@ void updateBoxAABBs(Query, Read, Write, Read, Write> query, Write collisions); -/// @brief Updates the AABBs of all simplex colliders. -void updateSimplexAABBs(Query, Read, Write> query, - Write collisions); - /// @brief Updates the sweep markers of all colliders. void updateMarkers(Query> query, Write collisions); @@ -66,7 +58,5 @@ void sweep(Write collisions); /// @details /// TODO: This query is disgusting. We need a way to find if a component is present without reading it. /// Maybe something like Commands but for reads? -void findPairs(Query, OptRead, OptRead, OptRead, - Read> - query, +void findPairs(Query, OptRead, Read> query, Write collisions); \ No newline at end of file diff --git a/engine/src/cubos/engine/collisions/plugin.cpp b/engine/src/cubos/engine/collisions/plugin.cpp index 3bc92cb06f..0c04f3838b 100644 --- a/engine/src/cubos/engine/collisions/plugin.cpp +++ b/engine/src/cubos/engine/collisions/plugin.cpp @@ -12,19 +12,14 @@ void cubos::engine::collisionsPlugin(Cubos& cubos) cubos.addComponent(); cubos.addComponent(); - cubos.addComponent(); cubos.addComponent(); - cubos.addComponent(); cubos.system(trackNewEntities).tagged("cubos.collisions.aabb.missing"); - cubos.system(trackNewEntities).tagged("cubos.collisions.aabb.missing"); cubos.system(trackNewEntities).tagged("cubos.collisions.aabb.missing"); - cubos.system(trackNewEntities).tagged("cubos.collisions.aabb.missing"); cubos.tag("cubos.collisions.aabb.missing").before("cubos.collisions.aabb"); cubos.system(updateBoxAABBs).tagged("cubos.collisions.aabb"); cubos.system(updateCapsuleAABBs).tagged("cubos.collisions.aabb"); - cubos.system(updateSimplexAABBs).tagged("cubos.collisions.aabb"); cubos.tag("cubos.collisions.aabb").after("cubos.transform.update"); cubos.system(updateMarkers).tagged("cubos.collisions.broad.markers").after("cubos.collisions.aabb");