From bce297cc9cae657e3a4b0539dc50cf61a77d0103 Mon Sep 17 00:00:00 2001 From: petermayo Date: Fri, 6 Nov 2015 13:56:25 -0800 Subject: Decrease the presumed thickness of polygons. This addresses some of the common expectations that single digit differences in Z value will change rendering order. BUG=499397 R=flackr@chromium.org TEST=Rendering of Z stacked boxes, test case in bug. CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1412143004 Cr-Commit-Position: refs/heads/master@{#358416} --- cc/quads/draw_polygon.cc | 4 ++-- cc/quads/draw_polygon_unittest.cc | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) (limited to 'cc/quads') 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 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 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 vertices_a; -- cgit v1.1