Changeset 1594 for GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
- Timestamp:
- 10/10/06 00:59:59 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1589 r1594 29 29 #define SAMPLE_ORIGIN_OBJECTS 0 30 30 31 // $$JB HACK 32 #define USE_KD_PVS 1 33 #define KD_PVS_AREA 1e-3f 31 34 32 35 namespace GtpVisibilityPreprocessor { … … 1183 1186 const float filterWidth) 1184 1187 { 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 { 1196 1197 1198 1199 1200 1201 1188 ViewCell *currentViewCell = GetViewCell(viewPoint); 1189 1190 if (mMaxFilterSize < 1) { 1191 prvs.mViewCell = currentViewCell; 1192 return; 1193 } 1194 1195 const AxisAlignedBox3 box = GetFilterBBox(viewPoint, filterWidth); 1196 1197 if (currentViewCell) 1198 { 1199 ViewCellContainer viewCells; 1200 ComputeBoxIntersections(box, viewCells); 1201 1202 ViewCell *root = ConstructLocalMergeTree2(currentViewCell, viewCells); 1203 prvs.mViewCell = root; 1204 1202 1205 } 1203 1204 { 1205 1206 1206 else 1207 { 1208 prvs.mViewCell = NULL; 1209 //prvs.mPvs = root->GetPvs(); 1207 1210 } 1208 1211 } … … 1808 1811 ViewCellContainer *viewcells = &ray.mViewCells; 1809 1812 ViewCellContainer::const_iterator it; 1813 1814 if (!ray.mTerminationObject) 1815 return; 1816 1817 #if USE_KD_PVS 1818 float area = GetPreprocessor()->mKdTree->GetBox().SurfaceArea()*KD_PVS_AREA; 1819 KdNode *node = GetPreprocessor()->mKdTree->GetNode(ray.mTermination, area); 1820 Intersectable *obj = 1821 GetPreprocessor()->mKdTree-> 1822 GetOrCreateKdIntersectable(node); 1823 #else 1824 Intersectable *obj = ray.mTerminationObject; 1825 #endif 1826 1810 1827 for (it = viewcells->begin(); it != viewcells->end(); ++it) { 1811 1828 ViewCell *viewcell = *it; 1812 1829 if (viewcell->GetValid()) { 1813 1830 // if ray not outside of view space 1814 viewcell->GetPvs().AddSample( ray.mTerminationObject, ray.mPdf);1831 viewcell->GetPvs().AddSample(obj, ray.mPdf); 1815 1832 } 1816 1833 } … … 1851 1868 } 1852 1869 1870 #if USE_KD_PVS 1871 float area = GetPreprocessor()->mKdTree->GetBox().SurfaceArea()*KD_PVS_AREA; 1872 KdNode *node = GetPreprocessor()->mKdTree->GetNode(ray.mTermination, area); 1873 Intersectable *obj = 1874 GetPreprocessor()->mKdTree-> 1875 GetOrCreateKdIntersectable(node); 1876 #else 1877 Intersectable *obj = ray.mTerminationObject; 1878 #endif 1879 1880 1853 1881 ViewCellContainer::const_iterator it = viewcells.begin(); 1854 1882 1855 1883 for (; it != viewcells.end(); ++ it) 1856 1884 { … … 1862 1890 1863 1891 if (ray.mTerminationObject) 1864 { 1865 if (viewcell->GetPvs().GetSampleContribution( 1866 ray.mTerminationObject, 1867 ray.mPdf, 1868 contribution)) 1892 { 1893 1894 1895 if (viewcell->GetPvs().GetSampleContribution(obj, 1896 ray.mPdf, 1897 contribution)) 1869 1898 { 1870 1871 1899 ++ ray.mPvsContribution; 1900 ray.mRelativePvsContribution += contribution; 1872 1901 } 1873 1902 } … … 1903 1932 if (ray.mTerminationObject) 1904 1933 { 1905 viewcell->GetPvs().AddSample( ray.mTerminationObject, ray.mPdf);1934 viewcell->GetPvs().AddSample(obj, ray.mPdf); 1906 1935 } 1907 1936 #if SAMPLE_ORIGIN_OBJECTS … … 2330 2359 // now compute a new Pvs by including also objects intersecting the 2331 2360 // extended boxes of visible objects 2332 2333 2361 Intersectable::NewMail(); 2334 2362 … … 5510 5538 if (ray.mTerminationObject) 5511 5539 { 5512 // todo: maybe not correct for kd node pvs 5513 Intersectable *obj = mHierarchyManager->GetIntersectable(ray, true); 5514 if (viewcell->GetPvs().GetSampleContribution(obj, 5515 ray.mPdf, 5516 contribution)) 5540 // todo: maybe not correct for kd node pvs 5541 Intersectable *obj = mHierarchyManager->GetIntersectable(ray, true); 5542 5543 if (viewcell->GetPvs().GetSampleContribution(obj, 5544 ray.mPdf, 5545 contribution)) 5517 5546 { 5518 5547 ++ ray.mPvsContribution; 5519 5548 } 5520 5521 5549 5550 ray.mRelativePvsContribution += contribution; 5522 5551 } 5523 5552 5524 5553 // for directional sampling it is important to count only contributions 5525 5554 // made in one direction!
Note: See TracChangeset
for help on using the changeset viewer.