- Timestamp:
- 11/01/05 20:02:22 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/SamplingPreprocessor.cpp
r365 r366 121 121 for (j=1; j < ((int)ray.bspLeaves.size() - 1); ++ j) 122 122 { 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()-> 125 127 AddPassingRay(ray, contributingSamples ? 1 : 0); 126 128 } … … 162 164 } 163 165 164 if ( mViewCellsType == BSP_VIEW_CELLS)166 if (ViewCell::sHierarchy == ViewCell::BSP) 165 167 { 166 168 // cast ray to BSP tree to get intersection with view cells … … 376 378 int passSamples = 0; 377 379 int index = 0; 378 Real maxTime = 0; 379 int maxTimeIdx = 0; 380 380 381 int reverseSamples = 0; 381 382 bool collectSamplesForBsp = 382 ( mViewCellsType == BSP_VIEW_CELLS) &&383 (ViewCell::sHierarchy == ViewCell::BSP) && 383 384 (BspTree::sConstructionMethod == BspTree::FROM_RAYS) && 384 385 (totalSamples < mBspConstructionSamples); 385 386 386 cout << "totalSamples: " << totalSamples << endl;387 //cout << "totalSamples: " << totalSamples << endl; 387 388 388 389 for (i = 0; i < objects.size(); i++) { … … 392 393 393 394 int pvsSize = 0; 394 if ( mViewCellsType == KD_VIEW_CELLS)395 if (ViewCell::sHierarchy == ViewCell::KD) 395 396 pvsSize = object->mKdPvs.GetSize(); 396 397 … … 402 403 int faceIndex = object->GetRandomSurfacePoint(point, normal); 403 404 404 long samplesPerObjStart = GetTime();405 406 405 bool viewcellSample = true; 407 406 int sampleContributions; … … 456 455 } 457 456 //------------------- 458 if ( mViewCellsType == BSP_VIEW_CELLS)457 if (ViewCell::sHierarchy == ViewCell::BSP) 459 458 { 460 459 ProcessBspViewCells(collectSamplesForBsp, … … 471 470 // object->GetRandomVisibleMesh(Plane3(normal, point)); 472 471 } 473 474 // measure maximal time for samples per object475 Real t = TimeDiff(samplesPerObjStart, GetTime());476 477 if (t > maxTime)478 {479 maxTime = t;480 maxTimeIdx = i;481 }482 472 483 473 // CORR matt: must add all samples … … 494 484 int pvsSize = 0; 495 485 496 if ( mViewCellsType == BSP_VIEW_CELLS) {486 if (ViewCell::sHierarchy == ViewCell::BSP) { 497 487 for (i=0; i < mViewCells.size(); i++) { 498 488 ViewCell *vc = mViewCells[i]; … … 506 496 } 507 497 508 Debug << "maximal time needed for pass: " << maxTime << " (object " << maxTimeIdx << ")" << endl;509 510 498 float avgRayContrib = (passContributingSamples > 0) ? 511 499 passSampleContributions/(float)passContributingSamples : 0; … … 529 517 } 530 518 531 if ( mViewCellsType == KD_VIEW_CELLS)519 if (ViewCell::sHierarchy == ViewCell::KD) 532 520 cout << "#totalPvsSize=" << mKdTree->CollectLeafPvs() << endl; 533 521 … … 535 523 if (mBspTree) 536 524 { 525 cout << "starting post processing ... "; 526 527 Debug << "original pvs size: " << mBspTree->CountViewCellPvs() << endl; 528 529 long startTime = GetTime(); 537 530 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; 550 538 551 539 } … … 557 545 exporter->ExportKdTree(*mKdTree); 558 546 559 if (mBspTree && ( mViewCellsType == BSP_VIEW_CELLS))547 if (mBspTree && (ViewCell::sHierarchy == ViewCell::BSP)) 560 548 exporter->ExportBspTree(*mBspTree); 561 549 … … 580 568 //-- several visualizations and statistics 581 569 if (1) { 582 if (mBspTree && (mViewCellsType == BSP_VIEW_CELLS))570 if (mBspTree && (ViewCell::sHierarchy == ViewCell::BSP)) 583 571 { 584 572 bool exportSplits = false; … … 672 660 RayContainer::const_iterator rit, rit_end = rays.end(); 673 661 vector<BspLeaf *>::const_iterator lit; 674 if (0) 662 675 663 for (rit = rays.begin(); rit != rays.end(); ++ rit) 676 664 { 677 665 // traverse leaves stored in the rays and compare and merge consecutive 678 666 // leaves (i.e., the neighbors in the tree) 667 if ((*rit)->bspLeaves.empty()) 668 continue; 669 679 670 lit = (*rit)->bspLeaves.begin(); 680 671 … … 693 684 } 694 685 } 686 695 687 return merged; 696 688 } … … 775 767 for (int i = 0; i < (int)bspLeaves.size(); ++ i) 776 768 { 777 if (bspLeaves[i] == ray->bspLeaves[j])769 if (bspLeaves[i]->GetViewCell() == ray->bspLeaves[j]->GetViewCell()) 778 770 { 779 771 vcRays[i].push_back(*ray); … … 799 791 ViewCellPvsMap::iterator it = vc->GetPvs().mEntries.begin(); 800 792 793 exporter->SetWireframe(); 794 801 795 Material m;//= RandomMaterial(); 802 796 m.mDiffuseColor = RgbColor(0, 1, 0); 803 797 exporter->SetForcedMaterial(m); 804 798 805 exporter->SetWireframe();806 807 799 if (vc->GetMesh()) 808 800 exporter->ExportViewCell(vc); … … 810 802 { 811 803 PolygonContainer cell; 812 813 mBspTree->ConstructGeometry(bspLeaves[i] , cell);804 // export view cell 805 mBspTree->ConstructGeometry(bspLeaves[i]->GetViewCell(), cell); 814 806 exporter->ExportPolygons(cell); 815 807 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 {}}*/822 808 } 823 809
Note: See TracChangeset
for help on using the changeset viewer.