diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/crepe/system/CollisionSystem.cpp | 6 | ||||
-rw-r--r-- | src/test/CollisionTest.cpp | 14 |
2 files changed, 13 insertions, 7 deletions
diff --git a/src/crepe/system/CollisionSystem.cpp b/src/crepe/system/CollisionSystem.cpp index 0d056a5..a3c59e3 100644 --- a/src/crepe/system/CollisionSystem.cpp +++ b/src/crepe/system/CollisionSystem.cpp @@ -70,7 +70,7 @@ std::vector<std::pair<int, int>> CollisionSystem::check_collisions(const std::ve for (size_t j = 0; j < circlecolliders.size(); ++j) { // Skip self collision - int game_object_id_2 = boxcolliders[j].get().game_object_id; + int game_object_id_2 = circlecolliders[j].get().game_object_id; if (game_object_id_1 == game_object_id_2) continue; // Fetch components for the second collider (circle) @@ -87,13 +87,13 @@ std::vector<std::pair<int, int>> CollisionSystem::check_collisions(const std::ve for (size_t i = 0; i < circlecolliders.size(); ++i) { // Fetch components for the first circle collider - int game_object_id_1 = boxcolliders[i].get().game_object_id; + int game_object_id_1 = circlecolliders[i].get().game_object_id; Transform & transform1 = mgr.get_components_by_id<Transform>(circlecolliders[i].get().game_object_id).front().get(); Rigidbody & rigidbody1 = mgr.get_components_by_id<Rigidbody>(circlecolliders[i].get().game_object_id).front().get(); for (size_t j = i + 1; j < circlecolliders.size(); ++j) { // Skip self collision - int game_object_id_2 = boxcolliders[j].get().game_object_id; + int game_object_id_2 = circlecolliders[j].get().game_object_id; if (game_object_id_1 == game_object_id_2) continue; // Fetch components for the second circle collider diff --git a/src/test/CollisionTest.cpp b/src/test/CollisionTest.cpp index 1c4c325..3e43479 100644 --- a/src/test/CollisionTest.cpp +++ b/src/test/CollisionTest.cpp @@ -52,7 +52,7 @@ protected: .use_gravity = false, .bounce = false, }); - game_object2->add_component<BoxCollider>(Vector2{0,0},10,10); + game_object2->add_component<CircleCollider>(Vector2{0,0},5); } }; @@ -67,11 +67,17 @@ TEST_F(CollisionTest, box_box_collision) { collision_system.update(); transform.position = {40,50}; collision_system.update(); - transform.position = {41,50}; + transform.position = {50,39}; collision_system.update(); - transform.position = {44,50}; + transform.position = {50,40}; collision_system.update(); - transform.position = {50,50}; + transform.position = {50,60}; + collision_system.update(); + transform.position = {50,61}; + collision_system.update(); + transform.position = {60,50}; + collision_system.update(); + transform.position = {61,50}; collision_system.update(); } |