Ignore:
Timestamp:
09/14/06 18:55:38 (18 years ago)
Author:
mattausch
Message:

debugged global sorting, worked on object-viewspace subdivision

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.cpp

    r1359 r1370  
    1717#include "Beam.h" 
    1818#include "VspTree.h" 
     19#include "HierarchyManager.h" 
    1920 
    2021 
     
    2223 
    2324 
     25#define PROBABILIY_IS_BV_VOLUME 1 
    2426#define USE_FIXEDPOINT_T 0 
    2527 
     
    197199                Randomize(); // initialise random generator for heuristics 
    198200 
     201 
     202        ///////////////////////////////////////////////////////////// 
    199203        //-- termination criteria for autopartition 
    200204        Environment::GetSingleton()->GetIntValue("BvHierarchy.Termination.maxDepth", mTermMaxDepth); 
    201205        Environment::GetSingleton()->GetIntValue("BvHierarchy.Termination.maxLeaves", mTermMaxLeaves); 
    202206        Environment::GetSingleton()->GetIntValue("BvHierarchy.Termination.minObjects", mTermMinObjects); 
     207        Environment::GetSingleton()->GetIntValue("BvHierarchy.Termination.minRays", mTermMinRays); 
    203208        Environment::GetSingleton()->GetFloatValue("BvHierarchy.Termination.minProbability", mTermMinProbability); 
    204209         
    205210        Environment::GetSingleton()->GetIntValue("BvHierarchy.Termination.missTolerance", mTermMissTolerance); 
    206          
     211 
     212 
     213        //////////////////////////////////////////////// 
    207214        //-- max cost ratio for early tree termination 
     215 
    208216        Environment::GetSingleton()->GetFloatValue("BvHierarchy.Termination.maxCostRatio", mTermMaxCostRatio); 
    209  
    210217        Environment::GetSingleton()->GetFloatValue("BvHierarchy.Termination.minGlobalCostRatio", 
    211218                mTermMinGlobalCostRatio); 
     
    213220                mTermGlobalCostMissTolerance); 
    214221 
    215         //-- factors for bsp tree split plane heuristics 
    216  
    217         // if only the driving axis is used for axis aligned split 
     222 
     223        ///////////////////////////////////////// 
     224        //-- factors for subdivision heuristics 
     225 
     226        // if only the driving axis is used for splits 
    218227        Environment::GetSingleton()->GetBoolValue("BvHierarchy.splitUseOnlyDrivingAxis", mOnlyDrivingAxis); 
    219228        Environment::GetSingleton()->GetFloatValue("BvHierarchy.maxStaticMemory", mMaxMemory); 
     
    263272} 
    264273 
     274static int CountRays(const ObjectContainer &objects) 
     275{ 
     276        int nRays = 0; 
     277 
     278        ObjectContainer::const_iterator oit, oit_end = objects.end(); 
     279 
     280        for (oit = objects.begin(); oit != oit_end; ++ oit) 
     281        { 
     282                nRays += (int)(*oit)->mVssRays.size(); 
     283        } 
     284 
     285        return nRays; 
     286} 
    265287 
    266288BvhInterior *BvHierarchy::SubdivideNode(const BvhSubdivisionCandidate &sc, 
     
    268290                                                                                BvhTraversalData &backData) 
    269291{ 
     292        mBvhStats.nodes += 2; // we have two new leaves 
     293 
    270294        const BvhTraversalData &tData = sc.mParentData; 
    271295        BvhLeaf *leaf = tData.mNode; 
    272     mBvhStats.nodes += 2; // we have two new leaves 
     296        AxisAlignedBox3 parentBox = leaf->GetBoundingBox(); 
    273297 
    274298        // add the new nodes to the tree 
    275         BvhInterior *node = new BvhInterior(tData.mBoundingBox, leaf->GetParent()); 
    276          
     299        BvhInterior *node = new BvhInterior(parentBox, leaf->GetParent()); 
     300         
     301 
     302        //////////////////////////////// 
     303        //-- create front and back leaf 
     304 
     305        AxisAlignedBox3 fbox = ComputeBoundingBox(sc.mFrontObjects, &parentBox); 
     306        AxisAlignedBox3 bbox = ComputeBoundingBox(sc.mBackObjects, &parentBox); 
     307 
     308        BvhLeaf *back =  
     309                new BvhLeaf(bbox, node, (int)sc.mBackObjects.size()); 
     310        BvhLeaf *front =  
     311                new BvhLeaf(fbox, node, (int)sc.mFrontObjects.size()); 
     312 
     313        BvhInterior *parent = leaf->GetParent(); 
     314 
     315        // replace a link from node's parent 
     316        if (parent) 
     317        { 
     318                parent->ReplaceChildLink(leaf, node); 
     319                node->SetParent(parent); 
     320        } 
     321        else // no parent => this node is the root 
     322        { 
     323                mRoot = node; 
     324        } 
     325 
     326        // and setup child links 
     327        node->SetupChildLinks(front, back); 
     328 
     329        ++ mBvhStats.splits; 
     330 
    277331 
    278332        /////////////////////////////////////////////////////////////////// 
     
    281335        frontData.mDepth = backData.mDepth = tData.mDepth + 1; 
    282336 
    283         frontData.mBoundingBox = ComputeBoundingBox(sc.mFrontObjects, &tData.mBoundingBox); 
    284         backData.mBoundingBox = ComputeBoundingBox(sc.mBackObjects, &tData.mBoundingBox); 
    285          
    286  
    287         //////////////////////////////// 
    288         //-- create front and back leaf 
    289  
    290         BvhLeaf *back =  
    291                 new BvhLeaf(backData.mBoundingBox, node, (int)sc.mBackObjects.size()); 
    292         BvhLeaf *front =  
    293                 new BvhLeaf(frontData.mBoundingBox, node, (int)sc.mFrontObjects.size()); 
    294  
    295         BvhInterior *parent = leaf->GetParent(); 
    296  
    297         // replace a link from node's parent 
    298         if (parent) 
    299         { 
    300                 parent->ReplaceChildLink(leaf, node); 
    301                 node->SetParent(parent); 
    302         } 
    303         else // no parent => this node is the root 
    304         { 
    305                 mRoot = node; 
    306         } 
    307  
    308         // and setup child links 
    309         node->SetupChildLinks(front, back); 
    310  
    311         ++ mBvhStats.splits; 
    312  
    313         //////////////////////////////////// 
    314         //-- fill traversal data 
    315  
    316337        frontData.mNode = front; 
    317338        backData.mNode = back; 
     
    319340        back->mObjects = sc.mBackObjects; 
    320341        front->mObjects = sc.mFrontObjects; 
     342 
     343        // if the number of rays is too low, no assumptions can be made 
     344        // (=> switch to surface area heuristics?) 
     345        frontData.mNumRays = CountRays(sc.mFrontObjects); 
     346        backData.mNumRays = CountRays(sc.mBackObjects); 
    321347 
    322348        AssociateObjectsWithLeaf(back); 
    323349        AssociateObjectsWithLeaf(front); 
    324350    
     351#if PROBABILIY_IS_BV_VOLUME 
     352        // volume of bvh (= probability that this bvh can be seen) 
     353        frontData.mProbability = fbox.GetVolume(); 
     354        backData.mProbability = bbox.GetVolume(); 
     355#else 
    325356        // compute probability of this node being visible,  
    326357        // i.e., volume of the view cells that can see this node 
    327358        frontData.mProbability = EvalViewCellsVolume(sc.mFrontObjects); 
    328359        backData.mProbability = EvalViewCellsVolume(sc.mBackObjects); 
     360#endif 
    329361 
    330362    // how often was max cost ratio missed in this branch? 
     
    389421                tBackData.mNode->SetSubdivisionCandidate(backCandidate); 
    390422 
    391                 Debug << "leaf: " << tFrontData.mNode << " setting f candidate: "  
    392                           << tFrontData.mNode->GetSubdivisionCandidate() << " type: "  
    393                           << tFrontData.mNode->GetSubdivisionCandidate()->Type() << endl; 
    394  
    395                 Debug << "leaf: " << tBackData.mNode << " setting b candidate: "  
    396                           << tBackData.mNode->GetSubdivisionCandidate() << " type: "  
    397                           << tBackData.mNode->GetSubdivisionCandidate()->Type() << endl; 
    398                  
    399423                tQueue.Push(frontCandidate); 
    400424                tQueue.Push(backCandidate); 
     
    460484        const float renderCostDecr = oldRenderCost - newRenderCost; 
    461485 
    462         Debug << "\nbvh render cost decr: " << renderCostDecr << endl; 
     486        //Debug << "\nbvh render cost decr: " << renderCostDecr << endl; 
    463487        splitCandidate.SetRenderCostDecrease(renderCostDecr); 
    464488 
     
    481505        // matt: TODO 
    482506        return ( 0 
    483                 //|| ((int)data.mNode->mObjects.size() < mTermMinObjects) 
    484                 //|| (data.mProbability <= mTermMinProbability) 
    485                 //|| (data.mDepth >= mTermMaxDepth) 
     507                || ((int)data.mNode->mObjects.size() < mTermMinObjects) 
     508                || (data.mProbability <= mTermMinProbability) 
     509                || (data.mDepth >= mTermMaxDepth) 
     510                || (data.mNumRays <= mTermMinRays) 
    486511                 ); 
    487512} 
     
    493518        return (0 
    494519                || (mBvhStats.Leaves() >= mTermMaxLeaves) 
    495                 //|| (mGlobalCostMisses >= mTermGlobalCostMissTolerance) 
     520                || (mGlobalCostMisses >= mTermGlobalCostMissTolerance) 
    496521                //|| mOutOfMemory  
    497522                ); 
     
    506531        ++ mCreatedLeaves; 
    507532 
     533         
     534        if (data.mProbability <= mTermMinProbability) 
     535        { 
     536                ++ mBvhStats.minProbabilityNodes; 
     537        } 
     538 
     539        //////////////////////////////////////////// 
     540        // depth related stuff 
     541 
     542        if (data.mDepth > mBvhStats.maxDepth) 
     543        { 
     544                mBvhStats.maxDepth = data.mDepth; 
     545        } 
     546 
     547        if (data.mDepth < mBvhStats.minDepth) 
     548        { 
     549                mBvhStats.minDepth = data.mDepth; 
     550        } 
     551 
    508552        if (data.mDepth >= mTermMaxDepth) 
    509553        { 
    510554        ++ mBvhStats.maxDepthNodes; 
    511                 //Debug << "new max depth: " << mVspStats.maxDepthNodes << endl; 
    512         } 
    513  
    514         if (data.mDepth < mTermMaxDepth) 
    515         { 
    516         ++ mBvhStats.minDepthNodes; 
    517         } 
    518  
    519         if (data.mProbability <= mTermMinProbability) 
    520                 ++ mBvhStats.minProbabilityNodes; 
    521          
     555        } 
     556 
    522557        // accumulate depth to compute average depth 
    523558        mBvhStats.accumDepth += data.mDepth; 
    524   
    525         if ((int)(leaf->mObjects.size()) < mTermMinObjects) 
     559 
     560 
     561        //////////////////////////////////////////// 
     562        // objects related stuff 
     563 
     564        // note: this number should always accumulate to the total number of objects 
     565        mBvhStats.objectRefs += (int)leaf->mObjects.size(); 
     566 
     567        if ((int)leaf->mObjects.size() <= mTermMinObjects) 
     568        { 
    526569             ++ mBvhStats.minObjectsNodes; 
    527   
    528         if ((int)(leaf->mObjects.size()) > mBvhStats.maxObjectRefs) 
     570        } 
     571 
     572        if ((int)leaf->mObjects.size() > mBvhStats.maxObjectRefs) 
     573        { 
    529574                mBvhStats.maxObjectRefs = (int)leaf->mObjects.size(); 
     575        } 
     576 
     577        if ((int)leaf->mObjects.size() < mBvhStats.minObjectRefs) 
     578        { 
     579                mBvhStats.minObjectRefs = (int)leaf->mObjects.size(); 
     580        } 
     581 
     582        //////////////////////////////////////////// 
     583        // ray related stuff 
     584 
     585        // note: this number should always accumulate to the total number of rays 
     586        mBvhStats.rayRefs += data.mNumRays; 
     587         
     588        if (data.mNumRays <= mTermMinRays) 
     589        { 
     590             ++ mBvhStats.minRaysNodes; 
     591        } 
     592 
     593        if (data.mNumRays > mBvhStats.maxRayRefs) 
     594        { 
     595                mBvhStats.maxRayRefs = data.mNumRays; 
     596        } 
     597 
     598        if (data.mNumRays < mBvhStats.minRayRefs) 
     599        { 
     600                mBvhStats.minRayRefs = data.mNumRays; 
     601        } 
     602 
     603        cout << "depth: " << data.mDepth << " objects: " << (int)leaf->mObjects.size()  
     604                 << " rays: " << data.mNumRays << " rays / objects "  
     605                 << (float)data.mNumRays / (float)leaf->mObjects.size() << endl; 
    530606} 
    531607 
    532608 
    533609#if 0 
     610 
     611/// compute object boundaries using spatial mid split 
    534612float BvHierarchy::EvalLocalObjectPartition(const BvhTraversalData &tData, 
    535613                                                                                        const int axis, 
     
    553631                // object mailed => belongs to back objects 
    554632                if (objMid < midPoint)  
     633                { 
    555634                        objectsBack.push_back(obj); 
     635                } 
    556636                else 
     637                { 
    557638                        objectsFront.push_back(obj); 
    558         } 
    559  
    560         const float oldRenderCost = tData.mProbability * (float)tData.mNode->mObjects.size(); 
     639                } 
     640        } 
     641 
     642        const float oldProp = EvalViewCellsVolume(tData.mNode->mObjects); 
     643        //const float oldProp = tData.mProbability; 
     644 
     645        const float oldRenderCost = oldProb * (float)tData.mNode->mObjects.size(); 
    561646        const float newRenderCost =  
    562647                EvalRenderCost(tData, objectsFront, objectsBack); 
     
    568653#else 
    569654 
     655/// compute object partition by getting balanced objects on the left and right side 
    570656float BvHierarchy::EvalLocalObjectPartition(const BvhTraversalData &tData, 
    571657                                                                                        const int axis, 
     
    592678 
    593679        const float oldProp = EvalViewCellsVolume(tData.mNode->mObjects); 
    594         //const float oldProp2 = tData.mProbability; 
     680        //const float oldProp = tData.mProbability; 
    595681 
    596682        const float oldRenderCost = oldProp * (float)tData.mNode->mObjects.size(); 
     
    649735 
    650736        vector<float>::const_iterator bit = bordersRight.begin(); 
    651  
     737        cout << "here42" << endl; 
    652738        SortableEntryContainer::const_iterator cit, cit_end = mSubdivisionCandidates->end(); 
    653739        for (cit = mSubdivisionCandidates->begin(); cit != cit_end; ++ cit, ++ bit)  
     
    671757                const float sum = objectsLeft * lbox.SurfaceArea() + objectsRight * rbox.SurfaceArea(); 
    672758       
    673             // cout<<"pos="<<(*ci).value<<"\t q=("<<ql<<","<<qr<<")\t r=("<<rl<<","<<rr<<")"<<endl; 
    674             // cout<<"cost= "<<sum<<endl; 
     759                cout << "pos=" << (*cit).mPos << "\t q=(" << objectsLeft << "," << objectsRight <<")\t r=("  
     760                         << lbox.SurfaceArea() << "," << rbox.SurfaceArea() << ")" << endl; 
     761            cout << "cost= " << sum << endl; 
    675762       
    676763                if (sum < minSum)  
    677764                { 
    678765                        minSum = sum;    
    679                         // objects belongs to left side now 
     766                        // objects belong to left side now 
    680767                        for (; currentPos != (cit + 1); ++ currentPos); 
    681768                } 
    682769        } 
    683770 
     771        //////////////////////////////////////////// 
    684772        //-- assign object to front and back volume 
    685773 
     
    796884        { 
    797885                Intersectable *object = (*cit).mObject; 
    798                  
     886         
    799887                // evaluate change in l and r volume 
    800888                // voll = view cells that see only left node (i.e., left pvs) 
     
    864952{ 
    865953        //-- insert object queries 
    866         ObjectContainer *objects; 
    867  
    868         if (!mUseGlobalSorting) 
    869                 objects = &tData.mNode->mObjects; 
    870         else 
    871                 objects = tData.mSortedObjects[axis]; 
    872          
    873         CreateLocalSubdivisionCandidates(*objects, &mSubdivisionCandidates, mUseGlobalSorting, axis); 
     954        ObjectContainer *objects = mUseGlobalSorting ? tData.mSortedObjects[axis] : &tData.mNode->mObjects; 
     955 
     956        CreateLocalSubdivisionCandidates(*objects, &mSubdivisionCandidates, !mUseGlobalSorting, axis); 
    874957} 
    875958 
     
    9371020        } 
    9381021 
    939         // mail the objects on the left side 
    940         Intersectable::NewMail(); 
    941         // mail view cells on the left side 
     1022        // we will mail view cells switching to the back side 
    9421023        ViewCell::NewMail(); 
    9431024         
     
    10091090        ObjectContainer nFrontObjects[3]; 
    10101091        ObjectContainer nBackObjects[3]; 
    1011  
    10121092        float nCostRatio[3]; 
    10131093 
    1014         // create bounding box of node geometry 
    1015         AxisAlignedBox3 box = tData.mBoundingBox; 
    1016                  
    10171094        int sAxis = 0; 
    10181095        int bestAxis = -1; 
     
    10201097        if (mOnlyDrivingAxis) 
    10211098        { 
     1099                const AxisAlignedBox3 box = tData.mNode->GetBoundingBox(); 
    10221100                sAxis = box.Size().DrivingAxis(); 
    10231101        } 
     
    10321110                        if (mUseCostHeuristics) 
    10331111                        { 
    1034                                 //-- partition objects using heuristics 
    1035                                 nCostRatio[axis] = 
    1036                                         EvalLocalCostHeuristics( 
    1037                                                                                         tData, 
    1038                                                                                         axis, 
    1039                                                                                         nFrontObjects[axis], 
    1040                                                                                         nBackObjects[axis]); 
     1112                                ////////////////////////////////// 
     1113                //-- split objects using heuristics 
     1114                                 
     1115                                if (mHierarchyManager->GetViewSpaceSubdivisionType() ==  
     1116                                        HierarchyManager::KD_BASED_VIEWSPACE_SUBDIV) 
     1117                                { 
     1118                                        //-- heuristics using objects weighted by view cells volume 
     1119                                        nCostRatio[axis] = 
     1120                                                EvalLocalCostHeuristics( 
     1121                                                                                                tData, 
     1122                                                                                                axis, 
     1123                                                                                                nFrontObjects[axis], 
     1124                                                                                                nBackObjects[axis]); 
     1125                                } 
     1126                                else 
     1127                                { 
     1128                                        //-- use surface area heuristic because view cells not constructed yet                           
     1129                                        nCostRatio[axis] = 
     1130                                                EvalLocalCostHeuristics( 
     1131                                                                                                tData, 
     1132                                                                                                axis, 
     1133                                                                                                nFrontObjects[axis], 
     1134                                                                                                nBackObjects[axis]); 
     1135                                } 
    10411136                        } 
    10421137                        else 
    10431138                        { 
     1139                                //-- split objects using some simple criteria 
     1140 
    10441141                                nCostRatio[axis] = 
    10451142                                        EvalLocalObjectPartition( 
     
    10721169 
    10731170 
    1074 void BvHierarchy::AssociateObjectsWithRays(const VssRayContainer &rays) 
    1075 { 
    1076  
     1171int BvHierarchy::AssociateObjectsWithRays(const VssRayContainer &rays) const 
     1172{ 
     1173        int nRays = 0; 
    10771174        VssRayContainer::const_iterator rit, rit_end = rays.end(); 
     1175 
     1176        VssRay::NewMail(); 
    10781177 
    10791178    for (rit = rays.begin(); rit != rays.end(); ++ rit) 
     
    10841183                { 
    10851184                        ray->mTerminationObject->mVssRays.push_back(ray); 
    1086                 } 
    1087  
    1088                 if (0 && ray->mOriginObject) 
     1185                        if (!ray->Mailed()) 
     1186                        { 
     1187                                ray->Mail(); 
     1188                                ++ nRays; 
     1189                        } 
     1190                } 
     1191 
     1192                if (1 && ray->mOriginObject) 
    10891193                { 
    10901194                        ray->mOriginObject->mVssRays.push_back(ray); 
    1091                 } 
    1092         } 
     1195 
     1196                        if (!ray->Mailed()) 
     1197                        { 
     1198                                ray->Mail(); 
     1199                                ++ nRays; 
     1200                        } 
     1201                } 
     1202        } 
     1203 
     1204        return nRays; 
    10931205} 
    10941206 
     
    11371249                                                                  const ObjectContainer &objectsBack) const 
    11381250{ 
    1139         BvhLeaf *leaf = tData.mNode; 
    1140  
    11411251        // probability that view point lies in a view cell which sees this node 
    11421252        const float pFront = EvalViewCellsVolume(objectsFront); 
    11431253        const float pBack = EvalViewCellsVolume(objectsBack); 
    11441254                 
    1145         const int totalObjects = (int)leaf->mObjects.size(); 
    1146         const int nObjectsFront = (int)objectsFront.size(); 
    1147         const int nObjectsBack = (int)objectsBack.size(); 
    1148  
    11491255        //-- pvs rendering heuristics 
    1150         const float newRenderCost = nObjectsFront * pFront + nObjectsBack * pBack; 
     1256        const float newRenderCost = (int)objectsFront.size() * pFront + (int)objectsBack.size() * pBack; 
    11511257 
    11521258#ifdef _DEBUG 
     
    11711277        ObjectContainer::const_iterator oit, oit_end = objects.end(); 
    11721278 
    1173         //-- compute bounding box 
    11741279        for (oit = objects.begin(); oit != oit_end; ++ oit) 
    11751280        { 
    11761281                Intersectable *obj = *oit; 
    11771282 
    1178                 // compute bounding box of view space 
     1283                // grow bounding box to include all objects 
    11791284                box.Include(obj->GetBox()); 
    11801285        } 
     
    14961601        BvhSubdivisionCandidate::sBvHierarchy = this; 
    14971602        mBvhStats.nodes = 1; 
     1603        mGlobalCostMisses = 0; 
    14981604 
    14991605        // compute bounding box from objects 
     
    15021608        BvhLeaf *bvhleaf = dynamic_cast<BvhLeaf *>(mRoot); 
    15031609 
     1610        // multiply termination criterium for comparison, 
     1611        // so it can be set between zero and one and 
     1612        // no division is necessary during traversal 
     1613 
     1614#if PROBABILIY_IS_BV_VOLUME 
    15041615        mTermMinProbability *= mBoundingBox.GetVolume(); 
    1505         mGlobalCostMisses = 0; 
    1506          
     1616        // probability that bounding volume is seen 
     1617        const float prop = GetBoundingBox().GetVolume(); 
     1618#else 
     1619        mTermMinProbability *= mVspTree->GetBoundingBox().GetVolume(); 
     1620        // probability that volume is "seen" from the view cells 
     1621        const float prop = EvalViewCellsVolume(objects); 
     1622#endif 
     1623 
    15071624        // only rays intersecting objects in node are interesting 
    1508         AssociateObjectsWithRays(sampleRays); 
    1509          
    1510         // probabilty is voume of all "seen" view cells 
    1511 #if 1 
    1512         const float prop = EvalViewCellsVolume(objects); 
    1513 #else 
    1514         const float prop = GetBoundingBox().GetVolume(); 
    1515 #endif 
     1625        const int nRays = AssociateObjectsWithRays(sampleRays); 
     1626        //Debug << "using " << nRays << " of " << (int)sampleRays.size() << " rays" << endl; 
    15161627 
    15171628        // create bvh traversal data 
    1518         BvhTraversalData oData(bvhleaf, 0, mBoundingBox, prop); 
     1629        BvhTraversalData oData(bvhleaf, 0, prop, nRays); 
    15191630 
    15201631        // create sorted object lists for the first data 
     
    15401651 
    15411652        return oSubdivisionCandidate; 
    1542 } 
    1543  
    1544  
    1545 bool BvHierarchy::AddLeafToPvs(BvhLeaf *leaf,  
    1546                                                            ViewCell *vc,  
    1547                                                            const float pdf,  
    1548                                                            float &contribution) 
    1549 { 
    1550         // add kd intersecable to pvs 
    1551         BvhIntersectable *bvhObj = GetOrCreateBvhIntersectable(leaf); 
    1552          
    1553         return vc->AddPvsSample(bvhObj, pdf, contribution); 
    15541653} 
    15551654 
     
    16021701                backData.mSortedObjects[i]->reserve((int)sc.mFrontObjects.size()); 
    16031702 
    1604                 ObjectContainer::const_iterator oit, oit_end = sc.mParentData.mNode->mObjects.end(); 
    1605  
    1606                 for (oit = sc.mParentData.mNode->mObjects.begin(); oit != oit_end; ++ oit) 
     1703                ObjectContainer::const_iterator oit, oit_end = sc.mParentData.mSortedObjects[i]->end(); 
     1704 
     1705                for (oit = sc.mParentData.mSortedObjects[i]->begin(); oit != oit_end; ++ oit) 
    16071706                { 
    16081707                        if ((*oit)->Mailed()) 
     
    16351734        app << "#AXIS_ALIGNED_SPLITS (number of axis aligned splits)\n" << splits << endl; 
    16361735 
    1637         app << "#N_PMINDEPTHLEAVES ( Percentage of leaves at minimum depth )\n"  
    1638                 <<      minDepthNodes * 100 / (double)Leaves() << endl; 
    1639  
     1736        app << "#N_MAXCOSTNODES  ( Percentage of leaves with terminated because of max cost ratio )\n" 
     1737                << maxCostNodes * 100 / (double)Leaves() << endl; 
     1738 
     1739        app << "#N_PMINPROBABILITYLEAVES  ( Percentage of leaves with mininum probability )\n" 
     1740                << minProbabilityNodes * 100 / (double)Leaves() << endl; 
     1741 
     1742 
     1743        ////////////////////////////////////////////////// 
     1744         
    16401745        app << "#N_PMAXDEPTHLEAVES ( Percentage of leaves at maximum depth )\n"  
    16411746                <<      maxDepthNodes * 100 / (double)Leaves() << endl; 
    1642  
    1643         app << "#N_MAXCOSTNODES  ( Percentage of leaves with terminated because of max cost ratio )\n" 
    1644                 << maxCostNodes * 100 / (double)Leaves() << endl; 
    1645  
    1646         app << "#N_PMINPROBABILITYLEAVES  ( Percentage of leaves with mininum probability )\n" 
    1647                 << minProbabilityNodes * 100 / (double)Leaves() << endl; 
    1648  
     1747         
     1748        app << "#N_PMAXDEPTH ( Maximal reached depth )\n" << maxDepth << endl; 
     1749 
     1750        app << "#N_PMINDEPTH ( Minimal reached depth )\n" << minDepth << endl; 
     1751 
     1752        app << "#AVGDEPTH ( average depth )\n" << AvgDepth() << endl; 
     1753 
     1754         
     1755        //////////////////////////////////////////////////////// 
     1756         
    16491757        app << "#N_PMINOBJECTSLEAVES  ( Percentage of leaves with mininum objects )\n" 
    16501758                << minObjectsNodes * 100 / (double)Leaves() << endl; 
    16511759 
    1652         app << "#N_PMAXDEPTH ( Maximal reached depth )\n" << maxDepth << endl; 
    1653  
    1654         app << "#N_PMINDEPTH ( Minimal reached depth )\n" << minDepth << endl; 
    1655  
    1656         app << "#AVGDEPTH ( average depth )\n" << AvgDepth() << endl; 
    1657  
    1658         app << "#N_INVALIDLEAVES (number of invalid leaves )\n" << invalidLeaves << endl; 
    1659  
    16601760        app << "#N_MAXOBJECTREFS  ( Max number of object refs / leaf )\n" << maxObjectRefs << "\n"; 
    16611761 
    1662         //app << "#N_RAYS (number of rays / leaf)\n" << AvgRays() << endl; 
    1663          
    1664         app << "========== END OF VspTree statistics ==========\n"; 
    1665 } 
    1666  
    1667  
    1668 } 
     1762        app << "#N_MINOBJECTREFS  ( Min number of object refs / leaf )\n" << minObjectRefs << "\n"; 
     1763         
     1764        app << "#N_PAVGOBJECTSLEAVES  ( average object refs / leaf)\n" << AvgObjectRefs() << endl; 
     1765 
     1766 
     1767        //////////////////////////////////////////////////////// 
     1768         
     1769        app << "#N_PMINRAYSLEAVES  ( Percentage of leaves with mininum rays )\n" 
     1770                << minRaysNodes * 100 / (double)Leaves() << endl; 
     1771 
     1772        app << "#N_MAXRAYREFS  ( Max number of ray refs / leaf )\n" << maxRayRefs << "\n"; 
     1773 
     1774        app << "#N_MINRAYREFS  ( Min number of ray refs / leaf )\n" << minRayRefs << "\n"; 
     1775         
     1776        app << "#N_PAVGRAYLEAVES  ( average ray refs / leaf )\n" << AvgRayRefs() << endl; 
     1777         
     1778        app << "#N_PAVGRAYCONTRIBLEAVES  ( Average ray contribution)\n" << 
     1779                rayRefs / (double)objectRefs << endl; 
     1780 
     1781        app << "#N_PMAXRAYCONTRIBLEAVES  ( Percentage of leaves with maximal ray contribution )\n"<< 
     1782                maxRayContriNodes * 100 / (double)Leaves() << endl; 
     1783 
     1784        app << "========== END OF BvHierarchy statistics ==========\n"; 
     1785} 
     1786 
     1787 
     1788} 
Note: See TracChangeset for help on using the changeset viewer.