PixelLightAPI
.
|
00001 /*********************************************************\ 00002 * File: Intersect.h * 00003 * Intersection tools 00004 * 00005 * Copyright (C) 2002-2011 The PixelLight Team (http://www.pixellight.org/) 00006 * 00007 * This file is part of PixelLight. 00008 * 00009 * PixelLight is free software: you can redistribute it and/or modify 00010 * it under the terms of the GNU Lesser General Public License as published by 00011 * the Free Software Foundation, either version 3 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * PixelLight is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU Lesser General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU Lesser General Public License 00020 * along with PixelLight. If not, see <http://www.gnu.org/licenses/>. 00021 \*********************************************************/ 00022 00023 00024 #ifndef __PLMATH_INTERSECT_H__ 00025 #define __PLMATH_INTERSECT_H__ 00026 #pragma once 00027 00028 00029 //[-------------------------------------------------------] 00030 //[ Includes ] 00031 //[-------------------------------------------------------] 00032 #include <PLCore/PLCore.h> 00033 #include "PLMath/PLMath.h" 00034 00035 00036 //[-------------------------------------------------------] 00037 //[ Forward declarations ] 00038 //[-------------------------------------------------------] 00039 namespace PLCore { 00040 template <class AType> class Array; 00041 } 00042 00043 00044 //[-------------------------------------------------------] 00045 //[ Namespace ] 00046 //[-------------------------------------------------------] 00047 namespace PLMath { 00048 00049 00050 //[-------------------------------------------------------] 00051 //[ Predefinitions ] 00052 //[-------------------------------------------------------] 00053 class Ray; 00054 class Line; 00055 class Plane; 00056 class Sphere; 00057 class Vector3; 00058 class Vector4; 00059 class PlaneSet; 00060 class BoundingBox; 00061 class AABoundingBox; 00062 00063 00064 //[-------------------------------------------------------] 00065 //[ Classes ] 00066 //[-------------------------------------------------------] 00067 /** 00068 * @brief 00069 * Static class with some useful intersection tools 00070 */ 00071 class Intersect { 00072 00073 00074 //[-------------------------------------------------------] 00075 //[ Public functions ] 00076 //[-------------------------------------------------------] 00077 public: 00078 //[-------------------------------------------------------] 00079 //[ Sphere ] 00080 //[-------------------------------------------------------] 00081 /** 00082 * @brief 00083 * Check whether there's a sphere/point intersection 00084 * 00085 * @param[in] cSphere 00086 * Sphere to check 00087 * @param[in] cPoint 00088 * Point to check 00089 * 00090 * @return 00091 * 'true' if there's a sphere/axis aligned box intersection, else 'false' 00092 */ 00093 static PLMATH_API bool SpherePoint(const Sphere &cSphere, const Vector3 &cPoint); 00094 static PLMATH_API bool SpherePoint(const Sphere &cSphere, const Vector4 &cPoint); 00095 00096 /** 00097 * @brief 00098 * Check whether there's a sphere/ray intersection 00099 * 00100 * @param[in] cSphere 00101 * Sphere to check 00102 * @param[in] vRayOrigin 00103 * Ray origin 00104 * @param[in] vRayDir 00105 * Ray direction vector 00106 * 00107 * @return 00108 * Distance to intersection point, -1.0 it there was no intersection 00109 */ 00110 static PLMATH_API float SphereRay(const Sphere &cSphere, const Vector3 &vRayOrigin, const Vector3 &vRayDir); 00111 00112 /** 00113 * @brief 00114 * Check whether there's a sphere/ray intersection 00115 * 00116 * @param[in] cSphere 00117 * Sphere to check 00118 * @param[in] vRayOrigin 00119 * Ray origin 00120 * @param[in] vRayDirection 00121 * Ray direction vector 00122 * @param[out] pvIntersect 00123 * If not a null pointer, will receive the intersection point (if there's one) 00124 * 00125 * @return 00126 * 'true' if there's a sphere/ray intersection, else 'false' 00127 */ 00128 static PLMATH_API bool SphereRay(const Sphere &cSphere, const Vector3 &vRayOrigin, 00129 const Vector3 &vRayDirection, Vector3 *pvIntersect = nullptr); 00130 00131 /** 00132 * @brief 00133 * Check whether there's a sphere/ray intersection 00134 * 00135 * @param[in] cSphere 00136 * Sphere to check 00137 * @param[in] vRayOrigin 00138 * Ray origin 00139 * @param[in] vRayDirection 00140 * Ray direction vector 00141 * @param[in] fDistance 00142 * Ray 'length' 00143 * @param[out] pvIntersect 00144 * If not a null pointer, will receive the intersection point (if there's one) 00145 * 00146 * @return 00147 * 'true' if there's a sphere/ray intersection, else 'false' 00148 */ 00149 static PLMATH_API bool SphereRay(const Sphere &cSphere, const Vector3 &vRayOrigin, const Vector3 &vRayDirection, float fDistance, Vector3 *pvIntersect = nullptr); 00150 00151 /** 00152 * @brief 00153 * Check whether there's a sphere/ray intersection 00154 * 00155 * @param[in] cSphere 00156 * Sphere to check 00157 * @param[in] vRayOrigin 00158 * Ray origin 00159 * @param[in] vRayDirection 00160 * Ray direction vector 00161 * @param[out] pvIntersect 00162 * If not a null pointer, will receive the intersection point (if there's one) 00163 * 00164 * @return 00165 * 'true' if there's a sphere/ray intersection, else 'false' 00166 */ 00167 static PLMATH_API bool SphereRayInFront(const Sphere &cSphere, const Vector3 &vRayOrigin, const Vector3 &vRayDirection, Vector3 *pvIntersect = nullptr); 00168 00169 /** 00170 * @brief 00171 * Check whether there's a sphere/line intersection 00172 * 00173 * @param[in] cSphere 00174 * Sphere to check 00175 * @param[in] vStart 00176 * Line start point 00177 * @param[in] vEnd 00178 * Line end point 00179 * 00180 * @return 00181 * 'true' if there's a sphere/line intersection, else 'false' 00182 */ 00183 static PLMATH_API bool SphereLine(const Sphere &cSphere, const Vector3 &vStart, const Vector3 &vEnd); 00184 00185 /** 00186 * @brief 00187 * Check whether there's a sphere/sphere intersection 00188 * 00189 * @param[in] cSphere 00190 * Sphere to check 00191 * @param[in] vPos 00192 * Second sphere position 00193 * @param[in] fRadius 00194 * Second sphere radius 00195 * 00196 * @return 00197 * 'true' if there's a sphere/sphere intersection, else 'false' 00198 */ 00199 static PLMATH_API bool SphereSphere(const Sphere &cSphere, const Vector3 &vPos, float fRadius); 00200 00201 /** 00202 * @brief 00203 * Check whether there's a sphere/sphere intersection 00204 * 00205 * @param[in] cSphere 00206 * Sphere to check 00207 * @param[in] cSphere2 00208 * Second sphere to check 00209 * 00210 * @return 00211 * 'true' if there's a sphere/sphere intersection, else 'false' 00212 */ 00213 static PLMATH_API bool SphereSphere(const Sphere &cSphere, const Sphere &cSphere2); 00214 00215 /** 00216 * @brief 00217 * Check whether a sphere intersects with this sphere while moving 00218 * 00219 * @param[in] cSphere 00220 * Sphere to check 00221 * @param[in] cSphere2 00222 * Second sphere to test 00223 * @param[in] vMove1 00224 * Movement vector of this sphere 00225 * @param[in] vMove2 00226 * Movement vector of the other sphere box 00227 * 00228 * @return 00229 * 'true' if there's an intersection, else 'false' 00230 */ 00231 static PLMATH_API bool SphereSphere(const Sphere &cSphere, const Sphere &cSphere2, const Vector3 &vMove1, const Vector3 &vMove2); 00232 00233 /** 00234 * @brief 00235 * Check whether there's a sphere/axis aligned box intersection 00236 * 00237 * @param[in] vSpherePos 00238 * Position of the sphere to check 00239 * @param[in] fSphereRadius 00240 * Radius of the sphere to check 00241 * @param[in] cAABox 00242 * Axis aligned box to check 00243 * 00244 * @return 00245 * 'true' if there's a sphere/axis aligned box intersection, else 'false' 00246 */ 00247 static PLMATH_API bool SphereAABox(const Vector3 &vSpherePos, float fSphereRadius, const AABoundingBox &cAABox); 00248 00249 /** 00250 * @brief 00251 * Check whether there's a sphere/axis aligned box intersection 00252 * 00253 * @param[in] cSphere 00254 * Sphere to check 00255 * @param[in] cAABox 00256 * Axis aligned box to check 00257 * 00258 * @return 00259 * 'true' if there's a sphere/axis aligned box intersection, else 'false' 00260 */ 00261 static PLMATH_API bool SphereAABox(const Sphere &cSphere, const AABoundingBox &cAABox); 00262 00263 /** 00264 * @brief 00265 * Check whether there's a sphere/box intersection 00266 * 00267 * @param[in] vSpherePos 00268 * Position of the sphere to check 00269 * @param[in] fSphereRadius 00270 * Radius of the sphere to check 00271 * @param[in] cBox 00272 * Box to check 00273 * 00274 * @return 00275 * 'true' if there's a sphere/box intersection, else 'false' 00276 */ 00277 static PLMATH_API bool SphereBox(const Vector3 &vSpherePos, float fSphereRadius, const BoundingBox &cBox); 00278 00279 /** 00280 * @brief 00281 * Check whether there's a sphere/box intersection 00282 * 00283 * @param[in] cSphere 00284 * Sphere to check 00285 * @param[in] cBox 00286 * Box to check 00287 * 00288 * @return 00289 * 'true' if there's a sphere/box intersection, else 'false' 00290 */ 00291 static PLMATH_API bool SphereBox(const Sphere &cSphere, const BoundingBox &cBox); 00292 00293 //[-------------------------------------------------------] 00294 //[ Axis aligned box ] 00295 //[-------------------------------------------------------] 00296 /** 00297 * @brief 00298 * Check whether a point is inside the axis aligned box 00299 * 00300 * @param[in] vAABoxMin 00301 * Axis aligned box minimum position 00302 * @param[in] vAABoxMax 00303 * Axis aligned box box maximum position 00304 * @param[in] vPos 00305 * Point to test 00306 * 00307 * @return 00308 * 'true' if the given point is inside the axis aligned box, else 'false' 00309 */ 00310 static PLMATH_API bool AABoxPoint(const Vector3 &vAABoxMin, const Vector3 &vAABoxMax, const Vector3 &vPos); 00311 00312 /** 00313 * @brief 00314 * Check whether there's a axis aligned box/line intersection 00315 * 00316 * @param[in] vAABoxMin 00317 * Axis aligned box minimum position 00318 * @param[in] vAABoxMax 00319 * Axis aligned box box maximum position 00320 * @param[in] vStart 00321 * Line start point 00322 * @param[in] vEnd 00323 * Line end point 00324 * @param[out] pfIntersection 00325 * Receives the intersection distance if not null, <0 if there's no intersection or when the start point is inside the axis aligned box or when the distance is just negative 00326 * 00327 * @return 00328 * 'true' if there's a axis aligned box/line intersection, else 'false' 00329 */ 00330 static PLMATH_API bool AABoxLine(const Vector3 &vAABoxMin, const Vector3 &vAABoxMax, const Vector3 &vStart, const Vector3 &vEnd, float *pfIntersection = nullptr); 00331 00332 /** 00333 * @brief 00334 * Check whether there's a axis aligned box/line intersection 00335 * 00336 * @param[in] vAABoxMin 00337 * Axis aligned box minimum position 00338 * @param[in] vAABoxMax 00339 * Axis aligned box box maximum position 00340 * @param[in] cLine 00341 * Line to check 00342 * @param[out] pfIntersection 00343 * Receives the intersection distance if not null, <0 if there's no intersection or when the start point is inside the axis aligned box or when the distance is just negative 00344 * 00345 * @return 00346 * 'true' if there's a axis aligned box/line intersection, else 'false' 00347 */ 00348 static PLMATH_API bool AABoxLine(const Vector3 &vAABoxMin, const Vector3 &vAABoxMax, const Line &cLine, float *pfIntersection = nullptr); 00349 00350 /** 00351 * @brief 00352 * Check whether there's a axis aligned box/sphere intersection 00353 * 00354 * @param[in] vAABoxMin 00355 * Axis aligned box minimum position 00356 * @param[in] vAABoxMax 00357 * Axis aligned box box maximum position 00358 * @param[in] vSpherePos 00359 * Position of the sphere to check 00360 * @param[in] fSphereRadius 00361 * Radius of the sphere to check 00362 * 00363 * @return 00364 * 'true' if there's a sphere/axis aligned box intersection, else 'false' 00365 */ 00366 static PLMATH_API bool AABoxSphere(const Vector3 &vAABoxMin, const Vector3 &vAABoxMax, const Vector3 &vSpherePos, float fSphereRadius); 00367 00368 /** 00369 * @brief 00370 * Check whether there's a axis aligned box/axis aligned box intersection 00371 * 00372 * @param[in] vAABoxMin1 00373 * Axis aligned box minimum position 1 00374 * @param[in] vAABoxMax1 00375 * Axis aligned box box maximum position 1 00376 * @param[in] vAABoxMin2 00377 * Axis aligned box minimum position 2 00378 * @param[in] vAABoxMax2 00379 * Axis aligned box box maximum position 2 00380 * 00381 * @return 00382 * 'true' if there's a axis aligned box/axis aligned box intersection, else 'false' 00383 */ 00384 static PLMATH_API bool AABoxAABox(const Vector3 &vAABoxMin1, const Vector3 &vAABoxMax1, 00385 const Vector3 &vAABoxMin2, const Vector3 &vAABoxMax2); 00386 00387 /** 00388 * @brief 00389 * Check whether there's a axis aligned box/axis aligned box intersection 00390 * 00391 * @param[in] cBox1 00392 * Axis aligned box 1 00393 * @param[in] cBox2 00394 * Axis aligned box 2 00395 * 00396 * @return 00397 * 'true' if there's a axis aligned box/axis aligned box intersection, else 'false' 00398 */ 00399 static PLMATH_API bool AABoxAABox(const AABoundingBox &cBox1, const AABoundingBox &cBox2); 00400 00401 //[-------------------------------------------------------] 00402 //[ Box ] 00403 //[-------------------------------------------------------] 00404 /** 00405 * @brief 00406 * Check whether a point is inside the box 00407 * 00408 * @param[in] cBox 00409 * Box to check 00410 * @param[in] vPos 00411 * Point to test 00412 * 00413 * @return 00414 * 'true' if the given point is inside the box, else 'false' 00415 */ 00416 static PLMATH_API bool BoxPoint(const BoundingBox &cBox, const Vector3 &vPos); 00417 00418 /** 00419 * @brief 00420 * Check whether a line intersects with the box 00421 * 00422 * @param[in] cBox 00423 * Box to check 00424 * @param[in] vA 00425 * Line start position 00426 * @param[in] vB 00427 * Line end position 00428 * 00429 * @return 00430 * 'true' if the given line intersects with the box, else 'false' 00431 */ 00432 static PLMATH_API bool BoxLine(const BoundingBox &cBox, const Vector3 &vA, const Vector3 &vB); 00433 00434 /** 00435 * @brief 00436 * Check whether another box intersects with this box 00437 * 00438 * @param[in] cBox1 00439 * First box to check 00440 * @param[in] cBox2 00441 * Second box to test 00442 * 00443 * @return 00444 * 'true' if the given box intersects with this box, else 'false' 00445 */ 00446 static PLMATH_API bool BoxBox(const BoundingBox &cBox1, const BoundingBox &cBox2); 00447 00448 /** 00449 * @brief 00450 * Check whether another box intersects with this box while moving 00451 * 00452 * @param[in] cBox1 00453 * First box to check 00454 * @param[in] cBox2 00455 * Second box to test 00456 * @param[in] vMove1 00457 * Movement vector of first box 00458 * @param[in] vMove2 00459 * Movement vector of second box 00460 * 00461 * @return 00462 * 'true' if the given box intersects with this box while moving, else 'false' 00463 */ 00464 static PLMATH_API bool BoxBox(const BoundingBox &cBox1, const BoundingBox &cBox2, const Vector3 &vMove1, const Vector3 &vMove2); 00465 00466 /** 00467 * @brief 00468 * Check whether the box is in the plane set or not 00469 * 00470 * @param[in] cBox 00471 * Box to check 00472 * @param[in] cPlaneSet 00473 * Plane set to check 00474 * 00475 * @return 00476 * 'true' if the box is in the plane set, else 'false' 00477 */ 00478 static PLMATH_API bool BoxPlaneSet(const BoundingBox &cBox, const PlaneSet &cPlaneSet); 00479 00480 //[-------------------------------------------------------] 00481 //[ Plane ] 00482 //[-------------------------------------------------------] 00483 /** 00484 * @brief 00485 * Checks if there's a plane/ray intersection 00486 * 00487 * @param[in] cPlane 00488 * Plane to check 00489 * @param[in] vRayDir 00490 * Ray direction (must be normalized) 00491 * 00492 * @return 00493 * 'true' if the ray intersects the plane, else 'false' (ray is parallel to plane) 00494 */ 00495 static PLMATH_API bool IsPlaneRay(const Plane &cPlane, const Vector3 &vRayDir); 00496 00497 /** 00498 * @brief 00499 * Returns the plane/ray intersection point 00500 * 00501 * @param[in] cPlane 00502 * Plane to check 00503 * @param[in] vRayPos 00504 * Ray position 00505 * @param[in] vRayDir 00506 * Ray direction (must be normalized) 00507 * 00508 * @return 00509 * The intersection point, if there was no intersection the ray position 00510 * will be returned 00511 */ 00512 static PLMATH_API Vector3 PlaneRay(const Plane &cPlane, const Vector3 &vRayPos, const Vector3 &vRayDir); 00513 00514 /** 00515 * @brief 00516 * Checks if there's a plane/line intersection 00517 * 00518 * @param[in] cPlane 00519 * Plane to check 00520 * @param[in] vStartPos 00521 * Line start position 00522 * @param[in] vEndPos 00523 * Line end direction 00524 * @param[out] pvPos 00525 * If not a null pointer this will receive the intersection point (if there is any :) 00526 * 00527 * @return 00528 * Factor between 0-1 if there was an intersection, -1.0f if no intersection 00529 */ 00530 static PLMATH_API float PlaneLine(const Plane &cPlane, const Vector3 &vStartPos, const Vector3 &vEndPos, Vector3 *pvPos = nullptr); 00531 00532 /** 00533 * @brief 00534 * Checks if there's a plane/plane intersection 00535 * 00536 * @param[in] cPlane 00537 * Plane to check 00538 * @param[in] cPlane2 00539 * Plane2 to test with 00540 * 00541 * @return 00542 * 'true' if the plane intersects the plane, else 'false' 00543 */ 00544 static PLMATH_API bool PlanePlane(const Plane &cPlane, const Plane &cPlane2); 00545 00546 /** 00547 * @brief 00548 * Checks if there's a plane/plane intersection and calculates the intersection ray 00549 * 00550 * @param[in] cPlane 00551 * Plane to check 00552 * @param[in] cPlane2 00553 * Second plane 00554 * @param[out] cRay 00555 * Receives the intersection ray/line 00556 * 00557 * @return 00558 * 'true' if theres a plane intersection, else 'false' 00559 */ 00560 static PLMATH_API bool PlanePlane(const Plane &cPlane, const Plane &cPlane2, Ray &cRay); 00561 00562 /** 00563 * @brief 00564 * Checks if there's an intersection between the three planes and returns the 00565 * intersection point 00566 * 00567 * @param[in] cP1 00568 * Plane to check 00569 * @param[in] cP2 00570 * Plane to intersect with 00571 * @param[in] cP3 00572 * Plane to intersect with 00573 * @param[out] vRes 00574 * Receives the intersection point 00575 * 00576 * @return 00577 * 'true' if there's an intersection between the three planes, else 'false' 00578 */ 00579 static PLMATH_API bool PlanePlanePlane(const Plane &cP1, const Plane &cP2, const Plane &cP3, Vector3 &vRes); 00580 00581 //[-------------------------------------------------------] 00582 //[ Plane set ] 00583 //[-------------------------------------------------------] 00584 /** 00585 * @brief 00586 * Test whether a point is in the plane set 00587 * 00588 * @param[in] cPlaneSet 00589 * Plane set to check 00590 * @param[in] vPoint 00591 * Position of the point 00592 * 00593 * @return 00594 * 'true' if the point is in plane set, else 'false' 00595 */ 00596 static PLMATH_API bool PlaneSetPoint(const PlaneSet &cPlaneSet, const Vector3 &vPoint); 00597 00598 /** 00599 * @brief 00600 * Test whether a point is in the plane set 00601 * 00602 * @param[in] cPlaneSet 00603 * Plane set to check 00604 * @param[in] vPoint 00605 * Position of the point 00606 * 00607 * @return 00608 * 'true' if the point is in plane set, else 'false' 00609 */ 00610 static PLMATH_API bool PlaneSetPoint(const PlaneSet &cPlaneSet, const Vector4 &vPoint); 00611 00612 /** 00613 * @brief 00614 * Test whether the given points are in the plane set 00615 * 00616 * @param[in] cPlaneSet 00617 * Plane set to check 00618 * @param[in] lstPoints 00619 * Array of all points to test 00620 * 00621 * @return 00622 * 'true' if the points are in plane set, else 'false' 00623 */ 00624 static PLMATH_API bool PlaneSetPoints(const PlaneSet &cPlaneSet, const PLCore::Array<Vector3> &lstPoints); 00625 00626 /** 00627 * @brief 00628 * Test whether the given points are in the plane set 00629 * 00630 * @param[in] cPlaneSet 00631 * Plane set to check 00632 * @param[in] lstPoints 00633 * Array of all points to test 00634 * 00635 * @return 00636 * 'true' if the points are in plane set, else 'false' 00637 */ 00638 static PLMATH_API bool PlaneSetPoints(const PlaneSet &cPlaneSet, const PLCore::Array<Vector4> &lstPoints); 00639 00640 /** 00641 * @brief 00642 * Test whether a sphere is in the plane set 00643 * 00644 * @param[in] cPlaneSet 00645 * Plane set to check 00646 * @param[in] vSphereOrigin 00647 * Middle of the sphere 00648 * @param[in] fSphereRadius 00649 * Sphere radius 00650 * 00651 * @return 00652 * 'true' if the sphere is in plane set, else 'false' 00653 */ 00654 static PLMATH_API bool PlaneSetSphere(const PlaneSet &cPlaneSet, const Vector3 &vSphereOrigin, float fSphereRadius); 00655 00656 /** 00657 * @brief 00658 * Test whether a triangle is in the plane set 00659 * 00660 * @param[in] cPlaneSet 00661 * Plane set to check 00662 * @param[in] vV1 00663 * First triangle point 00664 * @param[in] vV2 00665 * Second triangle point 00666 * @param[in] vV3 00667 * Third triangle point 00668 * 00669 * @return 00670 * 'true' if the triangle is in plane set, else 'false' 00671 */ 00672 static PLMATH_API bool PlaneSetTriangle(const PlaneSet &cPlaneSet, const Vector3 &vV1, 00673 const Vector3 &vV2, const Vector3 &vV3); 00674 00675 /** 00676 * @brief 00677 * Tests whether an axis aligned box is within the plane set or not 00678 * 00679 * @param[in] cPlaneSet 00680 * Plane set to check 00681 * @param[in] vMin 00682 * Minimum position 00683 * @param[in] vMax 00684 * Maximum position 00685 * @param[out] pnOutClipMask 00686 * If not a null pointer, this clip mask will receive the intersection state of a 00687 * maximum number of 32 planes if the box intersects the plane set. If this mask is 00688 * 0, there was no plane intersection at all. (= complete inside/outside the plane set) 00689 * 00690 * @return 00691 * 'true' if the axis aligned box is within plane set, else 'false' 00692 */ 00693 static PLMATH_API bool PlaneSetAABox(const PlaneSet &cPlaneSet, const Vector3 &vMin, const Vector3 &vMax, PLCore::uint32 *pnOutClipMask = nullptr); 00694 00695 //[-------------------------------------------------------] 00696 //[ Triangle ] 00697 //[-------------------------------------------------------] 00698 /** 00699 * @brief 00700 * Checks if there's a triangle/ray intersection 00701 * 00702 * @param[in] vV1 00703 * First triangle point 00704 * @param[in] vV2 00705 * Second triangle point 00706 * @param[in] vV3 00707 * Third triangle point 00708 * @param[in] vN 00709 * Triangle plane normal 00710 * @param[in] vRayOrigin 00711 * Ray origin 00712 * @param[in] vRayDirection 00713 * Ray direction vector 00714 * @param[out] pvIntersectionPointPos 00715 * If not a null pointer, will receive the position of the intersection point 00716 * 00717 * @return 00718 * 'true' if the ray intersects the triangle, else 'false' 00719 */ 00720 static PLMATH_API bool TriangleRay(const Vector3 &vV1, const Vector3 &vV2, 00721 const Vector3 &vV3, const Vector3 &vN, 00722 const Vector3 &vRayOrigin, const Vector3 &vRayDirection, 00723 Vector3 *pvIntersectionPointPos = nullptr); 00724 00725 /** 00726 * @brief 00727 * Checks if there's a triangle/ray intersection 00728 * 00729 * @param[in] vV1 00730 * First triangle point 00731 * @param[in] vV2 00732 * Second triangle point 00733 * @param[in] vV3 00734 * Third triangle point 00735 * @param[in] vN 00736 * Triangle plane normal 00737 * @param[in] cRay 00738 * Ray to check 00739 * @param[out] pvIntersectionPointPos 00740 * If not a null pointer, will receive the position of the intersection point 00741 * 00742 * @return 00743 * 'true' if the ray intersects the triangle, else 'false' 00744 */ 00745 static PLMATH_API bool TriangleRay(const Vector3 &vV1, const Vector3 &vV2, 00746 const Vector3 &vV3, const Vector3 &vN, 00747 const Ray &cRay, Vector3 *pvIntersectionPointPos = nullptr); 00748 00749 00750 }; 00751 00752 00753 //[-------------------------------------------------------] 00754 //[ Namespace ] 00755 //[-------------------------------------------------------] 00756 } // PLMath 00757 00758 00759 #endif // __PLMATH_INTERSECT_H__
|