PxCapsuleController.h
Go to the documentation of this file.
1 //
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions
4 // are met:
5 // * Redistributions of source code must retain the above copyright
6 // notice, this list of conditions and the following disclaimer.
7 // * Redistributions in binary form must reproduce the above copyright
8 // notice, this list of conditions and the following disclaimer in the
9 // documentation and/or other materials provided with the distribution.
10 // * Neither the name of NVIDIA CORPORATION nor the names of its
11 // contributors may be used to endorse or promote products derived
12 // from this software without specific prior written permission.
13 //
14 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
15 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 //
26 // Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
27 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
28 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
29 
30 
31 #ifndef PX_PHYSICS_CCT_CAPSULE_CONTROLLER
32 #define PX_PHYSICS_CCT_CAPSULE_CONTROLLER
33 
38 
39 #if !PX_DOXYGEN
40 namespace physx
41 {
42 #endif
43 
45 {
46  enum Enum
47  {
50 
51  eLAST
52  };
53 };
54 
61 {
62 public:
68 
73 
78 
82  PX_INLINE virtual void setToDefault();
88  PX_INLINE virtual bool isValid() const;
89 
98 
107 
116 
117 protected:
118  PX_INLINE void copy(const PxCapsuleControllerDesc&);
119 };
120 
122 {
123  radius = height = 0.0f;
125 }
126 
128 {
129  copy(other);
130 }
131 
133 {
135  copy(other);
136  return *this;
137 }
138 
140 {
141  radius = other.radius;
142  height = other.height;
143  climbingMode = other.climbingMode;
144 }
145 
147 {
148  *this = PxCapsuleControllerDesc();
149 }
150 
152 {
153  if(!PxControllerDesc::isValid()) return false;
154  if(radius<=0.0f) return false;
155  if(height<=0.0f) return false;
156  if(stepOffset>height+radius*2.0f) return false; // Prevents obvious mistakes
157  return true;
158 }
177 {
178 public:
179 
187  virtual PxF32 getRadius() const = 0;
188 
199  virtual bool setRadius(PxF32 radius) = 0;
200 
208  virtual PxF32 getHeight() const = 0;
209 
220  virtual bool setHeight(PxF32 height) = 0;
221 
229  virtual PxCapsuleClimbingMode::Enum getClimbingMode() const = 0;
230 
238  virtual bool setClimbingMode(PxCapsuleClimbingMode::Enum mode) = 0;
239 
240 protected:
242  virtual ~PxCapsuleController() {}
243 };
244 
245 #if !PX_DOXYGEN
246 } // namespace physx
247 #endif
248 
250 #endif
Definition: GuContactBuffer.h:37
Standard mode, let the capsule climb over surfaces according to impact normal.
Definition: PxCapsuleController.h:48
virtual PxCapsuleClimbingMode::Enum getClimbingMode() const =0
Gets controller&#39;s climbing mode.
PX_INLINE PxCapsuleController()
Definition: PxCapsuleController.h:241
float PxF32
Definition: PxSimpleTypes.h:76
virtual PxF32 getRadius() const =0
Gets controller&#39;s radius.
virtual PX_INLINE bool isValid() const
returns true if the current settings are valid
Definition: PxController.h:597
virtual bool setClimbingMode(PxCapsuleClimbingMode::Enum mode)=0
Sets controller&#39;s climbing mode.
virtual ~PxCapsuleController()
Definition: PxCapsuleController.h:242
PxF32 stepOffset
Defines the maximum height of an obstacle which the character can climb.
Definition: PxController.h:417
virtual bool setRadius(PxF32 radius)=0
Sets controller&#39;s radius.
PxCapsuleClimbingMode::Enum climbingMode
The climbing mode.
Definition: PxCapsuleController.h:115
PxF32 height
The height of the controller.
Definition: PxCapsuleController.h:106
Definition: PxCapsuleController.h:44
virtual PxF32 getHeight() const =0
Gets controller&#39;s height.
virtual PX_INLINE ~PxCapsuleControllerDesc()
Definition: PxCapsuleController.h:67
virtual bool setHeight(PxF32 height)=0
Resets controller&#39;s height.
Base class for character controllers.
Definition: PxController.h:628
PX_INLINE PxControllerDesc & operator=(const PxControllerDesc &)
assignment operator.
Definition: PxController.h:565
A capsule character controller.
Definition: PxCapsuleController.h:176
PX_INLINE void copy(const PxCapsuleControllerDesc &)
Definition: PxCapsuleController.h:139
PX_INLINE PxCapsuleControllerDesc()
constructor sets to default.
Definition: PxCapsuleController.h:121
The type of controller, eg box, sphere or capsule.
Definition: PxController.h:49
Constrained mode, try to limit climbing according to the step offset.
Definition: PxCapsuleController.h:49
PX_INLINE PxCapsuleControllerDesc & operator=(const PxCapsuleControllerDesc &)
assignment operator.
Definition: PxCapsuleController.h:132
virtual PX_INLINE bool isValid() const
returns true if the current settings are valid
Definition: PxCapsuleController.h:151
A descriptor for a capsule character controller.
Definition: PxCapsuleController.h:60
Descriptor class for a character controller.
Definition: PxController.h:300
virtual PX_INLINE void setToDefault()
(re)sets the structure to the default.
Definition: PxCapsuleController.h:146
PxF32 radius
The radius of the capsule.
Definition: PxCapsuleController.h:97
#define PX_INLINE
Definition: PxPreprocessor.h:336
Enum
Definition: PxCapsuleController.h:46