Skip to content

Commit

Permalink
refactor(collisions): farewell simplex
Browse files Browse the repository at this point in the history
  • Loading branch information
luishfonseca committed Oct 3, 2023
1 parent c50da74 commit 660f908
Show file tree
Hide file tree
Showing 12 changed files with 7 additions and 318 deletions.
37 changes: 0 additions & 37 deletions core/include/cubos/core/geom/plane.hpp

This file was deleted.

82 changes: 0 additions & 82 deletions core/include/cubos/core/geom/simplex.hpp

This file was deleted.

1 change: 0 additions & 1 deletion core/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ add_executable(

geom/box.cpp
geom/capsule.cpp
geom/simplex.cpp
)

target_link_libraries(cubos-core-tests cubos-core doctest::doctest)
Expand Down
53 changes: 0 additions & 53 deletions core/tests/geom/simplex.cpp

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,7 @@ namespace cubos::engine
{
BoxBox = 0,
BoxCapsule,
BoxPlane,
BoxSimplex,
CapsuleCapsule,
CapsulePlane,
CapsuleSimplex,
PlanePlane,
PlaneSimplex,
SimplexSimplex,

Count ///< Number of collision types.
};
Expand Down
28 changes: 0 additions & 28 deletions engine/include/cubos/engine/collisions/colliders/plane.hpp

This file was deleted.

33 changes: 0 additions & 33 deletions engine/include/cubos/engine/collisions/colliders/simplex.hpp

This file was deleted.

2 changes: 0 additions & 2 deletions engine/include/cubos/engine/collisions/plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
57 changes: 6 additions & 51 deletions engine/src/cubos/engine/collisions/broad_phase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,6 @@ void updateCapsuleAABBs(Query<Read<LocalToWorld>, Read<CapsuleCollider>, Write<C
(void)collisions;
}

void updateSimplexAABBs(Query<Read<LocalToWorld>, Read<SimplexCollider>, Write<ColliderAABB>> query,
Write<BroadPhaseCollisions> collisions)
{
(void)query;
(void)collisions;
}

void updateMarkers(Query<Read<ColliderAABB>> query, Write<BroadPhaseCollisions> collisions)
{
// TODO: This is parallelizable.
Expand Down Expand Up @@ -98,59 +91,22 @@ void sweep(Write<BroadPhaseCollisions> 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<BoxCollider>, OptRead<CapsuleCollider>, OptRead<PlaneCollider>, OptRead<SimplexCollider>,
Read<ColliderAABB>>
query,
void findPairs(Query<OptRead<BoxCollider>, OptRead<CapsuleCollider>, Read<ColliderAABB>> query,
Write<BroadPhaseCollisions> collisions)
{
collisions->clearCandidates();
Expand All @@ -159,14 +115,13 @@ void findPairs(Query<OptRead<BoxCollider>, OptRead<CapsuleCollider>, OptRead<Pla
{
for (auto& [entity, overlaps] : collisions->sweepOverlapMaps[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)
{
Expand Down
Loading

0 comments on commit 660f908

Please sign in to comment.