Changeset 1320 for GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include
- Timestamp:
- 09/04/06 08:56:26 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include
- Files:
-
- 5 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreBvHierarchy.h
r1319 r1320 11 11 #define _OgreBvHierarchy_H__ 12 12 13 #define KDNODE_CAST(a) (static_cast<KdTree::Node>(a))14 #define KDBRANCH_CAST(a) (static_cast<KdTree::Branch>(a))15 #define KDLEAF_CAST(a) (static_cast<KdTree::Leaf>(a))16 #define KDNODEPTR_CAST(a) (static_cast<KdTree::Node *>(a))17 #define KDBRANCHPTR_CAST(a) (static_cast<KdTree::Branch *>(a))18 #define KDLEAFPTR_CAST(a) (static_cast<KdTree::Leaf *>(a))19 20 #define KDTREE_LOGNAME "KdTreeBuild.log"13 #define BVHNODE_CAST(a) (static_cast<BvHierarchy::Node>(a)) 14 #define BVHBRANCH_CAST(a) (static_cast<BvHierarchy::Branch>(a)) 15 #define BVHLEAF_CAST(a) (static_cast<BvHierarchy::Leaf>(a)) 16 #define BVHNODEPTR_CAST(a) (static_cast<BvHierarchy::Node *>(a)) 17 #define BVHBRANCHPTR_CAST(a) (static_cast<BvHierarchy::Branch *>(a)) 18 #define BVHLEAFPTR_CAST(a) (static_cast<BvHierarchy::Leaf *>(a)) 19 20 #define BvHierarchy_LOGNAME "BvHierarchyBuild.log" 21 21 22 22 #include <OgreAxisAlignedBox.h> … … 31 31 #include "OgreBvHierarchyCamera.h" 32 32 #include "HierarchyInterface.h" 33 33 #include "OgreKdTree.h" 34 34 35 35 namespace Ogre 36 36 { 37 37 class BvHierarchyCamera; 38 class Bv Renderable;39 struct SplitInfo;40 41 class PlaneEvent38 class BvhRenderable; 39 struct BvhSplitInfo; 40 41 class BvhPlaneEvent 42 42 { 43 43 public: … … 63 63 }; 64 64 65 PlaneEvent(): mRenderable(0), mPosition(Vector3()), mDimension(PED_X), mType(PET_ON)65 BvhPlaneEvent(): mRenderable(0), mPosition(Vector3()), mDimension(PED_X), mType(PET_ON) 66 66 { }; 67 67 68 PlaneEvent(BvRenderable *rend, const Vector3& pos, PlaneEvent::Dimension dim,PlaneEvent::Type type):68 BvhPlaneEvent(BvhRenderable *rend, const Vector3& pos, BvhPlaneEvent::Dimension dim, BvhPlaneEvent::Type type): 69 69 mRenderable(rend), mPosition(pos), mDimension(dim), mType(type) 70 70 { }; 71 71 72 ~ PlaneEvent() {};72 ~BvhPlaneEvent() {}; 73 73 74 74 // the less operator for plane events 75 75 // first sort by position, then by dimension and finally by type 76 bool operator < (const PlaneEvent& e) const76 bool operator < (const BvhPlaneEvent& e) const 77 77 { 78 78 if(mPosition[mDimension] < e.mPosition[e.mDimension]) … … 100 100 101 101 // the equals operator for tree events 102 bool operator == (const PlaneEvent& e) const102 bool operator == (const BvhPlaneEvent& e) const 103 103 { 104 104 return (mPosition[mDimension] == e.mPosition[e.mDimension]) && … … 107 107 }; 108 108 109 bool equalsType(const PlaneEvent& e,PlaneEvent::Type t)109 bool equalsType(const BvhPlaneEvent& e, BvhPlaneEvent::Type t) 110 110 { 111 111 return (mPosition[mDimension] == e.mPosition[e.mDimension]) && … … 114 114 }; 115 115 116 void classify(const PlaneEvent& e,PlaneEvent::Side side);117 118 PlaneEvent clip(AxisAlignedBox& box,PlaneEvent::Dimension dim);116 void classify(const BvhPlaneEvent& e, BvhPlaneEvent::Side side); 117 118 BvhPlaneEvent clip(AxisAlignedBox& box, BvhPlaneEvent::Dimension dim); 119 119 120 120 Plane * getSplitPlane() const … … 125 125 } 126 126 127 Bv Renderable * getRenderable() const //??127 BvhRenderable * getRenderable() const //?? 128 128 { 129 129 return mRenderable; 130 130 }; 131 131 132 PlaneEvent::Dimension getDimension() const //??132 BvhPlaneEvent::Dimension getDimension() const //?? 133 133 { 134 134 return mDimension; … … 139 139 protected: 140 140 // event info 141 Bv Renderable * mRenderable;141 BvhRenderable * mRenderable; 142 142 Vector3 mPosition; 143 PlaneEvent::Dimension mDimension;144 PlaneEvent::Type mType;143 BvhPlaneEvent::Dimension mDimension; 144 BvhPlaneEvent::Type mType; 145 145 146 146 // ------------------------------------------------------------------------------// … … 149 149 // TODO discuss if these functions really belong here, OO & SE - wise 150 150 // pros: convenient, don't have to pass internal data to the outside 151 // cons: SplitInfo ...151 // cons: BvhSplitInfo ... 152 152 public: 153 153 // compute "global" surface area heuristic (SAH) for the plane represented by this event 154 154 // use only with priority queue build method 155 void pqSAH(Real globalSA, Real parentSA, int nLeft, int nPlane, int nRight, AxisAlignedBox& parentBox, SplitInfo& split);155 void pqSAH(Real globalSA, Real parentSA, int nLeft, int nPlane, int nRight, AxisAlignedBox& parentBox, BvhSplitInfo& split); 156 156 static Real pqSplitCost(Real p, Real pl, Real pr, int nLeft, int nRight, Real mu); 157 157 158 158 // compute the surface area heuristic (SAH) for the plane represented by this event 159 void SAH(const AxisAlignedBox& parent, int nLeft, int nPlane, int nRight, SplitInfo& split);159 void SAH(const AxisAlignedBox& parent, int nLeft, int nPlane, int nRight, BvhSplitInfo& split); 160 160 // the variables determining the cost of a branch traversal (KT) and a leaf intersection (KI) 161 161 static Real KT; … … 171 171 172 172 // Holds all the important information on a split 173 struct SplitInfo173 struct BvhSplitInfo 174 174 { 175 175 AxisAlignedBox bleft; … … 178 178 int nright; 179 179 Real cost; 180 PlaneEvent::Side side;181 PlaneEvent event;180 BvhPlaneEvent::Side side; 181 BvhPlaneEvent event; 182 182 183 183 // DEBUG … … 185 185 }; 186 186 187 typedef std::list< PlaneEvent> PlaneEventList;188 typedef std::list<Bv Renderable *> BvRenderableList;187 typedef std::list<BvhRenderable *> BvhRenderableList; 188 typedef std::list<BvhPlaneEvent> BvhPlaneEventList; 189 189 190 class KdTree190 class BvHierarchy 191 191 { 192 192 protected: … … 197 197 { 198 198 public: 199 Node( KdTree* owner, int level, AxisAlignedBox& aabb, Branch * parent):199 Node(BvHierarchy * owner, int level, AxisAlignedBox& aabb, Branch * parent): 200 200 mOwner(owner), 201 201 mLevel(level), … … 217 217 218 218 // Gets this node's parent (NULL if this is the root). 219 KdTree::Node *getParent(void) const { return mParent; };219 BvHierarchy::Node *getParent(void) const { return mParent; }; 220 220 221 221 // Gets the nodes left & right child nodes, or NULL if not present or node is leaf 222 virtual KdTree::Node *getLeftChild(void) const = 0;223 virtual KdTree::Node *getRightChild(void) const = 0;222 virtual BvHierarchy::Node *getLeftChild(void) const = 0; 223 virtual BvHierarchy::Node *getRightChild(void) const = 0; 224 224 225 225 // add contained objects to render queue … … 242 242 243 243 if (mOwner->getHiLiteLevel() == mLevel) 244 mWBB->setMaterial(" KdTree/BoxHiLite");244 mWBB->setMaterial("BvHierarchy/BoxHiLite"); 245 245 else 246 246 mWBB->setMaterial("BaseWhiteNoLighting"); … … 275 275 */ 276 276 void setLastRendered(unsigned int frameid) { mLastRendered = frameid; }; 277 /** Returns real extent of the kdtree, i.e., the merged extent of the bounding boxes.277 /** Returns real extent of the BvHierarchy, i.e., the merged extent of the bounding boxes. 278 278 */ 279 279 AxisAlignedBox _getWorldAABB(void) const { return mAABB; }; 280 /** Updates bound of the real aabb of kdtree280 /** Updates bound of the real aabb of BvHierarchy 281 281 */ 282 282 virtual void _updateBounds(bool recurse = true) = 0; … … 288 288 AxisAlignedBox mWorldAABB; 289 289 protected: 290 KdTree* mOwner;290 BvHierarchy * mOwner; 291 291 Branch * mParent; 292 292 int mLevel; … … 303 303 { 304 304 public: 305 Branch( KdTree* owner, int level, AxisAlignedBox& aabb, Branch * parent,306 Plane * splitplane, PlaneEvent::Side side):305 Branch(BvHierarchy * owner, int level, AxisAlignedBox& aabb, Branch * parent, 306 Plane * splitplane, BvhPlaneEvent::Side side): 307 307 Node(owner, level, aabb, parent), 308 308 mSplitPlane(splitplane), … … 335 335 336 336 // a branch should have at least one child 337 virtual KdTree::Node * getLeftChild() const { return mLeft; };338 virtual KdTree::Node * getRightChild() const { return mRight; };337 virtual BvHierarchy::Node * getLeftChild() const { return mLeft; }; 338 virtual BvHierarchy::Node * getRightChild() const { return mRight; }; 339 339 340 340 virtual void queueVisibleObjects(unsigned long currentFrame, … … 379 379 Node * mRight; 380 380 Plane * mSplitPlane; 381 PlaneEvent::Side mPlaneSide;381 BvhPlaneEvent::Side mPlaneSide; 382 382 protected: 383 383 std::set<Leaf *> mLeaves; … … 387 387 { 388 388 public: 389 Leaf( KdTree* owner, int level, AxisAlignedBox& aabb, Branch * parent):389 Leaf(BvHierarchy * owner, int level, AxisAlignedBox& aabb, Branch * parent): 390 390 Node(owner, level, aabb, parent) 391 391 {}; … … 397 397 398 398 // a leaf is empty when it does not posses renderables 399 virtual bool isEmpty() const { return mBv Renderables.empty(); }399 virtual bool isEmpty() const { return mBvhRenderables.empty(); } 400 400 401 401 // a leaf has geometry when it has renderables 402 virtual bool hasGeometry() const { return !mBv Renderables.empty(); }402 virtual bool hasGeometry() const { return !mBvhRenderables.empty(); } 403 403 404 404 // a leaf adds itself to the leaf set … … 406 406 407 407 // a leaf never has children 408 virtual KdTree::Node * getLeftChild() const { return 0; };409 virtual KdTree::Node * getRightChild() const { return 0; };408 virtual BvHierarchy::Node * getLeftChild() const { return 0; }; 409 virtual BvHierarchy::Node * getRightChild() const { return 0; }; 410 410 411 411 virtual void queueVisibleObjects(unsigned long currentFrame, … … 417 417 virtual void _updateBounds(bool recurse = true); 418 418 419 virtual void remove(Bv Renderable * rend)420 { 421 mBv Renderables.remove(rend);422 //mBv Renderables.erase(find(mBvRenderables.begin(), mBvRenderables.end(), rend));419 virtual void remove(BvhRenderable * rend) 420 { 421 mBvhRenderables.remove(rend); 422 //mBvhRenderables.erase(find(mBvhRenderables.begin(), mBvhRenderables.end(), rend)); 423 423 }; 424 424 425 virtual void insert(Bv Renderable * rend)426 { 427 mBv Renderables.push_back(rend);425 virtual void insert(BvhRenderable * rend) 426 { 427 mBvhRenderables.push_back(rend); 428 428 }; 429 429 430 Bv RenderableList mBvRenderables;431 }; 432 433 struct SplitCandidate434 { 435 SplitCandidate(PlaneEventList * e, int n, AxisAlignedBox& a,436 KdTree::Branch * p, Real c, Real d, SplitInfo * b,PlaneEvent::Side s):430 BvhRenderableList mBvhRenderables; 431 }; 432 433 struct BvhSubdivisionCandidate 434 { 435 BvhSubdivisionCandidate(BvhPlaneEventList * e, int n, AxisAlignedBox& a, 436 BvHierarchy::Branch * p, Real c, Real d, BvhSplitInfo * b, BvhPlaneEvent::Side s): 437 437 events(e), nObjects(n), aabb(a), parent(p), cost(c), decrease(d), best(b), side(s) 438 438 { }; 439 439 440 bool operator < (const SplitCandidate& rhs) const440 bool operator < (const BvhSubdivisionCandidate& rhs) const 441 441 { 442 442 return decrease < rhs.decrease; 443 443 }; 444 444 445 void operator = (const SplitCandidate& rhs)445 void operator = (const BvhSubdivisionCandidate& rhs) 446 446 { 447 447 decrease = rhs.decrease; … … 461 461 Real cost; 462 462 int nObjects; 463 PlaneEvent::Side side;463 BvhPlaneEvent::Side side; 464 464 AxisAlignedBox aabb; 465 PlaneEventList *events;466 KdTree::Branch * parent;467 SplitInfo * best;468 }; 469 470 // typedef std::stack< SplitCandidate> SplitCandidatePQ;471 typedef std::priority_queue< SplitCandidate> SplitCandidatePQ;465 BvhPlaneEventList *events; 466 BvHierarchy::Branch * parent; 467 BvhSplitInfo * best; 468 }; 469 470 // typedef std::stack<BvhSubdivisionCandidate> SplitCandidatePQ; 471 typedef std::priority_queue<BvhSubdivisionCandidate> SplitCandidatePQ; 472 472 473 473 // nodestack for the stack-based rendering function 474 typedef std::stack< KdTree::Node *> NodeStack;474 typedef std::stack<BvHierarchy::Node *> NodeStack; 475 475 public: 476 friend class KdTreeHierarchyInterface;477 478 typedef KdTree::Node * NodePtr;479 typedef KdTree::Branch * BranchPtr;480 typedef KdTree::Leaf * LeafPtr;476 friend class BvHierarchyInterface; 477 478 typedef BvHierarchy::Node * NodePtr; 479 typedef BvHierarchy::Branch * BranchPtr; 480 typedef BvHierarchy::Leaf * LeafPtr; 481 481 482 482 typedef std::list<NodePtr> NodeList; … … 513 513 enum RenderMethod 514 514 { 515 KDRM_INTERNAL,516 KDRM_GTP_VFC,517 KDRM_GTP_SWC,518 KDRM_GTP_CHC,515 BVHRM_INTERNAL, 516 BVHRM_GTP_VFC, 517 BVHRM_GTP_SWC, 518 BVHRM_GTP_CHC, 519 519 // invalid modes, just for convenience 520 KDRM_SIZE,521 KDRM_NOTSET520 BVHRM_SIZE, 521 BVHRM_NOTSET 522 522 }; 523 523 524 524 enum BuildMethod 525 525 { 526 KDBM_RECURSIVE,527 KDBM_PRIORITYQUEUE,526 BVHBM_RECURSIVE, 527 BVHBM_PRIORITYQUEUE, 528 528 // invalid modes, just for convenience 529 KDBM_SIZE,530 KDBM_NOTSET529 BVHBM_SIZE, 530 BVHBM_NOTSET 531 531 }; 532 532 … … 534 534 const static int HILITE_OFF = -1; 535 535 536 KdTree(int maxdepth, BuildMethod bm);537 KdTree(int maxdepth, BuildMethod bm, int hilite, bool allboxes, bool shownodes);538 virtual ~ KdTree();536 BvHierarchy(int maxdepth, BuildMethod bm); 537 BvHierarchy(int maxdepth, BuildMethod bm, int hilite, bool allboxes, bool shownodes); 538 virtual ~BvHierarchy(); 539 539 540 540 // DEBUG … … 546 546 inline int getHiLiteLevel(void) { return mHiLiteLevel; }; 547 547 548 // toggles displaying the kdtreeboxes548 // toggles displaying the BvHierarchy boxes 549 549 inline void setShowAllBoxes(bool show) { mShowAllBoxes = show; }; 550 550 inline bool getShowAllBoxes(void) { return mShowAllBoxes; }; … … 559 559 bool getEnhancedVis(void); 560 560 561 NodePtr getRoot(void) const { return m KdRoot; };562 563 // insert a new scene node into an existing kd-tree564 void insert(Bv Renderable * rend);561 NodePtr getRoot(void) const { return mBvhRoot; }; 562 563 // insert a new scene node into an existing bvhierarchy 564 void insert(BvhRenderable * rend); 565 565 // remove a scene node from the tree 566 void remove(Bv Renderable * rend);566 void remove(BvhRenderable * rend); 567 567 // function to initialize a kd-tree based on the contents of the scene 568 void build(Bv Renderable * sceneRoot);568 void build(BvhRenderable * sceneRoot); 569 569 570 570 // test visibility of objects and add to render queue 571 571 void queueVisibleObjects(BvHierarchyCamera* cam, RenderQueue* queue, bool onlyShadowCasters, 572 bool showBoxes, KdTree::NodeList& visibleNodes);572 bool showBoxes, BvHierarchy::NodeList& visibleNodes); 573 573 574 574 // find visible nodes & place in list 575 575 //void findVisibleNodes(NodeList& visibleNodes, Camera * cam); 576 576 577 /** Recurses the kdtree, adding any nodes intersecting with the577 /** Recurses the BvHierarchy, adding any nodes intersecting with the 578 578 box/sphere/volume/ray into the given list. 579 579 It ignores the exclude scene node. … … 588 588 const TreeStats& getTreeStats(void) const { return mTreeStats; } 589 589 const FrameStats& getFramesStats(void) const { return mFrameStats; } 590 AxisAlignedBox getBox(void) { if (m KdRoot) return mKdRoot->mAABB; else return AxisAlignedBox(); }590 AxisAlignedBox getBox(void) { if (mBvhRoot) return mBvhRoot->mAABB; else return AxisAlignedBox(); } 591 591 void setBuildMethod(BuildMethod bm) { mBuildMethod = bm; } 592 592 protected: … … 594 594 void init(); 595 595 // recursive insert funciton 596 void recInsert( KdTree::Node * node, BvRenderable * rend);596 void recInsert(BvHierarchy::Node * node, BvhRenderable * rend); 597 597 // helper functions for insert 598 void recInsertNew( KdTree::Branch * parent, PlaneEvent::Side side, BvRenderable * rend);599 void splitBox(const KdTree::Branch& parent, AxisAlignedBox& left, AxisAlignedBox& right);600 void rebuildSubtree( KdTree::Node * node, BvRenderable * rend);598 void recInsertNew(BvHierarchy::Branch * parent, BvhPlaneEvent::Side side, BvhRenderable * rend); 599 void splitBox(const BvHierarchy::Branch& parent, AxisAlignedBox& left, AxisAlignedBox& right); 600 void rebuildSubtree(BvHierarchy::Node * node, BvhRenderable * rend); 601 601 // build scene from a list of nodes rather than a hierarchy 602 KdTree::Node * buildFromList(BvRenderableList& nodelist, KdTree::Branch * parent, AxisAlignedBox& aabb);603 void addRendToList( KdTree::Node * node, BvRenderableList& nodelist);602 BvHierarchy::Node * buildFromList(BvhRenderableList& nodelist, BvHierarchy::Branch * parent, AxisAlignedBox& aabb); 603 void addRendToList(BvHierarchy::Node * node, BvhRenderableList& nodelist); 604 604 605 605 // recursively delete empty nodes 606 void recDelete( KdTree::Node * node);606 void recDelete(BvHierarchy::Node * node); 607 607 608 608 // find the best plane for node division 609 SplitInfo * pqFindPlane(PlaneEventList * events, int nObjects, AxisAlignedBox& aabb, Real globalSA);609 BvhSplitInfo * pqFindPlane(BvhPlaneEventList * events, int nObjects, AxisAlignedBox& aabb, Real globalSA); 610 610 611 611 // priority queue based build function 612 KdTree::Node * pqBuild(PlaneEventList& events, int nObjects, AxisAlignedBox& aabb, KdTree::Branch * parent);612 BvHierarchy::Node * pqBuild(BvhPlaneEventList& events, int nObjects, AxisAlignedBox& aabb, BvHierarchy::Branch * parent); 613 613 // recursive build function 614 KdTree::Node * recBuild(PlaneEventList& events, int nObjects, AxisAlignedBox& aabb, KdTree::Branch * parent);614 BvHierarchy::Node * recBuild(BvhPlaneEventList& events, int nObjects, AxisAlignedBox& aabb, BvHierarchy::Branch * parent); 615 615 616 616 // recursive rendering function 617 void recQueueVisibleObjects( KdTree::Node * node, unsigned long currentFrame, BvHierarchyCamera* cam,617 void recQueueVisibleObjects(BvHierarchy::Node * node, unsigned long currentFrame, BvHierarchyCamera* cam, 618 618 RenderQueue* queue, bool onlyShadowCasters, bool showBoxes, 619 KdTree::NodeList& visibleNodes, bool fullVis = false);619 BvHierarchy::NodeList& visibleNodes, bool fullVis = false); 620 620 621 621 // recursively find visible nodes 622 //void recFindVisibleNodes( KdTree::Node * node, NodeList& visibleNodes, Camera * cam);623 624 /** Recurses the kdtree, adding any nodes intersecting with the622 //void recFindVisibleNodes(BvHierarchy::Node * node, NodeList& visibleNodes, Camera * cam); 623 624 /** Recurses the BvHierarchy, adding any nodes intersecting with the 625 625 box/sphere/volume/ray into the given list. 626 626 It ignores the exclude scene node. … … 631 631 void recFindNodesIn(const Ray &ray, std::list<SceneNode *> &list, SceneNode *exclude, Node * node, bool full = false); 632 632 633 // the root node of the kdtree634 KdTree::Node * mKdRoot;633 // the root node of the BvHierarchy 634 BvHierarchy::Node * mBvhRoot; 635 635 // Maximum depth of the tree 636 636 int mMaxDepth; … … 649 649 650 650 /** Visualization flags **/ 651 // show/highlight selected level in kdtree651 // show/highlight selected level in BvHierarchy 652 652 int mHiLiteLevel; 653 653 // show whole kd-tree … … 662 662 663 663 // DEBUG 664 void KdTree::dump(KdTree::Node * node);665 Real KdTree::calcCost(KdTree::Node * node, Real vs);666 }; // class KdTree664 void BvHierarchy::dump(BvHierarchy::Node * node); 665 Real BvHierarchy::calcCost(BvHierarchy::Node * node, Real vs); 666 }; // class BvHierarchy 667 667 668 668 } // namespace Ogre -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreBvHierarchyCamera.h
r1319 r1320 13 13 #include <OgreCamera.h> 14 14 15 #define KDCAMPTR_CAST(cam) (static_cast<BvHierarchyCamera *>(cam))15 #define BVHCAMPTR_CAST(cam) (static_cast<BvHierarchyCamera *>(cam)) 16 16 17 17 namespace Ogre … … 23 23 enum NodeVisibility 24 24 { 25 KDNV_NONE,26 KDNV_PART,27 KDNV_FULL25 BVHNV_NONE, 26 BVHNV_PART, 27 BVHNV_FULL 28 28 }; 29 29 -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreBvHierarchyInterface.h
r1319 r1320 16 16 { 17 17 18 class KdTreeSceneManager;18 class BvHierarchySceneManager; 19 19 20 class KdTreeHierarchyInterface : public PlatformHierarchyInterface20 class BvHierarchyInterface : public PlatformHierarchyInterface 21 21 { 22 22 public: 23 KdTreeHierarchyInterface(KdTreeSceneManager *sm, RenderSystem *rsys);23 BvHierarchyInterface(BvHierarchySceneManager *sm, RenderSystem *rsys); 24 24 25 virtual ~ KdTreeHierarchyInterface() {};25 virtual ~BvHierarchyInterface() {}; 26 26 27 27 /** Returns true if current node is leaf of the hierarchy. -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreBvHierarchySceneManager.h
r1319 r1320 8 8 */ 9 9 10 #ifndef _ KdTreeSceneManager_H__11 #define _ KdTreeSceneManager_H__10 #ifndef _BvHierarchySceneManager_H__ 11 #define _BvHierarchySceneManager_H__ 12 12 13 13 #include <OgreSceneManager.h> … … 19 19 #include "OgreBvHierarchyInterface.h" 20 20 21 #define KDTREE_MAX_DEPTH 1221 #define BvHierarchy_MAX_DEPTH 12 22 22 23 23 namespace Ogre 24 24 { 25 25 26 class KdTreeSceneNode;27 28 class KdTreeSceneManager : public SceneManager26 class BvHierarchySceneNode; 27 28 class BvHierarchySceneManager : public SceneManager 29 29 { 30 30 public: 31 KdTreeSceneManager(const String& name, GtpVisibility::VisibilityManager *vm);32 ~ KdTreeSceneManager(void);31 BvHierarchySceneManager(const String& name, GtpVisibility::VisibilityManager *vm); 32 ~BvHierarchySceneManager(void); 33 33 34 34 virtual const String& getTypeName(void) const; 35 35 36 //typedef std::list< KdTreeSceneNode *> NodeList;36 //typedef std::list<BvHierarchySceneNode *> NodeList; 37 37 //typedef std::list<WireBoundingBox *> BoxList; 38 38 39 39 /************************************************************************/ 40 /* Functions overridden form SceneManager for KdTree*/40 /* Functions overridden form SceneManager for BvHierarchy */ 41 41 /************************************************************************/ 42 42 … … 45 45 virtual Camera* createCamera(const String& name); 46 46 47 /** Override from SceneManager to create SceneNodes as instance of KdTreeSceneNode47 /** Override from SceneManager to create SceneNodes as instance of BvHierarchySceneNode 48 48 */ 49 49 virtual SceneNode* createSceneNode(void); 50 /** Override from SceneManager to create SceneNodes as instance of KdTreeSceneNode50 /** Override from SceneManager to create SceneNodes as instance of BvHierarchySceneNode 51 51 */ 52 52 virtual SceneNode* createSceneNode(const String& name); … … 62 62 bool getOptionKeys(StringVector &refKeys); 63 63 64 /** Overide from scene manager to destroy kdtreeproperly (before the scene graph is destroyed)64 /** Overide from scene manager to destroy BvHierarchy properly (before the scene graph is destroyed) 65 65 */ 66 66 virtual void clearScene(); … … 110 110 111 111 /************************************************************************/ 112 /* Functions which are specific to the KdTree*/112 /* Functions which are specific to the BvHierarchy */ 113 113 /************************************************************************/ 114 114 115 /** Update the KdTreewith the node (more or less disabled now)116 */ 117 virtual void _updateNode( KdTreeSceneNode *node); // TODO:118 119 /** Show or hide the bounding boxes of KdTreenodes - obsolete, use options115 /** Update the BvHierarchy with the node (more or less disabled now) 116 */ 117 virtual void _updateNode(BvHierarchySceneNode *node); // TODO: 118 119 /** Show or hide the bounding boxes of BvHierarchy nodes - obsolete, use options 120 120 */ 121 121 virtual void setShowBoxes(bool showboxes); … … 124 124 virtual bool getShowBoxes(void) const; 125 125 126 /** Recurses the kdtree, adding any nodes intersecting with the126 /** Recurses the BvHierarchy, adding any nodes intersecting with the 127 127 box/sphere/volume/ray into the given list. 128 128 It ignores the exclude scene node. … … 162 162 /** Render a list of scenenodes 163 163 */ 164 //virtual void _renderNodes(const Bv RenderableList& nodelist, Camera * cam,164 //virtual void _renderNodes(const BvhRenderableList& nodelist, Camera * cam, 165 165 // bool onlyShadowCasters, int leavePassesInQueue); 166 virtual void _renderNode( KdTree::NodePtr node, Camera * cam,166 virtual void _renderNode(BvHierarchy::NodePtr node, Camera * cam, 167 167 bool onlyShadowCasters, int leavePassesInQueue); 168 168 … … 181 181 /** Returns hierarchy interface. 182 182 */ 183 KdTreeHierarchyInterface *GetHierarchyInterface();183 BvHierarchyInterface *GetHierarchyInterface(); 184 184 185 185 protected: … … 223 223 224 224 // the hierarchy interface for CHC 225 KdTreeHierarchyInterface *mHierarchyInterface;225 BvHierarchyInterface *mHierarchyInterface; 226 226 227 227 // if hierarchical culling is currently in use … … 273 273 274 274 // remember visited scene nodes for viz 275 KdTree::NodeList mVisibleNodes;275 BvHierarchy::NodeList mVisibleNodes; 276 276 277 277 /************************************************************************/ 278 278 /* Kd-Tree specific options & members */ 279 279 /************************************************************************/ 280 // maximum depth of the kdtree280 // maximum depth of the BvHierarchy 281 281 int mMaxDepth; 282 282 283 // the kdtreewhich holds the scene284 KdTree*mBvHierarchy;285 286 // if bounding boxes of kdtreenodes are shown283 // the BvHierarchy which holds the scene 284 BvHierarchy *mBvHierarchy; 285 286 // if bounding boxes of BvHierarchy nodes are shown 287 287 bool mShowBoxes; 288 288 // bounding boxes of kd nodes will be highlighted on this level of the kd tree … … 290 290 // if all bounding boxes shall be displayed, not only the highlighted level 291 291 bool mShowAllBoxes; 292 // visualize kdtreenodes or bounding boxes of objects in nodes292 // visualize BvHierarchy nodes or bounding boxes of objects in nodes 293 293 bool mShowNodes; 294 294 … … 297 297 298 298 // the method/algorithm used when rendering the scene 299 KdTree::RenderMethod mRenderMethod;299 BvHierarchy::RenderMethod mRenderMethod; 300 300 301 301 // the method of building the tree 302 KdTree::BuildMethod mBuildMethod;302 BvHierarchy::BuildMethod mBuildMethod; 303 303 304 304 /************************************************************************/ … … 327 327 328 328 329 /// Factory for KdTreeSceneManager330 class BvHierarchySceneManagerFactory 329 /// Factory for BvHierarchySceneManager 330 class BvHierarchySceneManagerFactory: public SceneManagerFactory 331 331 { 332 332 protected: … … 337 337 { 338 338 visManager = vm; 339 } ;339 } 340 340 ~BvHierarchySceneManagerFactory(void) {}; 341 341 /// Factory type name … … 347 347 } // namespace Ogre 348 348 349 #endif // _ KdTreeSceneManager_H__349 #endif // _BvHierarchySceneManager_H__ -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreBvHierarchySceneNode.h
r1319 r1320 12 12 13 13 #include <OgreSceneNode.h> 14 #include "OgreBv Renderable.h"14 #include "OgreBvhRenderable.h" 15 15 16 16 namespace Ogre 17 17 { 18 18 19 class KdTreeSceneNode : public SceneNode, public BvRenderable19 class BvHierarchySceneNode : public SceneNode, public BvhRenderable 20 20 { 21 21 public: 22 KdTreeSceneNode(SceneManager *creator):22 BvHierarchySceneNode(SceneManager *creator): 23 23 SceneNode(creator) {}; 24 24 25 KdTreeSceneNode(SceneManager *creator, const String& name):25 BvHierarchySceneNode(SceneManager *creator, const String& name): 26 26 SceneNode(creator, name) {}; 27 27 28 ~ KdTreeSceneNode() {};28 ~BvHierarchySceneNode() {}; 29 29 30 30 // gather info for kd-tree creation 31 virtual void computeScene( PlaneEventList& events, AxisAlignedBox& aabb, int& nObjects, bool includeChildren = true);31 virtual void computeScene(BvhPlaneEventList& events, AxisAlignedBox& aabb, int& nObjects, bool includeChildren = true); 32 32 33 33 // add all contained objects to render queue -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreBvhRenderable.h
r1319 r1320 8 8 */ 9 9 10 #ifndef _OgreBv Renderable_H__11 #define _OgreBv Renderable_H__10 #ifndef _OgreBvhRenderable_H__ 11 #define _OgreBvhRenderable_H__ 12 12 13 13 #include "OgreBvHierarchy.h" … … 18 18 // interface which must be implemented by all objects which desire to be 19 19 // placed in the kd-tree 20 class Bv Renderable20 class BvhRenderable 21 21 { 22 22 public: 23 Bv Renderable():mSide(PlaneEvent::PES_BOTH), mClassified(false), mLastQueued(0), mBvHierarchy(0) {};24 virtual ~Bv Renderable()23 BvhRenderable():mSide(BvhPlaneEvent::PES_BOTH), mClassified(false), mLastQueued(0), mBvHierarchy(0) {}; 24 virtual ~BvhRenderable() 25 25 { 26 26 if (mBvHierarchy) … … 29 29 30 30 // gather the information required for the creation of the kd-tree 31 virtual void computeScene( PlaneEventList& events, AxisAlignedBox& aabb, int& nObjects, bool includeChildren = true) = 0;31 virtual void computeScene(BvhPlaneEventList& events, AxisAlignedBox& aabb, int& nObjects, bool includeChildren = true) = 0; 32 32 33 33 // put all objects this element holds in the renedering queue … … 50 50 }; 51 51 52 inline PlaneEvent::Side getSide()52 inline BvhPlaneEvent::Side getSide() 53 53 { 54 54 return mSide; 55 55 }; 56 inline void setSide( PlaneEvent::Side s)56 inline void setSide(BvhPlaneEvent::Side s) 57 57 { 58 58 mSide = s; … … 65 65 }; 66 66 // the following functions should work in O(log N) 67 inline bool isAttached( KdTree::LeafPtr leaf)67 inline bool isAttached(BvHierarchy::LeafPtr leaf) 68 68 { 69 69 return mLeaves.find(leaf) != mLeaves.end(); 70 70 }; 71 inline bool attachTo( KdTree::LeafPtr leaf, KdTree * kdTree)71 inline bool attachTo(BvHierarchy::LeafPtr leaf, BvHierarchy * BvHierarchy) 72 72 { 73 if (mBvHierarchy == 0 || mBvHierarchy == kdTree)74 mBvHierarchy = kdTree;73 if (mBvHierarchy == 0 || mBvHierarchy == BvHierarchy) 74 mBvHierarchy = BvHierarchy; 75 75 else 76 76 return false; 77 77 78 KdTree::LeafSet::_Pairib p = mLeaves.insert(leaf);78 BvHierarchy::LeafSet::_Pairib p = mLeaves.insert(leaf); 79 79 return p.second; 80 80 }; 81 inline bool detachFrom( KdTree::LeafPtr leaf)81 inline bool detachFrom(BvHierarchy::LeafPtr leaf) 82 82 { 83 83 bool success = (mLeaves.erase(leaf) == 1); … … 102 102 }; 103 103 104 KdTree::LeafSet& getLeaves()104 BvHierarchy::LeafSet& getLeaves() 105 105 { 106 106 return mLeaves; … … 113 113 Camera * mLastCam; 114 114 115 // kdtreeto which this renderable is attached116 KdTree* mBvHierarchy;117 // kdtreeleaves which overlap this renderable118 KdTree::LeafSet mLeaves;115 // BvHierarchy to which this renderable is attached 116 BvHierarchy * mBvHierarchy; 117 // BvHierarchy leaves which overlap this renderable 118 BvHierarchy::LeafSet mLeaves; 119 119 120 120 // Flag for the SAH determining the "cheaper" side of the split plane 121 PlaneEvent::Side mSide;121 BvhPlaneEvent::Side mSide; 122 122 // Flag for the SAH which marks if this renderable was already placed in the list after a split 123 123 bool mClassified; 124 }; // class Bv Renderable124 }; // class BvhRenderable 125 125 126 126 } // namespace Ogre 127 127 128 #endif // _OgreBv Renderable_H__128 #endif // _OgreBvhRenderable_H__
Note: See TracChangeset
for help on using the changeset viewer.