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-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_BOX_CONTROLLER
32 #define PX_PHYSICS_CCT_BOX_CONTROLLER
33 
38 
39 #if !PX_DOXYGEN
40 namespace physx
41 {
42 #endif
43 
50 {
51 public:
57 
62 
67 
71  PX_INLINE virtual void setToDefault();
72 
78  PX_INLINE virtual bool isValid() const;
79 
85  PxF32 halfHeight; // Half-height in the "up" direction
86 
92  PxF32 halfSideExtent; // Half-extent in the "side" direction
93 
99  PxF32 halfForwardExtent; // Half-extent in the "forward" direction
100 
101 protected:
102  PX_INLINE void copy(const PxBoxControllerDesc&);
103 };
104 
107  halfHeight (1.0f),
108  halfSideExtent (0.5f),
109  halfForwardExtent (0.5f)
110 {
111 }
112 
114 {
115  copy(other);
116 }
117 
119 {
121  copy(other);
122  return *this;
123 }
124 
126 {
127  halfHeight = other.halfHeight;
130 }
131 
133 {
134  *this = PxBoxControllerDesc();
135 }
136 
138 {
139  if(!PxControllerDesc::isValid()) return false;
140  if(halfHeight<=0.0f) return false;
141  if(halfSideExtent<=0.0f) return false;
142  if(halfForwardExtent<=0.0f) return false;
143  if(stepOffset>2.0f*halfHeight) return false; // Prevents obvious mistakes
144  return true;
145 }
146 
153 {
154 public:
155 
163  virtual PxF32 getHalfHeight() const = 0;
164 
172  virtual PxF32 getHalfSideExtent() const = 0;
173 
181  virtual PxF32 getHalfForwardExtent() const = 0;
182 
193  virtual bool setHalfHeight(PxF32 halfHeight) = 0;
194 
205  virtual bool setHalfSideExtent(PxF32 halfSideExtent) = 0;
206 
217  virtual bool setHalfForwardExtent(PxF32 halfForwardExtent) = 0;
218 
219 protected:
221  virtual ~PxBoxController() {}
222 };
223 
224 #if !PX_DOXYGEN
225 } // namespace physx
226 #endif
227 
229 #endif
PX_INLINE PxBoxControllerDesc & operator=(const PxBoxControllerDesc &)
assignment operator.
Definition: PxBoxController.h:118
Definition: GuContactBuffer.h:37
PX_INLINE PxBoxController()
Definition: PxBoxController.h:220
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:125
virtual PX_INLINE bool isValid() const
returns true if the current settings are valid
Definition: PxController.h:597
PxF32 halfHeight
Half height.
Definition: PxBoxController.h:85
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:417
PxF32 halfForwardExtent
Half forward extent.
Definition: PxBoxController.h:99
virtual PX_INLINE bool isValid() const
returns true if the current settings are valid
Definition: PxBoxController.h:137
Descriptor for a box character controller.
Definition: PxBoxController.h:49
Box character controller.
Definition: PxBoxController.h:152
Base class for character controllers.
Definition: PxController.h:628
PX_INLINE PxControllerDesc & operator=(const PxControllerDesc &)
assignment operator.
Definition: PxController.h:565
virtual ~PxBoxController()
Definition: PxBoxController.h:221
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:132
The type of controller, eg box, sphere or capsule.
Definition: PxController.h:49
virtual PX_INLINE ~PxBoxControllerDesc()
Definition: PxBoxController.h:56
PxF32 halfSideExtent
Half side extent.
Definition: PxBoxController.h:92
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:300
PX_INLINE PxBoxControllerDesc()
constructor sets to default.
Definition: PxBoxController.h:105
#define PX_INLINE
Definition: PxPreprocessor.h:336
virtual PxF32 getHalfSideExtent() const =0
Gets controller&#39;s half side extent.