1 | #ifndef SUBDIVISIONCANDIDATE_H
|
---|
2 | #define SUBDIVISIONCANDIDATE_H
|
---|
3 |
|
---|
4 |
|
---|
5 | #include "FlexibleHeap.h"
|
---|
6 |
|
---|
7 | using namespace std;
|
---|
8 |
|
---|
9 | namespace GtpVisibilityPreprocessor {
|
---|
10 |
|
---|
11 | class SubdivisionCandidate;
|
---|
12 |
|
---|
13 | typedef vector<SubdivisionCandidate *> SubdivisionCandidateContainer;
|
---|
14 | typedef FlexibleHeap<SubdivisionCandidate *> SplitQueue;
|
---|
15 |
|
---|
16 | /** Candidate for a view space / object space split.
|
---|
17 | */
|
---|
18 | class SubdivisionCandidate: public Heapable
|
---|
19 | {
|
---|
20 | public:
|
---|
21 |
|
---|
22 | enum {OBJECT_SPACE, VIEW_SPACE};
|
---|
23 |
|
---|
24 | SubdivisionCandidate(): mRenderCostDecrease(0) {};
|
---|
25 |
|
---|
26 | virtual ~SubdivisionCandidate() {};
|
---|
27 | virtual void EvalPriority(bool computeSplitplane = true) = 0;
|
---|
28 | virtual int Type() const = 0;
|
---|
29 | virtual bool Apply(SplitQueue &splitQueue, bool terminationCriteriaMet) = 0;
|
---|
30 | virtual bool GlobalTerminationCriteriaMet() const = 0;
|
---|
31 |
|
---|
32 | virtual void CollectDirtyCandidates(SubdivisionCandidateContainer &dirtyList,
|
---|
33 | const bool onlyUnmailed) = 0;
|
---|
34 |
|
---|
35 | /** Set render cost decrease achieved through this split.
|
---|
36 | */
|
---|
37 | inline void SetRenderCostDecrease(const float renderCostDecr)
|
---|
38 | {
|
---|
39 | mRenderCostDecrease = renderCostDecr;
|
---|
40 | }
|
---|
41 |
|
---|
42 | inline float GetRenderCostDecrease() const
|
---|
43 | {
|
---|
44 | return mRenderCostDecrease;
|
---|
45 | }
|
---|
46 |
|
---|
47 | /** Position in queue.
|
---|
48 | */
|
---|
49 | inline int GetPosition() const
|
---|
50 | {
|
---|
51 | return mPosition;
|
---|
52 | }
|
---|
53 |
|
---|
54 | inline void SetSplitAxis(const int splitAxis)
|
---|
55 | {
|
---|
56 | mSplitAxis = splitAxis;
|
---|
57 | }
|
---|
58 | inline void SetMaxCostMisses(const int misses)
|
---|
59 | {
|
---|
60 | mMaxCostMisses = misses;
|
---|
61 | }
|
---|
62 | inline void SetPvsEntriesIncr(const int pvsEntriesIncr)
|
---|
63 | {
|
---|
64 | mPvsEntriesIncr = pvsEntriesIncr;
|
---|
65 | }
|
---|
66 |
|
---|
67 | inline int GetSplitAxis() const
|
---|
68 | {
|
---|
69 | return mSplitAxis;
|
---|
70 | }
|
---|
71 | inline int GetMaxCostMisses() const
|
---|
72 | {
|
---|
73 | return mMaxCostMisses;
|
---|
74 | }
|
---|
75 | inline int GetPvsEntriesIncr() const
|
---|
76 | {
|
---|
77 | return mPvsEntriesIncr;
|
---|
78 | }
|
---|
79 |
|
---|
80 | //////////
|
---|
81 | //-- mailing stuff
|
---|
82 |
|
---|
83 | static void NewMail(const int reserve = 1)
|
---|
84 | {
|
---|
85 | sMailId += sReservedMailboxes;
|
---|
86 | sReservedMailboxes = reserve;
|
---|
87 | }
|
---|
88 |
|
---|
89 | void Mail() { mMailbox = sMailId; }
|
---|
90 | bool Mailed() const { return mMailbox == sMailId; }
|
---|
91 |
|
---|
92 | void Mail(const int mailbox) { mMailbox = sMailId + mailbox; }
|
---|
93 | bool Mailed(const int mailbox) const { return mMailbox == sMailId + mailbox; }
|
---|
94 |
|
---|
95 | int IncMail() { return ++ mMailbox - sMailId; }
|
---|
96 |
|
---|
97 |
|
---|
98 | // last mail id -> warning not thread safe!
|
---|
99 | // both mailId and mailbox should be unique for each thread!!!
|
---|
100 | static int sMailId;
|
---|
101 | static int sReservedMailboxes;
|
---|
102 |
|
---|
103 | protected:
|
---|
104 |
|
---|
105 | /// split axis of this plane (0, 1, 2, or 3 if non-axis-aligned)
|
---|
106 | int mSplitAxis;
|
---|
107 | /// the number of misses of max cost ratio until this split
|
---|
108 | int mMaxCostMisses;
|
---|
109 | /// render cost decrease achieved through this split
|
---|
110 | float mRenderCostDecrease;
|
---|
111 | /// the decrease of the number of pvs entries
|
---|
112 | int mPvsEntriesIncr;
|
---|
113 |
|
---|
114 | int mMailbox;
|
---|
115 | };
|
---|
116 |
|
---|
117 |
|
---|
118 | }
|
---|
119 |
|
---|
120 | // SUBDIVISIONCANDIDATE_H
|
---|
121 | #endif
|
---|