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

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