source: trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.h @ 471

Revision 471, 2.7 KB checked in by mattausch, 19 years ago (diff)

fixed rendersimulator

Line 
1#ifndef _ViewCell_H__
2#define _ViewCell_H__
3
4#include "Mesh.h"
5#include "Containers.h"
6#include "Ray.h"
7#include "Statistics.h"
8//namespace GtpVisibilityPreprocessor {
9
10struct Triangle3;
11
12class BspInterior;
13class BspPvs;
14class BspLeaf;
15class VspKdTree;
16class VspKdLeaf;
17class KdLeaf;
18
19/**
20        View cell with an optional mesh representation
21*/
22class ViewCell: public MeshInstance
23{
24public:
25        ViewCell();
26
27        /** Constructor taking a mesh representing the shape of the viewcell.
28        */
29        ViewCell(Mesh *mesh);
30
31        /** Default destructor.
32        */
33        virtual ~ViewCell() {}
34        /** Returns Pvs.
35        */
36        const ObjectPvs &GetPvs() const;
37        ObjectPvs &GetPvs();
38
39        int Type() const;
40
41        /** Adds a passing ray to the passing ray container.
42        */
43        void AddPassingRay(const Ray &ray, const int contributions);
44
45        /** Returns volume of the view cell.
46        */
47        virtual float GetVolume() const;
48
49        /** Sets volume of the view cell.
50        */
51        void SetVolume(float size);
52
53        /// Ray set description of the rays passing through this node.
54        PassingRaySet mPassingRays;
55
56        /// Rays piercing this view cell.
57        RayContainer mPiercingRays;
58
59protected:
60
61        /// the potentially visible objects
62        ObjectPvs mPvs;
63
64        float mVolume;
65};
66
67/**
68        View cell belonging to a hierarchy.
69*/
70template<typename T>
71class HierarchyViewCell: public ViewCell
72{
73public:
74        HierarchyViewCell<T>(): mLeaves(0) {}
75        HierarchyViewCell<T>(Mesh *mesh):
76                ViewCell(mesh), mLeaves(0) {}
77
78        /// Leaves of the hierarchy which are part of this view cell.
79        std::vector<T> mLeaves;
80};
81
82typedef HierarchyViewCell<BspLeaf *> BspViewCell;
83typedef HierarchyViewCell<KdLeaf *> KdViewCell;
84typedef HierarchyViewCell<VspKdLeaf *> VspKdViewCell;
85
86
87/** Statistics for a view cell partition.
88*/
89
90class ViewCellsStatistics: public StatisticsBase
91{
92public:
93
94        /// number of view cells
95        int viewCells;
96
97        /// size of the PVS
98        int pvs;
99
100        /// largest PVS of all view cells
101        int maxPvs;
102
103        /// smallest PVS of all view cells
104        int minPvs;
105
106        /// view cells with empty PVS
107        int emptyPvs;
108
109        /// number of leaves covering the view space
110        int leaves;
111
112        /// largest number of leaves covered by one view cell
113        int maxLeaves;
114
115    // Constructor
116        ViewCellsStatistics()
117        {
118                Reset();
119        }
120
121        double AvgLeaves() const {return (double)leaves / (double)viewCells;};
122        double AvgPvs() const {return (double)pvs / (double)viewCells;};
123
124        void Reset()
125        {
126                viewCells = 0;
127                pvs = 0;
128                maxPvs = 0;
129
130                minPvs = 999999;
131                emptyPvs = 0;
132                leaves = 0;
133                maxLeaves = 0;
134        }
135
136        void Print(ostream &app) const;
137
138        friend ostream &operator<<(ostream &s, const ViewCellsStatistics &stat)
139        {
140                stat.Print(s);
141                return s;
142        }
143};
144
145#endif
Note: See TracBrowser for help on using the repository browser.