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-2018 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 
39 
40 #if !PX_DOXYGEN
41 namespace physx
42 {
43 #endif
44 
46 {
47  enum Enum
48  {
51 
52  eLAST
53  };
54 };
55 
62 {
63 public:
69 
74 
79 
83  PX_INLINE virtual void setToDefault();
89  PX_INLINE virtual bool isValid() const;
90 
99 
108 
117 
118 protected:
119  PX_INLINE void copy(const PxCapsuleControllerDesc&);
120 };
121 
123 {
124  radius = height = 0.0f;
126 }
127 
129 {
130  copy(other);
131 }
132 
134 {
136  copy(other);
137  return *this;
138 }
139 
141 {
142  radius = other.radius;
143  height = other.height;
144  climbingMode = other.climbingMode;
145 }
146 
148 {
149  *this = PxCapsuleControllerDesc();
150 }
151 
153 {
154  if(!PxControllerDesc::isValid()) return false;
155  if(radius<=0.0f) return false;
156  if(height<=0.0f) return false;
157  if(stepOffset>height+radius*2.0f) return false; // Prevents obvious mistakes
158  return true;
159 }
178 {
179 public:
180 
188  virtual PxF32 getRadius() const = 0;
189 
200  virtual bool setRadius(PxF32 radius) = 0;
201 
209  virtual PxF32 getHeight() const = 0;
210 
221  virtual bool setHeight(PxF32 height) = 0;
222 
230  virtual PxCapsuleClimbingMode::Enum getClimbingMode() const = 0;
231 
239  virtual bool setClimbingMode(PxCapsuleClimbingMode::Enum mode) = 0;
240 
241 protected:
243  virtual ~PxCapsuleController() {}
244 };
245 
246 #if !PX_DOXYGEN
247 } // namespace physx
248 #endif
249 
251 #endif
Definition: GuContactBuffer.h:37
Standard mode, let the capsule climb over surfaces according to impact normal.
Definition: PxCapsuleController.h:49
virtual PxCapsuleClimbingMode::Enum getClimbingMode() const =0
Gets controller&#39;s climbing mode.
PX_INLINE PxCapsuleController()
Definition: PxCapsuleController.h:242
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:601
virtual bool setClimbingMode(PxCapsuleClimbingMode::Enum mode)=0
Sets controller&#39;s climbing mode.
virtual ~PxCapsuleController()
Definition: PxCapsuleController.h:243
PxF32 stepOffset
Defines the maximum height of an obstacle which the character can climb.
Definition: PxController.h:421
virtual bool setRadius(PxF32 radius)=0
Sets controller&#39;s radius.
PxCapsuleClimbingMode::Enum climbingMode
The climbing mode.
Definition: PxCapsuleController.h:116
PxF32 height
The height of the controller.
Definition: PxCapsuleController.h:107
Definition: PxCapsuleController.h:45
virtual PxF32 getHeight() const =0
Gets controller&#39;s height.
virtual PX_INLINE ~PxCapsuleControllerDesc()
Definition: PxCapsuleController.h:68
virtual bool setHeight(PxF32 height)=0
Resets controller&#39;s height.
Base class for character controllers.
Definition: PxController.h:623
PX_INLINE PxControllerDesc & operator=(const PxControllerDesc &)
assignment operator.
Definition: PxController.h:569
A capsule character controller.
Definition: PxCapsuleController.h:177
PX_INLINE void copy(const PxCapsuleControllerDesc &)
Definition: PxCapsuleController.h:140
PX_INLINE PxCapsuleControllerDesc()
constructor sets to default.
Definition: PxCapsuleController.h:122
The type of controller, eg box, sphere or capsule.
Definition: PxController.h:52
Constrained mode, try to limit climbing according to the step offset.
Definition: PxCapsuleController.h:50
PX_INLINE PxCapsuleControllerDesc & operator=(const PxCapsuleControllerDesc &)
assignment operator.
Definition: PxCapsuleController.h:133
virtual PX_INLINE bool isValid() const
returns true if the current settings are valid
Definition: PxCapsuleController.h:152
A descriptor for a capsule character controller.
Definition: PxCapsuleController.h:61
Descriptor class for a character controller.
Definition: PxController.h:304
virtual PX_INLINE void setToDefault()
(re)sets the structure to the default.
Definition: PxCapsuleController.h:147
PxF32 radius
The radius of the capsule.
Definition: PxCapsuleController.h:98
#define PX_INLINE
Definition: PxPreprocessor.h:349
Enum
Definition: PxCapsuleController.h:47