source: GTP/trunk/Lib/Vis/OnlineCullingCHC/include/HierarchyInterface.h @ 726

Revision 726, 6.2 KB checked in by mattausch, 18 years ago (diff)

improved performance of TerrainSceneManager?
revisit octreescenemanager

RevLine 
[59]1#ifndef _GtpVisibilityHierarchyInterface_H__
2#define _GtpVisibilityHierarchyInterface_H__
3
4#include "DistanceQueue.h"
[130]5#include "VisibilityMesh.h"
[155]6#include <stack>
[59]7
8namespace GtpVisibility {
9
[112]10enum  CullingType {QUERY_CULLED, FRUSTUM_CULLED};
11
[370]12typedef std::vector<HierarchyNode *> NodeVector;
13typedef std::vector<GtpVisibility::Mesh *> GeometryVector;
14typedef std::vector<GtpVisibility::Patch *> PatchVector;
[130]15typedef std::pair<HierarchyNode *, OcclusionQuery *> QueryPair;
[370]16typedef std::pair<HierarchyNode *, bool> PendingQuery;
[130]17typedef std::queue<QueryPair> QueryQueue;
[370]18typedef std::queue<PendingQuery> PendingQueue;
[130]19
[158]20
[59]21/**     Class which implements a hierarchy interface for a scene hierarchy.
22*/
23class HierarchyInterface
24{
25public:
26        /** Default constructor.
27        */
28        HierarchyInterface();
29        virtual ~HierarchyInterface();
30        /** Returns true if current node is leaf of the hierarchy.
31                @param node hierarchy node
32                @returns true if node is leaf
33        */
[74]34    virtual bool IsLeaf(HierarchyNode *node) const = 0;
[155]35        /** Traverses and renders the given node.
[59]36                @param node the hierarchy node
37        */
[158]38        virtual void TraverseNode(HierarchyNode *node) = 0;
[130]39        /** Renders current hierarchy node.
40                @param node current hierarchy node to be rendered
[59]41        */
42        virtual void RenderNode(HierarchyNode *node) = 0;
43        /** Pulls up the visibility from the current node recursively to the parent nodes.
44                @param node the current node
45        */
[345]46        virtual void PullUpVisibility(HierarchyNode *node) const = 0;
[59]47        /** Issue a occlusion query for this node.
48                @param node the current hierarchy node
49                @returns occlusion query for this node
50        */
[175]51        virtual OcclusionQuery *IssueNodeOcclusionQuery(HierarchyNode *node,
[86]52                const bool wasVisible = false) = 0;
[59]53        /** Sets the root of the scene hierarchy.
54                @param root the hierarchy root
55        */
[155]56        void SetHierarchyRoot(HierarchyNode *root);
[74]57    /** Get the root of the scene hierarchy.
58                @return the hierarchy root
59        */
[155]60        HierarchyNode *GetHierarchyRoot() const;
[158]61        /** Sets the scene root and initialises this hierarchy interface for a traversal.               
[155]62                @remark also resets the statistics evaluated in the last traversal
[59]63        */
[158]64        void InitTraversal();
[59]65        /** Returns current frame id.
66                @returns frame id
67        */
[74]68        unsigned int GetFrameId() const;
[155]69        /** Returns a pointer to the distance queue.
70                @returns current distance queue.
71                @remark the distance queue stores hierarchy nodes in a front-to-back order
[59]72        */
73        DistanceQueue *GetQueue();
[726]74       
[87]75        /** Returns distance of the node to the view plane.
[726]76                @param node the hierarchy node
[59]77        */                     
[87]78        virtual float GetSquaredDistance(HierarchyNode *node) const = 0;
[59]79        /** Checks if the node is visible from the current view frustum.
80                @param node the current node
81                @param intersects returns true if the current node intersects the near plane
82        */
83        virtual bool CheckFrustumVisible(HierarchyNode *node, bool &intersects) = 0;
[74]84        /** Checks if the node is visible from the current view frustum.
85                @param node the current node
86        */
87        bool CheckFrustumVisible(HierarchyNode *node);
[59]88        /** Returns next available occlusion query or creates new one.
89                @return the next occlusion query
90        */
91        virtual OcclusionQuery *GetNextOcclusionQuery() = 0;
92        /** Returns true if there is renderable geometry attached to this node
93                @param node the current node
94                @returns if the node has renderable geometry
95        */
[74]96    virtual bool HasGeometry(HierarchyNode *node) const = 0;
[59]97        /** Sets the visible flag for this node.
98                @param node the current node
99                @param visible the visible flag
100        */
[345]101        virtual void SetNodeVisible(HierarchyNode *node, const bool visible) const = 0;
[59]102        /** Returns true if node has the visible flag set. See set
103        */
[74]104        virtual bool IsNodeVisible(HierarchyNode *node) const = 0;
[59]105        /** Sets the last visited frame id for this node.
106                @param node the current node
107                @param frameId the current frame id
108        */
[74]109        virtual void SetLastVisited(HierarchyNode *node,
[345]110                                                                const unsigned int frameId) const = 0;
[59]111        /** Returns frame id when this node was last visited by the traverser. See set
112        */
[74]113        virtual unsigned int LastVisited(HierarchyNode *node) const = 0;
114        /** Returns number of traversed nodes.
115        */
116        unsigned int GetNumTraversedNodes();
117        /** Returns number of rendered nodes.
118        */
119        unsigned int GetNumRenderedNodes();
[155]120               
[112]121        //bool mIsShadowPass;
[59]122
[112]123        /** Visualization of a culled node, dependent on the culling type.
124                @param type can be one of FRUSTUM_CULLED, QUERY_CULLED
125        */
126        virtual void VisualizeCulledNode(HierarchyNode *node,
[345]127                CullingType type) const = 0;
[111]128
[175]129        /** Returns vector of visible hierarchy nodes from previous render.
[130]130        */
[174]131        std::vector<HierarchyNode *> *GetVisibleNodes();
[130]132        /** Returns vector of previoulsy rendered geometry.
133        */
134       
[155]135        /** Returns the geometry of a given hierarchy node.
136                @param node the hierarchy node containing the geometry
137                @param geometryList geometry is returned in this list
138                @param includeChildren if the geometry of the children should be taken into account
[130]139        */
[155]140        virtual void GetNodeGeometryList(GtpVisibility::HierarchyNode *node,   
[370]141                                                         GeometryVector *geometryList,
[130]142                                                         bool includeChildren) = 0;
143
[158]144       
[155]145        /** This is an optimization when issuing the occlusion test.
146                The test is done with actual geometry rather than the bounding
[158]147                box of leave nodes previously marked as visible.
148
[155]149                @param testGeometry if this optimization should be used
150                @remark this option is only useful for the coherent hierarchical culling algorithm
151        */
152        void TestGeometryForVisibleLeaves(bool testGeometry);
153
154
[59]155protected:
[606]156
157
[155]158        /// chc optimization for testing geometry of leaves instead of bounding box
159        bool mTestGeometryForVisibleLeaves;
[158]160        /// the current frame number
[59]161        unsigned int mFrameId;
[158]162        /// points to the last occlusion query in the query list
[59]163        int mCurrentTestIdx;
164       
[155]165        /// number of traversed nodes
[59]166        unsigned int mNumTraversedNodes;
[158]167
168        /// The queue is useful for rendering hierarchy nodes in front to back order.
[59]169        DistanceQueue *mDistanceQueue;
[111]170
[155]171        /// the root of the hierarchy
172        HierarchyNode *mHierarchyRoot;
173       
[158]174        /// buffer for a node pointer
[155]175        HierarchyNode *mSavedNode;
[158]176        /// list of rendered hierarchy nodes (e.g., useful for exact visibility queries)
[174]177        std::vector<HierarchyNode *> mVisibleNodes;
[59]178};
179} // namespace GtpVisibility
[155]180
[112]181#endif // GtpVisisibilityHierarchyInterface_H
Note: See TracBrowser for help on using the repository browser.