Changeset 1178


Ignore:
Timestamp:
08/02/06 17:01:35 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis
Files:
8 edited

Legend:

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

    r1168 r1178  
    251251                                                        float &contribution) 
    252252{ 
     253        Debug << "here9 "<< endl; 
     254        Debug << "here2 " << mVolume << endl; 
    253255        const bool result = mPvs.AddSample(sample, pdf, contribution); 
    254  
     256        Debug << "here4" << endl; 
    255257        // update pvs size scalar 
    256258        //mPvsSize = mPvs.GetSize(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1176 r1178  
    3131 
    3232 
    33  
    3433template <typename T> class myless 
    3534{ 
     
    921920                cout << "finished" << endl; 
    922921        } 
    923          
    924922        cout << "finished" << endl; 
    925923 
    926         cout << "Evaluating view cell partition" << endl; 
     924    cout << "Evaluating view cell partition ... " << endl; 
    927925 
    928926        while (castSamples < numSamples) 
     
    978976                cout << "finished in " << timeDiff * 1e-3 << " secs" << endl; 
    979977                Debug << "finished in " << timeDiff * 1e-3 << " secs" << endl; 
    980  
    981978         
    982979                disposeRays(evaluationSamples, NULL); 
     
    25342531         
    25352532 
    2536 #else 
    2537  
    2538         // really merge cells: slow put sumpdf is correct 
     2533#else // really merge cells: slow put sumPdf is correct 
    25392534        viewCellInterior->GetPvs().Merge(backVc->GetPvs()); 
    25402535        viewCellInterior->GetPvs().Merge(frontVc->GetPvs()); 
    25412536#endif 
    25422537} 
    2543  
    25442538 
    25452539 
     
    48854879 
    48864880        long startTime; 
    4887  
     4881Debug << "here601" << endl; 
    48884882        //mHierarchyManager->Construct(constructionRays, objects, &mViewSpaceBox); 
    48894883        mHierarchyManager->Construct2(constructionRays, objects, &mViewSpaceBox); 
    48904884 
     4885        VssRayContainer::const_iterator vit, vit_end = constructionRays.end(); 
     4886        for (vit = constructionRays.begin(); vit != vit_end; ++ vit) 
     4887        { 
     4888                storedRays.push_back(new VssRay(*(*vit))); 
     4889        } 
    48914890 
    48924891        // print subdivision statistics 
     
    49024901 
    49034902        cout << "Computing remaining ray contributions ... "; 
     4903 
    49044904 
    49054905        // recast rest of rays 
     
    52785278        int raysOut = 0; 
    52795279 
     5280 
    52805281        //-- some rays for output 
     5282         
    52815283        for (int i = 0; i < limit; ++ i) 
    52825284        { 
     
    57255727 
    57265728 
     5729void VspOspViewCellsManager::EvalViewCellPartition() 
     5730{ 
     5731        Debug << "here23" << endl; 
     5732        int samplesPerPass; 
     5733        int numSamples; 
     5734        int castSamples = 0; 
     5735 
     5736        char s[64];  
     5737 
     5738        Environment::GetSingleton()->GetIntValue("ViewCells.Evaluation.samplesPerPass", samplesPerPass); 
     5739        Environment::GetSingleton()->GetIntValue("ViewCells.Evaluation.samples", numSamples); 
     5740 
     5741        char statsPrefix[100]; 
     5742        Environment::GetSingleton()->GetStringValue("ViewCells.Evaluation.statsPrefix", statsPrefix); 
     5743 
     5744        Debug << "view cell evaluation samples per pass: " << samplesPerPass << endl; 
     5745        Debug << "view cell evaluation samples: " << numSamples << endl; 
     5746        Debug << "view cell stats prefix: " << statsPrefix << endl; 
     5747 
     5748        // should directional sampling be used? 
     5749        bool dirSamples = (mEvaluationSamplingType == Preprocessor::DIRECTION_BASED_DISTRIBUTION); 
     5750 
     5751        cout << "reseting pvs ... "; 
     5752                 
     5753        const bool startFromZero = true; 
     5754 
     5755        // reset pvs and start over from zero 
     5756        if (startFromZero) 
     5757        { 
     5758                mViewCellsTree->ResetPvs(); 
     5759        } 
     5760        else // start from current sampless 
     5761        { 
     5762                // statistics before casting more samples 
     5763                cout << "compute new statistics ... "; 
     5764                sprintf(s, "-%09d-eval.log", castSamples); 
     5765                string fName = string(statsPrefix) + string(s); 
     5766 
     5767                mViewCellsTree->ExportStats(fName); 
     5768                cout << "finished" << endl; 
     5769        } 
     5770        cout << "finished" << endl; 
     5771 
     5772    cout << "Evaluating view cell partition ... " << endl; 
     5773 
     5774        VssRayContainer evaluationSamples = storedRays; 
     5775        const int samplingType = mEvaluationSamplingType; 
     5776         
     5777        cout << "computing sample contributions of " << (int)evaluationSamples.size()  << " samples ... "; 
     5778 
     5779        ComputeSampleContributions(evaluationSamples, true, false); 
     5780 
     5781        cout << "finished" << endl; 
     5782         
     5783        cout << "compute new statistics ... "; 
     5784        Debug << "compute new statistics ... "; 
     5785 
     5786        //-- propagate pvs or pvs size information 
     5787        ObjectPvs pvs; 
     5788        UpdatePvsForEvaluation(mViewCellsTree->GetRoot(), pvs); 
     5789 
     5790        //-- output stats 
     5791 
     5792        sprintf(s, "-%09d-eval.log", castSamples); 
     5793        string fileName = string(statsPrefix) + string(s); 
     5794 
     5795        mViewCellsTree->ExportStats(fileName); 
     5796         
     5797        cout << "finished" << endl; 
     5798 
     5799        disposeRays(evaluationSamples, NULL); 
     5800} 
     5801 
    57275802////////////////////////////////// 
    57285803/*ViewCellsManager *ViewCellsManagerFactory::Create(const string mName) 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r1168 r1178  
    383383        /** Evaluates render cost statistics of current view cell hierarchy. 
    384384        */ 
    385         void EvalViewCellPartition(); 
     385        virtual void EvalViewCellPartition(); 
    386386 
    387387        /** Sets maximal size of a view cell filter. 
     
    413413        */ 
    414414        void UpdateScalarPvsSize(ViewCell *vc, const int pvsSize, const int entriesInPvs) const; 
    415  
    416415 
    417416        /** Returns bounding box of a view cell. 
     
    674673 
    675674        bool mStoreKdPvs; 
     675 
     676        VssRayContainer storedRays; 
    676677}; 
    677678 
     
    10111012protected: 
    10121013         
     1014        virtual void EvalViewCellPartition(); 
     1015 
    10131016        /** Exports view cell geometry. 
    10141017        */ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp

    r1176 r1178  
    3030OspTree *OspTree::OspSplitCandidate::sOspTree = NULL; 
    3131 
     32// variable for debugging volume contribution for heuristics 
     33static float debugVol; 
     34 
    3235// pvs penalty can be different from pvs size 
    3336inline static float EvalPvsPenalty(const int pvs,  
     
    460463                Debug << "pvs heuristics: per kd node" << endl; 
    461464 
    462         mSplitCandidates = new vector<SortableEntry>; 
     465        mLocalSplitCandidates = new vector<SortableEntry>; 
    463466 
    464467        Debug << endl; 
     
    494497{ 
    495498        DEL_PTR(mRoot); 
    496         DEL_PTR(mSplitCandidates); 
     499        DEL_PTR(mLocalSplitCandidates); 
    497500} 
    498501 
     
    703706        if (newNode->IsLeaf()) // subdivision terminated 
    704707        { 
    705                 //CreateViewCell(tData); // create new view cell 
     708                // view cell is created during subdivision 
     709                //CreateViewCell(tData);  
    706710 
    707711                VspLeaf *leaf = dynamic_cast<VspLeaf *>(newNode); 
     
    980984   
    981985        ViewCellLeaf *vc = leaf->GetViewCell(); 
    982   
     986 
    983987        // add contributions from samples to the PVS 
    984988        for (it = rays.begin(); it != it_end; ++ it) 
     
    10161020                { 
    10171021                        // potentially visible kd cells 
    1018                         if (!mUseKdPvsForHeuristics) // matt TODo: remove storekdpvs!! 
     1022                        if (!mStoreKdPvs) // matt Todo: remove storekdpvs!! 
    10191023                        { 
    10201024                                if (vc->AddPvsSample(obj, ray->mPdf, contribution)) 
     
    10501054                                                                  float maxBand) 
    10511055{ 
    1052         mSplitCandidates->clear(); 
     1056        mLocalSplitCandidates->clear(); 
    10531057 
    10541058        int requestedSize = 2 * (int)(rays.size()); 
    10551059 
    10561060        // creates a sorted split candidates array 
    1057         if (mSplitCandidates->capacity() > 500000 && 
    1058                 requestedSize < (int)(mSplitCandidates->capacity() / 10) ) 
    1059         { 
    1060         delete mSplitCandidates; 
    1061                 mSplitCandidates = new vector<SortableEntry>; 
    1062         } 
    1063  
    1064         mSplitCandidates->reserve(requestedSize); 
     1061        if (mLocalSplitCandidates->capacity() > 500000 && 
     1062                requestedSize < (int)(mLocalSplitCandidates->capacity() / 10) ) 
     1063        { 
     1064        delete mLocalSplitCandidates; 
     1065                mLocalSplitCandidates = new vector<SortableEntry>; 
     1066        } 
     1067 
     1068        mLocalSplitCandidates->reserve(requestedSize); 
     1069 
    10651070 
    10661071        float pos; 
     
    10751080                pos = (*rit).ExtrapOrigin(axis); 
    10761081                 
    1077                 mSplitCandidates->push_back(SortableEntry(positive ? SortableEntry::ERayMin : SortableEntry::ERayMax,  
     1082                mLocalSplitCandidates->push_back(SortableEntry(positive ? SortableEntry::ERayMin : SortableEntry::ERayMax,  
    10781083                                                                        pos, (*rit).mRay)); 
    10791084 
    10801085                pos = (*rit).ExtrapTermination(axis); 
    10811086 
    1082                 mSplitCandidates->push_back(SortableEntry(positive ? SortableEntry::ERayMax : SortableEntry::ERayMin,  
     1087                mLocalSplitCandidates->push_back(SortableEntry(positive ? SortableEntry::ERayMax : SortableEntry::ERayMin,  
    10831088                                                                        pos, (*rit).mRay)); 
    10841089        } 
    10851090 
    1086         stable_sort(mSplitCandidates->begin(), mSplitCandidates->end()); 
     1091        stable_sort(mLocalSplitCandidates->begin(), mLocalSplitCandidates->end()); 
    10871092} 
    10881093 
     
    14111416 
    14121417 
    1413         vector<SortableEntry>::const_iterator ci, ci_end = mSplitCandidates->end(); 
    1414  
    14151418        //-- traverse through visibility events 
    14161419 
    1417         for (ci = mSplitCandidates->begin(); ci != ci_end; ++ ci) 
     1420        vector<SortableEntry>::const_iterator ci, ci_end = mLocalSplitCandidates->end(); 
     1421 
     1422        for (ci = mLocalSplitCandidates->begin(); ci != ci_end; ++ ci) 
    14181423        { 
    14191424                EvalPvsIncr(*ci, pvsl, pvsr); 
     
    14691474        } 
    14701475         
    1471         //if (axis != 1) 
     1476        const float volRatio = tData.mBoundingBox.GetVolume() / (sizeBox * mBoundingBox.GetVolume()); 
     1477 
     1478/*       
     1479//if (axis != 1) 
    14721480        //Debug << "axis=" << axis << " costRatio=" << ratio << " pos=" << position << " t=" << (position - minBox) / (maxBox - minBox) 
    14731481        //      <<"\t pb=(" << pvsBack << ")\t pf=(" << pvsFront << ")" << endl; 
    14741482 
    1475         const float volRatio = tData.mBoundingBox.GetVolume() / (sizeBox * mBoundingBox.GetVolume()); 
    1476  
    1477         Debug << "\n§§§§ eval local cost §§§§" << endl 
     1483Debug << "\n§§§§ eval local cost §§§§" << endl 
    14781484                  << "back pvs: " << penaltyBack << " front pvs: " << penaltyFront << " total pvs: " << penaltyOld << endl  
    14791485                  << "back p: " << pBack * volRatio << " front p " << pFront * volRatio << " p: " << pOverall * volRatio << endl 
    14801486                  << "old rc: " << oldRenderCost * volRatio << " new rc: " << newRenderCost * volRatio << endl 
    14811487                  << "render cost decrease: " << oldRenderCost * volRatio - newRenderCost * volRatio << endl; 
    1482  
     1488*/ 
    14831489        return ratio; 
    14841490} 
     
    16481654        normalizedOldRenderCost = oldRenderCost / viewSpaceVol; 
    16491655 
    1650         //Debug << "decrease: " << oldRenderCost - newRenderCost << endl; 
    16511656        const float renderCostDecrease = (oldRenderCost - newRenderCost) / viewSpaceVol; 
    1652          
     1657        /* 
    16531658        Debug << "\n==== eval render cost decrease ===" << endl 
    16541659                  << "back pvs: " << pvsBack << " front pvs " << pvsFront << " total pvs: " << totalPvs << endl  
     
    16561661                  << "old rc: " << normalizedOldRenderCost << " new rc: " << newRenderCost / viewSpaceVol << endl 
    16571662                  << "render cost decrease: " << renderCostDecrease << endl; 
    1658  
     1663*/ 
    16591664        return renderCostDecrease; 
    16601665} 
     
    16901695        } 
    16911696 
    1692         //-- cost heuristics 
     1697        //-- evaluate cost heuristics 
     1698 
    16931699        float pOverall; 
    16941700         
     
    19861992{ 
    19871993        vector<VspLeaf *> leaves; 
     1994        CollectLeaves(leaves); 
    19881995 
    19891996        vector<VspLeaf *>::const_iterator lit, lit_end = leaves.end(); 
     
    29332940        mBoundingBox = kdTree.GetBox(); 
    29342941        mRoot = kdTree.GetRoot(); 
     2942        mSplitCandidates = new vector<SortableEntry>; 
    29352943} 
    29362944 
     
    29492957                DEL_PTR(mRoot); 
    29502958 
     2959        DEL_PTR(mSplitCandidates); 
    29512960        mSubdivisionStats.close(); 
    29522961} 
     
    32303239        float frontProb; 
    32313240        float backProb; 
    3232          
     3241 
    32333242        // compute locally best split plane 
    32343243        const bool success =  
     
    33373346        RayInfoContainer usedRays; 
    33383347int mMaxTests = 5000; // HACK 
    3339         if (mMaxTests < (int)tData.mRays->size()) 
    3340         { 
    3341                 GetRayInfoSets(*tData.mRays, mMaxTests, usedRays); 
    3342         } 
    3343         else 
    3344         { 
     3348//      if (mMaxTests < (int)tData.mRays->size()) 
     3349//      { 
     3350//              GetRayInfoSets(*tData.mRays, mMaxTests, usedRays); 
     3351//      } 
     3352//      else 
     3353//      { 
    33453354                usedRays = *tData.mRays; 
    3346         } 
     3355//      } 
    33473356 
    33483357        // go through the lists, count the number of objects left and right 
     
    33963405        float minSum = 1e20f; 
    33973406 
     3407        debugVol = 0; 
     3408        const float viewSpaceVol = mVspTree->GetBoundingBox().GetVolume(); 
     3409 
    33983410        ///////////////////////////// 
     3411        // the sweep heuristics 
     3412 
    33993413 
    34003414        Intersectable::NewMail(); 
    34013415        ViewCell::NewMail(); 
    3402  
     3416         
     3417         
    34033418        //-- traverse through events and find best split plane 
     3419         
    34043420        vector<SortableEntry>::const_iterator ci, ci_end = mSplitCandidates->end(); 
    34053421 
     
    34313447                                currentPos = (*ci).mPos;                         
    34323448 
    3433                         // note matt: can happen that volr is less than zero: bug or numerical error? 
    3434                         //if (volr < 0) Debug << "warning!"; 
    3435  
    3436                         /*Debug << "pos: " << (*ci).mPos  
     3449                        if ((totalVol - voll - volr - debugVol) / viewSpaceVol > 0.0001) 
     3450                                Debug << "front and back volume: " << (totalVol - voll - volr) / viewSpaceVol << " error: " << (totalVol - voll - volr - debugVol) / viewSpaceVol << endl; 
     3451                        /*      Debug << "pos: " << currentPos  
    34373452                                 << "\t (pvsl: " << pvsl << ", pvsr: " << pvsr << ")" 
    34383453                                 << "\t (voll: " << voll << ", volr: " << volr << ")" 
    34393454                                 << "\t (vcl: " << vcl << ", vcr: " << vcr << ", nvc: " << numViewCells << ")" 
    3440                                  << "\t sum: " << sum << endl;*/ 
     3455                                 << "\t sum: " << sum << endl; 
     3456                                 */ 
    34413457 
    34423458                        if (sum < minSum) 
     
    34713487                ratio = newRenderCost / oldRenderCost; 
    34723488        } 
    3473          
     3489 
    34743490        //Debug << "axis=" << axis << " costRatio=" << ratio << " pos="  
    34753491        //        << position << " t=" << (position - minBox) / (maxBox - minBox) 
    34763492        //      << "\t pb=(" << volBack << ")\t pf=(" << volFront << ")" << endl; 
    3477  
    3478         const float viewSpaceVol = mVspTree->GetBoundingBox().GetVolume(); 
    34793493 
    34803494        Debug << "\n§§§§ eval local cost §§§§" << endl 
     
    35433557                                                          ); 
    35443558                } 
    3545  
    3546  
    3547  
    35483559 
    35493560                if (ray->mTerminationObject && (GetLeaf(ray->mTermination, ray->mTerminationNode) == leaf)) 
     
    37413752                        // => remove ref to right child node 
    37423753                        volRight -= vol; 
     3754 
     3755                        debugVol += vol; 
    37433756                } 
    37443757 
     
    37563769                        // contributes only to left node now 
    37573770                        volLeft += vol; 
     3771                        debugVol -= vol; 
    37583772                } 
    37593773        } 
     
    37933807                sAxis = box.Size().DrivingAxis(); 
    37943808        } 
     3809         
    37953810 
    37963811        // -- evaluate split cost for all three axis 
     
    40114026        } 
    40124027 
     4028        ViewCellContainer::const_iterator vit, vit_end = collectedViewCells.end(); 
     4029 
     4030        // evaluate view cells volume contribution with respect to mail box 
     4031        for (vit = collectedViewCells.begin(); vit != vit_end; ++ vit) 
     4032        { 
     4033                AddViewCellVolumeContri(*vit, pFront, pBack, pFrontAndBack); 
     4034        } 
     4035 
    40134036        // these are non-overlapping sets 
    40144037        pOverall = pFront + pBack + pFrontAndBack; 
    4015  
    4016         ViewCellContainer::const_iterator vit, vit_end = collectedViewCells.end(); 
    4017  
    4018         // evaluate view cells volume contribution with respect to mail box 
    4019         for (vit = collectedViewCells.begin(); vit != vit_end; ++ vit) 
    4020         { 
    4021                 AddViewCellVolumeContri(*vit, pFront, pBack, pFrontAndBack); 
    4022         } 
    4023  
    40244038 
    40254039        //-- pvs rendering heuristics 
     
    42884302        { 
    42894303                VssRay *ray = *rit; 
     4304 
    42904305                float minT, maxT; 
    42914306                static Ray hray; 
     
    44984513{ 
    44994514        SplitCandidate *splitCandidate = mTQueue.Top(); 
    4500  
    4501         cout << "next candidate: " << splitCandidate->Type() 
    4502                 << ", priority: " << splitCandidate->GetPriority() << endl; 
    4503  
    45044515        mTQueue.Pop(); 
    45054516 
     
    45474558                                                                        mVspTree.mBoundingBox); 
    45484559 
    4549 #if WORK_WITH_VIEWCELL_PVS 
    4550          
    45514560        // create first view cell 
    45524561        mVspTree.CreateViewCell(vData, false); 
    45534562                 
     4563#if WORK_WITH_VIEWCELL_PVS 
     4564         
    45544565        // add first view cell to all the objects view cell pvs 
    45554566        ObjectPvsMap::const_iterator oit,  
     
    47364747                        ++ mGlobalCostMisses; 
    47374748 
    4738                 /*              cout << "nodes: " << ++ numNodes << endl; 
     4749                /*               
     4750                cout << "nodes: " << ++ numNodes << endl; 
    47394751                Debug << "\n**********" << endl 
    47404752                          << "total cost: " << mTotalCost << " render cost decr: "  
     
    47434755*/ 
    47444756                //-- subdivide leaf node 
     4757 
    47454758                if (SubdivideSplitCandidate(splitCandidate)) 
    47464759                { 
     4760                        // subdivision successful 
    47474761                        EvalSubdivisionStats(*splitCandidate); 
    47484762                 
     
    47524766                        if (repair) 
    47534767                                RepairQueue(); 
     4768 
     4769                        cout << "candidate: " << splitCandidate->Type() << ", priority: " << splitCandidate->GetPriority() << endl; 
    47544770                } 
    47554771 
     
    47634779                                                                  AxisAlignedBox3 *forcedViewSpace) 
    47644780{ 
     4781        // rays clipped in view space and in object space 
    47654782        RayInfoContainer *viewSpaceRays = new RayInfoContainer(); 
    47664783        RayInfoContainer *objectSpaceRays = new RayInfoContainer(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.h

    r1176 r1178  
    451451 
    452452        SplitCandidate *GetSplitCandidate() const  
    453         { return mSplitCandidate; } 
     453        {  
     454                return mSplitCandidate;  
     455        } 
    454456 
    455457public: 
     
    10501052                and must be reevaluated. 
    10511053        */ 
    1052         void CollectDirtyCandidates(VspSplitCandidate *sc,  
    1053                 vector<SplitCandidate *> &dirtyList); 
     1054        void CollectDirtyCandidates(VspSplitCandidate *sc, vector<SplitCandidate *> &dirtyList); 
    10541055 
    10551056        /** Rays will be clipped to the bounding box. 
     
    10711072        ViewCellsManager *mViewCellsManager; 
    10721073         
    1073         vector<SortableEntry> *mSplitCandidates; 
     1074        vector<SortableEntry> *mLocalSplitCandidates; 
    10741075 
    10751076        /// Pointer to the root of the tree 
  • GTP/trunk/Lib/Vis/Preprocessing/src/X3dExporter.cpp

    r1168 r1178  
    114114  stream<<"key='0.0 "; 
    115115  int i; 
    116   int size = rays.size() + 2; 
     116  int size = (int)rays.size() + 2; 
    117117  for (i=1; i < size; i++) { 
    118118        stream<<i/(float)(size-1)<<" "; 
  • GTP/trunk/Lib/Vis/QtRenderer/QtRenderer.vcproj

    r1166 r1178  
    2424                                MinimalRebuild="TRUE" 
    2525                                BasicRuntimeChecks="3" 
    26                                 RuntimeLibrary="1" 
     26                                RuntimeLibrary="3" 
    2727                                UsePrecompiledHeader="0" 
    2828                                WarningLevel="3" 
     
    3333                        <Tool 
    3434                                Name="VCLinkerTool" 
    35                                 AdditionalDependencies="Preprocessor.lib qtmain.lib QtGui4d.lib Qt3Support4d.lib QAxContainerd.lib QtCore4d.lib QtOpenGL4.lib xerces-c_2.lib glew32.lib OpenGL32.Lib glu32.lib cg.lib cgGL.lib" 
     35                                AdditionalDependencies="Preprocessor.lib qtmain.lib QtGui4.lib Qt3Support4.lib QAxContainerd.lib QtCore4.lib QtOpenGL4.lib xerces-c_2.lib glew32.lib OpenGL32.Lib glu32.lib cg.lib cgGL.lib" 
    3636                                OutputFile="$(OutDir)/QtRenderer.dll" 
    3737                                LinkIncremental="2" 
Note: See TracChangeset for help on using the changeset viewer.