PxBoxController.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_BOX_CONTROLLER
32 #define PX_PHYSICS_CCT_BOX_CONTROLLER
33 
39 
40 #if !PX_DOXYGEN
41 namespace physx
42 {
43 #endif
44 
51 {
52 public:
58 
63 
68 
72  PX_INLINE virtual void setToDefault();
73 
79  PX_INLINE virtual bool isValid() const;
80 
86  PxF32 halfHeight; // Half-height in the "up" direction
87 
93  PxF32 halfSideExtent; // Half-extent in the "side" direction
94 
100  PxF32 halfForwardExtent; // Half-extent in the "forward" direction
101 
102 protected:
103  PX_INLINE void copy(const PxBoxControllerDesc&);
104 };
105 
108  halfHeight (1.0f),
109  halfSideExtent (0.5f),
110  halfForwardExtent (0.5f)
111 {
112 }
113 
115 {
116  copy(other);
117 }
118 
120 {
122  copy(other);
123  return *this;
124 }
125 
127 {
128  halfHeight = other.halfHeight;
131 }
132 
134 {
135  *this = PxBoxControllerDesc();
136 }
137 
139 {
140  if(!PxControllerDesc::isValid()) return false;
141  if(halfHeight<=0.0f) return false;
142  if(halfSideExtent<=0.0f) return false;
143  if(halfForwardExtent<=0.0f) return false;
144  if(stepOffset>2.0f*halfHeight) return false; // Prevents obvious mistakes
145  return true;
146 }
147 
154 {
155 public:
156 
164  virtual PxF32 getHalfHeight() const = 0;
165 
173  virtual PxF32 getHalfSideExtent() const = 0;
174 
182  virtual PxF32 getHalfForwardExtent() const = 0;
183 
194  virtual bool setHalfHeight(PxF32 halfHeight) = 0;
195 
206  virtual bool setHalfSideExtent(PxF32 halfSideExtent) = 0;
207 
218  virtual bool setHalfForwardExtent(PxF32 halfForwardExtent) = 0;
219 
220 protected:
222  virtual ~PxBoxController() {}
223 };
224 
225 #if !PX_DOXYGEN
226 } // namespace physx
227 #endif
228 
230 #endif
PX_INLINE PxBoxControllerDesc & operator=(const PxBoxControllerDesc &)
assignment operator.
Definition: PxBoxController.h:119
Definition: GuContactBuffer.h:37
PX_INLINE PxBoxController()
Definition: PxBoxController.h:221
float PxF32
Definition: PxSimpleTypes.h:76
virtual PxF32 getHalfHeight() const =0
Gets controller&#39;s half height.
PX_INLINE void copy(const PxBoxControllerDesc &)
Definition: PxBoxController.h:126
virtual PX_INLINE bool isValid() const
returns true if the current settings are valid
Definition: PxController.h:601
PxF32 halfHeight
Half height.
Definition: PxBoxController.h:86
virtual bool setHalfHeight(PxF32 halfHeight)=0
Sets controller&#39;s half height.
PxF32 stepOffset
Defines the maximum height of an obstacle which the character can climb.
Definition: PxController.h:421
PxF32 halfForwardExtent
Half forward extent.
Definition: PxBoxController.h:100
virtual PX_INLINE bool isValid() const
returns true if the current settings are valid
Definition: PxBoxController.h:138
Descriptor for a box character controller.
Definition: PxBoxController.h:50
Box character controller.
Definition: PxBoxController.h:153
Base class for character controllers.
Definition: PxController.h:623
PX_INLINE PxControllerDesc & operator=(const PxControllerDesc &)
assignment operator.
Definition: PxController.h:569
virtual ~PxBoxController()
Definition: PxBoxController.h:222
virtual bool setHalfSideExtent(PxF32 halfSideExtent)=0
Sets controller&#39;s half side extent.
virtual PX_INLINE void setToDefault()
(re)sets the structure to the default.
Definition: PxBoxController.h:133
The type of controller, eg box, sphere or capsule.
Definition: PxController.h:52
virtual PX_INLINE ~PxBoxControllerDesc()
Definition: PxBoxController.h:57
PxF32 halfSideExtent
Half side extent.
Definition: PxBoxController.h:93
virtual PxF32 getHalfForwardExtent() const =0
Gets controller&#39;s half forward extent.
virtual bool setHalfForwardExtent(PxF32 halfForwardExtent)=0
Sets controller&#39;s half forward extent.
Descriptor class for a character controller.
Definition: PxController.h:304
PX_INLINE PxBoxControllerDesc()
constructor sets to default.
Definition: PxBoxController.h:106
#define PX_INLINE
Definition: PxPreprocessor.h:349
virtual PxF32 getHalfSideExtent() const =0
Gets controller&#39;s half side extent.