Changeset 2015 for GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
- Timestamp:
- 01/22/07 20:25:06 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r2014 r2015 28 28 29 29 30 30 31 #define USE_RAY_LENGTH_AS_CONTRIBUTION 0 31 32 #define DIST_WEIGHTED_CONTRIBUTION 0 … … 37 38 namespace GtpVisibilityPreprocessor { 38 39 40 41 PerfTimer viewCellCastTimer; 42 PerfTimer pvsTimer; 43 PerfTimer objTimer; 39 44 40 45 // HACK … … 1694 1699 1695 1700 VssRayContainer::const_iterator it, it_end = rays.end(); 1696 1701 1697 1702 for (it = rays.begin(); it != it_end; ++ it) 1698 1703 { … … 1707 1712 } 1708 1713 1714 cout<<"view cell cast time:"<<viewCellCastTimer.TotalTime()<<" s"<<endl; 1715 cout<<"pvs time:"<<pvsTimer.TotalTime()<<" s"<<endl; 1716 1709 1717 return sum; 1710 1718 } … … 2235 2243 2236 2244 2245 void 2246 ViewCellsManager::SortViewCellPvs() 2247 { 2248 2249 ViewCellContainer::iterator it, it_end = mViewCells.end(); 2250 for (it = mViewCells.begin(); it != it_end; ++ it) { 2251 ObjectPvs &pvs = (*it)->GetPvs(); 2252 if (pvs.RequiresResortLog()) 2253 pvs.Sort(); 2254 } 2255 } 2256 2237 2257 void ViewCellsManager::ComputeViewCellContribution(ViewCell *viewCell, 2238 2258 VssRay &ray, … … 2242 2262 { 2243 2263 // check if we are outside of view space 2244 if (!obj || !viewCell->GetValid()) 2245 return; 2246 2247 // if ray not outside of view space 2248 float relContribution = 0.0f; 2249 float absContribution = 0.0f; 2250 2251 if (obj) 2252 { 2253 // todo: maybe not correct for kd node pvs 2254 if (addRays) 2255 { 2256 float pdf = viewCell->GetPvs().AddSampleDirtyCheck(obj, ray.mPdf); 2257 2258 if (pdf == ray.mPdf) 2259 { 2260 absContribution = 1.0f; 2261 if (viewCell->GetPvs().RequiresResort()) 2262 viewCell->GetPvs().SimpleSort(); 2263 } 2264 } 2265 else 2266 { 2267 if (viewCell->GetPvs().GetSampleContribution( 2268 obj, 2269 ray.mPdf, 2270 relContribution)) 2271 { 2272 absContribution = 1.0f; 2273 } 2274 } 2275 2276 // $$ clear the relative contribution as it is currently not correct anyway 2277 relContribution = 0.0f; 2278 2279 if (absContribution == 1.0f) 2280 { 2281 ++ ray.mPvsContribution; 2282 relContribution = 1.0f; 2283 2284 2264 // $$JB tmp commented to speedup up computations 2265 #if 0 2266 if (!obj || !viewCell->GetValid()) 2267 return; 2268 #endif 2269 2270 2271 // if ray not outside of view space 2272 float relContribution = 0.0f; 2273 float absContribution = 0.0f; 2274 bool hasAbsContribution; 2275 2276 // todo: maybe not correct for kd node pvs 2277 if (addRays) { 2278 hasAbsContribution = viewCell->GetPvs().AddSampleDirtyCheck(obj, 2279 ray.mPdf); 2280 } 2281 else { 2282 hasAbsContribution = viewCell->GetPvs().GetSampleContribution( 2283 obj, 2284 ray.mPdf, 2285 relContribution); 2286 } 2287 2288 // $$ clear the relative contribution as it is currently not correct anyway 2289 // relContribution = 0.0f; 2290 2291 if (hasAbsContribution) { 2292 ++ ray.mPvsContribution; 2293 absContribution = relContribution = 1.0f; 2294 if (viewCell->GetPvs().RequiresResort()) 2295 viewCell->GetPvs().SimpleSort(); 2296 2285 2297 #if CONTRIBUTION_RELATIVE_TO_PVS_SIZE 2286 2298 relContribution /= viewcell->GetPvs().GetSize(); 2287 2299 #endif 2288 2300 2289 2301 #if DIST_WEIGHTED_CONTRIBUTION 2290 2291 2292 2293 2294 2302 // recalculate the contribution - weight the 1.0f contribution by the sqr distance to the 2303 // object-> a new contribution in the proximity of the viewcell has a larger weight! 2304 relContribution /= SqrDistance(GetViewCellBox(viewcell).Center(), 2305 ray.mTermination); 2306 2295 2307 #endif 2296 2297 2308 } 2309 2298 2310 #if SUM_RAY_CONTRIBUTIONS || AVG_RAY_CONTRIBUTIONS 2299 2311 ray.mRelativePvsContribution += relContribution; 2300 2312 #else 2301 2302 2303 2313 // recalculate relative contribution - use max of Rel Contribution 2314 if (ray.mRelativePvsContribution < relContribution) 2315 ray.mRelativePvsContribution = relContribution; 2304 2316 #endif 2305 2306 2307 } 2317 } 2318 2319 2308 2320 2309 2321 … … 2365 2377 2366 2378 if (!ray.mTerminationObject) 2367 return 0.0f; 2368 2369 static ViewCellContainer viewCells; 2370 2371 2379 return 0.0f; 2380 2372 2381 static Ray hray; 2373 2382 hray.Init(ray); … … 2382 2391 Vector3 origin = hray.Extrap(tmin); 2383 2392 Vector3 termination = hray.Extrap(tmax); 2384 2393 2385 2394 ViewCell::NewMail(); 2386 2387 viewCells.clear(); 2388 2389 // traverse the view space subdivision 2390 CastLineSegment(origin, termination, viewCells); 2395 2396 viewCellCastTimer.Entry(); 2397 2398 static ViewCellContainer viewCells; 2399 static VssRay *lastVssRay = NULL; 2400 2401 if (lastVssRay == NULL || 2402 !(ray.mOrigin == lastVssRay->mTermination) || 2403 !(ray.mTermination == lastVssRay->mOrigin)) { 2404 viewCells.clear(); 2405 // traverse the view space subdivision 2406 CastLineSegment(origin, termination, viewCells); 2407 lastVssRay = &ray; 2408 } 2409 2410 viewCellCastTimer.Exit(); 2391 2411 2392 2412 mSamplesStat.mViewCells += (int)viewCells.size(); … … 2394 2414 if (storeViewCells) 2395 2415 { 2416 cerr<<"Store viewcells should not be used in the test!"<<endl; 2396 2417 // copy viewcells memory efficiently 2397 2418 #if VSS_STORE_VIEWCELLS … … 2403 2424 #endif 2404 2425 } 2405 2426 2406 2427 Intersectable *terminationObj; 2428 2429 objTimer.Entry(); 2407 2430 2408 2431 // obtain pvs entry (can be different from hit object) 2409 2432 if (!useHitObjects) 2410 2433 terminationObj = GetIntersectable(ray, true); 2411 2434 else 2412 terminationObj = ray.mTerminationObject; 2435 terminationObj = ray.mTerminationObject; 2436 2437 objTimer.Exit(); 2438 2439 pvsTimer.Entry(); 2413 2440 2414 2441 ViewCellContainer::const_iterator it = viewCells.begin(); … … 2422 2449 addRays); 2423 2450 } 2451 2452 pvsTimer.Exit(); 2424 2453 2425 2454 mSamplesStat.mPvsContributions += ray.mPvsContribution;
Note: See TracChangeset
for help on using the changeset viewer.