OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CC_OUTPUT_BSP_CONTROLLER_H_ | |
6 #define CC_OUTPUT_BSP_CONTROLLER_H_ | |
7 | |
8 #include "cc/output/bsp_compare_result.h" | |
9 #include "cc/quads/draw_polygon.h" | |
10 | |
11 namespace cc { | |
12 | |
13 enum ViewCompareResult { IN_FRONT, BEHIND }; | |
Ian Vollick
2014/07/16 20:54:32
If we treat the camera plane as a splitting plane,
troyhildebrandt
2014/07/18 21:48:25
Done.
| |
14 | |
15 // Specialization of the BSP Controller abstract class that deals specifically | |
16 // with DrawPolygons | |
17 class BspController { | |
18 public: | |
19 BspController(float compare_thresh, float split_thresh) | |
Ian Vollick
2014/07/16 20:54:32
Could they be static constants in the cc file rath
troyhildebrandt
2014/07/18 21:48:25
Done.
| |
20 : compare_threshold_(compare_thresh), split_threshold_(split_thresh) {} | |
21 | |
22 // Returns whether or not nodeA is on one or the other side of nodeB, | |
23 // coplanar, or whether it crosses nodeB's plane and needs to be split | |
24 BspCompareResult GetNodePositionRelative(const DrawPolygon& node_a, | |
Ian Vollick
2014/07/16 20:54:32
Perhaps this could be static if the two thresholds
troyhildebrandt
2014/07/18 21:48:25
Done.
| |
25 const DrawPolygon& node_b) const; | |
26 // Returns whether or not our viewer is in front of or behind the plane | |
27 // defined by this polygon/node | |
28 ViewCompareResult GetCameraPositionRelative(const DrawPolygon& node) const; | |
29 bool SplitPolygon(scoped_ptr<DrawPolygon> polygon, | |
30 const DrawPolygon& splitter, | |
31 scoped_ptr<DrawPolygon>* front, | |
32 scoped_ptr<DrawPolygon>* back) const; | |
Ian Vollick
2014/07/16 20:54:32
Ditto.
troyhildebrandt
2014/07/18 21:48:25
Done.
| |
33 | |
34 // This heuristic uses the surface area of the polygon to determine whether | |
35 // or not a polygon is a good splitter. The idea is that if a polygon is | |
36 // larger, it is more likely to cross the planes of many other polygons, | |
37 // so using it as a splitter instead avoids many unnecessary splits. | |
Ian Vollick
2014/07/16 20:54:32
Is this a common heuristic?
troyhildebrandt
2014/07/18 21:48:25
I'm not certain if it is, it probably wouldn't hur
| |
38 virtual float SplitWeight(const DrawPolygon& polygon); | |
39 | |
40 private: | |
41 float compare_threshold_; | |
42 float split_threshold_; | |
43 }; | |
44 | |
45 } // namespace cc | |
46 | |
47 #endif // CC_OUTPUT_BSP_CONTROLLER_H_ | |
OLD | NEW |