Line | |
---|
1 | #ifndef _DistanceQueue_H__
|
---|
2 | #define _DistanceQueue_H__
|
---|
3 |
|
---|
4 | #include "OcclusionQuery.h"
|
---|
5 |
|
---|
6 | #include <queue>
|
---|
7 |
|
---|
8 | namespace GtpVisibility {
|
---|
9 |
|
---|
10 | /* We define HierarchyNode as void * because
|
---|
11 | there is no common ancestor for hierarchy nodes in Ogre
|
---|
12 | */
|
---|
13 | typedef void HierarchyNode;
|
---|
14 |
|
---|
15 | class HierarchyInterface;
|
---|
16 | /** This class implements the less operator for the priority queue, i.e.,
|
---|
17 | a greater distance has a lower priority in the queue.
|
---|
18 | */
|
---|
19 | template <typename T> class GtDistance
|
---|
20 | {
|
---|
21 | public:
|
---|
22 | GtDistance(HierarchyInterface *hierarchyInterface): mHierarchyInterface(hierarchyInterface)
|
---|
23 | {}
|
---|
24 |
|
---|
25 | bool operator() (const T v1, const T v2) const
|
---|
26 | {
|
---|
27 | //return false;
|
---|
28 | return mHierarchyInterface->GetSquaredDistance(v1) > mHierarchyInterface->GetSquaredDistance(v2);
|
---|
29 | }
|
---|
30 |
|
---|
31 | private:
|
---|
32 | HierarchyInterface *mHierarchyInterface;
|
---|
33 | };
|
---|
34 |
|
---|
35 | /** A priority queue where closer hierarchy nodes are given a higher priority.
|
---|
36 | */
|
---|
37 | typedef std::priority_queue<HierarchyNode *, std::vector<HierarchyNode *>, GtDistance<std::vector<HierarchyNode *>::value_type> > DistanceQueue;
|
---|
38 |
|
---|
39 | } // namespace GtpVisibility
|
---|
40 |
|
---|
41 | #endif // DistanceQueue_H |
---|
Note: See
TracBrowser
for help on using the repository browser.