فهرست منبع

Change test to permit double-collision.
Fix test failure with self-collision.

Sam Jaffe 6 سال پیش
والد
کامیت
f2e5fcf98f
2فایلهای تغییر یافته به همراه2 افزوده شده و 1 حذف شده
  1. 1 0
      engine/src/scene.cpp
  2. 1 1
      engine/test/scene_test.cxx

+ 1 - 0
engine/src/scene.cpp

@@ -24,6 +24,7 @@ void scene::check_collisions(std::vector<collidable *> const & from,
                              std::vector<collidable *> const & to) {
   for (auto & ent : from) {
     for (auto & hit : to) {
+      if (ent == hit) continue;
       if (math::intersects(ent->render_info().points,
                            hit->render_info().points)) {
         ent->collide(*hit);

+ 1 - 1
engine/test/scene_test.cxx

@@ -135,7 +135,7 @@ TEST_F(SceneTest, ObjectCanBeInMultipleCollidableAsGroups) {
   scene().update(0.f);
 }
 
-TEST_F(SceneTest, DoubleCollisionDoesNotOccur) {
+TEST_F(SceneTest, DoubleCollisionCanOccur) {
   math::dim2::rectangle bnds{{{0.f, 0.f}}, {{1.f, 1.f}}};
   mock_collidable one{bnds}, two{bnds};
   scene().add_with(1, one);