Changeset 309


Ignore:
Timestamp:
10/05/05 14:14:35 (19 years ago)
Author:
mattausch
Message:

removed bug when encountering bsp leaf
added flag for view cell type

Location:
trunk/VUT/GtpVisibilityPreprocessor
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/scripts/Preprocessor.vcproj

    r260 r309  
    6363                                Name="VCCLCompilerTool" 
    6464                                AdditionalIncludeDirectories="..\support;..\support\devil\include;..\support\zlib\include;"$(QTDIR)\include";"$(QTDIR)\include\Qt";..\include" 
    65                                 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;TEST_BSP_VIEWCELLS" 
     65                                PreprocessorDefinitions="WIN32;NDEBUG;_LIB;" 
    6666                                RuntimeLibrary="2" 
    6767                                RuntimeTypeInfo="TRUE" 
  • trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env

    r308 r309  
    6363        totalSamples    1000000 
    6464        samplesPerPass  5 
     65        viewCells    BSP 
     66        #viewCells    KD 
    6567} 
    6668 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp

    r297 r309  
    11511151                 "1000000"); 
    11521152 
     1153  RegisterOption("Sampling.viewCells", 
     1154                 optString, 
     1155                 "-view_cells", 
     1156                 "BSP"); 
     1157 
    11531158  RegisterOption("Sampling.samplesPerPass", 
    11541159                 optInt, 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp

    r308 r309  
    1010mKdTree(NULL), 
    1111mBspTree(NULL), 
    12 mRootViewCell(NULL) 
     12mRootViewCell(NULL), 
     13mViewCellsType(BSP_VIEW_CELLS) 
    1314{ 
    1415} 
  • trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.h

    r308 r309  
    110110  /// the root view cell of the bsp tree 
    111111  ViewCell *mRootViewCell; 
     112 
     113  enum {BSP_VIEW_CELLS, KD_VIEW_CELLS}; 
     114 
     115  int mViewCellsType; 
    112116}; 
    113117 
  • trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp

    r308 r309  
    1313  environment->GetIntValue("Sampling.samplesPerPass", mSamplesPerPass); 
    1414  environment->GetIntValue("Sampling.totalSamples", mTotalSamples); 
     15   
     16  char viewCellsStr[64]; 
     17  environment->GetStringValue("Sampling.viewCells", viewCellsStr); 
     18 
     19  mViewCellsType = BSP_VIEW_CELLS; 
     20 
     21  if (strcmp(viewCellsStr, "BSP") == 0) 
     22          mViewCellsType = BSP_VIEW_CELLS; 
     23  else if (strcmp(viewCellsStr, "KD") == 0) 
     24      mViewCellsType= KD_VIEW_CELLS; 
     25  else  
     26  { 
     27          cerr<<"Wrong view cells type" << viewCellsStr << endl; 
     28          exit(1); 
     29  } 
     30 
    1531  mKdPvsDepth = 100; 
    1632  mStats.open("stats.log"); 
     
    5470    for (j=1; j < ray.leaves.size() - 1; j++) { 
    5571      ray.leaves[j]->AddPassingRay(ray, contributingSamples ? 1 : 0); 
    56     } 
     72  } 
    5773   
    5874  return contributingSamples; 
     
    101117        int sampleContributions = 0; 
    102118 
    103 #ifndef TEST_BSP_VIEWCELLS 
    104         mKdTree->CastRay(ray); 
     119        if (mViewCellsType == KD_VIEW_CELLS) 
     120        { 
     121                mKdTree->CastRay(ray); 
    105122         
    106         if (ray.leaves.size()) { 
    107                 sampleContributions += AddNodeSamples(object, ray); 
    108                  
    109                 if (ray.intersections.size()) { 
    110                         sampleContributions += AddNodeSamples(ray.intersections[0].mObject, ray); 
     123                if (ray.leaves.size()) { 
     124                        sampleContributions += AddNodeSamples(object, ray); 
     125                 
     126                        if (ray.intersections.size()) { 
     127                                sampleContributions += AddNodeSamples(ray.intersections[0].mObject, ray); 
     128                        } 
     129                }  
     130        } else   
     131        { 
     132                mBspTree->CastRay(ray); 
     133 
     134                if (ray.viewCells.size() > 0) // view cell found 
     135                { 
     136                        sampleContributions += sampleContributions += AddObjectSamples(object, ray); 
     137         
     138                        // cast ray to KD tree to find intersections with other objects 
     139                        mKdTree->CastRay(ray); 
     140 
     141                        if (ray.intersections.size())  
     142                                sampleContributions += AddObjectSamples(ray.intersections[0].mObject, ray); 
    111143                } 
    112144        } 
    113 #else 
    114         mBspTree->CastRay(ray); 
    115  
    116         if (ray.viewCells.size() > 0) // view cell found 
    117         { 
    118                 ++ sampleContributions; 
    119          
    120                 //  cast ray to KD tree to find intersections with other objects 
    121                 mKdTree->CastRay(ray); 
    122  
    123                 if (ray.intersections.size())  
    124                 { 
    125                         sampleContributions += AddObjectSamples(ray.intersections[0].mObject, ray); 
    126                 } 
    127         } 
    128 #endif 
     145 
    129146        return sampleContributions; 
    130147} 
     
    235252                int index = 0; 
    236253                Debug << "************************************" << endl; 
    237                 Debug << "totalSamples: " << totalSamples << " (" << mTotalSamples << ")" << endl; 
     254                 
    238255                for (i = 0; i < objects.size(); i++) { 
    239256                        KdNode *nodeToSample = NULL; 
     
    294311                        } 
    295312                         
    296                  
    297313                        object->GetRandomSurfacePoint(point, normal); 
    298314                        bool viewcellSample = true; 
     
    333349                        } 
    334350                                 
    335                          
    336351                        if ( i < pvsOut ) 
    337352                                rays[i].push_back(ray); 
     
    363378 
    364379                int pvsSize = 0; 
    365 #ifdef TEST_BSP_VIEWCELLS     
    366                 for (i=0; i < mViewCells.size(); i++) { 
    367                         ViewCell *vc = mViewCells[i]; 
    368                         pvsSize += vc->GetPvs().GetSize(); 
     380         
     381                if (mViewCellsType == BSP_VIEW_CELLS) 
     382                { 
     383                        for (i=0; i < mViewCells.size(); i++) { 
     384                                ViewCell *vc = mViewCells[i]; 
     385                                pvsSize += vc->GetPvs().GetSize(); 
     386                        } 
     387                } else 
     388                { 
     389                        for (i=0; i < objects.size(); i++) { 
     390                                Intersectable *object = objects[i]; 
     391                                pvsSize += object->mKdPvs.GetSize(); 
     392                        } 
    369393                } 
    370                 Debug << "pvs size: " << pvsSize << endl; 
    371 #else 
    372                 for (i=0; i < objects.size(); i++) { 
    373                         Intersectable *object = objects[i]; 
    374                         pvsSize += object->mKdPvs.GetSize(); 
    375                 } 
    376 #endif           
     394 
    377395                cout << "#Pass " << mPass<<" : t = " << TimeDiff(startTime, GetTime())*1e-3 << "s" << endl; 
    378396                cout << "#TotalSamples=" << totalSamples/1000  
     
    392410                        "#AvgRayContrib\n" << passSampleContributions/(float)passContributingSamples << endl; 
    393411        } 
    394   Debug << "Collecting leaf pvs" << endl; 
    395   int totalPvsSize = mKdTree->CollectLeafPvs(); 
    396   cout << "#totalPvsSize=" << totalPvsSize << endl; 
     412   
     413        if (mViewCellsType == KD_VIEW_CELLS)     
     414                cout << "#totalPvsSize=" << mKdTree->CollectLeafPvs() << endl; 
    397415   
    398416  //  HoleSamplingPass(); 
  • trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp

    r308 r309  
    12491249                        } 
    12501250 
    1251                         //-- split 
    1252  
    12531251                        // push data for far child 
    12541252                        tStack.push(BspRayTraversalData(farChild, extp, maxt)); 
     
    12701268                        } 
    12711269 
    1272                         if (hits && ray.GetType() == Ray::LOCAL_RAY) 
    1273                                 if (ray.intersections[0].mT <= maxt) 
    1274                                         break; 
    1275        
    1276                         // get the next node from the stack 
     1270                        // get the next node from the stack 
    12771271                        if (tStack.empty()) 
    12781272                                break; 
  • trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp

    r305 r309  
    3434  p->KdTreeStatistics(cout); 
    3535 
    36 #ifdef TEST_BSP_VIEWCELLS 
    37   environment->GetStringValue("Scene.viewcells", buff); 
    3836 
    39   string vcFilename(buff); 
     37  if (p->mViewCellsType == Preprocessor::BSP_VIEW_CELLS) 
     38  { 
     39           // if BSP tree construction method needs predefined view cells 
     40          if (BspTree::sConstructionMethod == BspTree::VIEW_CELLS) 
     41          { 
     42                  environment->GetStringValue("Scene.viewcells", buff); 
     43                   
     44                  string vcFilename(buff); 
     45                  
     46                  if (vcFilename != "") 
     47                  p->LoadViewCells(vcFilename); 
     48                  else 
     49                          p->GenerateViewCells(); 
    4050 
    41   // if BSP tree construction method needs predefined view cells 
    42   if (BspTree::sConstructionMethod == BspTree::VIEW_CELLS) 
    43   { 
    44           if (vcFilename != "") 
    45           p->LoadViewCells(vcFilename); 
    46           else 
    47                   p->GenerateViewCells(); 
     51                   Debug << "Viewcells loaded / generated. Number of view cells: " << (int)p->mViewCells.size() << endl; 
     52          } 
     53           
     54          p->BuildBspTree(); 
     55          p->BspTreeStatistics(Debug); 
     56          p->Export("vc_bsptree2.x3d", false, false, true); 
     57  
     58#if 0 
     59          //-- export the complementary view cells 
     60          // i.e., the view cells not associated with leafs in the tree. 
     61          Exporter *exporter = Exporter::GetExporter("viewcells_compl.x3d"); 
    4862 
    49          Debug << "Viewcells loaded / generated. Number of view cells: " << (int)p->mViewCells.size() << endl; 
    50   } 
     63          ViewCellContainer::iterator vc_compl_it; 
     64          ViewCellContainer vc_compl(p->mViewCells.size() + X3dExporter::foundViewCells.size()); 
     65   
     66          sort(p->mViewCells.begin(), p->mViewCells.end()); 
    5167 
    52   p->BuildBspTree(); 
    53   p->BspTreeStatistics(Debug); 
    54   p->Export("vc_bsptree2.x3d", false, false, true); 
     68          vc_compl_it = set_difference(p->mViewCells.begin(), p->mViewCells.end(),  
     69                  X3dExporter::foundViewCells.begin(), X3dExporter::foundViewCells.end(), vc_compl.begin()); 
    5570 
    56 #if 0 
    57   //-- export the complementary view cells 
    58   // i.e., the view cells not associated with leafs in the tree. 
    59   Exporter *exporter = Exporter::GetExporter("viewcells_compl.x3d"); 
    60  
    61   ViewCellContainer::iterator vc_compl_it; 
    62   ViewCellContainer vc_compl(p->mViewCells.size() + X3dExporter::foundViewCells.size()); 
    63    
    64   sort(p->mViewCells.begin(), p->mViewCells.end()); 
    65   vc_compl_it = set_difference(p->mViewCells.begin(), p->mViewCells.end(),  
    66                                  X3dExporter::foundViewCells.begin(), X3dExporter::foundViewCells.end(), 
    67                                  vc_compl.begin()); 
    68   vc_compl.erase(vc_compl_it, vc_compl.end()); 
     71          vc_compl.erase(vc_compl_it, vc_compl.end()); 
    6972   
    7073 
    71   if (exporter)  
    72   {      
    73           Debug << "Exporting complementary view cells" << endl; 
    74           exporter->ExportViewCells(&vc_compl); // export view cells 
    75           delete exporter; 
     74          if (exporter)  
     75          {      
     76                  Debug << "Exporting complementary view cells" << endl; 
     77                  exporter->ExportViewCells(&vc_compl); // export view cells 
     78                  delete exporter; 
     79          } 
     80#endif 
    7681  } 
    77 #endif 
    78  
    79 #endif 
    8082 
    8183  //  p->mSceneGraph->Export("soda.x3d"); 
Note: See TracChangeset for help on using the changeset viewer.