| 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 | #ifndef PX_VEHICLE_DRIVE_H | 
| 31 | #define PX_VEHICLE_DRIVE_H | 
| 32 | /** \addtogroup vehicle | 
| 33 |   @{ | 
| 34 | */ | 
| 35 |  | 
| 36 | #include "vehicle/PxVehicleWheels.h" | 
| 37 | #include "vehicle/PxVehicleComponents.h" | 
| 38 |  | 
| 39 | #if !PX_DOXYGEN | 
| 40 | namespace physx | 
| 41 | { | 
| 42 | #endif | 
| 43 |  | 
| 44 | struct PxFilterData; | 
| 45 | class PxGeometry; | 
| 46 | class PxPhysics; | 
| 47 | class PxVehicleDrivableSurfaceToTireFrictionPairs; | 
| 48 | class PxShape; | 
| 49 | class PxMaterial; | 
| 50 | class PxRigidDynamic; | 
| 51 |  | 
| 52 | /** | 
| 53 | \brief Data structure describing non-wheel configuration data of a vehicle that has engine, gears, clutch, and auto-box. | 
| 54 | @see PxVehicleWheelsSimData for wheels configuration data. | 
| 55 | */ | 
| 56 | class PxVehicleDriveSimData | 
| 57 | { | 
| 58 | //= ATTENTION! ===================================================================================== | 
| 59 | // Changing the data layout of this class breaks the binary serialization format.  See comments for  | 
| 60 | // PX_BINARY_SERIAL_VERSION.  If a modification is required, please adjust the getBinaryMetaData  | 
| 61 | // function.  If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION | 
| 62 | // accordingly. | 
| 63 | //================================================================================================== | 
| 64 | public: | 
| 65 |  | 
| 66 | 	friend class PxVehicleDriveTank; | 
| 67 |  | 
| 68 | 	/** | 
| 69 | 	\brief Return the engine data | 
| 70 | 	*/ | 
| 71 | 	PX_FORCE_INLINE const PxVehicleEngineData& getEngineData() const  | 
| 72 | 	{ | 
| 73 | 		return mEngine; | 
| 74 | 	} | 
| 75 | 	 | 
| 76 | 	/** | 
| 77 | 	\brief Set the engine data | 
| 78 | 	\param[in] engine - the data stored in engine is copied to the vehicle's engine. | 
| 79 | 	*/ | 
| 80 | 	void setEngineData(const PxVehicleEngineData& engine); | 
| 81 |  | 
| 82 | 	/** | 
| 83 | 	\brief Return the gears data | 
| 84 | 	*/ | 
| 85 | 	PX_FORCE_INLINE const PxVehicleGearsData& getGearsData() const  | 
| 86 | 	{ | 
| 87 | 		return mGears; | 
| 88 | 	} | 
| 89 | 	 | 
| 90 | 	/** | 
| 91 | 	\brief Set the gears data | 
| 92 | 	\param[in] gears - the data stored in gears is copied to the vehicle's gears. | 
| 93 | 	*/ | 
| 94 | 	void setGearsData(const PxVehicleGearsData& gears); | 
| 95 |  | 
| 96 | 	/** | 
| 97 | 	\brief Return the clutch data | 
| 98 | 	*/ | 
| 99 | 	PX_FORCE_INLINE const PxVehicleClutchData& getClutchData() const  | 
| 100 | 	{ | 
| 101 | 		return mClutch; | 
| 102 | 	} | 
| 103 | 	 | 
| 104 | 	/** | 
| 105 | 	\brief Set the clutch data | 
| 106 | 	\param[in] clutch - the data stored in clutch is copied to the vehicle's clutch. | 
| 107 | 	*/ | 
| 108 | 	void setClutchData(const PxVehicleClutchData& clutch); | 
| 109 |  | 
| 110 | 	/** | 
| 111 | 	\brief Return the autobox data | 
| 112 | 	*/ | 
| 113 | 	PX_FORCE_INLINE const PxVehicleAutoBoxData& getAutoBoxData() const  | 
| 114 | 	{ | 
| 115 | 		return mAutoBox; | 
| 116 | 	} | 
| 117 |  | 
| 118 | 	/** | 
| 119 | 	\brief Set the autobox data | 
| 120 | 	\param[in] autobox - the data stored in autobox is copied to the vehicle's autobox. | 
| 121 | 	*/ | 
| 122 | 	void setAutoBoxData(const PxVehicleAutoBoxData& autobox); | 
| 123 |  | 
| 124 | protected: | 
| 125 | 	/* | 
| 126 | 	\brief Engine simulation data | 
| 127 | 	@see setEngineData, getEngineData | 
| 128 | 	*/ | 
| 129 | 	PxVehicleEngineData				mEngine; | 
| 130 |  | 
| 131 | 	/* | 
| 132 | 	\brief Gear simulation data | 
| 133 | 	@see setGearsData, getGearsData | 
| 134 | 	*/ | 
| 135 | 	PxVehicleGearsData				mGears; | 
| 136 |  | 
| 137 | 	/* | 
| 138 | 	\brief Clutch simulation data | 
| 139 | 	@see setClutchData, getClutchData | 
| 140 | 	*/ | 
| 141 | 	PxVehicleClutchData				mClutch; | 
| 142 |  | 
| 143 | 	/* | 
| 144 | 	\brief Autobox simulation data | 
| 145 | 	@see setAutoboxData, getAutoboxData | 
| 146 | 	*/ | 
| 147 | 	PxVehicleAutoBoxData			mAutoBox; | 
| 148 |  | 
| 149 | 	/** | 
| 150 | 	\brief Test that a PxVehicleDriveSimData instance has been configured with legal data. | 
| 151 | 	Call only after setting all components with setEngineData,setGearsData,setClutchData,setAutoBoxData | 
| 152 | 	@see PxVehicleDrive4W::setup, PxVehicleDriveTank::setup | 
| 153 | 	*/ | 
| 154 | 	bool isValid() const; | 
| 155 |  | 
| 156 |  | 
| 157 | //serialization | 
| 158 | public: | 
| 159 | 	PxVehicleDriveSimData() {} | 
| 160 | 	PxVehicleDriveSimData(const PxEMPTY) :  mEngine(PxEmpty), mGears(PxEmpty), mClutch(PxEmpty), mAutoBox(PxEmpty) {} | 
| 161 | 	static void getBinaryMetaData(PxOutputStream& stream); | 
| 162 | //~serialization | 
| 163 | }; | 
| 164 | PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleDriveSimData) & 15)); | 
| 165 |  | 
| 166 |  | 
| 167 | /** | 
| 168 | \brief Data structure with instanced dynamics data for vehicle with engine, clutch, gears, autobox | 
| 169 | @see PxVehicleWheelsDynData for wheels dynamics data. | 
| 170 | */ | 
| 171 | class PxVehicleDriveDynData | 
| 172 | { | 
| 173 | public: | 
| 174 | 	 | 
| 175 | 	enum | 
| 176 | 	{ | 
| 177 | 		eMAX_NB_ANALOG_INPUTS=16 | 
| 178 | 	}; | 
| 179 |  | 
| 180 | 	friend class PxVehicleDrive; | 
| 181 |  | 
| 182 | 	/** | 
| 183 | 	\brief Set all dynamics data to zero to bring the vehicle to rest. | 
| 184 | 	*/ | 
| 185 | 	void setToRestState(); | 
| 186 |  | 
| 187 | 	/** | 
| 188 | 	\brief Set an analog control value to drive the vehicle. | 
| 189 | 	\param[in] type describes the type of analog control being modified | 
| 190 | 	\param[in] analogVal is the new value of the specific analog control. | 
| 191 | 	@see PxVehicleDrive4WControl, PxVehicleDriveNWControl, PxVehicleDriveTankControl | 
| 192 | 	*/ | 
| 193 | 	void setAnalogInput(const PxU32 type, const PxReal analogVal); | 
| 194 |  | 
| 195 | 	/** | 
| 196 | 	\brief Get the analog control value that has been applied to the vehicle. | 
| 197 | 	\return The value of the specified analog control value. | 
| 198 | 	@see PxVehicleDrive4WControl, PxVehicleDriveNWControl, PxVehicleDriveTankControl | 
| 199 | 	*/ | 
| 200 | 	PxReal getAnalogInput(const PxU32 type) const; | 
| 201 |  | 
| 202 | 	/** | 
| 203 | 	\brief Inform the vehicle that the gear-up button has been pressed. | 
| 204 |  | 
| 205 | 	\param[in] digitalVal is the state of the gear-up button. | 
| 206 | 	 | 
| 207 | 	\note If digitalVal is true the vehicle will attempt to initiate a gear change at the next call to PxVehicleUpdates. | 
| 208 |  | 
| 209 | 	\note The value of mGearUpPressed is not reset by PxVehicleUpdates | 
| 210 | 	*/ | 
| 211 | 	void setGearUp(const bool digitalVal)  | 
| 212 | 	{ | 
| 213 | 		mGearUpPressed = digitalVal; | 
| 214 | 	} | 
| 215 |  | 
| 216 | 	/** | 
| 217 | 	\brief Set that the gear-down button has been pressed. | 
| 218 |  | 
| 219 | 	\param[in] digitalVal is the state of the gear-down button. | 
| 220 |  | 
| 221 | 	\note If digitalVal is true the vehicle will attempt to initiate a gear change at the next call to PxVehicleUpdates. | 
| 222 |  | 
| 223 | 	\note The value of mGearDownPressed is not reset by PxVehicleUpdates | 
| 224 | 	*/ | 
| 225 | 	void setGearDown(const bool digitalVal)  | 
| 226 | 	{ | 
| 227 | 		mGearDownPressed = digitalVal; | 
| 228 | 	} | 
| 229 |  | 
| 230 | 	/** | 
| 231 | 	\brief Check if the gear-up button has been pressed | 
| 232 | 	\return The state of the gear-up button. | 
| 233 | 	*/ | 
| 234 | 	bool getGearUp() const  | 
| 235 | 	{ | 
| 236 | 		return mGearUpPressed; | 
| 237 | 	} | 
| 238 |  | 
| 239 | 	/** | 
| 240 | 	\brief Check if the gear-down button has been pressed | 
| 241 | 	\return The state of the gear-down button. | 
| 242 | 	*/ | 
| 243 | 	bool getGearDown() const  | 
| 244 | 	{ | 
| 245 | 		return mGearDownPressed; | 
| 246 | 	} | 
| 247 |  | 
| 248 | 	/** | 
| 249 | 	\brief Set the flag that will be used to select auto-gears | 
| 250 | 	If useAutoGears is true the auto-box will be active. | 
| 251 | 	\param[in] useAutoGears is the active state of the auto-box. | 
| 252 | 	*/ | 
| 253 | 	PX_FORCE_INLINE void setUseAutoGears(const bool useAutoGears) | 
| 254 | 	{ | 
| 255 | 		mUseAutoGears=useAutoGears; | 
| 256 | 	} | 
| 257 |  | 
| 258 | 	/** | 
| 259 | 	\brief Get the flag status that is used to select auto-gears | 
| 260 | 	\return The active status of the auto-box. | 
| 261 | 	*/ | 
| 262 | 	PX_FORCE_INLINE bool getUseAutoGears() const | 
| 263 | 	{ | 
| 264 | 		return mUseAutoGears; | 
| 265 | 	} | 
| 266 |  | 
| 267 | 	/** | 
| 268 | 	\brief Toggle the auto-gears flag | 
| 269 | 	If useAutoGears is true the auto-box will be active. | 
| 270 | 	*/ | 
| 271 | 	PX_FORCE_INLINE void toggleAutoGears()  | 
| 272 | 	{ | 
| 273 | 		mUseAutoGears = !mUseAutoGears; | 
| 274 | 	} | 
| 275 |  | 
| 276 | 	/** | 
| 277 | 	\brief Set the current gear. | 
| 278 |  | 
| 279 | 	\param[in] currentGear is the vehicle's gear. | 
| 280 |  | 
| 281 | 	\note If the target gear is different from the current gear the vehicle will  | 
| 282 | 	attempt to start a gear change from the current gear that has just been set  | 
| 283 | 	towards the target gear at the next call to PxVehicleUpdates. | 
| 284 |  | 
| 285 | 	@see setTargetGear, PxVehicleGearsData | 
| 286 | 	*/ | 
| 287 | 	PX_FORCE_INLINE void setCurrentGear(PxU32 currentGear)  | 
| 288 | 	{ | 
| 289 | 		mCurrentGear = currentGear; | 
| 290 | 	} | 
| 291 |  | 
| 292 | 	/** | 
| 293 | 	\brief Get the current gear. | 
| 294 |  | 
| 295 | 	\return The vehicle's current gear. | 
| 296 |  | 
| 297 | 	@see getTargetGear, PxVehicleGearsData | 
| 298 | 	*/ | 
| 299 | 	PX_FORCE_INLINE PxU32 getCurrentGear() const | 
| 300 | 	{ | 
| 301 | 		return mCurrentGear; | 
| 302 | 	} | 
| 303 |  | 
| 304 | 	/** | 
| 305 | 	\brief Set the target gear. | 
| 306 |  | 
| 307 | 	\param[in] targetGear is the vehicle's target gear. | 
| 308 |  | 
| 309 | 	\note If the target gear is different from the current gear the vehicle will  | 
| 310 | 	attempt to start a gear change towards the target gear at the next call to  | 
| 311 | 	PxVehicleUpdates. | 
| 312 |  | 
| 313 | 	@see PxVehicleGearsData | 
| 314 | 	*/ | 
| 315 | 	PX_FORCE_INLINE void setTargetGear(PxU32 targetGear)  | 
| 316 | 	{ | 
| 317 | 		mTargetGear = targetGear; | 
| 318 | 	} | 
| 319 |  | 
| 320 | 	/** | 
| 321 | 	\brief Get the target gear. | 
| 322 |  | 
| 323 | 	\return The vehicle's target gear. | 
| 324 |  | 
| 325 | 	@see setTargetGear, PxVehicleGearsData | 
| 326 | 	*/ | 
| 327 | 	PX_FORCE_INLINE PxU32 getTargetGear() const | 
| 328 | 	{ | 
| 329 | 		return mTargetGear; | 
| 330 | 	} | 
| 331 | 	 | 
| 332 | 	/** | 
| 333 | 	\brief Start a gear change to a target gear.  | 
| 334 | 	 | 
| 335 | 	\param[in] targetGear is the gear the vehicle will begin a transition towards. | 
| 336 |  | 
| 337 | 	\note The gear change will begin at the next call to PxVehicleUpadates. | 
| 338 |  | 
| 339 | 	@see PxVehicleGearsData | 
| 340 | 	*/ | 
| 341 | 	PX_FORCE_INLINE void startGearChange(const PxU32 targetGear) | 
| 342 | 	{ | 
| 343 | 		mTargetGear=targetGear; | 
| 344 | 	} | 
| 345 |  | 
| 346 | 	/** | 
| 347 | 	\brief Force an immediate gear change to a target gear | 
| 348 |  | 
| 349 | 	\param[in] targetGear is the gear the vehicle will be given immediately. | 
| 350 |  | 
| 351 | 	@see PxVehicleGearsData | 
| 352 | 	*/ | 
| 353 | 	PX_FORCE_INLINE void forceGearChange(const PxU32 targetGear) | 
| 354 | 	{ | 
| 355 | 		mTargetGear=targetGear; | 
| 356 | 		mCurrentGear=targetGear; | 
| 357 | 	} | 
| 358 |  | 
| 359 | 	/** | 
| 360 | 	\brief Set the rotation speed of the engine (radians per second) | 
| 361 |  | 
| 362 | 	\param[in] speed is the rotational speed (radians per second) to apply to the engine. | 
| 363 | 	*/ | 
| 364 | 	PX_FORCE_INLINE void setEngineRotationSpeed(const PxF32 speed) | 
| 365 | 	{ | 
| 366 | 		mEnginespeed = speed; | 
| 367 | 	} | 
| 368 |  | 
| 369 | 	/** | 
| 370 | 	\brief Return the rotation speed of the engine (radians per second) | 
| 371 |  | 
| 372 | 	\return The rotational speed (radians per second) of the engine. | 
| 373 | 	*/ | 
| 374 | 	PX_FORCE_INLINE PxReal getEngineRotationSpeed() const | 
| 375 | 	{ | 
| 376 | 		return mEnginespeed; | 
| 377 | 	} | 
| 378 |  | 
| 379 | 	/** | 
| 380 | 	\brief Return the time that has passed since the current gear change was initiated. | 
| 381 | 	 | 
| 382 | 	\return The time that has passed since the current gear change was initiated.  | 
| 383 |  | 
| 384 | 	\note If no gear change is in process the gear switch time will be zero. | 
| 385 |  | 
| 386 | 	@see PxVehicleGearsData.mSwitchTime | 
| 387 | 	*/ | 
| 388 | 	PX_FORCE_INLINE PxReal getGearSwitchTime() const | 
| 389 | 	{ | 
| 390 | 		return mGearSwitchTime; | 
| 391 | 	} | 
| 392 |  | 
| 393 | 	/** | 
| 394 | 	\brief Return the time that has passed since the autobox last initiated a gear change. | 
| 395 |  | 
| 396 | 	\return  The time that has passed since the autobox last initiated a gear change. | 
| 397 |  | 
| 398 | 	@see PxVehicleAutoBoxData::setLatency, PxVehicleAutoBoxData::getLatency | 
| 399 | 	*/ | 
| 400 | 	PX_FORCE_INLINE PxReal getAutoBoxSwitchTime() const | 
| 401 | 	{ | 
| 402 | 		return mAutoBoxSwitchTime; | 
| 403 | 	} | 
| 404 |  | 
| 405 | 	/** | 
| 406 | 	\brief All dynamic data values are public for fast access. | 
| 407 | 	*/ | 
| 408 |  | 
| 409 |  | 
| 410 | 	/** | 
| 411 | 	\brief Analog control values used by vehicle simulation.  | 
| 412 | 	@see setAnalogInput, getAnalogInput, PxVehicleDrive4WControl, PxVehicleDriveNWControl, PxVehicleDriveTankControl | 
| 413 | 	*/ | 
| 414 | 	PxReal mControlAnalogVals[eMAX_NB_ANALOG_INPUTS]; | 
| 415 |  | 
| 416 | 	/** | 
| 417 | 	\brief Auto-gear flag used by vehicle simulation.  Set true to enable the autobox, false to disable the autobox. | 
| 418 | 	@see setUseAutoGears, setUseAutoGears, toggleAutoGears, PxVehicleAutoBoxData | 
| 419 | 	*/ | 
| 420 | 	bool mUseAutoGears; | 
| 421 |  | 
| 422 | 	/** | 
| 423 | 	\brief Gear-up digital control value used by vehicle simulation.   | 
| 424 | 	 | 
| 425 | 	\note If true a gear change will be initiated towards currentGear+1 (or to first gear if in reverse). | 
| 426 |  | 
| 427 | 	@see setDigitalInput, getDigitalInput | 
| 428 | 	*/ | 
| 429 | 	bool mGearUpPressed; | 
| 430 |  | 
| 431 | 	/** | 
| 432 | 	\brief Gear-down digital control value used by vehicle simulation.   | 
| 433 | 	 | 
| 434 | 	\note If true a gear change will be initiated towards currentGear-1 (or to reverse if in first). | 
| 435 |  | 
| 436 | 	@see setDigitalInput, getDigitalInput | 
| 437 | 	*/ | 
| 438 | 	bool mGearDownPressed; | 
| 439 |  | 
| 440 | 	/** | 
| 441 | 	\brief Current gear  | 
| 442 | 	@see startGearChange, forceGearChange, getCurrentGear, PxVehicleGearsData | 
| 443 | 	*/ | 
| 444 | 	PxU32 mCurrentGear; | 
| 445 |  | 
| 446 | 	/** | 
| 447 | 	\brief Target gear (different from current gear if a gear change is underway)  | 
| 448 | 	@see startGearChange, forceGearChange, getTargetGear, PxVehicleGearsData | 
| 449 | 	*/ | 
| 450 | 	PxU32 mTargetGear; | 
| 451 |  | 
| 452 | 	/** | 
| 453 | 	\brief Rotation speed of engine | 
| 454 | 	@see setToRestState, getEngineRotationSpeed | 
| 455 | 	*/	 | 
| 456 | 	PxReal mEnginespeed; | 
| 457 |  | 
| 458 | 	/** | 
| 459 | 	\brief Reported time that has passed since gear change started. | 
| 460 | 	@see setToRestState, startGearChange, PxVehicleGearsData::mSwitchTime | 
| 461 | 	*/ | 
| 462 | 	PxReal mGearSwitchTime; | 
| 463 |  | 
| 464 | 	/** | 
| 465 | 	\brief Reported time that has passed since last autobox gearup/geardown decision. | 
| 466 | 	@see setToRestState, PxVehicleAutoBoxData::setLatency | 
| 467 | 	*/ | 
| 468 | 	PxReal mAutoBoxSwitchTime; | 
| 469 |  | 
| 470 | private: | 
| 471 | 	PxU32 mPad[2]; | 
| 472 |  | 
| 473 | 	/** | 
| 474 | 	\brief Test that a PxVehicleDriveDynData instance has legal values. | 
| 475 | 	@see setToRestState | 
| 476 | 	*/ | 
| 477 | 	bool isValid() const; | 
| 478 |  | 
| 479 | //serialization | 
| 480 | public: | 
| 481 | 	PxVehicleDriveDynData(); | 
| 482 | 	PxVehicleDriveDynData(const PxEMPTY)  {} | 
| 483 | 	PxU32 getNbAnalogInput() const { return eMAX_NB_ANALOG_INPUTS; } | 
| 484 | 	PX_FORCE_INLINE void setGearChange(const PxU32 gearChange) { mTargetGear= gearChange; } | 
| 485 | 	PX_FORCE_INLINE PxU32 getGearChange() const { return mTargetGear; } | 
| 486 | 	PX_FORCE_INLINE void setGearSwitchTime(const PxReal switchTime) { mGearSwitchTime = switchTime; } | 
| 487 | 	PX_FORCE_INLINE void setAutoBoxSwitchTime(const PxReal autoBoxSwitchTime) { mAutoBoxSwitchTime = autoBoxSwitchTime; } | 
| 488 | //~serialization | 
| 489 | }; | 
| 490 | PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleDriveDynData) & 15)); | 
| 491 |  | 
| 492 | /** | 
| 493 | \brief A complete vehicle with instance dynamics data and configuration data for wheels and engine,clutch,gears,autobox. | 
| 494 | @see PxVehicleDrive4W, PxVehicleDriveTank | 
| 495 | */ | 
| 496 | class PxVehicleDrive : public PxVehicleWheels | 
| 497 | { | 
| 498 | //= ATTENTION! ===================================================================================== | 
| 499 | // Changing the data layout of this class breaks the binary serialization format.  See comments for  | 
| 500 | // PX_BINARY_SERIAL_VERSION.  If a modification is required, please adjust the getBinaryMetaData  | 
| 501 | // function.  If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION | 
| 502 | // accordingly. | 
| 503 | //================================================================================================== | 
| 504 | public: | 
| 505 |  | 
| 506 | 	friend class PxVehicleUpdate; | 
| 507 |  | 
| 508 | 	/** | 
| 509 | 	\brief Dynamics data of vehicle instance. | 
| 510 | 	@see setup | 
| 511 | 	*/ | 
| 512 | 	PxVehicleDriveDynData mDriveDynData; | 
| 513 |  | 
| 514 | protected: | 
| 515 | 	 | 
| 516 | 	/** | 
| 517 | 	\brief Test that all instanced dynamics data and configuration data have legal values. | 
| 518 | 	*/ | 
| 519 | 	bool isValid() const; | 
| 520 |  | 
| 521 | 	/** | 
| 522 | 	\brief Set vehicle to rest. | 
| 523 | 	*/ | 
| 524 | 	void setToRestState(); | 
| 525 |  | 
| 526 | 	/** | 
| 527 | 	@see PxVehicleDrive4W::allocate, PxVehicleDriveTank::allocate | 
| 528 | 	*/ | 
| 529 | 	static PxU32 computeByteSize(const PxU32 numWheels); | 
| 530 | 	static PxU8* patchupPointers(const PxU32 nbWheels, PxVehicleDrive* vehDrive, PxU8* ptr); | 
| 531 | 	virtual void init(const PxU32 numWheels); | 
| 532 |  | 
| 533 | 	/** | 
| 534 | 	\brief Deallocate a PxVehicle4WDrive instance. | 
| 535 | 	@see PxVehicleDrive4W::free, PxVehicleDriveTank::free | 
| 536 | 	*/ | 
| 537 | 	void free(); | 
| 538 |  | 
| 539 | 	/** | 
| 540 | 	@see PxVehicleDrive4W::setup, PxVehicleDriveTank::setup | 
| 541 | 	*/ | 
| 542 | 	void setup | 
| 543 | 		(PxPhysics* physics, PxRigidDynamic* vehActor,  | 
| 544 | 		 const PxVehicleWheelsSimData& wheelsData, | 
| 545 | 		 const PxU32 nbDrivenWheels, const PxU32 nbNonDrivenWheels); | 
| 546 |  | 
| 547 | //serialization | 
| 548 | public: | 
| 549 | 	static void getBinaryMetaData(PxOutputStream& stream); | 
| 550 | 	PxVehicleDrive(PxBaseFlags baseFlags) : PxVehicleWheels(baseFlags), mDriveDynData(PxEmpty) {} | 
| 551 | 	virtual const char* getConcreteTypeName() const { return "PxVehicleDrive" ; } | 
| 552 | protected: | 
| 553 | 	PxVehicleDrive(PxType concreteType, PxBaseFlags baseFlags) : PxVehicleWheels(concreteType, baseFlags) {}	 | 
| 554 | 	~PxVehicleDrive() {} | 
| 555 | 	virtual bool isKindOf(const char* name)	const { return !::strcmp(s1: "PxVehicleDrive" , s2: name) || PxBase::isKindOf(superClass: name); } | 
| 556 | //~serialization | 
| 557 | }; | 
| 558 | PX_COMPILE_TIME_ASSERT(0==(sizeof(PxVehicleDrive) & 15)); | 
| 559 |  | 
| 560 | #if !PX_DOXYGEN | 
| 561 | } // namespace physx | 
| 562 | #endif | 
| 563 |  | 
| 564 | /** @} */ | 
| 565 | #endif //PX_VEHICLE_DRIVE_H | 
| 566 |  |