Changeset 582 for trunk/VUT/GtpVisibilityPreprocessor/src
- Timestamp:
- 02/02/06 19:16:39 (18 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/Environment.cpp
r581 r582 1325 1325 "false"); 1326 1326 1327 RegisterOption("ViewCells.maxStaticMemory", 1328 optFloat, 1329 "view_cells_max_static_mem=", 1330 "8.0"); 1331 1327 1332 1328 1333 /************************************************************************************/ -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.cpp
r581 r582 308 308 { 309 309 environment->GetBoolValue("ViewCells.Visualization.exportMergedViewCells", mExportMergedViewCells); 310 environment->GetFloatValue("ViewCells.maxStaticMemory", mMaxMemory); 310 311 311 312 //-- merge options … … 314 315 environment->GetFloatValue("ViewCells.PostProcess.maxCostRatio", mMergeMaxCostRatio); 315 316 317 318 Debug << "========= view cell tree options ================\n"; 319 Debug << "minimum view cells: " << mMergeMinViewCells << endl; 320 Debug << "max cost ratio: " << mMergeMaxCostRatio << endl; 321 Debug << "max memory: " << mMaxMemory << endl; 322 316 323 MergeCandidate::sRenderCostWeight = mRenderCostWeight; 317 324 318 325 mStats.open("mergeStats.log"); 326 } 327 328 329 // return memory usage in MB 330 float ViewCellsTree::GetMemUsage() const 331 { 332 return 0; 333 /*(sizeof(ViewCellsTree) + 334 mBspStats.Leaves() * sizeof(BspLeaf) + 335 mBspStats.Interior() * sizeof(BspInterior) + 336 mBspStats.accumRays * sizeof(RayInfo)) / (1024.0f * 1024.0f);*/ 319 337 } 320 338 … … 387 405 const ObjectContainer &objects) 388 406 { 389 // number of view cells equals the number of leaves 390 // (without the invalid ones ) 391 //mNumViewCells = mBspStats.Leaves();//- mBspStats.invalidLeaves; 392 mNumViewCells = (int)mViewCellsManager->GetViewCells().size(); 407 mNumActiveViewCells = (int)mViewCellsManager->GetViewCells().size(); 393 408 394 409 float variance = 0; … … 432 447 // view cell manager. They will change with 433 448 // subsequent merges 434 ViewCellContainer & viewCells = mViewCellsManager->GetViewCells();449 ViewCellContainer &activeViewCells = mViewCellsManager->GetViewCells(); 435 450 436 451 … … 455 470 float realExpectedCost = mExpectedCost; 456 471 float realAvgRenderCost = mAvgRenderCost; 457 int realNum ViewCells = mNumViewCells;472 int realNumActiveViewCells = mNumActiveViewCells; 458 473 459 474 // maximal ratio of old expected render cost to expected render … … 461 476 float avgCostMaxDeviation; 462 477 int maxMergesPerPass; 463 int num ActiveViewCells = 0;478 int numMergedViewCells = 0; 464 479 465 480 environment->GetIntValue("ViewCells.PostProcess.maxMergesPerPass", maxMergesPerPass); … … 472 487 //-- use priority queue to merge leaf pairs 473 488 474 while (!mMergeQueue.empty() && (realNumViewCells > mMergeMinViewCells))489 while (!mMergeQueue.empty())// && (realNumActiveViewCells > mMergeMinViewCells)) 475 490 { 476 491 //-- reset merge queue if the ratio of current expected cost / real expected cost … … 495 510 mExpectedCost = realExpectedCost; 496 511 mAvgRenderCost = realAvgRenderCost; 497 mNum ViewCells = realNumViewCells;512 mNumActiveViewCells = realNumActiveViewCells; 498 513 499 const int numActiveViewCells = UpdateMergedViewCells(viewCells); 500 514 const int numMergedViewCells = UpdateActiveViewCells(activeViewCells); 515 516 // recompute priorities => reset render cost 501 517 ResetMergeQueue(); 502 518 … … 509 525 if (mExportMergedViewCells) 510 526 { 511 ExportMergedViewCells( viewCells, objects, numActiveViewCells);527 ExportMergedViewCells(activeViewCells, objects, numMergedViewCells); 512 528 } 513 529 } … … 524 540 mMergeQueue.pop(); 525 541 526 // both view cells equal! 542 // both view cells equal 543 // NOTE: do I really still need this? probably cannot happen!! 527 544 if (mc.mLeftViewCell == mc.mRightViewCell) 528 545 continue; … … 532 549 ViewCell::NewMail(); 533 550 534 -- realNum ViewCells;551 -- realNumActiveViewCells; 535 552 ++ mergeStats.merged; 536 553 ++ mergedPerPass; … … 547 564 mDeviation += mc.GetDeviationIncr(); 548 565 549 realExpectedCost = totalCost / (float)realNum ViewCells;566 realExpectedCost = totalCost / (float)realNumActiveViewCells; 550 567 551 568 const float currentMergeCost = mc.GetMergeCost(); … … 557 574 558 575 totalPvs += pvsDiff; 576 559 577 // set timestamp 560 578 mergedVc->SetTimeStamp(mergeStats.merged); 561 579 562 realAvgRenderCost = (float)totalPvs / (float)realNum ViewCells;580 realAvgRenderCost = (float)totalPvs / (float)realNumActiveViewCells; 563 581 #if VC_HISTORY 564 582 if (mc.mLeftViewCell->IsSibling(mc.mRightViewCell)) … … 566 584 #endif 567 585 if (((mergeStats.merged % statsOut) == 0) || 568 (realNum ViewCells == mMergeMinViewCells))586 (realNumActiveViewCells == mMergeMinViewCells)) 569 587 { 570 588 cout << "merged " << mergeStats.merged << " view cells" << endl; … … 573 591 << "#Pass\n" << pass << endl 574 592 << "#Merged\n" << mergeStats.merged << endl 575 << "#Viewcells\n" << realNum ViewCells << endl593 << "#Viewcells\n" << realNumActiveViewCells << endl 576 594 << "#CurrentCost\n" << currentMergeCost << endl 577 595 << "#RelativeCost\n" << currentMergeCost / mOverallCost << endl … … 584 602 << "#AvgRenderCost\n" << mAvgRenderCost << endl 585 603 << "#expectedCostRatio\n" << mExpectedCost / realExpectedCost << endl 586 << "#Deviation\n" << mDeviation / (float)realNum ViewCells << endl604 << "#Deviation\n" << mDeviation / (float)realNumActiveViewCells << endl 587 605 << "#TotalDeviation\n" << mDeviation<< endl; 588 606 } … … 592 610 // merge candidate not valid, because one of the leaves was already 593 611 // merged with another one => validate and reinsert into queue 594 SetMergeCandidateValid(mc); 595 mMergeQueue.push(mc); 612 if (ValidateMergeCandidate(mc)) 613 { 614 EvalMergeCost(mc); 615 mMergeQueue.push(mc); 616 } 596 617 } 597 618 } … … 600 621 mExpectedCost = realExpectedCost; 601 622 mAvgRenderCost = realAvgRenderCost; 602 mNum ViewCells = realNumViewCells;603 604 Update MergedViewCells(viewCells);623 mNumActiveViewCells = realNumActiveViewCells; 624 625 UpdateActiveViewCells(activeViewCells); 605 626 ResetMergeQueue(); 606 607 627 608 628 // create a root node if the merge was not done till root level, 609 629 // else take the single node as new root 610 if ((int)viewCells.size() > 1) 611 { 612 Debug << "here888" << endl; 613 ViewCellInterior *root = new ViewCellInterior(); 630 if ((int)activeViewCells.size() > 1) 631 { 632 Debug << "creating root of view cell hierarchy for " << (int)activeViewCells.size() << " view cells" << endl; 633 for (int i = 0; i < activeViewCells.size(); ++ i){ 634 Debug << "here233 " << activeViewCells[i]->GetParent() << endl; 635 Debug << "here233 " << activeViewCells[i] << endl; 636 } 637 ViewCellInterior *root = mViewCellsManager->MergeViewCells(activeViewCells); 614 638 615 639 root->SetTimeStamp(mergeStats.merged + 1); 616 617 ViewCellContainer::const_iterator it, it_end = viewCells.end();618 for (it = viewCells.begin(); it != it_end; ++ it)619 root->SetupChildLink(*it);620 621 640 mRoot = root; 622 641 } 623 else if ((int) viewCells.size() == 1)624 { 625 Debug << " here555" << endl;626 mRoot = viewCells[0];642 else if ((int)activeViewCells.size() == 1) 643 { 644 Debug << "setting root of the merge history" << endl; 645 mRoot = activeViewCells[0]; 627 646 } 628 647 … … 668 687 669 688 // recalculate cost 670 SetMergeCandidateValid(mc); 671 buf.push_back(mc); 689 if (ValidateMergeCandidate(mc)) 690 { 691 EvalMergeCost(mc); 692 buf.push_back(mc); 693 } 672 694 } 673 695 … … 684 706 685 707 686 int ViewCellsTree::UpdateMergedViewCells(ViewCellContainer &viewCells) 687 { 688 int numActiveViewCells = 0; 689 708 int ViewCellsTree::UpdateActiveViewCells(ViewCellContainer &viewCells) 709 { 710 int numMergedViewCells = 0; 711 712 Debug << "updating active vc: " << viewCells.size() << endl; 690 713 // find all already merged view cells and remove them from view cells 714 715 // sort out all view cells which are not active anymore, i.e., they 716 // were already part of a merge 691 717 int i = 0; 692 718 719 ViewCell::NewMail(); 720 693 721 while (1) 694 722 { 695 while (!viewCells.empty() && (!viewCells.back()->GetParent())) 723 // remove all merged view cells from end of the vector 724 while (!viewCells.empty() && (viewCells.back()->GetParent())) 696 725 { 697 726 viewCells.pop_back(); … … 703 732 704 733 // already merged view cell, put it to end of vector 705 if ( !viewCells[i]->IsRoot())734 if (viewCells[i]->GetParent()) 706 735 swap(viewCells[i], viewCells.back()); 707 736 708 ++ i; 709 } 737 viewCells[i ++]->Mail(); 738 } 739 710 740 711 741 // add new view cells to container only if they don't have been 712 742 // merged in the mean time 713 while (!mActiveViewCells.empty()) 714 { 715 if (!mActiveViewCells.back()->GetParent()) 716 { 717 viewCells.push_back(mActiveViewCells.back()); 718 ++ numActiveViewCells; 719 } 720 721 mActiveViewCells.pop_back(); 722 } 743 ViewCellContainer::const_iterator ait, ait_end = mMergedViewCells.end(); 744 for (ait = mMergedViewCells.begin(); ait != ait_end; ++ ait) 745 { 746 ViewCell *vc = mMergedViewCells.back(); 747 if (!vc->GetParent() && !vc->Mailed()) 748 { 749 vc->Mail(); 750 viewCells.push_back(vc); 751 ++ numMergedViewCells; 752 } 753 } 754 755 mMergedViewCells.clear(); 723 756 724 757 // update standard deviation … … 737 770 738 771 mDeviation /= (float)viewCells.size(); 739 740 // clear the view cells which were merged 741 mInactiveViewCells.clear(); 742 // remove the new view cells 743 mActiveViewCells.clear(); 744 745 return numActiveViewCells; 772 773 return numMergedViewCells; 746 774 } 747 775 … … 749 777 void ViewCellsTree::ExportMergedViewCells(ViewCellContainer &viewCells, 750 778 const ObjectContainer &objects, 751 const int num ActiveViewCells)779 const int numMergedViewCells) 752 780 { 753 781 … … 771 799 // assign special material to new view cells 772 800 // new view cells are on the back of container 773 if (i ++ >= (viewCells.size() - num ActiveViewCells))801 if (i ++ >= (viewCells.size() - numMergedViewCells)) 774 802 { 775 803 //m = RandomMaterial(); … … 798 826 ViewCellInterior *ViewCellsTree::MergeViewCells(ViewCell *l, ViewCell *r, int &pvsDiff) //const 799 827 { 800 ViewCellInterior *vc = mViewCellsManager->MergeViewCells( *l, *r);828 ViewCellInterior *vc = mViewCellsManager->MergeViewCells(l, r); 801 829 802 830 // if merge was unsuccessful … … 817 845 818 846 819 //-- clean up old view cells 820 if (0 && !mExportMergedViewCells) 821 { 822 DEL_PTR(l); 823 DEL_PTR(r); 824 } 825 else 826 { 827 mInactiveViewCells.push_back(l); 828 mInactiveViewCells.push_back(r); 829 830 mActiveViewCells.push_back(vc); 831 } 847 // new view cells are stored in this vector 848 mMergedViewCells.push_back(vc); 832 849 833 850 pvsDiff = vc->GetPvs().GetSize() - pvs1 - pvs2; … … 1018 1035 1019 1036 return mRenderCostWeight * (renderCost1 + renderCost2) + 1020 (1.0f - mRenderCostWeight) * (dev1 + dev2) / (float)mNum ViewCells;1037 (1.0f - mRenderCostWeight) * (dev1 + dev2) / (float)mNumActiveViewCells; 1021 1038 } 1022 1039 … … 1112 1129 { 1113 1130 const float penalty = EvalPvsPenalty(vc->GetPvs().GetSize(), lower, upper); 1114 return (mAvgRenderCost - penalty) * (mAvgRenderCost - penalty) / (float)mNum ViewCells;1131 return (mAvgRenderCost - penalty) * (mAvgRenderCost - penalty) / (float)mNumActiveViewCells; 1115 1132 } 1116 1133 … … 1128 1145 { 1129 1146 const float penalty = EvalPvsPenalty(vc->GetPvs().GetSize(), lower, upper); 1130 return fabs(mAvgRenderCost - penalty) / (float)mNum ViewCells;1147 return fabs(mAvgRenderCost - penalty) / (float)mNumActiveViewCells; 1131 1148 } 1132 1149 … … 1153 1170 1154 1171 1155 void ViewCellsTree::SetMergeCandidateValid(MergeCandidate &mc) const1172 bool ViewCellsTree::ValidateMergeCandidate(MergeCandidate &mc) const 1156 1173 { 1157 1174 while (mc.mLeftViewCell->mParent) … … 1165 1182 } 1166 1183 1167 EvalMergeCost(mc);1184 return mc.mLeftViewCell != mc.mRightViewCell; 1168 1185 } 1169 1186 … … 1210 1227 1211 1228 if (1) 1212 newDev = fabs(mAvgRenderCost - newPenalty) / (float)mNum ViewCells;1229 newDev = fabs(mAvgRenderCost - newPenalty) / (float)mNumActiveViewCells; 1213 1230 else 1214 newDev = fabs(mExpectedCost - newCost) / (float)mNum ViewCells;1231 newDev = fabs(mExpectedCost - newCost) / (float)mNumActiveViewCells; 1215 1232 1216 1233 oldDev = GetDeviation(vc1) + GetDeviation(vc2); … … 1251 1268 TraversalQueue tqueue; 1252 1269 tqueue.push(mRoot); 1253 Debug << "here34 " << numViewCells << endl;1270 1254 1271 while (!tqueue.empty()) 1255 1272 { 1256 1273 ViewCell *vc = tqueue.top(); 1257 tqueue.pop();1258 Debug << "here7 " << vc->GetTimeStamp() << endl;1259 if (vc->IsLeaf())1260 {1261 Debug << "here6" << endl;1274 1275 // save the view cells if it is a leaf or if enough view cells have already been traversed 1276 // because of the priority queue, this will be the optimal set of v 1277 if (vc->IsLeaf() || ((viewCells.size() + tqueue.size()) >= numViewCells)) 1278 { 1262 1279 viewCells.push_back(vc); 1263 1280 } 1264 else if (viewCells.size() + tqueue.size() < numViewCells)1265 { Debug << "here4" << endl;1281 else 1282 { 1266 1283 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 1267 1284 … … 1273 1290 } 1274 1291 } 1292 1293 tqueue.pop(); 1275 1294 } 1276 1295 } … … 1390 1409 bool MergeCandidate::IsValid() const 1391 1410 { 1392 return !(mLeftViewCell->mParent &&mRightViewCell->mParent);1411 return !(mLeftViewCell->mParent || mRightViewCell->mParent); 1393 1412 } 1394 1413 -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCell.h
r581 r582 325 325 float GetDeviation(ViewCell *vc) const; 326 326 327 /** Recalculates this merge candidate and sets valid. 328 */ 329 void SetMergeCandidateValid(MergeCandidate &mc) const; 327 /** Tries to set this merge candidate to valid. 328 @returns false if both view cells are the same 329 */ 330 bool ValidateMergeCandidate(MergeCandidate &mc) const; 330 331 331 332 /** Merge view cells of leaves l1 and l2. … … 360 361 361 362 /** Updates the current top level of view cells. 362 */ 363 int UpdateMergedViewCells(ViewCellContainer &viewCells); 363 @returns number of newly merged view cells 364 */ 365 int UpdateActiveViewCells(ViewCellContainer &viewCells); 364 366 365 367 void ComputeCommonPvs(ViewCellInterior *interior); 368 369 370 /** Returns memory usage of view cells. 371 */ 372 float GetMemUsage() const; 373 366 374 367 375 … … 375 383 376 384 377 ViewCellContainer m InactiveViewCells;378 ViewCellContainer mActiveViewCells;385 ViewCellContainer mMergedViewCells; 386 379 387 380 388 /// weights between variance and render cost increase (must be between zero and one) … … 389 397 int mUseAreaForPvs; 390 398 391 int mNum ViewCells;399 int mNumActiveViewCells; 392 400 393 401 /// minimal number of view cells … … 402 410 MergeQueue mMergeQueue; 403 411 404 412 float mMaxMemory; 405 413 406 414 }; -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellBsp.cpp
r580 r582 1030 1030 } 1031 1031 1032 1032 1033 void BspTree::SortSplitCandidates(const PolygonContainer &polys, 1033 1034 const int axis, -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp
r581 r582 56 56 environment->GetBoolValue("ViewCells.PostProcess.useRaysForMerge", mUseRaysForMerge); 57 57 58 environment->GetIntValue("ViewCells.active", mNum ActiveViewCells);58 environment->GetIntValue("ViewCells.active", mNumMergedViewCells); 59 59 60 60 mMinPvsSize = emptyViewCells ? 1 : 0; … … 107 107 { 108 108 cout << "disposing samples ... "; 109 long startTime = GetTime(); 110 int n = (int)rays.size(); 111 109 112 if (outRays) 110 113 { … … 121 124 } 122 125 cout << "finished" << endl; 126 Debug << "disposed " << n << " samples in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 123 127 } 124 128 … … 519 523 520 524 521 ViewCellInterior *ViewCellsManager::MergeViewCells(ViewCell &left, ViewCell &right) const525 ViewCellInterior *ViewCellsManager::MergeViewCells(ViewCell *left, ViewCell *right) const 522 526 { 523 527 // generate parent view cell … … 525 529 526 530 // merge pvs 527 vc->GetPvs().Merge(left .GetPvs(), right.GetPvs());531 vc->GetPvs().Merge(left->GetPvs(), right->GetPvs()); 528 532 529 533 //-- merge ray sets 530 534 if (0) 531 535 { 532 stable_sort(left .mPiercingRays.begin(), left.mPiercingRays.end());533 stable_sort(right .mPiercingRays.begin(), right.mPiercingRays.end());534 535 std::merge(left .mPiercingRays.begin(), left.mPiercingRays.end(),536 right .mPiercingRays.begin(), right.mPiercingRays.end(),536 stable_sort(left->mPiercingRays.begin(), left->mPiercingRays.end()); 537 stable_sort(right->mPiercingRays.begin(), right->mPiercingRays.end()); 538 539 std::merge(left->mPiercingRays.begin(), left->mPiercingRays.end(), 540 right->mPiercingRays.begin(), right->mPiercingRays.end(), 537 541 vc->mPiercingRays.begin()); 538 542 } 539 543 540 544 541 vc->SetupChildLink(&left); 542 vc->SetupChildLink(&right); 543 545 vc->SetupChildLink(left); 546 vc->SetupChildLink(right); 547 548 549 return vc; 550 } 551 552 553 ViewCellInterior *ViewCellsManager::MergeViewCells(ViewCellContainer &children) const 554 { 555 ViewCellInterior *vc = new ViewCellInterior();//GenerateViewCell(); 556 557 ViewCellContainer::const_iterator it, it_end = children.end(); 558 559 for (it = children.begin(); it != it_end; ++ it) 560 { 561 // merge pvs 562 vc->GetPvs().Merge(vc->GetPvs(), (*it)->GetPvs()); 563 564 vc->SetupChildLink(*it); 565 } 544 566 545 567 return vc; … … 845 867 if (!mOnlyValidViewCells || (*it)->GetValid()) 846 868 { 847 ExportColor(exporter, *it); 848 ExportViewCellGeometry(exporter, *it); 849 } 850 } 869 ExportColor(exporter, *it); 870 ExportViewCellGeometry(exporter, *it); 871 } 872 } 873 851 874 } 852 875 … … 1175 1198 VssRayContainer vcRays; 1176 1199 Intersectable::NewMail(); 1177 #if 0 1178 BspViewCell *vc = dynamic_cast<BspViewCell *>(mViewCells[i]); 1179 #else 1180 BspViewCell *vc = dynamic_cast<BspViewCell *>(mViewCells[Random((int)mViewCells.size())]); 1181 #endif 1200 ViewCell *vc; 1201 1202 if (0) 1203 vc = mViewCells[i]; 1204 else 1205 vc = mViewCells[Random((int)mViewCells.size())]; 1206 1182 1207 cout << "creating output for view cell " << i << " ... "; 1183 1208 … … 1213 1238 1214 1239 //-- export view cell 1240 #if VC_HISTORY 1215 1241 mBspTree->ConstructGeometry(vc, vcGeom); 1216 1242 exporter->ExportPolygons(vcGeom.mPolys); 1243 #endif 1217 1244 } 1218 1245 … … 1271 1298 // cast line segment to get intersections with bsp leaves 1272 1299 CastLineSegment(vssRay->mTermination, vssRay->mOrigin, viewCells); 1273 1300 #if VC_HISTORY 1274 1301 ViewCellContainer::const_iterator vit, vit_end = viewCells.end(); 1275 1302 for (vit = viewCells.begin(); vit != vit_end; ++ vit) 1276 1303 { 1277 BspViewCell *vc = dynamic_cast<BspViewCell *>(*vit);1304 ViewCell *vc = *vit; 1278 1305 ray->intersections.push_back(BspIntersection(0, vc->mLeaf)); 1279 1306 } 1280 1307 #endif 1281 1308 mBspRays.push_back(ray); 1282 1309 } … … 1334 1361 { 1335 1362 BspNodeGeometry geom; 1336 mBspTree->ConstructGeometry( 1337 dynamic_cast<BspViewCell *>(vc), geom);1363 #if VC_HISTORY 1364 mBspTree->ConstructGeometry(vc, geom); 1338 1365 exporter->ExportPolygons(geom.mPolys); 1366 #endif 1339 1367 } 1340 1368 } … … 2081 2109 { 2082 2110 // we can use the view cells tree hierarchy to get the right set 2083 mViewCellsTree->CollectBestViewCellSet(mViewCells, mNum ActiveViewCells);2111 mViewCellsTree->CollectBestViewCellSet(mViewCells, mNumMergedViewCells); 2084 2112 } 2085 2113 … … 2380 2408 for (vit = mViewCells.begin(); vit != mViewCells.end(); ++ vit) 2381 2409 { 2382 BspViewCell *vc = dynamic_cast<BspViewCell *>(*vit);2410 ViewCell *vc = *vit; 2383 2411 2384 2412 vm = RandomMaterial(); … … 2547 2575 for (vit = mViewCells.begin(); vit != mViewCells.end(); ++ vit) 2548 2576 { 2549 BspViewCell *vc = dynamic_cast<BspViewCell *>(*vit);2577 ViewCell *vc = *vit; 2550 2578 2551 2579 ViewCellContainer leaves; … … 2658 2686 VssRayContainer vcRays; 2659 2687 Intersectable::NewMail(); 2660 BspViewCell *vc;2688 ViewCell *vc; 2661 2689 2662 2690 if (0) // largest view cell pvs first 2663 { 2664 vc = dynamic_cast<BspViewCell *>(mViewCells[i]); 2665 } 2691 vc = mViewCells[i]; 2666 2692 else 2667 { 2668 vc = dynamic_cast<BspViewCell *> 2669 (mViewCells[Random((int)mViewCells.size())]); 2670 } 2693 vc = mViewCells[Random((int)mViewCells.size())]; 2671 2694 2672 2695 if (1) … … 2678 2701 for (int j = 0; j < (int)ray->mViewCells.size(); ++ j) 2679 2702 { 2680 BspViewCell *bspVc = dynamic_cast<BspViewCell *>(ray->mViewCells[j]); 2681 BspLeaf *leaf = bspVc->mLeaf; 2682 if (vc == bspVc) 2703 ViewCell *rayvc = ray->mViewCells[j]; 2704 #if VC_HISTORY 2705 BspLeaf *leaf = rayvc->mLeaf; 2706 if (vc == rayvc) 2683 2707 vcRays.push_back(ray); 2708 #endif 2684 2709 } 2685 2710 } … … 2835 2860 2836 2861 BspNodeGeometry geom; 2837 mVspBspTree-> 2838 ConstructGeometry(dynamic_cast<BspViewCell *>(vc), geom); 2862 mVspBspTree->ConstructGeometry(vc, geom); 2839 2863 exporter->ExportPolygons(geom.mPolys); 2840 2864 } … … 2845 2869 ViewCellContainer leaves; 2846 2870 mViewCellsTree->CollectLeaves(vc, leaves); 2847 2848 2871 2849 2872 int maxDist = 0; … … 2886 2909 2887 2910 BspNodeGeometry geom; 2888 BspViewCell *bspVc = dynamic_cast<BspViewCell *>(vc);2889 mVspBspTree->ConstructGeometry( bspVc, geom);2911 2912 mVspBspTree->ConstructGeometry(vc, geom); 2890 2913 2891 2914 Mesh *mesh = new Mesh(); … … 2984 3007 void VspBspViewCellsManager::Finalize(ViewCell *viewCell, const bool createMesh) 2985 3008 { 2986 BspViewCell *vc = dynamic_cast<BspViewCell *>(viewCell); 2987 CreateMesh(vc); 3009 CreateMesh(viewCell); 2988 3010 2989 3011 float area = 0; … … 2991 3013 2992 3014 ViewCellContainer leaves; 2993 mViewCellsTree->CollectLeaves(v c, leaves);3015 mViewCellsTree->CollectLeaves(viewCell, leaves); 2994 3016 2995 3017 ViewCellContainer::const_iterator it, it_end = leaves.end(); -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h
r581 r582 135 135 @returns new view cell based on the merging. 136 136 */ 137 ViewCellInterior *MergeViewCells(ViewCell &front, ViewCell &back) const; 137 ViewCellInterior *MergeViewCells(ViewCell *front, ViewCell *back) const; 138 139 /** Merges a container of view cells. 140 @returns new view cell based on the merging. 141 */ 142 ViewCellInterior *MergeViewCells(ViewCellContainer &children) const; 138 143 139 144 /** Generates view cell of type specified by this manager … … 429 434 float mMaxPvsRatio; 430 435 431 int mNum ActiveViewCells;436 int mNumMergedViewCells; 432 437 433 438 ViewCellsStatistics mViewCellsStats; -
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
r580 r582 132 132 Debug << "max plane candidates: " << mMaxRayCandidates << endl; 133 133 Debug << "randomize: " << randomize << endl; 134 // Debug << "minimum view cells: " << mMergeMinViewCells << endl; 134 135 135 Debug << "using area for pvs: " << mUseAreaForPvs << endl; 136 136 Debug << "render cost weight: " << mRenderCostWeight << endl; … … 2049 2049 2050 2050 2051 void VspBspTree::ConstructGeometry( BspViewCell *vc,2051 void VspBspTree::ConstructGeometry(ViewCell *vc, 2052 2052 BspNodeGeometry &vcGeom) const 2053 2053 { -
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.h
r580 r582 218 218 /** Construct geometry of view cell. 219 219 */ 220 void ConstructGeometry( BspViewCell *vc, BspNodeGeometry &geom) const;220 void ConstructGeometry(ViewCell *vc, BspNodeGeometry &geom) const; 221 221 222 222 /** Returns random leaf of BSP tree. -
trunk/VUT/GtpVisibilityPreprocessor/src/VspKdTree.cpp
r580 r582 2196 2196 2197 2197 VspKdViewCell *vc = dynamic_cast<VspKdViewCell *>( 2198 mViewCellsManager->MergeViewCells( *fVc, *bVc));2198 mViewCellsManager->MergeViewCells(fVc, bVc)); 2199 2199 2200 2200 // if merge was unsuccessful -
trunk/VUT/GtpVisibilityPreprocessor/src/common.h
r574 r582 145 145 while (0) 146 146 #endif 147 #endif 147 148 #else 148 149 149 150 #ifndef CLEAR_CONTAINER … … 153 154 while (0) 154 155 #endif 156 157 #endif 158 155 159 156 160 inline
Note: See TracChangeset
for help on using the changeset viewer.