Changeset 1320


Ignore:
Timestamp:
09/04/06 08:56:26 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis
Files:
9 edited
6 moved

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/GtpVisibility.sln

    r1318 r1320  
    3939                {80DECC17-BDDD-4412-8CF8-F7C1C17A7436} = {80DECC17-BDDD-4412-8CF8-F7C1C17A7436} 
    4040                {7319E499-473D-4CE5-9983-725D6E68A55D} = {7319E499-473D-4CE5-9983-725D6E68A55D} 
    41         EndProjectSection 
    42 EndProject 
    43 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_BvhSceneManager", "OnlineCullingCHC\OGRE\BvHierarchySceneManager\src\Plugin_BvhSceneManager.vcproj", "{80DECC17-BDDD-4412-8CF8-F7C1C17A7436}" 
    44         ProjectSection(ProjectDependencies) = postProject 
    4541        EndProjectSection 
    4642EndProject 
     
    151147                {17F2C6F9-6101-430E-ABF4-71383868EF24}.Release Static.ActiveCfg = Release|Win32 
    152148                {17F2C6F9-6101-430E-ABF4-71383868EF24}.Release Static.Build.0 = Release|Win32 
    153                 {80DECC17-BDDD-4412-8CF8-F7C1C17A7436}.Debug.ActiveCfg = Debug|Win32 
    154                 {80DECC17-BDDD-4412-8CF8-F7C1C17A7436}.Debug.Build.0 = Debug|Win32 
    155                 {80DECC17-BDDD-4412-8CF8-F7C1C17A7436}.Debug Static.ActiveCfg = Debug|Win32 
    156                 {80DECC17-BDDD-4412-8CF8-F7C1C17A7436}.Debug Static.Build.0 = Debug|Win32 
    157                 {80DECC17-BDDD-4412-8CF8-F7C1C17A7436}.mlrt.ActiveCfg = mlrt|Win32 
    158                 {80DECC17-BDDD-4412-8CF8-F7C1C17A7436}.mlrt.Build.0 = mlrt|Win32 
    159                 {80DECC17-BDDD-4412-8CF8-F7C1C17A7436}.Release.ActiveCfg = Release|Win32 
    160                 {80DECC17-BDDD-4412-8CF8-F7C1C17A7436}.Release.Build.0 = Release|Win32 
    161                 {80DECC17-BDDD-4412-8CF8-F7C1C17A7436}.Release Internal.ActiveCfg = Release Internal|Win32 
    162                 {80DECC17-BDDD-4412-8CF8-F7C1C17A7436}.Release Internal.Build.0 = Release Internal|Win32 
    163                 {80DECC17-BDDD-4412-8CF8-F7C1C17A7436}.Release Static.ActiveCfg = Release Internal|Win32 
    164                 {80DECC17-BDDD-4412-8CF8-F7C1C17A7436}.Release Static.Build.0 = Release Internal|Win32 
    165  
    166149        EndGlobalSection 
    167150        GlobalSection(ExtensibilityGlobals) = postSolution 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreBvHierarchy.h

    r1319 r1320  
    1111#define _OgreBvHierarchy_H__ 
    1212 
    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" 
    2121 
    2222#include <OgreAxisAlignedBox.h> 
     
    3131#include "OgreBvHierarchyCamera.h" 
    3232#include "HierarchyInterface.h" 
    33  
     33#include "OgreKdTree.h" 
    3434 
    3535namespace Ogre 
    3636{ 
    3737        class BvHierarchyCamera; 
    38         class BvRenderable; 
    39         struct SplitInfo; 
    40  
    41         class PlaneEvent 
     38        class BvhRenderable; 
     39        struct BvhSplitInfo; 
     40         
     41        class BvhPlaneEvent 
    4242        { 
    4343        public: 
     
    6363                }; 
    6464 
    65                 PlaneEvent(): mRenderable(0), mPosition(Vector3()), mDimension(PED_X), mType(PET_ON) 
     65                BvhPlaneEvent(): mRenderable(0), mPosition(Vector3()), mDimension(PED_X), mType(PET_ON) 
    6666                { }; 
    6767 
    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): 
    6969                        mRenderable(rend), mPosition(pos), mDimension(dim), mType(type)  
    7070                { }; 
    7171 
    72                 ~PlaneEvent() {}; 
     72                ~BvhPlaneEvent() {}; 
    7373 
    7474                // the less operator for plane events 
    7575                // first sort by position, then by dimension and finally by type 
    76                 bool operator < (const PlaneEvent& e) const 
     76                bool operator < (const BvhPlaneEvent& e) const 
    7777                { 
    7878                        if(mPosition[mDimension] < e.mPosition[e.mDimension]) 
     
    100100 
    101101                // the equals operator for tree events 
    102                 bool operator == (const PlaneEvent& e) const 
     102                bool operator == (const BvhPlaneEvent& e) const 
    103103                { 
    104104                        return  (mPosition[mDimension] == e.mPosition[e.mDimension]) && 
     
    107107                }; 
    108108 
    109                 bool equalsType(const PlaneEvent& e, PlaneEvent::Type t) 
     109                bool equalsType(const BvhPlaneEvent& e, BvhPlaneEvent::Type t) 
    110110                { 
    111111                        return  (mPosition[mDimension] == e.mPosition[e.mDimension]) && 
     
    114114                }; 
    115115 
    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); 
    119119 
    120120                Plane * getSplitPlane() const 
     
    125125                } 
    126126 
    127                 BvRenderable * getRenderable() const //?? 
     127                BvhRenderable * getRenderable() const //?? 
    128128                { 
    129129                        return mRenderable; 
    130130                }; 
    131131 
    132                 PlaneEvent::Dimension getDimension() const //?? 
     132                BvhPlaneEvent::Dimension getDimension() const //?? 
    133133                { 
    134134                        return mDimension; 
     
    139139        protected: 
    140140                // event info 
    141                 BvRenderable *                  mRenderable; 
     141                BvhRenderable *                 mRenderable; 
    142142                Vector3                                 mPosition; 
    143                 PlaneEvent::Dimension   mDimension; 
    144                 PlaneEvent::Type                mType; 
     143                BvhPlaneEvent::Dimension        mDimension; 
     144                BvhPlaneEvent::Type             mType; 
    145145 
    146146                // ------------------------------------------------------------------------------// 
     
    149149                // TODO discuss if these functions really belong here, OO & SE - wise 
    150150                // pros: convenient, don't have to pass internal data to the outside 
    151                 // cons: SplitInfo ...  
     151                // cons: BvhSplitInfo ...  
    152152        public: 
    153153                // compute "global" surface area heuristic (SAH) for the plane represented by this event 
    154154                // 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); 
    156156                static Real pqSplitCost(Real p, Real pl, Real pr, int nLeft, int nRight, Real mu); 
    157157 
    158158                // 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); 
    160160                // the variables determining the cost of a branch traversal (KT) and a leaf intersection (KI) 
    161161                static Real KT; 
     
    171171 
    172172        // Holds all the important information on a split 
    173         struct SplitInfo 
     173        struct BvhSplitInfo 
    174174        { 
    175175                AxisAlignedBox bleft; 
     
    178178                int nright; 
    179179                Real cost; 
    180                 PlaneEvent::Side side; 
    181                 PlaneEvent event; 
     180                BvhPlaneEvent::Side side; 
     181                BvhPlaneEvent event; 
    182182 
    183183                // DEBUG 
     
    185185        }; 
    186186 
    187         typedef std::list<PlaneEvent> PlaneEventList; 
    188         typedef std::list<BvRenderable *> BvRenderableList; 
     187        typedef std::list<BvhRenderable *> BvhRenderableList; 
     188        typedef std::list<BvhPlaneEvent> BvhPlaneEventList; 
    189189         
    190         class KdTree 
     190        class BvHierarchy 
    191191        { 
    192192        protected: 
     
    197197                { 
    198198                public: 
    199                         Node(KdTree * owner, int level, AxisAlignedBox& aabb, Branch * parent): 
     199                        Node(BvHierarchy * owner, int level, AxisAlignedBox& aabb, Branch * parent): 
    200200                        mOwner(owner), 
    201201                        mLevel(level), 
     
    217217 
    218218                        // 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; }; 
    220220 
    221221                        // 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; 
    224224 
    225225                        // add contained objects to render queue 
     
    242242 
    243243                                if (mOwner->getHiLiteLevel() == mLevel) 
    244                                         mWBB->setMaterial("KdTree/BoxHiLite"); 
     244                                        mWBB->setMaterial("BvHierarchy/BoxHiLite"); 
    245245                                else 
    246246                                        mWBB->setMaterial("BaseWhiteNoLighting"); 
     
    275275                        */ 
    276276                        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.  
    278278                        */ 
    279279                        AxisAlignedBox _getWorldAABB(void) const { return mAABB; }; 
    280                         /** Updates bound of the real aabb of kdtree 
     280                        /** Updates bound of the real aabb of BvHierarchy 
    281281                        */ 
    282282                        virtual void _updateBounds(bool recurse = true) = 0; 
     
    288288                        AxisAlignedBox mWorldAABB; 
    289289                protected: 
    290                         KdTree * mOwner; 
     290                        BvHierarchy * mOwner; 
    291291                        Branch * mParent; 
    292292                        int mLevel; 
     
    303303                { 
    304304                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): 
    307307                        Node(owner, level, aabb, parent),  
    308308                        mSplitPlane(splitplane),  
     
    335335 
    336336                        // 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; }; 
    339339 
    340340                        virtual void queueVisibleObjects(unsigned long currentFrame,  
     
    379379                        Node * mRight; 
    380380                        Plane  * mSplitPlane; 
    381                         PlaneEvent::Side mPlaneSide; 
     381                        BvhPlaneEvent::Side mPlaneSide; 
    382382                protected: 
    383383                        std::set<Leaf *> mLeaves; 
     
    387387                { 
    388388                public: 
    389                         Leaf(KdTree * owner, int level, AxisAlignedBox& aabb, Branch * parent): 
     389                        Leaf(BvHierarchy * owner, int level, AxisAlignedBox& aabb, Branch * parent): 
    390390                        Node(owner, level, aabb, parent)  
    391391                        {}; 
     
    397397 
    398398                        // a leaf is empty when it does not posses renderables 
    399                         virtual bool isEmpty() const { return mBvRenderables.empty(); } 
     399                        virtual bool isEmpty() const { return mBvhRenderables.empty(); } 
    400400 
    401401                        // a leaf has geometry when it has renderables 
    402                         virtual bool hasGeometry() const { return !mBvRenderables.empty(); } 
     402                        virtual bool hasGeometry() const { return !mBvhRenderables.empty(); } 
    403403 
    404404                        // a leaf adds itself to the leaf set 
     
    406406 
    407407                        // 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; }; 
    410410 
    411411                        virtual void queueVisibleObjects(unsigned long currentFrame,  
     
    417417                        virtual void _updateBounds(bool recurse = true); 
    418418 
    419                         virtual void remove(BvRenderable * rend) 
    420                         { 
    421                                 mBvRenderables.remove(rend); 
    422                                 //mBvRenderables.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)); 
    423423                        }; 
    424424 
    425                         virtual void insert(BvRenderable * rend) 
    426                         { 
    427                                 mBvRenderables.push_back(rend); 
     425                        virtual void insert(BvhRenderable * rend) 
     426                        { 
     427                                mBvhRenderables.push_back(rend); 
    428428                        }; 
    429429 
    430                         BvRenderableList mBvRenderables; 
    431                 }; 
    432  
    433                 struct SplitCandidate 
    434                 { 
    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): 
    437437                        events(e), nObjects(n), aabb(a), parent(p), cost(c), decrease(d), best(b), side(s) 
    438438                        { }; 
    439439 
    440                         bool operator < (const SplitCandidate& rhs) const 
     440                        bool operator < (const BvhSubdivisionCandidate& rhs) const 
    441441                        { 
    442442                                return decrease < rhs.decrease; 
    443443                        }; 
    444444 
    445                         void operator = (const SplitCandidate& rhs) 
     445                        void operator = (const BvhSubdivisionCandidate& rhs) 
    446446                        { 
    447447                                decrease = rhs.decrease; 
     
    461461                        Real cost; 
    462462                        int nObjects; 
    463                         PlaneEvent::Side side; 
     463                        BvhPlaneEvent::Side side; 
    464464                        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; 
    472472 
    473473                // nodestack for the stack-based rendering function 
    474                 typedef std::stack<KdTree::Node *> NodeStack; 
     474                typedef std::stack<BvHierarchy::Node *> NodeStack; 
    475475        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; 
    481481 
    482482                typedef std::list<NodePtr> NodeList; 
     
    513513                enum RenderMethod 
    514514                { 
    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, 
    519519                        // invalid modes, just for convenience 
    520                         KDRM_SIZE, 
    521                         KDRM_NOTSET 
     520                        BVHRM_SIZE, 
     521                        BVHRM_NOTSET 
    522522                }; 
    523523 
    524524                enum BuildMethod 
    525525                { 
    526                         KDBM_RECURSIVE, 
    527                         KDBM_PRIORITYQUEUE, 
     526                        BVHBM_RECURSIVE, 
     527                        BVHBM_PRIORITYQUEUE, 
    528528                        // invalid modes, just for convenience 
    529                         KDBM_SIZE, 
    530                         KDBM_NOTSET 
     529                        BVHBM_SIZE, 
     530                        BVHBM_NOTSET 
    531531                }; 
    532532 
     
    534534                const static int HILITE_OFF  = -1; 
    535535                 
    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(); 
    539539 
    540540                // DEBUG 
     
    546546                inline int  getHiLiteLevel(void) { return mHiLiteLevel; }; 
    547547 
    548                 // toggles displaying the kdtree boxes 
     548                // toggles displaying the BvHierarchy boxes 
    549549                inline void setShowAllBoxes(bool show) { mShowAllBoxes = show; }; 
    550550                inline bool getShowAllBoxes(void) { return mShowAllBoxes; }; 
     
    559559                bool getEnhancedVis(void); 
    560560 
    561                 NodePtr getRoot(void) const { return mKdRoot; }; 
    562  
    563                 // insert a new scene node into an existing kd-tree 
    564                 void insert(BvRenderable * rend); 
     561                NodePtr getRoot(void) const { return mBvhRoot; }; 
     562 
     563                // insert a new scene node into an existing bvhierarchy 
     564                void insert(BvhRenderable * rend); 
    565565                // remove a scene node from the tree 
    566                 void remove(BvRenderable * rend); 
     566                void remove(BvhRenderable * rend); 
    567567                // function to initialize a kd-tree based on the contents of the scene 
    568                 void build(BvRenderable * sceneRoot); 
     568                void build(BvhRenderable * sceneRoot); 
    569569 
    570570                // test visibility of objects and add to render queue 
    571571                void queueVisibleObjects(BvHierarchyCamera* cam, RenderQueue* queue, bool onlyShadowCasters,  
    572                         bool showBoxes, KdTree::NodeList& visibleNodes); 
     572                        bool showBoxes, BvHierarchy::NodeList& visibleNodes); 
    573573 
    574574                // find visible nodes & place in list 
    575575                //void findVisibleNodes(NodeList& visibleNodes, Camera * cam); 
    576576 
    577                 /** Recurses the kdtree, adding any nodes intersecting with the  
     577                /** Recurses the BvHierarchy, adding any nodes intersecting with the  
    578578                box/sphere/volume/ray into the given list. 
    579579                It ignores the exclude scene node. 
     
    588588                const TreeStats& getTreeStats(void) const { return mTreeStats; } 
    589589                const FrameStats& getFramesStats(void) const { return mFrameStats; } 
    590                 AxisAlignedBox getBox(void) { if (mKdRoot) return mKdRoot->mAABB; else return AxisAlignedBox(); } 
     590                AxisAlignedBox getBox(void) { if (mBvhRoot) return mBvhRoot->mAABB; else return AxisAlignedBox(); } 
    591591                void setBuildMethod(BuildMethod bm) { mBuildMethod = bm; } 
    592592        protected: 
     
    594594                void init(); 
    595595                // recursive insert funciton 
    596                 void recInsert(KdTree::Node * node, BvRenderable * rend); 
     596                void recInsert(BvHierarchy::Node * node, BvhRenderable * rend); 
    597597                // 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); 
    601601                // 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); 
    604604 
    605605                // recursively delete empty nodes 
    606                 void recDelete(KdTree::Node * node); 
     606                void recDelete(BvHierarchy::Node * node); 
    607607 
    608608                // 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); 
    610610 
    611611                // 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); 
    613613                // 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); 
    615615 
    616616                // 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, 
    618618                        RenderQueue* queue, bool onlyShadowCasters, bool showBoxes,  
    619                         KdTree::NodeList& visibleNodes, bool fullVis = false); 
     619                        BvHierarchy::NodeList& visibleNodes, bool fullVis = false); 
    620620 
    621621                // recursively find visible nodes 
    622                 //void recFindVisibleNodes(KdTree::Node * node, NodeList& visibleNodes, Camera * cam); 
    623  
    624                 /** Recurses the kdtree, adding any nodes intersecting with the  
     622                //void recFindVisibleNodes(BvHierarchy::Node * node, NodeList& visibleNodes, Camera * cam); 
     623 
     624                /** Recurses the BvHierarchy, adding any nodes intersecting with the  
    625625                box/sphere/volume/ray into the given list. 
    626626                It ignores the exclude scene node. 
     
    631631                void recFindNodesIn(const Ray &ray, std::list<SceneNode *> &list, SceneNode *exclude, Node * node, bool full = false); 
    632632 
    633                 // the root node of the kdtree 
    634                 KdTree::Node * mKdRoot; 
     633                // the root node of the BvHierarchy 
     634                BvHierarchy::Node * mBvhRoot; 
    635635                // Maximum depth of the tree 
    636636                int mMaxDepth; 
     
    649649 
    650650                /** Visualization flags **/ 
    651                 // show/highlight selected level in kdtree 
     651                // show/highlight selected level in BvHierarchy 
    652652                int mHiLiteLevel; 
    653653                // show whole kd-tree 
     
    662662 
    663663                // DEBUG 
    664                 void KdTree::dump(KdTree::Node * node); 
    665                 Real KdTree::calcCost(KdTree::Node * node, Real vs); 
    666         }; // class KdTree 
     664                void BvHierarchy::dump(BvHierarchy::Node * node); 
     665                Real BvHierarchy::calcCost(BvHierarchy::Node * node, Real vs); 
     666        }; // class BvHierarchy 
    667667 
    668668} // namespace Ogre 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreBvHierarchyCamera.h

    r1319 r1320  
    1313#include <OgreCamera.h> 
    1414 
    15 #define KDCAMPTR_CAST(cam) (static_cast<BvHierarchyCamera *>(cam)) 
     15#define BVHCAMPTR_CAST(cam) (static_cast<BvHierarchyCamera *>(cam)) 
    1616 
    1717namespace Ogre 
     
    2323        enum NodeVisibility 
    2424        { 
    25                 KDNV_NONE, 
    26                 KDNV_PART, 
    27                 KDNV_FULL 
     25                BVHNV_NONE, 
     26                BVHNV_PART, 
     27                BVHNV_FULL 
    2828        }; 
    2929 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreBvHierarchyInterface.h

    r1319 r1320  
    1616{ 
    1717 
    18 class KdTreeSceneManager; 
     18class BvHierarchySceneManager; 
    1919 
    20 class KdTreeHierarchyInterface : public PlatformHierarchyInterface 
     20class BvHierarchyInterface : public PlatformHierarchyInterface 
    2121{ 
    2222public: 
    23         KdTreeHierarchyInterface(KdTreeSceneManager *sm, RenderSystem *rsys); 
     23        BvHierarchyInterface(BvHierarchySceneManager *sm, RenderSystem *rsys); 
    2424 
    25         virtual ~KdTreeHierarchyInterface() {}; 
     25        virtual ~BvHierarchyInterface() {}; 
    2626 
    2727        /** Returns true if current node is leaf of the hierarchy.  
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreBvHierarchySceneManager.h

    r1319 r1320  
    88*/ 
    99 
    10 #ifndef _KdTreeSceneManager_H__ 
    11 #define _KdTreeSceneManager_H__ 
     10#ifndef _BvHierarchySceneManager_H__ 
     11#define _BvHierarchySceneManager_H__ 
    1212 
    1313#include <OgreSceneManager.h> 
     
    1919#include "OgreBvHierarchyInterface.h" 
    2020 
    21 #define KDTREE_MAX_DEPTH 12 
     21#define BvHierarchy_MAX_DEPTH 12 
    2222 
    2323namespace Ogre 
    2424{ 
    2525 
    26 class KdTreeSceneNode; 
    27  
    28 class KdTreeSceneManager : public SceneManager 
     26class BvHierarchySceneNode; 
     27 
     28class BvHierarchySceneManager : public SceneManager 
    2929{ 
    3030public: 
    31         KdTreeSceneManager(const String& name, GtpVisibility::VisibilityManager *vm); 
    32         ~KdTreeSceneManager(void); 
     31        BvHierarchySceneManager(const String& name, GtpVisibility::VisibilityManager *vm); 
     32        ~BvHierarchySceneManager(void); 
    3333 
    3434        virtual const String& getTypeName(void) const; 
    3535 
    36         //typedef std::list<KdTreeSceneNode *> NodeList; 
     36        //typedef std::list<BvHierarchySceneNode *> NodeList; 
    3737        //typedef std::list<WireBoundingBox *> BoxList; 
    3838 
    3939        /************************************************************************/ 
    40         /* Functions overridden form SceneManager for KdTree                    */ 
     40        /* Functions overridden form SceneManager for BvHierarchy                    */ 
    4141        /************************************************************************/ 
    4242 
     
    4545        virtual Camera* createCamera(const String& name); 
    4646 
    47         /** Override from SceneManager to create SceneNodes as instance of KdTreeSceneNode 
     47        /** Override from SceneManager to create SceneNodes as instance of BvHierarchySceneNode 
    4848        */ 
    4949        virtual SceneNode* createSceneNode(void); 
    50         /** Override from SceneManager to create SceneNodes as instance of KdTreeSceneNode 
     50        /** Override from SceneManager to create SceneNodes as instance of BvHierarchySceneNode 
    5151        */ 
    5252        virtual SceneNode* createSceneNode(const String& name); 
     
    6262        bool getOptionKeys(StringVector &refKeys); 
    6363 
    64         /** Overide from scene manager to destroy kdtree properly (before the scene graph is destroyed) 
     64        /** Overide from scene manager to destroy BvHierarchy properly (before the scene graph is destroyed) 
    6565        */ 
    6666        virtual void clearScene(); 
     
    110110 
    111111        /************************************************************************/ 
    112         /* Functions which are specific to the KdTree                           */ 
     112        /* Functions which are specific to the BvHierarchy                           */ 
    113113        /************************************************************************/ 
    114114         
    115         /** Update the KdTree with the node (more or less disabled now) 
    116         */ 
    117         virtual void _updateNode(KdTreeSceneNode *node); // TODO:  
    118  
    119         /** Show or hide the bounding boxes of KdTree nodes - obsolete, use options 
     115        /** 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 
    120120        */ 
    121121        virtual void setShowBoxes(bool showboxes); 
     
    124124        virtual bool getShowBoxes(void) const; 
    125125 
    126         /** Recurses the kdtree, adding any nodes intersecting with the  
     126        /** Recurses the BvHierarchy, adding any nodes intersecting with the  
    127127        box/sphere/volume/ray into the given list. 
    128128        It ignores the exclude scene node. 
     
    162162        /** Render a list of scenenodes 
    163163        */ 
    164         //virtual void _renderNodes(const BvRenderableList& nodelist, Camera * cam, 
     164        //virtual void _renderNodes(const BvhRenderableList& nodelist, Camera * cam, 
    165165        //      bool onlyShadowCasters, int leavePassesInQueue); 
    166         virtual void _renderNode(KdTree::NodePtr node, Camera * cam, 
     166        virtual void _renderNode(BvHierarchy::NodePtr node, Camera * cam, 
    167167                bool onlyShadowCasters, int leavePassesInQueue); 
    168168 
     
    181181        /** Returns hierarchy interface. 
    182182        */ 
    183         KdTreeHierarchyInterface *GetHierarchyInterface(); 
     183        BvHierarchyInterface *GetHierarchyInterface(); 
    184184 
    185185protected: 
     
    223223 
    224224        // the hierarchy interface for CHC 
    225         KdTreeHierarchyInterface *mHierarchyInterface; 
     225        BvHierarchyInterface *mHierarchyInterface; 
    226226 
    227227        // if hierarchical culling is currently in use 
     
    273273 
    274274        // remember visited scene nodes for viz 
    275         KdTree::NodeList mVisibleNodes; 
     275        BvHierarchy::NodeList mVisibleNodes; 
    276276 
    277277        /************************************************************************/ 
    278278        /* Kd-Tree specific options & members                                   */ 
    279279        /************************************************************************/ 
    280         // maximum depth of the kdtree 
     280        // maximum depth of the BvHierarchy 
    281281        int mMaxDepth; 
    282282 
    283         // the kdtree which holds the scene 
    284         KdTree *mBvHierarchy; 
    285  
    286         // if bounding boxes of kdtree nodes are shown 
     283        // the BvHierarchy which holds the scene 
     284        BvHierarchy *mBvHierarchy; 
     285 
     286        // if bounding boxes of BvHierarchy nodes are shown 
    287287        bool mShowBoxes; 
    288288        // bounding boxes of kd nodes will be highlighted on this level of the kd tree 
     
    290290        // if all bounding boxes shall be displayed, not only the highlighted level 
    291291        bool mShowAllBoxes; 
    292         // visualize kdtree nodes or bounding boxes of objects in nodes 
     292        // visualize BvHierarchy nodes or bounding boxes of objects in nodes 
    293293        bool mShowNodes; 
    294294 
     
    297297 
    298298        // the method/algorithm used when rendering the scene 
    299         KdTree::RenderMethod mRenderMethod; 
     299        BvHierarchy::RenderMethod mRenderMethod; 
    300300 
    301301        // the method of building the tree 
    302         KdTree::BuildMethod mBuildMethod; 
     302        BvHierarchy::BuildMethod mBuildMethod; 
    303303 
    304304        /************************************************************************/ 
     
    327327 
    328328 
    329 /// Factory for KdTreeSceneManager 
    330 class BvHierarchySceneManagerFactory : public SceneManagerFactory 
     329/// Factory for BvHierarchySceneManager 
     330class BvHierarchySceneManagerFactory: public SceneManagerFactory 
    331331{ 
    332332protected: 
     
    337337        { 
    338338                visManager = vm; 
    339         }; 
     339        } 
    340340        ~BvHierarchySceneManagerFactory(void) {}; 
    341341        /// Factory type name 
     
    347347} // namespace Ogre 
    348348 
    349 #endif // _KdTreeSceneManager_H__ 
     349#endif // _BvHierarchySceneManager_H__ 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreBvHierarchySceneNode.h

    r1319 r1320  
    1212 
    1313#include <OgreSceneNode.h> 
    14 #include "OgreBvRenderable.h" 
     14#include "OgreBvhRenderable.h" 
    1515 
    1616namespace Ogre 
    1717{ 
    1818 
    19         class KdTreeSceneNode : public SceneNode, public BvRenderable 
     19        class BvHierarchySceneNode : public SceneNode, public BvhRenderable 
    2020        { 
    2121        public: 
    22                 KdTreeSceneNode(SceneManager *creator): 
     22                BvHierarchySceneNode(SceneManager *creator): 
    2323                  SceneNode(creator) {}; 
    2424 
    25                 KdTreeSceneNode(SceneManager *creator, const String& name): 
     25                BvHierarchySceneNode(SceneManager *creator, const String& name): 
    2626                  SceneNode(creator, name) {}; 
    2727 
    28                 ~KdTreeSceneNode() {}; 
     28                ~BvHierarchySceneNode() {}; 
    2929 
    3030                // 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); 
    3232 
    3333                // add all contained objects to render queue 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreBvhRenderable.h

    r1319 r1320  
    88*/ 
    99 
    10 #ifndef _OgreBvRenderable_H__ 
    11 #define _OgreBvRenderable_H__ 
     10#ifndef _OgreBvhRenderable_H__ 
     11#define _OgreBvhRenderable_H__ 
    1212 
    1313#include "OgreBvHierarchy.h" 
     
    1818        // interface which must be implemented by all objects which desire to be 
    1919        // placed in the kd-tree 
    20         class BvRenderable 
     20        class BvhRenderable 
    2121        { 
    2222        public: 
    23                 BvRenderable():mSide(PlaneEvent::PES_BOTH), mClassified(false), mLastQueued(0), mBvHierarchy(0) {}; 
    24                 virtual ~BvRenderable() 
     23                BvhRenderable():mSide(BvhPlaneEvent::PES_BOTH), mClassified(false), mLastQueued(0), mBvHierarchy(0) {}; 
     24                virtual ~BvhRenderable() 
    2525                { 
    2626                        if (mBvHierarchy) 
     
    2929 
    3030                // 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; 
    3232 
    3333                // put all objects this element holds in the renedering queue 
     
    5050                }; 
    5151 
    52                 inline PlaneEvent::Side getSide() 
     52                inline BvhPlaneEvent::Side getSide() 
    5353                { 
    5454                        return mSide; 
    5555                }; 
    56                 inline void setSide(PlaneEvent::Side s) 
     56                inline void setSide(BvhPlaneEvent::Side s) 
    5757                { 
    5858                        mSide = s; 
     
    6565                }; 
    6666                // the following functions should work in O(log N) 
    67                 inline bool isAttached(KdTree::LeafPtr leaf) 
     67                inline bool isAttached(BvHierarchy::LeafPtr leaf) 
    6868                { 
    6969                        return mLeaves.find(leaf) != mLeaves.end(); 
    7070                }; 
    71                 inline bool attachTo(KdTree::LeafPtr leaf, KdTree * kdTree) 
     71                inline bool attachTo(BvHierarchy::LeafPtr leaf, BvHierarchy * BvHierarchy) 
    7272                { 
    73                         if (mBvHierarchy == 0 || mBvHierarchy == kdTree) 
    74                                 mBvHierarchy = kdTree; 
     73                        if (mBvHierarchy == 0 || mBvHierarchy == BvHierarchy) 
     74                                mBvHierarchy = BvHierarchy; 
    7575                        else 
    7676                                return false; 
    7777 
    78                         KdTree::LeafSet::_Pairib p = mLeaves.insert(leaf); 
     78                        BvHierarchy::LeafSet::_Pairib p = mLeaves.insert(leaf); 
    7979                        return p.second; 
    8080                }; 
    81                 inline bool detachFrom(KdTree::LeafPtr leaf) 
     81                inline bool detachFrom(BvHierarchy::LeafPtr leaf) 
    8282                { 
    8383                        bool success = (mLeaves.erase(leaf) == 1); 
     
    102102                }; 
    103103 
    104                 KdTree::LeafSet& getLeaves() 
     104                BvHierarchy::LeafSet& getLeaves() 
    105105                { 
    106106                        return mLeaves; 
     
    113113                Camera * mLastCam; 
    114114                 
    115                 // kdtree to which this renderable is attached 
    116                 KdTree * mBvHierarchy; 
    117                 // kdtree leaves which overlap this renderable 
    118                 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; 
    119119 
    120120                // Flag for the SAH determining the "cheaper" side of the split plane 
    121                 PlaneEvent::Side mSide; 
     121                BvhPlaneEvent::Side mSide; 
    122122                // Flag for the SAH which marks if this renderable was already placed in the list after a split 
    123123                bool mClassified; 
    124         }; // class BvRenderable 
     124        }; // class BvhRenderable 
    125125 
    126126} // namespace Ogre 
    127127 
    128 #endif // _OgreBvRenderable_H__ 
     128#endif // _OgreBvhRenderable_H__ 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreBvHierarchy.cpp

    r1319 r1320  
    99 
    1010#include "OgreBvHierarchy.h" 
    11 #include "OgreBvRenderable.h" 
     11#include "OgreBvhRenderable.h" 
    1212#include "OgreBvHierarchySceneNode.h" 
    1313#include "OgreBvHierarchySceneManager.h" 
     
    2525{ 
    2626 
    27 enum Intersection 
     27enum BvhIntersection 
    2828{ 
    2929        OUTSIDE=0, 
     
    3232}; 
    3333 
    34 Intersection intersect( const Ray &one, const AxisAlignedBox &two ) 
     34static BvhIntersection intersect( const Ray &one, const AxisAlignedBox &two ) 
    3535{ 
    3636        // Null box? 
     
    9999/** Checks how the second box intersects with the first. 
    100100*/ 
    101 Intersection intersect( const PlaneBoundedVolume &one, const AxisAlignedBox &two ) 
     101static BvhIntersection intersect( const PlaneBoundedVolume &one, const AxisAlignedBox &two ) 
    102102{ 
    103103        // Null box? 
     
    146146/** Checks how the second box intersects with the first. 
    147147*/ 
    148 Intersection intersect( const AxisAlignedBox &one, const AxisAlignedBox &two ) 
     148static BvhIntersection intersect( const AxisAlignedBox &one, const AxisAlignedBox &two ) 
    149149{ 
    150150        // Null box? 
     
    180180/** Checks how the box intersects with the sphere. 
    181181*/ 
    182 Intersection intersect( const Sphere &one, const AxisAlignedBox &two ) 
     182static BvhIntersection intersect( const Sphere &one, const AxisAlignedBox &two ) 
    183183{ 
    184184        // Null box? 
     
    235235} 
    236236 
    237 Real PlaneEvent::KT = 2.0; 
    238 Real PlaneEvent::KI = 1.0; 
     237Real BvhPlaneEvent::KT = 2.0; 
     238Real BvhPlaneEvent::KI = 1.0; 
    239239 
    240240//---------------------------------------------------------------------------- 
    241241// determine if this event is left or right of the reference event 
    242 void PlaneEvent::classify(const PlaneEvent& e, PlaneEvent::Side side) 
     242void BvhPlaneEvent::classify(const BvhPlaneEvent& e, BvhPlaneEvent::Side side) 
    243243{ 
    244244        // only classify events of the same dimension 
     
    271271//---------------------------------------------------------------------------- 
    272272// clip this event to an aabb (move it so that the plane on one of the box planes) 
    273 PlaneEvent PlaneEvent::clip(AxisAlignedBox& box, PlaneEvent::Dimension dim) 
     273BvhPlaneEvent BvhPlaneEvent::clip(AxisAlignedBox& box, BvhPlaneEvent::Dimension dim) 
    274274{ 
    275275        Vector3 newpos = mPosition, min = box.getMinimum(), max = box.getMaximum(); 
     
    279279                newpos[dim] = max[dim]; 
    280280 
    281         return PlaneEvent(mRenderable, newpos, mDimension, mType); 
     281        return BvhPlaneEvent(mRenderable, newpos, mDimension, mType); 
    282282} 
    283283 
     
    285285// the surface area heuristic to determine the cost of splitting the parent aabb 
    286286// along the plane represented by this event 
    287 void PlaneEvent::SAH(const AxisAlignedBox& parent, int nLeft, int nPlane, int nRight, SplitInfo& split) 
     287void BvhPlaneEvent::SAH(const AxisAlignedBox& parent, int nLeft, int nPlane, int nRight, BvhSplitInfo& split) 
    288288{ 
    289289        Real mu = splitBox(parent, split.bleft, split.bright); 
     
    314314//---------------------------------------------------------------------------- 
    315315// split the parent aabb with the plane in this event 
    316 Real PlaneEvent::splitBox(const AxisAlignedBox& parent, AxisAlignedBox& left, AxisAlignedBox& right) 
     316Real BvhPlaneEvent::splitBox(const AxisAlignedBox& parent, AxisAlignedBox& left, AxisAlignedBox& right) 
    317317{ 
    318318        Vector3 bmin = parent.getMinimum(); 
     
    337337//---------------------------------------------------------------------------- 
    338338// compute surface area of a box ... DUH! 
    339 Real PlaneEvent::surfaceArea(const AxisAlignedBox& box) 
     339Real BvhPlaneEvent::surfaceArea(const AxisAlignedBox& box) 
    340340{ 
    341341        Vector3 sides = box.getMaximum() - box.getMinimum(); 
     
    348348// lookup the penalty for placing the splitting plane near to the edge of the AABB 
    349349// 0.0 <= p <= 1.0, p = 0.5 means the plane divides the aabb in half 
    350 Real PlaneEvent::lookupPenalty(Real p) 
     350Real BvhPlaneEvent::lookupPenalty(Real p) 
    351351{ 
    352352        // precomputed table of {x^6 + 1|0 <= x <= 1} 
     
    380380// compute cost of the split, reward splitting of empty space (lambda, const), 
    381381// penalize splitting off 'thin' slices (mu, const) 
    382 Real PlaneEvent::splitCost(Real pLeft, Real pRight, int nLeft, int nRight) 
     382Real BvhPlaneEvent::splitCost(Real pLeft, Real pRight, int nLeft, int nRight) 
    383383{ 
    384384        // reward splitting off chunks of empty space 
     
    401401// compute cost of the split, reward splitting of empty space (lambda, const), 
    402402// penalize splitting off 'thin' slices (mu, parameter) 
    403 Real PlaneEvent::splitCost(Real pLeft, Real pRight, int nLeft, int nRight, Real mu) 
     403Real BvhPlaneEvent::splitCost(Real pLeft, Real pRight, int nLeft, int nRight, Real mu) 
    404404{ 
    405405        // reward splitting off chunks of empty space 
     
    416416// surface area heuristic modified for the priority queue method of building 
    417417// the probabilities (p, pl, pr) are relative to the global (all enclosing) aabb 
    418 void PlaneEvent::pqSAH(Real globalSA, Real parentSA, int nLeft, int nPlane, int nRight,  
    419         AxisAlignedBox& parentBox, SplitInfo& split) 
     418void BvhPlaneEvent::pqSAH(Real globalSA,  
     419                                                  Real parentSA,  
     420                                                  int nLeft,  
     421                                                  int nPlane,  
     422                                                  int nRight,  
     423                                                  AxisAlignedBox& parentBox,  
     424                                                  BvhSplitInfo& split) 
    420425{ 
    421426        Real mu = splitBox(parentBox, split.bleft, split.bright); 
     
    446451//---------------------------------------------------------------------------- 
    447452// compute split cost without any penalties 
    448 Real PlaneEvent::pqSplitCost(Real pParent, Real pLeft, Real pRight, int nLeft, int nRight, Real mu) 
     453Real BvhPlaneEvent::pqSplitCost(Real pParent, Real pLeft, Real pRight, int nLeft, int nRight, Real mu) 
    449454{ 
    450455        return pParent * KT + (KI * (pLeft * nLeft + pRight * nRight)); 
     
    453458//---------------------------------------------------------------------------- 
    454459// DEBUG 
    455 String PlaneEvent::print() 
     460String BvhPlaneEvent::print() 
    456461{ 
    457462        String dim, type; 
     
    473478 
    474479//---------------------------------------------------------------------------- 
    475 String SplitInfo::print() 
     480String BvhSplitInfo::print() 
    476481{ 
    477482        String sside; 
    478         if (side == PlaneEvent::PES_BOTH) 
     483        if (side == BvhPlaneEvent::PES_BOTH) 
    479484                sside = "BOTH "; 
    480         if (side == PlaneEvent::PES_LEFT) 
     485        if (side == BvhPlaneEvent::PES_LEFT) 
    481486                sside = "LEFT "; 
    482         if (side == PlaneEvent::PES_RIGHT) 
     487        if (side == BvhPlaneEvent::PES_RIGHT) 
    483488                sside = "RIGHT"; 
    484489        return "nLeft: " + StringConverter::toString(nleft, 4) + " nRight: " +  
     
    492497 
    493498//---------------------------------------------------------------------------- 
    494 String KdTree::SplitCandidate::print() 
     499String BvHierarchy::BvhSubdivisionCandidate::print() 
    495500{                
    496501        String sside; 
    497         if (side == PlaneEvent::PES_BOTH) 
     502        if (side == BvhPlaneEvent::PES_BOTH) 
    498503                sside = "BOTH "; 
    499         if (side == PlaneEvent::PES_LEFT) 
     504        if (side == BvhPlaneEvent::PES_LEFT) 
    500505                sside = "LEFT "; 
    501         if (side == PlaneEvent::PES_RIGHT) 
     506        if (side == BvhPlaneEvent::PES_RIGHT) 
    502507                sside = "RIGHT"; 
    503508        return "List: " + StringConverter::toString(events->size(), 4) + " Objects: " + 
     
    513518//---------------------------------------------------------------------------- 
    514519 
    515 KdTree::KdTree(int maxdepth, BuildMethod bm):  
     520BvHierarchy::BvHierarchy(int maxdepth, BuildMethod bm):  
    516521mMaxDepth(maxdepth),  
    517522mBuildMethod(bm),  
     
    519524mShowAllBoxes(false), 
    520525mShowNodes(true), 
    521 mKdRoot(0),  
     526mBvhRoot(0),  
    522527mBuildLog(0) 
    523528{ 
     
    525530} 
    526531 
    527 KdTree::KdTree(int maxdepth, BuildMethod bm, int hilite, bool allboxes, bool shownodes): 
     532BvHierarchy::BvHierarchy(int maxdepth, BuildMethod bm, int hilite, bool allboxes, bool shownodes): 
    528533mMaxDepth(maxdepth),  
    529534mBuildMethod(bm),  
     
    531536mShowAllBoxes(allboxes), 
    532537mShowNodes(shownodes), 
    533 mKdRoot(0),  
     538mBvhRoot(0),  
    534539mBuildLog(0) 
    535540{ 
     
    537542} 
    538543 
    539 KdTree::~KdTree() 
    540 { 
    541         delete mKdRoot; 
    542 } 
    543  
    544 void KdTree::init() 
     544BvHierarchy::~BvHierarchy() 
     545{ 
     546        delete mBvhRoot; 
     547} 
     548 
     549void BvHierarchy::init() 
    545550{ 
    546551        MaterialPtr mat; 
     
    548553 
    549554        // init visualization materials (unlit solid green/yellow) 
    550         mat = MaterialManager::getSingleton().getByName("KdTree/BoxHiLite"); 
     555        mat = MaterialManager::getSingleton().getByName("BvHierarchy/BoxHiLite"); 
    551556        if (mat.isNull()) 
    552557        { 
    553558                ColourValue green(0, 1, 0); 
    554                 mat = MaterialManager::getSingleton().create("KdTree/BoxHiLite", "General"); 
     559                mat = MaterialManager::getSingleton().create("BvHierarchy/BoxHiLite", "General"); 
    555560                //mat->setAmbient(green); 
    556561                //mat->setDiffuse(green); 
     
    560565        } 
    561566 
    562         mat = MaterialManager::getSingleton().getByName("KdTree/BoxViz"); 
     567        mat = MaterialManager::getSingleton().getByName("BvHierarchy/BoxViz"); 
    563568        if (mat.isNull()) 
    564569        { 
    565570                ColourValue yellow(1, 1, 0); 
    566                 mat = MaterialManager::getSingleton().create("KdTree/BoxViz", "General"); 
     571                mat = MaterialManager::getSingleton().create("BvHierarchy/BoxViz", "General"); 
    567572                //mat->setAmbient(yellow); 
    568573                //mat->setDiffuse(yellow); 
     
    575580        try 
    576581        { 
    577                 mBuildLog = LogManager::getSingleton().getLog(KDTREE_LOGNAME); 
     582                mBuildLog = LogManager::getSingleton().getLog(BvHierarchy_LOGNAME); 
    578583        } 
    579584        catch (Exception&) 
    580585        {                
    581                 mBuildLog = LogManager::getSingleton().createLog(KDTREE_LOGNAME); 
     586                mBuildLog = LogManager::getSingleton().createLog(BvHierarchy_LOGNAME); 
    582587        } 
    583588 
     
    586591 
    587592/************************************************************************/ 
    588 /* KdTree insert/delete functions                                       */ 
     593/* BvHierarchy insert/delete functions                                       */ 
    589594/************************************************************************/ 
    590595 
    591 void KdTree::remove(BvRenderable * rend) 
     596void BvHierarchy::remove(BvhRenderable * rend) 
    592597{ 
    593598        // DEBUG 
    594         //LogManager::getSingleton().logMessage("-- Removing SceneNode: " + (static_cast<KdTreeSceneNode *>(rend))->getName()); 
     599        //LogManager::getSingleton().logMessage("-- Removing SceneNode: " + (static_cast<BvHierarchySceneNode *>(rend))->getName()); 
    595600        std::queue<LeafPtr> cleanup; 
    596601        LeafPtr leaf; 
     
    616621} 
    617622 
    618 void KdTree::recDelete(KdTree::Node * node) 
     623void BvHierarchy::recDelete(BvHierarchy::Node * node) 
    619624{ 
    620625        if (node == 0) // DEBUG 
    621626        { 
    622627                OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, 
    623                         "SNAFU while inserting BvRenderable into KdTree.", 
    624                         "KdTree::recInsert" ); 
     628                        "SNAFU while inserting BvhRenderable into BvHierarchy.", 
     629                        "BvHierarchy::recInsert" ); 
    625630                return; 
    626631        } 
     
    628633        if (node->isEmpty()) 
    629634        { 
    630                 if (node == mKdRoot) 
    631                 { 
    632                         OGRE_DELETE(mKdRoot); 
     635                if (node == mBvhRoot) 
     636                { 
     637                        OGRE_DELETE(mBvhRoot); 
    633638                }  
    634639                else 
    635640                { 
    636                         KdTree::Branch * parent = KDBRANCHPTR_CAST(node->getParent()); 
     641                        BvHierarchy::Branch * parent = BVHBRANCHPTR_CAST(node->getParent()); 
    637642                        if (node == parent->mLeft) 
    638643                        { 
     
    648653} 
    649654 
    650 void KdTree::insert(BvRenderable * rend) 
     655void BvHierarchy::insert(BvhRenderable * rend) 
    651656{ 
    652657        // make sure the tree exists 
    653         if (mKdRoot) 
     658        if (mBvhRoot) 
    654659        { 
    655660                // make sure the renderable is inside the world bounding box 
    656661                AxisAlignedBox aabb = rend->getBoundingBox(); 
    657                 AxisAlignedBox isect = mKdRoot->mAABB.intersection(aabb); 
     662                AxisAlignedBox isect = mBvhRoot->mAABB.intersection(aabb); 
    658663                if (isect.getMinimum() == aabb.getMinimum() && isect.getMaximum() == aabb.getMaximum()) 
    659664                { 
    660                         recInsert(mKdRoot, rend); 
     665                        recInsert(mBvhRoot, rend); 
    661666                } 
    662667                else 
    663668                { 
    664669                        //LogManager::getSingleton().logMessage("Inserted node outside of world AABB."); 
    665                         BvRenderableList nodelist; 
     670                        BvhRenderableList nodelist; 
    666671                        nodelist.push_back(rend); 
    667                         addRendToList(mKdRoot, nodelist); 
    668                         OGRE_DELETE(mKdRoot); 
    669                         mKdRoot = buildFromList(nodelist, 0, AxisAlignedBox()); 
     672                        addRendToList(mBvhRoot, nodelist); 
     673                        OGRE_DELETE(mBvhRoot); 
     674                        mBvhRoot = buildFromList(nodelist, 0, AxisAlignedBox()); 
    670675                } 
    671676        } 
     
    677682} 
    678683 
    679 void KdTree::recInsert(KdTree::Node * node, BvRenderable * rend) 
     684void BvHierarchy::recInsert(BvHierarchy::Node * node, BvhRenderable * rend) 
    680685{ 
    681686        if (node == 0) // DEBUG 
    682687        { 
    683688                OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, 
    684                         "SNAFU while inserting BvRenderable into KdTree.", 
    685                         "KdTree::recInsert" ); 
     689                        "SNAFU while inserting BvhRenderable into BvHierarchy.", 
     690                        "BvHierarchy::recInsert" ); 
    686691                return; 
    687692        } 
     
    695700        else 
    696701        { 
    697                 KdTree::Branch * branch = KDBRANCHPTR_CAST(node); 
     702                BvHierarchy::Branch * branch = BVHBRANCHPTR_CAST(node); 
    698703                AxisAlignedBox aabb = rend->getBoundingBox(); 
    699704                Plane::Side smin = branch->mSplitPlane->getSide(aabb.getMinimum()); 
     
    702707                { 
    703708                        if (smax == Plane::NEGATIVE_SIDE || 
    704                                 (smax == Plane::NO_SIDE && branch->mPlaneSide == PlaneEvent::PES_LEFT)) 
     709                                (smax == Plane::NO_SIDE && branch->mPlaneSide == BvhPlaneEvent::PES_LEFT)) 
    705710                        { 
    706711                                if (branch->mLeft) 
    707712                                        recInsert(branch->mLeft, rend); 
    708713                                else 
    709                                         recInsertNew(branch, PlaneEvent::PES_LEFT, rend); 
     714                                        recInsertNew(branch, BvhPlaneEvent::PES_LEFT, rend); 
    710715                        } 
    711716                        else if (smin == Plane::POSITIVE_SIDE ||  
    712                                 (smin == Plane::NO_SIDE && branch->mPlaneSide == PlaneEvent::PES_RIGHT)) 
     717                                (smin == Plane::NO_SIDE && branch->mPlaneSide == BvhPlaneEvent::PES_RIGHT)) 
    713718                        { 
    714719                                if (branch->mRight) 
    715720                                        recInsert(branch->mRight, rend); 
    716721                                else 
    717                                         recInsertNew(branch, PlaneEvent::PES_RIGHT, rend); 
     722                                        recInsertNew(branch, BvhPlaneEvent::PES_RIGHT, rend); 
    718723                        } 
    719724                } 
     
    725730                                        recInsert(branch->mLeft, rend); 
    726731                                else 
    727                                         recInsertNew(branch, PlaneEvent::PES_LEFT, rend); 
     732                                        recInsertNew(branch, BvhPlaneEvent::PES_LEFT, rend); 
    728733                        } 
    729734                        else if (smax == Plane::POSITIVE_SIDE && smin == Plane::NO_SIDE) 
     
    732737                                        recInsert(branch->mRight, rend); 
    733738                                else 
    734                                         recInsertNew(branch, PlaneEvent::PES_RIGHT, rend); 
     739                                        recInsertNew(branch, BvhPlaneEvent::PES_RIGHT, rend); 
    735740                        } 
    736741                        else 
     
    744749} 
    745750 
    746 void KdTree::recInsertNew(KdTree::Branch * parent, PlaneEvent::Side side, BvRenderable * rend) 
     751void BvHierarchy::recInsertNew(BvHierarchy::Branch * parent, BvhPlaneEvent::Side side, BvhRenderable * rend) 
    747752{ 
    748753        //LogManager::getSingleton().logMessage("## Inserting into new subtree"); 
    749754 
    750755        AxisAlignedBox left, rigth, aabb; 
    751         PlaneEventList events; 
     756        BvhPlaneEventList events; 
    752757        int nObjects; 
    753758         
     
    756761        // override aabb 
    757762        splitBox(*parent, left, rigth); 
    758         if (side == PlaneEvent::PES_LEFT) 
     763        if (side == BvhPlaneEvent::PES_LEFT) 
    759764        { 
    760765                aabb = left; 
    761                 if (mBuildMethod == KDBM_RECURSIVE) 
     766                if (mBuildMethod == BVHBM_RECURSIVE) 
    762767                        parent->mLeft = recBuild(events, nObjects, aabb, parent); 
    763                 else if (mBuildMethod == KDBM_PRIORITYQUEUE) 
     768                else if (mBuildMethod == BVHBM_PRIORITYQUEUE) 
    764769                        parent->mLeft = pqBuild(events, nObjects, aabb, parent); 
    765770                else 
    766771                { 
    767772                        OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,  
    768                                 "Invalid build method for the KdTree.", 
    769                                 "KdTree::buildFromList"); 
     773                                "Invalid build method for the BvHierarchy.", 
     774                                "BvHierarchy::buildFromList"); 
    770775                        parent->mLeft = 0; 
    771776                } 
    772777                 
    773778        } 
    774         else if (side == PlaneEvent::PES_RIGHT) 
     779        else if (side == BvhPlaneEvent::PES_RIGHT) 
    775780        { 
    776781                aabb = rigth; 
    777                 if (mBuildMethod == KDBM_RECURSIVE) 
     782                if (mBuildMethod == BVHBM_RECURSIVE) 
    778783                        parent->mRight = recBuild(events, nObjects, aabb, parent); 
    779                 else if (mBuildMethod == KDBM_PRIORITYQUEUE) 
     784                else if (mBuildMethod == BVHBM_PRIORITYQUEUE) 
    780785                        parent->mRight = pqBuild(events, nObjects, aabb, parent); 
    781786                else 
    782787                { 
    783788                        OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,  
    784                                 "Invalid build method for the KdTree.", 
    785                                 "KdTree::buildFromList"); 
     789                                "Invalid build method for the BvHierarchy.", 
     790                                "BvHierarchy::buildFromList"); 
    786791                        parent->mRight = 0; 
    787792                } 
     
    789794} 
    790795 
    791 void KdTree::rebuildSubtree(KdTree::Node * node, BvRenderable * rend) 
     796void BvHierarchy::rebuildSubtree(BvHierarchy::Node * node, BvhRenderable * rend) 
    792797{ 
    793798        //LogManager::getSingleton().logMessage("## Rebuilding subtree"); 
     
    795800        AxisAlignedBox aabb = node->mAABB; 
    796801         
    797         BvRenderableList nodelist; 
     802        BvhRenderableList nodelist; 
    798803        nodelist.push_back(rend); 
    799804        addRendToList(node, nodelist); 
    800805 
    801         if (node == mKdRoot) 
    802         { 
    803                 OGRE_DELETE(mKdRoot); 
    804                 mKdRoot = buildFromList(nodelist, 0, aabb); 
     806        if (node == mBvhRoot) 
     807        { 
     808                OGRE_DELETE(mBvhRoot); 
     809                mBvhRoot = buildFromList(nodelist, 0, aabb); 
    805810        } 
    806811        else 
    807812        { 
    808                 KdTree::Branch * parent = KDBRANCHPTR_CAST(node->getParent()); 
     813                BvHierarchy::Branch * parent = BVHBRANCHPTR_CAST(node->getParent()); 
    809814 
    810815                if (node == parent->mLeft) 
     
    821826                { 
    822827                        OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, 
    823                                 "SNAFU while inserting BvRenderable into KdTree.", 
    824                                 "KdTree::recInsert" ); 
     828                                "SNAFU while inserting BvhRenderable into BvHierarchy.", 
     829                                "BvHierarchy::recInsert" ); 
    825830                } 
    826831        } 
     
    828833 
    829834// compute both AABB then return the requested one. 
    830 void KdTree::splitBox(const KdTree::Branch& parent, AxisAlignedBox& left, AxisAlignedBox& right) 
     835void BvHierarchy::splitBox(const BvHierarchy::Branch& parent, AxisAlignedBox& left, AxisAlignedBox& right) 
    831836{ 
    832837        Vector3 bmin = parent.mAABB.getMinimum(); 
     
    845850} 
    846851 
    847 void KdTree::addRendToList(KdTree::Node * node, BvRenderableList& nodelist) 
     852void BvHierarchy::addRendToList(BvHierarchy::Node * node, BvhRenderableList& nodelist) 
    848853{ 
    849854        if (node->isLeaf()) 
    850855        { 
    851                 KdTree::Leaf * leaf = KDLEAFPTR_CAST(node); 
    852                 BvRenderableList::iterator it  = leaf->mBvRenderables.begin(); 
    853                 BvRenderableList::iterator end = leaf->mBvRenderables.end(); 
     856                BvHierarchy::Leaf * leaf = BVHLEAFPTR_CAST(node); 
     857                BvhRenderableList::iterator it  = leaf->mBvhRenderables.begin(); 
     858                BvhRenderableList::iterator end = leaf->mBvhRenderables.end(); 
    854859                while (it != end) 
    855860                { 
     
    860865        else 
    861866        { 
    862                 KdTree::Branch * branch = KDBRANCHPTR_CAST(node); 
     867                BvHierarchy::Branch * branch = BVHBRANCHPTR_CAST(node); 
    863868                if (branch->mLeft) 
    864869                        addRendToList(branch->mLeft, nodelist); 
     
    869874 
    870875/************************************************************************/ 
    871 /* KdTree build functions                                               */ 
     876/* BvHierarchy build functions                                               */ 
    872877/************************************************************************/ 
    873878 
    874 void KdTree::build(BvRenderable * sceneRoot) 
     879void BvHierarchy::build(BvhRenderable * sceneRoot) 
    875880{ 
    876881        Timer *timer = Root::getSingleton().getTimer(); 
     
    880885         
    881886        // data we want to collect 
    882         PlaneEventList events; 
     887        BvhPlaneEventList events; 
    883888        AxisAlignedBox aabb; 
    884889        int nObjects = 0; 
     
    897902        aabb.merge(aabb.getMinimum()+Vector3(-1,-1,-1)); 
    898903 
    899         if (mBuildMethod == KDBM_RECURSIVE) 
    900                 mKdRoot = recBuild(events, nObjects, aabb, 0); 
    901         else if (mBuildMethod == KDBM_PRIORITYQUEUE) 
    902                 mKdRoot = pqBuild(events, nObjects, aabb, 0); 
     904        if (mBuildMethod == BVHBM_RECURSIVE) 
     905                mBvhRoot = recBuild(events, nObjects, aabb, 0); 
     906        else if (mBuildMethod == BVHBM_PRIORITYQUEUE) 
     907                mBvhRoot = pqBuild(events, nObjects, aabb, 0); 
    903908        else 
    904909        { 
    905910                OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,  
    906                         "Invalid build method for the KdTree.", 
    907                         "KdTree::build"); 
    908                 mKdRoot = 0; 
     911                        "Invalid build method for the BvHierarchy.", 
     912                        "BvHierarchy::build"); 
     913                mBvhRoot = 0; 
    909914        } 
    910915 
     
    912917 
    913918        String method = "Invalid"; 
    914         if (mBuildMethod == KDBM_RECURSIVE) 
     919        if (mBuildMethod == BVHBM_RECURSIVE) 
    915920                method = "Recursive"; 
    916         else if (mBuildMethod == KDBM_PRIORITYQUEUE) 
     921        else if (mBuildMethod == BVHBM_PRIORITYQUEUE) 
    917922                method = "Priority Queue"; 
    918923 
     
    931936} 
    932937 
    933 KdTree::Node * KdTree::buildFromList(BvRenderableList& nodelist, KdTree::Branch * parent, AxisAlignedBox& aabb) 
     938BvHierarchy::Node * BvHierarchy::buildFromList(BvhRenderableList& nodelist, BvHierarchy::Branch * parent, AxisAlignedBox& aabb) 
    934939{ 
    935940        // data we want to collect 
    936         PlaneEventList events; 
     941        BvhPlaneEventList events; 
    937942        AxisAlignedBox nodeaabb; 
    938943        int nObjects = 0; 
    939944 
    940         BvRenderableList::iterator it = nodelist.begin(); 
    941         BvRenderableList::iterator end = nodelist.end(); 
     945        BvhRenderableList::iterator it = nodelist.begin(); 
     946        BvhRenderableList::iterator end = nodelist.end(); 
    942947        while (it != end) 
    943948        { 
     
    954959        } 
    955960 
    956         if (mBuildMethod == KDBM_RECURSIVE) 
     961        if (mBuildMethod == BVHBM_RECURSIVE) 
    957962                return recBuild(events, nObjects, aabb, parent); 
    958         else if (mBuildMethod == KDBM_PRIORITYQUEUE) 
     963        else if (mBuildMethod == BVHBM_PRIORITYQUEUE) 
    959964                return pqBuild(events, nObjects, aabb, parent); 
    960965        else 
    961966        { 
    962967                OGRE_EXCEPT(Exception::ERR_INVALIDPARAMS,  
    963                         "Invalid build method for the KdTree.", 
    964                         "KdTree::buildFromList"); 
     968                        "Invalid build method for the BvHierarchy.", 
     969                        "BvHierarchy::buildFromList"); 
    965970                return 0; 
    966971        } 
    967972} 
    968973 
    969 KdTree::Node * KdTree::recBuild(PlaneEventList& events, int nObjects, AxisAlignedBox& aabb, KdTree::Branch * parent) 
     974BvHierarchy::Node * BvHierarchy::recBuild(BvhPlaneEventList& events, int nObjects, AxisAlignedBox& aabb, BvHierarchy::Branch * parent) 
    970975{ 
    971976        // determine the depth we are on 
     
    990995        } 
    991996 
    992         SplitInfo split, best; 
     997        BvhSplitInfo split, best; 
    993998        best.cost = Math::POS_INFINITY; 
    994999 
    995         PlaneEventList::iterator begin = events.begin(); 
    996         PlaneEventList::iterator end = events.end(); 
    997         PlaneEventList::iterator it = begin; 
     1000        BvhPlaneEventList::iterator begin = events.begin(); 
     1001        BvhPlaneEventList::iterator end = events.end(); 
     1002        BvhPlaneEventList::iterator it = begin; 
    9981003        // try all planes to find the best one for the given set of objects 
    9991004        while (it != end) 
    10001005        { 
    1001                 PlaneEventList::iterator p = it; 
     1006                BvhPlaneEventList::iterator p = it; 
    10021007                pStart = pOn = pEnd = 0; 
    1003                 while (it != end && p->equalsType(*it, PlaneEvent::PET_END)) 
     1008                while (it != end && p->equalsType(*it, BvhPlaneEvent::PET_END)) 
    10041009                { 
    10051010                        it++; pEnd++; 
    10061011                } 
    1007                 while (it != end && p->equalsType(*it, PlaneEvent::PET_ON)) 
     1012                while (it != end && p->equalsType(*it, BvhPlaneEvent::PET_ON)) 
    10081013                { 
    10091014                        it++; pOn++; 
    10101015                } 
    1011                 while (it != end && p->equalsType(*it, PlaneEvent::PET_START)) 
     1016                while (it != end && p->equalsType(*it, BvhPlaneEvent::PET_START)) 
    10121017                { 
    10131018                        it++; pStart++; 
     
    10271032        /************************************************/ 
    10281033        // check terminating condition 
    1029         if (best.cost > PlaneEvent::KI*nObjects || level >= mMaxDepth) 
     1034        if (best.cost > BvhPlaneEvent::KI*nObjects || level >= mMaxDepth) 
    10301035        { 
    10311036                // Terminating condition reached, create leaf and add renderables to list 
    1032                 KdTree::Leaf * leaf = new KdTree::Leaf(this, level, aabb, parent); 
    1033                 BvRenderable *rend; 
     1037                BvHierarchy::Leaf * leaf = new BvHierarchy::Leaf(this, level, aabb, parent); 
     1038                BvhRenderable *rend; 
    10341039                it = begin; 
    10351040                while (it != end) 
     
    10571062        else 
    10581063        { 
    1059                 PlaneEventList eventsRight, eventsLeft; 
     1064                BvhPlaneEventList eventsRight, eventsLeft; 
    10601065                it = begin; 
    10611066                // slightly redundant, since we mark each renderable up to 6 times 
    10621067                while (it != end) 
    10631068                { 
    1064                         it->getRenderable()->setSide(PlaneEvent::PES_BOTH); 
     1069                        it->getRenderable()->setSide(BvhPlaneEvent::PES_BOTH); 
    10651070                        it->getRenderable()->setClassified(false); 
    10661071                        it++; 
     
    10791084                { 
    10801085                        // right-only nodes go in right list 
    1081                         if (it->getRenderable()->getSide() == PlaneEvent::PES_RIGHT) 
     1086                        if (it->getRenderable()->getSide() == BvhPlaneEvent::PES_RIGHT) 
    10821087                        { 
    10831088                                if (!it->getRenderable()->isClassified()) 
     
    10891094                        } 
    10901095                        // left-only nodes go in left list 
    1091                         else if (it->getRenderable()->getSide() == PlaneEvent::PES_LEFT) 
     1096                        else if (it->getRenderable()->getSide() == BvhPlaneEvent::PES_LEFT) 
    10921097                        { 
    10931098                                if (!it->getRenderable()->isClassified()) 
     
    11141119 
    11151120                // create a new branch node and continue recursion 
    1116                 KdTree::Branch * branch = new KdTree::Branch(this, level, aabb, parent,  
     1121                BvHierarchy::Branch * branch = new BvHierarchy::Branch(this, level, aabb, parent,  
    11171122                        best.event.getSplitPlane(), best.side); 
    11181123 
     
    11371142} 
    11381143 
    1139 KdTree::Node * KdTree::pqBuild(PlaneEventList& events, int nObjects, AxisAlignedBox& aabb, KdTree::Branch * parent) 
     1144BvHierarchy::Node * BvHierarchy::pqBuild(BvhPlaneEventList& events, int nObjects, AxisAlignedBox& aabb, BvHierarchy::Branch * parent) 
    11401145{ 
    11411146        SplitCandidatePQ pqueue; 
     
    11431148        Real globalSA; 
    11441149 
    1145         KdTree::Node * newNode = 0, * topNode = 0; 
     1150        BvHierarchy::Node * newNode = 0, * topNode = 0; 
    11461151        // init global tree cost 
    1147         globalTreeCost = PlaneEvent::KI * nObjects; 
    1148         globalSA = PlaneEvent::surfaceArea(aabb); 
    1149  
    1150         PlaneEventList * e = new PlaneEventList(events); 
     1152        globalTreeCost = BvhPlaneEvent::KI * nObjects; 
     1153        globalSA = BvhPlaneEvent::surfaceArea(aabb); 
     1154 
     1155        BvhPlaneEventList * e = new BvhPlaneEventList(events); 
    11511156 
    11521157        // inital split candidate 
    1153         SplitInfo * best = pqFindPlane(e, nObjects, aabb, globalSA); 
    1154         SplitCandidate splitcandidate(e, nObjects, aabb, parent, globalTreeCost,  
    1155                 globalTreeCost - best->cost, best, PlaneEvent::PES_BOTH); 
     1158        BvhSplitInfo * best = pqFindPlane(e, nObjects, aabb, globalSA); 
     1159        BvhSubdivisionCandidate splitcandidate(e, nObjects, aabb, parent, globalTreeCost,  
     1160                globalTreeCost - best->cost, best, BvhPlaneEvent::PES_BOTH); 
    11561161        pqueue.push(splitcandidate); 
    11571162 
     
    11601165        while (!pqueue.empty()) 
    11611166        { 
    1162                 SplitCandidate sc = pqueue.top(); 
     1167                BvhSubdivisionCandidate sc = pqueue.top(); 
    11631168                pqueue.pop(); 
    11641169 
     
    11771182                { 
    11781183                        // Terminating condition reached, create leaf and add renderables to list 
    1179                         KdTree::Leaf * leaf = new KdTree::Leaf(this, level, sc.aabb, sc.parent); 
    1180                         BvRenderable *rend; 
    1181                         PlaneEventList::iterator begin = sc.events->begin(); 
    1182                         PlaneEventList::iterator end = sc.events->end(); 
    1183                         PlaneEventList::iterator it = begin; 
     1184                        BvHierarchy::Leaf * leaf = new BvHierarchy::Leaf(this, level, sc.aabb, sc.parent); 
     1185                        BvhRenderable *rend; 
     1186                        BvhPlaneEventList::iterator begin = sc.events->begin(); 
     1187                        BvhPlaneEventList::iterator end = sc.events->end(); 
     1188                        BvhPlaneEventList::iterator it = begin; 
    11841189                        while (it != end) 
    11851190                        { 
     
    12051210                else 
    12061211                { 
    1207                         PlaneEventList * eventsLeft = new PlaneEventList(); 
    1208                         PlaneEventList * eventsRight = new PlaneEventList(); 
    1209                         PlaneEventList::iterator begin = sc.events->begin(); 
    1210                         PlaneEventList::iterator end = sc.events->end(); 
    1211                         PlaneEventList::iterator it = begin; 
     1212                        BvhPlaneEventList * eventsLeft = new BvhPlaneEventList(); 
     1213                        BvhPlaneEventList * eventsRight = new BvhPlaneEventList(); 
     1214                        BvhPlaneEventList::iterator begin = sc.events->begin(); 
     1215                        BvhPlaneEventList::iterator end = sc.events->end(); 
     1216                        BvhPlaneEventList::iterator it = begin; 
    12121217                        // slightly redundant, since we mark each renderable up to 6 times 
    12131218                        while (it != end) 
    12141219                        { 
    1215                                 it->getRenderable()->setSide(PlaneEvent::PES_BOTH); 
     1220                                it->getRenderable()->setSide(BvhPlaneEvent::PES_BOTH); 
    12161221                                it->getRenderable()->setClassified(false); 
    12171222                                it++; 
     
    12321237                        { 
    12331238                                // right-only events go in the right list 
    1234                                 if (it->getRenderable()->getSide() == PlaneEvent::PES_RIGHT) 
     1239                                if (it->getRenderable()->getSide() == BvhPlaneEvent::PES_RIGHT) 
    12351240                                { 
    12361241                                        if (!it->getRenderable()->isClassified()) 
     
    12431248                                } 
    12441249                                // left-only events go in the left list 
    1245                                 else if (it->getRenderable()->getSide() == PlaneEvent::PES_LEFT) 
     1250                                else if (it->getRenderable()->getSide() == BvhPlaneEvent::PES_LEFT) 
    12461251                                { 
    12471252                                        if (!it->getRenderable()->isClassified()) 
     
    12681273 
    12691274                        // create a new branch node 
    1270                         KdTree::Branch * branch = new KdTree::Branch(this, level, sc.aabb, sc.parent,  
     1275                        BvHierarchy::Branch * branch = new BvHierarchy::Branch(this, level, sc.aabb, sc.parent,  
    12711276                                sc.best->event.getSplitPlane(), sc.best->side); 
    12721277 
     
    12791284                        { 
    12801285                                best = pqFindPlane(eventsLeft, nLeftS + nBothS, sc.best->bleft, globalSA); 
    1281                                 Real old = PlaneEvent::surfaceArea(sc.best->bleft)/globalSA*PlaneEvent::KI*(nLeftS + nBothS); 
    1282                                 SplitCandidate scleft(eventsLeft, nLeftS + nBothS, sc.best->bleft,  
    1283                                         branch, old, old - best->cost, best, PlaneEvent::PES_LEFT); 
     1286                                Real old = BvhPlaneEvent::surfaceArea(sc.best->bleft)/globalSA*BvhPlaneEvent::KI*(nLeftS + nBothS); 
     1287                                BvhSubdivisionCandidate scleft(eventsLeft, nLeftS + nBothS, sc.best->bleft,  
     1288                                        branch, old, old - best->cost, best, BvhPlaneEvent::PES_LEFT); 
    12841289                                pqueue.push(scleft); 
    12851290                        } 
     
    12931298                        { 
    12941299                                best = pqFindPlane(eventsRight, nBothS + nRightS, sc.best->bright, globalSA); 
    1295                                 Real old = PlaneEvent::surfaceArea(sc.best->bright)/globalSA*PlaneEvent::KI*(nBothS + nRightS); 
    1296                                 SplitCandidate scright(eventsRight, nBothS + nRightS, sc.best->bright,  
    1297                                         branch, old, old - best->cost, best, PlaneEvent::PES_RIGHT); 
     1300                                Real old = BvhPlaneEvent::surfaceArea(sc.best->bright)/globalSA*BvhPlaneEvent::KI*(nBothS + nRightS); 
     1301                                BvhSubdivisionCandidate scright(eventsRight, nBothS + nRightS, sc.best->bright,  
     1302                                        branch, old, old - best->cost, best, BvhPlaneEvent::PES_RIGHT); 
    12981303                                pqueue.push(scright); 
    12991304                        } 
     
    13161321                if (sc.parent) 
    13171322                { 
    1318                         if (sc.side == PlaneEvent::PES_LEFT) 
     1323                        if (sc.side == BvhPlaneEvent::PES_LEFT) 
    13191324                        { 
    13201325                                sc.parent->mLeft = newNode; 
    13211326                        } 
    1322                         else if (sc.side == PlaneEvent::PES_RIGHT) 
     1327                        else if (sc.side == BvhPlaneEvent::PES_RIGHT) 
    13231328                        { 
    13241329                                sc.parent->mRight = newNode; 
     
    13271332                        { 
    13281333                                OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, 
    1329                                         "PQBUILD SNAFU - CHILD I AM NOT LEFT NOR RIGHT","KdTree::pqBuild"); 
     1334                                        "PQBUILD SNAFU - CHILD I AM NOT LEFT NOR RIGHT","BvHierarchy::pqBuild"); 
    13301335                        } 
    13311336                } 
     
    13441349 
    13451350//------------------------------------------------------------------------- 
    1346 SplitInfo * KdTree::pqFindPlane(PlaneEventList * events, int nObjects, AxisAlignedBox& aabb, Real globalSA) 
     1351BvhSplitInfo * BvHierarchy::pqFindPlane(BvhPlaneEventList * events, int nObjects, AxisAlignedBox& aabb, Real globalSA) 
    13471352{ 
    13481353        static const int dim = 3; 
     
    13541359        } 
    13551360 
    1356         SplitInfo split, best; 
     1361        BvhSplitInfo split, best; 
    13571362        best.cost = Math::POS_INFINITY; 
    13581363 
    1359         Real parentSA = PlaneEvent::surfaceArea(aabb); 
    1360  
    1361         PlaneEventList::iterator begin = events->begin(); 
    1362         PlaneEventList::iterator end = events->end(); 
    1363         PlaneEventList::iterator it = begin; 
     1364        Real parentSA = BvhPlaneEvent::surfaceArea(aabb); 
     1365 
     1366        BvhPlaneEventList::iterator begin = events->begin(); 
     1367        BvhPlaneEventList::iterator end = events->end(); 
     1368        BvhPlaneEventList::iterator it = begin; 
    13641369        // try all planes to find the best one for the given set of objects 
    13651370        while (it != end) 
    13661371        { 
    1367                 PlaneEventList::iterator p = it; 
     1372                BvhPlaneEventList::iterator p = it; 
    13681373                pStart = pOn = pEnd = 0; 
    1369                 while (it != end && p->equalsType(*it, PlaneEvent::PET_END)) 
     1374                while (it != end && p->equalsType(*it, BvhPlaneEvent::PET_END)) 
    13701375                { 
    13711376                        it++; pEnd++; 
    13721377                } 
    1373                 while (it != end && p->equalsType(*it, PlaneEvent::PET_ON)) 
     1378                while (it != end && p->equalsType(*it, BvhPlaneEvent::PET_ON)) 
    13741379                { 
    13751380                        it++; pOn++; 
    13761381                } 
    1377                 while (it != end && p->equalsType(*it, PlaneEvent::PET_START)) 
     1382                while (it != end && p->equalsType(*it, BvhPlaneEvent::PET_START)) 
    13781383                { 
    13791384                        it++; pStart++; 
     
    13881393                nLeft[d] += pStart; nLeft[d] += pOn; nPlane[d] = 0; 
    13891394        } 
    1390         return new SplitInfo(best); 
     1395        return new BvhSplitInfo(best); 
    13911396} 
    13921397 
    13931398/************************************************************************/ 
    1394 /* KdTree rendering functions                                           */ 
     1399/* BvHierarchy rendering functions                                           */ 
    13951400/************************************************************************/ 
    13961401 
    13971402//------------------------------------------------------------------------- 
    1398 void KdTree::queueVisibleObjects(BvHierarchyCamera* cam, RenderQueue* queue, bool onlyShadowCasters,  
    1399         bool showBoxes, KdTree::NodeList& visibleNodes) 
     1403void BvHierarchy::queueVisibleObjects(BvHierarchyCamera* cam, RenderQueue* queue, bool onlyShadowCasters,  
     1404        bool showBoxes, BvHierarchy::NodeList& visibleNodes) 
    14001405{ 
    14011406        mFrameStats.clear(); 
    14021407        cam->mNumVisQueries = 0; 
    14031408 
    1404         if (mKdRoot) 
    1405                 recQueueVisibleObjects(mKdRoot, Root::getSingleton().getCurrentFrameNumber(), 
     1409        if (mBvhRoot) 
     1410                recQueueVisibleObjects(mBvhRoot, Root::getSingleton().getCurrentFrameNumber(), 
    14061411                        cam, queue, onlyShadowCasters, showBoxes, visibleNodes); 
    14071412 
     
    14101415 
    14111416//------------------------------------------------------------------------- 
    1412 void KdTree::recQueueVisibleObjects(KdTree::Node * node, unsigned long currentFrame,  
     1417void BvHierarchy::recQueueVisibleObjects(BvHierarchy::Node * node, unsigned long currentFrame,  
    14131418        BvHierarchyCamera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes,  
    1414         KdTree::NodeList& visibleNodes, bool fullVis) 
    1415 { 
    1416         BvHierarchyCamera::NodeVisibility vis = BvHierarchyCamera::KDNV_PART; 
     1419        BvHierarchy::NodeList& visibleNodes, bool fullVis) 
     1420{ 
     1421        BvHierarchyCamera::NodeVisibility vis = BvHierarchyCamera::BVHNV_PART; 
    14171422        // test visibility 
    14181423        //if (cam->isVisible(node->mAABB)) 
    14191424        if (fullVis ||  
    1420                 ((vis = (cam->*getVisibility)(node->mAABB)) != BvHierarchyCamera::KDNV_NONE)) 
     1425                ((vis = (cam->*getVisibility)(node->mAABB)) != BvHierarchyCamera::BVHNV_NONE)) 
    14211426        { 
    14221427                visibleNodes.push_back(node); 
    14231428 
    1424                 bool v = (fullVis || vis == BvHierarchyCamera::KDNV_FULL); 
     1429                bool v = (fullVis || vis == BvHierarchyCamera::BVHNV_FULL); 
    14251430 
    14261431                node->queueVisibleObjects(currentFrame, cam, queue, onlyShadowCasters, showBoxes, v); 
     
    14471452 
    14481453//------------------------------------------------------------------------- 
    1449 void KdTree::setEnhancedVis(bool enh) 
     1454void BvHierarchy::setEnhancedVis(bool enh) 
    14501455{ 
    14511456        if (enh) 
     
    14561461 
    14571462//------------------------------------------------------------------------- 
    1458 bool KdTree::getEnhancedVis() 
     1463bool BvHierarchy::getEnhancedVis() 
    14591464{ 
    14601465        return getVisibility == &BvHierarchyCamera::getVisibilityEnhanced; 
     
    14621467 
    14631468//------------------------------------------------------------------------- 
    1464 //void KdTree::findVisibleNodes(NodeList& visibleNodes, Camera * cam) 
     1469//void BvHierarchy::findVisibleNodes(NodeList& visibleNodes, Camera * cam) 
    14651470//{ 
    1466 //      if (mKdRoot) 
    1467 //              recFindVisibleNodes(mKdRoot, visibleNodes, cam); 
     1471//      if (mBvhRoot) 
     1472//              recFindVisibleNodes(mBvhRoot, visibleNodes, cam); 
    14681473//} 
    14691474 
    14701475////------------------------------------------------------------------------- 
    1471 //void KdTree::recFindVisibleNodes(KdTree::Node * node, NodeList& visibleNodes, Camera * cam) 
     1476//void BvHierarchy::recFindVisibleNodes(BvHierarchy::Node * node, NodeList& visibleNodes, Camera * cam) 
    14721477//{ 
    14731478//      // test visibility 
     
    14831488//} 
    14841489 
    1485 void KdTree::findNodesIn(const AxisAlignedBox &box, std::list<SceneNode *> &list, SceneNode *exclude) 
    1486 { 
    1487         if (mKdRoot) 
    1488                 recFindNodesIn(box, list, exclude, mKdRoot); 
    1489 } 
    1490  
    1491 void KdTree::findNodesIn(const Sphere &sphere, std::list<SceneNode *> &list, SceneNode *exclude) 
    1492 { 
    1493         if (mKdRoot) 
    1494                 recFindNodesIn(sphere, list, exclude, mKdRoot); 
    1495 } 
    1496  
    1497 void KdTree::findNodesIn(const PlaneBoundedVolume &volume, std::list<SceneNode *> &list, SceneNode *exclude) 
    1498 { 
    1499         if (mKdRoot) 
    1500                 recFindNodesIn(volume, list, exclude, mKdRoot); 
    1501 } 
    1502  
    1503 void KdTree::findNodesIn(const Ray &ray, std::list<SceneNode *> &list, SceneNode *exclude) 
    1504 { 
    1505         if (mKdRoot) 
    1506                 recFindNodesIn(ray, list, exclude, mKdRoot); 
    1507 } 
    1508  
    1509 void KdTree::recFindNodesIn(const AxisAlignedBox &box, std::list<SceneNode *> &list, SceneNode *exclude, Node * node, bool full) 
     1490void BvHierarchy::findNodesIn(const AxisAlignedBox &box, std::list<SceneNode *> &list, SceneNode *exclude) 
     1491{ 
     1492        if (mBvhRoot) 
     1493                recFindNodesIn(box, list, exclude, mBvhRoot); 
     1494} 
     1495 
     1496void BvHierarchy::findNodesIn(const Sphere &sphere, std::list<SceneNode *> &list, SceneNode *exclude) 
     1497{ 
     1498        if (mBvhRoot) 
     1499                recFindNodesIn(sphere, list, exclude, mBvhRoot); 
     1500} 
     1501 
     1502void BvHierarchy::findNodesIn(const PlaneBoundedVolume &volume, std::list<SceneNode *> &list, SceneNode *exclude) 
     1503{ 
     1504        if (mBvhRoot) 
     1505                recFindNodesIn(volume, list, exclude, mBvhRoot); 
     1506} 
     1507 
     1508void BvHierarchy::findNodesIn(const Ray &ray, std::list<SceneNode *> &list, SceneNode *exclude) 
     1509{ 
     1510        if (mBvhRoot) 
     1511                recFindNodesIn(ray, list, exclude, mBvhRoot); 
     1512} 
     1513 
     1514void BvHierarchy::recFindNodesIn(const AxisAlignedBox &box, std::list<SceneNode *> &list, SceneNode *exclude, Node * node, bool full) 
    15101515{ 
    15111516        // check intersection 
    15121517        if ( !full ) 
    15131518        { 
    1514                 Intersection isect = intersect(box, node->_getWorldAABB()); 
     1519                BvhIntersection isect = intersect(box, node->_getWorldAABB()); 
    15151520 
    15161521                if ( isect == OUTSIDE ) 
     
    15221527        if (node->isLeaf()) 
    15231528        { 
    1524                 LeafPtr leaf = KDLEAFPTR_CAST(node); 
    1525                 for (BvRenderableList::iterator it = leaf->mBvRenderables.begin(); 
    1526                         it != leaf->mBvRenderables.end(); it ++) 
     1529                LeafPtr leaf = BVHLEAFPTR_CAST(node); 
     1530                for (BvhRenderableList::iterator it = leaf->mBvhRenderables.begin(); 
     1531                        it != leaf->mBvhRenderables.end(); it ++) 
    15271532                { 
    15281533                        SceneNode *sn = dynamic_cast<SceneNode *>(*it); 
     
    15361541                                else 
    15371542                                { 
    1538                                         Intersection nsect = intersect(box, sn->_getWorldAABB()); 
     1543                                        BvhIntersection nsect = intersect(box, sn->_getWorldAABB()); 
    15391544 
    15401545                                        if ( nsect != OUTSIDE ) 
     
    15551560} 
    15561561 
    1557 void KdTree::recFindNodesIn(const Sphere &sphere, std::list<SceneNode *> &list, SceneNode *exclude, Node * node, bool full) 
     1562void BvHierarchy::recFindNodesIn(const Sphere &sphere, std::list<SceneNode *> &list, SceneNode *exclude, Node * node, bool full) 
    15581563{ 
    15591564        // TODO 
    15601565} 
    15611566 
    1562 void KdTree::recFindNodesIn(const PlaneBoundedVolume &volume, std::list<SceneNode *> &list, SceneNode *exclude, Node * node, bool full) 
     1567void BvHierarchy::recFindNodesIn(const PlaneBoundedVolume &volume, std::list<SceneNode *> &list, SceneNode *exclude, Node * node, bool full) 
    15631568{ 
    15641569        // TODO 
    15651570} 
    15661571 
    1567 void KdTree::recFindNodesIn(const Ray &ray, std::list<SceneNode *> &list, SceneNode *exclude, Node * node, bool full) 
     1572void BvHierarchy::recFindNodesIn(const Ray &ray, std::list<SceneNode *> &list, SceneNode *exclude, Node * node, bool full) 
    15681573{ 
    15691574        // TODO 
     
    15711576 
    15721577/************************************************************************/ 
    1573 /* KdTree debug & helper functions                                      */ 
     1578/* BvHierarchy debug & helper functions                                      */ 
    15741579/************************************************************************/ 
    15751580 
    15761581//------------------------------------------------------------------------- 
    1577 void KdTree::dump() 
    1578 { 
    1579         //LogManager::getSingleton().logMessage("#@#@#@#@ Dumping KdTree #@#@#@#@"); 
    1580         mBuildLog->logMessage("#@#@#@#@ Dumping KdTree #@#@#@#@"); 
    1581         if (mKdRoot) 
    1582                 dump(mKdRoot); 
     1582void BvHierarchy::dump() 
     1583{ 
     1584        //LogManager::getSingleton().logMessage("#@#@#@#@ Dumping BvHierarchy #@#@#@#@"); 
     1585        mBuildLog->logMessage("#@#@#@#@ Dumping BvHierarchy #@#@#@#@"); 
     1586        if (mBvhRoot) 
     1587                dump(mBvhRoot); 
    15831588} 
    15841589 
    15851590//------------------------------------------------------------------------- 
    1586 void KdTree::dump(KdTree::Node * node) 
     1591void BvHierarchy::dump(BvHierarchy::Node * node) 
    15871592{ 
    15881593        //LogManager * log = LogManager::getSingletonPtr(); 
    1589         KdTreeSceneNode * scenenode; 
     1594        BvHierarchySceneNode * scenenode; 
    15901595        String pad; 
    15911596        int p; 
     
    15991604        if (node->isLeaf()) 
    16001605        { 
    1601                 KdTree::Leaf * leaf = KDLEAFPTR_CAST(node); 
    1602                 BvRenderableList::iterator it  = leaf->mBvRenderables.begin(); 
    1603                 BvRenderableList::iterator end = leaf->mBvRenderables.end(); 
     1606                BvHierarchy::Leaf * leaf = BVHLEAFPTR_CAST(node); 
     1607                BvhRenderableList::iterator it  = leaf->mBvhRenderables.begin(); 
     1608                BvhRenderableList::iterator end = leaf->mBvhRenderables.end(); 
    16041609                while (it != end) 
    16051610                { 
    1606                         scenenode = dynamic_cast<KdTreeSceneNode *>(*it); 
     1611                        scenenode = dynamic_cast<BvHierarchySceneNode *>(*it); 
    16071612                        mBuildLog->logMessage(pad + "# Leaf   level " +  
    16081613                                StringConverter::toString(node->getLevel()) +  
     
    16141619        else 
    16151620        { 
    1616                 KdTree::Branch * branch = KDBRANCHPTR_CAST(node); 
     1621                BvHierarchy::Branch * branch = BVHBRANCHPTR_CAST(node); 
    16171622                if (branch->mLeft) 
    16181623                { 
     
    16311636 
    16321637//------------------------------------------------------------------------- 
    1633 Real KdTree::calcCost() 
    1634 { 
    1635         if (mKdRoot) 
    1636                 return calcCost(mKdRoot, PlaneEvent::surfaceArea(mKdRoot->mAABB)); 
     1638Real BvHierarchy::calcCost() 
     1639{ 
     1640        if (mBvhRoot) 
     1641                return calcCost(mBvhRoot, BvhPlaneEvent::surfaceArea(mBvhRoot->mAABB)); 
    16371642        else 
    16381643                return 0; 
     
    16401645 
    16411646//------------------------------------------------------------------------- 
    1642 Real KdTree::calcCost(KdTree::Node * node, Real vs) 
     1647Real BvHierarchy::calcCost(BvHierarchy::Node * node, Real vs) 
    16431648{ 
    16441649        if (node == 0) 
     
    16471652        if (node->isLeaf()) 
    16481653        { 
    1649                 KdTree::Leaf * leaf = KDLEAFPTR_CAST(node); 
    1650                 return (PlaneEvent::surfaceArea(node->mAABB)/vs) * 
    1651                         PlaneEvent::KI * leaf->mBvRenderables.size(); 
     1654                BvHierarchy::Leaf * leaf = BVHLEAFPTR_CAST(node); 
     1655                return (BvhPlaneEvent::surfaceArea(node->mAABB)/vs) * 
     1656                        BvhPlaneEvent::KI * leaf->mBvhRenderables.size(); 
    16521657        } 
    16531658        else 
    16541659        { 
    1655                 KdTree::Branch * branch = KDBRANCHPTR_CAST(node); 
    1656                 return (PlaneEvent::surfaceArea(node->mAABB)/vs) * PlaneEvent::KT +  
     1660                BvHierarchy::Branch * branch = BVHBRANCHPTR_CAST(node); 
     1661                return (BvhPlaneEvent::surfaceArea(node->mAABB)/vs) * BvhPlaneEvent::KT +  
    16571662                        calcCost(branch->mLeft, vs) + calcCost(branch->mRight, vs); 
    16581663        } 
     
    16601665 
    16611666/************************************************************************/ 
    1662 /* KdTree::Node/Branch/Leaf functions                                   */ 
     1667/* BvHierarchy::Node/Branch/Leaf functions                                   */ 
    16631668/************************************************************************/ 
    16641669 
    16651670//------------------------------------------------------------------------- 
    1666 KdTree::Leaf::~Leaf() 
     1671BvHierarchy::Leaf::~Leaf() 
    16671672{ 
    16681673        // detach all scene nodes in the case that we are rebuilding 
    16691674        // the tree but not the scene 
    1670         BvRenderableList::iterator it = mBvRenderables.begin(); 
    1671         BvRenderableList::iterator end = mBvRenderables.end(); 
     1675        BvhRenderableList::iterator it = mBvhRenderables.begin(); 
     1676        BvhRenderableList::iterator end = mBvhRenderables.end(); 
    16721677        while (it != end) 
    16731678        { 
     
    16751680                it++; 
    16761681        } 
    1677         mBvRenderables.clear(); 
     1682        mBvhRenderables.clear(); 
    16781683} 
    16791684 
    16801685//------------------------------------------------------------------------- 
    1681 void KdTree::Leaf::queueVisibleObjects(unsigned long currentFrame,  
     1686void BvHierarchy::Leaf::queueVisibleObjects(unsigned long currentFrame,  
    16821687        Camera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes, bool fullVis) 
    16831688{ 
    1684         BvRenderableList::iterator it  = mBvRenderables.begin(); 
    1685         BvRenderableList::iterator end = mBvRenderables.end(); 
     1689        BvhRenderableList::iterator it  = mBvhRenderables.begin(); 
     1690        BvhRenderableList::iterator end = mBvhRenderables.end(); 
    16861691        while (it != end) 
    16871692        {                        
     
    16991704 
    17001705//------------------------------------------------------------------------- 
    1701 void KdTree::Leaf::getGeometryList(GtpVisibility::GeometryVector *geometryList) 
    1702 { 
    1703         BvRenderableList::iterator it = mBvRenderables.begin(); 
    1704         BvRenderableList::iterator end = mBvRenderables.end(); 
     1706void BvHierarchy::Leaf::getGeometryList(GtpVisibility::GeometryVector *geometryList) 
     1707{ 
     1708        BvhRenderableList::iterator it = mBvhRenderables.begin(); 
     1709        BvhRenderableList::iterator end = mBvhRenderables.end(); 
    17051710        while (it != end) 
    17061711        { 
     
    17121717//------------------------------------------------------------------------- 
    17131718// update the world aabb based on the contained geometry 
    1714 void KdTree::Leaf::_updateBounds(bool recurse) 
     1719void BvHierarchy::Leaf::_updateBounds(bool recurse) 
    17151720{ 
    17161721        // reset box 
     
    17181723 
    17191724        // merge boxes from attached geometry 
    1720         BvRenderableList::iterator it = mBvRenderables.begin(); 
    1721         BvRenderableList::iterator end = mBvRenderables.end(); 
     1725        BvhRenderableList::iterator it = mBvhRenderables.begin(); 
     1726        BvhRenderableList::iterator end = mBvhRenderables.end(); 
    17221727        while (it != end) 
    17231728        { 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreBvHierarchyCamera.cpp

    r1319 r1320  
    3232        // Null boxes always invisible 
    3333        if ( box.isNull() ) 
    34                 return KDNV_NONE; 
     34                return BVHNV_NONE; 
    3535 
    3636        // Make any pending updates to the calculated frustum planes 
     
    7575 
    7676                if ( all_outside ) 
    77                         return KDNV_NONE; 
     77                        return BVHNV_NONE; 
    7878        } 
    7979 
    8080        if ( all_inside ) 
    81                 return KDNV_FULL; 
     81                return BVHNV_FULL; 
    8282        else 
    83                 return KDNV_PART; 
     83                return BVHNV_PART; 
    8484} 
    8585 
     
    9494        if (mCullFrustum) 
    9595        { 
    96                 return mCullFrustum->isVisible(box, culledBy) ? KDNV_PART : KDNV_NONE; 
     96                return mCullFrustum->isVisible(box, culledBy) ? BVHNV_PART : BVHNV_NONE; 
    9797        } 
    9898        else 
    9999        { 
    100                 return Frustum::isVisible(box, culledBy) ? KDNV_PART : KDNV_NONE; 
     100                return Frustum::isVisible(box, culledBy) ? BVHNV_PART : BVHNV_NONE; 
    101101        } 
    102102} 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreBvHierarchyInterface.cpp

    r1319 r1320  
    88*/ 
    99 
    10 #include "OgreBvRenderable.h" 
     10#include "OgreBvhRenderable.h" 
    1111#include "OgreBvHierarchySceneManager.h" 
    1212#include "OgreBvHierarchyInterface.h" 
     
    1515{ 
    1616 
    17 KdTreeHierarchyInterface::KdTreeHierarchyInterface(KdTreeSceneManager *sm, RenderSystem *rsys): 
     17BvHierarchyInterface::BvHierarchyInterface(BvHierarchySceneManager *sm, RenderSystem *rsys): 
    1818PlatformHierarchyInterface(sm, rsys) 
    1919{ 
     
    2121} 
    2222 
    23 bool KdTreeHierarchyInterface::IsLeaf(GtpVisibility::HierarchyNode *node) const 
     23bool BvHierarchyInterface::IsLeaf(GtpVisibility::HierarchyNode *node) const 
    2424{ 
    25         return KDNODEPTR_CAST(node)->isLeaf(); 
     25        return BVHNODEPTR_CAST(node)->isLeaf(); 
    2626} 
    2727 
    28 void KdTreeHierarchyInterface::TraverseNode(GtpVisibility::HierarchyNode *node) 
     28void BvHierarchyInterface::TraverseNode(GtpVisibility::HierarchyNode *node) 
    2929{ 
    3030        ++ mNumTraversedNodes; 
    3131 
    32         KdTree::Node * kdnode = KDNODEPTR_CAST(node); 
     32        BvHierarchy::Node * kdnode = BVHNODEPTR_CAST(node); 
    3333 
    3434        // if the node is a leaf and has geometry => render it 
     
    4949} 
    5050 
    51 void KdTreeHierarchyInterface::RenderNode(GtpVisibility::HierarchyNode *node) 
     51void BvHierarchyInterface::RenderNode(GtpVisibility::HierarchyNode *node) 
    5252{ 
    53         KdTree::Node * kdnode = KDNODEPTR_CAST(node); 
     53        BvHierarchy::Node * kdnode = BVHNODEPTR_CAST(node); 
    5454        if (kdnode->lastRendered() != mFrameId) 
    5555        { 
    5656                kdnode->setLastRendered(mFrameId); 
    57                 KdTreeSceneManager * ksm = static_cast<KdTreeSceneManager *>(mSceneManager); 
     57                BvHierarchySceneManager * ksm = static_cast<BvHierarchySceneManager *>(mSceneManager); 
    5858 
    5959                ksm->_renderNode(kdnode, mCamera, mOnlyShadowCasters, mLeavePassesInQueue); 
     
    6363} 
    6464 
    65 void KdTreeHierarchyInterface::PullUpVisibility(GtpVisibility::HierarchyNode *node) const 
     65void BvHierarchyInterface::PullUpVisibility(GtpVisibility::HierarchyNode *node) const 
    6666{ 
    67         KdTree::Node * kdnode = KDNODEPTR_CAST(node); 
     67        BvHierarchy::Node * kdnode = BVHNODEPTR_CAST(node); 
    6868 
    6969        while (kdnode && !kdnode->isNodeVisible()) 
     
    7474} 
    7575 
    76 float KdTreeHierarchyInterface::GetSquaredDistance(GtpVisibility::HierarchyNode *node) const 
     76float BvHierarchyInterface::GetSquaredDistance(GtpVisibility::HierarchyNode *node) const 
    7777{ 
    78         const Vector3 pos = KDNODEPTR_CAST(node)->mAABB.getCenter(); 
     78        const Vector3 pos = BVHNODEPTR_CAST(node)->mAABB.getCenter(); 
    7979        return (mCameraPosition - pos).squaredLength(); 
    8080} 
    8181 
    82 AxisAlignedBox * KdTreeHierarchyInterface::GetBoundingBox(GtpVisibility::HierarchyNode *node) 
     82AxisAlignedBox * BvHierarchyInterface::GetBoundingBox(GtpVisibility::HierarchyNode *node) 
    8383{ 
    8484        // reuse box if node is the same 
     
    8787        { 
    8888                mSavedNode = node; 
    89                 mBox = KDNODEPTR_CAST(node)->_getWorldAABB(); 
     89                mBox = BVHNODEPTR_CAST(node)->_getWorldAABB(); 
    9090        } 
    9191 
     
    9393} 
    9494 
    95 bool KdTreeHierarchyInterface::HasGeometry(GtpVisibility::HierarchyNode *node) const 
     95bool BvHierarchyInterface::HasGeometry(GtpVisibility::HierarchyNode *node) const 
    9696{ 
    97         return KDNODEPTR_CAST(node)->hasGeometry(); 
     97        return BVHNODEPTR_CAST(node)->hasGeometry(); 
    9898} 
    9999 
    100 void KdTreeHierarchyInterface::SetNodeVisible(GtpVisibility::HierarchyNode *node, const bool visible) const 
     100void BvHierarchyInterface::SetNodeVisible(GtpVisibility::HierarchyNode *node, const bool visible) const 
    101101{ 
    102         KDNODEPTR_CAST(node)->setNodeVisible(visible); 
     102        BVHNODEPTR_CAST(node)->setNodeVisible(visible); 
    103103} 
    104104 
    105 bool KdTreeHierarchyInterface::IsNodeVisible(GtpVisibility::HierarchyNode *node) const 
     105bool BvHierarchyInterface::IsNodeVisible(GtpVisibility::HierarchyNode *node) const 
    106106{ 
    107         return KDNODEPTR_CAST(node)->isNodeVisible(); 
     107        return BVHNODEPTR_CAST(node)->isNodeVisible(); 
    108108} 
    109109 
    110 void KdTreeHierarchyInterface::SetLastVisited(GtpVisibility::HierarchyNode *node, const unsigned int frameId) const 
     110void BvHierarchyInterface::SetLastVisited(GtpVisibility::HierarchyNode *node, const unsigned int frameId) const 
    111111{ 
    112         KDNODEPTR_CAST(node)->setLastVisited(frameId); 
     112        BVHNODEPTR_CAST(node)->setLastVisited(frameId); 
    113113} 
    114114 
    115 unsigned int KdTreeHierarchyInterface::LastVisited(GtpVisibility::HierarchyNode *node) const 
     115unsigned int BvHierarchyInterface::LastVisited(GtpVisibility::HierarchyNode *node) const 
    116116{ 
    117         return KDNODEPTR_CAST(node)->lastVisited(); 
     117        return BVHNODEPTR_CAST(node)->lastVisited(); 
    118118} 
    119119 
    120 void KdTreeHierarchyInterface::VisualizeCulledNode(GtpVisibility::HierarchyNode *node,  
     120void BvHierarchyInterface::VisualizeCulledNode(GtpVisibility::HierarchyNode *node,  
    121121                                                                                                   GtpVisibility::CullingType type) const 
    122122{ 
    123         WireBoundingBox *box = KDNODEPTR_CAST(node)->getWireBoundingBox(); 
     123        WireBoundingBox *box = BVHNODEPTR_CAST(node)->getWireBoundingBox(); 
    124124 
    125125        if (type == GtpVisibility::FRUSTUM_CULLED) 
     
    132132        } 
    133133 
    134         dynamic_cast<KdTreeSceneManager *>(mSceneManager)->getRenderQueue()->addRenderable(box); 
     134        dynamic_cast<BvHierarchySceneManager *>(mSceneManager)->getRenderQueue()->addRenderable(box); 
    135135} 
    136136 
    137 void KdTreeHierarchyInterface::GetNodeGeometryList(GtpVisibility::HierarchyNode *node,  
     137void BvHierarchyInterface::GetNodeGeometryList(GtpVisibility::HierarchyNode *node,  
    138138                                                                                                   GtpVisibility::GeometryVector *geometryList,  
    139139                                                                                                   bool includeChildren)  
    140140{ 
    141         KDNODEPTR_CAST(node)->getGeometryList(geometryList); 
     141        BVHNODEPTR_CAST(node)->getGeometryList(geometryList); 
    142142} 
    143143 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreBvHierarchySceneManager.cpp

    r1319 r1320  
    2727{ 
    2828 
    29 KdTreeSceneManager::KdTreeSceneManager(const String& name, GtpVisibility::VisibilityManager *vm): 
     29BvHierarchySceneManager::BvHierarchySceneManager(const String& name, GtpVisibility::VisibilityManager *vm): 
    3030SceneManager(name),  
    3131mVisibilityManager(vm),  
    3232mBvHierarchy(0),  
    33 mMaxDepth(KDTREE_MAX_DEPTH), 
     33mMaxDepth(BvHierarchy_MAX_DEPTH), 
    3434mShowBoxes(false), 
    3535mHiLiteLevel(0), 
    3636mShowAllBoxes(false), 
    3737mEnhancedVisiblity(true), 
    38 mBuildMethod(KdTree::KDBM_RECURSIVE), 
    39 mRenderMethod(KdTree::KDRM_INTERNAL), 
     38mBuildMethod(BvHierarchy::BVHBM_RECURSIVE), 
     39mRenderMethod(BvHierarchy::BVHRM_INTERNAL), 
    4040mShowVisualization(false), 
    4141mRenderNodesForViz(false), 
     
    6464        // Replace root node with my node 
    6565        OGRE_DELETE(mSceneRoot); 
    66         mSceneRoot = new KdTreeSceneNode(this, "root node"); 
     66        mSceneRoot = new BvHierarchySceneNode(this, "root node"); 
    6767        mSceneRoot->_notifyRootNode(); 
    6868 
    6969        // init heirarchy interface 
    70         mHierarchyInterface = new KdTreeHierarchyInterface(this, mDestRenderSystem); 
    71 } 
    72  
    73 KdTreeSceneManager::~KdTreeSceneManager(void) 
     70        mHierarchyInterface = new BvHierarchyInterface(this, mDestRenderSystem); 
     71} 
     72 
     73BvHierarchySceneManager::~BvHierarchySceneManager(void) 
    7474{ 
    7575        delete mHierarchyInterface; 
     
    7777} 
    7878 
    79 void KdTreeSceneManager::clearScene() 
     79void BvHierarchySceneManager::clearScene() 
    8080{ 
    8181        // DEBUG 
     
    9090 
    9191 
    92 const String& KdTreeSceneManager::getTypeName(void) const 
     92const String& BvHierarchySceneManager::getTypeName(void) const 
    9393{ 
    9494        return BvHierarchySceneManagerFactory::FACTORY_TYPE_NAME; 
    9595} 
    9696 
    97 void KdTreeSceneManager::setShowBoxes(bool showboxes) 
     97void BvHierarchySceneManager::setShowBoxes(bool showboxes) 
    9898{ 
    9999        mShowBoxes = showboxes; 
    100100} 
    101101 
    102 bool KdTreeSceneManager::getShowBoxes(void) const 
     102bool BvHierarchySceneManager::getShowBoxes(void) const 
    103103{ 
    104104        return mShowBoxes; 
    105105} 
    106106 
    107 bool KdTreeSceneManager::setOption(const String& strKey, const void* pValue) 
    108 { 
    109         // change max depth of the kdtree 
     107bool BvHierarchySceneManager::setOption(const String& strKey, const void* pValue) 
     108{ 
     109        // change max depth of the BvHierarchy 
    110110        // rebuild the tree if already exists 
    111         if (strKey == "KdTreeMaxDepth") 
     111        if (strKey == "BvHierarchyMaxDepth") 
    112112        { 
    113113                int maxdepth = *static_cast<const int *>(pValue); 
     
    132132                if (kt > 0) 
    133133                { 
    134                         PlaneEvent::KT = kt; 
     134                        BvhPlaneEvent::KT = kt; 
    135135                        return true; 
    136136                } 
     
    145145                if (ki > 0) 
    146146                { 
    147                         PlaneEvent::KI = ki; 
     147                        BvhPlaneEvent::KI = ki; 
    148148                        return true; 
    149149                } 
     
    153153                } 
    154154        } 
    155         else if (strKey == "RebuildKdTree") 
     155        else if (strKey == "RebuildBvHierarchy") 
    156156        { 
    157157                OGRE_DELETE(mBvHierarchy); 
    158                 mBvHierarchy = new KdTree(mMaxDepth, mBuildMethod, mHiLiteLevel, mShowAllBoxes, mShowNodes); 
    159                 mBvHierarchy->build(static_cast<KdTreeSceneNode *>(mSceneRoot)); 
     158                mBvHierarchy = new BvHierarchy(mMaxDepth, mBuildMethod, mHiLiteLevel, mShowAllBoxes, mShowNodes); 
     159                mBvHierarchy->build(static_cast<BvHierarchySceneNode *>(mSceneRoot)); 
    160160                mBvHierarchy->setEnhancedVis(mEnhancedVisiblity); 
    161161                return true; 
     
    172172        else if (strKey == "BuildMethod") 
    173173        { 
    174                 KdTree::BuildMethod bm = *static_cast<const KdTree::BuildMethod *>(pValue); 
    175                 if (bm == KdTree::KDBM_RECURSIVE || bm == KdTree::KDBM_PRIORITYQUEUE) 
     174                BvHierarchy::BuildMethod bm = *static_cast<const BvHierarchy::BuildMethod *>(pValue); 
     175                if (bm == BvHierarchy::BVHBM_RECURSIVE || bm == BvHierarchy::BVHBM_PRIORITYQUEUE) 
    176176                { 
    177177                        mBuildMethod = bm; 
     
    185185        else if (strKey == "RenderMethod") 
    186186        { 
    187                 KdTree::RenderMethod rm = *static_cast<const KdTree::RenderMethod *>(pValue); 
    188                 if (rm == KdTree::KDRM_INTERNAL) 
     187                BvHierarchy::RenderMethod rm = *static_cast<const BvHierarchy::RenderMethod *>(pValue); 
     188                if (rm == BvHierarchy::BVHRM_INTERNAL) 
    189189                { 
    190190                        mRenderMethod = rm; 
    191191                        return true; 
    192192                } 
    193                 else if (rm == KdTree::KDRM_GTP_VFC) 
     193                else if (rm == BvHierarchy::BVHRM_GTP_VFC) 
    194194                { 
    195195                        mRenderMethod = rm; 
     
    198198                                .setOption("Algorithm", &cmt); 
    199199                } 
    200                 else if (rm == KdTree::KDRM_GTP_SWC) 
     200                else if (rm == BvHierarchy::BVHRM_GTP_SWC) 
    201201                { 
    202202                        mRenderMethod = rm; 
     
    205205                                .setOption("Algorithm", &cmt); 
    206206                } 
    207                 else if (rm == KdTree::KDRM_GTP_CHC) 
     207                else if (rm == BvHierarchy::BVHRM_GTP_CHC) 
    208208                { 
    209209                        mRenderMethod = rm; 
     
    227227                        int val = *static_cast<const int *>(pValue); 
    228228                        if (val == GtpVisibility::VisibilityEnvironment::FRUSTUM_CULLING) 
    229                                 mRenderMethod = KdTree::KDRM_GTP_VFC; 
     229                                mRenderMethod = BvHierarchy::BVHRM_GTP_VFC; 
    230230                        else if (val == GtpVisibility::VisibilityEnvironment::STOP_AND_WAIT_CULLING) 
    231                                 mRenderMethod = KdTree::KDRM_GTP_SWC; 
     231                                mRenderMethod = BvHierarchy::BVHRM_GTP_SWC; 
    232232                        else if (val == GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING) 
    233                                 mRenderMethod = KdTree::KDRM_GTP_CHC; 
     233                                mRenderMethod = BvHierarchy::BVHRM_GTP_CHC; 
    234234                        // default, should never happen 
    235235                        else 
    236                                 mRenderMethod = KdTree::KDRM_INTERNAL; 
     236                                mRenderMethod = BvHierarchy::BVHRM_INTERNAL; 
    237237                } 
    238238                else 
    239239                { 
    240                         mRenderMethod = KdTree::KDRM_INTERNAL; 
     240                        mRenderMethod = BvHierarchy::BVHRM_INTERNAL; 
    241241                } 
    242242                return success; 
    243243        } 
    244         else if (strKey == "ShowKdTree") 
     244        else if (strKey == "ShowBvHierarchy") 
    245245        { 
    246246                bool sk = *static_cast<const bool *>(pValue); 
     
    406406} 
    407407 
    408 bool KdTreeSceneManager::getOption(const String& strKey, void* pDestValue) 
    409 { 
    410         if (strKey == "KdTreeMaxDepth") 
     408bool BvHierarchySceneManager::getOption(const String& strKey, void* pDestValue) 
     409{ 
     410        if (strKey == "BvHierarchyMaxDepth") 
    411411        { 
    412412                *static_cast<int *>(pDestValue) = mMaxDepth; 
     
    415415        else if (strKey == "KT") 
    416416        { 
    417                 *static_cast<Real *>(pDestValue) = PlaneEvent::KT; 
     417                *static_cast<Real *>(pDestValue) = BvhPlaneEvent::KT; 
    418418                return true; 
    419419        } 
    420420        else if (strKey == "KI") 
    421421        { 
    422                 *static_cast<Real *>(pDestValue) = PlaneEvent::KI; 
     422                *static_cast<Real *>(pDestValue) = BvhPlaneEvent::KI; 
    423423                return true; 
    424424        } 
     
    433433        else if (strKey == "BuildMethod") 
    434434        { 
    435                 *static_cast<KdTree::BuildMethod *>(pDestValue) = mBuildMethod; 
     435                *static_cast<BvHierarchy::BuildMethod *>(pDestValue) = mBuildMethod; 
    436436                return true; 
    437437        } 
    438438        else if (strKey == "RenderMethod") 
    439439        { 
    440                 *static_cast<KdTree::RenderMethod *>(pDestValue) = mRenderMethod; 
    441                 return true; 
    442         } 
    443         else if (strKey == "ShowKdTree") 
     440                *static_cast<BvHierarchy::RenderMethod *>(pDestValue) = mRenderMethod; 
     441                return true; 
     442        } 
     443        else if (strKey == "ShowBvHierarchy") 
    444444        { 
    445445                *static_cast<bool *>(pDestValue) = mShowBoxes; 
     
    464464        else if (strKey == "NumFrustumCulledNodes") 
    465465        { 
    466                 if (mRenderMethod == KdTree::KDRM_INTERNAL) 
     466                if (mRenderMethod == BvHierarchy::BVHRM_INTERNAL) 
    467467                { 
    468468                        unsigned int numnodes = 0; 
     
    477477        else if (strKey == "NumQueryCulledNodes") 
    478478        { 
    479                 if (mRenderMethod == KdTree::KDRM_INTERNAL) 
     479                if (mRenderMethod == BvHierarchy::BVHRM_INTERNAL) 
    480480                { 
    481481                        * static_cast<unsigned int *>(pDestValue) = 0; 
     
    495495        else if (strKey == "NumRenderedNodes") 
    496496        { 
    497                 if (mRenderMethod == KdTree::KDRM_INTERNAL) 
     497                if (mRenderMethod == BvHierarchy::BVHRM_INTERNAL) 
    498498                { 
    499499                        unsigned int numnodes = 0; 
     
    508508        else if (strKey == "NumQueriesIssued") 
    509509        { 
    510                 if (mRenderMethod == KdTree::KDRM_INTERNAL) 
     510                if (mRenderMethod == BvHierarchy::BVHRM_INTERNAL) 
    511511                { 
    512512                        * static_cast<unsigned int *>(pDestValue) = 0; 
     
    517517        else if (strKey == "NumTraversedNodes") 
    518518        { 
    519                 if (mRenderMethod == KdTree::KDRM_INTERNAL) 
     519                if (mRenderMethod == BvHierarchy::BVHRM_INTERNAL) 
    520520                { 
    521521                        unsigned int numnodes = 0; 
     
    557557} 
    558558 
    559 bool KdTreeSceneManager::getOptionKeys(StringVector &refKeys) 
     559bool BvHierarchySceneManager::getOptionKeys(StringVector &refKeys) 
    560560{ 
    561561        refKeys.push_back("Algorithm"); 
     
    570570        refKeys.push_back("KI"); 
    571571        refKeys.push_back("KT"); 
    572         refKeys.push_back("KdTreeMaxDepth"); 
     572        refKeys.push_back("BvHierarchyMaxDepth"); 
    573573        refKeys.push_back("LoadViewCells"); 
    574574        refKeys.push_back("NumHierarchyNodes"); 
    575575        refKeys.push_back("PrepareVisualization"); 
    576         refKeys.push_back("RebuildKdTree"); 
     576        refKeys.push_back("RebuildBvHierarchy"); 
    577577        refKeys.push_back("RenderMethod"); 
    578578        refKeys.push_back("RenderNodesContentForViz"); 
     
    580580        refKeys.push_back("RenderTransparentsForItemBuffer"); 
    581581        refKeys.push_back("ShowAllBoxes"); 
    582         refKeys.push_back("ShowKdTree"); 
     582        refKeys.push_back("ShowBvHierarchy"); 
    583583        refKeys.push_back("ShowNodes"); 
    584584        refKeys.push_back("SkyBoxEnabled"); 
     
    595595} 
    596596 
    597 bool KdTreeSceneManager::getOptionValues(const String & key, StringVector &refValueList) 
     597bool BvHierarchySceneManager::getOptionValues(const String & key, StringVector &refValueList) 
    598598{ 
    599599        return SceneManager::getOptionValues(key, refValueList); 
    600600} 
    601601 
    602 void KdTreeSceneManager::setVisibilityManager(GtpVisibility::VisibilityManager *visManager) 
     602void BvHierarchySceneManager::setVisibilityManager(GtpVisibility::VisibilityManager *visManager) 
    603603{ 
    604604        mVisibilityManager = visManager; 
    605605} 
    606606 
    607 GtpVisibility::VisibilityManager * KdTreeSceneManager::getVisibilityManager() 
     607GtpVisibility::VisibilityManager * BvHierarchySceneManager::getVisibilityManager() 
    608608{ 
    609609        return mVisibilityManager; 
    610610} 
    611611 
    612 GtpVisibility::VisibilityManager * KdTreeSceneManager::GetVisibilityManager() 
     612GtpVisibility::VisibilityManager * BvHierarchySceneManager::GetVisibilityManager() 
    613613{ 
    614614        return mVisibilityManager; 
    615615} 
    616616 
    617 KdTreeHierarchyInterface * KdTreeSceneManager::GetHierarchyInterface() 
     617BvHierarchyInterface * BvHierarchySceneManager::GetHierarchyInterface() 
    618618{ 
    619619        return mHierarchyInterface; 
    620620} 
    621621 
    622 Camera* KdTreeSceneManager::createCamera(const String& name) 
     622Camera* BvHierarchySceneManager::createCamera(const String& name) 
    623623{ 
    624624        // Check name not used 
     
    637637} 
    638638 
    639 SceneNode* KdTreeSceneManager::createSceneNode(void) 
    640 { 
    641         SceneNode* sn = new KdTreeSceneNode(this); 
     639SceneNode* BvHierarchySceneManager::createSceneNode(void) 
     640{ 
     641        SceneNode* sn = new BvHierarchySceneNode(this); 
    642642        assert(mSceneNodes.find(sn->getName()) == mSceneNodes.end()); 
    643643        mSceneNodes[sn->getName()] = sn; 
     
    645645} 
    646646 
    647 SceneNode* KdTreeSceneManager::createSceneNode(const String& name) 
     647SceneNode* BvHierarchySceneManager::createSceneNode(const String& name) 
    648648{ 
    649649        // Check name not used 
     
    653653                        Exception::ERR_DUPLICATE_ITEM, 
    654654                        "A scene node with the name " + name + " already exists", 
    655                         "KdTreeSceneManager::createSceneNode" ); 
    656         } 
    657  
    658         SceneNode* sn = new KdTreeSceneNode(this, name); 
     655                        "BvHierarchySceneManager::createSceneNode" ); 
     656        } 
     657 
     658        SceneNode* sn = new BvHierarchySceneNode(this, name); 
    659659        mSceneNodes[sn->getName()] = sn; 
    660660        return sn; 
    661661} 
    662662 
    663 Entity * KdTreeSceneManager::createEntity(const String& entityName, const String& meshName) 
     663Entity * BvHierarchySceneManager::createEntity(const String& entityName, const String& meshName) 
    664664{ 
    665665        Entity *ent = SceneManager::createEntity(entityName, meshName); 
     
    677677 
    678678// make sure it's called only for non-empty nodes .. avoids one uneccessary funciton call 
    679 void KdTreeSceneManager::_updateNode(KdTreeSceneNode *node) 
     679void BvHierarchySceneManager::_updateNode(BvHierarchySceneNode *node) 
    680680{ 
    681681        //LogManager::getSingleton().logMessage("### _updateNode called for " + node->getName()); 
    682682 
    683         /* Rebuild kdtree when it was wiped out 
     683        /* Rebuild BvHierarchy when it was wiped out 
    684684                * Usually this happens only before the first frame 
    685685                * The initial AABB shall enclose all objects present 
     
    691691        if (!mBvHierarchy) 
    692692        { 
    693                 mBvHierarchy = new KdTree(mMaxDepth, mBuildMethod); 
    694                 mBvHierarchy->build(static_cast<KdTreeSceneNode *>(mSceneRoot)); 
     693                mBvHierarchy = new BvHierarchy(mMaxDepth, mBuildMethod); 
     694                mBvHierarchy->build(static_cast<BvHierarchySceneNode *>(mSceneRoot)); 
    695695                mBvHierarchy->setEnhancedVis(mEnhancedVisiblity); 
    696696        } 
     
    713713                 
    714714                //delete mBvHierarchy; 
    715                 //mBvHierarchy = new KdTree(mMaxDepth); 
    716                 //mBvHierarchy->build(static_cast<KdTreeSceneNode *>(mSceneRoot)); 
    717         } 
    718  
    719 } 
    720  
    721 void KdTreeSceneManager::_updateSceneGraph(Camera* cam) 
     715                //mBvHierarchy = new BvHierarchy(mMaxDepth); 
     716                //mBvHierarchy->build(static_cast<BvHierarchySceneNode *>(mSceneRoot)); 
     717        } 
     718 
     719} 
     720 
     721void BvHierarchySceneManager::_updateSceneGraph(Camera* cam) 
    722722{ 
    723723        mVisibilityManager->GetCullingManager()->SetHierarchyInterface(mHierarchyInterface); 
     
    727727} 
    728728 
    729 void KdTreeSceneManager::_findVisibleObjects(Camera *cam, bool onlyShadowCasters) 
    730 { 
    731         if (mRenderMethod == KdTree::KDRM_INTERNAL) 
     729void BvHierarchySceneManager::_findVisibleObjects(Camera *cam, bool onlyShadowCasters) 
     730{ 
     731        if (mRenderMethod == BvHierarchy::BVHRM_INTERNAL) 
    732732        { 
    733733                getRenderQueue()->clear(); 
     
    742742                        { 
    743743                                // determine visibility 
    744                                 mBvHierarchy->queueVisibleObjects(KDCAMPTR_CAST(cam), getRenderQueue(), onlyShadowCasters, mShowBoxes, mVisibleNodes); 
     744                                mBvHierarchy->queueVisibleObjects(BVHCAMPTR_CAST(cam), getRenderQueue(), onlyShadowCasters, mShowBoxes, mVisibleNodes); 
    745745                                // apply view cell pvs 
    746746                                updatePvs(cam); 
     
    767767                                getRenderQueue()->clear(); 
    768768                                if (mBvHierarchy) 
    769                                         mBvHierarchy->queueVisibleObjects(KDCAMPTR_CAST(cam), getRenderQueue(), onlyShadowCasters, mShowBoxes, mVisibleNodes); 
     769                                        mBvHierarchy->queueVisibleObjects(BVHCAMPTR_CAST(cam), getRenderQueue(), onlyShadowCasters, mShowBoxes, mVisibleNodes); 
    770770                        } 
    771771 
     
    781781} 
    782782 
    783 void KdTreeSceneManager::_renderVisibleObjects() 
    784 { 
    785         if (mRenderMethod == KdTree::KDRM_INTERNAL) 
     783void BvHierarchySceneManager::_renderVisibleObjects() 
     784{ 
     785        if (mRenderMethod == BvHierarchy::BVHRM_INTERNAL) 
    786786        { 
    787787                SceneManager::_renderVisibleObjects(); 
     
    884884                        if (mUseDepthPass) 
    885885                        { 
    886                                 KdTree::NodeList::const_iterator it, end = mVisibleNodes.end(); 
     886                                BvHierarchy::NodeList::const_iterator it, end = mVisibleNodes.end(); 
    887887                                for (it = mVisibleNodes.begin(); it != end; it++) 
    888888                                { 
     
    917917 
    918918 
    919 void KdTreeSceneManager::_renderNode(KdTree::NodePtr node, Camera * cam,  
     919void BvHierarchySceneManager::_renderNode(BvHierarchy::NodePtr node, Camera * cam,  
    920920                                                                         bool onlyShadowCasters, int leavePassesInQueue) 
    921921{ 
     
    932932 
    933933//----------------------------------------------------------------------- 
    934 const Pass *KdTreeSceneManager::_setPass(const Pass* pass, bool evenIfSuppressed) 
    935 { 
    936         if (mRenderMethod == KdTree::KDRM_INTERNAL) 
     934const Pass *BvHierarchySceneManager::_setPass(const Pass* pass, bool evenIfSuppressed) 
     935{ 
     936        if (mRenderMethod == BvHierarchy::BVHRM_INTERNAL) 
    937937        { 
    938938                return SceneManager::_setPass(pass); 
     
    10071007} 
    10081008//----------------------------------------------------------------------- 
    1009 void KdTreeSceneManager::renderBasicQueueGroupObjects(RenderQueueGroup* pGroup, 
     1009void BvHierarchySceneManager::renderBasicQueueGroupObjects(RenderQueueGroup* pGroup, 
    10101010                                                                                                          QueuedRenderableCollection::OrganisationMode om) 
    10111011{ 
     
    10281028 
    10291029                // Do transparents (always descending) 
    1030                 if (mRenderMethod == KdTree::KDRM_INTERNAL || !mSkipTransparents) 
     1030                if (mRenderMethod == BvHierarchy::BVHRM_INTERNAL || !mSkipTransparents) 
    10311031                { 
    10321032                        renderObjects(pPriorityGrp->getTransparents(),  
     
    10381038} 
    10391039//----------------------------------------------------------------------- 
    1040 bool KdTreeSceneManager::validatePassForRendering(Pass* pass) 
    1041 { 
    1042         if (mRenderMethod == KdTree::KDRM_INTERNAL) 
     1040bool BvHierarchySceneManager::validatePassForRendering(Pass* pass) 
     1041{ 
     1042        if (mRenderMethod == BvHierarchy::BVHRM_INTERNAL) 
    10431043        { 
    10441044                return SceneManager::validatePassForRendering(pass); 
     
    10591059} 
    10601060//----------------------------------------------------------------------- 
    1061 void KdTreeSceneManager::_renderQueueGroupObjects(RenderQueueGroup* pGroup,  
     1061void BvHierarchySceneManager::_renderQueueGroupObjects(RenderQueueGroup* pGroup,  
    10621062                                                                                                  QueuedRenderableCollection::OrganisationMode om) 
    10631063{ 
    1064         if (mRenderMethod == KdTree::KDRM_INTERNAL || !mIsItemBufferPhase) 
     1064        if (mRenderMethod == BvHierarchy::BVHRM_INTERNAL || !mIsItemBufferPhase) 
    10651065        { 
    10661066                SceneManager::_renderQueueGroupObjects(pGroup, om); 
     
    10811081} 
    10821082//----------------------------------------------------------------------- 
    1083 void KdTreeSceneManager::renderAdditiveStencilShadowedQueueGroupObjects( 
     1083void BvHierarchySceneManager::renderAdditiveStencilShadowedQueueGroupObjects( 
    10841084        RenderQueueGroup* pGroup, QueuedRenderableCollection::OrganisationMode om) 
    10851085{ 
     
    11151115} 
    11161116//----------------------------------------------------------------------- 
    1117 void KdTreeSceneManager::renderModulativeStencilShadowedQueueGroupObjects( 
     1117void BvHierarchySceneManager::renderModulativeStencilShadowedQueueGroupObjects( 
    11181118        RenderQueueGroup* pGroup, QueuedRenderableCollection::OrganisationMode om) 
    11191119{ 
     
    11401140} 
    11411141//----------------------------------------------------------------------- 
    1142 void KdTreeSceneManager::InitDepthPass() 
     1142void BvHierarchySceneManager::InitDepthPass() 
    11431143{ 
    11441144        MaterialPtr depthMat = MaterialManager::getSingleton().getByName("Visibility/DepthPass"); 
     
    11611161} 
    11621162//----------------------------------------------------------------------- 
    1163 void KdTreeSceneManager::InitItemBufferPass() 
     1163void BvHierarchySceneManager::InitItemBufferPass() 
    11641164{ 
    11651165        MaterialPtr itemBufferMat = MaterialManager::getSingleton(). 
     
    11851185} 
    11861186//----------------------------------------------------------------------- 
    1187 void KdTreeSceneManager::PrepareVisualization(Camera *cam) 
     1187void BvHierarchySceneManager::PrepareVisualization(Camera *cam) 
    11881188{ 
    11891189        // add player camera for visualization purpose 
     
    12061206                unsigned long frameid = 0; 
    12071207 
    1208                 if (mRenderMethod == KdTree::KDRM_INTERNAL) 
     1208                if (mRenderMethod == BvHierarchy::BVHRM_INTERNAL) 
    12091209                        frameid = Root::getSingleton().getCurrentFrameNumber(); 
    12101210                else 
    12111211                        frameid = mHierarchyInterface->GetFrameId(); 
    12121212 
    1213                 for (KdTree::NodeList::iterator it = mVisibleNodes.begin(); it != mVisibleNodes.end(); ++it) 
     1213                for (BvHierarchy::NodeList::iterator it = mVisibleNodes.begin(); it != mVisibleNodes.end(); ++it) 
    12141214                { 
    12151215                        if (mRenderNodesForViz && (*it)->isLeaf()) 
    12161216                        { 
    12171217                                WireBoundingBox * wirebox = (*it)->getWireBoundingBox(); 
    1218                                 wirebox->setMaterial("KdTree/BoxViz"); 
     1218                                wirebox->setMaterial("BvHierarchy/BoxViz"); 
    12191219                                getRenderQueue()->addRenderable(wirebox); 
    12201220                        } 
     
    12281228} 
    12291229//----------------------------------------------------------------------- 
    1230 void KdTreeSceneManager::InitVisibilityCulling(Camera *cam) 
     1230void BvHierarchySceneManager::InitVisibilityCulling(Camera *cam) 
    12311231{ 
    12321232        // reset culling manager stats 
     
    13001300 
    13011301//------------------------------------------------------------------------- 
    1302 void KdTreeSceneManager::SetObjectsVisible(const bool visible) 
     1302void BvHierarchySceneManager::SetObjectsVisible(const bool visible) 
    13031303{ 
    13041304        GtpVisibilityPreprocessor::ObjectContainer::iterator it, it_end = mObjects.end(); 
     
    13131313} 
    13141314//----------------------------------------------------------------------- 
    1315 bool KdTreeSceneManager::LoadViewCells(const String &filename) 
     1315bool BvHierarchySceneManager::LoadViewCells(const String &filename) 
    13161316{ 
    13171317        // objects are set to invisible initially 
    13181318        SetObjectsVisible(false); 
    13191319 
    1320         const string bboxesFilename = mVisibilityManager->GetVisibilityEnvironment()->getViewCellsFileName(); 
     1320        const string bboxesFilename =  
     1321                mVisibilityManager->GetVisibilityEnvironment()->getViewCellsFileName(); 
    13211322 
    13221323        // converter between view cell ids and Ogre entites  
    13231324        GtpVisibilityPreprocessor::IndexedBoundingBoxContainer iboxes; 
     1325#if 0 
    13241326        OgreBoundingBoxConverter bconverter(this); 
    13251327 
     
    13291331 
    13301332        return (mViewCellsManager != NULL); 
     1333#endif 
    13311334} 
    13321335//------------------------------------------------------------------------- 
    1333 void KdTreeSceneManager::applyViewCellPvs(GtpVisibilityPreprocessor::ViewCell *vc,  
     1336void BvHierarchySceneManager::applyViewCellPvs(GtpVisibilityPreprocessor::ViewCell *vc,  
    13341337                                                                                                        const bool load) 
    13351338{       // NOTE: should not happen, rather apply view cell representing unbounded space then 
     
    13561359} 
    13571360//------------------------------------------------------------------------- 
    1358 void KdTreeSceneManager::updatePvs(Camera *cam) 
     1361void BvHierarchySceneManager::updatePvs(Camera *cam) 
    13591362{ 
    13601363        if (!(mViewCellsLoaded && mUseViewCells)) 
     
    14061409 
    14071410//----------------------------------------------------------------------- 
    1408 void KdTreeSceneManager::WriteLog() 
     1411void BvHierarchySceneManager::WriteLog() 
    14091412{ 
    14101413        std::stringstream d; 
     
    14271430 
    14281431/************************************************************************/ 
    1429 /* Factory for KdTreeSceneManager                                       */ 
     1432/* Factory for BvHierarchySceneManager                                       */ 
    14301433/************************************************************************/ 
    14311434//----------------------------------------------------------------------- 
    14321435//----------------------------------------------------------------------- 
    1433 const String BvHierarchySceneManagerFactory::FACTORY_TYPE_NAME = "KdTreeSceneManager"; 
     1436const String BvHierarchySceneManagerFactory::FACTORY_TYPE_NAME = "BvHierarchySceneManager"; 
    14341437//----------------------------------------------------------------------- 
    14351438void BvHierarchySceneManagerFactory::initMetaData(void) const 
     
    14441447        const String& instanceName) 
    14451448{ 
    1446         return new KdTreeSceneManager(instanceName, visManager); 
     1449        return new BvHierarchySceneManager(instanceName, visManager); 
    14471450} 
    14481451//----------------------------------------------------------------------- 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreBvHierarchySceneNode.cpp

    r1319 r1320  
    1818        // TRIVIA: this function is _not_ called for nodes which did not change since the last frame 
    1919        // only exception: the root node ... it's aabb should be null however, so we don't care 
    20         void KdTreeSceneNode::_updateBounds(void) 
     20        void BvHierarchySceneNode::_updateBounds(void) 
    2121        { 
    2222                // Reset bounds first 
     
    3333                if (!mWorldAABB.isNull()) 
    3434                { 
    35                         static_cast<KdTreeSceneManager *>(mCreator)->_updateNode(this); 
     35                        static_cast<BvHierarchySceneManager *>(mCreator)->_updateNode(this); 
    3636                } 
    3737        } 
    3838 
    39         void KdTreeSceneNode::computeScene(PlaneEventList& events, AxisAlignedBox& aabb, int& nObjects, bool includeChildren) 
     39        void BvHierarchySceneNode::computeScene(BvhPlaneEventList& events, AxisAlignedBox& aabb, int& nObjects, bool includeChildren) 
    4040        { 
    4141                /**************************************************************************************/ 
    4242                /* HACK: do not include camera node, FUCKS UP world AABB really BAD, dunno why        */ 
    43                 /* TODO: find a generic solution where MOVABLE nodes are NOT INSERTED into the KDTREE */ 
     43                /* TODO: find a generic solution where MOVABLE nodes are NOT INSERTED into the BvHierarchy */ 
    4444                /**************************************************************************************/ 
    4545                //if (mName == "PlayerCamNode") 
     
    5555                        if (getExcludedMovables().find(i->second->getMovableType()) == getExcludedMovables().end()) 
    5656                        { 
    57                                 //LogManager::getSingleton().getLog(KDTREE_LOGNAME)->logMessage("Adding movable type " + i->second->getMovableType() + " to KdTree"); 
     57                                //LogManager::getSingleton().getLog(BvHierarchy_LOGNAME)->logMessage("Adding movable type " + i->second->getMovableType() + " to BvHierarchy"); 
    5858                                // Merge world bounds of each object 
    5959                                mWorldAABB.merge(i->second->getWorldBoundingBox(true)); 
     
    6161                } 
    6262 
    63                 // create information for KdTree/SAH 
     63                // create information for BvHierarchy/SAH 
    6464                if (!mWorldAABB.isNull()) 
    6565                { 
     
    7171 
    7272                        // generate events 
    73                         PlaneEvent::Dimension axes[] =  
    74                                 {PlaneEvent::PED_X, PlaneEvent::PED_Y, PlaneEvent::PED_Z}; 
     73                        BvhPlaneEvent::Dimension axes[] =  
     74                                {BvhPlaneEvent::PED_X, BvhPlaneEvent::PED_Y, BvhPlaneEvent::PED_Z}; 
    7575                        Vector3 min = mWorldAABB.getMinimum(); 
    7676                        Vector3 max = mWorldAABB.getMaximum(); 
     
    8080                                if (min[i] == max[i]) 
    8181                                {        
    82                                         //e = new PlaneEvent(this, min, axes[i], PlaneEvent::PET_ON); 
     82                                        //e = new BvhPlaneEvent(this, min, axes[i], BvhPlaneEvent::PET_ON); 
    8383                                        //sceneinfo.events.push_back(*e); 
    84                                         events.push_back(PlaneEvent(this, min, axes[i], PlaneEvent::PET_ON)); 
     84                                        events.push_back(BvhPlaneEvent(this, min, axes[i], BvhPlaneEvent::PET_ON)); 
    8585                                } 
    8686                                else 
    8787                                { 
    88                                         //e = new PlaneEvent(this, min, axes[i], PlaneEvent::PET_START); 
     88                                        //e = new BvhPlaneEvent(this, min, axes[i], BvhPlaneEvent::PET_START); 
    8989                                        //sceneinfo.events.push_back(*e); 
    90                                         //e = new PlaneEvent(this, max, axes[i], PlaneEvent::PET_END); 
     90                                        //e = new BvhPlaneEvent(this, max, axes[i], BvhPlaneEvent::PET_END); 
    9191                                        //sceneinfo.events.push_back(*e); 
    92                                         events.push_back(PlaneEvent(this, min, axes[i], PlaneEvent::PET_START)); 
    93                                         events.push_back(PlaneEvent(this, max, axes[i], PlaneEvent::PET_END)); 
     92                                        events.push_back(BvhPlaneEvent(this, min, axes[i], BvhPlaneEvent::PET_START)); 
     93                                        events.push_back(BvhPlaneEvent(this, max, axes[i], BvhPlaneEvent::PET_END)); 
    9494                                } 
    9595                        } 
     
    102102                        for (child = mChildren.begin(); child != mChildren.end(); ++child) 
    103103                        { 
    104                                 KdTreeSceneNode* sceneChild = static_cast<KdTreeSceneNode*>(child->second); 
     104                                BvHierarchySceneNode* sceneChild = static_cast<BvHierarchySceneNode*>(child->second); 
    105105                                sceneChild->computeScene(events, aabb, nObjects); 
    106106                        } 
     
    108108        } 
    109109 
    110         //void KdTreeSceneNode::_findVisibleObjects(Camera* cam, RenderQueue* queue,  
     110        //void BvHierarchySceneNode::_findVisibleObjects(Camera* cam, RenderQueue* queue,  
    111111        //      bool includeChildren, bool displayNodes, bool onlyShadowCasters) 
    112         void KdTreeSceneNode::queueObjects(Camera* cam, RenderQueue* queue, bool onlyShadowCasters) 
     112        void BvHierarchySceneNode::queueObjects(Camera* cam, RenderQueue* queue, bool onlyShadowCasters) 
    113113        { 
    114114                //SceneNode::_findVisibleObjects(cam, queue, includeChildren, displayNodes, onlyShadowCasters); 
     
    136136        } 
    137137 
    138         void KdTreeSceneNode::getGeometryList(GtpVisibility::GeometryVector *geometryList) 
     138        void BvHierarchySceneNode::getGeometryList(GtpVisibility::GeometryVector *geometryList) 
    139139        { 
    140140                SceneNode::ObjectIterator objIt = getAttachedObjectIterator(); 
     
    154154 
    155155        // recalculate the world aabb 
    156         AxisAlignedBox KdTreeSceneNode::getBoundingBox(void) const 
     156        AxisAlignedBox BvHierarchySceneNode::getBoundingBox(void) const 
    157157        { 
    158158                return mWorldAABB; 
    159159        } 
    160160 
    161         KdTreeSceneNode::StringSet& KdTreeSceneNode::getExcludedMovables(void) 
     161        BvHierarchySceneNode::StringSet& BvHierarchySceneNode::getExcludedMovables(void) 
    162162        { 
    163163                static StringSet sExluded; 
     
    175175 
    176176        // DEBUG 
    177         String KdTreeSceneNode::dumpToString(void) 
     177        String BvHierarchySceneNode::dumpToString(void) 
    178178        { 
    179179                String objects; 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTree.cpp

    r1312 r1320  
    2525{ 
    2626 
    27 enum Intersection 
     27enum BvhIntersection 
    2828{ 
    2929        OUTSIDE=0, 
     
    3232}; 
    3333 
    34 Intersection intersect( const Ray &one, const AxisAlignedBox &two ) 
     34static BvhIntersection intersect( const Ray &one, const AxisAlignedBox &two ) 
    3535{ 
    3636        // Null box? 
     
    9999/** Checks how the second box intersects with the first. 
    100100*/ 
    101 Intersection intersect( const PlaneBoundedVolume &one, const AxisAlignedBox &two ) 
     101static BvhIntersection intersect( const PlaneBoundedVolume &one, const AxisAlignedBox &two ) 
    102102{ 
    103103        // Null box? 
     
    146146/** Checks how the second box intersects with the first. 
    147147*/ 
    148 Intersection intersect( const AxisAlignedBox &one, const AxisAlignedBox &two ) 
     148static BvhIntersection intersect( const AxisAlignedBox &one, const AxisAlignedBox &two ) 
    149149{ 
    150150        // Null box? 
     
    180180/** Checks how the box intersects with the sphere. 
    181181*/ 
    182 Intersection intersect( const Sphere &one, const AxisAlignedBox &two ) 
     182static BvhIntersection intersect( const Sphere &one, const AxisAlignedBox &two ) 
    183183{ 
    184184        // Null box? 
     
    15121512        if ( !full ) 
    15131513        { 
    1514                 Intersection isect = intersect(box, node->_getWorldAABB()); 
     1514                BvhIntersection isect = intersect(box, node->_getWorldAABB()); 
    15151515 
    15161516                if ( isect == OUTSIDE ) 
     
    15361536                                else 
    15371537                                { 
    1538                                         Intersection nsect = intersect(box, sn->_getWorldAABB()); 
     1538                                        BvhIntersection nsect = intersect(box, sn->_getWorldAABB()); 
    15391539 
    15401540                                        if ( nsect != OUTSIDE ) 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreVisibilitySceneManagerDll.cpp

    r1273 r1320  
    3030#include <OgreLogManager.h> 
    3131 
     32#include "OgreBvHierarchySceneManager.h" 
    3233#include "VisibilityManager.h" 
    3334#include "VisibilityEnvironment.h" 
     
    3940 
    4041 
    41 OcclusionCullingSceneManagerFactory *occlusionCullingPlugin; 
     42OcclusionCullingSceneManagerFactory *occlusionCullingFactory; 
    4243KdTreeSceneManagerFactory *kdTreeFactory; 
    4344KdTerrainSceneManagerFactory *kdTerrainFactory; 
     45BvHierarchySceneManagerFactory *bvHierarchyFactory; 
    4446 
    4547//----------------------------------------------------------------------- 
     
    5153 
    5254        // Create new scene manager 
    53         occlusionCullingPlugin = new OcclusionCullingSceneManagerFactory(visManager); 
     55        occlusionCullingFactory = new OcclusionCullingSceneManagerFactory(visManager); 
    5456        kdTreeFactory = new KdTreeSceneManagerFactory(visManager); 
    5557        kdTerrainFactory = new KdTerrainSceneManagerFactory(visManager); 
     58        bvHierarchyFactory = new BvHierarchySceneManagerFactory(visManager); 
     59 
    5660        // Construct listener manager singleton 
    5761        new TerrainPageSourceListenerManager(); 
     
    5963 
    6064        // Register 
    61         Root::getSingleton().addSceneManagerFactory(occlusionCullingPlugin); 
     65        Root::getSingleton().addSceneManagerFactory(occlusionCullingFactory); 
    6266        Root::getSingleton().addSceneManagerFactory(kdTreeFactory); 
    6367        Root::getSingleton().addSceneManagerFactory(kdTerrainFactory); 
     68        Root::getSingleton().addSceneManagerFactory(bvHierarchyFactory); 
    6469} 
    6570//----------------------------------------------------------------------- 
    6671extern "C" void __declspec(dllexport) dllShutdownPlugin() 
    6772{ 
    68         Root::getSingleton().removeSceneManagerFactory(occlusionCullingPlugin); 
     73        Root::getSingleton().removeSceneManagerFactory(occlusionCullingFactory); 
    6974        Root::getSingleton().removeSceneManagerFactory(kdTreeFactory); 
    7075        Root::getSingleton().removeSceneManagerFactory(kdTerrainFactory); 
     76        Root::getSingleton().removeSceneManagerFactory(bvHierarchyFactory); 
     77 
    7178        // destroy listener manager 
    7279        delete TerrainPageSourceListenerManager::getSingletonPtr(); 
     
    7885        //delete heightmapTerrainPageSource; 
    7986        // BUG: crashes on delete!!!! FIX this  
    80         delete occlusionCullingPlugin; 
     87        delete occlusionCullingFactory; 
    8188        delete kdTreeFactory; 
    8289        delete kdTerrainFactory; 
     90        delete bvHierarchyFactory; 
    8391 
    8492        delete visManager; 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/Plugin_VisibilitySceneManager.vcproj

    r1296 r1320  
    352352        <Files> 
    353353                <Filter 
    354                         Name="SceneManager_Plugins" 
     354                        Name="OcclusionCullingSceneManager" 
    355355                        Filter=""> 
    356356                        <Filter 
     
    382382                </Filter> 
    383383                <Filter 
    384                         Name="VisibilitySceneManager" 
     384                        Name="BvHierarchySceneManager" 
    385385                        Filter=""> 
    386386                        <Filter 
    387                                 Name="Header Files" 
    388                                 Filter="h;hpp;hxx;hm;inl;inc"> 
    389                                 <File 
    390                                         RelativePath="..\include\OgreBoundingBoxConverter.h"> 
    391                                 </File> 
    392                                 <File 
    393                                         RelativePath="..\include\OgreMeshInstance.h"> 
    394                                 </File> 
    395                                 <File 
    396                                         RelativePath="..\include\OgreOcclusionQueriesQueryManager.h"> 
    397                                 </File> 
    398                                 <File 
    399                                         RelativePath="..\include\OgrePlatformHierarchyInterface.h"> 
    400                                 </File> 
    401                                 <File 
    402                                         RelativePath="..\include\OgrePlatformOcclusionQuery.h"> 
    403                                 </File> 
    404                                 <File 
    405                                         RelativePath="..\include\OgrePlatformQueryManager.h"> 
    406                                 </File> 
    407                                 <File 
    408                                         RelativePath="..\include\OgreSceneContentGenerator.h"> 
    409                                 </File> 
    410                                 <File 
    411                                         RelativePath="..\include\OgreSceneNodeHierarchyInterface.h"> 
    412                                 </File> 
    413                                 <File 
    414                                         RelativePath="..\include\OgreSolidBoundingBox.h"> 
    415                                 </File> 
    416                                 <File 
    417                                         RelativePath="..\include\OgreSolidHalfBoundingBox.h"> 
    418                                 </File> 
    419                                 <File 
    420                                         RelativePath="..\include\OgreTypeConverter.h"> 
    421                                 </File> 
    422                                 <File 
    423                                         RelativePath="..\include\OgreVisibilityOptionsManager.h"> 
    424                                 </File> 
    425                         </Filter> 
    426                         <Filter 
    427                                 Name="Source Files" 
    428                                 Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm"> 
    429                                 <File 
    430                                         RelativePath="..\src\OgreBoundingBoxConverter.cpp"> 
    431                                 </File> 
    432                                 <File 
    433                                         RelativePath="..\src\OgreMeshInstance.cpp"> 
    434                                 </File> 
    435                                 <File 
    436                                         RelativePath="..\src\OgreOcclusionQueriesQueryManager.cpp"> 
    437                                 </File> 
    438                                 <File 
    439                                         RelativePath="..\src\OgrePlatformHierarchyInterface.cpp"> 
    440                                 </File> 
    441                                 <File 
    442                                         RelativePath="..\src\OgrePlatformOcclusionQuery.cpp"> 
    443                                 </File> 
    444                                 <File 
    445                                         RelativePath="..\src\OgrePlatformQueryManager.cpp"> 
    446                                 </File> 
    447                                 <File 
    448                                         RelativePath="..\src\OgreSceneContentGenerator.cpp"> 
    449                                 </File> 
    450                                 <File 
    451                                         RelativePath="..\src\OgreSceneNodeHierarchyInterface.cpp"> 
    452                                 </File> 
    453                                 <File 
    454                                         RelativePath="..\src\OgreSolidBoundingBox.cpp"> 
    455                                 </File> 
    456                                 <File 
    457                                         RelativePath="..\src\OgreSolidHalfBoundingBox.cpp"> 
    458                                 </File> 
    459                                 <File 
    460                                         RelativePath="..\src\OgreTypeConverter.cpp"> 
    461                                 </File> 
    462                                 <File 
    463                                         RelativePath="..\src\OgreVisibilityOptionsManager.cpp"> 
    464                                 </File> 
    465                                 <File 
    466                                         RelativePath="..\src\OgreVisibilitySceneManagerDll.cpp"> 
     387                                Name="src" 
     388                                Filter=""> 
     389                                <File 
     390                                        RelativePath=".\OgreBvHierarchy.cpp"> 
     391                                </File> 
     392                                <File 
     393                                        RelativePath=".\OgreBvHierarchyCamera.cpp"> 
     394                                </File> 
     395                                <File 
     396                                        RelativePath=".\OgreBvHierarchyInterface.cpp"> 
     397                                </File> 
     398                                <File 
     399                                        RelativePath=".\OgreBvHierarchySceneManager.cpp"> 
     400                                </File> 
     401                                <File 
     402                                        RelativePath=".\OgreBvHierarchySceneNode.cpp"> 
     403                                </File> 
     404                        </Filter> 
     405                        <Filter 
     406                                Name="include" 
     407                                Filter=""> 
     408                                <File 
     409                                        RelativePath="..\include\OgreBvHierarchy.h"> 
     410                                </File> 
     411                                <File 
     412                                        RelativePath="..\include\OgreBvHierarchyCamera.h"> 
     413                                </File> 
     414                                <File 
     415                                        RelativePath="..\include\OgreBvHierarchyInterface.h"> 
     416                                </File> 
     417                                <File 
     418                                        RelativePath="..\include\OgreBvHierarchySceneManager.h"> 
     419                                </File> 
     420                                <File 
     421                                        RelativePath="..\include\OgreBvHierarchySceneNode.h"> 
     422                                </File> 
     423                                <File 
     424                                        RelativePath="..\include\OgreBvhRenderable.h"> 
    467425                                </File> 
    468426                        </Filter> 
     
    563521                                </File> 
    564522                        </Filter> 
     523                </Filter> 
     524                <Filter 
     525                        Name="Header Files" 
     526                        Filter="h;hpp;hxx;hm;inl;inc"> 
     527                        <File 
     528                                RelativePath="..\include\OgreBoundingBoxConverter.h"> 
     529                        </File> 
     530                        <File 
     531                                RelativePath="..\include\OgreMeshInstance.h"> 
     532                        </File> 
     533                        <File 
     534                                RelativePath="..\include\OgreOcclusionQueriesQueryManager.h"> 
     535                        </File> 
     536                        <File 
     537                                RelativePath="..\include\OgrePlatformHierarchyInterface.h"> 
     538                        </File> 
     539                        <File 
     540                                RelativePath="..\include\OgrePlatformOcclusionQuery.h"> 
     541                        </File> 
     542                        <File 
     543                                RelativePath="..\include\OgrePlatformQueryManager.h"> 
     544                        </File> 
     545                        <File 
     546                                RelativePath="..\include\OgreSceneContentGenerator.h"> 
     547                        </File> 
     548                        <File 
     549                                RelativePath="..\include\OgreSceneNodeHierarchyInterface.h"> 
     550                        </File> 
     551                        <File 
     552                                RelativePath="..\include\OgreSolidBoundingBox.h"> 
     553                        </File> 
     554                        <File 
     555                                RelativePath="..\include\OgreSolidHalfBoundingBox.h"> 
     556                        </File> 
     557                        <File 
     558                                RelativePath="..\include\OgreTypeConverter.h"> 
     559                        </File> 
     560                        <File 
     561                                RelativePath="..\include\OgreVisibilityOptionsManager.h"> 
     562                        </File> 
     563                </Filter> 
     564                <Filter 
     565                        Name="Source Files" 
     566                        Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm"> 
     567                        <File 
     568                                RelativePath="..\src\OgreBoundingBoxConverter.cpp"> 
     569                        </File> 
     570                        <File 
     571                                RelativePath="..\src\OgreMeshInstance.cpp"> 
     572                        </File> 
     573                        <File 
     574                                RelativePath="..\src\OgreOcclusionQueriesQueryManager.cpp"> 
     575                        </File> 
     576                        <File 
     577                                RelativePath="..\src\OgrePlatformHierarchyInterface.cpp"> 
     578                        </File> 
     579                        <File 
     580                                RelativePath="..\src\OgrePlatformOcclusionQuery.cpp"> 
     581                        </File> 
     582                        <File 
     583                                RelativePath="..\src\OgrePlatformQueryManager.cpp"> 
     584                        </File> 
     585                        <File 
     586                                RelativePath="..\src\OgreSceneContentGenerator.cpp"> 
     587                        </File> 
     588                        <File 
     589                                RelativePath="..\src\OgreSceneNodeHierarchyInterface.cpp"> 
     590                        </File> 
     591                        <File 
     592                                RelativePath="..\src\OgreSolidBoundingBox.cpp"> 
     593                        </File> 
     594                        <File 
     595                                RelativePath="..\src\OgreSolidHalfBoundingBox.cpp"> 
     596                        </File> 
     597                        <File 
     598                                RelativePath="..\src\OgreTypeConverter.cpp"> 
     599                        </File> 
     600                        <File 
     601                                RelativePath="..\src\OgreVisibilityOptionsManager.cpp"> 
     602                        </File> 
     603                        <File 
     604                                RelativePath="..\src\OgreVisibilitySceneManagerDll.cpp"> 
     605                        </File> 
    565606                </Filter> 
    566607                <File 
Note: See TracChangeset for help on using the changeset viewer.