Changeset 1789 for GTP/trunk


Ignore:
Timestamp:
11/25/06 00:19:18 (18 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
10 edited

Legend:

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

    r1787 r1789  
    304304        Environment::GetSingleton()->GetIntValue("BvHierarchy.minRaysForVisibility", mMinRaysForVisibility); 
    305305        Environment::GetSingleton()->GetIntValue("BvHierarchy.maxTests", mMaxTests); 
    306         //      Environment::GetSingleton()->GetBoolValue("BvHierarchy.Construction.useInitialSubdivision", mApplyInitialPartition); 
     306        Environment::GetSingleton()->GetBoolValue("BvHierarchy.Construction.useInitialSubdivision", mApplyInitialPartition); 
    307307        Environment::GetSingleton()->GetIntValue("BvHierarchy.Construction.Initial.minObjects", mInitialMinObjects); 
    308308        Environment::GetSingleton()->GetFloatValue("BvHierarchy.Construction.Initial.maxAreaRatio", mInitialMaxAreaRatio); 
     
    957957 
    958958                const bool noValidSplit = ((objectsLeft <= Limits::Small) || (objectsRight <= Limits::Small)); 
    959                 const float sum =  noValidSplit ? 1e25 : objectsLeft * al + objectsRight * ar; 
     959                const float sum = noValidSplit ? 1e25 : objectsLeft * al + objectsRight * ar; 
    960960       
    961961                /*cout << "pos=" << (*cit).mPos << "\t q=(" << objectsLeft << "," << objectsRight <<")\t r=("  
     
    15531553                        } 
    15541554 
     1555                        // no good results for degenerate axis split 
     1556                        if (0 && tData.mNode->GetBoundingBox().Size(axis) < Limits::Small) 
     1557                                        nCostRatio[axis] += 9999; 
     1558 
    15551559                        if ((bestAxis == -1) || (nCostRatio[axis] < nCostRatio[bestAxis])) 
    15561560                        { 
     
    21492153                new BvhSubdivisionCandidate(oData); 
    21502154 
    2151         // evaluate priority 
    2152         EvalSubdivisionCandidate(*oSubdivisionCandidate); 
    21532155        bvhLeaf->SetSubdivisionCandidate(oSubdivisionCandidate); 
    21542156 
     
    21562158        mPvsEntries = CountViewCells(objects); 
    21572159 
    2158         PrintSubdivisionStats(*oSubdivisionCandidate); 
    2159          
    21602160        if (mApplyInitialPartition) 
    21612161        { 
    2162                 ApplyInitialSubdivision(oSubdivisionCandidate, tQueue);          
     2162                vector<SubdivisionCandidate *> candidateContainer; 
     2163 
     2164                mIsInitialSubdivision = true; 
     2165                 
     2166                // evaluate priority 
     2167                EvalSubdivisionCandidate(*oSubdivisionCandidate); 
     2168                PrintSubdivisionStats(*oSubdivisionCandidate); 
     2169 
     2170                ApplyInitialSubdivision(oSubdivisionCandidate, candidateContainer);              
     2171 
     2172                mIsInitialSubdivision = false; 
     2173 
     2174                vector<SubdivisionCandidate *>::const_iterator cit, cit_end = candidateContainer.end(); 
     2175 
     2176                for (cit = candidateContainer.begin(); cit != cit_end; ++ cit) 
     2177                { 
     2178                        // reevaluate priority 
     2179                        EvalSubdivisionCandidate(*oSubdivisionCandidate); 
     2180                        tQueue.Push(*cit); 
     2181                } 
    21632182        } 
    21642183        else 
    21652184        { 
     2185                // evaluate priority 
     2186                EvalSubdivisionCandidate(*oSubdivisionCandidate); 
     2187                PrintSubdivisionStats(*oSubdivisionCandidate); 
     2188 
    21662189                tQueue.Push(oSubdivisionCandidate); 
    21672190        } 
     2191                 
    21682192        cout << "!!size: " << GetStatistics().Leaves() << endl; 
    21692193} 
     
    25102534 
    25112535void BvHierarchy::ApplyInitialSubdivision(SubdivisionCandidate *firstCandidate, 
    2512                                                                                   SplitQueue &tQueue) 
    2513 { 
    2514         mIsInitialSubdivision = true; 
    2515  
     2536                                                                                  vector<SubdivisionCandidate *> &candidateContainer) 
     2537{ 
    25162538        SplitQueue tempQueue; 
    25172539        tempQueue.Push(firstCandidate); 
     
    25232545                BvhSubdivisionCandidate *bsc =  
    25242546                        dynamic_cast<BvhSubdivisionCandidate *>(candidate); 
    2525                 cout << "§§§§§§§§here49 "<< bsc->mParentData.mSortedObjects[3]->size() << " " << mInitialMinObjects << endl; 
    25262547 
    25272548                const bool globalCriteriaMet = GlobalTerminationCriteriaMet(bsc->mParentData); 
    25282549 
    25292550                if (!InitialTerminationCriteriaMet(bsc->mParentData)) 
    2530                 { 
    2531                         cout << "here9"<<bsc->mParentData.mNode->mObjects.size()<<endl; 
     2551                {cout << "here9"<<endl; 
    25322552                        BvhNode *node = Subdivide(tempQueue, bsc, globalCriteriaMet); 
    25332553 
     
    25362556                } 
    25372557                else // initial preprocessing  finished for this candidate 
    2538                 {cout << "here14"<<endl; 
     2558                {cout << "here19"<<endl; 
    25392559                        // add to "real" traversal queue 
    2540                         tQueue.Push(bsc); 
    2541                 } 
    2542         } 
    2543  
    2544         mIsInitialSubdivision = false; 
     2560                        candidateContainer.push_back(bsc); 
     2561                } 
     2562        } 
    25452563} 
    25462564 
     
    25502568                                                                        ObjectContainer &backObjects) 
    25512569{ 
    2552         cout << "*******here54 "<<tData.mSortedObjects[3]->size()<<endl; 
    25532570        ObjectContainer *objects = tData.mSortedObjects[3]; 
    25542571 
     
    25632580 
    25642581        ObjectContainer::const_iterator backObjectsStart = objects->begin(); 
    2565  
    2566     for (oit = objects->begin(); oit != (objects->end() - 1); ++ oit) 
     2582int dummy = 0; 
     2583    for (oit = objects->begin(); oit != (objects->end() - 1); ++ oit, ++ dummy) 
    25672584        { 
    25682585                Intersectable *objS = *oit; 
     
    25742591                if (areaDiff > maxAreaDiff) 
    25752592                { 
    2576                         //cout << "here5 " << areaDiff << " " << maxAreaDiff << endl; 
    25772593                        maxAreaDiff = areaDiff; 
     2594                        //cout << "maxAreaDiff : " << maxAreaDiff << " " << dummy << " " << objects->size() - dummy <<  endl; 
    25782595                        backObjectsStart = oit + 1; 
    25792596                } 
     
    25832600        for (oit = objects->begin(); oit != backObjectsStart; ++ oit) 
    25842601        { 
    2585                 backObjects.push_back(*oit); 
     2602                frontObjects.push_back(*oit); 
    25862603        } 
    25872604 
     
    25892606        for (oit = backObjectsStart; oit != oit_end; ++ oit) 
    25902607        { 
    2591                 frontObjects.push_back(*oit); 
    2592         } 
     2608                backObjects.push_back(*oit); 
     2609        } 
     2610        TriangleIntersectable *tObj1 = (TriangleIntersectable *)frontObjects.back(); 
     2611        TriangleIntersectable *tObj2 = (TriangleIntersectable *)backObjects.front(); 
     2612 
     2613        cout << "here4 " << tObj1->GetItem().GetArea() << " " << tObj2->GetItem().GetArea() << endl; 
     2614 
     2615 
     2616if (maxAreaDiff < 0.0001) 
     2617cout << "big error!!!! " << maxAreaDiff << endl; 
     2618 
     2619        cout << "front: " << (int)frontObjects.size() << " back " << (int)backObjects.size() << " " << backObjects.front()->GetBox().SurfaceArea() - frontObjects.back()->GetBox().SurfaceArea() << endl; 
    25932620} 
    25942621 
  • GTP/trunk/Lib/Vis/Preprocessing/src/BvHierarchy.h

    r1786 r1789  
    887887        */ 
    888888        void ApplyInitialSubdivision(SubdivisionCandidate *firstCandidate, 
    889                                                                  SplitQueue &tQueue); 
     889                                                                 vector<SubdivisionCandidate *> &candidateContainer); 
    890890 
    891891        void ApplyInitialSplit(const BvhTraversalData &tData, 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp

    r1787 r1789  
    20202020         
    20212021                ObjectPvs pvs; 
    2022                 //GetPvsRecursive(vc, pvs); 
    2023                  
    2024                 // uses mailing 
    2025                 // warning: pvs not sorted!! 
     2022                                 
    20262023                if (vc->GetPvs().Empty()) 
    20272024                { 
     2025                        // warning: uses mailing, pvs not sorted!! 
    20282026                        GetPvsEfficiently(vc, pvs); 
     2027                        //GetPvsRecursive(vc, pvs); 
    20292028                        vc->SetPvs(pvs); 
    20302029                        //cout << "q"; 
     
    21052104        //-- or the reverse order of subdivision for subdivision-only  
    21062105        //-- view cell hierarchies. 
    2107          
     2106 
    21082107        while (!tQueue.Empty()) 
    21092108        { 
     
    21142113                int entriesIncr;  
    21152114 
    2116         if (nextCandidate->Type() == SubdivisionCandidate::VIEW_SPACE) 
     2115                if (nextCandidate->Type() == SubdivisionCandidate::VIEW_SPACE) 
    21172116                { 
    21182117                        timeStamp = (int)-nextCandidate->GetPriority(); 
     
    21202119                        VspNode *newNode = mVspTree->SubdivideAndCopy(tQueue, nextCandidate); 
    21212120                        VspNode *oldNode = (VspNode *)nextCandidate->mEvaluationHack; 
    2122                          
     2121 
    21232122                        isLeaf = newNode->IsLeaf(); 
    21242123                        //subStats.mRenderCostDecrease = oldNode->mRenderCostDecr; 
     
    21282127                { 
    21292128                        timeStamp = (int)-nextCandidate->GetPriority(); 
    2130                          
     2129 
    21312130                        BvhNode *newNode = mBvHierarchy->SubdivideAndCopy(tQueue, nextCandidate); 
    21322131                        BvhNode *oldNode = (BvhNode *)nextCandidate->mEvaluationHack; 
    2133                          
     2132 
    21342133                        isLeaf = newNode->IsLeaf(); 
    21352134                        //subStats.mRenderCostDecrease = oldNode->mRenderCostDecr; 
    21362135                        //entriesIncr = oldNode->mPvsEntriesIncr; 
    21372136                }                
    2138                                  
     2137 
    21392138                if (!isLeaf) 
    21402139                { 
     
    21642163 
    21652164                        subStats.Print(stats); 
    2166                          
     2165 
    21672166                } 
    21682167 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h

    r1786 r1789  
    3232        template<typename T, typename S> 
    3333        friend int operator< (const PvsEntry<T, S> &a, const PvsEntry<T, S> &b); 
     34        template<typename T, typename S> 
     35        friend int operator== (const PvsEntry<T, S> &a, const PvsEntry<T, S> &b); 
    3436}; 
    3537 
     
    3941{ 
    4042        return a.mObject < b.mObject; 
     43}  
     44 
     45template<typename T, typename S> 
     46int operator== (const PvsEntry<T, S> &a, const PvsEntry<T, S> &b) 
     47{ 
     48        return a.mObject == b.mObject; 
    4149}  
    4250 
     
    5159}; 
    5260 
     61template<typename T, typename S> 
     62int equalSample (const PvsEntry<T, S> &a, const PvsEntry<T, S> &b) 
     63{ 
     64        return a.mObject == b.mObject; 
     65}  
    5366 
    5467/** Information stored with a PVS entry. Consists of the number 
     
    189202 
    190203        /** Finds sample in PVS. 
     204                @param checkDirty if dirty part of the pvs should be checked for entry  
     205                        (warning: linear runtime in dirty part) 
    191206                @returns iterator on the sample. 
    192207        */ 
    193         typename vector<PvsEntry<T, S> >::iterator Find(T sample); 
     208        typename vector<PvsEntry<T, S> >::iterator Find(T sample, const bool checkDirty = true); 
    194209 
    195210        bool GetSampleContribution(T sample, const float pdf, float &contribution); 
     
    199214                @returns true if sample was not already in PVS. 
    200215        */ 
    201         bool AddSample(T sample, const float pdf, float &contribution); 
     216        //bool AddSample(T sample, const float pdf, float &contribution); 
    202217 
    203218        /** Adds sample to PVS. 
     
    206221        float AddSample(T sample, const float pdf); 
    207222 
    208   /** Adds sample to PVS without checking for presence of the sample 
    209           pvs remians unsorted! 
    210   */ 
    211   void AddSampleDirty(T sample, const float pdf); 
    212  
    213   /** Sort pvs entries - this should always be called after a 
    214           sequence of AddSampleDirty calls */ 
    215   void Sort(); 
    216    
     223        /** Adds sample to PVS without checking for presence of the sample 
     224                pvs remains unsorted! 
     225        */ 
     226        void AddSampleDirty(T sample, const float pdf); 
     227 
     228        /** Adds sample dirty (on the end of the vector) but 
     229                first checks if sample is already in clean part of the pvs. 
     230        */ 
     231        bool AddSampleDirtyCheck(T sample, const float pdf);//, float &contribution); 
     232 
     233        /** Sort pvs entries - this should always be called after a 
     234                sequence of AddSampleDirty calls  
     235        */ 
     236        void Sort(); 
     237 
    217238        /** Adds sample to PVS. Assumes that the pvs is sorted 
    218239                @returns contribution of sample (0 or 1) 
     
    266287        static void Merge(Pvs<T, S> &mergedPvs, const Pvs<T, S> &a, const Pvs<T, S> &b); 
    267288 
     289        static void Merge(Pvs<T, S> &mergedPvs,  
     290                                          const typename std::vector<PvsEntry<T, S> >::const_iterator &aBegin, 
     291                                          const typename std::vector<PvsEntry<T, S> >::const_iterator &aEnd, 
     292                                          const typename std::vector<PvsEntry<T, S> >::const_iterator &bBegin, 
     293                                          const typename std::vector<PvsEntry<T, S> >::const_iterator &bEnd, 
     294                                          const int aSamples,  
     295                                          const int bSamples); 
     296 
    268297        int GetSamples() const 
    269298        { 
    270299                return mSamples; 
     300        } 
     301 
     302 
     303        bool IsDirty() const 
     304        { 
     305                return mLastSorted < mEntries.size(); 
     306        } 
     307 
     308        bool RequiresResort() const 
     309        { 
     310                // the last part should not be more than log of the sorted part. this 
     311                // way we can achieve logarithmic behaviour for insertion and find 
     312                const int dirtySize = (int)mEntries.size() - mLastSorted; 
     313                return dirtySize > (int)(log((double)mEntries.size()) / log(2.0)); 
     314        } 
     315 
     316 
     317        int GetLastSorted() const 
     318        { 
     319                return mLastSorted; 
    271320        } 
    272321 
     
    281330        int mSamples; 
    282331   
    283   /// Last sorted entry in the pvs (important for find and merge 
    284   int mLastSorted; 
    285    
     332        /// Last sorted entry in the pvs (important for find and merge) 
     333        int mLastSorted;   
    286334}; 
    287335 
     
    293341        mEntries = samples; 
    294342        mLastSorted = 0; 
    295 } 
     343        mSamples = samples.size(); 
     344} 
     345 
    296346 
    297347template <typename T, typename S> 
    298348void Pvs<T, S>::Sort() 
    299349{ 
    300   std::vector<PvsEntry<T, S> >::iterator it = mEntries.begin(); 
    301   it.inc(mLastSorted); 
    302   sort(it, mEntries.end()); 
    303   mLastSorted = mEntries.size() - 1; 
    304 } 
     350        std::vector<PvsEntry<T, S> >::iterator it = mEntries.begin() + mLastSorted; 
     351        //std::vector<PvsEntry<T, S> >::const_iterator it = mEntries.begin() + mLastSorted; 
     352        std::vector<PvsEntry<T, S> >::iterator it_end = mEntries.end(); 
     353 
     354        // throw out double entries 
     355        std::vector<PvsEntry<T, S> >::iterator newEnd = unique(it, it_end); 
     356        sort(it, newEnd); 
     357        //sort(mEntries.begin(), mEntries.end()); 
     358 
     359        // now merge sorted ranges 
     360        ObjectPvs newPvs; 
     361        Merge(newPvs,  
     362                  mEntries.begin(), it,  
     363                  it, newEnd,  
     364                  mSamples, 0); 
     365         
     366        mEntries = newPvs.mEntries; 
     367        mLastSorted = (int)mEntries.size(); 
     368} 
     369 
    305370 
    306371/** 
     
    436501        std::vector<PvsEntry<T, S> >::const_iterator bit = b.mEntries.begin(), bit_end = b.mEntries.end(); 
    437502         
    438         for (; (ait != ait_end); ++ ait) 
     503        Merge(mergedPvs,  
     504                  ait, ait_end, 
     505                  bit, bit_end, 
     506                  a.mSamples, 
     507                  b.mSamples); 
     508} 
     509 
     510 
     511template <typename T, typename S> 
     512void Pvs<T, S>::Merge(Pvs<T, S> &mergedPvs,  
     513                                          const typename std::vector<PvsEntry<T, S> >::const_iterator &aBegin, 
     514                                          const typename std::vector<PvsEntry<T, S> >::const_iterator &aEnd, 
     515                                          const typename std::vector<PvsEntry<T, S> >::const_iterator &bBegin, 
     516                                          const typename std::vector<PvsEntry<T, S> >::const_iterator &bEnd, 
     517                                          const int aSamples,  
     518                                          const int bSamples) 
     519{ 
     520        std::vector<PvsEntry<T, S> >::const_iterator ait = aBegin; 
     521        std::vector<PvsEntry<T, S> >::const_iterator bit = bBegin; 
     522         
     523        for (; (ait != aEnd); ++ ait) 
    439524        { 
    440525                Intersectable *aObj = (*ait).mObject; 
    441526                Intersectable *bObj = NULL; 
    442                 PvsEntry<T, S> aEntry = (*ait); 
    443  
    444                 for (; (bit != bit_end) && ((*bit).mObject <= (*ait).mObject); ++ bit) 
     527                //Intersectable *bObjOld = NULL; 
     528         
     529                const PvsEntry<T, S> &aEntry = (*ait); 
     530 
     531                for (; (bit != bEnd) && ((*bit).mObject <= (*ait).mObject); ++ bit) 
    445532                { 
    446533                        bObj = (*bit).mObject; 
     
    457544                                mergedPvs.mEntries.push_back(*bit); 
    458545                        } 
     546                         
     547                        //bObjOld = bObj; 
    459548                } 
    460549 
     
    468557 
    469558        // add the rest 
    470         for (; (bit != bit_end); ++ bit) 
     559        for (; (bit != bEnd); ++ bit) 
    471560        { 
    472561                mergedPvs.mEntries.push_back(*bit); 
    473562        } 
    474         mergedPvs.mSamples = a.mSamples + b.mSamples; 
     563 
     564        mergedPvs.mSamples = aSamples + bSamples; 
    475565} 
    476566 
     
    480570        mEntries.clear(); 
    481571        mSamples = 0; 
     572        mLastSorted = 0; 
    482573 
    483574        if (trim) 
     
    495586 
    496587template <typename T, typename S>  
    497 typename std::vector<PvsEntry<T, S> >::iterator Pvs<T, S>::Find(T sample) 
     588typename std::vector<PvsEntry<T, S> >::iterator Pvs<T, S>::Find(T sample, const bool checkDirty) 
    498589{ 
    499590        PvsEntry<T, S> dummy(sample, PvsData()); 
    500         vector<PvsEntry<T, S> >::iterator it = lower_bound(mEntries.begin(), mEntries.end(), dummy); 
    501                                  
     591 
     592        // only check clean part 
     593        //mLastSorted = 0; 
     594        vector<PvsEntry<T, S> >::iterator sorted_end = mEntries.begin() + mLastSorted; 
     595if (sorted_end != mEntries.end()) 
     596cout << "not entries end!! " << endl; 
     597        // binary search 
     598        vector<PvsEntry<T, S> >::iterator it = lower_bound(mEntries.begin(), sorted_end, dummy); 
     599 
     600        // sample not found yet => search further in the unsorted part 
     601        if (checkDirty && 
     602                ((it == mEntries.end()) || ((*it).mObject != sample))) 
     603        { 
     604                vector<PvsEntry<T, S> >::const_iterator it_end = mEntries.end(); 
     605                for (it = sorted_end; (it != it_end) && ((*it).mObject != sample); ++ it); 
     606        } 
     607        else cout << "f "; 
    502608        return it; 
    503609} 
     
    519625{ 
    520626        ++ mSamples; 
     627        cout << "! "; 
    521628        std::vector<PvsEntry<T, S> >::iterator it = Find(sample); 
    522629 
    523630        if ((it != mEntries.end()) && ((*it).mObject == sample)) 
    524         { 
     631        {       cout << "g"; 
    525632                S &data = (*it).mData; 
    526633                data.mSumPdf += pdf; 
     
    528635        } 
    529636        else  
    530         { 
     637        {cout << "t"; 
    531638                PvsEntry<T, S> entry(sample, pdf); 
    532639                mEntries.insert(it, entry); 
     640                ++ mLastSorted; 
    533641                return pdf; 
    534642        } 
     643        cout << " $"; 
    535644} 
    536645 
     
    539648void Pvs<T, S>::AddSampleDirty(T sample, const float pdf) 
    540649{ 
    541   ++ mSamples; 
    542   mEntries.push_back(PvsEntry<T, S>(sample, pdf)); 
     650        ++ mSamples; 
     651        mEntries.push_back(PvsEntry<T, S>(sample, pdf)); 
    543652} 
    544653                                          
     
    548657{ 
    549658        ++ mSamples; 
     659         
    550660        std::vector<PvsEntry<T, S> >::iterator it = Find(sample); 
    551661 
     
    559669                PvsEntry<T, S> entry(sample, pdf); 
    560670                mEntries.insert(it, entry); 
     671                ++ mLastSorted; 
    561672        } 
    562673 
     
    565676 
    566677 
    567 template <typename T, typename S>  
     678/*template <typename T, typename S>  
    568679bool Pvs<T, S>::AddSample(T sample, 
    569680                                                  const float pdf, 
     
    589700                mEntries.insert(it, entry); 
    590701                contribution = 1.0f; 
     702                ++ mLastSorted; 
     703 
     704                return true; 
     705        } 
     706}*/ 
     707 
     708 
     709/** Adds sample dirty (on the end of the vector) but 
     710        first checks if sample is already in clean part of the pvs. 
     711*/ 
     712template <typename T, typename S>  
     713bool Pvs<T, S>::AddSampleDirtyCheck(T sample, 
     714                                                                        const float pdf) 
     715                                                                        //,float &contribution) 
     716{ 
     717        ++ mSamples; 
     718 
     719        std::vector<PvsEntry<T, S> >::iterator it = Find(sample); 
     720 
     721        if ((it != mEntries.end()) && ((*it).mObject == sample)) 
     722        { 
     723                S &data = (*it).mData; 
     724 
     725                data.mSumPdf += pdf; 
     726                //contribution = pdf / data.mSumPdf; 
     727 
     728                return false; 
     729        } 
     730        else  
     731        { 
     732                AddSampleDirty(sample, pdf); 
     733                //contribution = 1.0f; 
    591734 
    592735                return true; 
     
    620763{ 
    621764        -- mSamples; 
    622  
     765         
    623766        std::vector<PvsEntry<T, S> >::iterator it = Find(sample); 
    624767 
     
    633776        { 
    634777                mEntries.erase(it); 
     778                -- mLastSorted; // wrong if sample was in tail!! 
    635779        } 
    636780 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp

    r1786 r1789  
    263263                                                        float &contribution) 
    264264{  
    265         const bool result = mPvs.AddSample(sample, pdf, contribution); 
     265        const bool result = mPvs.AddSample(sample, pdf);//, contribution); 
    266266        // have to recompute pvs size 
    267267        mPvsSizeValid = false; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp

    r1715 r1789  
    26992699                if (!ray->intersections.empty()) 
    27002700                  contribution += vc->GetPvs().AddSample(ray->intersections[0].mObject, 
    2701                                                                                                  1.0f, 
    2702                                                                                                  relContribution); 
     2701                                                                                                 1.0f); 
     2702                                                                                                 //relContribution); 
    27032703                 
    27042704                if (ray->sourceObject.mObject) 
    27052705                        contribution += vc->GetPvs().AddSample(ray->sourceObject.mObject, 
    2706                                                                                                    1.0f, 
    2707                                                                                                    relContribution); 
     2706                                                                                                   1.0f); 
     2707                                                                                                   //relContribution); 
    27082708                 
    27092709                if (contribution) 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1787 r1789  
    19561956} 
    19571957 
    1958  
     1958/* 
    19591959void 
    19601960ViewCellsManager::AddSampleContributions(const VssRayContainer &rays) 
     
    19641964 
    19651965  VssRayContainer::const_iterator it, it_end = rays.end(); 
    1966  
     1966cout <<"here60"<<endl; 
    19671967  for (it = rays.begin(); it != it_end; ++ it) { 
    19681968        AddSampleContributions(*(*it)); 
    19691969  } 
    19701970} 
    1971  
     1971*/ 
    19721972 
    19731973int ViewCellsManager::GetMinPvsSize() const 
     
    19831983} 
    19841984 
    1985  
     1985/* 
    19861986void 
    19871987ViewCellsManager::AddSampleContributions(VssRay &ray) 
    1988 { 
     1988{cout << "here12" << endl; 
    19891989        // assumes viewcells have been stored... 
    19901990        ViewCellContainer *viewcells = &ray.mViewCells; 
     
    20082008        } 
    20092009} 
    2010  
     2010*/ 
    20112011 
    20122012float ViewCellsManager::ComputeSampleContribution(VssRay &ray, 
    20132013                                                                                                  const bool addRays, 
    20142014                                                                                                  const bool storeViewCells) 
    2015 { 
     2015{cout << "$$$$$$$$$$$$$4here10" << endl; 
    20162016        ViewCellContainer viewcells; 
    20172017 
     
    34703470        if (sortViewCells) 
    34713471        {       // sort view cells to visualize the largest view cells 
    3472                 stable_sort(mViewCells.begin(), mViewCells.end(), ViewCell::LargerRenderCost); 
     3472                sort(mViewCells.begin(), mViewCells.end(), ViewCell::LargerRenderCost); 
    34733473        } 
    34743474 
     
    48244824        { 
    48254825                // sort view cells to visualize the largest view cells 
    4826                 stable_sort(mViewCells.begin(), mViewCells.end(), ViewCell::LargerRenderCost); 
     4826                sort(mViewCells.begin(), mViewCells.end(), ViewCell::LargerRenderCost); 
    48274827        } 
    48284828 
     
    52785278 
    52795279 
    5280 VspOspViewCellsManager::VspOspViewCellsManager(ViewCellsTree *vcTree, const string &hierarchyType) 
     5280VspOspViewCellsManager::VspOspViewCellsManager(ViewCellsTree *vcTree,  
     5281                                                                                           const string &hierarchyType) 
    52815282: ViewCellsManager(vcTree) 
    52825283{ 
     
    52975298        mHierarchyManager->SetViewCellsTree(mViewCellsTree); 
    52985299} 
     5300 
    52995301 
    53005302Intersectable * 
     
    53075309#endif 
    53085310} 
     5311 
    53095312 
    53105313HierarchyManager *VspOspViewCellsManager::CreateHierarchyManager(const string &hierarchyType) 
     
    56755678        Exporter *exporter = Exporter::GetExporter("final_view_cells.wrl"); 
    56765679 
    5677         Vector3 scale(0.9f, 0.9f, 0.9f); 
     5680        //Vector3 scale(0.9f, 0.9f, 0.9f); 
     5681        Vector3 scale(1.0f, 1.0f, 1.0f); 
     5682 
    56785683        if (exporter) 
    56795684        { 
     
    57735778        { 
    57745779                // sort view cells to visualize the view cells with highest render cost 
    5775                 stable_sort(mViewCells.begin(), mViewCells.end(), ViewCell::LargerRenderCost); 
     5780                sort(mViewCells.begin(), mViewCells.end(), ViewCell::LargerRenderCost); 
    57765781        } 
    57775782 
     
    60556060        float tmin = 0, tmax = 1.0; 
    60566061 
    6057          
    60586062        if (!GetViewSpaceBox().GetRaySegment(hray, tmin, tmax) || (tmin > tmax)) 
    60596063                return 0; 
     
    60696073        if (storeViewCells) 
    60706074        {        
    6071           // copy viewcells memory efficiently 
    6072           ray.mViewCells.reserve(viewcells.size()); 
    6073           ray.mViewCells = viewcells; 
     6075                // copy viewcells memory efficiently 
     6076                ray.mViewCells.reserve(viewcells.size()); 
     6077                ray.mViewCells = viewcells; 
    60746078        } 
    60756079 
     
    60786082        Intersectable *terminationObj = GetIntersectable(ray, true); 
    60796083        Intersectable *originObj = GetIntersectable(ray, false); 
    6080            
    6081         for (; it != viewcells.end(); ++ it) { 
    6082           ViewCell *viewcell = *it; 
    6083            
    6084           if (viewcell->GetValid()) 
     6084 
     6085        for (; it != viewcells.end(); ++ it)  
     6086        { 
     6087                ViewCell *viewcell = *it; 
     6088 
     6089                if (viewcell->GetValid()) 
    60856090                {       // if ray not outside of view space 
    6086                   float contribution; 
    6087                    
    6088                   if (terminationObj)  
     6091                        float contribution; 
     6092 
     6093                        if (terminationObj)  
    60896094                        { 
    6090                           // todo: maybe not correct for kd node pvs 
    6091                           if (viewcell->GetPvs().GetSampleContribution( 
    6092                                                                                                                    terminationObj, ray.mPdf, contribution)) 
     6095                                // todo: maybe not correct for kd node pvs 
     6096                        /*      if (viewcell->GetPvs().GetSampleContribution( 
     6097                                        terminationObj, ray.mPdf, contribution)) 
    60936098                                { 
    6094                                   ++ ray.mPvsContribution; 
     6099                                        ++ ray.mPvsContribution; 
    60956100                                } 
    6096                            
    6097                           ray.mRelativePvsContribution += contribution; 
     6101                                ray.mRelativePvsContribution += contribution;*/ 
    60986102                        } 
    6099                          
    6100                   //////////////// 
    6101                   //-- for directional sampling it is important to count  
    6102                   //-- only contributions made in one direction! 
    6103                   //-- the other contributions of this sample will be counted for the opposite ray! 
    6104                    
     6103 
     6104                        //////////////// 
     6105                        //-- for directional sampling it is important to count  
     6106                        //-- only contributions made in one direction! 
     6107                        //-- the other contributions of this sample will be counted for the opposite ray! 
     6108 
    61056109#if SAMPLE_ORIGIN_OBJECTS 
    6106                    
    6107                   if (originObj &&  
    6108                           viewcell->GetPvs().GetSampleContribution(originObj, 
    6109                                                                                                           ray.mPdf, 
    6110                                                                                                           contribution)) 
     6110 
     6111                /*      if (originObj &&  
     6112                                viewcell->GetPvs().GetSampleContribution(originObj, 
     6113                                                                                                                ray.mPdf, 
     6114                                                                                                                contribution)) 
    61116115                        { 
    6112                           ++ ray.mPvsContribution; 
    6113                           ray.mRelativePvsContribution += contribution; 
    6114                         } 
     6116                                ++ ray.mPvsContribution; 
     6117                                ray.mRelativePvsContribution += contribution; 
     6118                        }*/ 
    61156119#endif 
    61166120                } 
    61176121        } 
    6118          
     6122 
    61196123        if (!addRays) 
    61206124        { 
     
    61316135 
    61326136                //$$JB hack 
    6133                 viewCell->GetPvs().AddSample(terminationObj, ray.mPdf); 
    6134                  
     6137                float contrib; 
     6138                //viewCell->GetPvs().AddSampleDirtyCheck(terminationObj, ray.mPdf, contrib); 
     6139                viewCell->GetPvs().AddSample(terminationObj, ray.mPdf);//, contrib); 
     6140 
     6141                if (viewCell->GetPvs().GetSize() == 50) 
     6142                //if (viewCell->GetPvs().RequiresResort()) 
     6143                {Intersectable::NewMail(); 
     6144                cout << "\nbefore sort: " << viewCell->GetPvs().GetLastSorted() << " \n"; 
     6145                        ObjectPvsIterator pit = viewCell->GetPvs().GetIterator(); int i = 0; 
     6146                        while (pit.HasMoreEntries()) 
     6147                        {                
     6148                                ObjectPvsEntry entry = pit.Next(); 
     6149                Intersectable *object = entry.mObject; 
     6150 
     6151                                if ((i ++) == viewCell->GetPvs().GetLastSorted()) 
     6152                                        cout << "| "; 
     6153                                 
     6154                                //if (object->Mailed()) cout << "error!!"<<endl; 
     6155                                object->Mail(); 
     6156                                cout << (int)object << " "; 
     6157                        } 
     6158 
     6159                        //viewCell->GetPvs().Sort(); 
     6160                         
     6161                        /*cout << "\nafter sort\n"; 
     6162                        pit = viewCell->GetPvs().GetIterator(); i = 0; 
     6163                        while (pit.HasMoreEntries()) 
     6164                        {                
     6165                                ObjectPvsEntry entry = pit.Next(); 
     6166                Intersectable *object = entry.mObject; 
     6167 
     6168                                if ((i ++) == viewCell->GetPvs().GetLastSorted()) 
     6169                                        cout << "| ";    
     6170                                cout << (int)object << " "; 
     6171                        }*/ 
     6172                } 
     6173                //else cout << "b"; 
    61356174#if SAMPLE_ORIGIN_OBJECTS 
    6136                 viewCell->GetPvs().AddSample(originObj, ray.mPdf); 
    6137 #endif                   
    6138         } 
    6139          
     6175                //viewCell->GetPvs().AddSample(originObj, ray.mPdf); 
     6176#endif 
     6177        } 
     6178 
    61406179        return ABS_CONTRIBUTION_WEIGHT*ray.mPvsContribution + 
    6141           (1.0f - ABS_CONTRIBUTION_WEIGHT)*ray.mRelativePvsContribution; 
     6180                (1.0f - ABS_CONTRIBUTION_WEIGHT)*ray.mRelativePvsContribution; 
    61426181} 
    61436182 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r1787 r1789  
    131131        /** Add sample contributions to the viewcells they intersect  
    132132        */ 
    133         void AddSampleContributions(const VssRayContainer &rays); 
     133        //void AddSampleContributions(const VssRayContainer &rays); 
    134134   
    135135 
     
    144144                                                                                        const bool storeViewCells); 
    145145 
    146         virtual void AddSampleContributions(VssRay &ray); 
     146        //virtual void AddSampleContributions(VssRay &ray); 
    147147 
    148148        /** Prints out statistics of the view cells. 
  • GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp

    r1773 r1789  
    13571357        // C = ct_div_ci  + (ql*rl + qr*rr)/queries 
    13581358 
    1359         int pvsl = 0; 
    1360         int pvsr = pvsSize; 
    1361  
    1362         int pvsBack = pvsl; 
    1363         int pvsFront = pvsr; 
     1359        float pvsl = 0; 
     1360        float pvsr = (float)pvsSize; 
     1361 
     1362        float pvsBack = pvsl; 
     1363        float pvsFront = pvsr; 
    13641364 
    13651365        float sum = (float)pvsSize * sizeBox; 
     
    15041504        const float pFront = maxBox - position; 
    15051505         
    1506         const float penaltyOld = EvalPvsPenalty(pvsSize, lowerPvsLimit, upperPvsLimit); 
     1506        const float penaltyOld = EvalPvsPenalty((float)pvsSize, lowerPvsLimit, upperPvsLimit); 
    15071507    const float penaltyFront = EvalPvsPenalty(pvsFront, lowerPvsLimit, upperPvsLimit); 
    15081508        const float penaltyBack = EvalPvsPenalty(pvsBack, lowerPvsLimit, upperPvsLimit); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/X3dParser.cpp

    r1627 r1789  
    243243                for (fit = fit_begin; fit != fit_end; ++ fit) 
    244244                { 
    245                         //cout << "f"; 
    246245                        // triangulate the faces 
    247246                        Face *face = *fit; 
Note: See TracChangeset for help on using the changeset viewer.