|
|
@@ -25,9 +25,15 @@ struct test_scene : engine::scene {
|
|
|
void render() override {}
|
|
|
void handle_key_event(engine::event::key_event) override {}
|
|
|
void handle_mouse_event(engine::event::mouse_event) override {}
|
|
|
- bool in_bounds(math::dim2::point c) const { return engine::scene::in_bounds(c); }
|
|
|
- bool in_bounds(engine::collidable * c) const { return engine::scene::in_bounds(c); }
|
|
|
- graphics::manager const & graphics_manager() const { return engine::scene::graphics_manager(); }
|
|
|
+ bool in_bounds(math::dim2::point c) const {
|
|
|
+ return engine::scene::in_bounds(c);
|
|
|
+ }
|
|
|
+ bool in_bounds(engine::collidable * c) const {
|
|
|
+ return engine::scene::in_bounds(c);
|
|
|
+ }
|
|
|
+ graphics::manager const & graphics_manager() const {
|
|
|
+ return engine::scene::graphics_manager();
|
|
|
+ }
|
|
|
|
|
|
void add_with(engine::collision_t t, engine::collidable & c) {
|
|
|
colliders[t].push_back(&c);
|
|
|
@@ -166,34 +172,34 @@ struct BoundsTest : SceneTest, testing::WithParamInterface<math::vec2> {};
|
|
|
TEST_F(BoundsTest, BoundsCheckIsPointInScreenZone) {
|
|
|
// Confirm that the size is as expected...
|
|
|
EXPECT_THAT(scene().size(), Eq(make_vector(1600.f, 900.f)));
|
|
|
-
|
|
|
+
|
|
|
// Lower-Left Corner
|
|
|
- EXPECT_FALSE(scene().in_bounds(make_vector( -1.f, 0.f)));
|
|
|
- EXPECT_FALSE(scene().in_bounds(make_vector( 0.f, -1.f)));
|
|
|
+ EXPECT_FALSE(scene().in_bounds(make_vector(-1.f, 0.f)));
|
|
|
+ EXPECT_FALSE(scene().in_bounds(make_vector(0.f, -1.f)));
|
|
|
EXPECT_TRUE(scene().in_bounds(make_vector(0.f, 0.f)));
|
|
|
// Lower-Right Corner
|
|
|
- EXPECT_FALSE(scene().in_bounds(make_vector(1600.f, -1.f)));
|
|
|
- EXPECT_FALSE(scene().in_bounds(make_vector(1601.f, 0.f)));
|
|
|
- EXPECT_TRUE(scene().in_bounds(make_vector(1600.f, 0.f)));
|
|
|
+ EXPECT_FALSE(scene().in_bounds(make_vector(1600.f, -1.f)));
|
|
|
+ EXPECT_FALSE(scene().in_bounds(make_vector(1601.f, 0.f)));
|
|
|
+ EXPECT_TRUE(scene().in_bounds(make_vector(1600.f, 0.f)));
|
|
|
// Upper-Right Corner
|
|
|
EXPECT_FALSE(scene().in_bounds(make_vector(1601.f, 900.f)));
|
|
|
EXPECT_FALSE(scene().in_bounds(make_vector(1600.f, 901.f)));
|
|
|
EXPECT_TRUE(scene().in_bounds(make_vector(1600.f, 900.f)));
|
|
|
// Upper-Left Corner
|
|
|
- EXPECT_FALSE(scene().in_bounds(make_vector( 0.f, 901.f)));
|
|
|
- EXPECT_FALSE(scene().in_bounds(make_vector( -1.f, 900.f)));
|
|
|
- EXPECT_TRUE(scene().in_bounds(make_vector( 0.f, 900.f)));
|
|
|
+ EXPECT_FALSE(scene().in_bounds(make_vector(0.f, 901.f)));
|
|
|
+ EXPECT_FALSE(scene().in_bounds(make_vector(-1.f, 900.f)));
|
|
|
+ EXPECT_TRUE(scene().in_bounds(make_vector(0.f, 900.f)));
|
|
|
}
|
|
|
|
|
|
TEST_P(BoundsTest, BoundsCheckOnCollidableIsAnyPointInBounds) {
|
|
|
math::dim2::square bounds = {GetParam(), 2.f};
|
|
|
engine::collidable collide{{{}, bounds, cast<graphics::material>(1), {}}};
|
|
|
-
|
|
|
+
|
|
|
EXPECT_TRUE(scene().in_bounds(&collide));
|
|
|
}
|
|
|
|
|
|
INSTANTIATE_TEST_CASE_P(Collidable, BoundsTest,
|
|
|
- ::testing::Values(make_vector( -1.f, -1.f),
|
|
|
- make_vector(1599.f, -1.f),
|
|
|
+ ::testing::Values(make_vector(-1.f, -1.f),
|
|
|
+ make_vector(1599.f, -1.f),
|
|
|
make_vector(1599.f, 899.f),
|
|
|
- make_vector( -1.f, 899.f)));
|
|
|
+ make_vector(-1.f, 899.f)));
|