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

Revision 1895, 3.8 KB checked in by mattausch, 18 years ago (diff)

added avg ray contrib

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
[1895]24        SubdivisionCandidate():
25                mRenderCostDecrease(0),
26                mAvgRayContribution(0),
27                mDirty(true)
28                {}
[1237]29
[1305]30        virtual ~SubdivisionCandidate() {};
[1895]31       
[1667]32        /** Evaluate this subdivision candidate.
33        */
34        virtual void EvalCandidate(bool computeSplitplane = true) = 0;
[1895]35       
[1667]36        /** Returns type of this subdivision candidate.
37        */
[1237]38        virtual int Type() const = 0;
[1895]39       
[1667]40        /** Evaluate this candidate and put results into queue for further traversal.
41        */
[1633]42        virtual bool Apply(SplitQueue &splitQueue, bool terminationCriteriaMet) = 0;
[1895]43       
[1667]44        /** Returns true of the global termination criteria of this split were met,
45                false otherwise.
46        */
[1237]47        virtual bool GlobalTerminationCriteriaMet() const = 0;
[1895]48       
[1684]49        /** Collects subdivision candidates that were affected by the
[1667]50                application of this one.
51        */
[1633]52        virtual void CollectDirtyCandidates(SubdivisionCandidateContainer &dirtyList,
53                                                                                const bool onlyUnmailed) = 0;
54
[1237]55        /** Set render cost decrease achieved through this split.
56        */
[1473]57        inline void SetRenderCostDecrease(const float renderCostDecr)
[1237]58        {
59                mRenderCostDecrease = renderCostDecr;
60        }
61       
[1473]62        inline float GetRenderCostDecrease() const
[1237]63        {
64                return mRenderCostDecrease;
65        }
66
[1895]67        /** The average ray contribution of this candidate .
68                This is somewhat of a confidence value into the computed values. If
69                it is high, there is likely to be a lot of undersampling.
70        */
71        inline void SetAvgRayContribution(const float rayContri)
72        {
73                mAvgRayContribution = rayContri;
74        }
75       
76        inline float GetAvgRayContribution() const
77        {
78                return mAvgRayContribution;
79        }
80
[1297]81        /** Position in queue.
82        */
[1576]83        inline int GetPosition() const
[1297]84        {
85                return mPosition;
86        }
87
[1576]88        inline void SetSplitAxis(const int splitAxis)
89        {
90                mSplitAxis = splitAxis;
91        }
[1667]92       
[1576]93        inline void SetMaxCostMisses(const int misses)
94        {
95                mMaxCostMisses = misses;
96        }
[1667]97
[1576]98        inline void SetPvsEntriesIncr(const int pvsEntriesIncr)
99        {
100                mPvsEntriesIncr = pvsEntriesIncr;
101        }
102
103        inline int GetSplitAxis() const
104        {
105                return mSplitAxis;
106        }
[1667]107
[1576]108        inline int GetMaxCostMisses() const
109        {
110                return mMaxCostMisses;
111        }
[1667]112
[1576]113        inline int GetPvsEntriesIncr() const
114        {
115                return mPvsEntriesIncr;
116        }
117
[1727]118        inline bool IsDirty() const
119        {
120                return mDirty;
121        }
[1667]122
[1733]123        inline void SetDirty(const bool dirty)
124        {
125                mDirty = dirty;
126        }
127
[1633]128        //////////
129        //-- mailing stuff
130
131        static void NewMail(const int reserve = 1)
132        {
133                sMailId += sReservedMailboxes;
134                sReservedMailboxes = reserve;
135        }
136
137        void Mail() { mMailbox = sMailId; }
138        bool Mailed() const { return mMailbox == sMailId; }
139
140        void Mail(const int mailbox) { mMailbox = sMailId + mailbox; }
141        bool Mailed(const int mailbox) const { return mMailbox == sMailId + mailbox; }
142
143        int IncMail() { return ++ mMailbox - sMailId; }
144
145
146        // last mail id -> warning not thread safe!
147        // both mailId and mailbox should be unique for each thread!!!
148        static int sMailId;
149        static int sReservedMailboxes;
150
[1684]151        void *mEvaluationHack;
[1733]152
[1576]153protected:
154
[1473]155        /// split axis of this plane (0, 1, 2, or 3 if non-axis-aligned)
156        int mSplitAxis;
157        /// the number of misses of max cost ratio until this split
158        int mMaxCostMisses;
[1237]159        /// render cost decrease achieved through this split
160        float mRenderCostDecrease;
[1576]161        /// the decrease of the number of pvs entries
162        int mPvsEntriesIncr;
[1633]163
[1895]164        /// the average ray contribution of this candidate
165        float mAvgRayContribution;
166
[1633]167        int mMailbox;
[1695]168
169        bool mDirty;
[1237]170};
171
[1313]172
[1237]173}
174
[1633]175// SUBDIVISIONCANDIDATE_H
[1237]176#endif
Note: See TracBrowser for help on using the repository browser.