MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / TEST

Function TEST

source/test/world_geometry_test.cpp:8–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6using namespace Star;
7
8TEST(WorldGeometryTest, All) {
9 WorldGeometry geom = WorldGeometry(Vec2U{8192, 3072});
10
11 PolyF shapeA = {
12 {19.9954f, 1603.62f}, {21.9954f, 1602.62f}, {21.9954f, 1607.62f}, {19.9954f, 1606.62f}, {19.9954f, 1605.12f}};
13 Line2F lineA = {{20.9575f, 1605.13f}, {21.7853f, 1605.03f}};
14
15 EXPECT_TRUE(geom.lineIntersectsPoly(lineA, shapeA));
16
17 PolyF shapeA2 = {{0.9954f, 1.62f}, {2.9954f, 0.62f}, {2.9954f, 5.62f}, {0.9954f, 4.62f}, {0.9954f, 3.12f}};
18 Line2F lineA2 = {{1.9575f, 3.13f}, {2.7853f, 3.03f}};
19
20 EXPECT_TRUE(geom.lineIntersectsPoly(lineA2, shapeA2));
21
22 PolyF shapeA3 = {{-10.0f, -10.0f}, {10, -10.0f}, {10.0f, 10.0f}, {-10.0f, 10.0f}}; //, {-10, 3.12};
23 Line2F lineA3 = {{1.9575f, 3.13f}, {2.7853f, 3.03f}};
24
25 EXPECT_TRUE(geom.lineIntersectsPoly(lineA3, shapeA3));
26
27 RectF shapeA3R = RectF::withSize({-10, -10}, {20, 20});
28
29 EXPECT_TRUE(geom.lineIntersectsRect(lineA3, shapeA3R));
30
31 PolyF shapeB = {
32 {20.5608f, 1603.62f}, {22.5608f, 1602.62f}, {22.5608f, 1607.62f}, {20.5608f, 1606.62f}, {20.5608f, 1605.12f}};
33 Line2F lineB = {{21.7893f, 1605.07f}, {22.6173f, 1604.98f}};
34
35 EXPECT_TRUE(geom.lineIntersectsPoly(lineB, shapeB));
36
37 PolyF shapeC = {{-10.0f, -10.0f}, {10.0f, -10.0f}, {10.0f, 10.0f}, {-10.0f, 10.0f}};
38 PolyF shapeC2 = {{-1.0f, -1.0f}, {1.0f, -1.0f}, {1.0f, 1.0f}, {-1.0f, 1.0f}};
39
40 EXPECT_TRUE(geom.polyIntersectsPoly(shapeC2, shapeC));
41 EXPECT_TRUE(geom.polyIntersectsPoly(shapeC, shapeC2));
42 EXPECT_TRUE(geom.polyContains(shapeC, Vec2F(0, 0)));
43 EXPECT_TRUE(fabs(geom.polyOverlapArea(shapeC, shapeC2) - 4) < 0.0001f);
44}

Callers

nothing calls this directly

Calls 6

WorldGeometryClass · 0.85
lineIntersectsPolyMethod · 0.80
lineIntersectsRectMethod · 0.80
polyIntersectsPolyMethod · 0.80
polyOverlapAreaMethod · 0.80
polyContainsMethod · 0.45

Tested by

no test coverage detected