Changeset 1942 for GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp
- Timestamp:
- 01/05/07 16:29:54 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp
r1932 r1942 3 3 #include "Ray.h" 4 4 #include "Preprocessor.h" 5 #include "ViewCellsManager.h" 5 6 6 7 … … 10 11 #define DEBUG_RAYCAST 0 11 12 12 #define EXACT_BOX_CLIPPING 113 #define EXACT_BOX_CLIPPING 0 13 14 14 15 RayCaster::RayCaster(const Preprocessor &preprocessor): … … 38 39 } 39 40 41 bool 42 RayCaster::ClipToViewSpaceBox(const Vector3 &origin, 43 const Vector3 &termination, 44 Vector3 &clippedOrigin, 45 Vector3 &clippedTermination) 46 { 47 Ray ray(origin, termination - origin, Ray::LINE_SEGMENT); 48 ray.Precompute(); 49 50 float tmin, tmax; 51 if ((!mPreprocessor.mViewCellsManager-> 52 GetViewSpaceBox().ComputeMinMaxT(ray, &tmin, &tmax)) || 53 tmin>=tmax 54 ) 55 return false; 56 57 if (tmin >= 1.0f || tmax <=0.0f) 58 return false; 59 60 if (tmin > 0.0f) 61 clippedOrigin = ray.Extrap(tmin); 62 else 63 clippedOrigin = origin; 64 65 if (tmax < 1.0f) 66 clippedTermination = ray.Extrap(tmax); 67 else 68 clippedTermination = termination; 69 70 return true; 71 } 40 72 41 73 /** Checks if ray is valid, (e.g., not in empty view space or outside the view space) … … 140 172 // degenerate rays checked by geometrical constraint... 141 173 // !pruneInvalidRays || (hitA.mObject != hitB.mObject); 174 142 175 143 176 #if DEBUG_RAYCAST 144 177 Debug<<"PR2"<<flush; 145 178 #endif 146 147 if (!pruneInvalidRays || hitA.mObject) 148 { 149 VssRay *vssRay = new VssRay(hitB.mPoint, 179 const bool validSample = true; 180 if (validSample) { 181 Vector3 clipA, clipB; 182 if (!ClipToViewSpaceBox(hitA.mPoint, 183 hitB.mPoint, 184 clipA, 185 clipB)) 186 return 0; 187 if (!pruneInvalidRays || hitA.mObject) { 188 VssRay *vssRay = new VssRay( 189 clipB, 150 190 hitA.mPoint, 151 191 hitB.mObject, … … 167 207 #endif 168 208 169 if (castDoubleRay && (!pruneInvalidRays || hitB.mObject)) 170 { 171 VssRay *vssRay = new VssRay(hitA.mPoint, 172 hitB.mPoint, 173 hitA.mObject, 174 hitB.mObject, 175 mPreprocessor.mPass, 176 simpleRay.mPdf); 177 178 if (validB) 209 if (castDoubleRay && (!pruneInvalidRays || hitB.mObject)) 210 { 211 VssRay *vssRay = new VssRay( 212 clipA, 213 hitB.mPoint, 214 hitA.mObject, 215 hitB.mObject, 216 mPreprocessor.mPass, 217 simpleRay.mPdf 218 ); 219 if (validB) 179 220 vssRay->mFlags |= VssRay::Valid; 180 221 … … 183 224 ++ hits; 184 225 //cout << "vssray 2: " << *vssRay << endl; 185 }186 187 #if DEBUG_RAYCAST 188 Debug<<"PR4"<<flush; 189 #endif 190 226 } 227 #if DEBUG_RAYCAST 228 Debug<<"PR4"<<flush; 229 #endif 230 } 231 191 232 return hits; 192 233 }
Note: See TracChangeset
for help on using the changeset viewer.