Changeset 309 for trunk/VUT/GtpVisibilityPreprocessor
- Timestamp:
- 10/05/05 14:14:35 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/scripts/Preprocessor.vcproj
r260 r309 63 63 Name="VCCLCompilerTool" 64 64 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;" 66 66 RuntimeLibrary="2" 67 67 RuntimeTypeInfo="TRUE" -
trunk/VUT/GtpVisibilityPreprocessor/scripts/default.env
r308 r309 63 63 totalSamples 1000000 64 64 samplesPerPass 5 65 viewCells BSP 66 #viewCells KD 65 67 } 66 68 -
trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp
r297 r309 1151 1151 "1000000"); 1152 1152 1153 RegisterOption("Sampling.viewCells", 1154 optString, 1155 "-view_cells", 1156 "BSP"); 1157 1153 1158 RegisterOption("Sampling.samplesPerPass", 1154 1159 optInt, -
trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.cpp
r308 r309 10 10 mKdTree(NULL), 11 11 mBspTree(NULL), 12 mRootViewCell(NULL) 12 mRootViewCell(NULL), 13 mViewCellsType(BSP_VIEW_CELLS) 13 14 { 14 15 } -
trunk/VUT/GtpVisibilityPreprocessor/src/Preprocessor.h
r308 r309 110 110 /// the root view cell of the bsp tree 111 111 ViewCell *mRootViewCell; 112 113 enum {BSP_VIEW_CELLS, KD_VIEW_CELLS}; 114 115 int mViewCellsType; 112 116 }; 113 117 -
trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp
r308 r309 13 13 environment->GetIntValue("Sampling.samplesPerPass", mSamplesPerPass); 14 14 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 15 31 mKdPvsDepth = 100; 16 32 mStats.open("stats.log"); … … 54 70 for (j=1; j < ray.leaves.size() - 1; j++) { 55 71 ray.leaves[j]->AddPassingRay(ray, contributingSamples ? 1 : 0); 56 72 } 57 73 58 74 return contributingSamples; … … 101 117 int sampleContributions = 0; 102 118 103 #ifndef TEST_BSP_VIEWCELLS 104 mKdTree->CastRay(ray); 119 if (mViewCellsType == KD_VIEW_CELLS) 120 { 121 mKdTree->CastRay(ray); 105 122 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); 111 143 } 112 144 } 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 129 146 return sampleContributions; 130 147 } … … 235 252 int index = 0; 236 253 Debug << "************************************" << endl; 237 Debug << "totalSamples: " << totalSamples << " (" << mTotalSamples << ")" << endl;254 238 255 for (i = 0; i < objects.size(); i++) { 239 256 KdNode *nodeToSample = NULL; … … 294 311 } 295 312 296 297 313 object->GetRandomSurfacePoint(point, normal); 298 314 bool viewcellSample = true; … … 333 349 } 334 350 335 336 351 if ( i < pvsOut ) 337 352 rays[i].push_back(ray); … … 363 378 364 379 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 } 369 393 } 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 377 395 cout << "#Pass " << mPass<<" : t = " << TimeDiff(startTime, GetTime())*1e-3 << "s" << endl; 378 396 cout << "#TotalSamples=" << totalSamples/1000 … … 392 410 "#AvgRayContrib\n" << passSampleContributions/(float)passContributingSamples << endl; 393 411 } 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; 397 415 398 416 // HoleSamplingPass(); -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r308 r309 1249 1249 } 1250 1250 1251 //-- split1252 1253 1251 // push data for far child 1254 1252 tStack.push(BspRayTraversalData(farChild, extp, maxt)); … … 1270 1268 } 1271 1269 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 1277 1271 if (tStack.empty()) 1278 1272 break; -
trunk/VUT/GtpVisibilityPreprocessor/src/main.cpp
r305 r309 34 34 p->KdTreeStatistics(cout); 35 35 36 #ifdef TEST_BSP_VIEWCELLS37 environment->GetStringValue("Scene.viewcells", buff);38 36 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(); 40 50 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"); 48 62 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()); 51 67 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()); 55 70 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()); 69 72 70 73 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 76 81 } 77 #endif78 79 #endif80 82 81 83 // p->mSceneGraph->Export("soda.x3d");
Note: See TracChangeset
for help on using the changeset viewer.