Changeset 1996


Ignore:
Timestamp:
01/18/07 20:20:48 (17 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
12 edited

Legend:

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

    r1990 r1996  
    13171317 
    13181318        RegisterOption("GvsPreprocessor.stats", 
    1319                                         optString, 
    1320                                         "gvs_stats=", 
    1321                                         "gvsStats.log"); 
    1322          
     1319                optString, 
     1320                "gvs_stats=", 
     1321                "gvsStats.log"); 
     1322 
     1323        RegisterOption("GvsPreprocessor.minContribution", 
     1324                 optInt, 
     1325                 "gvs_min_contribution=", 
     1326                 "50"); 
     1327 
     1328         RegisterOption("GvsPreprocessor.maxViewCells", 
     1329                 optInt, 
     1330                 "gvs_max_viewcells=", 
     1331                 "5"); 
     1332 
     1333 
    13231334  /**********************************************************************/ 
    13241335  /*                     View cells related options                     */ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp

    r1990 r1996  
    1616{ 
    1717   
    18 #define GVS_DEBUG 1 
     18#define GVS_DEBUG 0 
    1919 
    2020struct VizStruct 
     
    3333mSamplingType(SamplingStrategy::VIEWCELL_BASED_DISTRIBUTION), 
    3434//mSamplingType(SamplingStrategy::DIRECTION_BASED_DISTRIBUTION), 
    35 mNumViewCells(0), 
     35mProcessedViewCells(0), 
    3636mCurrentViewCell(NULL) 
    3737{ 
     
    3939        Environment::GetSingleton()->GetIntValue("GvsPreprocessor.initialSamples", mInitialSamples); 
    4040        Environment::GetSingleton()->GetIntValue("GvsPreprocessor.samplesPerPass", mSamplesPerPass); 
     41        Environment::GetSingleton()->GetIntValue("GvsPreprocessor.minContribution", mMinContribution); 
    4142        Environment::GetSingleton()->GetFloatValue("GvsPreprocessor.epsilon", mEps); 
    4243        Environment::GetSingleton()->GetFloatValue("GvsPreprocessor.threshold", mThreshold);     
    4344        Environment::GetSingleton()->GetBoolValue("GvsPreprocessor.perViewCell", mPerViewCell); 
     45        Environment::GetSingleton()->GetIntValue("GvsPreprocessor.maxViewCells", mMaxViewCells); 
    4446 
    4547        char gvsStatsLog[100]; 
     
    5456        Debug << "epsilon: " << mEps << endl; 
    5557        Debug << "stats: " << gvsStatsLog << endl; 
     58        Debug << "per view cell: " << mPerViewCell << endl; 
     59        Debug << "max view cells: " << mMaxViewCells << endl; 
     60        Debug << "min contribution: " << mMinContribution << endl; 
    5661 
    5762        if (1) 
     
    6671GvsPreprocessor::~GvsPreprocessor() 
    6772{ 
     73        ClearRayQueue(); 
     74} 
     75 
     76 
     77void GvsPreprocessor::ClearRayQueue() 
     78{ 
    6879        // clean ray queue 
    6980        while (!mRayQueue.empty()) 
     
    8091bool GvsPreprocessor::NextViewCell() 
    8192{ 
    82         if (mViewCellsManager->GetNumViewCells() == mNumViewCells) 
     93        //if (mViewCellsManager->GetNumViewCells() == mProcessedViewCells) 
     94        //      return false; // no more view cells 
     95 
     96        if (mProcessedViewCells == (int)mViewCells.size()) 
    8397                return false; // no more view cells 
    8498 
    85     if (1) 
    86                 mCurrentViewCell = mViewCellsManager->GetViewCell(mNumViewCells); 
    87         else 
    88         { 
    89                 // HACK 
    90                 int idx = (int)RandomValue(0.0f, (float)mViewCellsManager->GetNumViewCells() - 0.5f); 
    91                 mCurrentViewCell = mViewCellsManager->GetViewCell(idx); 
    92         } 
    93  
    94         if (!mCurrentViewCell->GetMesh()) 
     99        mCurrentViewCell = mViewCells[mProcessedViewCells]; 
     100 
     101   if (!mCurrentViewCell->GetMesh()) 
    95102                mViewCellsManager->CreateMesh(mCurrentViewCell); 
    96103 
    97         ++ mNumViewCells; 
     104        mGvsStats.mViewCellId = mCurrentViewCell->GetId(); 
     105 
     106        Debug << "vc: " << mCurrentViewCell->GetId() << endl; 
     107 
     108        ++ mProcessedViewCells; 
    98109     
    99110        return true; 
     
    101112 
    102113 
    103 bool GvsPreprocessor::CheckDiscontinuity(const VssRay &currentRay, 
    104                                                                                  const Triangle3 &hitTriangle, 
    105                                                                                  const VssRay &oldRay) 
     114int GvsPreprocessor::CheckDiscontinuity(const VssRay &currentRay, 
     115                                                                                const Triangle3 &hitTriangle, 
     116                                                                                const VssRay &oldRay) 
    106117{ 
    107118        // the predicted hitpoint: we expect to hit the same mesh again 
     
    123134 
    124135                if (!newRay) 
    125                         return false; 
     136                        return 1; 
    126137 
    127138                // set flag for visualization 
     
    140151                } 
    141152 
    142                 return true; 
    143         } 
    144  
    145         return false; 
     153                return 1; 
     154        } 
     155 
     156        return 0; 
    146157} 
    147158 
     
    269280                                                                   const VssRay &oldRay) 
    270281{ 
     282        int castRays = 0; 
     283 
    271284        // cast reverse rays if necessary 
    272         CheckDiscontinuity(ray1, hitTriangle, oldRay); 
    273         CheckDiscontinuity(ray2, hitTriangle, oldRay); 
     285        castRays += CheckDiscontinuity(ray1, hitTriangle, oldRay); 
     286        castRays += CheckDiscontinuity(ray2, hitTriangle, oldRay); 
    274287 
    275288        if (EqualVisibility(ray1, ray2) || (Magnitude(p1 - p2) <= MIN_DIST)) 
    276289        { 
    277                 return 0; 
     290                return castRays; 
    278291        } 
    279292         
     
    284297        SimpleRay sray(oldRay.mOrigin, p - oldRay.mOrigin, SamplingStrategy::GVS, 1.0f); 
    285298 
    286         VssRay *newRay = mRayCaster->CastRay(sray, mViewCellsManager->GetViewSpaceBox(), mPerViewCell); 
    287  
    288         if (!newRay) return 0; 
     299        VssRay *newRay = mRayCaster->CastRay(sray, mViewCellsManager->GetViewSpaceBox(), !mPerViewCell); 
     300         
     301        ++ castRays; 
     302 
     303        if (!newRay) return castRays; 
    289304 
    290305        newRay->mFlags |= VssRay::BorderSample; 
     
    294309 
    295310        // subdivide further 
    296         const int samples1 = SubdivideEdge(hitTriangle, p1, p, ray1, *newRay, oldRay); 
    297         const int samples2 = SubdivideEdge(hitTriangle, p, p2, *newRay, ray2, oldRay); 
     311        castRays += SubdivideEdge(hitTriangle, p1, p, ray1, *newRay, oldRay); 
     312        castRays += SubdivideEdge(hitTriangle, p, p2, *newRay, ray2, oldRay); 
    298313 
    299314        // this ray will not be further processed 
     
    301316                delete newRay; 
    302317 
    303         return samples1 + samples2 + 1; 
     318        return castRays; 
    304319} 
    305320 
     
    352367 
    353368        // don't cast double rays as we need only the forward rays 
    354         const bool castDoubleRays = false; 
     369        const bool castDoubleRays = !mPerViewCell; 
    355370        // cannot prune invalid rays because we have to compare adjacent  rays. 
    356371        const bool pruneInvalidRays = false; 
    357372 
     373 
     374        ////////// 
     375        //-- fill up simple rays with random rays so we can cast 16 
     376 
     377        //const int numRandomRays = 0; 
     378        const int numRandomRays = 16 - (int)simpleRays.size(); 
     379        ViewCellBasedDistribution vcStrat(*this, mCurrentViewCell); 
     380 
     381        GenerateRays(numRandomRays, vcStrat, simpleRays); 
     382 
     383        ///////////////////// 
     384 
     385 
    358386        // keep origin for per view cell sampling 
    359         CastRays(simpleRays, vssRays, castDoubleRays, pruneInvalidRays, mPerViewCell); 
     387        CastRays(simpleRays, vssRays, castDoubleRays, pruneInvalidRays); 
     388 
     389        const int numBorderSamples = (int)vssRays.size() - numRandomRays; 
    360390 
    361391        // set flags 
    362392        VssRayContainer::const_iterator rit, rit_end = vssRays.end(); 
    363         for (rit = vssRays.begin(); rit != rit_end; ++ rit) 
    364         { 
    365                 (*rit)->mFlags |= VssRay::BorderSample; 
     393        int i = 0; 
     394   
     395        for (rit = vssRays.begin(); rit != rit_end; ++ rit, ++ i) 
     396        { 
     397                if (i < numBorderSamples) 
     398                        (*rit)->mFlags |= VssRay::BorderSample; 
    366399        } 
    367400 
     
    369402        EnqueueRays(vssRays); 
    370403         
    371         const int n = (int)vssRays.size(); 
    372         int castRays = n; 
     404        int castRays = simpleRays.size(); 
    373405         
    374406    // recursivly subdivide each edge 
    375         for (int i = 0; i < n; ++ i) 
     407        for (int i = 0; i < numBorderSamples; ++ i) 
    376408        { 
    377409                castRays += SubdivideEdge(hitTriangle, 
    378410                                                                  enlargedTriangle[i],  
    379                                                                   enlargedTriangle[(i + 1) % n],  
     411                                                                  enlargedTriangle[(i + 1) % numBorderSamples],  
    380412                                                                  *vssRays[i],  
    381                                                                   *vssRays[(i + 1) % n], 
     413                                                                  *vssRays[(i + 1) % numBorderSamples], 
    382414                                                                  currentRay); 
    383415        } 
     
    389421 
    390422 
    391 Vector3 GvsPreprocessor::GetPassingPoint(const VssRay &currentRay, 
    392                                                                                  const Triangle3 &occluder, 
    393                                                                                  const VssRay &oldRay) const 
     423bool GvsPreprocessor::GetPassingPoint(const VssRay &currentRay, 
     424                                                                          const Triangle3 &occluder, 
     425                                                                          const VssRay &oldRay, 
     426                                                                          Vector3 &newPoint) const 
    394427{ 
    395428        //-- The plane p = (xp, hit(x), hit(xold)) is intersected 
     
    408441 
    409442        if (!intersects) 
    410                 cerr << "big error!! no intersection" << endl; 
     443        { 
     444                cerr << "big error!! no intersection " << pt1 << " " << pt2 << endl; 
     445                return false; 
     446        } 
    411447 
    412448        // get the intersection point on the old ray 
     
    417453 
    418454        // Evaluate new hitpoint just outside the triangle 
    419         Vector3 newPoint; 
    420  
    421455        const float eps = mEps; 
    422456 
     
    432466 
    433467        //cout << "passing point: " << newPoint << endl << endl; 
    434         return newPoint; 
     468        return true; 
    435469} 
    436470 
     
    455489         
    456490        // get a point which is passing just outside of the occluder 
    457     const Vector3 newPoint = GetPassingPoint(currentRay, occluder, oldRay); 
     491    Vector3 newPoint; 
     492 
     493        // why is there sometimes no intersecton found? 
     494        if (!GetPassingPoint(currentRay, occluder, oldRay, newPoint)) 
     495                return NULL; 
     496 
    458497        const Vector3 predicted = CalcPredictedHitPoint(currentRay, hitTriangle, oldRay); 
    459498 
     
    479518                ray.Clear(); 
    480519                ray.Init(newOrigin, -newDir, Ray::LOCAL_RAY); 
    481                 //ray.Init(newOrigin, -newDir, Ray::LINE_SEGMENT); 
    482520                 
    483521                //cout << "z"; 
     
    496534 
    497535        VssRay *reverseRay =  
    498                 mRayCaster->CastRay(simpleRay, mViewCellsManager->GetViewSpaceBox(), mPerViewCell); 
     536                mRayCaster->CastRay(simpleRay, mViewCellsManager->GetViewSpaceBox(), !mPerViewCell); 
    499537 
    500538    ++ mGvsStats.mReverseSamples; 
     
    513551         
    514552        ViewCellBasedDistribution vcStrat(*this, mCurrentViewCell); 
    515  
    516553    GenerateRays(numSamples, vcStrat, simpleRays); 
    517554 
     
    520557        VssRayContainer samples; 
    521558         
    522         const bool castDoubleRays = false; 
     559        const bool castDoubleRays = !mPerViewCell; 
    523560        const bool pruneInvalidRays = true; 
    524         const bool keepOrigin = mPerViewCell; 
    525  
    526         CastRays(simpleRays, samples, castDoubleRays, pruneInvalidRays, keepOrigin); 
     561         
     562        CastRays(simpleRays, samples, castDoubleRays, pruneInvalidRays); 
    527563         
    528564        // add to ray queue 
     
    556592                VssRay *ray = mRayQueue.top(); 
    557593                mRayQueue.pop(); 
    558                 if (!ray) cout << "Error!!!!!" << endl; 
     594                 
    559595                const int newSamples = AdaptiveBorderSampling(*ray); 
    560596 
     
    598634 
    599635        //exporter->ExportRays(vcRays, RgbColor(1, 0, 0)); 
    600         exporter->ExportRays(vcRays2, RgbColor(0, 1, 0)); 
     636        //exporter->ExportRays(vcRays2, RgbColor(0, 1, 0)); 
    601637        //exporter->ExportRays(vcRays3, RgbColor(1, 1, 1)); 
    602638} 
     
    609645        Material m; 
    610646         
    611         char str[64]; sprintf(str, "pass%06d.wrl", mNumViewCells); 
     647        char str[64]; sprintf(str, "pass%06d.wrl", mProcessedViewCells); 
    612648 
    613649        Exporter *exporter = Exporter::GetExporter(str); 
     
    655691void GvsPreprocessor::VisualizeViewCells() 
    656692{ 
    657         char str[64]; sprintf(str, "tmp/pass%06d_%04d-", mNumViewCells, mPass); 
     693        char str[64]; sprintf(str, "tmp/pass%06d_%04d-", mProcessedViewCells, mPass); 
    658694                         
    659695        // visualization 
     
    685721{ 
    686722        mGvsStats.mPerViewCellSamples = 0; 
    687         int oldContribution = 0; 
     723        int oldContribution = mGvsStats.mTotalContribution; 
    688724        int passSamples = 0; 
    689725 
    690         while (mGvsStats.mPerViewCellSamples < mTotalSamples)  
     726        //while (mGvsStats.mPerViewCellSamples < mTotalSamples)  
     727        while (1)  
    691728        { 
    692729                // Ray queue empty =>  
     
    699736                passSamples += newSamples; 
    700737                mGvsStats.mPerViewCellSamples += newSamples; 
    701          
    702                 if (0 && 
    703                         passSamples % (mSamplesPerPass + 1) == mSamplesPerPass) 
     738                //cout << "here4 " << passSamples % (mSamplesPerPass + 1) << endl; 
     739 
     740                if (passSamples >= mSamplesPerPass) 
    704741                { 
    705742                        ++ mPass; 
     
    711748 
    712749                        mGvsStats.mPass = mPass; 
    713                         mGvsStats.Stop(); 
    714                         mGvsStats.Print(mGvsStatsStream); 
    715  
    716                         //cout << "\nPass " << mPass << " #samples: " << mGvsStats.mTotalSamples << " of " << mTotalSamples << endl; 
     750 
     751                        cout << "\nPass " << mPass << " #samples: " << mGvsStats.mPerViewCellSamples << endl; 
     752                        cout << "contribution=" << mGvsStats.mPassContribution << " (of " << mMinContribution << ")" << endl; 
     753 
     754                        // termination criterium 
     755                        if (mGvsStats.mPassContribution < mMinContribution) 
     756                        { 
     757                                break; 
     758                        } 
    717759 
    718760                        // reset 
     
    725767 
    726768 
     769void GvsPreprocessor::CompileViewCellsList() 
     770{ 
     771        while ((int)mViewCells.size() < mMaxViewCells) 
     772    { 
     773                if (0) 
     774                { 
     775                        mViewCells.push_back(mViewCellsManager->GetViewCell((int)mViewCells.size())); 
     776                } 
     777                else 
     778                { 
     779                        // HACK 
     780                        const int tries = 10000; 
     781                        int i = 0; 
     782 
     783                        for (i = 0; i < tries; ++ i) 
     784                        { 
     785                                const int idx = (int)RandomValue(0.0f, (float)mViewCellsManager->GetNumViewCells() - 0.5f); 
     786         
     787                                ViewCell *viewCell = mViewCellsManager->GetViewCell(idx); 
     788 
     789                                if (!viewCell->Mailed()) 
     790                                { 
     791                                        viewCell->Mail(); 
     792                                        break; 
     793                                } 
     794 
     795                                mViewCells.push_back(viewCell); 
     796                        } 
     797 
     798                        if (i == tries) 
     799                        { 
     800                                cerr << "big error! no view cell found" << endl; 
     801                                return; 
     802                        } 
     803                } 
     804        } 
     805} 
     806 
     807 
    727808void GvsPreprocessor::PerViewCellComputation() 
    728809{ 
    729         const int maxViewCells = 25; 
    730          
    731         while (mNumViewCells < maxViewCells && NextViewCell()) 
    732         { 
    733                 cout << "processing view cell " << mNumViewCells << endl; 
     810        while (NextViewCell()) 
     811        { 
     812                cout << "\n***********************\nprocessing view cell " << mProcessedViewCells << endl; 
    734813 
    735814                // compute the pvs of the current view cell 
    736815                ProcessViewCell(); 
     816 
     817                mGvsStats.mTrianglePvs = mCurrentViewCell->GetPvs().GetSize(); 
    737818 
    738819                // exchange triangle pvs with objects 
     
    748829                //-- stats 
    749830                 
    750                 mGvsStats.mViewCells = mNumViewCells;//mPass; 
     831                mGvsStats.mViewCells = mProcessedViewCells;//mPass; 
     832                mGvsStats.mPerViewCellPvs = mCurrentViewCell->GetPvs().GetSize(); 
    751833                mGvsStats.mTotalPvs += mCurrentViewCell->GetPvs().GetSize(); 
    752834                mGvsStats.mTotalSamples += mGvsStats.mPerViewCellSamples; 
     
    754836                mGvsStats.Stop(); 
    755837                mGvsStats.Print(mGvsStatsStream); 
     838 
     839                // is this really necessary? 
     840                ClearRayQueue(); 
    756841        } 
    757842} 
     
    863948        if (mPerViewCell) 
    864949        { 
     950                // list of view cells to compute 
     951                CompileViewCellsList(); 
     952 
    865953                PerViewCellComputation(); 
    866954        } 
     
    9161004{ 
    9171005        app << "#Pass\n" << mPass << endl; 
     1006        app << "#ViewCellId\n" << mViewCellId << endl; 
    9181007        app << "#Time\n" << Time() << endl; 
    9191008        app << "#TotalSamples\n" << mTotalSamples << endl; 
     
    9251014        app << "#ViewCells\n" << mViewCells << endl; 
    9261015        app << "#TotalPvs\n" << mTotalPvs << endl; 
     1016        app << "#PerViewCellPvs\n" << mPerViewCellPvs << endl; 
     1017        app << "#TrianglePvs\n" << mTrianglePvs << endl; 
     1018        app << "#RaysPerSec\n" << RaysPerSec() << endl; 
    9271019        app << "#PerViewCellSamples\n" << mPerViewCellSamples << endl << endl; 
    9281020} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h

    r1990 r1996  
    3838                mViewCells = 0; 
    3939                mPerViewCellSamples = 0; 
     40                mPerViewCellPvs = 0; 
     41                mTrianglePvs = 0; 
     42                mViewCellId = 0; 
    4043        } 
    4144 
     
    5457        int mViewCells; 
    5558        int mPerViewCellSamples; 
    56                  
     59        int mPerViewCellPvs; 
     60        int mTrianglePvs; 
     61        int mViewCellId; 
     62         
     63        float RaysPerSec() const { if (!Time()) return 0; return (float)mTotalSamples / Time() * 1e-6f; } 
     64 
    5765        void Print(ostream &app) const; 
    5866 
     
    135143                Does reverse sampling if gap found. 
    136144        */ 
    137         bool CheckDiscontinuity(const VssRay &currentRay,  
    138                                                         const Triangle3 &hitTriangle, 
    139                                                         const VssRay &oldRay); 
     145        int CheckDiscontinuity(const VssRay &currentRay,  
     146                                                   const Triangle3 &hitTriangle, 
     147                                                   const VssRay &oldRay); 
    140148 
    141149        /** Adds new samples to the ray queue and classifies them 
     
    169177                                                                  const VssRay &oldRay) const; 
    170178 
    171  
    172         Vector3 GetPassingPoint(const VssRay &currentRay, 
    173                                                         const Triangle3 &hitTriangle, 
    174                                                         const VssRay &oldRay) const; 
     179        bool GetPassingPoint(const VssRay &currentRay, 
     180                                                 const Triangle3 &occluder, 
     181                                                 const VssRay &oldRay, 
     182                                                 Vector3 &newPoint) const; 
    175183 
    176184        bool NextViewCell(); 
     
    189197 
    190198        void ProcessViewCell(); 
     199        void ClearRayQueue(); 
     200 
     201        void CompileViewCellsList(); 
     202 
    191203 
    192204        ////////////////////// 
     
    222234        ViewCell *mCurrentViewCell; 
    223235 
    224         int mNumViewCells; 
     236        int mProcessedViewCells; 
     237 
     238        int mMinContribution; 
     239 
     240        ViewCellContainer mViewCells; 
     241 
     242        int mMaxViewCells; 
    225243}; 
    226244 
  • GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.cpp

    r1990 r1996  
    3838                                                        const AxisAlignedBox3 &box, 
    3939                                                        const bool castDoubleRay, 
    40                                                         const bool pruneInvalidRays, 
    41                                                         const bool keepOrigin 
     40                                                        const bool pruneInvalidRays 
    4241                                                        ) 
    4342{ 
     
    103102                                          box, 
    104103                                          castDoubleRay, 
    105                                           pruneInvalidRays, 
    106                                           keepOrigin 
     104                                          pruneInvalidRays 
    107105                                          ); 
    108106} 
     
    114112                                                                const AxisAlignedBox3 &sbox, 
    115113                                                                const bool castDoubleRay, 
    116                                                                 const bool pruneInvalidRays, 
    117                                                                 const bool keepOrigin) 
     114                                                                const bool pruneInvalidRays) 
    118115{ 
    119116        int i; 
     
    230227                                   sbox, 
    231228                                   castDoubleRay, 
    232                                    pruneInvalidRays, 
    233                                    keepOrigin 
     229                                   pruneInvalidRays 
    234230                                   ); 
    235231        } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/IntelRayCaster.h

    r1990 r1996  
    4242                                                const AxisAlignedBox3 &box, 
    4343                                                const bool castDoubleRay, 
    44                                                 const bool pruneInvalidRays = true, 
    45                                                 const bool keepOrigin = false); 
     44                                                const bool pruneInvalidRays = true); 
    4645 
    4746        virtual void CastRays16( 
     
    5049                                                        const AxisAlignedBox3 &sbox, 
    5150                                                        const bool castDoubleRay, 
    52                                                         const bool pruneInvalidRays = true, 
    53                                                         const bool keepOrigin = false); 
     51                                                        const bool pruneInvalidRays = true); 
    5452 
    5553protected: 
  • GTP/trunk/Lib/Vis/Preprocessing/src/InternalRayCaster.cpp

    r1990 r1996  
    2525                                                           const AxisAlignedBox3 &box, 
    2626                                                           const bool castDoubleRay, 
    27                                                            const bool pruneInvalidRays, 
    28                                                            const bool keepOrigin 
    29                                                            ) 
     27                                                           const bool pruneInvalidRays) 
    3028{ 
    3129  if (simpleRay.mType == Ray::GLOBAL_RAY) 
     
    7573                                        box, 
    7674                                        castDoubleRay, 
    77                                         pruneInvalidRays, 
    78                                         keepOrigin 
     75                                        pruneInvalidRays 
    7976                                        ); 
    8077} 
     
    198195                                                                   const AxisAlignedBox3 &sbox, 
    199196                                                                   const bool castDoubleRays, 
    200                                                                    const bool pruneInvalidRays, 
    201                                                                    const bool keepOrigin) 
     197                                                                   const bool pruneInvalidRays) 
    202198{ 
    203199#if DEBUG_RAYCAST 
     
    210206        for (sit = rays.begin(); sit != sit_end; ++ sit)  
    211207        { 
    212                 CastRay(*sit, vssRays, sbox, castDoubleRays, pruneInvalidRays, keepOrigin); 
     208                CastRay(*sit, vssRays, sbox, castDoubleRays, pruneInvalidRays); 
    213209        } 
    214210 
  • GTP/trunk/Lib/Vis/Preprocessing/src/InternalRayCaster.h

    r1990 r1996  
    4040                                                const AxisAlignedBox3 &box, 
    4141                                                const bool castDoubleRay, 
    42                                                 const bool pruneInvalidRays = true, 
    43                                                 const bool keepOrigin = false 
     42                                                const bool pruneInvalidRays = true 
    4443                                                ); 
    4544 
     
    4847                                                         const AxisAlignedBox3 &sbox, 
    4948                                                         const bool castDoubleRay, 
    50                                                          const bool pruneInvalidRays = true, 
    51                                                          const bool keepOrigin = false 
     49                                                         const bool pruneInvalidRays = true 
    5250                                                         ); 
    5351 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r1990 r1996  
    11471147                                           VssRayContainer &vssRays, 
    11481148                                           const bool castDoubleRays, 
    1149                                            const bool pruneInvalidRays, 
    1150                                            const bool keepOrigin 
     1149                                           const bool pruneInvalidRays 
    11511150                                           ) 
    11521151{ 
     
    11991198                                                                   mViewCellsManager->GetViewSpaceBox(), 
    12001199                                                                   castDoubleRays, 
    1201                                                                    pruneInvalidRays, 
    1202                                                                    keepOrigin); 
     1200                                                                   pruneInvalidRays); 
    12031201 
    12041202                        rayBucket.clear(); 
     
    12291227                                                        mViewCellsManager->GetViewSpaceBox(), 
    12301228                                                        castDoubleRays, 
    1231                                                         pruneInvalidRays, 
    1232                                                         keepOrigin); 
     1229                                                        pruneInvalidRays); 
    12331230                 
    12341231        } 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h

    r1990 r1996  
    145145                                                  VssRayContainer &vssRays, 
    146146                                                  const bool castDoubleRays, 
    147                                                   const bool pruneInvalidRays = true, 
    148                                                   const bool keepOrigin = false); 
     147                                                  const bool pruneInvalidRays = true); 
    149148 
    150149        /** Compute pixel error of the current PVS solution by sampling given number of viewpoints */ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp

    r1990 r1996  
    2626VssRay *RayCaster::CastRay(const SimpleRay &simpleRay, 
    2727                                                   const AxisAlignedBox3 &box, 
    28                                                    const bool keepOrigin)  
    29 { 
    30         // note: make no sense otherwise 
    31         const bool castDoubleRay = false; 
    32          
     28                                                   const bool castDoubleRay)  
     29{ 
    3330        VssRayContainer rays; 
    34         CastRay(simpleRay, rays, box, castDoubleRay, true, keepOrigin); 
     31        CastRay(simpleRay, rays, box, castDoubleRay, true); 
    3532     
    3633        if (!rays.empty()) 
     
    221218                                          const AxisAlignedBox3 &box, 
    222219                                          const bool castDoubleRay, 
    223                                           const bool pruneInvalidRays, 
    224                                           const bool keepOrigin) 
     220                                          const bool pruneInvalidRays) 
    225221{ 
    226222  int hits = 0; 
     
    283279          if (!pruneInvalidRays || hitA.mObject) { 
    284280                VssRay *vssRay = new VssRay( 
    285                                                                         keepOrigin ? simpleRay.mOrigin : clipB, 
     281                                                                        !castDoubleRay ? simpleRay.mOrigin : clipB, 
    286282                                                                        hitA.mPoint, 
    287283                                                                        hitB.mObject, 
     
    309305                { 
    310306                  VssRay *vssRay = new VssRay( 
    311                                                                           keepOrigin ? simpleRay.mOrigin : clipA, 
     307                                                                          clipA, 
    312308                                                                          hitB.mPoint, 
    313309                                                                          hitA.mObject, 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.h

    r1990 r1996  
    4545        VssRay *CastRay(const SimpleRay &simpleRay, 
    4646                                        const AxisAlignedBox3 &box, 
    47                                         const bool keepOrigin); 
     47                                        const bool castDoubleRay); 
    4848 
    4949        virtual int CastRay(const SimpleRay &simpleRay, 
     
    5151                                                const AxisAlignedBox3 &box, 
    5252                                                const bool castDoubleRay, 
    53                                                 const bool pruneInvalidRays = true, 
    54                                                 const bool keepOrigin = false 
    55                                                 ) = 0; 
     53                                                const bool pruneInvalidRays = true) = 0; 
    5654 
    5755        virtual void CastRays16( 
     
    6058                                                         const AxisAlignedBox3 &sbox, 
    6159                                                         const bool castDoubleRay, 
    62                                                          const bool pruneInvalidRays = true, 
    63                                                          const bool keepOrigin = false 
    64                                                          ) = 0; 
     60                                                         const bool pruneInvalidRays = true) = 0; 
    6561 
    6662 
     
    10197                                   const AxisAlignedBox3 &box, 
    10298                                   const bool castDoubleRay, 
    103                                    const bool pruneInvalidRays = true, 
    104                                    const bool keepOrigin = false); 
     99                                   const bool pruneInvalidRays = true); 
    105100 
    106101        /** Checks if ray is valid. 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp

    r1994 r1996  
    2020HaltonSequence HwGlobalLinesDistribution::sHalton; 
    2121 
     22HaltonSequence ViewCellBasedDistribution::sHalton; 
    2223 
    2324SamplingStrategy::SamplingStrategy(Preprocessor &preprocessor):  
     
    651652                                  } else 
    652653                                        if (strcmp(curr, "mutation")==0) { 
    653                                           mDistributions.push_back(new MutationBasedDistribution(mPreprocessor)); 
     654                                                // temp matt: still no mutationstrategy! 
     655                                          //mDistributions.push_back(new MutationBasedDistribution(mPreprocessor)); 
    654656                                        }  
    655657         
     
    738740 
    739741 
    740 } 
    741  
    742  
     742bool ViewCellBasedDistribution::GenerateSample(SimpleRay &ray) 
     743{ 
     744        Vector3 origin, direction;  
     745 
     746        ViewCellContainer &viewCells =  
     747                mPreprocessor.mViewCellsManager->GetViewCells(); 
     748 
     749        Vector3 point; 
     750        Vector3 normal, normal2; 
     751         
     752        float r[1]; 
     753        sHalton.GetNext(1, r); 
     754 
     755        const int objIdx = (int)(r[0] * (float)mPreprocessor.mObjects.size() - 1.0f); 
     756                                //      = (int)RandomValue(0, (float)mPreprocessor.mObjects.size() - 0.5f); 
     757        Intersectable *object = mPreprocessor.mObjects[objIdx]; 
     758 
     759        //cout << "obj: " << objIdx << endl; 
     760 
     761        object->GetRandomSurfacePoint(point, normal); 
     762        mViewCell->GetRandomSurfacePoint(origin, normal2); 
     763 
     764        direction = point - origin; 
     765 
     766        // move a little bit back to avoid piercing through walls 
     767        // that bound the view cell 
     768        origin -= 0.01f * normal2; 
     769 
     770        // $$ jb the pdf is yet not correct for all sampling methods! 
     771        const float c = Magnitude(direction); 
     772 
     773        if ((c <= Limits::Small) /*|| (DotProd(direction, normal) < 0)*/) 
     774        { 
     775                return false; 
     776        } 
     777 
     778        // $$ jb the pdf is yet not correct for all sampling methods! 
     779        const float pdf = 1.0f; 
     780 
     781        direction *= 1.0f / c; 
     782        ray = SimpleRay(origin, direction, VIEWCELL_BASED_DISTRIBUTION, pdf); 
     783 
     784        //cout << "ray: " << ray.mOrigin << " " << ray.mDirection << endl; 
     785 
     786        return true; 
     787} 
     788 
     789 
     790} 
     791 
     792 
Note: See TracChangeset for help on using the changeset viewer.