Changeset 1328 for GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.cpp
- Timestamp:
- 09/11/06 00:29:47 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Polygon3.cpp
r1076 r1328 316 316 int Polygon3::CastRay(const Ray &ray, float &t, const float nearestT) 317 317 { 318 Plane3 plane = GetSupportingPlane();319 float dot = DotProd(plane.mNormal, ray.GetDir());318 const Plane3 plane = GetSupportingPlane(); 319 const float dot = DotProd(plane.mNormal, ray.GetDir()); 320 320 321 321 // Watch for near-zero denominator 322 322 // ONLY single sided polygons!!!!! 323 323 if (dot > -Limits::Small) 324 // if (fabs(dot) < Limits::Small) 325 return Ray::NO_INTERSECTION; 324 { 325 // if (fabs(dot) < Limits::Small) 326 return Ray::NO_INTERSECTION; 327 } 326 328 327 329 t = (-plane.mD - DotProd(plane.mNormal, ray.GetLoc())) / dot; 328 330 329 331 if (t <= Limits::Small) 330 return Ray::INTERSECTION_OUT_OF_LIMITS; 331 332 if (t >= nearestT) { 333 return Ray::INTERSECTION_OUT_OF_LIMITS; // no intersection was found 332 { 333 return Ray::INTERSECTION_OUT_OF_LIMITS; 334 } 335 336 if (t >= nearestT) 337 { 338 return Ray::INTERSECTION_OUT_OF_LIMITS; // no intersection was found 334 339 } 335 340 … … 338 343 int i; 339 344 340 int paxis = plane.mNormal.DrivingAxis();345 const int paxis = plane.mNormal.DrivingAxis(); 341 346 342 347 // Project the intersection point onto the coordinate plane … … 344 349 ray.Extrap(t).ExtractVerts(&u, &v, paxis); 345 350 346 int size = (int)mVertices.size();351 const int size = (int)mVertices.size(); 347 352 348 353 mVertices.back().ExtractVerts(&u1, &v1, paxis ); … … 354 359 { 355 360 mVertices[i].ExtractVerts(&u2, &v2, paxis); 356 361 357 362 // line u1, v1, u2, v2 358 359 if ((v2 - v1)*(u1 - u) > (u2 - u1)*(v1 - v)) 363 if ((v2 - v1) * (u1 - u) > (u2 - u1)*(v1 - v)) 360 364 return Ray::NO_INTERSECTION; 361 365 362 366 u1 = u2; 363 367 v1 = v2; 364 }365 366 return Ray::INTERSECTION;368 } 369 370 return Ray::INTERSECTION; 367 371 } 368 372 … … 537 541 538 542 if ((count ++) % 2) 543 { 539 544 j = i ++; 545 } 540 546 else 547 { 541 548 j = k --; 549 } 542 550 } 543 551 } … … 575 583 } 576 584 577 } 585 586 AxisAlignedBox3 Polygon3::GetBoundingBox() const 587 { 588 VertexContainer::const_iterator vit, vit_end = mVertices.end(); 589 590 AxisAlignedBox3 box; 591 box.Initialize(); 592 593 for (vit = mVertices.begin(); vit != vit_end; ++ vit) 594 { 595 box.Include(*vit); 596 } 597 598 return box; 599 } 600 601 602 }
Note: See TracChangeset
for help on using the changeset viewer.