Changeset 1742 for GTP/trunk/Lib/Vis
- Timestamp:
- 11/13/06 03:26:51 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/HierarchyManager.cpp
r1741 r1742 1841 1841 1842 1842 // hack: should not be done here 1843 ObjectPvsEntries::const_iterator oit, oit_end = pvs.mEntries.end(); 1844 1845 for (oit = pvs.mEntries.begin(); oit != oit_end; ++ oit) 1846 { 1847 BvhIntersectable *intersect = dynamic_cast<BvhIntersectable *>((*oit).mObject); 1843 ObjectPvsIterator pit = pvs.GetIterator(); 1844 1845 while (pit.HasMoreEntries()) 1846 { 1847 ObjectPvsEntry entry = pit.Next(); 1848 1849 BvhIntersectable *intersect = dynamic_cast<BvhIntersectable *>(entry.mObject); 1848 1850 1849 1851 BvhLeaf *leaf = intersect->GetItem(); -
GTP/trunk/Lib/Vis/Preprocessing/src/Pvs.h
r1741 r1742 121 121 122 122 123 template<typename T, typename S>123 /*template<typename T, typename S> 124 124 class PvsIterator 125 125 { 126 Next(PvsEntry<T, S>) 126 127 private: 127 128 typename vector<PvsEntry<T, S> >::iterator mItCurrent; 128 129 typename vector<PvsEntry<T, S> >::iterator mItEnd; 130 };*/ 131 132 133 template<typename T, typename S> 134 class PvsIterator 135 { 136 public: 137 PvsIterator<T, S>(){} 138 PvsIterator<T, S>(const typename vector<PvsEntry<T, S> >::const_iterator &itCurrent, 139 const typename vector<PvsEntry<T, S> >::const_iterator &itEnd): 140 mItCurrent(itCurrent), mItEnd(itEnd) 141 { 142 } 143 144 bool HasMoreEntries() const 145 { 146 return (mItCurrent != mItEnd); 147 } 148 149 PvsEntry<T, S> Next() 150 { 151 return *(mItCurrent ++); 152 } 153 154 private: 155 typename vector<PvsEntry<T, S> >::const_iterator mItCurrent; 156 typename vector<PvsEntry<T, S> >::const_iterator mItEnd; 129 157 }; 130 158 … … 143 171 Pvs(): mSamples(0), mEntries() {} 144 172 173 /** creates pvs and initializes it with the given entries. 174 Assumes that entries are sorted- 175 */ 145 176 Pvs(const vector<PvsEntry<T, S> > &samples); 146 //virtual ~Pvs();177 virtual ~Pvs() {}; 147 178 148 179 /** Compresses PVS lossless or lossy. … … 185 216 float AddSample(T sample, const float pdf); 186 217 187 /** Adds sample to PVS. 218 /** Adds sample to PVS. Assumes that the pvs is sorted 188 219 @returns contribution of sample (0 or 1) 189 220 */ … … 234 265 static void Merge(Pvs<T, S> &mergedPvs, const Pvs<T, S> &a, const Pvs<T, S> &b); 235 266 236 //protected: 267 int GetSamples() const 268 { 269 return mSamples; 270 } 271 272 typename PvsIterator<T, S> GetIterator() const; 273 274 protected: 237 275 238 276 /// vector of PVS entries … … 373 411 std::vector<PvsEntry<T, S> >::const_iterator ait = a.mEntries.begin(), ait_end = a.mEntries.end(); 374 412 std::vector<PvsEntry<T, S> >::const_iterator bit = b.mEntries.begin(), bit_end = b.mEntries.end(); 375 Intersectable::NewMail();376 cout << "a: " << a.mEntries.size() << " b " << b.mEntries.size() << endl;377 413 378 414 for (; (ait != ait_end); ++ ait) … … 387 423 388 424 // object found => add up probabilities 389 if (bObj != aEntry.mObject)425 if (bObj == aEntry.mObject) 390 426 { 391 427 PvsData newData(aEntry.mData.mSumPdf + (*bit).mData.mSumPdf); 392 428 PvsEntry<T, S> entry(bObj, newData); 393 429 mergedPvs.mEntries.push_back(entry); 394 if (bObj->Mailed())395 cout << "Error2 " << bObj << endl;396 bObj->Mail();397 cout << "e: " << (int)bObj;398 430 } 399 431 else 400 432 { 401 if (bObj->Mailed())402 cout << "Error3 " << bObj << endl;403 bObj->Mail();404 433 mergedPvs.mEntries.push_back(*bit); 405 cout << "e: " << (int)bObj;406 434 } 407 435 } … … 412 440 { 413 441 mergedPvs.mEntries.push_back(*ait); 414 if (aObj->Mailed())415 cout << "Error1 " << aObj << endl;416 aObj->Mail();417 cout << "e: " << (int)aObj;418 442 } 419 443 } … … 422 446 for (; (bit != bit_end); ++ bit) 423 447 { 424 Intersectable *bObj = (*bit).mObject;425 426 448 mergedPvs.mEntries.push_back(*bit); 427 if (bObj->Mailed()) 428 cout << "Error4 " << bObj << endl; 429 bObj->Mail(); 430 cout << "e: " << (int)bObj; 431 } 432 433 /* 434 while ((ait != ait_end) || (bit != bit_end)) 435 {cout << "x"; 436 437 // first iterate through first vector until we find the objects 438 for (; (ait != ait_end) && ((bit == bit_end) || ((*ait).mObject <= (*bit).mObject)); ++ ait) 439 { 440 Intersectable *obj = (*ait).mObject; 441 aEntry = (*ait); 442 //bObject = (bit != bit_end) ? (*bit).mObject : NULL; 443 444 // only push back if objects different 445 // (equal case is handled by second loop) 446 if (obj != bEntry.mObject) 447 { 448 mergedPvs.mEntries.push_back(*ait); 449 if (obj->Mailed()) 450 cout << "Error1 " << obj << endl; 451 obj->Mail(); 452 cout << "e: " << obj; 453 } 454 } 455 456 // iterate through second pvs 457 for (; (bit != bit_end) && ((ait == ait_end) || ((*bit).mObject <= (*ait).mObject)); ++ bit) 458 { 459 Intersectable *obj = (*bit).mObject; 460 bEntry = (*bit); 461 //aObject = (ait != ait_end) ? (*ait).mObject : NULL; 462 463 // object found => add up probabilities 464 if (obj != aEntry.mObject) 465 { 466 PvsData newData(aEntry.mData.mSumPdf + bEntry.mData.mSumPdf); 467 PvsEntry<T, S> entry(obj, newData); 468 mergedPvs.mEntries.push_back(entry); 469 if (obj->Mailed()) 470 cout << "Error2 " << obj << endl; 471 obj->Mail(); 472 cout << "e: " << obj; 473 } 474 else 475 { 476 if (obj->Mailed()) 477 cout << "Error3 " << obj << endl; 478 obj->Mail(); 479 mergedPvs.mEntries.push_back(*bit); 480 cout << "e: " << obj; 481 } 482 } 483 }*/ 449 } 484 450 } 485 451 … … 545 511 S &data = (*it).mData; 546 512 data.mSumPdf += pdf; 547 cout << "w";548 513 return data.mSumPdf; 549 514 } … … 551 516 { 552 517 PvsEntry<T, S> entry(sample, pdf); 553 cout << "i";554 518 mEntries.insert(it, entry); 555 519 return pdf; … … 564 528 std::vector<PvsEntry<T, S> >::iterator it = Find(sample); 565 529 566 if ((it != mEntries.end()) && ((*it). first == T))530 if ((it != mEntries.end()) && ((*it).mObject == sample)) 567 531 { 568 532 S &data = (*it).second; … … 732 696 733 697 698 template <typename T, typename S> 699 typename PvsIterator<T, S> Pvs<T, S>::GetIterator() const 700 { 701 PvsIterator<T, S> pit(mEntries.begin(), mEntries.end()); 702 703 return pit; 704 } 705 706 734 707 /////////////////////////////////////// 735 708 … … 757 730 //-- typedefs 758 731 759 typedef std::vector<PvsEntry<Intersectable *, PvsData> > ObjectPvsEntries; 732 typedef PvsEntry<Intersectable *, PvsData> ObjectPvsEntry; 733 typedef std::vector<ObjectPvsEntry> ObjectPvsEntries; 760 734 typedef Pvs<ViewCell *, MailablePvsData> ViewCellPvs; 761 735 typedef PvsIterator<Intersectable *, PvsData> ObjectPvsIterator; 762 736 } 763 737 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCell.cpp
r1741 r1742 61 61 int count = 0; 62 62 63 ObjectPvsEntries::const_iterator it, it_end = vc->GetPvs().mEntries.end(); 64 for (it = vc->GetPvs().mEntries.begin(); it != it_end; ++ it) 65 { 66 if (!(*it).mObject->Mailed()) 67 { 68 (*it).mObject->Mail(); 63 ObjectPvsIterator pit = vc->GetPvs().GetIterator(); 64 65 while (pit.HasMoreEntries()) 66 { 67 ObjectPvsEntry entry = pit.Next(); 68 69 if (!entry.mObject->Mailed()) 70 { 71 entry.mObject->Mail(); 69 72 ++ count; 70 73 } … … 76 79 77 80 /// Fast computation of merged pvs size 78 static float ComputeMergedPvsCost(const ObjectPvs &pvs1, const ObjectPvs &pvs2) 81 static float ComputeMergedPvsCost(const ObjectPvs &pvs1, 82 const ObjectPvs &pvs2) 79 83 { 80 84 // add first pvs 81 85 float pvs = (float)pvs1.GetSize(); 82 86 83 ObjectPvsEntries::const_iterator it, it_end = pvs1.mEntries.end();84 85 87 Intersectable::NewMail(); 86 88 87 89 // mail all objects in first pvs 88 for (it = pvs1.mEntries.begin(); it != it_end; ++ it) 89 { 90 (*it).mObject->Mail(); 91 } 92 93 it_end = pvs2.mEntries.end(); 94 95 // look if the entries are also in second pvs 96 for (it = pvs2.mEntries.begin(); it != it_end; ++ it) 97 { 98 Intersectable *obj = (*it).mObject; 90 ObjectPvsIterator pit = pvs1.GetIterator(); 91 92 while (pit.HasMoreEntries()) 93 { 94 ObjectPvsEntry entry = pit.Next(); 95 entry.mObject->Mail(); 96 } 97 98 pit = pvs2.GetIterator(); 99 100 while (pit.HasMoreEntries()) 101 { 102 ObjectPvsEntry entry = pit.Next(); 103 104 Intersectable *obj = entry.mObject; 99 105 if (!obj->Mailed()) 100 106 ++ pvs; … … 830 836 831 837 // compute new pvs size 832 ObjectPvsEntries::const_iterator it, it_end = pvs1.mEntries.end();833 834 838 Intersectable::NewMail(); 835 839 840 ObjectPvsIterator pit = pvs1.GetIterator(); 841 836 842 // first mail all objects in first pvs 837 for (it = pvs1.mEntries.begin(); it != it_end; ++ it) 838 { 839 Intersectable *obj = (*it).mObject; 843 while (pit.HasMoreEntries()) 844 { 845 ObjectPvsEntry entry = pit.Next(); 846 847 Intersectable *obj = entry.mObject; 840 848 841 849 obj->Mail(); … … 843 851 } 844 852 845 it_end = pvs2.mEntries.end();846 847 848 for (it = pvs2.mEntries.begin(); it != it_end; ++ it)849 {850 Intersectable *obj = (*it).mObject;853 ObjectPvsIterator pit2 = pvs2.GetIterator(); 854 855 while (pit2.HasMoreEntries()) 856 { 857 ObjectPvsEntry entry = pit2.Next(); 858 Intersectable *obj = entry.mObject; 851 859 852 860 // test if object already considered … … 1636 1644 } 1637 1645 } 1638 1646 1639 1647 1640 1648 void ViewCellsTree::PullUpVisibility(ViewCellInterior *interior) … … 1643 1651 1644 1652 ViewCellContainer::const_iterator cit, cit_end = interior->mChildren.end(); 1645 1646 ObjectPvsEntries::const_iterator oit;1647 1653 1648 1654 // mail all objects in the leaf sets … … 1653 1659 ViewCell *vc = *cit; 1654 1660 1655 ObjectPvsEntries::const_iterator oit_end = vc->GetPvs().mEntries.end(); 1656 1657 for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 1658 { 1659 Intersectable *obj = (*oit).mObject; 1661 ObjectPvsIterator pit = vc->GetPvs().GetIterator(); 1662 1663 while (pit.HasMoreEntries()) 1664 { 1665 ObjectPvsEntry entry = pit.Next(); 1666 Intersectable *obj = entry.mObject; 1667 1660 1668 if ((cit == interior->mChildren.begin()) && !obj->Mailed()) 1669 { 1661 1670 obj->Mail(); 1662 1671 } 1672 1663 1673 int incm = obj->IncMail(); 1664 1674 } … … 1666 1676 1667 1677 interior->GetPvs().Clear(); 1668 1669 1678 1670 1679 // only the objects which are present in all leaf pvs 1671 1680 // should remain in the parent pvs … … 1674 1683 { 1675 1684 ViewCell *vc = *cit; 1676 1677 ObjectPvs Entries::const_iterator oit_end = vc->GetPvs().mEntries.end();1678 1679 for (oit = vc->GetPvs().mEntries.begin(); oit != oit_end; ++ oit)1685 1686 ObjectPvsIterator pit = vc->GetPvs().GetIterator(); 1687 1688 while (pit.HasMoreEntries()) 1680 1689 { 1681 if ((*oit).mObject->Mailed((int)interior->mChildren.size())) 1690 ObjectPvsEntry entry = pit.Next(); 1691 1692 if (entry.mObject->Mailed((int)interior->mChildren.size())) 1682 1693 { 1683 interior->GetPvs().AddSample( (*oit).mObject, (*oit).mData.mSumPdf);1694 interior->GetPvs().AddSample(entry.mObject, entry.mData.mSumPdf); 1684 1695 } 1685 1696 } 1686 1697 } 1687 1698 1688 1689 1699 // delete all the objects from the leaf sets which were moved to parent pvs 1690 ObjectPvsEntries::const_iterator oit_end = interior->GetPvs().mEntries.end(); 1691 1692 for (oit = interior->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 1693 { 1700 ObjectPvsIterator pit = interior->GetPvs().GetIterator(); 1701 1702 while (pit.HasMoreEntries()) 1703 { 1704 ObjectPvsEntry entry = pit.Next(); 1705 1694 1706 for (cit = interior->mChildren.begin(); cit != cit_end; ++ cit) 1695 1707 { 1696 if (!(*cit)->GetPvs().RemoveSample( (*oit).mObject, Limits::Infinity))1708 if (!(*cit)->GetPvs().RemoveSample(entry.mObject, Limits::Infinity)) 1697 1709 { 1698 1710 Debug << "should not come here!" << endl; … … 1723 1735 { 1724 1736 root = root->GetParent(); 1725 cout << "h";1726 1737 pvs.MergeInPlace(root->GetPvs()); 1727 1738 } … … 1735 1746 vc = tstack.top(); 1736 1747 tstack.pop(); 1737 1748 1738 1749 // add newly found pvs to merged pvs 1739 1750 ObjectPvs interPvs; … … 1783 1794 for (it = leaves.begin(); it != it_end; ++ it) 1784 1795 { 1785 ObjectPvsEntries::iterator oit, oit_end = (*it)->GetPvs().mEntries.end(); 1786 1787 for (oit = (*it)->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 1788 { 1789 Intersectable *intersect = (*oit).mObject; 1796 ObjectPvsIterator oit = (*it)->GetPvs().GetIterator(); 1797 1798 while (oit.HasMoreEntries()) 1799 { 1800 ObjectPvsEntry entry = oit.Next(); 1801 Intersectable *intersect = entry.mObject; 1790 1802 1791 1803 if (!intersect->Mailed()) 1792 1804 { 1793 1805 intersect->Mail(); 1794 newPvs.AddSample(intersect, (*oit).mData.mSumPdf);1806 newPvs.AddSample(intersect, entry.mData.mSumPdf); 1795 1807 } 1796 1808 } … … 1833 1845 for (it = leaves.begin(); it != it_end; ++ it) 1834 1846 { 1835 ObjectPvsEntries::iterator oit, oit_end = (*it)->GetPvs().mEntries.end(); 1836 1837 for (oit = (*it)->GetPvs().mEntries.begin(); oit != oit_end; ++ oit) 1838 { 1839 Intersectable *intersect = (*oit).mObject; 1847 ObjectPvsIterator oit = (*it)->GetPvs().GetIterator(); 1848 1849 while (oit.HasMoreEntries()) 1850 { 1851 ObjectPvsEntry entry = oit.Next(); 1852 Intersectable *intersect = entry.mObject; 1840 1853 1841 1854 if (!intersect->Mailed()) … … 1975 1988 case PVS_IN_INTERIORS: 1976 1989 default: 1977 // pvs is stored consistently in the tree up to the root1978 // just return pvs size1990 // pvs is stored consistently in the tree up 1991 //to the root just return pvs size 1979 1992 pvsCost = vc->GetPvs().EvalPvsCost(); 1980 1993 break; … … 2350 2363 void ViewCellsTree::ExportPvs(ViewCell *viewCell, OUT_STREAM &stream) 2351 2364 { 2352 ObjectPvsEntries::iterator it, it_end = viewCell->GetPvs().mEntries.end(); 2353 2354 for (it = viewCell->GetPvs().mEntries.begin(); it != it_end; ++ it) 2355 { 2356 Intersectable *obj = (*it).mObject; 2365 ObjectPvsIterator it = viewCell->GetPvs().GetIterator(); 2366 2367 while (it.HasMoreEntries()) 2368 { 2369 ObjectPvsEntry entry; 2370 Intersectable *obj = entry.mObject; 2371 2357 2372 // hack: just output full pvs 2358 2373 if (obj->Type() == Intersectable::BVH_INTERSECTABLE) … … 2370 2385 else 2371 2386 { 2372 stream << (*it).mObject->GetId() << " ";2387 stream << entry.mObject->GetId() << " "; 2373 2388 } 2374 2389 } … … 2464 2479 2465 2480 2466 2467 2481 /**************************************************************************/ 2468 2482 /* MergeCandidate implementation */ … … 2586 2600 } 2587 2601 2588 } 2602 2603 } -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1740 r1742 119 119 120 120 121 ObjectPvs pvs1, pvs2, mergedPvs; 122 123 pvs1.AddSample((Intersectable *)1, 1); 124 pvs1.AddSample((Intersectable *)3, 1); 125 pvs1.AddSample((Intersectable *)6, 1); 126 pvs1.AddSample((Intersectable *)7, 1); 127 pvs1.AddSample((Intersectable *)9, 1); 128 pvs1.AddSample((Intersectable *)12, 1); 129 pvs1.AddSample((Intersectable *)15, 1); 130 pvs1.AddSample((Intersectable *)7, 1); 131 pvs2.AddSample((Intersectable *)3, 1); 132 pvs2.AddSample((Intersectable *)4, 1); 133 pvs2.AddSample((Intersectable *)6, 1); 134 pvs2.AddSample((Intersectable *)8, 1); 135 pvs2.AddSample((Intersectable *)9, 1); 136 pvs2.AddSample((Intersectable *)14, 1); 137 138 ObjectPvs::Merge(mergedPvs, pvs1, pvs2); 139 140 Debug << "\npvs1\n"; 141 cout << "\npvs1\n"; 142 ObjectPvsIterator pvs1It = pvs1.GetIterator(); 143 144 while (pvs1It.HasMoreEntries()) 145 { 146 ObjectPvsEntry entry = pvs1It.Next(); 147 148 Debug << (int)entry.mObject << " "; 149 cout << (int)entry.mObject << " "; 150 } 151 152 Debug << "\npvs2\n"; 153 cout << "\npvs2\n"; 154 ObjectPvsIterator pvs2It = pvs2.GetIterator(); 155 156 while (pvs2It.HasMoreEntries()) 157 { 158 ObjectPvsEntry entry = pvs2It.Next(); 159 160 Debug << (int)entry.mObject << " "; 161 cout << (int)entry.mObject << " "; 162 } 163 164 Debug << "\nmerged\n"; 165 cout << "\nmerged\n"; 166 ObjectPvsIterator mergedIt = mergedPvs.GetIterator(); 167 168 while (mergedIt.HasMoreEntries()) 169 { 170 ObjectPvsEntry entry = mergedIt.Next(); 171 Debug << (int)entry.mObject << " " << entry.mData.mSumPdf << " x "; 172 cout << (int)entry.mObject << " " << entry.mData.mSumPdf << " x "; 173 } 174 121 175 // sampling type for view cells construction samples 122 176 if (strcmp(buf, "object") == 0) … … 2477 2531 // extended boxes of visible objects 2478 2532 Intersectable::NewMail(); 2533 2534 ObjectPvsIterator pit = pvs.GetIterator(); 2535 2536 while (pit.HasMoreEntries()) 2537 { 2538 ObjectPvsEntry entry = pit.Next(); 2479 2539 2480 ObjectPvsEntries::const_iterator oi; 2481 2482 for (oi = pvs.mEntries.begin(); oi != pvs.mEntries.end(); ++ oi) 2483 { 2484 Intersectable *object = (*oi).mObject; 2540 Intersectable *object = entry.mObject; 2485 2541 object->Mail(); 2486 2542 } 2487 2543 2488 2544 ObjectPvs nPvs; 2489 2545 int nPvsSize = 0; 2490 // now go through the pvs again 2491 for (oi = pvs.mEntries.begin(); oi != pvs.mEntries.end(); ++oi) { 2492 Intersectable *object = (*oi).mObject; 2493 2494 // Vector3 center = object->GetBox().Center(); 2495 // AxisAlignedBox3 box(center - Vector3(spatialFilterSize/2), 2496 // center + Vector3(spatialFilterSize/2)); 2497 2498 AxisAlignedBox3 box = object->GetBox(); 2499 box.Enlarge(Vector3(spatialFilterSize/2)); 2500 2501 ObjectContainer objects; 2502 2503 // $$ warning collect objects takes only unmailed ones! 2504 kdTree->CollectObjects(box, objects); 2505 // cout<<"collected objects="<<objects.size()<<endl; 2506 ObjectContainer::const_iterator noi = objects.begin(); 2507 for (; noi != objects.end(); ++ noi) 2508 { 2509 Intersectable *o = *noi; 2510 // $$ JB warning: pdfs are not correct at this point! 2511 nPvs.AddSample(o, Limits::Small); 2512 nPvsSize ++; 2513 } 2546 2547 ObjectPvsIterator pit2 = pvs.GetIterator(); 2548 2549 while (pit2.HasMoreEntries()) 2550 { 2551 // now go through the pvs again 2552 ObjectPvsEntry entry = pit2.Next(); 2553 Intersectable *object = entry.mObject; 2554 2555 // Vector3 center = object->GetBox().Center(); 2556 // AxisAlignedBox3 box(center - Vector3(spatialFilterSize/2), 2557 // center + Vector3(spatialFilterSize/2)); 2558 2559 AxisAlignedBox3 box = object->GetBox(); 2560 box.Enlarge(Vector3(spatialFilterSize/2)); 2561 2562 ObjectContainer objects; 2563 2564 // $$ warning collect objects takes only unmailed ones! 2565 kdTree->CollectObjects(box, objects); 2566 // cout<<"collected objects="<<objects.size()<<endl; 2567 ObjectContainer::const_iterator noi = objects.begin(); 2568 for (; noi != objects.end(); ++ noi) 2569 { 2570 Intersectable *o = *noi; 2571 // $$ JB warning: pdfs are not correct at this point! 2572 nPvs.AddSample(o, Limits::Small); 2573 nPvsSize ++; 2574 } 2514 2575 } 2515 2576 // cout<<"nPvs size = "<<nPvsSize<<endl; … … 2531 2592 2532 2593 Intersectable::NewMail(); 2533 ObjectPvsEntries::const_iterator oi; 2594 2595 ObjectPvsIterator pit = pvs.GetIterator(); 2596 2534 2597 // first mark all object from this pvs 2535 for (oi = pvs.mEntries.begin(); oi != pvs.mEntries.end(); ++ oi) { 2536 Intersectable *object = (*oi).mObject; 2537 object->Mail(); 2598 while (pit.HasMoreEntries()) 2599 { 2600 ObjectPvsEntry entry = pit.Next(); 2601 2602 Intersectable *object = entry.mObject; 2603 object->Mail(); 2538 2604 } 2539 2605 … … 2541 2607 int pvsSize = 0; 2542 2608 int nPvsSize = 0; 2543 float samples = (float)pvs. mSamples;2609 float samples = (float)pvs.GetSamples(); 2544 2610 cout<<"Samples = "<<samples<<endl; 2545 2611 // cout<<"Filter size = "<<filterSize<<endl; … … 2554 2620 2555 2621 float sumRadius = 0.0f; 2556 for (oi = pvs.mEntries.begin(); oi != pvs.mEntries.end(); ++oi, pvsSize++) { 2557 Intersectable *object = (*oi).mObject; 2622 2623 ObjectPvsIterator pit2 = pvs.GetIterator(); 2624 2625 // first mark all object from this pvs 2626 for (; pit2.HasMoreEntries(); pvsSize++) { 2627 ObjectPvsEntry entry = pit2.Next(); 2628 Intersectable *object = entry.mObject; 2558 2629 // compute filter size based on the distance and the numebr of samples 2559 2630 AxisAlignedBox3 box = object->GetBox(); … … 2562 2633 float globalRadius = distance*globalC; 2563 2634 2564 int objectSamples = (int) (*oi).mData.mSumPdf;2635 int objectSamples = (int)entry.mData.mSumPdf; 2565 2636 float localRadius = MAX_FLOAT; 2566 2637 … … 2599 2670 2600 2671 // update samples and globalC 2601 samples = (float)pvs. mSamples;2672 samples = (float)pvs.GetSamples(); 2602 2673 globalC = 2.0f*filterSize/sqrt(samples); 2603 2674 cout<<"neighboring viewcells = "<<i-1<<endl; … … 2605 2676 } 2606 2677 2607 for (oi = pvs.mEntries.begin(); oi != pvs.mEntries.end(); ++oi) { 2608 Intersectable *object = (*oi).mObject; 2609 // compute filter size based on the distance and the numebr of samples 2610 AxisAlignedBox3 box = object->GetBox(); 2611 2612 float distance = Distance(center, box.Center()); 2613 float globalRadius = distance*globalC; 2614 2615 2616 int objectSamples = (int)(*oi).mData.mSumPdf; 2617 float localRadius = MAX_FLOAT; 2618 if (objectSamples > MIN_LOCAL_SAMPLES) 2619 localRadius = filterSize*0.5f*Magnitude(box.Diagonal())/sqrt((float)objectSamples); 2620 2621 // cout<<"lr="<<localRadius<<" gr="<<globalRadius<<endl; 2622 2623 // now compute the filter size 2624 float radius = Min(localRadius, globalRadius); 2625 2626 // cout<<"box = "<<box<<endl; 2627 // cout<<"distance = "<<distance<<endl; 2628 // cout<<"radiues = "<<radius<<endl; 2629 2630 box.Enlarge(Vector3(radius)); 2631 2632 ObjectContainer objects; 2633 // $$ warning collect objects takes only unmailed ones! 2634 CollectObjects(box, objects); 2635 // cout<<"collected objects="<<objects.size()<<endl; 2636 ObjectContainer::const_iterator noi = objects.begin(); 2637 for (; noi != objects.end(); ++ noi) { 2638 Intersectable *o = *noi; 2639 // $$ JB warning: pdfs are not correct at this point! 2640 nPvs.AddSample(o, Limits::Small); 2641 nPvsSize ++; 2642 } 2678 pit = pvs.GetIterator(); 2679 2680 // first mark all object from this pvs 2681 while (pit.HasMoreEntries()) 2682 { 2683 ObjectPvsEntry entry = pit.Next(); 2684 2685 Intersectable *object = entry.mObject; 2686 // compute filter size based on the distance and the numebr of samples 2687 AxisAlignedBox3 box = object->GetBox(); 2688 2689 float distance = Distance(center, box.Center()); 2690 float globalRadius = distance*globalC; 2691 2692 int objectSamples = (int)entry.mData.mSumPdf; 2693 float localRadius = MAX_FLOAT; 2694 if (objectSamples > MIN_LOCAL_SAMPLES) 2695 localRadius = filterSize*0.5f*Magnitude(box.Diagonal())/sqrt((float)objectSamples); 2696 2697 // cout<<"lr="<<localRadius<<" gr="<<globalRadius<<endl; 2698 2699 // now compute the filter size 2700 float radius = Min(localRadius, globalRadius); 2701 2702 // cout<<"box = "<<box<<endl; 2703 // cout<<"distance = "<<distance<<endl; 2704 // cout<<"radiues = "<<radius<<endl; 2705 2706 box.Enlarge(Vector3(radius)); 2707 2708 ObjectContainer objects; 2709 // $$ warning collect objects takes only unmailed ones! 2710 CollectObjects(box, objects); 2711 // cout<<"collected objects="<<objects.size()<<endl; 2712 ObjectContainer::const_iterator noi = objects.begin(); 2713 for (; noi != objects.end(); ++ noi) { 2714 Intersectable *o = *noi; 2715 // $$ JB warning: pdfs are not correct at this point! 2716 nPvs.AddSample(o, Limits::Small); 2717 nPvsSize ++; 2718 } 2643 2719 } 2644 2720 cout<<"nPvs size = "<<nPvsSize<<endl; … … 2786 2862 for (vit = interior->mChildren.begin(); vit != vit_end; ++ vit, ++ oit) 2787 2863 { 2788 ObjectPvsEntries::iterator pit, pit_end = (*oit).mEntries.end(); 2789 2790 for (pit = (*oit).mEntries.begin(); pit != pit_end; ++ pit) 2791 { 2792 Intersectable *intersect = (*pit).mObject; 2864 ObjectPvsIterator pit = (*oit).GetIterator(); 2865 2866 // first mark all object from this pvs 2867 while (pit.HasMoreEntries()) 2868 { 2869 ObjectPvsEntry entry = pit.Next(); 2870 2871 Intersectable *intersect = entry.mObject; 2793 2872 2794 2873 if (!intersect->Mailed()) 2795 2874 { 2796 pvs.AddSample(intersect, (*pit).mData.mSumPdf);2875 pvs.AddSample(intersect, entry.mData.mSumPdf); 2797 2876 intersect->Mail(); 2798 2877 } … … 3274 3353 { 3275 3354 Intersectable::NewMail(); 3276 ObjectPvsEntries::const_iterator oit, oit_end = pvs.mEntries.end(); 3277 3278 // output PVS of view cell 3279 for (oit = pvs.mEntries.begin(); oit != oit_end; ++ oit) 3355 ObjectPvsIterator pit = pvs.GetIterator(); 3356 3357 while (pit.HasMoreEntries()) 3280 3358 { 3281 Intersectable *intersect = (*oit).mObject; 3359 ObjectPvsEntry entry = pit.Next(); 3360 3361 // output PVS of view cell 3362 Intersectable *intersect = entry.mObject; 3282 3363 3283 3364 if (!intersect->Mailed()) … … 3775 3856 exporter->SetFilled(); 3776 3857 3777 ObjectPvsEntries::iterator it, it_end = vc->GetPvs().mEntries.end(); 3778 // -- output PVS of view cell 3779 for (it = vc->GetPvs().mEntries.begin(); it != it_end; ++ it) 3780 { 3781 Intersectable *intersect = (*it).mObject; 3858 ObjectPvsIterator pit = vc->GetPvs().GetIterator(); 3859 3860 while (pit.HasMoreEntries()) 3861 { 3862 ObjectPvsEntry entry = pit.Next(); 3863 3864 //-- output PVS of view cell 3865 Intersectable *intersect = entry.mObject; 3782 3866 if (!intersect->Mailed()) 3783 3867 { … … 4623 4707 Intersectable::NewMail(); 4624 4708 4625 ObjectPvsEntries::const_iterator oit, oit_end = pvs.mEntries.end(); 4709 ObjectPvsIterator pit = pvs.GetIterator(); 4710 4626 4711 cout << endl; 4712 4627 4713 // output PVS of view cell 4628 for (oit = pvs.mEntries.begin(); oit != oit_end; ++ oit) 4629 { 4630 Intersectable *intersect = (*oit).mObject; 4714 while (pit.HasMoreEntries()) 4715 { 4716 ObjectPvsEntry entry = pit.Next(); 4717 Intersectable *intersect = entry.mObject; 4631 4718 4632 4719 if (!intersect->Mailed()) … … 5490 5577 5491 5578 Intersectable::NewMail(); 5492 ObjectPvsEntries::const_iterator oit, oit_end = pvs.mEntries.end();5493 5579 5580 ObjectPvsIterator pit = pvs.GetIterator(); 5581 5494 5582 // output PVS of view cell 5495 for (oit = pvs.mEntries.begin(); oit != oit_end; ++ oit)5583 while (pit.HasMoreEntries()) 5496 5584 { 5497 Intersectable *intersect = (*oit).mObject; 5585 ObjectPvsEntry entry = pit.Next(); 5586 5587 Intersectable *intersect = entry.mObject; 5588 5498 5589 if (!intersect->Mailed()) 5499 5590 {
Note: See TracChangeset
for help on using the changeset viewer.