RavEngine
Loading...
Searching...
No Matches
PxBoxController.h
1// Redistribution and use in source and binary forms, with or without
2// modification, are permitted provided that the following conditions
3// are met:
4// * Redistributions of source code must retain the above copyright
5// notice, this list of conditions and the following disclaimer.
6// * Redistributions in binary form must reproduce the above copyright
7// notice, this list of conditions and the following disclaimer in the
8// documentation and/or other materials provided with the distribution.
9// * Neither the name of NVIDIA CORPORATION nor the names of its
10// contributors may be used to endorse or promote products derived
11// from this software without specific prior written permission.
12//
13// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
14// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24//
25// Copyright (c) 2008-2022 NVIDIA Corporation. All rights reserved.
26// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
27// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
28
29#ifndef PX_BOX_CONTROLLER_H
30#define PX_BOX_CONTROLLER_H
35#include "characterkinematic/PxController.h"
36
37#if !PX_DOXYGEN
38namespace physx
39{
40#endif
41
48{
49public:
55
60
65
69 PX_INLINE virtual void setToDefault();
70
76 PX_INLINE virtual bool isValid() const;
77
83 PxF32 halfHeight; // Half-height in the "up" direction
84
90 PxF32 halfSideExtent; // Half-extent in the "side" direction
91
97 PxF32 halfForwardExtent; // Half-extent in the "forward" direction
98
99protected:
100 PX_INLINE void copy(const PxBoxControllerDesc&);
101};
102
105 halfHeight (1.0f),
106 halfSideExtent (0.5f),
107 halfForwardExtent (0.5f)
108{
109}
110
115
117{
119 copy(other);
120 return *this;
121}
122
123PX_INLINE void PxBoxControllerDesc::copy(const PxBoxControllerDesc& other)
124{
125 halfHeight = other.halfHeight;
128}
129
134
136{
137 if(!PxControllerDesc::isValid()) return false;
138 if(halfHeight<=0.0f) return false;
139 if(halfSideExtent<=0.0f) return false;
140 if(halfForwardExtent<=0.0f) return false;
141 if(stepOffset>2.0f*halfHeight) return false; // Prevents obvious mistakes
142 return true;
143}
144
151{
152public:
153
161 virtual PxF32 getHalfHeight() const = 0;
162
170 virtual PxF32 getHalfSideExtent() const = 0;
171
179 virtual PxF32 getHalfForwardExtent() const = 0;
180
191 virtual bool setHalfHeight(PxF32 halfHeight) = 0;
192
203 virtual bool setHalfSideExtent(PxF32 halfSideExtent) = 0;
204
215 virtual bool setHalfForwardExtent(PxF32 halfForwardExtent) = 0;
216
217protected:
219 virtual ~PxBoxController() {}
220};
221
222#if !PX_DOXYGEN
223} // namespace physx
224#endif
225
227#endif
Descriptor for a box character controller.
Definition PxBoxController.h:48
virtual PX_INLINE void setToDefault()
(re)sets the structure to the default.
Definition PxBoxController.h:130
PX_INLINE PxBoxControllerDesc()
constructor sets to default.
Definition PxBoxController.h:103
virtual PX_INLINE bool isValid() const
returns true if the current settings are valid
Definition PxBoxController.h:135
PxF32 halfSideExtent
Half side extent.
Definition PxBoxController.h:90
PX_INLINE PxBoxControllerDesc & operator=(const PxBoxControllerDesc &)
assignment operator.
Definition PxBoxController.h:116
PxF32 halfHeight
Half height.
Definition PxBoxController.h:83
PxF32 halfForwardExtent
Half forward extent.
Definition PxBoxController.h:97
Box character controller.
Definition PxBoxController.h:151
virtual PxF32 getHalfHeight() const =0
Gets controller's half height.
virtual bool setHalfHeight(PxF32 halfHeight)=0
Sets controller's half height.
virtual bool setHalfForwardExtent(PxF32 halfForwardExtent)=0
Sets controller's half forward extent.
virtual PxF32 getHalfForwardExtent() const =0
Gets controller's half forward extent.
virtual PxF32 getHalfSideExtent() const =0
Gets controller's half side extent.
virtual bool setHalfSideExtent(PxF32 halfSideExtent)=0
Sets controller's half side extent.
Descriptor class for a character controller.
Definition PxController.h:300
virtual PX_INLINE bool isValid() const
returns true if the current settings are valid
Definition PxController.h:606
PX_INLINE PxControllerDesc & operator=(const PxControllerDesc &)
assignment operator.
Definition PxController.h:573
PxF32 stepOffset
Defines the maximum height of an obstacle which the character can climb.
Definition PxController.h:416
Base class for character controllers.
Definition PxController.h:638
#define PX_INLINE
Definition PxPreprocessor.h:320
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
The type of controller, eg box, sphere or capsule.
Definition PxController.h:49