- Timestamp:
- 12/05/05 04:42:54 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp
r444 r448 68 68 69 69 void ViewCellsManager::ComputeSampleContributions(const RayContainer &rays, 70 const bool castRays,71 70 int &sampleContributions, 72 int &contributingSamples) 71 int &contributingSamples, 72 const bool castRays) 73 73 { 74 74 // view cells not yet constructed … … 168 168 SimulationStatistics ViewCellsManager::SimulateRendering() const 169 169 { 170 if (!ViewCellsConstructed() )170 if (!ViewCellsConstructed() || !mRenderSimulator) 171 171 return SimulationStatistics(); 172 172 … … 240 240 return 0; 241 241 242 Debug << "Constructing bsp view cells" << endl;243 244 242 int sampleContributions = 0; 245 243 … … 247 245 248 246 int limit = min (mConstructionSamples, (int)rays.size()); 247 248 // construct view cells using the collected samples 249 Debug << "construcing bsp view cells from " 250 << limit << " samples " << endl; 249 251 250 252 for (int i = 0; i < limit; ++ i) … … 332 334 int pvsSize = 0; 333 335 334 BspViewCellsStatistics stat;335 mBspTree->EvaluateViewCellsStats( stat);336 Debug << "original view cell partition:\n" << stat<< endl;337 338 if (1) // export view cells 336 BspViewCellsStatistics vcStats; 337 mBspTree->EvaluateViewCellsStats(vcStats); 338 Debug << "original view cell partition:\n" << vcStats << endl; 339 340 if (1) // export view cells before merge 339 341 { 340 342 cout << "exporting initial view cells (=leaves) ... "; … … 344 346 { 345 347 exporter->SetWireframe(); 346 exporter->ExportBspLeaves(*mBspTree, stat.maxPvs);348 exporter->ExportBspLeaves(*mBspTree, vcStats.maxPvs); 347 349 //exporter->ExportBspViewCellPartition(*mBspTree, 0); 348 350 … … 360 362 } 361 363 cout << "finished" << endl; 362 } 364 365 //-- render simulation 366 cout << "\nevaluating bsp view cells render time before merge ... "; 367 368 const SimulationStatistics ss = SimulateRendering(); 369 370 cout << " finished" << endl; 371 cout << ss << endl; 372 Debug << ss << endl; 373 } 374 363 375 364 376 cout << "starting post processing using " << mPostProcessSamples << " samples ... "; 365 377 366 378 long startTime = GetTime(); 367 368 379 369 380 //-- merge or subdivide view cells … … 408 419 cout << "merged " << merged << " view cells in " 409 420 << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl; 421 422 // statistics after post process 423 vcStats.Reset(); 424 mBspTree->EvaluateViewCellsStats(vcStats); 425 Debug << "post processed view cell partition:\n" << vcStats << endl; 410 426 411 427 return merged; … … 956 972 mVspKdTree(vspKdTree) 957 973 { 958 mRenderSimulator = NULL; // TODO:new VspKdRenderSimulator(vspKdTree);974 mRenderSimulator = NULL;//new VspKdRenderSimulator(vspKdTree); 959 975 InitRenderSimulator(); 960 976 } … … 983 999 return 0; 984 1000 985 //if (castRay) // TODO 1001 //if (castRay) 1002 //mVspKdTree->CastRay(ray); 986 1003 987 1004 int sampleContributions = 0; 988 1005 989 /*990 for (int i = 0; i < (int)rays.size(); ++ i)991 {992 Ray *ray = rays[i];993 994 mBspTree->CastRay(*ray);995 996 Intersectable *term =997 !ray->intersections.empty() ? ray->intersections[0].mObject : NULL998 ;999 sampleContributions +=1000 AddSampleContributions(*ray, ray->sourceObject.mObject, term);1001 1002 }1003 */1004 1006 return sampleContributions; 1005 1007 } … … 1121 1123 mVspBspTree(vspBspTree) 1122 1124 { 1123 mRenderSimulator = NULL;// TODO new VspBspRenderSimulator(bspTree);1124 //InitRenderSimulator();1125 mRenderSimulator = new VspBspRenderSimulator(vspBspTree); 1126 InitRenderSimulator(); 1125 1127 } 1126 1128 … … 1182 1184 for (int j = 0; j < (int)ray.bspIntersections.size(); ++ j) 1183 1185 { 1184 VspBspLeaf *leaf = NULL; //TODOray.bspIntersections[j].mLeaf;1186 BspLeaf *leaf = ray.bspIntersections[j].mLeaf; 1185 1187 1186 1188 // if ray not in unbounded space … … 1206 1208 for (int j = 1; j < ((int)ray.bspIntersections.size() - 1); ++ j) 1207 1209 { 1208 VspBspLeaf *leaf = NULL;// TODO= ray.bspIntersections[j].mLeaf;1210 BspLeaf *leaf = ray.bspIntersections[j].mLeaf; 1209 1211 1210 1212 if (leaf->GetViewCell() != mVspBspTree->GetRootCell()) … … 1219 1221 const RayContainer &rays) 1220 1222 { 1221 return 0;// TODO1222 1223 if (!ViewCellsConstructed()) 1223 1224 { … … 1231 1232 int pvsSize = 0; 1232 1233 1233 VspBspViewCellsStatistics vcStats;1234 BspViewCellsStatistics vcStats; 1234 1235 mVspBspTree->EvaluateViewCellsStats(vcStats); 1235 1236 Debug << "original view cell partition:\n" << vcStats << endl; … … 1243 1244 { 1244 1245 exporter->SetWireframe(); 1245 //exporter->ExportBspLeaves(*mVspBspTree, stat.maxPvs);1246 exporter->ExportBspViewCellPartition(*mVspBspTree, vcStats.maxPvs); 1246 1247 1247 1248 if (0) … … 1284 1285 iit = ray->bspIntersections.begin(); 1285 1286 1286 VspBspLeaf *previousLeaf = NULL;//TODO(*iit).mLeaf;1287 BspLeaf *previousLeaf = (*iit).mLeaf; 1287 1288 ++ iit; 1288 1289 1289 1290 for (; iit != ray->bspIntersections.end(); ++ iit) 1290 1291 { 1291 VspBspLeaf *leaf = NULL;//TODO(*iit).mLeaf;1292 BspLeaf *leaf = (*iit).mLeaf; 1292 1293 1293 1294 if (ShouldMerge(leaf, previousLeaf)) … … 1307 1308 << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl; 1308 1309 1310 // statistics after post process 1311 vcStats.Reset(); 1312 mVspBspTree->EvaluateViewCellsStats(vcStats); 1313 Debug << "post processed view cell partition:\n" << vcStats << endl; 1314 1309 1315 return merged; 1310 1316 } … … 1319 1325 const RayContainer &sampleRays) 1320 1326 { 1321 return; // TODO1322 1327 if (!ViewCellsConstructed()) 1323 1328 return; 1324 1329 1325 1330 //-- recount pvs 1326 VspBspViewCellsStatistics vcStats;1331 BspViewCellsStatistics vcStats; 1327 1332 mVspBspTree->EvaluateViewCellsStats(vcStats); 1328 1333 … … 1330 1335 { 1331 1336 cout << "exporting view cells after merge ... "; 1332 /*Exporter *exporter = Exporter::GetExporter("merged_view_cells.x3d");1337 Exporter *exporter = Exporter::GetExporter("merged_view_cells.x3d"); 1333 1338 1334 1339 if (exporter) … … 1337 1342 delete exporter; 1338 1343 } 1339 */1344 1340 1345 cout << "finished" << endl; 1341 1346 } … … 1343 1348 //-- visualization of the BSP splits 1344 1349 bool exportSplits = false; 1345 1350 environment->GetBoolValue("BspTree.Visualization.exportSplits", exportSplits); 1346 1351 1347 1352 if (exportSplits) … … 1352 1357 } 1353 1358 1354 //TODO ExportVspBspPvs(objects, sampleRays);1359 ExportBspPvs(objects, sampleRays); 1355 1360 } 1356 1361 … … 1367 1372 exporter->SetForcedMaterial(m); 1368 1373 exporter->SetWireframe(); 1369 // TODO1370 //exporter->ExportBspSplits(*mVspBspTree, true);1374 1375 exporter->ExportBspSplits(*mVspBspTree, true); 1371 1376 1372 1377 // take forced material, else big scenes cannot be viewed … … 1412 1417 const int raysOut = min((int)sampleRays.size(), mVisualizationSamples); 1413 1418 cout << "visualization using " << mVisualizationSamples << " samples" << endl; 1414 vector<Ray *> vcRays[leafOut]; 1415 1416 if (0) 1419 1420 if (1) 1417 1421 { 1418 1422 //-- some random view cells and rays for output 1419 vector< VspBspLeaf *> vspBspLeaves;1423 vector<BspLeaf *> vspBspLeaves; 1420 1424 1421 1425 for (int i = 0; i < leafOut; ++ i) … … 1424 1428 for (int i = 0; i < (int)vspBspLeaves.size(); ++ i) 1425 1429 { 1430 RayContainer vcRays; 1426 1431 cout << "creating output for view cell " << i << " ... "; 1427 1432 // check whether we can add the current ray to the output rays 1428 for (int k = 0; k < raysOut; ++ k)1433 /*for (int k = 0; k < raysOut; ++ k) 1429 1434 { 1430 1435 Ray *ray = sampleRays[k]; … … 1436 1441 if (vspBspLeaves[i]->GetViewCell() == leaf->GetViewCell()) 1437 1442 { 1438 vcRays [i].push_back(ray);1443 vcRays.push_back(ray); 1439 1444 } 1440 1445 } 1441 1446 } 1447 */ 1442 1448 1443 1449 Intersectable::NewMail(); … … 1474 1480 1475 1481 Debug << i << ": pvs size=" << (int)vc->GetPvs().GetSize() 1476 << ", piercing rays=" << (int)vcRays [i].size() << endl;1482 << ", piercing rays=" << (int)vcRays.size() << endl; 1477 1483 1478 1484 // export rays piercing this view cell 1479 exporter->ExportRays(vcRays[i], 1000, RgbColor(0, 1, 0)); 1480 1481 m.mDiffuseColor = RgbColor(1, 0, 0); 1485 exporter->ExportRays(vcRays, 1000, RgbColor(1, 0, 0)); 1486 exporter->ExportRays(vspBspLeaves[i]->mVssRays, RgbColor(1, 1, 1)); 1487 1488 m.mDiffuseColor = RgbColor(0, 1, 1); 1482 1489 exporter->SetForcedMaterial(m); 1483 1490 1484 //exporter->SetWireframe();1485 exporter->SetFilled();1491 exporter->SetWireframe(); 1492 //exporter->SetFilled(); 1486 1493 1487 1494 // output PVS of view cell … … 1527 1534 { 1528 1535 cout << "creating output for view cell " << i << " ... "; 1529 1536 RayContainer vcRays; 1530 1537 Intersectable::NewMail(); 1531 1538 BspViewCell *vc = dynamic_cast<BspViewCell *>(viewCells[i]); … … 1539 1546 for (int j = 0; j < (int)ray->bspIntersections.size(); ++ j) 1540 1547 { 1541 VspBspLeaf *leaf = NULL; // TODO= ray->bspIntersections[j].mLeaf;1548 BspLeaf *leaf = ray->bspIntersections[j].mLeaf; 1542 1549 1543 1550 if (vc == leaf->GetViewCell()) 1544 1551 { 1545 vcRays [i].push_back(ray);1552 vcRays.push_back(ray); 1546 1553 } 1547 1554 } … … 1572 1579 1573 1580 Debug << i << ": pvs size=" << (int)vc->GetPvs().GetSize() 1574 << ", piercing rays=" << (int)vcRays [i].size() << endl;1581 << ", piercing rays=" << (int)vcRays.size() << endl; 1575 1582 1576 1583 1577 1584 // export rays piercing this view cell 1578 exporter->ExportRays(vcRays [i], 1000, RgbColor(0, 1, 0));1585 exporter->ExportRays(vcRays, 1000, RgbColor(0, 1, 0)); 1579 1586 1580 1587 m.mDiffuseColor = RgbColor(1, 0, 0); … … 1607 1614 1608 1615 1609 bool VspBspViewCellsManager::MergeVspBspLeafViewCells( VspBspLeaf *front,1610 VspBspLeaf *back) const1616 bool VspBspViewCellsManager::MergeVspBspLeafViewCells(BspLeaf *front, 1617 BspLeaf *back) const 1611 1618 { 1612 1619 BspViewCell *viewCell = … … 1623 1630 BspViewCell *bVc = back->GetViewCell(); 1624 1631 1625 // TODO 1626 /*vector<VspBspLeaf *> fLeaves = fVc->mBspLeaves; 1627 vector<VspBspLeaf *> bLeaves = bVc->mBspLeaves; 1628 1629 vector<VspBspLeaf *>::const_iterator it; 1632 vector<BspLeaf *> fLeaves = fVc->mBspLeaves; 1633 vector<BspLeaf *> bLeaves = bVc->mBspLeaves; 1634 1635 vector<BspLeaf *>::const_iterator it; 1630 1636 1631 1637 for (it = fLeaves.begin(); it != fLeaves.end(); ++ it) … … 1642 1648 DEL_PTR(fVc); 1643 1649 DEL_PTR(bVc); 1644 */ 1650 1645 1651 return true; 1646 1652 } 1647 1653 1648 bool VspBspViewCellsManager::ShouldMerge( VspBspLeaf *front, VspBspLeaf *back) const1654 bool VspBspViewCellsManager::ShouldMerge(BspLeaf *front, BspLeaf *back) const 1649 1655 { 1650 1656 ViewCell *fvc = front->GetViewCell();
Note: See TracChangeset
for help on using the changeset viewer.