Changeset 675 for GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp
- Timestamp:
- 03/06/06 09:17:09 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/VssPreprocessor.cpp
r674 r675 36 36 useViewspacePlane = mUseViewSpaceBox; //hack 37 37 38 39 Debug << "*********** vss preprocessor options **************" << endl; 40 Debug << "use view space box=" << mUseViewSpaceBox << endl; 41 Debug << "enlarge view space=" << mEnlargeViewSpace << endl; 42 Debug << "detect empty view space=" << mDetectEmptyViewSpace << endl; 43 44 Debug << "*********** end vss preprocessor options **************" << endl; 45 38 46 mStats.open("stats.log"); 39 47 } … … 77 85 78 86 int hits = 0; 79 static Ray ray; 80 AxisAlignedBox3 box = mViewSpaceBox ? *mViewSpaceBox : mKdTree->GetBox(); 81 82 AxisAlignedBox3 sbox = box; 83 sbox.Enlarge(Vector3(-Limits::Small)); 84 if (!sbox.IsInside(viewPoint)) 85 return 0; 86 87 SetupRay(ray, viewPoint, direction); 88 // cast ray to KD tree to find intersection with other objects 89 Intersectable *objectA, *objectB; 90 Vector3 pointA, pointB; 91 float bsize = Magnitude(box.Size()); 92 87 static Ray ray; 88 89 AxisAlignedBox3 box = mViewSpaceBox ? *mViewSpaceBox : mKdTree->GetBox(); 90 AxisAlignedBox3 sbox = box; 91 92 sbox.Enlarge(Vector3(-Limits::Small)); 93 94 if (!sbox.IsInside(viewPoint)) 95 return 0; 96 97 SetupRay(ray, viewPoint, direction); 98 99 // cast ray to KD tree to find intersection with other objects 100 Intersectable *objectA, *objectB; 101 Vector3 pointA, pointB; 102 float bsize = Magnitude(box.Size()); 93 103 94 104 if (!mDetectEmptyViewSpace) 95 105 ray.mFlags &= ~Ray::CULL_BACKFACES; 96 106 else 97 ray.mFlags |= Ray::CULL_BACKFACES; 98 99 if (mKdTree->CastRay(ray)) { 100 objectA = ray.intersections[0].mObject; 101 pointA = ray.Extrap(ray.intersections[0].mT); 102 } else { 103 objectA = NULL; 104 // compute intersection with the scene bounding box 105 float tmin, tmax; 106 if (box.ComputeMinMaxT(ray, &tmin, &tmax) && tmin < tmax) 107 pointA = ray.Extrap(tmax); 107 ray.mFlags |= Ray::CULL_BACKFACES; 108 109 if (mKdTree->CastRay(ray)) 110 { 111 objectA = ray.intersections[0].mObject; 112 pointA = ray.Extrap(ray.intersections[0].mT); 113 } 114 else 115 { 116 objectA = NULL; 117 // compute intersection with the scene bounding box 118 float tmin, tmax; 119 if (box.ComputeMinMaxT(ray, &tmin, &tmax) && tmin < tmax) 120 pointA = ray.Extrap(tmax); 121 else 122 return 0; 123 } 124 125 126 if (mDetectEmptyViewSpace) { 127 SetupRay(ray, pointA, -direction); 128 } else 129 SetupRay(ray, viewPoint, -direction); 130 131 if (!mDetectEmptyViewSpace) 132 ray.mFlags &= ~Ray::CULL_BACKFACES; 108 133 else 109 return 0;110 } 111 112 113 if (mDetectEmptyViewSpace) { 114 SetupRay(ray, pointA, -direction);115 } else 116 SetupRay(ray, viewPoint, -direction);117 118 if (!mDetectEmptyViewSpace) 119 ray.mFlags &= ~Ray::CULL_BACKFACES;120 else 121 ray.mFlags |= Ray::CULL_BACKFACES;122 123 if (mKdTree->CastRay(ray)) { 124 objectB = ray.intersections[0].mObject;125 pointB = ray.Extrap(ray.intersections[0].mT);126 } else {127 objectB = NULL;128 float tmin, tmax;129 if (box.ComputeMinMaxT(ray, &tmin, &tmax) && tmin < tmax)130 pointB = ray.Extrap(tmax);131 else132 return 0;133 } 134 135 // if (objectA == NULL && objectB != NULL){136 if (mDetectEmptyViewSpace) { 137 // cast again to ensure that there is no objectA138 SetupRay(ray, pointB, direction);139 ray.mFlags |= Ray::CULL_BACKFACES;140 if (mKdTree->CastRay(ray)) { 141 objectA = ray.intersections[0].mObject; 142 pointA = ray.Extrap(ray.intersections[0].mT);143 } 144 } 145 146 147 VssRay *vssRay = NULL; 148 149 bool validSample = (objectA != objectB); 150 if (0 && mDetectEmptyViewSpace) { // consider all samples valid 151 // check if the viewpoint lies on the line segment AB152 if (Distance(pointA, pointB) <153 Distance(viewPoint, pointA) + Distance(viewPoint, pointB) - Limits::Small) {154 validSample = false;155 } 156 } 157 158 if (validSample) { 159 if (objectA) {160 vssRay = new VssRay(pointB,161 pointA,162 objectB,163 objectA,164 mPass165 166 167 168 }169 170 if (objectB) {171 vssRay = new VssRay(pointA,172 pointB,173 objectA,174 objectB,175 mPass176 177 178 179 }180 181 182 134 ray.mFlags |= Ray::CULL_BACKFACES; 135 136 if (mKdTree->CastRay(ray)) 137 { 138 objectB = ray.intersections[0].mObject; 139 pointB = ray.Extrap(ray.intersections[0].mT); 140 } 141 else 142 { 143 objectB = NULL; 144 float tmin, tmax; 145 146 if (box.ComputeMinMaxT(ray, &tmin, &tmax) && tmin < tmax) 147 pointB = ray.Extrap(tmax); 148 else 149 return 0; 150 } 151 152 // if (objectA == NULL && objectB != NULL) { 153 if (mDetectEmptyViewSpace) 154 { 155 // cast again to ensure that there is no objectA 156 SetupRay(ray, pointB, direction); 157 ray.mFlags |= Ray::CULL_BACKFACES; 158 159 if (mKdTree->CastRay(ray)) 160 { 161 objectA = ray.intersections[0].mObject; 162 pointA = ray.Extrap(ray.intersections[0].mT); 163 } 164 } 165 166 167 VssRay *vssRay = NULL; 168 169 bool validSample = (objectA != objectB); 170 171 if (0 && mDetectEmptyViewSpace) 172 { 173 // consider all samples valid 174 // check if the viewpoint lies on the line segment AB 175 if (Distance(pointA, pointB) < 176 Distance(viewPoint, pointA) + Distance(viewPoint, pointB) - Limits::Small) 177 { 178 validSample = false; 179 } 180 } 181 182 if (validSample) 183 { 184 if (objectA) 185 { 186 vssRay = new VssRay(pointB, 187 pointA, 188 objectB, 189 objectA, 190 mPass); 191 vssRays.push_back(vssRay); 192 hits ++; 193 } 194 195 if (objectB) 196 { 197 vssRay = new VssRay(pointA, 198 pointB, 199 objectA, 200 objectB, 201 mPass); 202 vssRays.push_back(vssRay); 203 hits ++; 204 } 205 } 206 207 return hits; 183 208 } 184 209 … … 528 553 529 554 cout<<"mUseViewSpaceBox="<<mUseViewSpaceBox<<endl; 530 Debug << "use view space box=" << mUseViewSpaceBox << endl; 555 531 556 532 557 if (mUseViewSpaceBox)
Note: See TracChangeset
for help on using the changeset viewer.