[1378] | 1 | #ifndef NX_INTERSECTION_SEGMENT_BOX
|
---|
| 2 | #define NX_INTERSECTION_SEGMENT_BOX
|
---|
| 3 | /** \addtogroup physics
|
---|
| 4 | @{
|
---|
| 5 | */
|
---|
| 6 |
|
---|
| 7 | #include "Nxp.h"
|
---|
| 8 | #include "NxBox.h"
|
---|
| 9 | #include "PhysXLoader.h"
|
---|
| 10 |
|
---|
| 11 | class NxRay;
|
---|
| 12 |
|
---|
| 13 | //namespace NxCollision
|
---|
| 14 | //{
|
---|
| 15 | /**
|
---|
| 16 | \brief Segment-AABB intersection test.
|
---|
| 17 |
|
---|
| 18 | Also computes intersection point.
|
---|
| 19 |
|
---|
| 20 | \warning #NxCreatePhysicsSDK() must be called before using this function.
|
---|
| 21 |
|
---|
| 22 | \param[in] p1 First point of line segment. <b>Range:</b> position vector
|
---|
| 23 | \param[in] p2 Second point of line segment. <b>Range:</b> position vector
|
---|
| 24 | \param[in] bbox_min Minimum extent of AABB. <b>Range:</b> position vector
|
---|
| 25 | \param[in] bbox_max Max extent of AABB. <b>Range:</b> position vector
|
---|
| 26 | \param[out] intercept Intersection point between segment and box.
|
---|
| 27 |
|
---|
| 28 | \return True if the segment and AABB intersect.
|
---|
| 29 |
|
---|
| 30 | <b>Platform:</b>
|
---|
| 31 | \li PC SW: Yes
|
---|
| 32 | \li PPU : Yes
|
---|
| 33 | \li PS3 : Yes
|
---|
| 34 | \li XB360: Yes
|
---|
| 35 | */
|
---|
| 36 | NX_INLINE bool NX_CALL_CONV NxSegmentBoxIntersect(const NxVec3& p1, const NxVec3& p2,
|
---|
| 37 | const NxVec3& bbox_min,const NxVec3& bbox_max, NxVec3& intercept)
|
---|
| 38 | {
|
---|
| 39 | return NxGetUtilLib()->NxSegmentBoxIntersect(p1,p2,bbox_min,bbox_max,intercept);
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | /**
|
---|
| 43 | \brief Ray-AABB intersection test.
|
---|
| 44 |
|
---|
| 45 | Also computes intersection point.
|
---|
| 46 |
|
---|
| 47 | \warning #NxCreatePhysicsSDK() must be called before using this function.
|
---|
| 48 |
|
---|
| 49 | \param[in] min Minimum extent of AABB. <b>Range:</b> position vector
|
---|
| 50 | \param[in] max Maximum extent of AABB. <b>Range:</b> position vector
|
---|
| 51 | \param[in] origin Origin of ray. <b>Range:</b> position vector
|
---|
| 52 | \param[in] dir Direction of ray. <b>Range:</b> direction vector
|
---|
| 53 | \param[out] coord Intersection point.
|
---|
| 54 |
|
---|
| 55 | \return True if the ray and AABB intersect.
|
---|
| 56 |
|
---|
| 57 | <b>Platform:</b>
|
---|
| 58 | \li PC SW: Yes
|
---|
| 59 | \li PPU : Yes
|
---|
| 60 | \li PS3 : Yes
|
---|
| 61 | \li XB360: Yes
|
---|
| 62 | */
|
---|
| 63 | NX_INLINE bool NX_CALL_CONV NxRayAABBIntersect(const NxVec3& min, const NxVec3& max,
|
---|
| 64 | const NxVec3& origin, const NxVec3& dir, NxVec3& coord)
|
---|
| 65 | {
|
---|
| 66 | return NxGetUtilLib()->NxRayAABBIntersect(min,max,origin,dir,coord);
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 | /**
|
---|
| 70 | \brief Extended Ray-AABB intersection test.
|
---|
| 71 |
|
---|
| 72 | Also computes intersection point, and parameter and returns contacted box axis index+1. Rays starting from inside the box are ignored.
|
---|
| 73 |
|
---|
| 74 | \warning #NxCreatePhysicsSDK() must be called before using this function.
|
---|
| 75 |
|
---|
| 76 | \param[in] min Minimum extent of AABB. <b>Range:</b> position vector
|
---|
| 77 | \param[in] max Maximum extent of AABB. <b>Range:</b> position vector
|
---|
| 78 | \param[in] origin Origin of ray. <b>Range:</b> position vector
|
---|
| 79 | \param[in] dir Direction of ray. <b>Range:</b> direction vector
|
---|
| 80 | \param[out] coord Intersection point.
|
---|
| 81 | \param[out] t Ray paraemeter corresponding to contact point.
|
---|
| 82 |
|
---|
| 83 | \return Box axis index.
|
---|
| 84 |
|
---|
| 85 | <b>Platform:</b>
|
---|
| 86 | \li PC SW: Yes
|
---|
| 87 | \li PPU : Yes
|
---|
| 88 | \li PS3 : Yes
|
---|
| 89 | \li XB360: Yes
|
---|
| 90 | */
|
---|
| 91 | NX_INLINE NxU32 NX_CALL_CONV NxRayAABBIntersect2(const NxVec3& min, const NxVec3& max,
|
---|
| 92 | const NxVec3& origin, const NxVec3& dir, NxVec3& coord, NxReal & t)
|
---|
| 93 | {
|
---|
| 94 | return NxGetUtilLib()->NxRayAABBIntersect2(min,max,origin,dir,coord,t);
|
---|
| 95 | }
|
---|
| 96 |
|
---|
| 97 | /**
|
---|
| 98 | \brief Boolean segment-OBB intersection test.
|
---|
| 99 |
|
---|
| 100 | Based on separating axis theorem.
|
---|
| 101 |
|
---|
| 102 | \warning #NxCreatePhysicsSDK() must be called before using this function.
|
---|
| 103 |
|
---|
| 104 | \param[in] p0 First point of line segment. <b>Range:</b> position vector
|
---|
| 105 | \param[in] p1 Second point of line segment. <b>Range:</b> position vector
|
---|
| 106 | \param[in] center Centre point of OBB. <b>Range:</b> position vector
|
---|
| 107 | \param[in] extents Extent/Radii of the OBB. <b>Range:</b> direction vector
|
---|
| 108 | \param[in] rot Rotation of the OBB(applied before translation). <b>Range:</b> rotation matrix
|
---|
| 109 |
|
---|
| 110 | \return true if the segment and OBB intersect.
|
---|
| 111 |
|
---|
| 112 | <b>Platform:</b>
|
---|
| 113 | \li PC SW: Yes
|
---|
| 114 | \li PPU : Yes
|
---|
| 115 | \li PS3 : Yes
|
---|
| 116 | \li XB360: Yes
|
---|
| 117 | */
|
---|
| 118 | NX_INLINE bool NX_CALL_CONV NxSegmentOBBIntersect(const NxVec3& p0, const NxVec3& p1,
|
---|
| 119 | const NxVec3& center, const NxVec3& extents, const NxMat33& rot)
|
---|
| 120 | {
|
---|
| 121 | return NxGetUtilLib()->NxSegmentOBBIntersect(p0,p1,center,extents,rot);
|
---|
| 122 | }
|
---|
| 123 |
|
---|
| 124 | /**
|
---|
| 125 | \brief Boolean segment-AABB intersection test.
|
---|
| 126 |
|
---|
| 127 | Based on separating axis theorem.
|
---|
| 128 |
|
---|
| 129 | \warning #NxCreatePhysicsSDK() must be called before using this function.
|
---|
| 130 |
|
---|
| 131 | \param[in] p0 First point of line segment. <b>Range:</b> position vector
|
---|
| 132 | \param[in] p1 Second point of line segment. <b>Range:</b> position vector
|
---|
| 133 | \param[in] min Minimum extent of AABB. <b>Range:</b> position vector
|
---|
| 134 | \param[in] max Maximum extent of AABB. <b>Range:</b> position vector
|
---|
| 135 |
|
---|
| 136 | \return True if the segment and AABB intersect.
|
---|
| 137 |
|
---|
| 138 | <b>Platform:</b>
|
---|
| 139 | \li PC SW: Yes
|
---|
| 140 | \li PPU : Yes
|
---|
| 141 | \li PS3 : Yes
|
---|
| 142 | \li XB360: Yes
|
---|
| 143 | */
|
---|
| 144 | NX_INLINE bool NX_CALL_CONV NxSegmentAABBIntersect(const NxVec3& p0, const NxVec3& p1,
|
---|
| 145 | const NxVec3& min, const NxVec3& max)
|
---|
| 146 | {
|
---|
| 147 | return NxGetUtilLib()->NxSegmentAABBIntersect(p0,p1,min,max);
|
---|
| 148 | }
|
---|
| 149 |
|
---|
| 150 | /**
|
---|
| 151 | \brief Boolean ray-OBB intersection test.
|
---|
| 152 |
|
---|
| 153 | Based on separating axis theorem.
|
---|
| 154 |
|
---|
| 155 | \warning #NxCreatePhysicsSDK() must be called before using this function.
|
---|
| 156 |
|
---|
| 157 | \param[in] ray Ray to test against OBB. <b>Range:</b> See #NxRay
|
---|
| 158 | \param[in] center Centre pointy of OBB. <b>Range:</b> position vector
|
---|
| 159 | \param[in] extents Extent/Radii of the OBB. <b>Range:</b> direction vector
|
---|
| 160 | \param[in] rot Rotation of the OBB(applied before translation). <b>Range:</b> rotation matrix
|
---|
| 161 |
|
---|
| 162 | \return True on intersection.
|
---|
| 163 |
|
---|
| 164 | <b>Platform:</b>
|
---|
| 165 | \li PC SW: Yes
|
---|
| 166 | \li PPU : Yes
|
---|
| 167 | \li PS3 : Yes
|
---|
| 168 | \li XB360: Yes
|
---|
| 169 | */
|
---|
| 170 | NX_INLINE bool NX_CALL_CONV NxRayOBBIntersect(const NxRay& ray, const NxVec3& center,
|
---|
| 171 | const NxVec3& extents, const NxMat33& rot)
|
---|
| 172 | {
|
---|
| 173 | return NxGetUtilLib()->NxRayOBBIntersect(ray,center,extents,rot);
|
---|
| 174 | }
|
---|
| 175 | //}
|
---|
| 176 |
|
---|
| 177 | /** @} */
|
---|
| 178 | #endif
|
---|
| 179 |
|
---|
| 180 |
|
---|
| 181 | //AGCOPYRIGHTBEGIN
|
---|
| 182 | ///////////////////////////////////////////////////////////////////////////
|
---|
| 183 | // Copyright © 2005 AGEIA Technologies.
|
---|
| 184 | // All rights reserved. www.ageia.com
|
---|
| 185 | ///////////////////////////////////////////////////////////////////////////
|
---|
| 186 | //AGCOPYRIGHTEND
|
---|
| 187 |
|
---|