Changeset 1318 for GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE
- Timestamp:
- 09/04/06 00:18:05 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE
- Files:
-
- 12 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/BvHierarchySceneManager/include/OgreBvHierarchy.h
r1317 r1318 8 8 */ 9 9 10 #ifndef _Ogre KdTree_H__11 #define _Ogre KdTree_H__10 #ifndef _OgreBvHierarchy_H__ 11 #define _OgreBvHierarchy_H__ 12 12 13 13 #define KDNODE_CAST(a) (static_cast<KdTree::Node>(a)) … … 29 29 #include <stack> 30 30 31 #include "Ogre KdTreeCamera.h"31 #include "OgreBvHierarchyCamera.h" 32 32 #include "HierarchyInterface.h" 33 33 … … 35 35 namespace Ogre 36 36 { 37 class KdTreeCamera;38 class KdRenderable;37 class BvHierarchyCamera; 38 class BvRenderable; 39 39 struct SplitInfo; 40 40 … … 66 66 { }; 67 67 68 PlaneEvent( KdRenderable *rend, const Vector3& pos, PlaneEvent::Dimension dim, PlaneEvent::Type type):68 PlaneEvent(BvRenderable *rend, const Vector3& pos, PlaneEvent::Dimension dim, PlaneEvent::Type type): 69 69 mRenderable(rend), mPosition(pos), mDimension(dim), mType(type) 70 70 { }; … … 125 125 } 126 126 127 KdRenderable * getRenderable() const //??127 BvRenderable * getRenderable() const //?? 128 128 { 129 129 return mRenderable; … … 139 139 protected: 140 140 // event info 141 KdRenderable * mRenderable;141 BvRenderable * mRenderable; 142 142 Vector3 mPosition; 143 143 PlaneEvent::Dimension mDimension; … … 186 186 187 187 typedef std::list<PlaneEvent> PlaneEventList; 188 typedef std::list< KdRenderable *> KdRenderableList;188 typedef std::list<BvRenderable *> BvRenderableList; 189 189 190 190 class KdTree … … 397 397 398 398 // a leaf is empty when it does not posses renderables 399 virtual bool isEmpty() const { return m KdRenderables.empty(); }399 virtual bool isEmpty() const { return mBvRenderables.empty(); } 400 400 401 401 // a leaf has geometry when it has renderables 402 virtual bool hasGeometry() const { return !m KdRenderables.empty(); }402 virtual bool hasGeometry() const { return !mBvRenderables.empty(); } 403 403 404 404 // a leaf adds itself to the leaf set … … 417 417 virtual void _updateBounds(bool recurse = true); 418 418 419 virtual void remove( KdRenderable * rend)420 { 421 m KdRenderables.remove(rend);422 //m KdRenderables.erase(find(mKdRenderables.begin(), mKdRenderables.end(), rend));419 virtual void remove(BvRenderable * rend) 420 { 421 mBvRenderables.remove(rend); 422 //mBvRenderables.erase(find(mBvRenderables.begin(), mBvRenderables.end(), rend)); 423 423 }; 424 424 425 virtual void insert( KdRenderable * rend)426 { 427 m KdRenderables.push_back(rend);425 virtual void insert(BvRenderable * rend) 426 { 427 mBvRenderables.push_back(rend); 428 428 }; 429 429 430 KdRenderableList mKdRenderables;430 BvRenderableList mBvRenderables; 431 431 }; 432 432 … … 562 562 563 563 // insert a new scene node into an existing kd-tree 564 void insert( KdRenderable * rend);564 void insert(BvRenderable * rend); 565 565 // remove a scene node from the tree 566 void remove( KdRenderable * rend);566 void remove(BvRenderable * rend); 567 567 // function to initialize a kd-tree based on the contents of the scene 568 void build( KdRenderable * sceneRoot);568 void build(BvRenderable * sceneRoot); 569 569 570 570 // test visibility of objects and add to render queue 571 void queueVisibleObjects( KdTreeCamera* cam, RenderQueue* queue, bool onlyShadowCasters,571 void queueVisibleObjects(BvHierarchyCamera* cam, RenderQueue* queue, bool onlyShadowCasters, 572 572 bool showBoxes, KdTree::NodeList& visibleNodes); 573 573 … … 594 594 void init(); 595 595 // recursive insert funciton 596 void recInsert(KdTree::Node * node, KdRenderable * rend);596 void recInsert(KdTree::Node * node, BvRenderable * rend); 597 597 // helper functions for insert 598 void recInsertNew(KdTree::Branch * parent, PlaneEvent::Side side, KdRenderable * rend);598 void recInsertNew(KdTree::Branch * parent, PlaneEvent::Side side, BvRenderable * rend); 599 599 void splitBox(const KdTree::Branch& parent, AxisAlignedBox& left, AxisAlignedBox& right); 600 void rebuildSubtree(KdTree::Node * node, KdRenderable * rend);600 void rebuildSubtree(KdTree::Node * node, BvRenderable * rend); 601 601 // build scene from a list of nodes rather than a hierarchy 602 KdTree::Node * buildFromList( KdRenderableList& nodelist, KdTree::Branch * parent, AxisAlignedBox& aabb);603 void addRendToList(KdTree::Node * node, KdRenderableList& nodelist);602 KdTree::Node * buildFromList(BvRenderableList& nodelist, KdTree::Branch * parent, AxisAlignedBox& aabb); 603 void addRendToList(KdTree::Node * node, BvRenderableList& nodelist); 604 604 605 605 // recursively delete empty nodes … … 615 615 616 616 // recursive rendering function 617 void recQueueVisibleObjects(KdTree::Node * node, unsigned long currentFrame, KdTreeCamera* cam,617 void recQueueVisibleObjects(KdTree::Node * node, unsigned long currentFrame, BvHierarchyCamera* cam, 618 618 RenderQueue* queue, bool onlyShadowCasters, bool showBoxes, 619 619 KdTree::NodeList& visibleNodes, bool fullVis = false); … … 659 659 // allows choosing between regular vis (NONE/PART, same es isVisible) 660 660 // and enhaced vis (NONE/PART/FULL) for early traversal abort 661 KdTreeCamera::NodeVisibility (KdTreeCamera::*getVisibility)(const AxisAlignedBox& box) const;661 BvHierarchyCamera::NodeVisibility (BvHierarchyCamera::*getVisibility)(const AxisAlignedBox& box) const; 662 662 663 663 // DEBUG … … 668 668 } // namespace Ogre 669 669 670 #endif // _Ogre KdTree_H__670 #endif // _OgreBvHierarchy_H__ -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/BvHierarchySceneManager/include/OgreBvHierarchySceneNode.h
r1317 r1318 8 8 */ 9 9 10 #ifndef _Ogre KdTreeSceneNode_H__11 #define _Ogre KdTreeSceneNode_H__10 #ifndef _OgreBvHierarchySceneNode_H__ 11 #define _OgreBvHierarchySceneNode_H__ 12 12 13 13 #include <OgreSceneNode.h> 14 #include "Ogre KdRenderable.h"14 #include "OgreBvRenderable.h" 15 15 16 16 namespace Ogre 17 17 { 18 18 19 class KdTreeSceneNode : public SceneNode, public KdRenderable19 class KdTreeSceneNode : public SceneNode, public BvRenderable 20 20 { 21 21 public: … … 52 52 } // namespace Ogre 53 53 54 #endif // _Ogre KdTreeSceneNode_H__54 #endif // _OgreBvHierarchySceneNode_H__ -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/BvHierarchySceneManager/src/OgreBvHierarchy.cpp
r1317 r1318 8 8 */ 9 9 10 #include "Ogre KdTree.h"11 #include "Ogre KdRenderable.h"12 #include "Ogre KdTreeSceneNode.h"13 #include "Ogre KdTreeSceneManager.h"10 #include "OgreBvHierarchy.h" 11 #include "OgreBvRenderable.h" 12 #include "OgreBvHierarchySceneNode.h" 13 #include "OgreBvHierarchySceneManager.h" 14 14 15 15 #include <OgreStringConverter.h> … … 589 589 /************************************************************************/ 590 590 591 void KdTree::remove( KdRenderable * rend)591 void KdTree::remove(BvRenderable * rend) 592 592 { 593 593 // DEBUG … … 621 621 { 622 622 OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, 623 "SNAFU while inserting KdRenderable into KdTree.",623 "SNAFU while inserting BvRenderable into KdTree.", 624 624 "KdTree::recInsert" ); 625 625 return; … … 648 648 } 649 649 650 void KdTree::insert( KdRenderable * rend)650 void KdTree::insert(BvRenderable * rend) 651 651 { 652 652 // make sure the tree exists … … 663 663 { 664 664 //LogManager::getSingleton().logMessage("Inserted node outside of world AABB."); 665 KdRenderableList nodelist;665 BvRenderableList nodelist; 666 666 nodelist.push_back(rend); 667 667 addRendToList(mKdRoot, nodelist); … … 677 677 } 678 678 679 void KdTree::recInsert(KdTree::Node * node, KdRenderable * rend)679 void KdTree::recInsert(KdTree::Node * node, BvRenderable * rend) 680 680 { 681 681 if (node == 0) // DEBUG 682 682 { 683 683 OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, 684 "SNAFU while inserting KdRenderable into KdTree.",684 "SNAFU while inserting BvRenderable into KdTree.", 685 685 "KdTree::recInsert" ); 686 686 return; … … 744 744 } 745 745 746 void KdTree::recInsertNew(KdTree::Branch * parent, PlaneEvent::Side side, KdRenderable * rend)746 void KdTree::recInsertNew(KdTree::Branch * parent, PlaneEvent::Side side, BvRenderable * rend) 747 747 { 748 748 //LogManager::getSingleton().logMessage("## Inserting into new subtree"); … … 789 789 } 790 790 791 void KdTree::rebuildSubtree(KdTree::Node * node, KdRenderable * rend)791 void KdTree::rebuildSubtree(KdTree::Node * node, BvRenderable * rend) 792 792 { 793 793 //LogManager::getSingleton().logMessage("## Rebuilding subtree"); … … 795 795 AxisAlignedBox aabb = node->mAABB; 796 796 797 KdRenderableList nodelist;797 BvRenderableList nodelist; 798 798 nodelist.push_back(rend); 799 799 addRendToList(node, nodelist); … … 821 821 { 822 822 OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, 823 "SNAFU while inserting KdRenderable into KdTree.",823 "SNAFU while inserting BvRenderable into KdTree.", 824 824 "KdTree::recInsert" ); 825 825 } … … 845 845 } 846 846 847 void KdTree::addRendToList(KdTree::Node * node, KdRenderableList& nodelist)847 void KdTree::addRendToList(KdTree::Node * node, BvRenderableList& nodelist) 848 848 { 849 849 if (node->isLeaf()) 850 850 { 851 851 KdTree::Leaf * leaf = KDLEAFPTR_CAST(node); 852 KdRenderableList::iterator it = leaf->mKdRenderables.begin();853 KdRenderableList::iterator end = leaf->mKdRenderables.end();852 BvRenderableList::iterator it = leaf->mBvRenderables.begin(); 853 BvRenderableList::iterator end = leaf->mBvRenderables.end(); 854 854 while (it != end) 855 855 { … … 872 872 /************************************************************************/ 873 873 874 void KdTree::build( KdRenderable * sceneRoot)874 void KdTree::build(BvRenderable * sceneRoot) 875 875 { 876 876 Timer *timer = Root::getSingleton().getTimer(); … … 931 931 } 932 932 933 KdTree::Node * KdTree::buildFromList( KdRenderableList& nodelist, KdTree::Branch * parent, AxisAlignedBox& aabb)933 KdTree::Node * KdTree::buildFromList(BvRenderableList& nodelist, KdTree::Branch * parent, AxisAlignedBox& aabb) 934 934 { 935 935 // data we want to collect … … 938 938 int nObjects = 0; 939 939 940 KdRenderableList::iterator it = nodelist.begin();941 KdRenderableList::iterator end = nodelist.end();940 BvRenderableList::iterator it = nodelist.begin(); 941 BvRenderableList::iterator end = nodelist.end(); 942 942 while (it != end) 943 943 { … … 1031 1031 // Terminating condition reached, create leaf and add renderables to list 1032 1032 KdTree::Leaf * leaf = new KdTree::Leaf(this, level, aabb, parent); 1033 KdRenderable *rend;1033 BvRenderable *rend; 1034 1034 it = begin; 1035 1035 while (it != end) … … 1178 1178 // Terminating condition reached, create leaf and add renderables to list 1179 1179 KdTree::Leaf * leaf = new KdTree::Leaf(this, level, sc.aabb, sc.parent); 1180 KdRenderable *rend;1180 BvRenderable *rend; 1181 1181 PlaneEventList::iterator begin = sc.events->begin(); 1182 1182 PlaneEventList::iterator end = sc.events->end(); … … 1396 1396 1397 1397 //------------------------------------------------------------------------- 1398 void KdTree::queueVisibleObjects( KdTreeCamera* cam, RenderQueue* queue, bool onlyShadowCasters,1398 void KdTree::queueVisibleObjects(BvHierarchyCamera* cam, RenderQueue* queue, bool onlyShadowCasters, 1399 1399 bool showBoxes, KdTree::NodeList& visibleNodes) 1400 1400 { … … 1411 1411 //------------------------------------------------------------------------- 1412 1412 void KdTree::recQueueVisibleObjects(KdTree::Node * node, unsigned long currentFrame, 1413 KdTreeCamera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes,1413 BvHierarchyCamera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes, 1414 1414 KdTree::NodeList& visibleNodes, bool fullVis) 1415 1415 { 1416 KdTreeCamera::NodeVisibility vis = KdTreeCamera::KDNV_PART;1416 BvHierarchyCamera::NodeVisibility vis = BvHierarchyCamera::KDNV_PART; 1417 1417 // test visibility 1418 1418 //if (cam->isVisible(node->mAABB)) 1419 1419 if (fullVis || 1420 ((vis = (cam->*getVisibility)(node->mAABB)) != KdTreeCamera::KDNV_NONE))1420 ((vis = (cam->*getVisibility)(node->mAABB)) != BvHierarchyCamera::KDNV_NONE)) 1421 1421 { 1422 1422 visibleNodes.push_back(node); 1423 1423 1424 bool v = (fullVis || vis == KdTreeCamera::KDNV_FULL);1424 bool v = (fullVis || vis == BvHierarchyCamera::KDNV_FULL); 1425 1425 1426 1426 node->queueVisibleObjects(currentFrame, cam, queue, onlyShadowCasters, showBoxes, v); … … 1450 1450 { 1451 1451 if (enh) 1452 getVisibility = & KdTreeCamera::getVisibilityEnhanced;1452 getVisibility = &BvHierarchyCamera::getVisibilityEnhanced; 1453 1453 else 1454 getVisibility = & KdTreeCamera::getVisibilitySimple;1454 getVisibility = &BvHierarchyCamera::getVisibilitySimple; 1455 1455 } 1456 1456 … … 1458 1458 bool KdTree::getEnhancedVis() 1459 1459 { 1460 return getVisibility == & KdTreeCamera::getVisibilityEnhanced;1460 return getVisibility == &BvHierarchyCamera::getVisibilityEnhanced; 1461 1461 } 1462 1462 … … 1523 1523 { 1524 1524 LeafPtr leaf = KDLEAFPTR_CAST(node); 1525 for ( KdRenderableList::iterator it = leaf->mKdRenderables.begin();1526 it != leaf->m KdRenderables.end(); it ++)1525 for (BvRenderableList::iterator it = leaf->mBvRenderables.begin(); 1526 it != leaf->mBvRenderables.end(); it ++) 1527 1527 { 1528 1528 SceneNode *sn = dynamic_cast<SceneNode *>(*it); … … 1600 1600 { 1601 1601 KdTree::Leaf * leaf = KDLEAFPTR_CAST(node); 1602 KdRenderableList::iterator it = leaf->mKdRenderables.begin();1603 KdRenderableList::iterator end = leaf->mKdRenderables.end();1602 BvRenderableList::iterator it = leaf->mBvRenderables.begin(); 1603 BvRenderableList::iterator end = leaf->mBvRenderables.end(); 1604 1604 while (it != end) 1605 1605 { … … 1649 1649 KdTree::Leaf * leaf = KDLEAFPTR_CAST(node); 1650 1650 return (PlaneEvent::surfaceArea(node->mAABB)/vs) * 1651 PlaneEvent::KI * leaf->m KdRenderables.size();1651 PlaneEvent::KI * leaf->mBvRenderables.size(); 1652 1652 } 1653 1653 else … … 1668 1668 // detach all scene nodes in the case that we are rebuilding 1669 1669 // the tree but not the scene 1670 KdRenderableList::iterator it = mKdRenderables.begin();1671 KdRenderableList::iterator end = mKdRenderables.end();1670 BvRenderableList::iterator it = mBvRenderables.begin(); 1671 BvRenderableList::iterator end = mBvRenderables.end(); 1672 1672 while (it != end) 1673 1673 { … … 1675 1675 it++; 1676 1676 } 1677 m KdRenderables.clear();1677 mBvRenderables.clear(); 1678 1678 } 1679 1679 … … 1682 1682 Camera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes, bool fullVis) 1683 1683 { 1684 KdRenderableList::iterator it = mKdRenderables.begin();1685 KdRenderableList::iterator end = mKdRenderables.end();1684 BvRenderableList::iterator it = mBvRenderables.begin(); 1685 BvRenderableList::iterator end = mBvRenderables.end(); 1686 1686 while (it != end) 1687 1687 { … … 1701 1701 void KdTree::Leaf::getGeometryList(GtpVisibility::GeometryVector *geometryList) 1702 1702 { 1703 KdRenderableList::iterator it = mKdRenderables.begin();1704 KdRenderableList::iterator end = mKdRenderables.end();1703 BvRenderableList::iterator it = mBvRenderables.begin(); 1704 BvRenderableList::iterator end = mBvRenderables.end(); 1705 1705 while (it != end) 1706 1706 { … … 1718 1718 1719 1719 // merge boxes from attached geometry 1720 KdRenderableList::iterator it = mKdRenderables.begin();1721 KdRenderableList::iterator end = mKdRenderables.end();1720 BvRenderableList::iterator it = mBvRenderables.begin(); 1721 BvRenderableList::iterator end = mBvRenderables.end(); 1722 1722 while (it != end) 1723 1723 {
Note: See TracChangeset
for help on using the changeset viewer.