Changeset 1305


Ignore:
Timestamp:
08/31/06 16:47:41 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
6 edited

Legend:

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

    r1303 r1305  
    380380                tFrontData.mNode->SetSubdivisionCandidate(frontCandidate);  
    381381                tBackData.mNode->SetSubdivisionCandidate(backCandidate); 
    382 Debug << "here125 candidate: " << tFrontData.mNode->GetSubdivisionCandidate() << " type: " << tFrontData.mNode->GetSubdivisionCandidate()->Type() << endl; 
    383 Debug << "here129 candidate: " << tBackData.mNode->GetSubdivisionCandidate() << " type: " << tBackData.mNode->GetSubdivisionCandidate()->Type() << endl; 
     382 
     383                Debug << "leaf: " << tFrontData.mNode << " setting f candidate: " << tFrontData.mNode->GetSubdivisionCandidate() << " type: " << tFrontData.mNode->GetSubdivisionCandidate()->Type() << endl; 
     384                Debug << "leaf: " << tBackData.mNode << " setting b candidate: " << tBackData.mNode->GetSubdivisionCandidate() << " type: " << tBackData.mNode->GetSubdivisionCandidate()->Type() << endl; 
     385                 
    384386                tQueue.Push(frontCandidate); 
    385387                tQueue.Push(backCandidate); 
     
    389391        } 
    390392 
    391  
    392393        //-- terminate traversal 
     394 
    393395    if (newNode->IsLeaf()) 
    394396        { 
    395397                //-- store additional info 
     398                 
    396399                EvaluateLeafStats(tData); 
    397400         
     
    402405                        CollectRays(leaf->mObjects, leaf->mVssRays); 
    403406                } 
    404  
     407                 
     408                // detach subdivision candidate: this leaf is no candidate for 
     409                // splitting anymore 
     410                tData.mNode->SetSubdivisionCandidate(NULL);  
    405411                // detach node so it won't get deleted 
    406412                tData.mNode = NULL; 
     
    430436        const float viewSpaceVol = mVspTree->GetBoundingBox().GetVolume(); 
    431437        const float oldProp = EvalViewCellsVolume(leaf->mObjects); 
    432         const float oldProp2 = splitCandidate.mParentData.mProbability; //Debug << "here8 " << (oldProp - oldProp2) / viewSpaceVol << "  " << oldProp  / viewSpaceVol << " " << oldProp2  / viewSpaceVol << endl; 
     438        //const float oldProp2 = splitCandidate.mParentData.mProbability; Debug << "here8 " << (oldProp - oldProp2) / viewSpaceVol << "  " << oldProp  / viewSpaceVol << " " << oldProp2  / viewSpaceVol << endl; 
    433439 
    434440        const float oldRenderCost = oldProp * (float)leaf->mObjects.size() / viewSpaceVol; 
     
    440446 
    441447        newRenderCost /=  viewSpaceVol; 
    442  
    443448        const float renderCostDecr = oldRenderCost - newRenderCost; 
    444449 
     
    10711076                                        vc->Mail(); 
    10721077                                        if (setCounter) 
     1078                                        { 
    10731079                                                vc->mCounter = 0; 
     1080                                        } 
    10741081                                } 
    1075                                  
    10761082                                viewCells.push_back(vc); 
    10771083                        } 
     
    11061112                VspLeaf *leaf = vc->mLeaf; 
    11071113                SubdivisionCandidate *candidate = leaf->GetSubdivisionCandidate(); 
    1108                 Debug << "here100 candidate: " << candidate << " type: " << candidate->Type() << endl; 
    11091114                 
    1110                 dirtyList.push_back(leaf->GetSubdivisionCandidate()); 
     1115                if (candidate) // is this leaf still a split candidate? 
     1116                { 
     1117                        dirtyList.push_back(candidate); 
     1118                } 
    11111119        } 
    11121120} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h

    r1302 r1305  
    356356                {}; 
    357357 
    358                 ~BvhSubdivisionCandidate() { mParentData.Clear(); } 
     358                ~BvhSubdivisionCandidate()  
     359                {  
     360                        mParentData.Clear();  
     361                } 
    359362 
    360363                int Type() const { return OBJECT_SPACE; } 
     
    377380                {} 
    378381 
    379                  
     382                /// pointer to parent tree. 
    380383                static BvHierarchy *sBvHierarchy; 
    381  
    382384                /// parent data 
    383385                BvhTraversalData mParentData; 
     386                /// the objects on the front of the potential split 
    384387                ObjectContainer mFrontObjects; 
     388                /// the objects on the back of the potential split 
    385389                ObjectContainer mBackObjects; 
    386390        }; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r1303 r1305  
    311311 
    312312        cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 
    313  
    314313        mBvHierarchy->mBvhStats.Stop(); 
    315314} 
     
    399398        while (!FinishedConstruction()) 
    400399        { 
    401                 mCurrentCandidate = NextSubdivisionCandidate(); 
    402              
     400                mCurrentCandidate = NextSubdivisionCandidate();     
    403401                mTotalCost -= mCurrentCandidate->GetRenderCostDecrease(); 
    404402 
     
    408406                //Debug << "ratio: " << costRatio << " min ratio: " << mTermMinGlobalCostRatio << endl; 
    409407                if (costRatio < mTermMinGlobalCostRatio) 
     408                { 
    410409                        ++ mGlobalCostMisses; 
     410                } 
    411411 
    412412                //-- subdivide leaf node 
    413  
    414413                if (ApplySubdivisionCandidate(mCurrentCandidate)) 
    415414                { 
     
    419418                        EvalSubdivisionStats(*mCurrentCandidate); 
    420419                 
    421                         // reevaluate candidates affected by the split 
    422                         // for view space splits, this would be object space splits 
    423                         // and other way round 
     420                        // reevaluate candidates affected by the split for view space splits,  
     421                        // this would be object space splits and other way round 
    424422                        if (repair) RepairQueue(); 
    425  
    426                         Debug << "candidate: " << mCurrentCandidate->Type() << ", priority: "  
    427                                   << mCurrentCandidate->GetPriority() << endl; 
    428423                } 
    429424                 
    430                 Debug << "here66 " << mCurrentCandidate << endl; 
    431425                DEL_PTR(mCurrentCandidate); 
    432426        } 
     
    458452 
    459453                        mBvHierarchy->CollectDirtyCandidates(sc, dirtyList); 
    460  
    461 sc->mParentData.mNode->SetSubdivisionCandidate(NULL); // HACK 
    462454                        break; 
    463455                } 
     
    474466 
    475467        mVspTree->CollectDirtyCandidates(sc, dirtyList); 
    476  
    477 sc->mParentData.mNode->SetSubdivisionCandidate(NULL); // HACK 
    478468} 
    479469 
     
    484474        if (mCurrentCandidate->Type() == SubdivisionCandidate::VIEW_SPACE) 
    485475        { 
    486                 Debug << "collecting candidates after view space split" << endl; 
    487476                CollectViewSpaceDirtyList(dirtyList); 
    488477        } 
    489478        else // object space split 
    490         {       Debug << "collecting candidates after object space split" << endl; 
     479        { 
    491480                CollectObjectSpaceDirtyList(dirtyList); 
    492481        } 
     
    515504        // collect list of "dirty" candidates 
    516505        vector<SubdivisionCandidate *> dirtyList; 
    517         Debug << "collecting dirty candidates" << endl; 
    518506        CollectDirtyCandidates(dirtyList); 
    519          
     507        Debug << "collected " << (int)dirtyList.size() << " candidates for reevaluation" << endl; 
     508 
    520509        //-- reevaluate the dirty list 
    521  
    522510        vector<SubdivisionCandidate *>::const_iterator sit, sit_end = dirtyList.end(); 
    523511         
    524         Debug << "collected " << (int)dirtyList.size() << " candidates" << endl; 
    525  
    526512        for (sit = dirtyList.begin(); sit != sit_end; ++ sit) 
    527513        { 
    528514                SubdivisionCandidate* sc = *sit; 
    529                 float rcd = sc->GetRenderCostDecrease(); 
    530                 Debug << "here6 " << rcd << endl; 
    531                 Debug << "here84 " << endl; 
    532                 Debug << "here7 " << sc << endl; 
    533                 Debug << "here90 " << sc->GetPosition() << endl; 
    534                 Debug << "here91 " << sc->Type() << endl; 
    535                 //Debug << "here1191" << sc->Type() << endl; 
    536                 //Debug << "sc: " << sc << " " << sc->GetPosition() << " " << sc->Type() << endl; 
     515                const float rcd = sc->GetRenderCostDecrease(); 
    537516                 
    538                 Debug << "here11" << endl; 
    539517                mTQueue.Erase(sc); // erase from queue 
    540                 Debug << "here2" << endl; 
    541  
    542518                sc->EvalPriority(); // reevaluate 
    543519                 
    544         /*      cout << "render cost decrease diff " << rcd - sc->GetRenderCostDecrease()  
    545                          << " old: " << rcd << " new " << sc->GetRenderCostDecrease() 
    546                          << " type " << sc->Type() << endl;*/ 
    547  
     520                /* 
     521                Debug << "candidate " << sc << " reevaluated\n"  
     522                          << "render cost decrease diff " <<  rcd - sc->GetRenderCostDecrease() 
     523                          << " old: " << rcd << " new " << sc->GetRenderCostDecrease() << endl;*/ 
     524                if (0) 
     525                { 
     526                        const float rcDiff =  rcd - sc->GetRenderCostDecrease(); 
     527                        mTotalCost += rcDiff; 
     528                } 
    548529                mTQueue.Push(sc); // reinsert 
    549530        } 
     
    560541                mOspTree->Export(stream); 
    561542                stream << endl << "</ObjectSpaceHierarchy>" << endl; 
    562                 break; 
    563                  
     543                break;           
    564544        case BV_BASED_OBJ_SUBDIV: 
    565545                stream << "<ObjectSpaceHierarchy type=\"bvh\">" << endl; 
     
    584564                // potentially visible objects 
    585565                return vc->AddPvsSample(obj, pdf, contribution); 
    586  
    587566        case KD_BASED_OBJ_SUBDIV: 
    588567                { 
     
    681660                mVspTree->PrepareConstruction(sampleRays, forcedViewSpace, *viewSpaceRays); 
    682661         
    683         // add to queue 
     662        // add to subdivision candidate to split candidate queue 
    684663        mTQueue.Push(vsc); 
    685664 
     
    708687        ///////////////////////////////////////////////////////////// 
    709688         
    710          
    711689        switch (mObjectSpaceSubdivisonType) 
    712690        { 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SubdivisionCandidate.h

    r1302 r1305  
    2626        SubdivisionCandidate(): mRenderCostDecrease(0) {}; 
    2727 
     28        virtual ~SubdivisionCandidate() {}; 
    2829        virtual void EvalPriority() = 0; 
    2930        virtual int Type() const = 0; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.cpp

    r1303 r1305  
    709709                // finally evaluate statistics for this leaf 
    710710                EvaluateLeafStats(tData); 
    711  
     711                // detach subdivision candidate: this leaf is no candidate for 
     712                // splitting anymore 
     713                tData.mNode->SetSubdivisionCandidate(NULL);  
    712714                // detach node so it won't get deleted 
    713715                tData.mNode = NULL; 
     
    26912693                        { 
    26922694                                leaf->Mail(); 
    2693                                 dirtyList.push_back(leaf->GetSubdivisionCandidate());Debug << "here87700" << endl; 
    2694                                 Debug << "here166 candidate: " << leaf->GetSubdivisionCandidate() << endl; 
    2695                                 Debug << "here120 candidate: " << leaf->GetSubdivisionCandidate() << " type: " << leaf->GetSubdivisionCandidate()->Type() << endl; 
    2696                                 Debug << "here877" << endl; 
     2695                                if (leaf->GetSubdivisionCandidate()) // a candidate still attached to this node 
     2696                                { 
     2697                                        dirtyList.push_back(leaf->GetSubdivisionCandidate()); 
     2698                                } 
    26972699                        } 
    26982700                        break; 
    26992701                } 
    2700                 break; 
    27012702        default: 
    27022703                break; 
     
    27942795                                obj->Mail(); 
    27952796                                obj->mCounter = 0; 
    2796  
    27972797                                ++ pvsSize; 
    27982798                        } 
    2799  
    28002799                        ++ obj->mCounter;        
    28012800                        break; 
     
    28152814                                leaf->Mail(); 
    28162815                                leaf->mCounter = 0; 
    2817  
    28182816                                pvsSize += (int)leaf->mObjects.size(); 
    28192817                        } 
    2820  
    28212818                        ++ leaf->mCounter;       
    28222819                        break; 
     
    28642861                { 
    28652862                        BvhLeaf *leaf = mHierarchyManager->mBvHierarchy->GetLeaf(obj); 
    2866  
    28672863                        if (!leaf->Mailed()) 
    28682864                        { 
     
    29282924        ray.GetSampleData(isTermination, pt, &obj, &node); 
    29292925 
    2930         if (!obj)  
    2931                 return 0; 
     2926        if (!obj) return 0; 
    29322927 
    29332928        int pvs = 0; 
     
    29772972        leaf->Mail(); 
    29782973 
    2979         int pvs = 0; 
    2980         pvs += (int)(leaf->mObjects.size() - leaf->mMultipleObjects.size()); 
     2974        int pvs = (int)(leaf->mObjects.size() - leaf->mMultipleObjects.size()); 
    29812975 
    29822976        ObjectContainer::const_iterator oit, oit_end = leaf->mMultipleObjects.end(); 
     
    29852979        { 
    29862980                Intersectable *obj = *oit; 
    2987  
    29882981                if (!obj->Mailed()) 
    29892982                { 
     
    29962989} 
    29972990 
    2998 } 
     2991 
     2992} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspTree.h

    r1302 r1305  
    447447                {}; 
    448448 
    449                 ~VspSubdivisionCandidate() { mParentData.Clear(); } 
     449                ~VspSubdivisionCandidate()  
     450                { 
     451                        mParentData.Clear();  
     452                } 
    450453 
    451454                int Type() const { return VIEW_SPACE; } 
     
    474477                VspNode *mNode; 
    475478                Vector3 mExitPoint; 
    476                  
    477479                float mMaxT; 
    478480     
     
    588590        */ 
    589591        int CastBeam(Beam &beam); 
    590  
    591592 
    592593        /** Checks if tree validity-flags are right  
     
    778779                                                                  const int axis, 
    779780                                                                  float &position); 
    780  
    781781 
    782782 
Note: See TracChangeset for help on using the changeset viewer.