1 | #include <iostream>
|
---|
2 | using namespace std;
|
---|
3 | #include "Pvs.h"
|
---|
4 | #include "Intersectable.h"
|
---|
5 |
|
---|
6 | KdPvsData *
|
---|
7 | KdPvs::Find(KdNode *node)
|
---|
8 | {
|
---|
9 | KdPvsMap::iterator i = mEntries.find(node);
|
---|
10 | if (i != mEntries.end()) {
|
---|
11 | // cout<<node<<" "<<(*i).first<<" "<<(*i).second.mVisibleSamples<<endl;
|
---|
12 | return &(*i).second;
|
---|
13 | } else
|
---|
14 | return NULL;
|
---|
15 | }
|
---|
16 |
|
---|
17 | int
|
---|
18 | KdPvs::AddNodeSample(KdNode *node)
|
---|
19 | {
|
---|
20 | int result;
|
---|
21 |
|
---|
22 | KdPvsData *data = Find(node);
|
---|
23 | if (data) {
|
---|
24 | data->mVisibleSamples++;
|
---|
25 | result = 0;
|
---|
26 | } else {
|
---|
27 | mEntries[node] = KdPvsData(1);
|
---|
28 | result = 1;
|
---|
29 | }
|
---|
30 | return result;
|
---|
31 | }
|
---|
32 |
|
---|
33 |
|
---|
34 | void
|
---|
35 | KdPvs::GetData(const int index,
|
---|
36 | KdNode *&node,
|
---|
37 | KdPvsData &data
|
---|
38 | )
|
---|
39 | {
|
---|
40 | KdPvsMap::iterator i = mEntries.begin();
|
---|
41 | for (int k = 0; k!=index && i != mEntries.end(); i++, k++);
|
---|
42 | node = (*i).first;
|
---|
43 | data = (*i).second;
|
---|
44 | }
|
---|
45 |
|
---|
46 | BspPvsData *BspPvs::Find(BspNode *node)
|
---|
47 | {
|
---|
48 | BspPvsMap::iterator i = mEntries.find(node);
|
---|
49 |
|
---|
50 | if (i != mEntries.end())
|
---|
51 | {
|
---|
52 | // cout<<node<<" "<<(*i).first<<" "<<(*i).second.mVisibleSamples<<endl;
|
---|
53 | return &(*i).second;
|
---|
54 | }
|
---|
55 | else
|
---|
56 | return NULL;
|
---|
57 | }
|
---|
58 |
|
---|
59 | // TODO: Get common ancestor for bsp and kd tree (HierarchyNode)
|
---|
60 | int BspPvs::AddNodeSample(BspNode *node)
|
---|
61 | {
|
---|
62 | int result;
|
---|
63 |
|
---|
64 | BspPvsData *data = Find(node);
|
---|
65 |
|
---|
66 | if (data)
|
---|
67 | {
|
---|
68 | data->mVisibleSamples ++;
|
---|
69 | result = 0;
|
---|
70 | }
|
---|
71 | else
|
---|
72 | {
|
---|
73 | mEntries[node] = BspPvsData(1);
|
---|
74 | result = 1;
|
---|
75 | }
|
---|
76 |
|
---|
77 | return result;
|
---|
78 | }
|
---|
79 |
|
---|
80 |
|
---|
81 | void BspPvs::GetData(const int index, BspNode *&node, BspPvsData &data)
|
---|
82 | {
|
---|
83 | BspPvsMap::iterator i = mEntries.begin();
|
---|
84 |
|
---|
85 | for (int k = 0; k!=index && i != mEntries.end(); i++, k++);
|
---|
86 |
|
---|
87 | node = (*i).first;
|
---|
88 | data = (*i).second;
|
---|
89 | }
|
---|
90 |
|
---|
91 | ViewCellPvsData *ViewCellPvs::Find(Intersectable *obj)
|
---|
92 | {
|
---|
93 | ViewCellPvsMap::iterator i = mEntries.find(obj);
|
---|
94 |
|
---|
95 | if (i != mEntries.end())
|
---|
96 | {
|
---|
97 | // cout<<node<<" "<<(*i).first<<" "<<(*i).second.mVisibleSamples<<endl;
|
---|
98 | return &(*i).second;
|
---|
99 | }
|
---|
100 | else
|
---|
101 | return NULL;
|
---|
102 | }
|
---|
103 |
|
---|
104 | int ViewCellPvs::AddObject(Intersectable *obj)
|
---|
105 | {
|
---|
106 | int result;
|
---|
107 |
|
---|
108 | ViewCellPvsData *data = Find(obj);
|
---|
109 |
|
---|
110 | if (data)
|
---|
111 | {
|
---|
112 | data->mVisibleSamples ++;
|
---|
113 | result = 0;
|
---|
114 | }
|
---|
115 | else
|
---|
116 | {
|
---|
117 | mEntries[obj] = ViewCellPvsData(1);
|
---|
118 | result = 1;
|
---|
119 | }
|
---|
120 |
|
---|
121 | return result;
|
---|
122 | }
|
---|
123 |
|
---|
124 | void ViewCellPvs::GetData(const int index, Intersectable *&obj, ViewCellPvsData &data)
|
---|
125 | {
|
---|
126 | ViewCellPvsMap::iterator i = mEntries.begin();
|
---|
127 |
|
---|
128 | for (int k = 0; k!=index && i != mEntries.end(); i++, k++);
|
---|
129 |
|
---|
130 | obj = (*i).first;
|
---|
131 | data = (*i).second;
|
---|
132 | }
|
---|