- Timestamp:
- 07/28/06 09:37:05 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.cpp
r1143 r1168 17 17 18 18 19 int ObjectPvs::Count Pvs() const19 int ObjectPvs::CountObjectsInPvs() const 20 20 { 21 21 int pvs = 0; … … 31 31 32 32 // found kd node 33 // the pvs is the sum of the objects in the leaves in the subtree 34 // We eliminate already accounted kd nodes and objects 35 // using mailboxing. 33 // the pvs is the number od different objects in the node leaves 34 // We eliminate already accounted kd nodes and objects using mailboxing. 36 35 if (obj->Type() == Intersectable::KD_INTERSECTABLE) 37 36 { … … 47 46 tStack.pop(); 48 47 49 // already processed node (objects in pvs) 50 if (node->Mailed()) 51 continue; 48 // already processed node (= objects in pvs)? 49 if (!node->Mailed()) 50 { 51 node->Mail(); 52 52 53 node->Mail(); 53 if (node->IsLeaf()) 54 { 55 KdLeaf *leaf = dynamic_cast<KdLeaf *>(node); 56 57 // add #objects exclusivly in this node 58 pvs += (int)(leaf->mObjects.size() - leaf->mMultipleObjects.size()); 54 59 55 if (node->IsLeaf()) 56 { 57 KdLeaf *leaf = dynamic_cast<KdLeaf *>(node); 58 59 pvs += (int)(leaf->mObjects.size() - leaf->mMultipleObjects.size()); 60 61 // Objects already accounted for can only be found among those 62 // which are referenced in more than one leaf 63 ObjectContainer::const_iterator oit, oit_end = leaf->mMultipleObjects.end(); 64 for (oit = leaf->mMultipleObjects.begin(); oit != oit_end; ++ oit) 65 { 66 Intersectable *object = *oit; 60 // Objects already accounted for can only be found among those 61 // which are referenced in more than one leaf 62 ObjectContainer::const_iterator oit, oit_end = leaf->mMultipleObjects.end(); 67 63 68 if (!object->Mailed())64 for (oit = leaf->mMultipleObjects.begin(); oit != oit_end; ++ oit) 69 65 { 70 object->Mail(); 71 ++ pvs; 66 Intersectable *object = *oit; 67 68 if (!object->Mailed()) 69 { 70 object->Mail(); 71 ++ pvs; 72 } 72 73 } 73 74 } 74 } 75 else 76 { 77 KdInterior *interior = dynamic_cast<KdInterior *>(node); 75 else // traverse tree 76 { 77 KdInterior *interior = dynamic_cast<KdInterior *>(node); 78 78 79 tStack.push(interior->mFront); 80 tStack.push(interior->mBack); 79 tStack.push(interior->mFront); 80 tStack.push(interior->mBack); 81 } 81 82 } 82 83 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h
r1141 r1168 421 421 { 422 422 public: 423 /** Counts pvs. Different to GetSize(), not423 /** Counts object int the pvs. Different to GetSize(), not 424 424 only the raw container size is returned, 425 425 but the individual contributions of the entries are summed up. 426 426 */ 427 int Count Pvs() const;427 int CountObjectsInPvs() const; 428 428 }; 429 429 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r1166 r1168 254 254 255 255 // update pvs size scalar 256 mPvsSize = mPvs.GetSize();257 mPvsSizeValid = true;256 //mPvsSize = mPvs.GetSize(); 257 mPvsSizeValid = false; // recompute pvs size 258 258 259 259 return result; … … 886 886 const int upper = mViewCellsManager->GetMaxPvsSize(); 887 887 888 const float penalty = EvalPvsPenalty((*vit)->GetPvs().Count Pvs(), lower, upper);888 const float penalty = EvalPvsPenalty((*vit)->GetPvs().CountObjectsInPvs(), lower, upper); 889 889 890 890 mDeviation += fabs(mAvgRenderCost - penalty); … … 978 978 vc->Mail(); 979 979 980 const int pvs1 = left->GetPvs().Count Pvs();981 const int pvs2 = right->GetPvs().Count Pvs();980 const int pvs1 = left->GetPvs().CountObjectsInPvs(); 981 const int pvs2 = right->GetPvs().CountObjectsInPvs(); 982 982 983 983 … … 985 985 mMergedViewCells.push_back(vc); 986 986 987 pvsDiff = vc->GetPvs().Count Pvs() - pvs1 - pvs2;987 pvsDiff = vc->GetPvs().CountObjectsInPvs() - pvs1 - pvs2; 988 988 989 989 … … 991 991 if (mViewCellsStorage == PVS_IN_LEAVES) 992 992 { 993 left->mPvsSize = left->GetPvs().GetSize(); 994 left->mPvsSizeValid = true; 995 993 // set scalars 994 mViewCellsManager->UpdateScalarPvsSize(left, 995 left->GetPvs().CountObjectsInPvs(), 996 left->GetPvs().GetSize()); 997 996 998 // remove pvs, we don't store interior pvss 997 999 if (!left->IsLeaf()) … … 1000 1002 } 1001 1003 1002 right->mPvsSize = right->GetPvs().CountPvs(); 1004 // set scalars 1005 mViewCellsManager->UpdateScalarPvsSize(right, 1006 right->GetPvs().CountObjectsInPvs(), 1007 right->GetPvs().GetSize()); 1008 1003 1009 right->mPvsSizeValid = true; 1004 1010 … … 1285 1291 if (1) 1286 1292 { 1287 const float penalty = EvalPvsPenalty(vc->GetPvs().Count Pvs(), lower, upper);1293 const float penalty = EvalPvsPenalty(vc->GetPvs().CountObjectsInPvs(), lower, upper); 1288 1294 return fabs(mAvgRenderCost - penalty) / (float)mNumActiveViewCells; 1289 1295 } … … 1298 1304 if (mUseAreaForPvs) 1299 1305 { 1300 return vc->GetPvs().Count Pvs() * vc->GetArea();1301 } 1302 1303 return vc->GetPvs().Count Pvs() * vc->GetVolume();1306 return vc->GetPvs().CountObjectsInPvs() * vc->GetArea(); 1307 } 1308 1309 return vc->GetPvs().CountObjectsInPvs() * vc->GetVolume(); 1304 1310 } 1305 1311 … … 1469 1475 const int rootEntries = GetPvsEntries(mRoot); 1470 1476 1477 Debug << "******** Export stats **********" << endl; 1471 1478 /*Debug << "vsb volume: " << vol << endl; 1472 1479 Debug << "root volume: " << mRoot->GetVolume() << endl; … … 1517 1524 1518 1525 ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 1519 1526 Debug << "\nhere92" << endl; 1520 1527 for (it = interior->mChildren.begin(); it != it_end; ++ it) 1521 1528 { 1529 Debug << "here15" << endl; 1522 1530 ViewCell *vc = *it; 1531 1523 1532 const int pvsSize = GetPvsSize(vc); 1524 1533 const int pvsEntries = GetPvsEntries(vc); … … 1532 1541 } 1533 1542 1534 1543 Debug << "\nhere1005" << endl; 1535 1544 const float costDecr = (parentCost - childCost) / vol; 1536 1545 … … 1655 1664 } 1656 1665 1666 1657 1667 // TODO matt: implement this function for different storing methods 1658 1668 void ViewCellsTree::GetPvs(ViewCell *vc, ObjectPvs &pvs) const … … 1708 1718 int ViewCellsTree::GetPvsSizeForLeafStorage(ViewCell *vc) const 1709 1719 { 1710 int pvsSize = 0;1711 1712 1720 // pvs is always stored directly in leaves 1713 1721 if (vc->IsLeaf()) 1714 1722 { 1715 pvsSize = vc->GetPvs().CountPvs(); 1716 //int pvsSize1 = vc->GetPvs().GetSize(); 1717 //Debug << "entries num: " << pvsSize1 << " size: "" << pvsSize << endl; 1718 } 1719 else // interior node 1720 { 1721 // interior nodes: pvs is either stored as a scalar or 1722 // has to be reconstructed from the leaves 1723 1724 // the stored pvs size is the valid pvs size => just return scalar 1725 if (vc->mPvsSizeValid) 1726 { 1727 pvsSize = vc->mPvsSize; 1728 } 1729 1730 // if no valid pvs size stored as a scalar => 1731 // compute current pvs size of interior from it's leaf nodes 1732 ViewCellContainer leaves; 1733 CollectLeaves(vc, leaves); 1734 1735 ViewCellContainer::const_iterator it, it_end = leaves.end(); 1736 1737 Intersectable::NewMail(); 1738 1739 // sum different intersectables 1740 for (it = leaves.begin(); it != it_end; ++ it) 1741 { 1742 pvsSize = GetPvsSizeForLeafStorage(*it); 1743 } 1744 } 1745 1746 return pvsSize; 1723 return vc->GetPvs().CountObjectsInPvs(); 1724 } 1725 1726 // interior node 1727 1728 // interior nodes: pvs is either stored as a scalar or 1729 // has to be reconstructed from the leaves 1730 1731 // the stored pvs size is the valid pvs size => just return scalar 1732 if (vc->mPvsSizeValid) 1733 { 1734 Debug << "here5"<<endl; 1735 return vc->mPvsSize; 1736 } 1737 1738 Debug << "here2"<<endl; 1739 1740 // if no valid pvs size stored as a scalar => 1741 // compute current pvs size of interior from it's leaf nodes 1742 ViewCellContainer leaves; 1743 CollectLeaves(vc, leaves); 1744 1745 ViewCellContainer::const_iterator it, it_end = leaves.end(); 1746 1747 Intersectable::NewMail(); 1748 ObjectPvs newPvs; 1749 1750 // sum different intersectables 1751 for (it = leaves.begin(); it != it_end; ++ it) 1752 { 1753 ObjectPvsMap::iterator oit, oit_end = (*it)->GetPvs().mEntries.end(); 1754 1755 for (oit = (*it)->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 1756 { 1757 Intersectable *intersect = (*oit).first; 1758 1759 if (!intersect->Mailed()) 1760 { 1761 intersect->Mail(); 1762 newPvs.AddSample(intersect, (*oit).second.mSumPdf); 1763 } 1764 } 1765 } 1766 1767 return newPvs.CountObjectsInPvs(); 1747 1768 } 1748 1769 … … 1750 1771 int ViewCellsTree::GetEntriesInPvsForLeafStorage(ViewCell *vc) const 1751 1772 { 1752 int pvsSize = 0;1753 1754 1773 // pvs is always stored directly in leaves 1755 1774 if (vc->IsLeaf()) 1756 1775 { 1757 pvsSize = vc->GetPvs().GetSize(); 1758 } 1759 else // interior node 1760 { 1761 // interior nodes: pvs is either stored as a scalar or 1762 // has to be reconstructed from the leaves 1763 1764 // the stored pvs size is the valid pvs size => just return scalar 1765 if (vc->mPvsSizeValid) 1766 { 1767 pvsSize = vc->mEntriesInPvs; 1768 } 1769 1770 // if no valid pvs size stored as a scalar => 1771 // compute current pvs size of interior from it's leaf nodes 1772 ViewCellContainer leaves; 1773 CollectLeaves(vc, leaves); 1774 1775 ViewCellContainer::const_iterator it, it_end = leaves.end(); 1776 1777 Intersectable::NewMail(); 1778 1779 // sum different intersectables 1780 for (it = leaves.begin(); it != it_end; ++ it) 1781 { 1782 pvsSize = GetEntriesInPvsForLeafStorage(*it); 1776 return vc->GetPvs().GetSize(); 1777 } 1778 1779 // interior node 1780 1781 // interior nodes: pvs is either stored as a scalar or 1782 // has to be reconstructed from the leaves 1783 1784 // the stored pvs size is the valid pvs size => just return scalar 1785 if (vc->mPvsSizeValid) 1786 { 1787 return vc->mEntriesInPvs; 1788 } 1789 1790 int pvsSize = 0; 1791 1792 // if no valid pvs size stored as a scalar => 1793 // compute current pvs size of interior from it's leaf nodes 1794 ViewCellContainer leaves; 1795 CollectLeaves(vc, leaves); 1796 1797 ViewCellContainer::const_iterator it, it_end = leaves.end(); 1798 Intersectable::NewMail(); 1799 1800 // sum different intersectables 1801 for (it = leaves.begin(); it != it_end; ++ it) 1802 { 1803 ObjectPvsMap::iterator oit, oit_end = (*it)->GetPvs().mEntries.end(); 1804 1805 for (oit = (*it)->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 1806 { 1807 Intersectable *intersect = (*oit).first; 1808 1809 if (!intersect->Mailed()) 1810 { 1811 intersect->Mail(); 1812 ++ pvsSize; 1813 } 1783 1814 } 1784 1815 } … … 1916 1947 // pvs is stored consistently in the tree up to the root 1917 1948 // just return pvs size 1918 pvsSize = vc->GetPvs().Count Pvs();1949 pvsSize = vc->GetPvs().CountObjectsInPvs(); 1919 1950 break; 1920 1951 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.h
r1166 r1168 206 206 return a->mPvsSize < b->mPvsSize; 207 207 #else 208 return a->GetPvs().Count Pvs() < b->GetPvs().CountPvs();208 return a->GetPvs().CountObjectsInPvs() < b->GetPvs().CountObjectsInPvs(); 209 209 #endif 210 210 } … … 288 288 /// is up to date and corresponding to the real pvs size 289 289 bool mPvsSizeValid; 290 291 292 290 }; 293 291 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellBsp.cpp
r1141 r1168 1948 1948 << "#polygons: " << (int)data.mPolygons->size() << " (max: " << mTermMinPolys << "), " 1949 1949 << "#rays: " << (int)data.mRays->size() << " (max: " << mTermMinRays << "), " 1950 << "#pvs: " << leaf->GetViewCell()->GetPvs().Count Pvs() << "=, "1950 << "#pvs: " << leaf->GetViewCell()->GetPvs().CountObjectsInPvs() << "=, " 1951 1951 << "#avg ray contrib (pvs): " << (float)data.mPvs / (float)data.mRays->size() << endl; 1952 1952 #endif -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1166 r1168 310 310 Ray *pray = (*it)->mPiercingRays[0]; 311 311 Debug << "view cell " << (*it)->GetId() << " not empty, pvs: " 312 << (*it)->GetPvs().Count Pvs() << " " << (int)pray->intersections.size() << endl;312 << (*it)->GetPvs().CountObjectsInPvs() << " " << (int)pray->intersections.size() << endl; 313 313 314 314 exporter->ExportRays((*it)->mPiercingRays); … … 1200 1200 { 1201 1201 1202 if ((vc->GetPvs().Count Pvs() > maxPvsSize) ||1203 (vc->GetPvs().Count Pvs() < minPvsSize))1202 if ((vc->GetPvs().CountObjectsInPvs() > maxPvsSize) || 1203 (vc->GetPvs().CountObjectsInPvs() < minPvsSize)) 1204 1204 { 1205 1205 return false; … … 1417 1417 { 1418 1418 ViewCell *vc = *it; 1419 totalRenderCost += vc->GetPvs().Count Pvs() * vc->GetVolume();1420 totalPvs += (int)vc->GetPvs().Count Pvs();1419 totalRenderCost += vc->GetPvs().CountObjectsInPvs() * vc->GetVolume(); 1420 totalPvs += (int)vc->GetPvs().CountObjectsInPvs(); 1421 1421 } 1422 1422 … … 1435 1435 ViewCell *vc = *it; 1436 1436 1437 float renderCost = vc->GetPvs().Count Pvs() * vc->GetVolume();1437 float renderCost = vc->GetPvs().CountObjectsInPvs() * vc->GetVolume(); 1438 1438 float dev; 1439 1439 1440 1440 if (1) 1441 dev = fabs(avgRenderCost - (float)vc->GetPvs().Count Pvs());1441 dev = fabs(avgRenderCost - (float)vc->GetPvs().CountObjectsInPvs()); 1442 1442 else 1443 1443 dev = fabs(expectedRenderCost - renderCost); … … 1568 1568 1569 1569 1570 // fast way of merging 2 view cells 1570 /** fast way of merging 2 view cells. 1571 */ 1571 1572 ViewCellInterior *ViewCellsManager::MergeViewCells(ViewCell *left, ViewCell *right) const 1572 1573 { … … 1596 1597 1597 1598 // update pvs size 1598 vc->mPvsSize = vc->GetPvs().CountPvs(); 1599 vc->mPvsSizeValid = true; 1599 UpdateScalarPvsSize(vc, vc->GetPvs().CountObjectsInPvs(), vc->GetPvs().GetSize()); 1600 1600 1601 1601 return vc; … … 2214 2214 2215 2215 2216 void ViewCellsManager::UpdateScalarPvsSize(ViewCell *vc, const int pvsSize, const int entriesInPvs) const 2216 void ViewCellsManager::UpdateScalarPvsSize(ViewCell *vc, 2217 const int pvsSize, 2218 const int entriesInPvs) const 2217 2219 { 2218 2220 vc->mPvsSize = pvsSize; … … 2466 2468 2467 2469 2470 void ViewCellsManager::UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs) 2471 { 2472 // terminate traversal 2473 if (root->IsLeaf()) 2474 { 2475 // we assume that pvs is explicitly stored in leaves 2476 pvs = root->GetPvs(); 2477 UpdateScalarPvsSize(root, pvs.CountObjectsInPvs(), pvs.GetSize()); 2478 2479 return; 2480 } 2481 2482 //-- interior node => propagate pvs up 2483 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(root); 2484 interior->GetPvs().Clear(); 2485 pvs.Clear(); 2486 vector<ObjectPvs> pvsList; 2487 2488 ViewCellContainer::const_iterator vit, vit_end = interior->mChildren.end(); 2489 2490 for (vit = interior->mChildren.begin(); vit != vit_end; ++ vit) 2491 { 2492 ObjectPvs objPvs; 2493 2494 //-- recursivly compute child pvss 2495 UpdatePvsForEvaluation(*vit, objPvs); 2496 2497 // store pvs in vector 2498 pvsList.push_back(objPvs); 2499 } 2500 2501 #if 1 2502 Intersectable::NewMail(); 2503 2504 //-- faster way of computing pvs: 2505 // construct merged pvs by adding 2506 // and only those of the next pvs which were not mailed. 2507 // note: sumpdf is not correct!! 2508 vector<ObjectPvs>::iterator oit = pvsList.begin(); 2509 2510 for (vit = interior->mChildren.begin(); vit != vit_end; ++ vit, ++ oit) 2511 { 2512 ObjectPvsMap::iterator pit, pit_end = (*oit).mEntries.end(); 2513 2514 for (pit = (*oit).mEntries.begin(); pit != pit_end; ++ pit) 2515 { 2516 Intersectable *intersect = (*pit).first; 2517 2518 if (!intersect->Mailed()) 2519 { 2520 pvs.AddSample(intersect, (*pit).second.mSumPdf); 2521 intersect->Mail(); 2522 } 2523 } 2524 } 2525 2526 // store pvs in this node 2527 if (mViewCellsTree->ViewCellsStorage() == ViewCellsTree::PVS_IN_INTERIORS) 2528 { 2529 interior->SetPvs(pvs); 2530 } 2531 2532 // set new pvs size 2533 UpdateScalarPvsSize(interior, pvs.CountObjectsInPvs(), pvs.GetSize()); 2534 2535 2536 #else 2537 2538 // really merge cells: slow put sumpdf is correct 2539 viewCellInterior->GetPvs().Merge(backVc->GetPvs()); 2540 viewCellInterior->GetPvs().Merge(frontVc->GetPvs()); 2541 #endif 2542 } 2543 2468 2544 /*******************************************************************/ 2469 2545 /* BspViewCellsManager implementation */ … … 3193 3269 3194 3270 3195 void BspViewCellsManager::UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs)3196 {3197 // terminate traversal3198 if (root->IsLeaf())3199 {3200 pvs = root->GetPvs();3201 UpdateScalarPvsSize(root, pvs.CountPvs(), pvs.GetSize());3202 3203 return;3204 }3205 3206 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(root);3207 ViewCellContainer::const_iterator vit, vit_end = interior->mChildren.end();3208 3209 vector<ObjectPvs> pvsList;3210 3211 3212 for (vit = interior->mChildren.begin(); vit != vit_end; ++ vit)3213 {3214 ObjectPvs objPvs;3215 3216 //-- recursivly compute child pvss3217 UpdatePvsForEvaluation(*vit, objPvs);3218 3219 // store pvs in vector3220 pvsList.push_back(objPvs);3221 }3222 3223 #if 13224 Intersectable::NewMail();3225 3226 //-- faster way of computing pvs:3227 // construct merged pvs by adding3228 // and only those of the next pvs which were not mailed.3229 // note: sumpdf is not correct!!3230 vector<ObjectPvs>::iterator oit = pvsList.begin();3231 3232 for (vit = interior->mChildren.begin(); vit != vit_end; ++ vit, ++ oit)3233 {3234 3235 ObjectPvsMap::iterator pit, pit_end = (*oit).mEntries.end();3236 3237 for (pit = (*oit).mEntries.begin(); pit != pit_end; ++ pit)3238 {3239 3240 Intersectable *intersect = (*pit).first;3241 3242 if (!intersect->Mailed())3243 {3244 pvs.AddSample(intersect, (*pit).second.mSumPdf);3245 intersect->Mail();3246 }3247 }3248 }3249 3250 // store pvs in this node3251 if (mViewCellsTree->ViewCellsStorage() == ViewCellsTree::PVS_IN_INTERIORS)3252 {3253 interior->SetPvs(pvs);3254 }3255 3256 // set correct pvs size for interior3257 UpdateScalarPvsSize(interior, pvs.CountPvs(), pvs.GetSize());3258 3259 #else3260 // really merge cells: slow nut sumpdf is correct3261 ViewCellInterior *viewCellInterior = new ViewCellInterior();3262 3263 viewCellInterior->GetPvs().Merge(backVc->GetPvs());3264 viewCellInterior->GetPvs().Merge(frontVc->GetPvs());3265 #endif3266 3267 }3268 3269 3271 /************************************************************************/ 3270 3272 /* KdViewCellsManager implementation */ … … 4075 4077 4076 4078 4077 4078 void VspBspViewCellsManager::UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs)4079 {4080 // terminate traversal4081 if (root->IsLeaf())4082 {4083 pvs = root->GetPvs();4084 UpdateScalarPvsSize(root, pvs.CountPvs(), pvs.GetSize());4085 4086 return;4087 }4088 4089 //-- interior node => propagate pvs up4090 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(root);4091 interior->GetPvs().Clear();4092 pvs.Clear();4093 vector<ObjectPvs> pvsList;4094 4095 ViewCellContainer::const_iterator vit, vit_end = interior->mChildren.end();4096 4097 for (vit = interior->mChildren.begin(); vit != vit_end; ++ vit)4098 {4099 ObjectPvs objPvs;4100 4101 //-- recursivly compute child pvss4102 UpdatePvsForEvaluation(*vit, objPvs);4103 4104 // store pvs in vector4105 pvsList.push_back(objPvs);4106 }4107 4108 #if 14109 4110 Intersectable::NewMail();4111 4112 //-- faster way of computing pvs:4113 // construct merged pvs by adding4114 // and only those of the next pvs which were not mailed.4115 // note: sumpdf is not correct!!4116 vector<ObjectPvs>::iterator oit = pvsList.begin();4117 4118 for (vit = interior->mChildren.begin(); vit != vit_end; ++ vit, ++ oit)4119 {4120 ObjectPvsMap::iterator pit, pit_end = (*oit).mEntries.end();4121 4122 for (pit = (*oit).mEntries.begin(); pit != pit_end; ++ pit)4123 {4124 Intersectable *intersect = (*pit).first;4125 4126 if (!intersect->Mailed())4127 {4128 pvs.AddSample(intersect, (*pit).second.mSumPdf);4129 intersect->Mail();4130 }4131 }4132 }4133 4134 // store pvs in this node4135 if (mViewCellsTree->ViewCellsStorage() == ViewCellsTree::PVS_IN_INTERIORS)4136 {4137 interior->SetPvs(pvs);4138 }4139 4140 // set new pvs size4141 UpdateScalarPvsSize(interior, pvs.CountPvs(), pvs.GetSize());4142 4143 4144 #else4145 4146 // really merge cells: slow but sumpdf is correct4147 viewCellInterior->GetPvs().Merge(backVc->GetPvs());4148 viewCellInterior->GetPvs().Merge(frontVc->GetPvs());4149 #endif4150 4151 }4152 4153 4154 4079 bool VspBspViewCellsManager::GetViewPoint(Vector3 &viewPoint) const 4155 4080 { … … 4646 4571 4647 4572 const int pvsVc = mViewCellsTree->GetPvsEntries(vc); 4648 const int pvs 2= (*vit).second.GetSize();4649 4650 m.mDiffuseColor.r = (float) (pvsVc - pvs 2);4573 const int pvsPtSamples = (*vit).second.GetSize(); 4574 4575 m.mDiffuseColor.r = (float) (pvsVc - pvsPtSamples); 4651 4576 m.mDiffuseColor.b = 1.0f; 4652 4577 //exporter->SetForcedMaterial(m); … … 5153 5078 5154 5079 return viewCellInterior; 5155 }5156 5157 5158 5159 void VspOspViewCellsManager::UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs)5160 {5161 // terminate traversal5162 if (root->IsLeaf())5163 {5164 // we assume that pvs is explicitly stored in leaves5165 pvs = root->GetPvs();5166 UpdateScalarPvsSize(root, pvs.CountPvs(), pvs.GetSize());5167 5168 return;5169 }5170 5171 //-- interior node => propagate pvs up5172 ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(root);5173 interior->GetPvs().Clear();5174 pvs.Clear();5175 vector<ObjectPvs> pvsList;5176 5177 ViewCellContainer::const_iterator vit, vit_end = interior->mChildren.end();5178 5179 for (vit = interior->mChildren.begin(); vit != vit_end; ++ vit)5180 {5181 ObjectPvs objPvs;5182 5183 //-- recursivly compute child pvss5184 UpdatePvsForEvaluation(*vit, objPvs);5185 5186 // store pvs in vector5187 pvsList.push_back(objPvs);5188 }5189 5190 #if 15191 Intersectable::NewMail();5192 5193 //-- faster way of computing pvs:5194 // construct merged pvs by adding5195 // and only those of the next pvs which were not mailed.5196 // note: sumpdf is not correct!!5197 vector<ObjectPvs>::iterator oit = pvsList.begin();5198 5199 for (vit = interior->mChildren.begin(); vit != vit_end; ++ vit, ++ oit)5200 {5201 ObjectPvsMap::iterator pit, pit_end = (*oit).mEntries.end();5202 5203 for (pit = (*oit).mEntries.begin(); pit != pit_end; ++ pit)5204 {5205 Intersectable *intersect = (*pit).first;5206 5207 if (!intersect->Mailed())5208 {5209 pvs.AddSample(intersect, (*pit).second.mSumPdf);5210 intersect->Mail();5211 }5212 }5213 }5214 5215 // store pvs in this node5216 if (mViewCellsTree->ViewCellsStorage() == ViewCellsTree::PVS_IN_INTERIORS)5217 {5218 interior->SetPvs(pvs);5219 }5220 5221 // set new pvs size5222 UpdateScalarPvsSize(interior, pvs.CountPvs(), pvs.GetSize());5223 5224 5225 #else5226 5227 // really merge cells: slow put sumpdf is correct5228 viewCellInterior->GetPvs().Merge(backVc->GetPvs());5229 viewCellInterior->GetPvs().Merge(frontVc->GetPvs());5230 #endif5231 5080 } 5232 5081 … … 5520 5369 exporter->ExportRays(vcRays, RgbColor(1, 1, 0)); 5521 5370 } 5522 5523 } 5524 5371 } 5525 5372 5526 5373 //-- export view cell geometry … … 5797 5644 if (ray.mTerminationObject) 5798 5645 { 5646 // todo: maybe not correct for kd node pvs 5799 5647 if (viewcell->GetPvs().GetSampleContribution(ray.mTerminationObject, 5800 5648 ray.mPdf, contribution)) … … 5852 5700 #if SAMPLE_ORIGIN_OBJECTS 5853 5701 if (ray.mOriginObject) 5854 viewcell->AddPvsSample(ray.mOriginObject, ray.mPdf, ray.mPvsContribution); 5702 { 5703 if (!mStoreKdPvs) 5704 { 5705 viewcell->AddPvsSample(ray.mOriginObject, ray.mPdf, ray.mPvsContribution); 5706 } 5707 else 5708 { 5709 /// get current leaf the point 5710 KdLeaf *leaf = mOspTree->GetLeaf(ray.mOrigin); 5711 KdIntersectable *entry = mOspTree->GetOrCreateKdIntersectable(leaf); 5712 5713 viewcell->AddPvsSample(entry, ray.mPdf, ray.mRelativePvsContribution); 5714 } 5715 } 5855 5716 #endif 5856 5717 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h
r1160 r1168 579 579 /** Updates pvs of all view cells for statistical evaluation after some more sampling 580 580 */ 581 v irtual void UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs) = 0;581 void UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs); 582 582 583 583 … … 736 736 ViewCell *ConstructSpatialMergeTree(BspNode *root); 737 737 738 /** Updates the pvs in the view cells tree. 739 */ 740 void UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs); 741 742 738 743 739 protected: 744 740 … … 815 811 protected: 816 812 817 virtual void UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs) {};818 813 /** Collects view cells from a hierarchy. 819 814 */ … … 924 919 ViewCell *ConstructSpatialMergeTree(BspNode *root); 925 920 926 void UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs);927 928 929 921 /// HACK for testing visibility filter functionality 930 922 void TestFilter(const ObjectContainer &objects); 931 932 923 933 924 /** Visualization of the pvs difference to exact visubility using … … 1040 1031 ViewCell *ConstructSpatialMergeTree(VspNode *root); 1041 1032 1042 void UpdatePvsForEvaluation(ViewCell *root, ObjectPvs &pvs);1043 1044 1033 /** Exports visualization of the PVS. 1045 1034 */ … … 1048 1037 1049 1038 1039 ///////////////////////////////////////// 1050 1040 /// the view space partition tree. 1051 1041 VspTree *mVspTree; -
GTP/trunk/Lib/Vis/Preprocessing/src/VrmlExporter.cpp
r1166 r1168 262 262 263 263 mForcedMaterial.mDiffuseColor.b = 1.0f; 264 const float importance = (float)leaf->GetViewCell()->GetPvs().Count Pvs() / (float)maxPvs;264 const float importance = (float)leaf->GetViewCell()->GetPvs().CountObjectsInPvs() / (float)maxPvs; 265 265 266 266 mForcedMaterial.mDiffuseColor.r = importance; -
GTP/trunk/Lib/Vis/Preprocessing/src/VspBspTree.cpp
r1160 r1168 843 843 // update scalar pvs size lookup 844 844 ObjectPvs &pvs = viewCell->GetPvs(); 845 mViewCellsManager->UpdateScalarPvsSize(viewCell, pvs.Count Pvs(), pvs.GetSize());845 mViewCellsManager->UpdateScalarPvsSize(viewCell, pvs.CountObjectsInPvs(), pvs.GetSize()); 846 846 847 847 … … 984 984 // update scalar pvs size value 985 985 ObjectPvs &pvs = viewCell->GetPvs(); 986 mViewCellsManager->UpdateScalarPvsSize(viewCell, pvs.Count Pvs(), pvs.GetSize());986 mViewCellsManager->UpdateScalarPvsSize(viewCell, pvs.CountObjectsInPvs(), pvs.GetSize()); 987 987 988 988 mBspStats.contributingSamples += conSamp; … … 2419 2419 if (leaf->TreeValid() && 2420 2420 (!onlyUnmailed || !leaf->Mailed()) && 2421 ((maxPvsSize < 0) || (leaf->GetViewCell()->GetPvs().Count Pvs() <= maxPvsSize)))2421 ((maxPvsSize < 0) || (leaf->GetViewCell()->GetPvs().CountObjectsInPvs() <= maxPvsSize))) 2422 2422 { 2423 2423 leaves.push_back(leaf); … … 2496 2496 << "PVS: " << data.mPvs << " (min: " << mTermMinPvs << "), " 2497 2497 << "#rays: " << (int)data.mRays->size() << " (max: " << mTermMinRays << "), " 2498 << "#pvs: " << leaf->GetViewCell()->GetPvs().Count Pvs() << "), "2498 << "#pvs: " << leaf->GetViewCell()->GetPvs().CountObjectsInPvs() << "), " 2499 2499 << "#avg ray contrib (pvs): " << (float)data.mPvs / (float)data.mRays->size() << endl; 2500 2500 #endif -
GTP/trunk/Lib/Vis/Preprocessing/src/VspOspTree.cpp
r1166 r1168 610 610 // update scalar pvs size value 611 611 ObjectPvs &pvs = viewCell->GetPvs(); 612 mViewCellsManager->UpdateScalarPvsSize(viewCell, pvs.Count Pvs(), pvs.GetSize());612 mViewCellsManager->UpdateScalarPvsSize(viewCell, pvs.CountObjectsInPvs(), pvs.GetSize()); 613 613 614 614 mVspStats.contributingSamples += conSamp; … … 725 725 // update scalar pvs size value 726 726 ObjectPvs &pvs = viewCell->GetPvs(); 727 mViewCellsManager->UpdateScalarPvsSize(viewCell, pvs.Count Pvs(), pvs.GetSize());727 mViewCellsManager->UpdateScalarPvsSize(viewCell, pvs.CountObjectsInPvs(), pvs.GetSize()); 728 728 729 729 mVspStats.contributingSamples += conSamp; … … 1797 1797 if (leaf->TreeValid() && 1798 1798 (!onlyUnmailed || !leaf->Mailed()) && 1799 ((maxPvsSize < 0) || (leaf->GetViewCell()->GetPvs().Count Pvs() <= maxPvsSize)))1799 ((maxPvsSize < 0) || (leaf->GetViewCell()->GetPvs().CountObjectsInPvs() <= maxPvsSize))) 1800 1800 { 1801 1801 leaves.push_back(leaf); … … 1874 1874 << "PVS: " << data.mPvs << " (min: " << mTermMinPvs << "), " 1875 1875 << "#rays: " << (int)data.mRays->size() << " (max: " << mTermMinRays << "), " 1876 << "#pvs: " << leaf->GetViewCell()->GetPvs().Count Pvs() << "), "1876 << "#pvs: " << leaf->GetViewCell()->GetPvs().CountObjectsInPvs() << "), " 1877 1877 << "#avg ray contrib (pvs): " << (float)data.mPvs / (float)data.mRays->size() << endl; 1878 1878 #endif … … 4496 4496 mTotalCost -= splitCandidate->GetRenderCostDecrease(); 4497 4497 4498 //-- subdivide leaf node4499 SubdivideSplitCandidate(splitCandidate);4500 4501 4498 // cost ratio of cost decrease / totalCost 4502 4499 const float costRatio = splitCandidate->GetRenderCostDecrease() / mTotalCost; … … 4506 4503 << splitCandidate->GetRenderCostDecrease() 4507 4504 << " cost ratio: " << costRatio << endl << endl; 4505 4506 //-- subdivide leaf node 4507 SubdivideSplitCandidate(splitCandidate); 4508 4508 4509 4509 if (costRatio < mTermMinGlobalCostRatio) -
GTP/trunk/Lib/Vis/Preprocessing/src/X3dExporter.cpp
r1141 r1168 298 298 mForcedMaterial.mDiffuseColor.b = 1.0f; 299 299 const float importance = 300 (float)leaf->GetViewCell()->GetPvs().Count Pvs() / (float)maxPvs;300 (float)leaf->GetViewCell()->GetPvs().CountObjectsInPvs() / (float)maxPvs; 301 301 302 302 mForcedMaterial.mDiffuseColor.r = importance;
Note: See TracChangeset
for help on using the changeset viewer.