source: GTP/trunk/Lib/Vis/Preprocessing/src/SubdivisionCandidate.h @ 1733

Revision 1733, 3.3 KB checked in by mattausch, 18 years ago (diff)

removed bug from dirtycandidates

RevLine 
[1239]1#ifndef SUBDIVISIONCANDIDATE_H
2#define SUBDIVISIONCANDIDATE_H
[1237]3
[1239]4
[1237]5#include "FlexibleHeap.h"
6
7using namespace std;
8
9namespace GtpVisibilityPreprocessor {
10
[1633]11class SubdivisionCandidate;
12
13typedef vector<SubdivisionCandidate *> SubdivisionCandidateContainer;
14typedef FlexibleHeap<SubdivisionCandidate *> SplitQueue;
15
[1237]16/** Candidate for a view space / object space split.
17*/
18class SubdivisionCandidate: public Heapable
19
20public:
21
22        enum {OBJECT_SPACE, VIEW_SPACE};
23
[1695]24        SubdivisionCandidate(): mRenderCostDecrease(0), mDirty(true) {};
[1237]25
[1305]26        virtual ~SubdivisionCandidate() {};
[1667]27        /** Evaluate this subdivision candidate.
28        */
29        virtual void EvalCandidate(bool computeSplitplane = true) = 0;
30        /** Returns type of this subdivision candidate.
31        */
[1237]32        virtual int Type() const = 0;
[1667]33        /** Evaluate this candidate and put results into queue for further traversal.
34        */
[1633]35        virtual bool Apply(SplitQueue &splitQueue, bool terminationCriteriaMet) = 0;
[1667]36        /** Returns true of the global termination criteria of this split were met,
37                false otherwise.
38        */
[1237]39        virtual bool GlobalTerminationCriteriaMet() const = 0;
[1684]40        /** Collects subdivision candidates that were affected by the
[1667]41                application of this one.
42        */
[1633]43        virtual void CollectDirtyCandidates(SubdivisionCandidateContainer &dirtyList,
44                                                                                const bool onlyUnmailed) = 0;
45
[1237]46        /** Set render cost decrease achieved through this split.
47        */
[1473]48        inline void SetRenderCostDecrease(const float renderCostDecr)
[1237]49        {
50                mRenderCostDecrease = renderCostDecr;
51        }
52       
[1473]53        inline float GetRenderCostDecrease() const
[1237]54        {
55                return mRenderCostDecrease;
56        }
57
[1297]58        /** Position in queue.
59        */
[1576]60        inline int GetPosition() const
[1297]61        {
62                return mPosition;
63        }
64
[1576]65        inline void SetSplitAxis(const int splitAxis)
66        {
67                mSplitAxis = splitAxis;
68        }
[1667]69       
[1576]70        inline void SetMaxCostMisses(const int misses)
71        {
72                mMaxCostMisses = misses;
73        }
[1667]74
[1576]75        inline void SetPvsEntriesIncr(const int pvsEntriesIncr)
76        {
77                mPvsEntriesIncr = pvsEntriesIncr;
78        }
79
80        inline int GetSplitAxis() const
81        {
82                return mSplitAxis;
83        }
[1667]84
[1576]85        inline int GetMaxCostMisses() const
86        {
87                return mMaxCostMisses;
88        }
[1667]89
[1576]90        inline int GetPvsEntriesIncr() const
91        {
92                return mPvsEntriesIncr;
93        }
94
[1727]95        inline bool IsDirty() const
96        {
97                return mDirty;
98        }
[1667]99
[1733]100        inline void SetDirty(const bool dirty)
101        {
102                mDirty = dirty;
103        }
104
[1633]105        //////////
106        //-- mailing stuff
107
108        static void NewMail(const int reserve = 1)
109        {
110                sMailId += sReservedMailboxes;
111                sReservedMailboxes = reserve;
112        }
113
114        void Mail() { mMailbox = sMailId; }
115        bool Mailed() const { return mMailbox == sMailId; }
116
117        void Mail(const int mailbox) { mMailbox = sMailId + mailbox; }
118        bool Mailed(const int mailbox) const { return mMailbox == sMailId + mailbox; }
119
120        int IncMail() { return ++ mMailbox - sMailId; }
121
122
123        // last mail id -> warning not thread safe!
124        // both mailId and mailbox should be unique for each thread!!!
125        static int sMailId;
126        static int sReservedMailboxes;
127
[1684]128        void *mEvaluationHack;
[1733]129
[1576]130protected:
131
[1473]132        /// split axis of this plane (0, 1, 2, or 3 if non-axis-aligned)
133        int mSplitAxis;
134        /// the number of misses of max cost ratio until this split
135        int mMaxCostMisses;
[1237]136        /// render cost decrease achieved through this split
137        float mRenderCostDecrease;
[1576]138        /// the decrease of the number of pvs entries
139        int mPvsEntriesIncr;
[1633]140
141        int mMailbox;
[1695]142
143        bool mDirty;
[1237]144};
145
[1313]146
[1237]147}
148
[1633]149// SUBDIVISIONCANDIDATE_H
[1237]150#endif
Note: See TracBrowser for help on using the repository browser.