- Timestamp:
- 02/02/06 19:16:39 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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();
Note: See TracChangeset
for help on using the changeset viewer.