- Timestamp:
- 01/20/06 11:44:19 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.cpp
r558 r561 26 26 mTotalArea(0.0f), 27 27 mViewCellsFinished(false), 28 mMaxPvsSize(99999) 28 mMaxPvsSize(99999), 29 mMaxPvsRatio(1.0) 29 30 { 30 31 mViewSpaceBox.Initialize(); … … 109 110 110 111 111 bool ViewCellsManager::CheckValid(ViewCell *vc) const 112 { 113 if (vc->GetPvs().GetSize() > mMaxPvsSize) 112 bool ViewCellsManager::CheckValidity(ViewCell *vc, 113 float minPvsRatio, 114 float maxPvsRatio) const 115 { 116 if ((vc->GetPvs().GetSize() > mMaxPvsSize * maxPvsRatio) || 117 (vc->GetPvs().GetSize() < mMaxPvsSize * minPvsRatio)) 118 { 114 119 return false; 120 } 115 121 116 122 return true; … … 421 427 422 428 429 float ViewCellsManager::GetMaxPvsRatio() const 430 { 431 return mMaxPvsRatio; 432 } 433 434 423 435 void ViewCellsManager::ComputeSampleContributions(VssRay &ray) 424 436 { … … 778 790 if (ray->intersections.size() < 2) 779 791 continue; 780 792 #if 0 781 793 iit = ray->intersections.begin(); 782 794 … … 797 809 previousLeaf = leaf; 798 810 } 811 #endif 799 812 } 800 813 … … 1024 1037 } 1025 1038 1026 1027 bool BspViewCellsManager::MergeBspLeafViewCells(BspLeaf *front, BspLeaf *back) const1028 {1029 BspViewCell *viewCell =1030 dynamic_cast<BspViewCell *>(MergeViewCells(*front->GetViewCell(),1031 *back->GetViewCell()));1032 1033 if (!viewCell)1034 return false;1035 1036 //-- change pointer to view cells of all leaves associated with the previous view cells1037 BspViewCell *fVc = front->GetViewCell();1038 BspViewCell *bVc = back->GetViewCell();1039 1040 vector<BspLeaf *> fLeaves = fVc->mLeaves;1041 vector<BspLeaf *> bLeaves = bVc->mLeaves;1042 1043 vector<BspLeaf *>::const_iterator it;1044 1045 for (it = fLeaves.begin(); it != fLeaves.end(); ++ it)1046 {1047 (*it)->SetViewCell(viewCell);1048 viewCell->mLeaves.push_back(*it);1049 }1050 for (it = bLeaves.begin(); it != bLeaves.end(); ++ it)1051 {1052 (*it)->SetViewCell(viewCell);1053 viewCell->mLeaves.push_back(*it);1054 }1055 1056 DEL_PTR(fVc);1057 DEL_PTR(bVc);1058 1059 return true;1060 }1061 1062 bool BspViewCellsManager::ShouldMerge(BspLeaf *front, BspLeaf *back) const1063 {1064 ViewCell *fvc = front->GetViewCell();1065 ViewCell *bvc = back->GetViewCell();1066 1067 if ((fvc == mBspTree->GetRootCell()) || (bvc == mBspTree->GetRootCell()) || (fvc == bvc))1068 return false;1069 1070 int fdiff = fvc->GetPvs().Diff(bvc->GetPvs());1071 1072 if (fvc->GetPvs().GetSize() + fdiff < mMaxPvs)1073 {1074 if ((fvc->GetPvs().GetSize() < mMinPvs) ||1075 (bvc->GetPvs().GetSize() < mMinPvs) ||1076 ((fdiff < mMinPvsDif) && (bvc->GetPvs().Diff(fvc->GetPvs()) < mMinPvsDif)))1077 {1078 return true;1079 }1080 }1081 1082 return false;1083 }1084 1039 1085 1040 … … 1976 1931 int merged = 0; 1977 1932 1978 cout << "starting merge using " << mPostProcessSamples << " samples ... " ;1933 cout << "starting merge using " << mPostProcessSamples << " samples ... " << endl; 1979 1934 long startTime = GetTime(); 1980 1935 … … 1983 1938 1984 1939 //-- stats and visualizations 1985 cout << "finished " << endl;1940 cout << "finished merging" << endl; 1986 1941 cout << "merged " << merged << " view cells in " 1987 1942 << TimeDiff(startTime, GetTime()) *1e-3 << " secs" << endl; … … 2099 2054 2100 2055 // real meshes are only contructed only at this stage 2101 //CreateViewCellMeshes();2102 2056 FinalizeViewCells(true); 2103 2057 … … 2419 2373 ViewCell *vc) const 2420 2374 { 2421 if (CheckValid (vc) && (mColorCode == 0)) // Random color2375 if (CheckValidity(vc, 0.0, mMaxPvsRatio) && (mColorCode == 0)) // Random color 2422 2376 return; 2423 2377 2424 2378 float importance = 0; 2425 2426 2379 Material m; 2427 2380 … … 2453 2406 } 2454 2407 2455 m.mDiffuseColor.b = CheckValid (vc) ? 1.0f : 0.0f;2408 m.mDiffuseColor.b = CheckValidity(vc, 0.0, mMaxPvsRatio) ? 1.0f : 0.0f; 2456 2409 m.mDiffuseColor.r = importance; 2457 2410 m.mDiffuseColor.g = 1.0f - m.mDiffuseColor.r;
Note: See TracChangeset
for help on using the changeset viewer.