1/*
2 * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
3 *
4 * NVIDIA CORPORATION and its licensors retain all intellectual property
5 * and proprietary rights in and to this software, related documentation
6 * and any modifications thereto. Any use, reproduction, disclosure or
7 * distribution of this software and related documentation without an express
8 * license agreement from NVIDIA CORPORATION is strictly prohibited.
9 */
10// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
11// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
12
13
14#ifndef PX_PHYSICS_CCT_BOX_CONTROLLER
15#define PX_PHYSICS_CCT_BOX_CONTROLLER
16/** \addtogroup character
17 @{
18*/
19
20#include "characterkinematic/PxCharacter.h"
21#include "characterkinematic/PxController.h"
22
23#ifndef PX_DOXYGEN
24namespace physx
25{
26#endif
27
28/**
29\brief Descriptor for a box character controller.
30
31@see PxBoxController PxControllerDesc
32*/
33class PxBoxControllerDesc : public PxControllerDesc
34{
35public:
36 /**
37 \brief constructor sets to default.
38 */
39 PX_INLINE PxBoxControllerDesc();
40 PX_INLINE virtual ~PxBoxControllerDesc() {}
41
42 /**
43 \brief copy constructor.
44 */
45 PX_INLINE PxBoxControllerDesc(const PxBoxControllerDesc&);
46
47 /**
48 \brief assignment operator.
49 */
50 PX_INLINE PxBoxControllerDesc& operator=(const PxBoxControllerDesc&);
51
52 /**
53 \brief (re)sets the structure to the default.
54 */
55 PX_INLINE virtual void setToDefault();
56
57 /**
58 \brief returns true if the current settings are valid
59
60 \return True if the descriptor is valid.
61 */
62 PX_INLINE virtual bool isValid() const;
63
64 /**
65 \brief Half height
66
67 <b>Default:</b> 1.0
68 */
69 PxF32 halfHeight; // Half-height in the "up" direction
70
71 /**
72 \brief Half side extent
73
74 <b>Default:</b> 0.5
75 */
76 PxF32 halfSideExtent; // Half-extent in the "side" direction
77
78 /**
79 \brief Half forward extent
80
81 <b>Default:</b> 0.5
82 */
83 PxF32 halfForwardExtent; // Half-extent in the "forward" direction
84
85protected:
86 PX_INLINE void copy(const PxBoxControllerDesc&);
87};
88
89PX_INLINE PxBoxControllerDesc::PxBoxControllerDesc() :
90 PxControllerDesc (PxControllerShapeType::eBOX),
91 halfHeight (1.0f),
92 halfSideExtent (0.5f),
93 halfForwardExtent (0.5f)
94{
95}
96
97PX_INLINE PxBoxControllerDesc::PxBoxControllerDesc(const PxBoxControllerDesc& other) : PxControllerDesc(other)
98{
99 copy(other);
100}
101
102PX_INLINE PxBoxControllerDesc& PxBoxControllerDesc::operator=(const PxBoxControllerDesc& other)
103{
104 PxControllerDesc::operator=(other);
105 copy(other);
106 return *this;
107}
108
109PX_INLINE void PxBoxControllerDesc::copy(const PxBoxControllerDesc& other)
110{
111 halfHeight = other.halfHeight;
112 halfSideExtent = other.halfSideExtent;
113 halfForwardExtent = other.halfForwardExtent;
114}
115
116PX_INLINE void PxBoxControllerDesc::setToDefault()
117{
118 *this = PxBoxControllerDesc();
119}
120
121PX_INLINE bool PxBoxControllerDesc::isValid() const
122{
123 if(!PxControllerDesc::isValid()) return false;
124 if(halfHeight<=0.0f) return false;
125 if(halfSideExtent<=0.0f) return false;
126 if(halfForwardExtent<=0.0f) return false;
127 if(stepOffset>2.0f*halfHeight) return false; // Prevents obvious mistakes
128 return true;
129}
130
131/**
132\brief Box character controller.
133
134@see PxBoxControllerDesc PxController
135*/
136class PxBoxController : public PxController
137{
138public:
139
140 /**
141 \brief Gets controller's half height.
142
143 \return The half height of the controller.
144
145 @see PxBoxControllerDesc.halfHeight setHalfHeight()
146 */
147 virtual PxF32 getHalfHeight() const = 0;
148
149 /**
150 \brief Gets controller's half side extent.
151
152 \return The half side extent of the controller.
153
154 @see PxBoxControllerDesc.halfSideExtent setHalfSideExtent()
155 */
156 virtual PxF32 getHalfSideExtent() const = 0;
157
158 /**
159 \brief Gets controller's half forward extent.
160
161 \return The half forward extent of the controller.
162
163 @see PxBoxControllerDesc.halfForwardExtent setHalfForwardExtent()
164 */
165 virtual PxF32 getHalfForwardExtent() const = 0;
166
167 /**
168 \brief Sets controller's half height.
169
170 \warning this doesn't check for collisions.
171
172 \param[in] halfHeight The new half height for the controller.
173 \return Currently always true.
174
175 @see PxBoxControllerDesc.halfHeight getHalfHeight()
176 */
177 virtual bool setHalfHeight(PxF32 halfHeight) = 0;
178
179 /**
180 \brief Sets controller's half side extent.
181
182 \warning this doesn't check for collisions.
183
184 \param[in] halfSideExtent The new half side extent for the controller.
185 \return Currently always true.
186
187 @see PxBoxControllerDesc.halfSideExtent getHalfSideExtent()
188 */
189 virtual bool setHalfSideExtent(PxF32 halfSideExtent) = 0;
190
191 /**
192 \brief Sets controller's half forward extent.
193
194 \warning this doesn't check for collisions.
195
196 \param[in] halfForwardExtent The new half forward extent for the controller.
197 \return Currently always true.
198
199 @see PxBoxControllerDesc.halfForwardExtent getHalfForwardExtent()
200 */
201 virtual bool setHalfForwardExtent(PxF32 halfForwardExtent) = 0;
202
203protected:
204 PX_INLINE PxBoxController() {}
205 virtual ~PxBoxController() {}
206};
207
208#ifndef PX_DOXYGEN
209} // namespace physx
210#endif
211
212/** @} */
213#endif
214