Changeset 1876 for GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
- Timestamp:
- 12/08/06 23:46:17 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1867 r1876 32 32 33 33 // $$JB HACK 34 #define USE_KD_PVS 034 #define USE_KD_PVS 1 35 35 36 36 #define KD_PVS_AREA (1e-5f) … … 2023 2023 2024 2024 ViewCellContainer viewcells; 2025 2026 2027 2028 2025 2029 2026 static Ray hray; … … 2084 2081 // for directional sampling it is important to count only contributions 2085 2082 // made in one direction!!! 2086 2083 // the other contributions of this sample will be counted for the oposite ray! 2087 2084 2088 2085 if (ray.mOriginObject && … … 6047 6044 6048 6045 #define PVS_ADD_DIRTY 1 6046 6049 6047 float 6050 6048 VspOspViewCellsManager::ComputeSampleContribution(VssRay &ray, … … 6060 6058 ViewCellContainer viewcells; 6061 6059 6062 6063 static Ray hray; 6064 hray.Init(ray); 6065 //hray.mFlags |= Ray::CULL_BACKFACES; 6066 //Ray hray(ray); 6067 6068 // if (ray.mPdf!=1.0f) 6069 // cout<<ray.mPdf<<" "; 6070 6071 float tmin = 0, tmax = 1.0; 6072 6073 if (!GetViewSpaceBox().GetRaySegment(hray, tmin, tmax) || (tmin > tmax)) 6074 return 0; 6075 6076 Vector3 origin = hray.Extrap(tmin); 6077 Vector3 termination = hray.Extrap(tmax); 6078 6079 ViewCell::NewMail(); 6080 6081 // traverse the view space subdivision 6082 CastLineSegment(origin, termination, viewcells); 6083 6084 if (storeViewCells) 6060 static Ray hray; 6061 hray.Init(ray); 6062 6063 float tmin = 0, tmax = 1.0; 6064 6065 if (!GetViewSpaceBox().GetRaySegment(hray, tmin, tmax) || (tmin > tmax)) 6066 return 0; 6067 6068 Vector3 origin = hray.Extrap(tmin); 6069 Vector3 termination = hray.Extrap(tmax); 6070 6071 ViewCell::NewMail(); 6072 6073 // traverse the view space subdivision 6074 CastLineSegment(origin, termination, viewcells); 6075 6076 if (storeViewCells) 6085 6077 { 6086 6087 6088 6089 } 6090 6091 6092 6093 6094 6078 // copy viewcells memory efficiently 6079 ray.mViewCells.reserve(viewcells.size()); 6080 ray.mViewCells = viewcells; 6081 } 6082 6083 ViewCellContainer::const_iterator it = viewcells.begin(); 6084 6085 Intersectable *terminationObj = GetIntersectable(ray, true); 6086 6095 6087 #if SAMPLE_ORIGIN_OBJECTS 6096 6088 Intersectable *originObj = GetIntersectable(ray, false); 6097 6089 #endif 6098 6099 6100 { 6101 6102 6103 6090 6091 for (; it != viewcells.end(); ++ it) 6092 { 6093 ViewCell *viewcell = *it; 6094 6095 if (viewcell->GetValid()) 6104 6096 { // if ray not outside of view space 6105 6106 6107 6097 float contribution; 6098 6099 if (terminationObj) 6108 6100 { 6109 6101 // todo: maybe not correct for kd node pvs … … 6116 6108 ray.mRelativePvsContribution += contribution; 6117 6109 } 6118 6119 6120 6121 6122 6123 6110 6111 //////////////// 6112 //-- for directional sampling it is important to count 6113 //-- only contributions made in one direction! 6114 //-- the other contributions of this sample will be counted for the opposite ray! 6115 6124 6116 #if SAMPLE_ORIGIN_OBJECTS 6125 6126 6127 6128 6129 6117 6118 if (originObj && 6119 viewcell->GetPvs().GetSampleContribution(originObj, 6120 ray.mPdf, 6121 contribution)) 6130 6122 { 6131 6132 6123 ++ ray.mPvsContribution; 6124 ray.mRelativePvsContribution += contribution; 6133 6125 } 6134 6126 #endif 6135 6127 } 6136 6128 } 6137 6138 if (!addRays) 6139 { 6140 return ray.mRelativePvsContribution; 6141 } 6142 6143 // sampled objects are stored in the pvs 6144 for (it = viewcells.begin(); it != viewcells.end(); ++ it) 6145 { 6146 ViewCell *viewCell = *it; 6147 6148 if (!viewCell->GetValid()) 6149 break; 6150 6151 //$$JB hack 6152 6129 6130 if (!addRays) { 6131 return ray.mRelativePvsContribution; 6132 } 6133 6134 // sampled objects are stored in the pvs 6135 for (it = viewcells.begin(); it != viewcells.end(); ++ it) { 6136 ViewCell *viewCell = *it; 6137 6138 if (!viewCell->GetValid()) 6139 break; 6140 6141 //$$JB hack 6142 6153 6143 #if PVS_ADD_DIRTY 6154 6144 viewCell->GetPvs().AddSampleDirtyCheck(terminationObj, ray.mPdf); 6155 6145 #else 6156 6146 viewCell->GetPvs().AddSample(terminationObj, ray.mPdf); 6157 6147 #endif 6158 6148 6159 6149 #if SAMPLE_ORIGIN_OBJECTS 6160 6150 #if PVS_ADD_DIRTY 6161 6151 viewCell->GetPvs().AddSampleDirtyCheck(originObj, ray.mPdf); 6162 6152 #else 6163 6153 viewCell->GetPvs().AddSample(originObj, ray.mPdf); 6164 6154 #endif 6165 6155 #endif 6166 if (viewCell->GetPvs().RequiresResort()) 6167 { 6168 viewCell->GetPvs().Sort(); 6169 } 6170 } 6171 6172 return ABS_CONTRIBUTION_WEIGHT*ray.mPvsContribution + 6173 (1.0f - ABS_CONTRIBUTION_WEIGHT)*ray.mRelativePvsContribution; 6156 if (viewCell->GetPvs().RequiresResort()) { 6157 viewCell->GetPvs().Sort(); 6158 } 6159 } 6160 6161 return ABS_CONTRIBUTION_WEIGHT*ray.mPvsContribution + 6162 (1.0f - ABS_CONTRIBUTION_WEIGHT)*ray.mRelativePvsContribution; 6174 6163 } 6175 6164
Note: See TracChangeset
for help on using the changeset viewer.