Ignore:
Timestamp:
11/01/05 20:02:22 (19 years ago)
Author:
mattausch
Message:

some ideas abou saving bspleaves with the ray and t

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp

    r365 r366  
    121121                for (j=1; j < ((int)ray.bspLeaves.size() - 1); ++ j)  
    122122                { 
    123                         if (ray.bspLeaves[j]->GetViewCell() != &mUnbounded) 
    124                                 ray.bspLeaves[j]->GetViewCell()-> 
     123                        BspLeaf *leaf = ray.bspIntersections.leaf; 
     124 
     125                        if (leaf->GetViewCell() != &mUnbounded) 
     126                                leaf->GetViewCell()-> 
    125127                                        AddPassingRay(ray, contributingSamples ? 1 : 0); 
    126128                } 
     
    162164        } 
    163165 
    164         if (mViewCellsType == BSP_VIEW_CELLS) 
     166        if (ViewCell::sHierarchy == ViewCell::BSP) 
    165167        { 
    166168                // cast ray to BSP tree to get intersection with view cells 
     
    376378                int passSamples = 0; 
    377379                int index = 0; 
    378                 Real maxTime = 0; 
    379                 int maxTimeIdx = 0; 
     380                 
    380381                int reverseSamples = 0; 
    381382                bool collectSamplesForBsp =  
    382                         (mViewCellsType == BSP_VIEW_CELLS) && 
     383                        (ViewCell::sHierarchy == ViewCell::BSP) && 
    383384                        (BspTree::sConstructionMethod == BspTree::FROM_RAYS) && 
    384385                        (totalSamples < mBspConstructionSamples); 
    385386                         
    386                 cout << "totalSamples: "  << totalSamples << endl; 
     387                //cout << "totalSamples: "  << totalSamples << endl; 
    387388 
    388389                for (i = 0; i < objects.size(); i++) { 
     
    392393                 
    393394                        int pvsSize = 0; 
    394                         if (mViewCellsType == KD_VIEW_CELLS) 
     395                        if (ViewCell::sHierarchy == ViewCell::KD) 
    395396                                pvsSize = object->mKdPvs.GetSize(); 
    396397                                                 
     
    402403                        int faceIndex = object->GetRandomSurfacePoint(point, normal); 
    403404                         
    404                         long samplesPerObjStart = GetTime(); 
    405  
    406405                        bool viewcellSample = true; 
    407406                        int sampleContributions; 
     
    456455                                        } 
    457456                                        //------------------- 
    458                                         if (mViewCellsType == BSP_VIEW_CELLS)  
     457                                        if (ViewCell::sHierarchy == ViewCell::BSP)  
    459458                                        { 
    460459                                                ProcessBspViewCells(collectSamplesForBsp, 
     
    471470                                //                              object->GetRandomVisibleMesh(Plane3(normal, point)); 
    472471                        } 
    473                                  
    474                         // measure maximal time for samples per object 
    475                         Real t = TimeDiff(samplesPerObjStart, GetTime()); 
    476  
    477                         if (t > maxTime) 
    478                         { 
    479                                 maxTime = t; 
    480                                 maxTimeIdx = i; 
    481                         } 
    482472         
    483473                        // CORR matt: must add all samples 
     
    494484                int pvsSize = 0; 
    495485         
    496                 if (mViewCellsType == BSP_VIEW_CELLS) { 
     486                if (ViewCell::sHierarchy == ViewCell::BSP) { 
    497487                        for (i=0; i < mViewCells.size(); i++) { 
    498488                                ViewCell *vc = mViewCells[i]; 
     
    506496                } 
    507497 
    508                 Debug << "maximal time needed for pass: " << maxTime << " (object " << maxTimeIdx << ")" << endl; 
    509  
    510498                float avgRayContrib = (passContributingSamples > 0) ?  
    511499                        passSampleContributions/(float)passContributingSamples : 0; 
     
    529517        } 
    530518         
    531         if (mViewCellsType == KD_VIEW_CELLS)     
     519        if (ViewCell::sHierarchy == ViewCell::KD)        
    532520                cout << "#totalPvsSize=" << mKdTree->CollectLeafPvs() << endl; 
    533521   
     
    535523        if (mBspTree) 
    536524        { 
     525                cout << "starting post processing ... "; 
     526 
     527                Debug << "original pvs size: " << mBspTree->CountViewCellPvs() << endl; 
     528 
     529                long startTime = GetTime(); 
    537530                int merged = PostprocessViewCells(mSampleRays); 
    538                 Debug << "merged " << merged << " view cells" << endl; 
    539  
    540                 ViewCellContainer vc; 
    541                 mBspTree->CollectViewCells(vc); 
    542  
    543                 ViewCellContainer::const_iterator it, it_end = vc.end(); 
    544  
    545                 int mergedPvs = 0; 
    546                 for (it = vc.begin(); it != it_end; ++ it) 
    547                         mergedPvs += (*it)->GetPvs().GetSize(); 
    548  
    549                 Debug << "merged pvs size: " << mergedPvs << endl; 
     531                 
     532                cout << "finished" << endl; 
     533                cout << "merged " << merged << " view cells in " 
     534                         << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl; 
     535 
     536                //-- recount pvs 
     537                Debug << "merged pvs size: " << mBspTree->CountViewCellPvs() << endl; 
    550538 
    551539        } 
     
    557545                exporter->ExportKdTree(*mKdTree); 
    558546 
    559                 if (mBspTree && (mViewCellsType == BSP_VIEW_CELLS)) 
     547                if (mBspTree && (ViewCell::sHierarchy == ViewCell::BSP)) 
    560548                        exporter->ExportBspTree(*mBspTree); 
    561549 
     
    580568        //-- several visualizations and statistics 
    581569        if (1) { 
    582         if (mBspTree && (mViewCellsType == BSP_VIEW_CELLS)) 
     570                if (mBspTree && (ViewCell::sHierarchy == ViewCell::BSP)) 
    583571        { 
    584572                bool exportSplits = false; 
     
    672660        RayContainer::const_iterator rit, rit_end = rays.end(); 
    673661        vector<BspLeaf *>::const_iterator lit; 
    674 if (0) 
     662 
    675663        for (rit = rays.begin(); rit != rays.end(); ++ rit) 
    676664        {   
    677665                // traverse leaves stored in the rays and compare and merge consecutive 
    678666                // leaves (i.e., the neighbors in the tree) 
     667                if ((*rit)->bspLeaves.empty()) 
     668                        continue; 
     669 
    679670                lit = (*rit)->bspLeaves.begin(); 
    680671 
     
    693684                } 
    694685        } 
     686 
    695687        return merged; 
    696688} 
     
    775767                        for (int i = 0; i < (int)bspLeaves.size(); ++ i) 
    776768                        { 
    777                                 if (bspLeaves[i] == ray->bspLeaves[j])  
     769                                if (bspLeaves[i]->GetViewCell() == ray->bspLeaves[j]->GetViewCell())  
    778770                                { 
    779771                                        vcRays[i].push_back(*ray); 
     
    799791                ViewCellPvsMap::iterator it = vc->GetPvs().mEntries.begin(); 
    800792 
     793                exporter->SetWireframe(); 
     794 
    801795                Material m;//= RandomMaterial(); 
    802796                m.mDiffuseColor = RgbColor(0, 1, 0); 
    803797                exporter->SetForcedMaterial(m); 
    804798 
    805                 exporter->SetWireframe(); 
    806  
    807799                if (vc->GetMesh()) 
    808800                        exporter->ExportViewCell(vc); 
     
    810802                { 
    811803            PolygonContainer cell; 
    812  
    813                         mBspTree->ConstructGeometry(bspLeaves[i], cell); 
     804                        // export view cell 
     805                        mBspTree->ConstructGeometry(bspLeaves[i]->GetViewCell(), cell); 
    814806                        exporter->ExportPolygons(cell); 
    815807                        CLEAR_CONTAINER(cell); 
    816  
    817                         /*vector<BspLeaf *> neighbors; 
    818                         mBspTree->FindNeighbors(bspLeaves[j], neighbors); 
    819                         for (int j = 0; j < (int)neighbors.size(); ++ j) 
    820                         {       if (neighbors[j]->mViewCell == bspLeaves[j]->mViewCell) 
    821                                 {}}*/ 
    822808                } 
    823809 
Note: See TracChangeset for help on using the changeset viewer.