Changeset 2571 for GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
- Timestamp:
- 12/18/07 17:40:35 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r2570 r2571 2671 2671 void ViewCellsManager::UpdateStatsForViewCell(ViewCell *vc, Intersectable *obj) 2672 2672 { 2673 KdIntersectable *kdObj = static_cast<KdIntersectable *>(obj); 2674 2675 const AxisAlignedBox3 box = kdObj->GetBox(); 2676 const float dist = SqrDistance(vc->GetBox().Center(), box.Center()); 2677 2678 float f; 2679 2680 const float radius = mViewSpaceBox.Radius(); 2681 const float fullRadius = mViewSpaceBox.Radius(); 2682 2683 const float minVal = 0.1f; 2684 const float maxVal = 1.0f; 2685 2686 if (dist <= radius) 2687 f = maxVal; 2688 else if (dist >= fullRadius) 2689 f = minVal; 2690 else // linear blending 2691 { 2692 f = minVal * (dist - radius) + maxVal * (fullRadius - radius - dist); 2693 } 2694 2695 const int numTriangles = kdObj->ComputeNumTriangles(); 2696 2697 vc->GetPvs().mStats.mDistanceWeightedTriangles += f * numTriangles; 2698 vc->GetPvs().mStats.mDistanceWeightedPvs += f; 2699 vc->GetPvs().mStats.mWeightedTriangles += numTriangles; 2673 KdIntersectable *kdObj = static_cast<KdIntersectable *>(obj); 2674 2675 const AxisAlignedBox3 box = kdObj->GetBox(); 2676 const float dist = Distance(vc->GetBox().Center(), box.Center()); 2677 2678 float f; 2679 2680 const float radius = box.Radius(); 2681 const float fullRadius = max(0.2f * mViewSpaceBox.Radius(), radius); 2682 2683 const float minVal = 0.01f; 2684 const float maxVal = 1.0f; 2685 2686 if (dist <= radius) 2687 f = maxVal; 2688 else if (dist >= fullRadius) 2689 f = minVal; 2690 else // linear blending 2691 { 2692 f = minVal * (dist - radius) / (fullRadius - radius) + 2693 maxVal * (fullRadius - radius - dist) / (fullRadius - radius); 2694 } 2695 2696 //cout << "x " << radius << " " << dist << " " << fullRadius << " " << f << " " << f * f << endl; 2697 2698 const int numTriangles = kdObj->ComputeNumTriangles(); 2699 2700 vc->GetPvs().mStats.mDistanceWeightedTriangles += f * numTriangles; 2701 vc->GetPvs().mStats.mDistanceWeightedPvs += f ; 2702 vc->GetPvs().mStats.mWeightedTriangles += numTriangles; 2700 2703 } 2701 2704 … … 2725 2728 //hasAbsContribution = viewCell->GetPvs().AddSample(obj,ray.mPdf); 2726 2729 #if 1 2727 UpdateStatsForViewCell(viewCell, obj); 2730 if (hasAbsContribution) 2731 { 2732 UpdateStatsForViewCell(viewCell, obj); 2733 mVizBuffer.AddRay(&ray); 2734 } 2728 2735 #endif 2729 2736
Note: See TracChangeset
for help on using the changeset viewer.