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_NX_RIGIDACTOR
32#define PX_PHYSICS_NX_RIGIDACTOR
33/** \addtogroup physics
34@{
35*/
36
37#include "PxActor.h"
38#include "PxShape.h"
39
40#if !PX_DOXYGEN
41namespace physx
42{
43#endif
44
45class PxConstraint;
46class PxMaterial;
47class PxGeometry;
48class PxBVHStructure;
49
50/**
51\brief PxRigidActor represents a base class shared between dynamic and static rigid bodies in the physics SDK.
52
53PxRigidActor objects specify the geometry of the object by defining a set of attached shapes (see #PxShape).
54
55@see PxActor
56*/
57
58class PxRigidActor : public PxActor
59{
60public:
61 /**
62 \brief Deletes the rigid actor object.
63
64 Also releases any shapes associated with the actor.
65
66 Releasing an actor will affect any objects that are connected to the actor (constraint shaders like joints etc.).
67 Such connected objects will be deleted upon scene deletion, or explicitly by the user by calling release()
68 on these objects. It is recommended to always remove all objects that reference actors before the actors
69 themselves are removed. It is not possible to retrieve list of dead connected objects.
70
71 <b>Sleeping:</b> This call will awaken any sleeping actors contacting the deleted actor (directly or indirectly).
72
73 Calls #PxActor::release() so you might want to check the documentation of that method as well.
74
75 @see PxActor::release()
76 */
77 virtual void release() = 0;
78
79
80/************************************************************************************************/
81/** @name Global Pose Manipulation
82*/
83
84 /**
85 \brief Retrieves the actors world space transform.
86
87 The getGlobalPose() method retrieves the actor's current actor space to world space transformation.
88
89 \return Global pose of object.
90
91 @see PxRigidDynamic.setGlobalPose() PxRigidStatic.setGlobalPose()
92 */
93 virtual PxTransform getGlobalPose() const = 0;
94
95 /**
96 \brief Method for setting an actor's pose in the world.
97
98 This method instantaneously changes the actor space to world space transformation.
99
100 This method is mainly for dynamic rigid bodies (see #PxRigidDynamic). Calling this method on static actors is
101 likely to result in a performance penalty, since internal optimization structures for static actors may need to be
102 recomputed. In addition, moving static actors will not interact correctly with dynamic actors or joints.
103
104 To directly control an actor's position and have it correctly interact with dynamic bodies and joints, create a dynamic
105 body with the PxRigidBodyFlag::eKINEMATIC flag, then use the setKinematicTarget() commands to define its path.
106
107 Even when moving dynamic actors, exercise restraint in making use of this method. Where possible, avoid:
108
109 \li moving actors into other actors, thus causing overlap (an invalid physical state)
110
111 \li moving an actor that is connected by a joint to another away from the other (thus causing joint error)
112
113 <b>Sleeping:</b> This call wakes dynamic actors if they are sleeping and the autowake parameter is true (default).
114
115 \param[in] pose Transformation from the actors local frame to the global frame. <b>Range:</b> rigid body transform.
116 \param[in] autowake whether to wake the object if it is dynamic. This parameter has no effect for static or kinematic actors. If true and the current wake counter value is smaller than #PxSceneDesc::wakeCounterResetValue it will get increased to the reset value.
117
118 @see getGlobalPose()
119 */
120 virtual void setGlobalPose(const PxTransform& pose, bool autowake = true) = 0;
121
122
123/************************************************************************************************/
124/** @name Shapes
125*/
126
127 /** attach a shared shape to an actor
128
129 This call will increment the reference count of the shape.
130
131 \note Mass properties of dynamic rigid actors will not automatically be recomputed
132 to reflect the new mass distribution implied by the shape. Follow this call with a call to
133 the PhysX extensions method #PxRigidBodyExt::updateMassAndInertia() to do that.
134
135 Attaching a triangle mesh, heightfield or plane geometry shape configured as eSIMULATION_SHAPE is not supported for
136 non-kinematic PxRigidDynamic instances.
137
138
139 <b>Sleeping:</b> Does <b>NOT</b> wake the actor up automatically.
140
141 \param[in] shape the shape to attach.
142
143 \return True if success.
144 */
145 virtual bool attachShape(PxShape& shape) = 0;
146
147
148 /** detach a shape from an actor.
149
150 This will also decrement the reference count of the PxShape, and if the reference count is zero, will cause it to be deleted.
151
152 <b>Sleeping:</b> Does <b>NOT</b> wake the actor up automatically.
153
154 \param[in] shape the shape to detach.
155 \param[in] wakeOnLostTouch Specifies whether touching objects from the previous frame should get woken up in the next frame. Only applies to PxArticulation and PxRigidActor types.
156
157 */
158 virtual void detachShape(PxShape& shape, bool wakeOnLostTouch = true) = 0;
159
160
161 /**
162 \brief Returns the number of shapes assigned to the actor.
163
164 You can use #getShapes() to retrieve the shape pointers.
165
166 \return Number of shapes associated with this actor.
167
168 @see PxShape getShapes()
169 */
170 virtual PxU32 getNbShapes() const = 0;
171
172
173 /**
174 \brief Retrieve all the shape pointers belonging to the actor.
175
176 These are the shapes used by the actor for collision detection.
177
178 You can retrieve the number of shape pointers by calling #getNbShapes()
179
180 Note: Removing shapes with #PxShape::release() will invalidate the pointer of the released shape.
181
182 \param[out] userBuffer The buffer to store the shape pointers.
183 \param[in] bufferSize Size of provided user buffer.
184 \param[in] startIndex Index of first shape pointer to be retrieved
185 \return Number of shape pointers written to the buffer.
186
187 @see PxShape getNbShapes() PxShape::release()
188 */
189 virtual PxU32 getShapes(PxShape** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
190
191
192/************************************************************************************************/
193/** @name Constraints
194*/
195
196 /**
197 \brief Returns the number of constraint shaders attached to the actor.
198
199 You can use #getConstraints() to retrieve the constraint shader pointers.
200
201 \return Number of constraint shaders attached to this actor.
202
203 @see PxConstraint getConstraints()
204 */
205 virtual PxU32 getNbConstraints() const = 0;
206
207
208 /**
209 \brief Retrieve all the constraint shader pointers belonging to the actor.
210
211 You can retrieve the number of constraint shader pointers by calling #getNbConstraints()
212
213 Note: Removing constraint shaders with #PxConstraint::release() will invalidate the pointer of the released constraint.
214
215 \param[out] userBuffer The buffer to store the constraint shader pointers.
216 \param[in] bufferSize Size of provided user buffer.
217 \param[in] startIndex Index of first constraint pointer to be retrieved
218 \return Number of constraint shader pointers written to the buffer.
219
220 @see PxConstraint getNbConstraints() PxConstraint::release()
221 */
222 virtual PxU32 getConstraints(PxConstraint** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
223
224protected:
225 PX_INLINE PxRigidActor(PxType concreteType, PxBaseFlags baseFlags) : PxActor(concreteType, baseFlags) {}
226 PX_INLINE PxRigidActor(PxBaseFlags baseFlags) : PxActor(baseFlags) {}
227 virtual ~PxRigidActor() {}
228 virtual bool isKindOf(const char* name) const { return !::strcmp(s1: "PxRigidActor", s2: name) || PxActor::isKindOf(name); }
229};
230
231
232#if !PX_DOXYGEN
233} // namespace physx
234#endif
235
236/** @} */
237#endif
238

source code of qtquick3dphysics/src/3rdparty/PhysX/include/PxRigidActor.h