Ignore:
Timestamp:
08/08/06 18:25:06 (18 years ago)
Author:
szydlowski
Message:

visualization in test app working, some issues to resolve

Location:
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTree.h

    r1183 r1187  
    207207                        virtual bool isEmpty() const = 0; 
    208208                        virtual bool hasGeometry() const = 0; 
     209 
     210                        virtual void queueVisibleObjects(unsigned long currentFrame,  
     211                                Camera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes) = 0; 
    209212                         
    210213                        // consider using typesafe callback functions 
     
    288291                        int mLevel; 
    289292                        AxisAlignedBox mAABB; 
    290                 protected: 
    291                         WireBoundingBox * mWBB; 
    292293 
    293294                        // for the CHC hierarchy interface 
    294295                        /** the real extent of the node. */ 
    295296                        AxisAlignedBox mWorldAABB; 
     297                protected: 
     298                        WireBoundingBox * mWBB; 
    296299                         
    297300                        unsigned int mLastRendered; 
     
    327330                        virtual bool hasGeometry() const { return false; }; 
    328331 
     332                        virtual void queueVisibleObjects(unsigned long currentFrame,  
     333                                Camera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes) 
     334                        { 
     335                                if (showBoxes) 
     336                                { 
     337                                        WireBoundingBox * wbb = getWireBoundingBox(); 
     338                                        if (wbb) 
     339                                                queue->addRenderable(wbb); 
     340                                } 
     341                        } 
     342 
    329343                        // branches do not posses geometry => just merge child aabbs 
    330344                        virtual void _updateBounds(bool recurse = true) 
     
    334348 
    335349                                if (mLeft) 
    336                                         mWorldAABB.merge(mLeft->_getWorldAABB()); 
     350                                        mWorldAABB.merge(mLeft->mWorldAABB); 
    337351                                if (mRight) 
    338                                         mWorldAABB.merge(mRight->_getWorldAABB()); 
     352                                        mWorldAABB.merge(mRight->mWorldAABB); 
    339353 
    340354                                // update parent recursively 
     
    367381                        virtual bool hasGeometry() const { return !mKdRenderables.empty(); }; 
    368382 
     383                        virtual void queueVisibleObjects(unsigned long currentFrame,  
     384                                Camera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes); 
     385 
    369386                        // update the world aabb based on the contained geometry 
    370387                        virtual void _updateBounds(bool recurse = true); 
     
    430447                typedef KdTree::Branch * BranchPtr; 
    431448                typedef KdTree::Leaf * LeafPtr; 
     449 
     450                typedef std::list<NodePtr> NodeList; 
    432451                typedef std::set<LeafPtr> LeafSet; 
    433452 
     
    484503 
    485504                // test visibility of objects and add to render queue 
    486                 void queueVisibleObjects(Camera* cam, RenderQueue* queue, bool onlyShadowCasters,  
    487                         RenderMethod renderMethod, bool showBoxes = false); 
     505                void queueVisibleObjects(Camera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes = false); 
    488506 
    489507                // self-explanatory ... 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTreeSceneManager.h

    r1185 r1187  
    1616#include "OgreKdTree.h" 
    1717 
    18 #define KDTREE_MAX_DEPTH 20 
     18#define KDTREE_MAX_DEPTH 12 
    1919 
    2020namespace Ogre 
     
    134134        /** Render a list of scenenodes 
    135135        */ 
    136         virtual void _renderNodes(const KdRenderableList& nodelist, Camera * cam, 
     136        //virtual void _renderNodes(const KdRenderableList& nodelist, Camera * cam, 
     137        //      bool onlyShadowCasters, int leavePassesInQueue); 
     138        virtual void _renderNode(KdTree::NodePtr node, Camera * cam, 
    137139                bool onlyShadowCasters, int leavePassesInQueue); 
    138140 
     
    227229 
    228230        // remember visited scene nodes for viz 
    229         KdRenderableList mVisibleNodes; 
     231        //KdRenderableList mVisibleNodes; 
     232        KdTree::NodeList mVisibleNodes; 
    230233 
    231234        /************************************************************************/ 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTreeSceneNode.h

    r1173 r1187  
    4343                virtual AxisAlignedBox getBoundingBox() const; 
    4444 
     45                // custom render op, show bounding box instead of axes 
     46                //virtual void getRenderOperation(RenderOperation& op); 
     47 
    4548                //virtual void _findVisibleObjects(Camera* cam, RenderQueue* queue,  
    4649                //      bool includeChildren = true, bool displayNodes = false, bool onlyShadowCasters = false); 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTree.cpp

    r1183 r1187  
    2222 
    2323#define KDTREE_LOGNAME "KdTreeBuild.log" 
     24#define PLT_SIZE 101 
    2425 
    2526namespace Ogre 
     
    2829        Real PlaneEvent::KI = 1.0; 
    2930 
     31        //---------------------------------------------------------------------------- 
     32        // determine if this event is left or right of the reference event 
    3033        void PlaneEvent::classify(const PlaneEvent& e, PlaneEvent::Side side) 
    3134        { 
     
    5760        } 
    5861 
     62        //---------------------------------------------------------------------------- 
     63        // clip this event to an aabb (move it so that the plane on one of the box planes) 
    5964        PlaneEvent PlaneEvent::clip(AxisAlignedBox& box, PlaneEvent::Dimension dim) 
    6065        { 
     
    6873        } 
    6974 
     75        //---------------------------------------------------------------------------- 
     76        // the surface area heuristic to determine the cost of splitting the parent aabb 
     77        // along the plane represented by this event 
    7078        void PlaneEvent::SAH(const AxisAlignedBox& parent, int nLeft, int nPlane, int nRight, SplitInfo& split) 
    7179        { 
    72  
    73 #ifdef KDTREE_DEBUG_OFF 
    7480                Real mu = splitBox(parent, split.bleft, split.bright); 
    75                 Real sav = surfaceArea(parent); // optimize?? called several times for the same box 
    76                 Real savl = surfaceArea(split.bleft); 
    77                 Real savr = surfaceArea(split.bright); 
    78                 Real pl = savl / sav; 
    79                 Real pr = savr / sav; 
    80                 Real costl = splitCost(pl, pr, nLeft + nPlane, nRight, mu); 
    81                 Real costr = splitCost(pl, pr, nLeft, nPlane + nRight, mu); 
    82  
    83                 Log * log = LogManager::getSingleton().getLog(KDTREE_LOGNAME); 
    84                 log->logMessage("SAH: SA-parent=" + StringConverter::toString(sav) +  
    85                         "\n\tSA-left=" + StringConverter::toString(savl) +  
    86                         " SA-right=" + StringConverter::toString(savr) +  
    87                         "\n\tp-left=" + StringConverter::toString(pl) +  
    88                         " p-right=" + StringConverter::toString(pr) + 
    89                         "\n\tmu=" + StringConverter::toString(mu) + 
    90                         "\n\tcost-left=" + StringConverter::toString(costl) + 
    91                         " cost-right=" + StringConverter::toString(costr)); 
    92 #else 
    93                 Real mu = splitBox(parent, split.bleft, split.bright); 
    94                 Real sav = surfaceArea(parent); // optimize?? called several times for the same box 
     81                Real sav = surfaceArea(parent); 
    9582                Real pl = surfaceArea(split.bleft) / sav; 
    9683                Real pr = surfaceArea(split.bright) / sav; 
     
    9885                Real costr = splitCost(pl, pr, nLeft, nPlane + nRight, mu); 
    9986 
    100 #endif 
    10187                if (costl < costr) 
    10288                { 
     
    117103        } 
    118104 
     105        //---------------------------------------------------------------------------- 
     106        // split the parent aabb with the plane in this event 
    119107        Real PlaneEvent::splitBox(const AxisAlignedBox& parent, AxisAlignedBox& left, AxisAlignedBox& right) 
    120108        { 
    121109                Vector3 bmin = parent.getMinimum(); 
    122110                Vector3 bmax = parent.getMaximum(); 
    123 #ifdef KDTREE_DEBUG_OFF 
    124                 if(bmin[mDimension] > mPosition[mDimension] || bmax[mDimension] < mPosition[mDimension]) 
    125                 { 
    126                         Log * log = LogManager::getSingleton().getLog(KDTREE_LOGNAME); 
    127                         log->logMessage("SPLITBOX SNAFU in event " + print() + 
    128                                 "\n\tmin=" + StringConverter::toString(bmin[mDimension]) +  
    129                                 " split=" + StringConverter::toString(mPosition[mDimension]) +  
    130                                 " max=" + StringConverter::toString(bmax[mDimension])); 
    131                 } 
    132 #endif 
    133111                // calculate the penalty for spliting the box that way 
    134                 Real mu = lookupPenalty((mPosition[mDimension] - bmin[mDimension]) / (bmax[mDimension] - bmin[mDimension])); 
     112                Real mu = lookupPenalty( 
     113                        (mPosition[mDimension] - bmin[mDimension]) /  
     114                        (bmax[mDimension] - bmin[mDimension])); 
    135115                // set corners which are the same as parent AABB 
    136116                left.setMinimum(bmin); 
     
    146126        } 
    147127 
     128        //---------------------------------------------------------------------------- 
     129        // compute surface area of a box ... DUH! 
     130        Real PlaneEvent::surfaceArea(const AxisAlignedBox& box) 
     131        { 
     132                Vector3 sides = box.getMaximum() - box.getMinimum(); 
     133                return  2 * sides.x * sides.y + 
     134                        2 * sides.y * sides.z + 
     135                        2 * sides.z * sides.x; 
     136        } 
     137 
     138        //---------------------------------------------------------------------------- 
     139        // lookup the penalty for placing the splitting plane near to the edge of the AABB 
     140        // 0.0 <= p <= 1.0, p = 0.5 means the plane divides the aabb in half 
     141        Real PlaneEvent::lookupPenalty(Real p) 
     142        { 
     143                // precomputed table of {x^6 + 1|0 <= x <= 1} 
     144                static Real mPenaltyLookupTable[PLT_SIZE]; 
     145                static bool init_done = false; 
     146 
     147                if (!init_done) 
     148                { 
     149                        Real step = 1.0  / (PLT_SIZE - 1); 
     150                        Real x = 0.0;  
     151                        //LogManager::getSingleton().logMessage("### Calculating Lookup Table ###"); 
     152                        for (int i = 0; i < PLT_SIZE; i++) 
     153                        { 
     154                                mPenaltyLookupTable[i] = Math::Pow(x, 6) + 1.0; 
     155                                x += step; 
     156                                //LogManager::getSingleton().logMessage("### mPenaltyLookupTable[" + StringConverter::toString(i,3) + "]=" + StringConverter::toString(mPenaltyLookupTable[i])); 
     157                        } 
     158                        init_done = true; 
     159                        //LogManager::getSingleton().logMessage("### Lookup Table Calculated ###"); 
     160                } 
     161 
     162                // normalize p to [0,1] 
     163                Real x = Math::Abs(p * 2 - 1); 
     164                // compute index 
     165                int i = Math::IFloor(x * (PLT_SIZE - 1)); 
     166 
     167                return mPenaltyLookupTable[i]; 
     168        } 
     169 
     170        //---------------------------------------------------------------------------- 
     171        // compute cost of the split, reward splitting of empty space (lambda, const), 
     172        // penalize splitting off 'thin' slices (mu, const) 
    148173        Real PlaneEvent::splitCost(Real pLeft, Real pRight, int nLeft, int nRight) 
    149174        { 
    150                 //assert(pLeft <= 1.0 && pRight <= 1.0); 
    151  
    152175                // reward splitting off chunks of empty space 
    153176                Real lambda = 1.0; 
     
    157180                } 
    158181 
    159                 // penalize splitting off small chunks 
     182                // penalize splitting off small chunks (thin slices) 
    160183                Real mu = 1.0; 
    161184                if (pLeft < 0.1 || pRight < 0.1 || pLeft > 0.9 || pRight > 0.9) 
     
    164187                } 
    165188                return lambda * mu * (KT + (KI * (pLeft*nLeft + pRight*nRight))); 
    166                  
    167                 //return lambda * (KT + (KI * (pLeft*nLeft + pRight*nRight))); 
    168         } 
    169  
     189        } 
     190 
     191        //---------------------------------------------------------------------------- 
     192        // compute cost of the split, reward splitting of empty space (lambda, const), 
     193        // penalize splitting off 'thin' slices (mu, parameter) 
    170194        Real PlaneEvent::splitCost(Real pLeft, Real pRight, int nLeft, int nRight, Real mu) 
    171195        { 
    172                 //assert(pLeft <= 1.0 && pRight <= 1.0); 
    173  
    174196                // reward splitting off chunks of empty space 
    175197                Real lambda = 1.0; 
     
    182204        } 
    183205 
    184         Real PlaneEvent::surfaceArea(const AxisAlignedBox& box) 
    185         { 
    186                 Vector3 sides = box.getMaximum() - box.getMinimum(); 
    187 #ifdef KDTREE_DEBUG_OFF 
    188                 if(sides.x < 0 || sides.y < 0 || sides.z < 0) 
    189                 { 
    190                         Log * log = LogManager::getSingleton().getLog(KDTREE_LOGNAME); 
    191                         log->logMessage("AABB SNAFU: x=" + StringConverter::toString(sides.x) +  
    192                                 " y=" + StringConverter::toString(sides.y) + " z=" + StringConverter::toString(sides.z) + 
    193                                 " BOX=" + StringConverter::toString(box.getMinimum()) + "," + StringConverter::toString(box.getMaximum())); 
    194                 } 
    195 #endif 
    196                 return  2 * sides.x * sides.y + 
    197                                 2 * sides.y * sides.z + 
    198                                 2 * sides.z * sides.x; 
    199         } 
    200  
    201         void PlaneEvent::pqSAH(Real globalSA, Real parentSA, int nLeft, int nPlane, int nRight, AxisAlignedBox& parentBox, SplitInfo& split) 
     206        //---------------------------------------------------------------------------- 
     207        // surface area heuristic modified for the priority queue method of building 
     208        // the probabilities (p, pl, pr) are relative to the global (all enclosing) aabb 
     209        void PlaneEvent::pqSAH(Real globalSA, Real parentSA, int nLeft, int nPlane, int nRight,  
     210                AxisAlignedBox& parentBox, SplitInfo& split) 
    202211        { 
    203212                Real mu = splitBox(parentBox, split.bleft, split.bright); 
     
    226235        } 
    227236 
     237        //---------------------------------------------------------------------------- 
     238        // compute split cost without any penalties 
    228239        Real PlaneEvent::pqSplitCost(Real pParent, Real pLeft, Real pRight, int nLeft, int nRight, Real mu) 
    229240        { 
    230                 // reward splitting off chunks of empty space 
    231                 //Real lambda = 1.0; 
    232                 //if (nLeft == 0 || nRight == 0) 
    233                 //{ 
    234                 //      lambda = 0.8; 
    235                 //} 
    236  
    237                 return /* lambda * mu * */ (pParent*KT + (KI * (pLeft*nLeft + pRight*nRight))); 
    238         } 
    239  
    240 #define PLT_SIZE 101 
    241  
    242         // lookup the penalty for placing the splitting plane near to the edge of the AABB 
    243         // 0.0 <= p <= 1.0, p = 0.5 means the plane divides the aabb in half 
    244         Real PlaneEvent::lookupPenalty(Real p) 
    245         { 
    246                 // precomputed table of {x^6 + 1|0 <= x <= 1} 
    247                 static Real mPenaltyLookupTable[PLT_SIZE]; 
    248                 static bool init_done = false; 
    249  
    250                 if (!init_done) 
    251                 { 
    252                         Real step = 1.0  / (PLT_SIZE - 1); 
    253                         Real x = 0.0;  
    254                         //LogManager::getSingleton().logMessage("### Calculating Lookup Table ###"); 
    255                         for (int i = 0; i < PLT_SIZE; i++) 
    256                         { 
    257                                 mPenaltyLookupTable[i] = Math::Pow(x, 6) + 1.0; 
    258                                 x += step; 
    259                                 //LogManager::getSingleton().logMessage("### mPenaltyLookupTable[" + StringConverter::toString(i,3) + "]=" + StringConverter::toString(mPenaltyLookupTable[i])); 
    260                         } 
    261                         init_done = true; 
    262                         //LogManager::getSingleton().logMessage("### Lookup Table Calculated ###"); 
    263                 } 
    264  
    265                 // normalize p to [0,1] 
    266                 Real x = Math::Abs(p * 2 - 1); 
    267                 int i = Math::IFloor(x * (PLT_SIZE - 1)); 
    268  
    269                 return mPenaltyLookupTable[i]; 
    270         } 
    271  
     241                return pParent * KT + (KI * (pLeft * nLeft + pRight * nRight)); 
     242        } 
     243 
     244        //---------------------------------------------------------------------------- 
    272245        // DEBUG 
    273246        String PlaneEvent::print() 
     
    290263        }; 
    291264 
     265        //---------------------------------------------------------------------------- 
    292266        String SplitInfo::print() 
    293267        { 
     
    308282        }; 
    309283 
     284        //---------------------------------------------------------------------------- 
    310285        String KdTree::SplitCandidate::print() 
    311286        {                
     
    361336        } 
    362337 
     338        /************************************************************************/ 
     339        /* KdTree insert/delete functions                                       */ 
     340        /************************************************************************/ 
     341 
    363342        void KdTree::remove(KdRenderable * rend) 
    364343        { 
     
    640619        } 
    641620 
     621        /************************************************************************/ 
     622        /* KdTree build functions                                               */ 
     623        /************************************************************************/ 
     624 
    642625        void KdTree::build(KdRenderable * sceneRoot) 
    643626        { 
    644                 // DEBUG 
    645                 //LogManager *lm = LogManager::getSingletonPtr(); 
    646627                Timer *timer = Root::getSingleton().getTimer(); 
    647628                unsigned long t1, t2, t3, t4; 
    648                 //AxisAlignedBox aabb; 
    649629 
    650630                mStats.clear(); 
     
    662642 
    663643                mStats.mNumSceneNodes = nObjects; 
    664                 // <DEBUG> 
    665                 //lm->logMessage("# of perfect splits " + StringConverter::toString(events.size())); 
    666                 //PlaneEventList::iterator it; 
    667                 //for (it = events.begin(); it != events.end(); it++) 
    668                 //{ 
    669                 //      lm->logMessage(it->print()); 
    670                 //} 
    671                 // </DEBUG> 
    672644 
    673645                assert(! aabb.isNull() && "Teh stubid worldAABB iz NULL ... waht now?"); 
     
    702674                mBuildLog->logMessage("Time for tree build: " + StringConverter::toString(t4 - t3) + "µs"); 
    703675                mBuildLog->logMessage("Total time: " + StringConverter::toString(t4 - t1) + "µs"); 
     676                mBuildLog->logMessage("Tree Depth: " + StringConverter::toString(mMaxDepth)); 
    704677                mBuildLog->logMessage("Number of Objects: " + StringConverter::toString(mStats.mNumSceneNodes)); 
    705678                mBuildLog->logMessage("Number of Leaves: " + StringConverter::toString(mStats.mNumLeaves)); 
     
    723696                        it++; 
    724697                } 
     698 
    725699                events.sort(); 
     700                 
    726701                // HACK 
    727702                if (aabb.isNull()) 
    728703                { 
    729                         //LogManager::getSingleton().logMessage("AABB empty, using node AABB."); 
    730704                        aabb = nodeaabb; 
    731705                } 
    732  
    733                 // this must never happen!! 
    734                 //AxisAlignedBox isect = aabb.intersection(nodeaabb); 
    735                 //if (isect.getMinimum() != nodeaabb.getMinimum() || isect.getMaximum() != nodeaabb.getMaximum()) 
    736                 //{ 
    737                 //      LogManager::getSingleton().logMessage("#+#+#+#+#+ SceneNodes outside of node AABB."); 
    738                 //} 
    739706 
    740707                if (mBuildMethod == KDBM_RECURSIVE) 
     
    760727                } 
    761728 
    762 #ifdef KDTREE_DEBUG_OFF 
    763                 mBuildLog->logMessage("events.size()=" + StringConverter::toString(events.size())); 
    764 #endif 
    765 #ifdef KDTREE_DEBUG_OFF 
    766                 PlaneEventList::iterator xit, xbegin, xend; 
    767                 xbegin = events.begin(); 
    768                 xend = events.end(); 
    769                 xit = xbegin; 
    770                 while (xit != xend) 
    771                 { 
    772                         mBuildLog->logMessage(xit->print()); 
    773                         xit++; 
    774                 } 
    775 #endif 
    776  
    777729                /************************************************/ 
    778730                /**************** BEGIN FINDPLANE ***************/ 
    779731                /************************************************/ 
    780732                // find optimal split plane and split node accordingly 
     733 
     734                // initialize 
    781735                const int dim = 3; 
    782736                int pStart, pOn, pEnd; 
     
    789743                SplitInfo split, best; 
    790744                best.cost = Math::POS_INFINITY; 
    791  
    792745 
    793746                PlaneEventList::iterator begin = events.begin(); 
     
    821774                } 
    822775 
    823 #ifdef KDTREE_DEBUG_OFF 
    824                 Real lvol = best.bleft.volume(); 
    825                 Real rvol = best.bright.volume(); 
    826  
    827                 if (lvol == 0 || rvol == 0) 
    828                 { 
    829                         mBuildLog->logMessage("WARNING INVALID SPLIT!!!"); 
    830                         String side; 
    831                         if (best.side == PlaneEvent::PES_LEFT) 
    832                                 side = "left"; 
    833                         else 
    834                                 side = "right"; 
    835  
    836                         mBuildLog->logMessage("Splitting node on level " + StringConverter::toString(level) +  
    837                                 "\n\tcost=" + StringConverter::toString(best.cost) + " term=" + StringConverter::toString(PlaneEvent::KI*nObjects) + 
    838                                 " side=" + side + 
    839                                 "\n\tVolume: left=" + StringConverter::toString(lvol) + 
    840                                 " right=" + StringConverter::toString(rvol)); 
    841                 } 
    842 #endif 
    843776                /************************************************/ 
    844777                /**************** BEGIN TERMINATE ***************/ 
     
    858791                                { 
    859792                                        leaf->insert(rend); 
    860                                         //LogManager::getSingleton().logMessage("++ Adding SceneNode: " + (static_cast<KdTreeSceneNode *>(rend))->getName()); 
    861793                                } 
    862794                                it++; 
     
    873805                /**************** BEGIN CLASSIFY ****************/ 
    874806                /************************************************/ 
     807                // split the event list in left and right sub-lists 
    875808                else 
    876809                { 
     
    896829                        while (it != end) 
    897830                        { 
    898                                 // right-only nodes get moved 
     831                                // right-only nodes go in right list 
    899832                                if (it->getRenderable()->getSide() == PlaneEvent::PES_RIGHT) 
    900833                                { 
     
    904837                                                nRightS++; 
    905838                                        } 
    906  
    907839                                        eventsRight.push_back(*it); 
    908840                                } 
    909                                 // both-only nodes get copied 
    910                                 // must clip AABBs to child AABB !!! 
    911                                 else if (it->getRenderable()->getSide() == PlaneEvent::PES_BOTH) 
    912                                 { 
    913                                         if (!it->getRenderable()->isClassified()) 
    914                                         { 
    915                                                 it->getRenderable()->setClassified(true); 
    916                                                 nBothS++; 
    917                                         } 
    918  
    919                                         //eventsRight.push_back(*it); 
    920                                         //eventsLeft.push_back(*it); 
    921                                         eventsRight.push_back(it->clip(best.bright, best.event.getDimension())); 
    922                                         eventsLeft.push_back(it->clip(best.bleft, best.event.getDimension())); 
    923                                 } 
    924                                 else 
     841                                // left-only nodes go in left list 
     842                                else if (it->getRenderable()->getSide() == PlaneEvent::PES_LEFT) 
    925843                                { 
    926844                                        if (!it->getRenderable()->isClassified()) 
     
    931849                                        eventsLeft.push_back(*it); 
    932850                                } 
     851                                // remaining nodes go in both lists, bust must be clipped to prevent 
     852                                // events from lying outside the new nodes aabb 
     853                                else 
     854                                { 
     855                                        if (!it->getRenderable()->isClassified()) 
     856                                        { 
     857                                                it->getRenderable()->setClassified(true); 
     858                                                nBothS++; 
     859                                        } 
     860                                        eventsRight.push_back(it->clip(best.bright, best.event.getDimension())); 
     861                                        eventsLeft.push_back(it->clip(best.bleft, best.event.getDimension())); 
     862                                } 
    933863                                it++; 
    934864                        } 
    935865 
    936 #ifdef KDTREE_DEBUG_OFF 
    937                         mBuildLog->logMessage("Splitting on " + best.event.print()); 
    938                         mBuildLog->logMessage("eventsLeft.size()=" + StringConverter::toString(eventsLeft.size())); 
    939                         mBuildLog->logMessage("eventsRight.size()=" + StringConverter::toString(eventsRight.size())); 
    940 #endif 
     866                        // create a new branch node and continue recursion 
    941867                        KdTree::Branch * branch = new KdTree::Branch(level, aabb, parent, best.event.getSplitPlane(), best.side); 
    942868 
     
    956882                        // update bounding box 
    957883                        branch->_updateBounds(false); 
    958  
    959  
    960                         //assert(branch->mRight || branch->mLeft); 
    961884 
    962885                        return branch; 
     
    979902                // inital split candidate 
    980903                SplitInfo * best = pqFindPlane(e, nObjects, aabb, globalSA); 
    981                 SplitCandidate splitcandidate(e, nObjects, aabb, parent, globalTreeCost, globalTreeCost - best->cost, best, PlaneEvent::PES_BOTH); 
     904                SplitCandidate splitcandidate(e, nObjects, aabb, parent, globalTreeCost,  
     905                        globalTreeCost - best->cost, best, PlaneEvent::PES_BOTH); 
    982906                pqueue.push(splitcandidate); 
    983  
    984 #ifdef KDTREE_DEBUG_OFF 
    985                 //mBuildLog->logMessage("best.pevent=" + best->event.print() +  
    986                 //      " events.size()=" + StringConverter::toString(events.size())); 
    987                 mBuildLog->logMessage("New split on " + splitcandidate.print()); 
    988 #endif 
    989907 
    990908 
     
    1001919                                level = sc.parent->mLevel + 1; 
    1002920                        } 
    1003  
    1004 #ifdef KDTREE_DEBUG_OFF 
    1005                         //mBuildLog->logMessage("Splitting on " + sc.best->event.print() + 
    1006                         //      " sc.events.size()=" + StringConverter::toString(sc.events->size())); 
    1007                         mBuildLog->logMessage("Splitting on " + sc.print()); 
    1008 #endif 
    1009921 
    1010922                        /************************************************/ 
     
    1012924                        /************************************************/ 
    1013925                        // check terminating condition 
    1014                         //if (best.cost > PlaneEvent::KI*sc.nObjects || level >= mMaxDepth) 
    1015926                        if (sc.decrease < 0.0 || level >= mMaxDepth) 
    1016927                        { 
     
    1028939                                        { 
    1029940                                                leaf->insert(rend); 
    1030                                                 //LogManager::getSingleton().logMessage("++ Adding SceneNode: " + (static_cast<KdTreeSceneNode *>(rend))->getName()); 
    1031941                                        } 
    1032942                                        it++; 
     
    1053963                                while (it != end) 
    1054964                                { 
    1055 #ifdef KDTREE_DEBUG_OFF 
    1056                                         mBuildLog->logMessage(it->print()); 
    1057 #endif 
    1058965                                        it->getRenderable()->setSide(PlaneEvent::PES_BOTH); 
    1059966                                        it->getRenderable()->setClassified(false); 
    1060967                                        it++; 
    1061968                                } 
     969 
    1062970                                // now classify all renderables. do they belong to the left child, the right child or both? 
    1063 #ifdef KDTREE_DEBUG_OFF 
    1064                                 bool bla = true; 
    1065971                                it = begin; 
    1066972                                while (it != end) 
    1067973                                { 
    1068974                                        it->classify(sc.best->event, sc.best->side); 
    1069                                         if (*it == sc.best->event) 
    1070                                         { 
    1071                                                 mBuildLog->logMessage("YEEPEE classified against valid event"); 
    1072                                                 bla = false; 
    1073                                         } 
    1074975                                        it++; 
    1075976                                } 
    1076                                 if (bla) 
    1077                                         mBuildLog->logMessage("FUCKIT! Invalid classification"); 
    1078 #else 
    1079                                 it = begin; 
    1080                                 while (it != end) 
    1081                                 { 
    1082                                         it->classify(sc.best->event, sc.best->side); 
    1083                                         it++; 
    1084                                 } 
    1085 #endif 
    1086  
    1087977 
    1088978                                // divide the event lists 
     
    1091981                                while (it != end) 
    1092982                                { 
     983                                        // right-only events go in the right list 
    1093984                                        if (it->getRenderable()->getSide() == PlaneEvent::PES_RIGHT) 
    1094985                                        { 
     
    1101992                                                eventsRight->push_back(*it); 
    1102993                                        } 
    1103                                         else if (it->getRenderable()->getSide() == PlaneEvent::PES_BOTH) 
    1104                                         { 
    1105                                                 if (!it->getRenderable()->isClassified()) 
    1106                                                 { 
    1107                                                         it->getRenderable()->setClassified(true); 
    1108                                                         nBothS++; 
    1109                                                 } 
    1110  
    1111                                                 eventsRight->push_back(it->clip(sc.best->bright, sc.best->event.getDimension())); 
    1112                                                 eventsLeft->push_back(it->clip(sc.best->bleft, sc.best->event.getDimension())); 
    1113                                         } 
    1114                                         else 
     994                                        // left-only events go in the left list 
     995                                        else if (it->getRenderable()->getSide() == PlaneEvent::PES_LEFT) 
    1115996                                        { 
    1116997                                                if (!it->getRenderable()->isClassified()) 
     
    11211002                                                eventsLeft->push_back(*it); 
    11221003                                        } 
     1004                                        // the rest goes in both lists after being clipped 
     1005                                        else 
     1006                                        { 
     1007                                                if (!it->getRenderable()->isClassified()) 
     1008                                                { 
     1009                                                        it->getRenderable()->setClassified(true); 
     1010                                                        nBothS++; 
     1011                                                } 
     1012 
     1013                                                eventsRight->push_back(it->clip(sc.best->bright, sc.best->event.getDimension())); 
     1014                                                eventsLeft->push_back(it->clip(sc.best->bleft, sc.best->event.getDimension())); 
     1015                                        } 
    11231016                                        it++; 
    11241017                                } 
    11251018 
    1126 #ifdef KDTREE_DEBUG_OFF 
    1127                                 mBuildLog->logMessage("#### Splitting node on level " + StringConverter::toString(level)); 
    1128                                 Plane * vplane; 
    1129                                 int count = 0; 
    1130                                 PlaneEventList::iterator vit, vbegin, vend; 
    1131                                 vbegin = eventsLeft->begin(); 
    1132                                 vend = eventsLeft->end(); 
    1133                                 vit = vbegin; 
    1134                                 while (vit != vend) 
    1135                                 { 
    1136                                         vplane = vit->getSplitPlane(); 
    1137                                         if (!sc.best.bleft.intersects(*vplane)) 
    1138                                         { 
    1139                                                 mBuildLog->logMessage("Invalid event classification! Plane: " +  
    1140                                                 StringConverter::toString(vplane->normal) + ", " + StringConverter::toString(-vplane->d) + 
    1141                                                 " Box: |" + StringConverter::toString(sc.best.bleft.getMinimum()) + "|" + 
    1142                                                 StringConverter::toString(sc.best.bleft.getMaximum()) + "|"); 
    1143                                                 count++; 
    1144                                         } 
    1145                                         OGRE_DELETE(vplane); 
    1146                                         vit++; 
    1147                                 } 
    1148                                 mBuildLog->logMessage("@@@@ Number of invalid events on the left: " +  
    1149                                         StringConverter::toString(count) + 
    1150                                         " Number of events on both sides: " + StringConverter::toString(nBothS)); 
    1151                                 count = 0; 
    1152                                 vbegin = eventsRight->begin(); 
    1153                                 vend = eventsRight->end(); 
    1154                                 vit = vbegin; 
    1155                                 while (vit != vend) 
    1156                                 { 
    1157                                         vplane = vit->getSplitPlane(); 
    1158                                         if (!sc.best.bright.intersects(*vplane)) 
    1159                                         { 
    1160                                                 mBuildLog->logMessage("Invalid event classification! Plane: " +  
    1161                                                 StringConverter::toString(vplane->normal) + ", " + StringConverter::toString(-vplane->d) + 
    1162                                                 " Box: |" + StringConverter::toString(sc.best.bright.getMinimum()) + "|" + 
    1163                                                 StringConverter::toString(sc.best.bright.getMaximum()) + "|"); 
    1164                                                 count++; 
    1165                                         } 
    1166                                         OGRE_DELETE(vplane); 
    1167                                         vit++; 
    1168                                 } 
    1169                                 mBuildLog->logMessage("@@@@ Number of invalid events on the right: " +  
    1170                                         StringConverter::toString(count) + 
    1171                                         " Number of events on both sides: " + StringConverter::toString(nBothS)); 
    1172 #endif 
    1173  
     1019                                // create a new branch node 
    11741020                                KdTree::Branch * branch =  
    11751021                                        new KdTree::Branch(level, sc.aabb, sc.parent, sc.best->event.getSplitPlane(), sc.best->side); 
    11761022 
    1177                                 //Real decr = (PlaneEvent::surfaceArea(sc.aabb)/globalSA*PlaneEvent::KI*sc.nObjects) - sc.best.cost; 
    11781023                                globalTreeCost -= sc.decrease; 
    11791024 
    1180                                 //mBuildLog->logMessage("Splitting, cost is now " + StringConverter::toString(globalTreeCost) + "€"); 
    1181  
    1182                                 // now create the child nodes and continue recursion 
     1025 
     1026                                // now for each potential child node, compute the split plane and the cost decrease 
     1027                                // and place them in the queue 
    11831028                                if (eventsLeft->size() > 0) 
    11841029                                { 
     
    11881033                                                branch, old, old - best->cost, best, PlaneEvent::PES_LEFT); 
    11891034                                        pqueue.push(scleft); 
    1190  
    1191 #ifdef KDTREE_DEBUG_OFF 
    1192                                         //mBuildLog->logMessage("best.pevent: " + best->event.print() +  
    1193                                         //      " eventsLeft.size()=" + StringConverter::toString(eventsLeft->size())); 
    1194                                         mBuildLog->logMessage("New split on " + scleft.print()); 
    1195                                         Plane * plane = best->event.getSplitPlane(); 
    1196                                         if (!sc.best->bleft.intersects(*plane)) 
    1197                                         { 
    1198                                                 mBuildLog->logMessage("Best plane outside parent box on level " +  
    1199                                                         StringConverter::toString(level)); 
    1200                                         } 
    1201                                         OGRE_DELETE(plane); 
    1202 #endif 
    12031035                                } 
    12041036                                // cleanup 
     
    12071039                                        delete eventsLeft; 
    12081040                                } 
     1041 
    12091042                                if (eventsRight->size() > 0) 
    12101043                                { 
     
    12141047                                                branch, old, old - best->cost, best, PlaneEvent::PES_RIGHT); 
    12151048                                        pqueue.push(scright); 
    1216  
    1217 #ifdef KDTREE_DEBUG_OFF 
    1218                                         //mBuildLog->logMessage("best.pevent: " + best->event.print() +  
    1219                                         //      " eventsRight.size()=" + StringConverter::toString(eventsRight->size())); 
    1220                                         mBuildLog->logMessage("New split on " + scright.print()); 
    1221                                         Plane * plane = best->event.getSplitPlane(); 
    1222                                         if (!sc.best->bright.intersects(*plane)) 
    1223                                         { 
    1224                                                 mBuildLog->logMessage("Best plane outside parent box on level " +  
    1225                                                         StringConverter::toString(level)); 
    1226                                         } 
    1227                                         OGRE_DELETE(plane); 
    1228 #endif 
    12291049                                } 
    12301050                                // cleanup 
     
    12731093        } 
    12741094 
     1095        //------------------------------------------------------------------------- 
    12751096        SplitInfo * KdTree::pqFindPlane(PlaneEventList * events, int nObjects, AxisAlignedBox& aabb, Real globalSA) 
    12761097        { 
     
    13201141        } 
    13211142 
    1322         void KdTree::queueVisibleObjects(Camera* cam, RenderQueue* queue, bool onlyShadowCasters,  
    1323                 KdTree::RenderMethod renderMethod, bool showBoxes) 
    1324         { 
    1325                 // for now only recurse or stack render methods 
     1143        /************************************************************************/ 
     1144        /* KdTree rendering functions                                           */ 
     1145        /************************************************************************/ 
     1146 
     1147        //------------------------------------------------------------------------- 
     1148        void KdTree::queueVisibleObjects(Camera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes) 
     1149        { 
    13261150                if (mKdRoot) 
    1327                 { 
    13281151                        recQueueVisibleObjects(mKdRoot, Root::getSingleton().getCurrentFrameNumber(), 
    13291152                                cam, queue, onlyShadowCasters, showBoxes); 
    1330                 } 
    1331         } 
    1332  
     1153        } 
     1154 
     1155        //------------------------------------------------------------------------- 
    13331156        void KdTree::recQueueVisibleObjects(KdTree::Node * node, unsigned long currentFrame,  
    13341157                Camera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes) 
     
    13831206        } 
    13841207 
     1208        /************************************************************************/ 
     1209        /* KdTree debug & helper functions                                      */ 
     1210        /************************************************************************/ 
     1211 
     1212        //------------------------------------------------------------------------- 
    13851213        void KdTree::dump() 
    13861214        { 
     
    13901218        } 
    13911219 
     1220        //------------------------------------------------------------------------- 
    13921221        void KdTree::dump(KdTree::Node * node) 
    13931222        { 
     
    14111240                        { 
    14121241                                scenenode = dynamic_cast<KdTreeSceneNode *>(*it); 
    1413                                 log->logMessage(pad + "# Leaf   level " + StringConverter::toString(node->mLevel) +  
     1242                                log->logMessage(pad + "# Leaf   level " +  
     1243                                        StringConverter::toString(node->mLevel) +  
    14141244                                        " SceneNode " + scenenode->getName()); 
    14151245                                log->logMessage(pad + "## Objects: " + scenenode->dumpToString()); 
     
    14221252                        if (branch->mLeft) 
    14231253                        { 
    1424                                 log->logMessage(pad + "# Branch level " + StringConverter::toString(node->mLevel) + " Left Child"); 
     1254                                log->logMessage(pad + "# Branch level " +  
     1255                                        StringConverter::toString(node->mLevel) + " Left Child"); 
    14251256                                dump(branch->mLeft); 
    14261257                        } 
    14271258                        if (branch->mRight) 
    14281259                        { 
    1429                                 log->logMessage(pad + "# Branch level " + StringConverter::toString(node->mLevel) + " Right Child"); 
     1260                                log->logMessage(pad + "# Branch level " +  
     1261                                        StringConverter::toString(node->mLevel) + " Right Child"); 
    14301262                                dump(branch->mRight); 
    14311263                        } 
     
    14331265        } 
    14341266 
     1267        //------------------------------------------------------------------------- 
    14351268        Real KdTree::calcCost() 
    14361269        { 
     
    14411274        } 
    14421275 
     1276        //------------------------------------------------------------------------- 
    14431277        Real KdTree::calcCost(KdTree::Node * node, Real vs) 
    14441278        { 
     
    14491283                { 
    14501284                        KdTree::Leaf * leaf = KDLEAFPTR_CAST(node); 
    1451                         return (PlaneEvent::surfaceArea(node->mAABB)/vs)*PlaneEvent::KI*leaf->mKdRenderables.size(); 
     1285                        return (PlaneEvent::surfaceArea(node->mAABB)/vs) * 
     1286                                PlaneEvent::KI * leaf->mKdRenderables.size(); 
    14521287                } 
    14531288                else 
    14541289                { 
    14551290                        KdTree::Branch * branch = KDBRANCHPTR_CAST(node); 
    1456                         return (PlaneEvent::surfaceArea(node->mAABB)/vs)*PlaneEvent::KT + calcCost(branch->mLeft, vs) + calcCost(branch->mRight, vs); 
    1457                 } 
    1458         } 
    1459  
     1291                        return (PlaneEvent::surfaceArea(node->mAABB)/vs) * PlaneEvent::KT +  
     1292                                calcCost(branch->mLeft, vs) + calcCost(branch->mRight, vs); 
     1293                } 
     1294        } 
     1295 
     1296        /************************************************************************/ 
     1297        /* KdTree::Node/Branch/Leaf functions                                   */ 
     1298        /************************************************************************/ 
     1299 
     1300        //------------------------------------------------------------------------- 
    14601301        KdTree::Leaf::~Leaf() 
    14611302        { 
     
    14721313        } 
    14731314 
     1315        void KdTree::Leaf::queueVisibleObjects(unsigned long currentFrame,  
     1316                Camera* cam, RenderQueue* queue, bool onlyShadowCasters, bool showBoxes) 
     1317        { 
     1318                KdRenderableList::iterator it  = mKdRenderables.begin(); 
     1319                KdRenderableList::iterator end = mKdRenderables.end(); 
     1320                while (it != end) 
     1321                {                        
     1322                        if (!(*it)->isQueued(currentFrame, cam)) 
     1323                        { 
     1324                                (*it)->queueObjects(cam, queue, onlyShadowCasters); 
     1325                        } 
     1326                        it++; 
     1327                } 
     1328 
     1329                if (showBoxes) 
     1330                { 
     1331                        WireBoundingBox * wbb = getWireBoundingBox(); 
     1332                        if (wbb) 
     1333                                queue->addRenderable(wbb); 
     1334                } 
     1335        } 
     1336 
     1337        //------------------------------------------------------------------------- 
    14741338        // update the world aabb based on the contained geometry 
    14751339        void KdTree::Leaf::_updateBounds(bool recurse) 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeHierarchyInterface.cpp

    r1173 r1187  
    5858                KdTreeSceneManager * ksm = static_cast<KdTreeSceneManager *>(mSceneManager); 
    5959 
    60                 // render only if the node is a leaf 
    61                 if (kdnode->isLeaf()) 
    62                 { 
    63                         ksm->_renderNodes(KDLEAFPTR_CAST(node)->mKdRenderables, mCamera,  
    64                                 mOnlyShadowCasters, mLeavePassesInQueue); 
    65                 }        
     60                ksm->_renderNode(kdnode, mCamera, mOnlyShadowCasters, mLeavePassesInQueue); 
    6661 
    6762                mVisibleNodes.push_back(node); 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneManager.cpp

    r1185 r1187  
    6161 
    6262// test 
    63 //String chc = "CHC"; 
    64 //setOption("RenderMethod", &chc); 
     63String chc = "CHC"; 
     64setOption("RenderMethod", &chc); 
    6565} 
    6666 
     
    557557                getRenderQueue()->clear(); 
    558558                if (mKdTree) 
    559                         mKdTree->queueVisibleObjects(cam, getRenderQueue(), onlyShadowCasters, mRenderMethod, mShowBoxes); 
     559                        mKdTree->queueVisibleObjects(cam, getRenderQueue(), onlyShadowCasters, mShowBoxes); 
    560560        } 
    561561        else 
     
    578578                                getRenderQueue()->clear(); 
    579579                                if (mKdTree) 
    580                                         mKdTree->queueVisibleObjects(cam, getRenderQueue(), onlyShadowCasters, mRenderMethod, mShowBoxes); 
     580                                        mKdTree->queueVisibleObjects(cam, getRenderQueue(), onlyShadowCasters, mShowBoxes); 
    581581                        } 
    582582 
     
    697697                        if (mUseDepthPass) 
    698698                        { 
    699                                 KdRenderableList::const_iterator it, it_end = mVisibleNodes.end(); 
    700  
    701                                 //getRenderQueue()->clear(); 
    702                                 for (it = mVisibleNodes.begin(); it != it_end; ++ it) 
     699                                //KdRenderableList::const_iterator it, it_end = mVisibleNodes.end(); 
     700 
     701                                ////getRenderQueue()->clear(); 
     702                                //for (it = mVisibleNodes.begin(); it != it_end; ++ it) 
     703                                //{ 
     704                                //      (*it)->queueObjects(mCameraInProgress, getRenderQueue(), false); 
     705                                //} 
     706                                KdTree::NodeList::const_iterator it, end = mVisibleNodes.end(); 
     707                                for (it = mVisibleNodes.begin(); it != end; it++) 
    703708                                { 
    704                                         (*it)->queueObjects(mCameraInProgress, getRenderQueue(), false); 
     709                                        (*it)->queueVisibleObjects(mHierarchyInterface->GetFrameId(), mCameraInProgress, 
     710                                                getRenderQueue(), false, mShowBoxes); 
    705711                                } 
    706712                        } 
    707 #endif   
     713#endif 
    708714                        //-- now we can render all remaining queue objects 
    709715                        //-- used for depth pass, transparents, overlay 
     
    724730} 
    725731 
    726 void KdTreeSceneManager::_renderNodes(const KdRenderableList& nodelist, Camera * cam,  
    727         bool onlyShadowCasters, int leavePassesInQueue) 
    728 { 
    729 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 
     732//void KdTreeSceneManager::_renderNodes(const KdRenderableList& nodelist, Camera * cam,  
     733//      bool onlyShadowCasters, int leavePassesInQueue) 
     734void KdTreeSceneManager::_renderNode(KdTree::NodePtr node, Camera * cam,  
     735                                                                         bool onlyShadowCasters, int leavePassesInQueue) 
     736{ 
    730737        RenderQueueGroup *currentGroup =  
    731738                getRenderQueue()->getQueueGroup(getRenderQueue()->getDefaultQueueGroup()); 
    732739        currentGroup->clear(leavePassesInQueue); 
    733 #else 
    734         getRenderQueue()->clear(); 
    735 #endif 
    736         KdRenderableList::const_iterator it = nodelist.begin(); 
    737         KdRenderableList::const_iterator end = nodelist.end(); 
    738         while (it != end) 
    739         { 
    740                 if (!(*it)->isQueued(mHierarchyInterface->GetFrameId(), cam)) 
    741                 { 
    742                         mVisibleNodes.push_back(*it); 
    743                         (*it)->queueObjects(cam, getRenderQueue(), onlyShadowCasters); 
    744                 } 
    745                 it++; 
    746         } 
     740 
     741        node->queueVisibleObjects(mHierarchyInterface->GetFrameId(), cam, getRenderQueue(), 
     742                onlyShadowCasters, mShowBoxes); 
     743        mVisibleNodes.push_back(node); 
     744 
     745        //KdRenderableList::const_iterator it = nodelist.begin(); 
     746        //KdRenderableList::const_iterator end = nodelist.end(); 
     747        //while (it != end) 
     748        //{ 
     749        //      if (!(*it)->isQueued(mHierarchyInterface->GetFrameId(), cam)) 
     750        //      { 
     751        //              mVisibleNodes.push_back(*it); 
     752        //              (*it)->queueObjects(cam, getRenderQueue(), onlyShadowCasters); 
     753        //      } 
     754        //      it++; 
     755        //} 
    747756 
    748757        _renderQueueGroupObjects(currentGroup, QueuedRenderableCollection::OM_PASS_GROUP); 
     
    957966                nodeMat->getTechnique(0)->getPass(0)->removeAllTextureUnitStates(); 
    958967 
    959                 for (KdRenderableList::iterator it = mVisibleNodes.begin(); it != mVisibleNodes.end(); ++it) 
     968                for (KdTree::NodeList::iterator it = mVisibleNodes.begin(); it != mVisibleNodes.end(); ++it) 
    960969                { 
    961970                        if (mRenderNodesForViz) 
    962971                        { 
    963                                 KdTreeSceneNode * node = static_cast<KdTreeSceneNode *>(*it); 
    964                                 // render the leaf nodes 
    965                                 if (node->numAttachedObjects() &&  
    966                                         !node->numChildren() &&  
    967                                         (node->getAttachedObject(0)->getMovableType() == "Entity") && 
    968                                         node->getAttachedObject(0)->isVisible()) 
    969                                 { 
    970                                         getRenderQueue()->addRenderable(node); 
    971                                 } 
     972                                //KdTreeSceneNode * node = static_cast<KdTreeSceneNode *>(*it); 
     973                                //// render the leaf nodes 
     974                                //if (node->numAttachedObjects() &&  
     975                                //      !node->numChildren() &&  
     976                                //      (node->getAttachedObject(0)->getMovableType() == "Entity") && 
     977                                //      node->getAttachedObject(0)->isVisible()) 
     978                                //{ 
     979                                //      //getRenderQueue()->addRenderable(node); 
     980                                //      node->_addBoundingBoxToQueue(getRenderQueue()); 
     981                                //} 
     982 
     983                                /*** TODO: fix this ... maybe revert to original state, not quite happy now! ***/ 
    972984 
    973985                                // addbounding boxes instead of node itself 
     
    977989                        if (mRenderNodesContentForViz)  
    978990                        { 
    979                                 (*it)->queueObjects(cam, getRenderQueue(), false); 
     991                                //(*it)->queueObjects(cam, getRenderQueue(), false); 
     992                                (*it)->queueVisibleObjects(mHierarchyInterface->GetFrameId(),  
     993                                        cam, getRenderQueue(), false, mShowBoxes); 
    980994                        } 
    981995                } 
  • GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneNode.cpp

    r1183 r1187  
    108108                        // Tell attached objects about camera position (incase any extra processing they want to do) 
    109109                        iobj->second->_notifyCurrentCamera(cam); 
    110                         if (!onlyShadowCasters || iobj->second->getCastShadows()) 
     110                        if (iobj->second->isVisible() && 
     111                                (!onlyShadowCasters || iobj->second->getCastShadows())) 
    111112                        { 
    112113                                iobj->second->_updateRenderQueue(queue); 
     
    175176        } 
    176177 
     178        //void KdTreeSceneNode::getRenderOperation(RenderOperation& op) 
     179        //{ 
     180        //      if (mWireBoundingBox == NULL)  
     181        //      { 
     182        //              mWireBoundingBox = new WireBoundingBox(); 
     183        //      } 
     184 
     185        //      mWireBoundingBox->setupBoundingBox(mWorldAABB); 
     186        //      mWireBoundingBox->getRenderOperation(op); 
     187        //} 
     188 
    177189        // DEBUG 
    178190        String KdTreeSceneNode::dumpToString() 
Note: See TracChangeset for help on using the changeset viewer.