Changeset 1141 for GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
- Timestamp:
- 07/18/06 19:03:14 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r1139 r1141 823 823 824 824 Debug << "updating active vc: " << (int)viewCells.size() << endl; 825 // find all already merged view cells and remove them from view cells 825 826 // find all already merged view cells and remove them from the 827 // container view cells 826 828 827 829 // sort out all view cells which are not active anymore, i.e., they … … 883 885 const int upper = mViewCellsManager->GetMaxPvsSize(); 884 886 885 const float penalty = EvalPvsPenalty((*vit)->GetPvs(). GetSize(), lower, upper);887 const float penalty = EvalPvsPenalty((*vit)->GetPvs().CountPvs(), lower, upper); 886 888 887 889 mDeviation += fabs(mAvgRenderCost - penalty); … … 943 945 944 946 // TODO: should be done in view cells manager 945 ViewCellInterior *ViewCellsTree::MergeViewCells(ViewCell *l ,946 ViewCell *r ,947 ViewCellInterior *ViewCellsTree::MergeViewCells(ViewCell *left, 948 ViewCell *right, 947 949 int &pvsDiff) //const 948 950 { 949 ViewCellInterior *vc = mViewCellsManager->MergeViewCells(l, r); 951 // create merged view cell 952 ViewCellInterior *vc = 953 mViewCellsManager->MergeViewCells(left, right); 950 954 951 955 // if merge was unsuccessful … … 953 957 954 958 // set to the new parent view cell 955 l ->SetParent(vc);956 r ->SetParent(vc);957 958 // set new size of view cell959 left->SetParent(vc); 960 right->SetParent(vc); 961 962 959 963 if (mUseAreaForPvs) 960 964 { 961 vc->SetArea(l->GetArea() + l->GetArea()); 965 // set new area of view cell 966 // not not correct, but costly to compute real area!! 967 vc->SetArea(left->GetArea() + right->GetArea()); 962 968 } 963 969 else 964 { 965 vc->SetVolume( r->GetVolume() + l->GetVolume());970 { // set new volume of view cell 971 vc->SetVolume(left->GetVolume() + right->GetVolume()); 966 972 } 967 973 … … 971 977 vc->Mail(); 972 978 973 const int pvs1 = l ->GetPvs().GetSize();974 const int pvs2 = r ->GetPvs().GetSize();975 976 977 // new view cells are stored in this vector979 const int pvs1 = left->GetPvs().CountPvs(); 980 const int pvs2 = right->GetPvs().CountPvs(); 981 982 983 // the new view cells are stored in this container 978 984 mMergedViewCells.push_back(vc); 979 985 980 pvsDiff = vc->GetPvs().GetSize() - pvs1 - pvs2; 981 982 983 984 //Ždon't store intermediate pvs 986 pvsDiff = vc->GetPvs().CountPvs() - pvs1 - pvs2; 987 988 989 // don't store pvs in interior cells, just a scalar 985 990 if (mViewCellsStorage == PVS_IN_LEAVES) 986 991 { 987 l ->mPvsSize = l->GetPvs().GetSize();988 l ->mPvsSizeValid = true;992 left->mPvsSize = left->GetPvs().GetSize(); 993 left->mPvsSizeValid = true; 989 994 990 if (!l->IsLeaf()) 991 l->GetPvs().Clear(); 995 // remove pvs, we don't store interior pvss 996 if (!left->IsLeaf()) 997 { 998 left->GetPvs().Clear(); 999 } 1000 1001 right->mPvsSize = right->GetPvs().CountPvs(); 1002 right->mPvsSizeValid = true; 992 1003 993 r->mPvsSize = r->GetPvs().GetSize(); 994 r->mPvsSizeValid = true; 995 996 if (!r->IsLeaf()) 997 r->GetPvs().Clear(); 998 999 } 1000 1004 // remove pvs, we don't store interior pvss 1005 if (!right->IsLeaf()) 1006 { 1007 right->GetPvs().Clear(); 1008 } 1009 } 1001 1010 1002 1011 return vc; … … 1258 1267 const float penalty = 1259 1268 EvalPvsPenalty(vc->GetPvs().GetSize(), lower, upper); 1269 1260 1270 return (mAvgRenderCost - penalty) * (mAvgRenderCost - penalty) / 1261 1271 (float)mNumActiveViewCells; … … 1274 1284 if (1) 1275 1285 { 1276 const float penalty = EvalPvsPenalty(vc->GetPvs(). GetSize(), lower, upper);1286 const float penalty = EvalPvsPenalty(vc->GetPvs().CountPvs(), lower, upper); 1277 1287 return fabs(mAvgRenderCost - penalty) / (float)mNumActiveViewCells; 1278 1288 } … … 1283 1293 1284 1294 1285 1286 1295 float ViewCellsTree::GetRenderCost(ViewCell *vc) const 1287 1296 { 1288 1297 if (mUseAreaForPvs) 1289 return vc->GetPvs().GetSize() * vc->GetArea(); 1290 1291 return vc->GetPvs().GetSize() * vc->GetVolume(); 1298 { 1299 return vc->GetPvs().CountPvs() * vc->GetArea(); 1300 } 1301 1302 return vc->GetPvs().CountPvs() * vc->GetVolume(); 1292 1303 } 1293 1304 … … 1328 1339 newPvs = (int)ComputeMergedPvsCost(mc.mLeftViewCell->GetPvs(), mc.mRightViewCell->GetPvs()); 1329 1340 1330 const float newPenalty = EvalPvsPenalty(newPvs, 1341 const float newPenalty = EvalPvsPenalty(newPvs, 1331 1342 mViewCellsManager->GetMinPvsSize(), 1332 1343 mViewCellsManager->GetMaxPvsSize()); … … 1477 1488 for (it = interior->mChildren.begin(); it != it_end; ++ it) 1478 1489 { 1479 int pvsSize = GetPvsSize(*it);1490 const int pvsSize = GetPvsSize(*it); 1480 1491 childCost += (float) pvsSize * (*it)->GetVolume(); 1481 1492 childPvs += pvsSize; … … 1603 1614 1604 1615 1605 1606 1616 // delete all the objects from the leaf sets which were moved to parent pvs 1607 1617 ObjectPvsMap::const_iterator oit_end = interior->GetPvs().mEntries.end(); … … 1615 1625 } 1616 1626 } 1617 1618 /*int dummy = interior->GetPvs().GetSize();1619 1620 for (cit = interior->mChildren.begin(); cit != cit_end; ++ cit)1621 {1622 dummy += (*cit)->GetPvs().GetSize();1623 }*/1624 1625 1627 } 1626 1628 … … 1729 1731 { 1730 1732 if (countKdPvs) 1731 pvsSize = vc->GetPvs(). GetSize();1733 pvsSize = vc->GetPvs().CountPvs(); 1732 1734 else 1733 1735 pvsSize = CountKdPvs(dynamic_cast<ViewCellLeaf *>(vc)); … … 1817 1819 case PVS_IN_INTERIORS: 1818 1820 default: 1819 Debug << "in interiors: " << vc->mPvsSize << " $$ " << vc->GetPvs(). GetSize() << endl;1820 pvsSize = vc->GetPvs(). GetSize();1821 Debug << "in interiors: " << vc->mPvsSize << " $$ " << vc->GetPvs().CountPvs() << endl; 1822 pvsSize = vc->GetPvs().CountPvs(); 1821 1823 } 1822 1824 … … 1840 1842 if ((mViewCellsStorage == PVS_IN_INTERIORS) || vc->IsLeaf()) 1841 1843 { 1842 pvsSize = vc->GetPvs(). GetSize();1844 pvsSize = vc->GetPvs().CountPvs(); 1843 1845 } 1844 1846
Note: See TracChangeset
for help on using the changeset viewer.