Index: cc/output/bsp_tree.cc |
diff --git a/cc/output/bsp_tree.cc b/cc/output/bsp_tree.cc |
index 080866f58f9a9bd8c9ed222d802906a48f6eac6c..300ba2aebb98a3e5527818c4c776fbb203d36b54 100644 |
--- a/cc/output/bsp_tree.cc |
+++ b/cc/output/bsp_tree.cc |
@@ -44,46 +44,24 @@ void BspTree::BuildTree( |
// find a splitting plane, then classify polygons as either in front of |
// or behind that splitting plane. |
while (!polygon_list->empty()) { |
- // Is this particular polygon in front of or behind our splitting polygon. |
- BspCompareResult comparer_result = |
- GetNodePositionRelative(*polygon_list->front(), *(node->node_data)); |
- |
- // If it's clearly behind or in front of the splitting plane, we use the |
- // heuristic to decide whether or not we should put it at the back |
- // or front of the list. |
- switch (comparer_result) { |
- case BSP_FRONT: |
- front_list.push_back(PopFront(polygon_list)); |
- break; |
- case BSP_BACK: |
- back_list.push_back(PopFront(polygon_list)); |
- break; |
- case BSP_SPLIT: |
- { |
- std::unique_ptr<DrawPolygon> polygon; |
- std::unique_ptr<DrawPolygon> new_front; |
- std::unique_ptr<DrawPolygon> new_back; |
- // Time to split this geometry, *it needs to be split by node_data. |
- polygon = PopFront(polygon_list); |
- bool split_result = |
- polygon->Split(*(node->node_data), &new_front, &new_back); |
- DCHECK(split_result); |
- if (!split_result) { |
- break; |
- } |
+ std::unique_ptr<DrawPolygon> polygon; |
+ std::unique_ptr<DrawPolygon> new_front; |
+ std::unique_ptr<DrawPolygon> new_back; |
+ // Time to split this geometry, *it needs to be split by node_data. |
+ polygon = PopFront(polygon_list); |
+ bool is_coplanar; |
+ node->node_data->SplitPolygon(std::move(polygon), &new_front, &new_back, |
+ &is_coplanar); |
+ if (is_coplanar) { |
+ if (new_front) |
+ node->coplanars_front.push_back(std::move(new_front)); |
+ if (new_back) |
+ node->coplanars_back.push_back(std::move(new_back)); |
+ } else { |
+ if (new_front) |
front_list.push_back(std::move(new_front)); |
+ if (new_back) |
back_list.push_back(std::move(new_back)); |
- break; |
- } |
- case BSP_COPLANAR_FRONT: |
- node->coplanars_front.push_back(PopFront(polygon_list)); |
- break; |
- case BSP_COPLANAR_BACK: |
- node->coplanars_back.push_back(PopFront(polygon_list)); |
- break; |
- default: |
- NOTREACHED(); |
- break; |
} |
} |
@@ -100,11 +78,6 @@ void BspTree::BuildTree( |
} |
} |
-BspCompareResult BspTree::GetNodePositionRelative(const DrawPolygon& node_a, |
- const DrawPolygon& node_b) { |
- return DrawPolygon::SideCompare(node_a, node_b); |
-} |
- |
// The base comparer with 0,0,0 as camera position facing forward |
BspCompareResult BspTree::GetCameraPositionRelative(const DrawPolygon& node) { |
if (node.normal().z() > 0.0f) { |