diff options
-rw-r--r-- | cc/quads/draw_polygon.cc | 4 | ||||
-rw-r--r-- | cc/quads/draw_polygon_unittest.cc | 21 |
2 files changed, 23 insertions, 2 deletions
diff --git a/cc/quads/draw_polygon.cc b/cc/quads/draw_polygon.cc index 9ff1af6..02c1283 100644 --- a/cc/quads/draw_polygon.cc +++ b/cc/quads/draw_polygon.cc @@ -16,7 +16,7 @@ static const float coplanar_dot_epsilon = 0.001f; // This threshold controls how "thick" a plane is. If a point's distance is // <= |compare_threshold|, then it is considered on the plane. Only when this // boundary is crossed do we consider doing splitting. -static const float compare_threshold = 1.0f; +static const float compare_threshold = 0.1f; // |split_threshold| is lower in this case because we want the points created // during splitting to be well within the range of |compare_threshold| for // comparison purposes. The splitting operation will produce intersection points @@ -27,7 +27,7 @@ static const float compare_threshold = 1.0f; // this range. // This is really supposd to be compare_threshold / 2.0f, but that would // create another static initializer. -static const float split_threshold = 0.5f; +static const float split_threshold = 0.05f; static const float normalized_threshold = 0.001f; } // namespace diff --git a/cc/quads/draw_polygon_unittest.cc b/cc/quads/draw_polygon_unittest.cc index 517e131..caf0f27 100644 --- a/cc/quads/draw_polygon_unittest.cc +++ b/cc/quads/draw_polygon_unittest.cc @@ -32,6 +32,27 @@ static void ValidatePoints(const DrawPolygon& polygon, } } +// Two quads are nearly touching but definitely ordered. Second one should +// compare in front. +TEST(DrawPolygonSplitTest, NearlyTouchingOrder) { + std::vector<gfx::Point3F> vertices_a; + vertices_a.push_back(gfx::Point3F(0.0f, 10.0f, 0.0f)); + vertices_a.push_back(gfx::Point3F(0.0f, 0.0f, 0.0f)); + vertices_a.push_back(gfx::Point3F(10.0f, 0.0f, 0.0f)); + vertices_a.push_back(gfx::Point3F(10.0f, 10.0f, 0.0f)); + std::vector<gfx::Point3F> vertices_b; + vertices_b.push_back(gfx::Point3F(0.0f, 10.0f, -1.0f)); + vertices_b.push_back(gfx::Point3F(0.0f, 0.0f, -1.0f)); + vertices_b.push_back(gfx::Point3F(10.0f, 0.0f, -1.0f)); + vertices_b.push_back(gfx::Point3F(10.0f, 10.0f, -1.0f)); + gfx::Vector3dF normal(0.0f, 0.0f, 1.0f); + + CREATE_NEW_DRAW_POLYGON(polygon_a, vertices_a, normal, 0); + CREATE_NEW_DRAW_POLYGON(polygon_b, vertices_b, normal, 1); + + EXPECT_EQ(BSP_BACK, DrawPolygon::SideCompare(polygon_b, polygon_a)); +} + // Two quads are definitely not touching and so no split should occur. TEST(DrawPolygonSplitTest, NotTouchingNoSplit) { std::vector<gfx::Point3F> vertices_a; |