Changeset 2575 for GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.cpp
- Timestamp:
- 01/03/08 15:53:44 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.cpp
r2332 r2575 1 1 2 // GOLEM library3 #include <assert.h>4 2 #include <iostream> 5 3 #include "AxisAlignedBox3.h" … … 10 8 #include "Triangle3.h" 11 9 #include "VssRay.h" 10 11 12 13 #include <cassert> 12 14 13 15 … … 210 212 int 211 213 AxisAlignedBox3::ComputeMinMaxT(const Ray &ray, 212 213 214 float *tmin, 215 float *tmax) const 214 216 { 215 217 float minx, maxx, miny, maxy, minz, maxz; … … 302 304 int 303 305 AxisAlignedBox3::ComputeMinMaxT(const Ray &ray, 304 305 306 float *tmin, 307 float *tmax) const 306 308 { 307 309 const float dirEps = 1e-8f; … … 398 400 // the bounding box and 0 if it does not. 399 401 int AxisAlignedBox3::ComputeMinMaxT(const Ray &ray, float *tmin, float *tmax, 400 402 EFaces &entryFace, EFaces &exitFace) const 401 403 { 402 404 float minx, maxx, miny, maxy, minz, maxz; … … 1840 1842 int 1841 1843 AxisAlignedBox3::ComputeMinMaxT(const Vector3 &origin, 1842 const Vector3 &direction, 1843 float *tmin, 1844 float *tmax) const 1845 { 1846 1844 const Vector3 &direction, 1845 float *tmin, 1846 float *tmax) const 1847 { 1847 1848 register float minx, maxx; 1848 1849 … … 2235 2236 2236 2237 2238 void AxisAlignedBox3::EnlargeToMinSize() 2239 { 2240 const float epsMin = 1e-7; 2241 const float epsAdd = 1e-6; 2242 const float epsMul = 1.000005; 2243 float dir = mMax.x - mMin.x; 2244 assert(dir >= 0.f); 2245 if (dir < epsMin) { 2246 if (mMax.x > 0) { 2247 mMax.x *= epsMul; 2248 mMax.x += epsAdd; 2249 } 2250 else { 2251 mMin.x *= epsMul; 2252 mMin.x -= epsAdd; 2253 } 2254 assert(mMin.x < mMax.x); 2255 } 2256 dir = mMax.y - mMin.y; 2257 assert(dir >= 0.f); 2258 if (dir < epsMin) { 2259 if (mMax.y > 0) { 2260 mMax.y *= epsMul; 2261 mMax.y += epsAdd; 2262 } 2263 else { 2264 mMin.y *= epsMul; 2265 mMin.y -= epsAdd; 2266 } 2267 assert(mMin.y < mMax.y); 2268 } 2269 dir = mMax.z - mMin.z; 2270 assert(dir >= 0.f); 2271 if (dir < epsMin) { 2272 if (mMax.z > 0) { 2273 mMax.z *= epsMul; 2274 mMax.z += epsAdd; 2275 } 2276 else { 2277 mMin.z *= epsMul; 2278 mMin.z -= epsAdd; 2279 } 2280 assert(mMin.z < mMax.z); 2281 } 2282 } 2283 2237 2284 void AxisAlignedBox3::SetMin(const Vector3 &v) 2238 2285 { 2239 2286 mMin = v; 2240 2287 } 2241 2288 … … 2243 2290 void AxisAlignedBox3::SetMax(const Vector3 &v) 2244 2291 { 2245 2292 mMax = v; 2246 2293 } 2247 2294
Note: See TracChangeset
for help on using the changeset viewer.