| 1 | /* |
| 2 | * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved. |
| 3 | * |
| 4 | * NVIDIA CORPORATION and its licensors retain all intellectual property |
| 5 | * and proprietary rights in and to this software, related documentation |
| 6 | * and any modifications thereto. Any use, reproduction, disclosure or |
| 7 | * distribution of this software and related documentation without an express |
| 8 | * license agreement from NVIDIA CORPORATION is strictly prohibited. |
| 9 | */ |
| 10 | // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. |
| 11 | // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. |
| 12 | |
| 13 | #ifndef PX_PHYSICS_CCT_OBSTACLES |
| 14 | #define PX_PHYSICS_CCT_OBSTACLES |
| 15 | /** \addtogroup character |
| 16 | @{ |
| 17 | */ |
| 18 | |
| 19 | #include "characterkinematic/PxCharacter.h" |
| 20 | #include "characterkinematic/PxExtended.h" |
| 21 | #include "geometry/PxGeometry.h" |
| 22 | |
| 23 | #ifndef PX_DOXYGEN |
| 24 | namespace physx |
| 25 | { |
| 26 | #endif |
| 27 | |
| 28 | class PxControllerManager; |
| 29 | |
| 30 | #define INVALID_OBSTACLE_HANDLE 0xffffffff |
| 31 | |
| 32 | /** |
| 33 | \brief Base class for obstacles. |
| 34 | |
| 35 | @see PxBoxObstacle PxCapsuleObstacle PxObstacleContext |
| 36 | */ |
| 37 | class PxObstacle |
| 38 | { |
| 39 | protected: |
| 40 | PxObstacle() : |
| 41 | mType (PxGeometryType::eINVALID), |
| 42 | mUserData (NULL), |
| 43 | mPos (0.0, 0.0, 0.0), |
| 44 | mRot (PxQuat(PxIdentity)) |
| 45 | {} |
| 46 | ~PxObstacle() {} |
| 47 | |
| 48 | PxGeometryType::Enum mType; |
| 49 | public: |
| 50 | |
| 51 | PX_FORCE_INLINE PxGeometryType::Enum getType() const { return mType; } |
| 52 | |
| 53 | void* mUserData; |
| 54 | PxExtendedVec3 mPos; |
| 55 | PxQuat mRot; |
| 56 | }; |
| 57 | |
| 58 | /** |
| 59 | \brief A box obstacle. |
| 60 | |
| 61 | @see PxObstacle PxCapsuleObstacle PxObstacleContext |
| 62 | */ |
| 63 | class PxBoxObstacle : public PxObstacle |
| 64 | { |
| 65 | public: |
| 66 | PxBoxObstacle() : |
| 67 | mHalfExtents(0.0f) |
| 68 | { mType = PxGeometryType::eBOX; } |
| 69 | ~PxBoxObstacle() {} |
| 70 | |
| 71 | PxVec3 mHalfExtents; |
| 72 | }; |
| 73 | |
| 74 | /** |
| 75 | \brief A capsule obstacle. |
| 76 | |
| 77 | @see PxBoxObstacle PxObstacle PxObstacleContext |
| 78 | */ |
| 79 | class PxCapsuleObstacle : public PxObstacle |
| 80 | { |
| 81 | public: |
| 82 | PxCapsuleObstacle() : |
| 83 | mHalfHeight (0.0f), |
| 84 | mRadius (0.0f) |
| 85 | { mType = PxGeometryType::eCAPSULE; } |
| 86 | ~PxCapsuleObstacle() {} |
| 87 | |
| 88 | PxReal mHalfHeight; |
| 89 | PxReal mRadius; |
| 90 | }; |
| 91 | |
| 92 | typedef PxU32 ObstacleHandle; |
| 93 | |
| 94 | /** |
| 95 | \brief Context class for obstacles. |
| 96 | |
| 97 | An obstacle context class contains and manages a set of user-defined obstacles. |
| 98 | |
| 99 | @see PxBoxObstacle PxCapsuleObstacle PxObstacle |
| 100 | */ |
| 101 | class PxObstacleContext |
| 102 | { |
| 103 | public: |
| 104 | PxObstacleContext() {} |
| 105 | virtual ~PxObstacleContext() {} |
| 106 | |
| 107 | /** |
| 108 | \brief Releases the context. |
| 109 | */ |
| 110 | virtual void release() = 0; |
| 111 | |
| 112 | /** |
| 113 | \brief Retrieves the controller manager associated with this context. |
| 114 | |
| 115 | \return The associated controller manager |
| 116 | */ |
| 117 | virtual PxControllerManager& getControllerManager() const = 0; |
| 118 | |
| 119 | /** |
| 120 | \brief Adds an obstacle to the context. |
| 121 | |
| 122 | \param [in] obstacle Obstacle data for the new obstacle. The data gets copied. |
| 123 | |
| 124 | \return Handle for newly-added obstacle |
| 125 | */ |
| 126 | virtual ObstacleHandle addObstacle(const PxObstacle& obstacle) = 0; |
| 127 | |
| 128 | /** |
| 129 | \brief Removes an obstacle from the context. |
| 130 | |
| 131 | \param [in] handle Handle for the obstacle object that needs to be removed. |
| 132 | |
| 133 | \return True if success |
| 134 | */ |
| 135 | virtual bool removeObstacle(ObstacleHandle handle) = 0; |
| 136 | |
| 137 | /** |
| 138 | \brief Updates data for an existing obstacle. |
| 139 | |
| 140 | \param [in] handle Handle for the obstacle object that needs to be updated. |
| 141 | \param [in] obstacle New obstacle data |
| 142 | |
| 143 | \return True if success |
| 144 | */ |
| 145 | virtual bool updateObstacle(ObstacleHandle handle, const PxObstacle& obstacle) = 0; |
| 146 | |
| 147 | /** |
| 148 | \brief Retrieves number of obstacles in the context. |
| 149 | |
| 150 | \return Number of obstacles in the context |
| 151 | */ |
| 152 | virtual PxU32 getNbObstacles() const = 0; |
| 153 | |
| 154 | /** |
| 155 | \brief Retrieves desired obstacle. |
| 156 | |
| 157 | \param [in] i Obstacle index |
| 158 | |
| 159 | \return Desired obstacle |
| 160 | */ |
| 161 | virtual const PxObstacle* getObstacle(PxU32 i) const = 0; |
| 162 | |
| 163 | /** |
| 164 | \brief Retrieves desired obstacle by given handle. |
| 165 | |
| 166 | \param [in] handle Obstacle handle |
| 167 | |
| 168 | \return Desired obstacle |
| 169 | */ |
| 170 | virtual const PxObstacle* getObstacleByHandle(ObstacleHandle handle) const = 0; |
| 171 | }; |
| 172 | |
| 173 | #ifndef PX_DOXYGEN |
| 174 | } |
| 175 | #endif |
| 176 | |
| 177 | /** @} */ |
| 178 | #endif |
| 179 | |