| 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_ACTOR | 
| 32 | #define PX_PHYSICS_NX_ACTOR | 
| 33 |  | 
| 34 | /** \addtogroup physics | 
| 35 |   @{ | 
| 36 | */ | 
| 37 |  | 
| 38 | #include "PxPhysXConfig.h" | 
| 39 | #include "foundation/PxBounds3.h" | 
| 40 | #include "PxClient.h" | 
| 41 | #include "common/PxBase.h" | 
| 42 |  | 
| 43 | #if !PX_DOXYGEN | 
| 44 | namespace physx | 
| 45 | { | 
| 46 | #endif | 
| 47 |  | 
| 48 | class PxRigidActor; | 
| 49 | class PxRigidBody; | 
| 50 | class PxRigidStatic; | 
| 51 | class PxRigidDynamic; | 
| 52 | class PxArticulation; | 
| 53 | class PxArticulationLink; | 
| 54 |  | 
| 55 |  | 
| 56 | /** Group index which allows to specify 1- or 2-way interaction */ | 
| 57 | typedef PxU8 PxDominanceGroup;		// Must be < 32, PxU8. | 
| 58 |  | 
| 59 | /** | 
| 60 | \brief Flags which control the behavior of an actor. | 
| 61 |  | 
| 62 | @see PxActorFlags PxActor PxActor.setActorFlag() PxActor.getActorFlags() | 
| 63 | */ | 
| 64 | struct PxActorFlag | 
| 65 | { | 
| 66 | 	enum Enum | 
| 67 | 	{ | 
| 68 | 		/** | 
| 69 | 		\brief Enable debug renderer for this actor | 
| 70 |  | 
| 71 | 		@see PxScene.getRenderBuffer() PxRenderBuffer PxVisualizationParameter | 
| 72 | 		*/ | 
| 73 | 		eVISUALIZATION					= (1<<0), | 
| 74 |  | 
| 75 | 		/** | 
| 76 | 		\brief Disables scene gravity for this actor | 
| 77 | 		*/ | 
| 78 | 		eDISABLE_GRAVITY				= (1<<1), | 
| 79 |  | 
| 80 | 		/** | 
| 81 | 		\brief Enables the sending of PxSimulationEventCallback::onWake() and PxSimulationEventCallback::onSleep() notify events | 
| 82 |  | 
| 83 | 		@see PxSimulationEventCallback::onWake() PxSimulationEventCallback::onSleep() | 
| 84 | 		*/ | 
| 85 | 		eSEND_SLEEP_NOTIFIES			= (1<<2), | 
| 86 |  | 
| 87 | 		/** | 
| 88 | 		\brief Disables simulation for the actor. | 
| 89 | 		 | 
| 90 | 		\note This is only supported by PxRigidStatic and PxRigidDynamic actors and can be used to reduce the memory footprint when rigid actors are | 
| 91 | 		used for scene queries only. | 
| 92 |  | 
| 93 | 		\note Setting this flag will remove all constraints attached to the actor from the scene. | 
| 94 |  | 
| 95 | 		\note If this flag is set, the following calls are forbidden: | 
| 96 | 		\li PxRigidBody: setLinearVelocity(), setAngularVelocity(), addForce(), addTorque(), clearForce(), clearTorque() | 
| 97 | 		\li PxRigidDynamic: setKinematicTarget(), setWakeCounter(), wakeUp(), putToSleep() | 
| 98 |  | 
| 99 | 		\par <b>Sleeping:</b> | 
| 100 | 		Raising this flag will set all velocities and the wake counter to 0, clear all forces, clear the kinematic target, put the actor | 
| 101 | 		to sleep and wake up all touching actors from the previous frame. | 
| 102 | 		*/ | 
| 103 | 		eDISABLE_SIMULATION				= (1<<3) | 
| 104 | 	}; | 
| 105 | }; | 
| 106 |  | 
| 107 | /** | 
| 108 | \brief collection of set bits defined in PxActorFlag. | 
| 109 |  | 
| 110 | @see PxActorFlag | 
| 111 | */ | 
| 112 | typedef PxFlags<PxActorFlag::Enum,PxU8> PxActorFlags; | 
| 113 | PX_FLAGS_OPERATORS(PxActorFlag::Enum,PxU8) | 
| 114 |  | 
| 115 | /** | 
| 116 | \brief Identifies each type of actor. | 
| 117 | @see PxActor  | 
| 118 | */ | 
| 119 | struct PxActorType | 
| 120 | { | 
| 121 | 	enum Enum | 
| 122 | 	{ | 
| 123 | 		/** | 
| 124 | 		\brief A static rigid body | 
| 125 | 		@see PxRigidStatic | 
| 126 | 		*/ | 
| 127 | 		eRIGID_STATIC, | 
| 128 |  | 
| 129 | 		/** | 
| 130 | 		\brief A dynamic rigid body | 
| 131 | 		@see PxRigidDynamic | 
| 132 | 		*/ | 
| 133 | 		eRIGID_DYNAMIC, | 
| 134 | 		 | 
| 135 | 		/** | 
| 136 | 		\brief An articulation link | 
| 137 | 		@see PxArticulationLink | 
| 138 | 		*/ | 
| 139 | 		eARTICULATION_LINK, | 
| 140 |  | 
| 141 | 		//brief internal use only! | 
| 142 | 		eACTOR_COUNT, | 
| 143 |  | 
| 144 | 		eACTOR_FORCE_DWORD = 0x7fffffff | 
| 145 | 	}; | 
| 146 | }; | 
| 147 |  | 
| 148 | /** | 
| 149 | \brief PxActor is the base class for the main simulation objects in the physics SDK. | 
| 150 |  | 
| 151 | The actor is owned by and contained in a PxScene. | 
| 152 |  | 
| 153 | */ | 
| 154 | class PxActor : public PxBase | 
| 155 | { | 
| 156 | public: | 
| 157 | 	/** | 
| 158 | 	\brief Deletes the actor. | 
| 159 | 	 | 
| 160 | 	Do not keep a reference to the deleted instance. | 
| 161 |  | 
| 162 | 	If the actor belongs to a #PxAggregate object, it is automatically removed from the aggregate. | 
| 163 |  | 
| 164 | 	@see PxBase.release(), PxAggregate | 
| 165 | 	*/ | 
| 166 | 	virtual		void			release() = 0; | 
| 167 |  | 
| 168 | 	/** | 
| 169 | 	\brief Retrieves the type of actor. | 
| 170 |  | 
| 171 | 	\return The actor type of the actor. | 
| 172 |  | 
| 173 | 	@see PxActorType | 
| 174 | 	*/ | 
| 175 | 	virtual		PxActorType::Enum	getType()	const = 0; | 
| 176 |  | 
| 177 | 	/** | 
| 178 | 	\brief Retrieves the scene which this actor belongs to. | 
| 179 |  | 
| 180 | 	\return Owner Scene. NULL if not part of a scene. | 
| 181 |  | 
| 182 | 	@see PxScene | 
| 183 | 	*/ | 
| 184 | 	virtual		PxScene*		getScene()	const = 0; | 
| 185 |  | 
| 186 | 	// Runtime modifications | 
| 187 |  | 
| 188 | 	/** | 
| 189 | 	\brief Sets a name string for the object that can be retrieved with getName(). | 
| 190 | 	 | 
| 191 | 	This is for debugging and is not used by the SDK. The string is not copied by the SDK,  | 
| 192 | 	only the pointer is stored. | 
| 193 |  | 
| 194 | 	\param[in] name String to set the objects name to. | 
| 195 |  | 
| 196 | 	<b>Default:</b> NULL | 
| 197 |  | 
| 198 | 	@see getName() | 
| 199 | 	*/ | 
| 200 | 	virtual		void			setName(const char* name)		= 0; | 
| 201 |  | 
| 202 | 	/** | 
| 203 | 	\brief Retrieves the name string set with setName(). | 
| 204 |  | 
| 205 | 	\return Name string associated with object. | 
| 206 |  | 
| 207 | 	@see setName() | 
| 208 | 	*/ | 
| 209 | 	virtual		const char*		getName()			const	= 0; | 
| 210 |  | 
| 211 | 	/** | 
| 212 | 	\brief Retrieves the axis aligned bounding box enclosing the actor. | 
| 213 |  | 
| 214 | 	\param[in] inflation  Scale factor for computed world bounds. Box extents are multiplied by this value. | 
| 215 |  | 
| 216 | 	\return The actor's bounding box. | 
| 217 |  | 
| 218 | 	@see PxBounds3 | 
| 219 | 	*/ | 
| 220 | 	virtual		PxBounds3		getWorldBounds(float inflation=1.01f) const = 0; | 
| 221 |  | 
| 222 | 	/** | 
| 223 | 	\brief Raises or clears a particular actor flag. | 
| 224 | 	 | 
| 225 | 	See the list of flags #PxActorFlag | 
| 226 |  | 
| 227 | 	<b>Sleeping:</b> Does <b>NOT</b> wake the actor up automatically. | 
| 228 |  | 
| 229 | 	\param[in] flag  The PxActor flag to raise(set) or clear. See #PxActorFlag. | 
| 230 | 	\param[in] value The boolean value to assign to the flag. | 
| 231 |  | 
| 232 | 	<b>Default:</b> PxActorFlag::eVISUALIZATION | 
| 233 |  | 
| 234 | 	@see PxActorFlag getActorFlags()  | 
| 235 | 	*/ | 
| 236 | 	virtual		void			setActorFlag(PxActorFlag::Enum flag, bool value) = 0; | 
| 237 | 	/** | 
| 238 | 	\brief sets the actor flags | 
| 239 | 	 | 
| 240 | 	See the list of flags #PxActorFlag | 
| 241 | 	@see PxActorFlag setActorFlag()  | 
| 242 | 	*/ | 
| 243 | 	virtual		void			setActorFlags( PxActorFlags inFlags ) = 0; | 
| 244 |  | 
| 245 | 	/** | 
| 246 | 	\brief Reads the PxActor flags. | 
| 247 | 	 | 
| 248 | 	See the list of flags #PxActorFlag | 
| 249 |  | 
| 250 | 	\return The values of the PxActor flags. | 
| 251 |  | 
| 252 | 	@see PxActorFlag setActorFlag()  | 
| 253 | 	*/ | 
| 254 | 	virtual		PxActorFlags	getActorFlags()	const = 0; | 
| 255 |  | 
| 256 | 	/** | 
| 257 | 	\brief Assigns dynamic actors a dominance group identifier. | 
| 258 | 	 | 
| 259 | 	PxDominanceGroup is a 5 bit group identifier (legal range from 0 to 31). | 
| 260 | 	 | 
| 261 | 	The PxScene::setDominanceGroupPair() lets you set certain behaviors for pairs of dominance groups. | 
| 262 | 	By default every dynamic actor is created in group 0. | 
| 263 |  | 
| 264 | 	<b>Default:</b> 0 | 
| 265 |  | 
| 266 | 	<b>Sleeping:</b> Changing the dominance group does <b>NOT</b> wake the actor up automatically. | 
| 267 |  | 
| 268 | 	\param[in] dominanceGroup The dominance group identifier. <b>Range:</b> [0..31] | 
| 269 |  | 
| 270 | 	@see getDominanceGroup() PxDominanceGroup PxScene::setDominanceGroupPair() | 
| 271 | 	*/ | 
| 272 | 	virtual		void			setDominanceGroup(PxDominanceGroup dominanceGroup)		 = 0; | 
| 273 | 	 | 
| 274 | 	/** | 
| 275 | 	\brief Retrieves the value set with setDominanceGroup(). | 
| 276 |  | 
| 277 | 	\return The dominance group of this actor. | 
| 278 |  | 
| 279 | 	@see setDominanceGroup() PxDominanceGroup PxScene::setDominanceGroupPair() | 
| 280 | 	*/ | 
| 281 | 	virtual		PxDominanceGroup	getDominanceGroup() const = 0; | 
| 282 |  | 
| 283 | 	 | 
| 284 | 	/** | 
| 285 | 	\brief Sets the owner client of an actor. | 
| 286 |  | 
| 287 | 	This cannot be done once the actor has been placed into a scene. | 
| 288 |  | 
| 289 | 	<b>Default:</b> PX_DEFAULT_CLIENT | 
| 290 |  | 
| 291 | 	@see PxClientID PxScene::createClient()  | 
| 292 | 	*/ | 
| 293 | 	virtual		void			setOwnerClient( PxClientID inClient ) = 0; | 
| 294 |  | 
| 295 | 	/** | 
| 296 | 	\brief Returns the owner client that was specified with at creation time. | 
| 297 |  | 
| 298 | 	This value cannot be changed once the object is placed into the scene. | 
| 299 |  | 
| 300 | 	@see PxClientID PxScene::createClient() | 
| 301 | 	*/ | 
| 302 | 	virtual		PxClientID		getOwnerClient() const = 0; | 
| 303 |  | 
| 304 | 	/** | 
| 305 | 	\brief Retrieves the aggregate the actor might be a part of. | 
| 306 |  | 
| 307 | 	\return The aggregate the actor is a part of, or NULL if the actor does not belong to an aggregate. | 
| 308 |  | 
| 309 | 	@see PxAggregate | 
| 310 | 	*/ | 
| 311 | 	virtual		PxAggregate*	getAggregate()	const = 0; | 
| 312 |  | 
| 313 | 	//public variables: | 
| 314 | 				void*			userData;	//!< user can assign this to whatever, usually to create a 1:1 relationship with a user object. | 
| 315 |  | 
| 316 | protected: | 
| 317 | 	PX_INLINE					PxActor(PxType concreteType, PxBaseFlags baseFlags) : PxBase(concreteType, baseFlags), userData(NULL) {} | 
| 318 | 	PX_INLINE					PxActor(PxBaseFlags baseFlags) : PxBase(baseFlags) {} | 
| 319 | 	virtual						~PxActor()	{} | 
| 320 | 	virtual		bool			isKindOf(const char* name)	const		{	return !::strcmp(s1: "PxActor" , s2: name) || PxBase::isKindOf(superClass: name); } | 
| 321 |  | 
| 322 |  | 
| 323 | }; | 
| 324 |  | 
| 325 | #if !PX_DOXYGEN | 
| 326 | } // namespace physx | 
| 327 | #endif | 
| 328 |  | 
| 329 | /** @} */ | 
| 330 | #endif | 
| 331 |  |