Changeset 561 for trunk/VUT/GtpVisibilityPreprocessor/src
- Timestamp:
- 01/20/06 11:44:19 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.cpp
r556 r561 925 925 //glFrustum(-1, 1, -1, 1, 1, 20000); 926 926 927 const Vector3 center = viewPoint + beam.GetMainDirection() * (zfar - znear) * 0.3 ;927 const Vector3 center = viewPoint + beam.GetMainDirection() * (zfar - znear) * 0.3f; 928 928 const Vector3 up = 929 929 Normalize(CrossProd(beam.mPlanes[0].mNormal, beam.mPlanes[4].mNormal)); -
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; -
trunk/VUT/GtpVisibilityPreprocessor/src/ViewCellsManager.h
r557 r561 253 253 /** Checks if view cell is considered as valid. 254 254 */ 255 virtual bool CheckValid(ViewCell *vc) const; 255 virtual bool CheckValidity(ViewCell *vc, 256 float minPvsRatio, 257 float maxPvsRatio) const; 256 258 257 259 /** Returns maximal allowed pvs size. 258 260 */ 259 261 int GetMaxPvsSize() const; 262 263 /** Returns maximal ratio. i.e., currentPVs / maxPvs, 264 where pvs is still considered valid. 265 */ 266 float GetMaxPvsRatio() const; 260 267 261 268 /** Exports view cell geometry. … … 327 334 int mVisualizationSamples; 328 335 329 //-- thresholds used for view cells merge330 int mMinPvsDif;331 int mMinPvs;332 int mMaxPvs;333 334 336 float mTotalAreaValid; 335 337 float mTotalArea; 336 338 337 339 int mMaxPvsSize; 338 339 340 float mMaxPvsRatio; 340 341 … … 410 411 void CollectViewCells(); 411 412 412 /** Merges view cells front and back leaf view cell.413 */414 bool MergeBspLeafViewCells(BspLeaf *front, BspLeaf *back) const;415 416 /** Returns true if front and back leaf should be merged.417 */418 bool ShouldMerge(BspLeaf *front, BspLeaf *back) const;419 420 413 void ConstructBspRays(const VssRayContainer &rays, 421 414 const int numSamples); -
trunk/VUT/GtpVisibilityPreprocessor/src/VspBspTree.cpp
r560 r561 510 510 } 511 511 512 if (!mViewCellsManager->CheckValid (viewCell))512 if (!mViewCellsManager->CheckValidity(viewCell, 0.0, mViewCellsManager->GetMaxPvsRatio())) 513 513 { 514 514 viewCell->SetValid(false); 515 516 515 leaf->SetTreeValid(false); 517 516 PropagateUpValidity(leaf); … … 1645 1644 BspViewCell *viewCell = dynamic_cast<BspLeaf *>(node)->GetViewCell(); 1646 1645 1647 if (!mViewCellsManager->CheckValid (viewCell))1646 if (!mViewCellsManager->CheckValidity(viewCell, 0.0, mViewCellsManager->GetMaxPvsRatio())) 1648 1647 { 1649 1648 vector<BspLeaf *>::const_iterator it, it_end = viewCell->mLeaves.end();
Note: See TracChangeset
for help on using the changeset viewer.