source: GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Pvs.h @ 3287

Revision 3287, 1.7 KB checked in by mattausch, 15 years ago (diff)

worked on videos - still problems with strange white pixels

RevLine 
[3242]1#ifndef __PVS_H
2#define __PVS_H
3
[3243]4#include "common.h"
[3259]5#include "Bvh.h"
[3243]6
[3242]7namespace CHCDemoEngine
8{
9
[3259]10class BvhNode;
11class Bvh;
12
[3287]13//#define USE_TIMESTAMPS
[3285]14
[3284]15struct PvsEntry
16{
17        PvsEntry(SceneEntity *ent, float t):
18        mEntity(ent)
[3285]19#ifdef USE_TIMESTAMPS
20        , mTimeStamp(t)
21#endif
[3284]22        {}
[3259]23
[3284]24        friend bool operator<(const PvsEntry &a, const PvsEntry &b);
25
26
27        ///////////////
28
29        SceneEntity *mEntity;
[3285]30#ifdef USE_TIMESTAMPS
31        float mTimeStamp;
32#endif
[3284]33};
34
35
36
37
38typedef std::vector<PvsEntry> PvsEntryContainer;
39
40
[3259]41/** Class representing the Potentially Visible Set (PVS) from a view cell.
[3242]42*/
43class Pvs
44{
45public:
46
[3259]47        void Clear();
[3242]48
[3259]49        bool Empty() const;
[3284]50        /** Convencience method adding all scene entities associated with a bvh node.
51        */
52        void AddEntry(Bvh *bvh, BvhNode *node, float timeStamp = -1);
[3242]53
[3259]54        int GetSize() const;
[3242]55
[3284]56        inline SceneEntity *GetEntity(int i) const;
57       
58        inline PvsEntry GetEntry(int i) const;
[3242]59
[3284]60        inline void AddEntry(const PvsEntry &entry);
61        /* Sort entries by timestamp
62        */
63        void Sort();
[3242]64
[3259]65
[3242]66protected:
67
[3283]68        /// vector of PVS entries
[3284]69        PvsEntryContainer mEntries;
[3242]70};
71
[3259]72
[3284]73inline SceneEntity *Pvs::GetEntity(int i) const
[3259]74{
[3284]75        return mEntries[i].mEntity;
76}
77
78
79inline PvsEntry Pvs::GetEntry(int i) const
80{
[3259]81        return mEntries[i];
[3242]82}
83
[3259]84
[3284]85inline void Pvs::AddEntry(const PvsEntry &entry)
[3259]86{
[3284]87        mEntries.push_back(entry);
[3259]88}
89
90
91inline int Pvs::GetSize() const
92{
93        return (int)mEntries.size();
94}
95
96
[3284]97inline void Pvs::AddEntry(Bvh *bvh, BvhNode *node, float timeStamp)
[3259]98{
99        int geometrySize;
100        SceneEntity **entities;
101        entities = bvh->GetGeometry(node, geometrySize);
102
103        for (int i = 0; i < geometrySize; ++ i)
104        {
[3284]105                AddEntry(PvsEntry(entities[i], timeStamp));
[3259]106        }
107}
108
109
[3284]110
[3259]111}
112
[3243]113#endif
Note: See TracBrowser for help on using the repository browser.