Changeset 2722 for GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
- Timestamp:
- 05/28/08 01:24:20 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r2720 r2722 1698 1698 float Preprocessor::_HackComputeRenderCost(ViewCell *vc) 1699 1699 { 1700 ObjectPvs basePvs; 1701 1702 basePvs = vc->CopyPvs(); 1703 ObjectPvsIterator pit = basePvs.GetIterator(); 1700 ObjectPvsIterator pit = vc->GetPvs().GetIterator(); 1704 1701 1705 1702 float renderCost = 0; 1706 1703 int i = 0; 1704 cout<<"size: " << vc->GetPvs().GetSize() << endl; 1707 1705 // first mark all objects from this pvs 1708 1706 while (pit.HasMoreEntries()) 1709 1707 { 1710 1708 Intersectable *obj = pit.Next(); 1711 1712 1709 if (obj->Type() == Intersectable::KD_INTERSECTABLE) 1713 1710 { 1714 KdIntersectable *kdObj = static_cast<KdIntersectable *>( pit.Next());1711 KdIntersectable *kdObj = static_cast<KdIntersectable *>(obj); 1715 1712 1716 1713 /*if (mShowDistanceWeightedPvs) … … 1756 1753 int maxPlanes = 0; 1757 1754 int allEntries = 0; 1755 1756 int viewCells = 0; 1757 1758 1758 // now search for pvss which contained any mailed node 1759 for (vit = mViewCellsManager->GetViewCells().begin(); vit != vit_end; ++ vit) { 1759 for (vit = mViewCellsManager->GetViewCells().begin(); vit != vit_end; ++ vit) 1760 { 1760 1761 ObjectPvs &pvs = (*vit)->GetPvs(); 1761 if (Overlap(box, (*vit)->GetBox())) { 1762 1763 bool pvsChanged = false; 1764 1765 if (Overlap(box, (*vit)->GetBox())) 1766 { 1762 1767 pvs.Clear(); 1763 1768 removedEntries += pvs.GetSize(); 1764 } else { 1769 pvsChanged = true; 1770 } 1771 else 1772 { 1765 1773 // cout<<(*vit)->GetBox()<<" "<<box<<endl; 1766 1774 shadowVolume.Init((*vit)->GetBox(), box); … … 1769 1777 1770 1778 int j = 0; 1771 for (int i=0; i < pvs.mEntries.size(); i++) { 1779 for (int i=0; i < pvs.mEntries.size(); i++) 1780 { 1772 1781 allEntries++; 1773 1782 Intersectable *o = pvs.mEntries[i].mObject; 1774 if (o == inter) { 1783 if (o == inter) 1784 { 1775 1785 removedSelfEntries++; 1776 } else { 1777 if (!shadowVolume.TestIsInsideShaft(o->GetBox())) { 1786 pvsChanged = true; 1787 } 1788 else 1789 { 1790 if (!shadowVolume.TestIsInsideShaft(o->GetBox())) 1791 { 1778 1792 if (j != i) 1779 1793 pvs.mEntries[j] = pvs.mEntries[i]; 1780 1794 j++; 1781 } else { 1795 } 1796 else 1797 { 1782 1798 removedEntries++; 1799 pvsChanged = true; 1783 1800 } 1784 1801 } 1785 1802 } 1803 1786 1804 // now the pvs has to be resorted 1787 1805 pvs.mLastSorted = 0; 1788 1806 if (j==0) 1789 1807 pvs.mEntries.clear(); 1790 else { 1808 else 1809 { 1791 1810 pvs.mEntries.resize(j); 1792 1811 if (j>1) … … 1795 1814 } 1796 1815 1797 ViewCell *vc = *vit; 1798 1799 // recompute render cost 1800 float renderCost = _HackComputeRenderCost(vc); 1801 vc->GetPvs().mStats.mWeightedTriangles = renderCost; 1816 if (pvsChanged) 1817 { 1818 ViewCell *vc = *vit; 1819 1820 // recompute render cost 1821 float renderCost = _HackComputeRenderCost(vc); 1822 vc->GetPvs().mStats.mWeightedTriangles = renderCost; 1823 } 1802 1824 } 1803 1825 1804 1826 cerr<<"Number of removed pvs entries = "<<removedEntries<<" ("<< 1805 1827 100.0f*removedEntries/(float)allEntries<<"%)"<<endl;
Note: See TracChangeset
for help on using the changeset viewer.