Changeset 1932 for GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp
- Timestamp:
- 01/03/07 01:36:35 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.cpp
r1900 r1932 24 24 25 25 VssRay *RayCaster::CastRay(const SimpleRay &simpleRay, 26 const AxisAlignedBox3 &box ,27 const bool castDoubleRay)26 const AxisAlignedBox3 &box) 27 //const bool castDoubleRay) 28 28 { 29 VssRayContainer rays; 30 CastRay(simpleRay, rays, box, castDoubleRay); 31 32 if (!rays.empty()) 33 return rays.back(); 34 else 35 return NULL; 29 // note: make no sense otherwise 30 const bool castDoubleRay = false; 31 VssRayContainer rays; 32 CastRay(simpleRay, rays, box, castDoubleRay); 33 34 if (!rays.empty()) 35 return rays.back(); 36 else 37 return NULL; 36 38 } 37 39 … … 45 47 Intersection &hit) 46 48 { 47 if (!hit.mObject) { 48 // compute intersection with the scene bounding box 49 if (!hit.mObject) 50 { 51 // compute intersection with the scene bounding box 49 52 #if EXACT_BOX_CLIPPING 50 static Ray ray; 51 mPreprocessor.SetupRay(ray, origin, direction); 52 53 float tmin, tmax; 54 if (box.ComputeMinMaxT(ray, &tmin, &tmax) && (tmin < tmax)) { 55 hit.mPoint = ray.Extrap(tmax); 53 static Ray ray; 54 mPreprocessor.SetupRay(ray, origin, direction); 55 56 float tmin, tmax; 57 if (box.ComputeMinMaxT(ray, &tmin, &tmax) && (tmin < tmax)) 58 { 59 hit.mPoint = ray.Extrap(tmax); 60 } 61 else 62 { 63 // cout<<" invalid hp "<<tmin<<" "<<tmax<<endl; 64 // cout<<" box "<<box<<endl; 65 // cout<<" origin "<<origin<<endl; 66 // cout<<" direction "<<direction<<endl; 67 // cout<< "inv dir"<<ray.GetInvDir()<<endl; 68 return false; 69 } 70 #else 71 hit.mPoint = origin + direction * Magnitude(box.Diagonal()); 72 #endif 56 73 } 57 else { 58 // cout<<" invalid hp "<<tmin<<" "<<tmax<<endl; 59 // cout<<" box "<<box<<endl; 60 // cout<<" origin "<<origin<<endl; 61 // cout<<" direction "<<direction<<endl; 62 // cout<< "inv dir"<<ray.GetInvDir()<<endl; 63 return false; 74 else 75 { 76 if (mPreprocessor.mDetectEmptyViewSpace) 77 { 78 if (DotProd(hit.mNormal, direction) >= -Limits::Small) 79 { 80 hit.mObject = NULL; 81 return false; 82 } 83 } 64 84 } 65 #else 66 hit.mPoint = origin + direction*Magnitude(box.Diagonal()); 67 #endif 68 } 69 else 70 if (mPreprocessor.mDetectEmptyViewSpace) { 71 if (DotProd(hit.mNormal, direction) >= -Limits::Small) { 72 hit.mObject = NULL; 73 return false; 74 } 75 } 76 77 return true; 85 86 return true; 78 87 } 79 88 … … 98 107 // return 0; 99 108 100 if (pruneInvalidRays) { 101 if (!hitA.mObject && !hitB.mObject) { 102 return 0; 103 } 109 if (pruneInvalidRays) 110 { 111 if (!hitA.mObject && !hitB.mObject) 112 { 113 return 0; 114 } 104 115 } 105 116 … … 107 118 ValidateRay(simpleRay.mOrigin, simpleRay.mDirection, box, hitA); 108 119 109 const bool validB = castDoubleRay && 110 ValidateRay(simpleRay.mOrigin, -simpleRay.mDirection, box, hitB); 120 // note: should we check for backward valitidy also for single rays? 121 const bool validB = //castDoubleRay && 122 ValidateRay(simpleRay.mOrigin, -simpleRay.mDirection, box, hitB); 111 123 112 124 #if DEBUG_RAYCAST … … 115 127 116 128 // reset both contributions 117 if (!validA || !validB) { 118 if (pruneInvalidRays) 119 return 0; 120 // reset both contributions of this ray 121 hitA.mObject = NULL; 122 hitB.mObject = NULL; 129 if (!validA || !validB) 130 { 131 if (pruneInvalidRays) 132 return 0; 133 134 // reset both contributions of this ray 135 hitA.mObject = NULL; 136 hitB.mObject = NULL; 123 137 } 124 138 125 126 const bool validSample = true;127 139 // 8.11. 2007 JB 128 140 // degenerate rays checked by geometrical constraint... … … 133 145 #endif 134 146 135 if (validSample) { 136 if (!pruneInvalidRays || hitA.mObject) { 137 VssRay *vssRay = new VssRay( 138 hitB.mPoint, 147 if (!pruneInvalidRays || hitA.mObject) 148 { 149 VssRay *vssRay = new VssRay(hitB.mPoint, 139 150 hitA.mPoint, 140 151 hitB.mObject, 141 152 hitA.mObject, 142 153 mPreprocessor.mPass, 143 simpleRay.mPdf 144 ); 145 154 simpleRay.mPdf); 155 146 156 if (validA) 147 vssRay->mFlags |= VssRay::Valid; 157 vssRay->mFlags |= VssRay::Valid; 158 148 159 vssRay->mDistribution = simpleRay.mDistribution; 149 160 vssRays.push_back(vssRay); 150 161 ++ hits; 151 162 //cout << "vssray 1: " << *vssRay << " " << vssRay->mTermination - vssRay->mOrigin << endl; 152 153 163 } 164 154 165 #if DEBUG_RAYCAST 155 166 Debug<<"PR3"<<flush; 156 167 #endif 157 168 158 if (castDoubleRay && (!pruneInvalidRays || hitB.mObject)) 159 { 160 VssRay *vssRay = new VssRay( 161 hitA.mPoint, 162 hitB.mPoint, 163 hitA.mObject, 164 hitB.mObject, 165 mPreprocessor.mPass, 166 simpleRay.mPdf 167 ); 168 if (validB) 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) 169 179 vssRay->mFlags |= VssRay::Valid; 170 171 vssRay->mDistribution = simpleRay.mDistribution; 172 vssRays.push_back(vssRay); 173 ++ hits; 174 //cout << "vssray 2: " << *vssRay << endl; 175 } 180 181 vssRay->mDistribution = simpleRay.mDistribution; 182 vssRays.push_back(vssRay); 183 ++ hits; 184 //cout << "vssray 2: " << *vssRay << endl; 176 185 } 177 186
Note: See TracChangeset
for help on using the changeset viewer.