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

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

worked on videos - still problems with strange white pixels

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