Changeset 1900 for GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
- Timestamp:
- 12/15/06 23:40:27 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1895 r1900 27 27 28 28 // $$JB HACK 29 #define USE_KD_PVS 029 #define USE_KD_PVS 1 30 30 31 31 #define KD_PVS_AREA (1e-5f) 32 33 #define USE_RAY_LENGTH_AS_CONTRIBUTION 0 34 #define DIST_WEIGHTED_CONTRIBUTION 1 32 35 33 36 namespace GtpVisibilityPreprocessor { … … 1536 1539 const bool storeViewCells) 1537 1540 { 1538 // view cells not yet constructed1539 if (!ViewCellsConstructed())1540 return 0.0f;1541 1542 1541 float sum = 0.0f; 1542 1543 1543 VssRayContainer::const_iterator it, it_end = rays.end(); 1544 1544 1545 1545 for (it = rays.begin(); it != it_end; ++ it) 1546 1546 { 1547 sum += ComputeSampleContribution(*(*it), addRays, storeViewCells); 1547 if (!ViewCellsConstructed()) { 1548 // view cells not yet constructed 1549 // just take the lenghts of the rays as contributions 1550 if ((*it)->mTerminationObject) 1551 sum += (*it)->Length(); 1552 } else { 1553 sum += ComputeSampleContribution(*(*it), addRays, storeViewCells); 1554 } 1548 1555 } 1549 1556 … … 2009 2016 float 2010 2017 ViewCellsManager::ComputeSampleContribution(VssRay &ray, 2011 2012 2018 const bool addRays, 2019 const bool storeViewCells) 2013 2020 { 2014 2021 ray.mPvsContribution = 0; … … 2059 2066 { 2060 2067 // todo: maybe not correct for kd node pvs 2061 if (viewcell->GetPvs().GetSampleContribution( 2062 terminationObj, ray.mPdf, contribution)) 2068 bool absContribution = viewcell->GetPvs().GetSampleContribution( 2069 terminationObj, 2070 ray.mPdf, 2071 contribution); 2072 #if DIST_WEIGHTED_CONTRIBUTION 2073 // clear the relative contribution 2074 contribution = 0.0f; 2075 #endif 2076 if (absContribution) 2063 2077 { 2064 2078 ++ ray.mPvsContribution; … … 2073 2087 #endif 2074 2088 } 2089 #if DIST_WEIGHTED_CONTRIBUTION 2090 // recalculate the contribution - weight the 1.0f contribution by the sqr distance to the 2091 // object-> a new contribution in the proximity of the viewcell has a larger weight! 2092 contribution = 1.0f/SqrDistance(GetViewCellBox(viewcell).Center(), 2093 ray.mTermination); 2094 #endif 2075 2095 } 2076 2096 … … 2079 2099 } 2080 2100 } 2081 2101 2102 #if USE_RAY_LENGTH_AS_CONTRIBUTION 2103 float c = 0.0f; 2104 if (terminationObj) 2105 c = ray.Length(); 2106 ray.mRelativePvsContribution = ray.mPvsContribution = c; 2107 return c; 2108 #else 2082 2109 return ABS_CONTRIBUTION_WEIGHT*ray.mPvsContribution + 2083 2110 (1.0f - ABS_CONTRIBUTION_WEIGHT)*ray.mRelativePvsContribution; 2111 #endif 2084 2112 } 2085 2113
Note: See TracChangeset
for help on using the changeset viewer.