[1378] | 1 | #ifndef NX_INTERSECTION_BOX_BOX
|
---|
| 2 | #define NX_INTERSECTION_BOX_BOX
|
---|
| 3 |
|
---|
| 4 | /*----------------------------------------------------------------------------*\
|
---|
| 5 | |
|
---|
| 6 | | NovodeX Technology
|
---|
| 7 | |
|
---|
| 8 | | www.novodex.com
|
---|
| 9 | |
|
---|
| 10 | \*----------------------------------------------------------------------------*/
|
---|
| 11 | /** \addtogroup physics
|
---|
| 12 | @{
|
---|
| 13 | */
|
---|
| 14 |
|
---|
| 15 | #include "Nxp.h"
|
---|
| 16 | #include "NxBox.h"
|
---|
| 17 | #include "PhysXLoader.h"
|
---|
| 18 |
|
---|
| 19 | /**
|
---|
| 20 | \brief Boolean intersection test between two OBBs.
|
---|
| 21 |
|
---|
| 22 | Uses the separating axis theorem. Disabling 'full_test' only performs 6 axis tests out of 15.
|
---|
| 23 |
|
---|
| 24 | \param[in] extents0 Extents/radii of first box before transformation. <b>Range:</b> direction vector
|
---|
| 25 | \param[in] center0 Centre of first box. <b>Range:</b> position vector
|
---|
| 26 | \param[in] rotation0 Rotatation to apply to first box (before translation). <b>Range:</b> rotation matrix
|
---|
| 27 | \param[in] extents1 Extents/radii of second box before transformation <b>Range:</b> direction vector
|
---|
| 28 | \param[in] center1 Centre of second box. <b>Range:</b> position vector
|
---|
| 29 | \param[in] rotation1 Rotatation to apply to second box(before translation). <b>Range:</b> rotation matrix
|
---|
| 30 | \param[in] fullTest If false test only the first 6 axis.
|
---|
| 31 |
|
---|
| 32 | \return true on intersection
|
---|
| 33 |
|
---|
| 34 | <b>Platform:</b>
|
---|
| 35 | \li PC SW: Yes
|
---|
| 36 | \li PPU : Yes
|
---|
| 37 | \li PS3 : Yes
|
---|
| 38 | \li XB360: Yes
|
---|
| 39 | */
|
---|
| 40 | NX_INLINE bool NX_CALL_CONV NxBoxBoxIntersect( const NxVec3& extents0, const NxVec3& center0, const NxMat33& rotation0,
|
---|
| 41 | const NxVec3& extents1, const NxVec3& center1, const NxMat33& rotation1,
|
---|
| 42 | bool fullTest)
|
---|
| 43 | {
|
---|
| 44 | return NxGetUtilLib()->NxBoxBoxIntersect(extents0,center0,rotation0,extents1,center1,rotation1,fullTest);
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | /**
|
---|
| 48 | \brief Boolean intersection test between two OBBs.
|
---|
| 49 |
|
---|
| 50 | Uses the separating axis theorem. Disabling 'full_test' only performs 6 axis tests out of 15.
|
---|
| 51 |
|
---|
| 52 | \param[in] obb0 First Oriented Bounding Box. <b>Range:</b> See #NxBox
|
---|
| 53 | \param[in] obb1 Second Oriented Bounding Box. <b>Range:</b> See #NxBox
|
---|
| 54 | \param[in] fullTest If false test only the first 6 axis.
|
---|
| 55 |
|
---|
| 56 | \return true on intersection
|
---|
| 57 |
|
---|
| 58 | <b>Platform:</b>
|
---|
| 59 | \li PC SW: Yes
|
---|
| 60 | \li PPU : Yes
|
---|
| 61 | \li PS3 : Yes
|
---|
| 62 | \li XB360: Yes
|
---|
| 63 |
|
---|
| 64 | @see NxBox
|
---|
| 65 | */
|
---|
| 66 | NX_INLINE bool NxBoxBoxIntersect(const NxBox& obb0, const NxBox& obb1, bool fullTest=true)
|
---|
| 67 | {
|
---|
| 68 | return NxBoxBoxIntersect(
|
---|
| 69 | obb0.extents, obb0.center, obb0.rot,
|
---|
| 70 | obb1.extents, obb1.center, obb1.rot,
|
---|
| 71 | fullTest);
|
---|
| 72 | }
|
---|
| 73 |
|
---|
| 74 | /*
|
---|
| 75 | \brief Boolean intersection test between a triangle and an AABB.
|
---|
| 76 |
|
---|
| 77 | \param[in] vertex0 First vertex of triangle. <b>Range:</b> position vector
|
---|
| 78 | \param[in] vertex1 Second Vertex of triangle. <b>Range:</b> position vector
|
---|
| 79 | \param[in] vertex2 Third Vertex of triangle. <b>Range:</b> position vector
|
---|
| 80 | \param[in] center Centre of Axis Aligned bounding box. <b>Range:</b> position vector
|
---|
| 81 | \param[in] extents Extents/radii of AABB. <b>Range:</b> direction vector
|
---|
| 82 |
|
---|
| 83 | \return true on intersection.
|
---|
| 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 bool NX_CALL_CONV NxTriBoxIntersect(const NxVec3 & vertex0, const NxVec3 & vertex1, const NxVec3 & vertex2, const NxVec3 & center, const NxVec3& extents)
|
---|
| 92 | {
|
---|
| 93 | return NxGetUtilLib()->NxTriBoxIntersect(vertex0,vertex1,vertex2,center,extents);
|
---|
| 94 |
|
---|
| 95 | }
|
---|
| 96 |
|
---|
| 97 |
|
---|
| 98 | /**
|
---|
| 99 | \brief Computes the separating axis between two OBBs.
|
---|
| 100 |
|
---|
| 101 | \param[in] extents0 Extents/radii of first box before transformation. <b>Range:</b> direction vector
|
---|
| 102 | \param[in] center0 Centre of box first box. <b>Range:</b> position vector
|
---|
| 103 | \param[in] rotation0 Rotatation to apply to first box (before translation). <b>Range:</b> rotation matrix
|
---|
| 104 | \param[in] extents1 Extents/radii of second box before transformation. <b>Range:</b> direction vector
|
---|
| 105 | \param[in] center1 Centre of second box. <b>Range:</b> position vector
|
---|
| 106 | \param[in] rotation1 Rotatation to apply to second box (before translation). <b>Range:</b> rotation matrix
|
---|
| 107 | \param[in] fullTest If false test only the first 6 axis.
|
---|
| 108 |
|
---|
| 109 | \return The separating axis or NX_SEP_AXIS_OVERLAP for an overlap.
|
---|
| 110 |
|
---|
| 111 | <b>Platform:</b>
|
---|
| 112 | \li PC SW: Yes
|
---|
| 113 | \li PPU : Yes
|
---|
| 114 | \li PS3 : Yes
|
---|
| 115 | \li XB360: Yes
|
---|
| 116 |
|
---|
| 117 | @see NxSepAxis
|
---|
| 118 | */
|
---|
| 119 | NX_INLINE NxSepAxis NX_CALL_CONV NxSeparatingAxis( const NxVec3& extents0, const NxVec3& center0, const NxMat33& rotation0,
|
---|
| 120 | const NxVec3& extents1, const NxVec3& center1, const NxMat33& rotation1,
|
---|
| 121 | bool fullTest=true)
|
---|
| 122 | {
|
---|
| 123 | return NxGetUtilLib()->NxSeparatingAxis(extents0,center0,rotation0,extents1,center1,rotation1,fullTest);
|
---|
| 124 | }
|
---|
| 125 |
|
---|
| 126 | /**
|
---|
| 127 | \brief Computes the separating axis between two OBBs.
|
---|
| 128 |
|
---|
| 129 | \param[in] obb0 First Oriented Bounding box. <b>Range:</b> See #NxBox
|
---|
| 130 | \param[in] obb1 Second Oriented Bounding box. <b>Range:</b> See #NxBox
|
---|
| 131 | \param[in] fullTest If false test only the first 6 axis.
|
---|
| 132 |
|
---|
| 133 | \return The separating axis.
|
---|
| 134 |
|
---|
| 135 | <b>Platform:</b>
|
---|
| 136 | \li PC SW: Yes
|
---|
| 137 | \li PPU : Yes
|
---|
| 138 | \li PS3 : Yes
|
---|
| 139 | \li XB360: Yes
|
---|
| 140 |
|
---|
| 141 | @see NxSepAxis
|
---|
| 142 | */
|
---|
| 143 | NX_INLINE NxSepAxis NxSeparatingAxis(const NxBox& obb0, const NxBox& obb1, bool fullTest=true)
|
---|
| 144 | {
|
---|
| 145 | return NxSeparatingAxis(
|
---|
| 146 | obb0.extents, obb0.center, obb0.rot,
|
---|
| 147 | obb1.extents, obb1.center, obb1.rot,
|
---|
| 148 | fullTest);
|
---|
| 149 | }
|
---|
| 150 |
|
---|
| 151 | /** @} */
|
---|
| 152 | #endif
|
---|
| 153 |
|
---|
| 154 |
|
---|
| 155 | //AGCOPYRIGHTBEGIN
|
---|
| 156 | ///////////////////////////////////////////////////////////////////////////
|
---|
| 157 | // Copyright © 2005 AGEIA Technologies.
|
---|
| 158 | // All rights reserved. www.ageia.com
|
---|
| 159 | ///////////////////////////////////////////////////////////////////////////
|
---|
| 160 | //AGCOPYRIGHTEND
|
---|
| 161 |
|
---|