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_PHYSICS_NX_PHYSICS
31#define PX_PHYSICS_NX_PHYSICS
32
33/** \addtogroup physics
34@{
35*/
36
37#include "PxPhysXConfig.h"
38#include "PxDeletionListener.h"
39#include "foundation/PxTransform.h"
40#include "PxShape.h"
41
42#if !PX_DOXYGEN
43namespace physx
44{
45#endif
46
47class PxPvd;
48class PxPhysicsInsertionCallback;
49
50class PxRigidActor;
51class PxConstraintConnector;
52struct PxConstraintShaderTable;
53
54class PxGeometry;
55class PxFoundation;
56class PxSerializationRegistry;
57
58class PxPruningStructure;
59class PxBVHStructure;
60
61/**
62\brief Abstract singleton factory class used for instancing objects in the Physics SDK.
63
64In addition you can use PxPhysics to set global parameters which will effect all scenes and create
65objects that can be shared across multiple scenes.
66
67You can get an instance of this class by calling PxCreateBasePhysics() or PxCreatePhysics() with pre-registered modules.
68
69@see PxCreatePhysics() PxCreateBasePhysics() PxScene PxVisualizationParameter
70*/
71class PxPhysics
72{
73public:
74
75 /** @name Basics
76 */
77 //@{
78
79 virtual ~PxPhysics() {}
80
81 /**
82 \brief Destroys the instance it is called on.
83
84 Use this release method to destroy an instance of this class. Be sure
85 to not keep a reference to this object after calling release.
86 Avoid release calls while a scene is simulating (in between simulate() and fetchResults() calls).
87
88 Note that this must be called once for each prior call to PxCreatePhysics, as
89 there is a reference counter. Also note that you mustn't destroy the allocator or the error callback (if available) until after the
90 reference count reaches 0 and the SDK is actually removed.
91
92 Releasing an SDK will also release any scenes, triangle meshes, convex meshes, heightfields and shapes
93 created through it, provided the user hasn't already done so.
94
95 \note This function is required to be called to release foundation usage.
96
97 @see PxCreatePhysics()
98 */
99 virtual void release() = 0;
100
101 /**
102 \brief Retrieves the Foundation instance.
103 \return A reference to the Foundation object.
104 */
105 virtual PxFoundation& getFoundation() = 0;
106
107 /**
108 \brief Creates an aggregate with the specified maximum size and selfCollision property.
109
110 \param [in] maxSize The maximum number of actors that may be placed in the aggregate.
111 \param [in] enableSelfCollision Whether the aggregate supports self-collision
112 \return The new aggregate.
113
114 @see PxAggregate
115 */
116 virtual PxAggregate* createAggregate(PxU32 maxSize, bool enableSelfCollision) = 0;
117
118 /**
119 \brief Returns the simulation tolerance parameters.
120 \return The current simulation tolerance parameters.
121 */
122 virtual const PxTolerancesScale& getTolerancesScale() const = 0;
123
124 //@}
125 /** @name Meshes
126 */
127 //@{
128
129 /**
130 \brief Creates a triangle mesh object.
131
132 This can then be instanced into #PxShape objects.
133
134 \param [in] stream The triangle mesh stream.
135 \return The new triangle mesh.
136
137 @see PxTriangleMesh PxMeshPreprocessingFlag PxTriangleMesh.release() PxInputStream PxTriangleMeshFlag
138 */
139 virtual PxTriangleMesh* createTriangleMesh(PxInputStream& stream) = 0;
140
141 /**
142 \brief Return the number of triangle meshes that currently exist.
143
144 \return Number of triangle meshes.
145
146 @see getTriangleMeshes()
147 */
148 virtual PxU32 getNbTriangleMeshes() const = 0;
149
150 /**
151 \brief Writes the array of triangle mesh pointers to a user buffer.
152
153 Returns the number of pointers written.
154
155 The ordering of the triangle meshes in the array is not specified.
156
157 \param [out] userBuffer The buffer to receive triangle mesh pointers.
158 \param [in] bufferSize The number of triangle mesh pointers which can be stored in the buffer.
159 \param [in] startIndex Index of first mesh pointer to be retrieved
160 \return The number of triangle mesh pointers written to userBuffer, this should be less or equal to bufferSize.
161
162 @see getNbTriangleMeshes() PxTriangleMesh
163 */
164 virtual PxU32 getTriangleMeshes(PxTriangleMesh** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
165
166 /**
167 \brief Creates a heightfield object from previously cooked stream.
168
169 This can then be instanced into #PxShape objects.
170
171 \param [in] stream The heightfield mesh stream.
172 \return The new heightfield.
173
174 @see PxHeightField PxHeightField.release() PxInputStream PxRegisterHeightFields
175 */
176 virtual PxHeightField* createHeightField(PxInputStream& stream) = 0;
177
178 /**
179 \brief Return the number of heightfields that currently exist.
180
181 \return Number of heightfields.
182
183 @see getHeightFields()
184 */
185 virtual PxU32 getNbHeightFields() const = 0;
186
187 /**
188 \brief Writes the array of heightfield pointers to a user buffer.
189
190 Returns the number of pointers written.
191
192 The ordering of the heightfields in the array is not specified.
193
194 \param [out] userBuffer The buffer to receive heightfield pointers.
195 \param [in] bufferSize The number of heightfield pointers which can be stored in the buffer.
196 \param [in] startIndex Index of first heightfield pointer to be retrieved
197 \return The number of heightfield pointers written to userBuffer, this should be less or equal to bufferSize.
198
199 @see getNbHeightFields() PxHeightField
200 */
201 virtual PxU32 getHeightFields(PxHeightField** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
202
203 /**
204 \brief Creates a convex mesh object.
205
206 This can then be instanced into #PxShape objects.
207
208 \param [in] stream The stream to load the convex mesh from.
209 \return The new convex mesh.
210
211 @see PxConvexMesh PxConvexMesh.release() PxInputStream createTriangleMesh() PxConvexMeshGeometry PxShape
212 */
213 virtual PxConvexMesh* createConvexMesh(PxInputStream &stream) = 0;
214
215 /**
216 \brief Return the number of convex meshes that currently exist.
217
218 \return Number of convex meshes.
219
220 @see getConvexMeshes()
221 */
222 virtual PxU32 getNbConvexMeshes() const = 0;
223
224 /**
225 \brief Writes the array of convex mesh pointers to a user buffer.
226
227 Returns the number of pointers written.
228
229 The ordering of the convex meshes in the array is not specified.
230
231 \param [out] userBuffer The buffer to receive convex mesh pointers.
232 \param [in] bufferSize The number of convex mesh pointers which can be stored in the buffer.
233 \param [in] startIndex Index of first convex mesh pointer to be retrieved
234 \return The number of convex mesh pointers written to userBuffer, this should be less or equal to bufferSize.
235
236 @see getNbConvexMeshes() PxConvexMesh
237 */
238 virtual PxU32 getConvexMeshes(PxConvexMesh** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
239
240 /**
241 \brief Creates a bounding volume hierarchy structure.
242
243 \param [in] stream The stream to load the BVH structure from.
244 \return The new BVH structure.
245
246 @see PxBVHStructure PxInputStream
247 */
248 virtual PxBVHStructure* createBVHStructure(PxInputStream &stream) = 0;
249
250 /**
251 \brief Return the number of bounding volume hierarchy structures that currently exist.
252
253 \return Number of bounding volume hierarchy structures.
254
255 @see getBVHStructures()
256 */
257 virtual PxU32 getNbBVHStructures() const = 0;
258
259 /**
260 \brief Writes the array of bounding volume hierarchy structure pointers to a user buffer.
261
262 Returns the number of pointers written.
263
264 The ordering of the BVH structures in the array is not specified.
265
266 \param [out] userBuffer The buffer to receive BVH structure pointers.
267 \param [in] bufferSize The number of BVH structure pointers which can be stored in the buffer.
268 \param [in] startIndex Index of first BVH structure pointer to be retrieved
269 \return The number of BVH structure pointers written to userBuffer, this should be less or equal to bufferSize.
270
271 @see getNbBVHStructures() PxBVHStructure
272 */
273 virtual PxU32 getBVHStructures(PxBVHStructure** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
274
275 //@}
276 /** @name Scenes
277 */
278 //@{
279
280 /**
281 \brief Creates a scene.
282
283 \note Every scene uses a Thread Local Storage slot. This imposes a platform specific limit on the
284 number of scenes that can be created.
285
286 \param [in] sceneDesc Scene descriptor. See #PxSceneDesc
287 \return The new scene object.
288
289 @see PxScene PxScene.release() PxSceneDesc
290 */
291 virtual PxScene* createScene(const PxSceneDesc& sceneDesc) = 0;
292
293 /**
294 \brief Gets number of created scenes.
295
296 \return The number of scenes created.
297
298 @see getScene()
299 */
300 virtual PxU32 getNbScenes() const = 0;
301
302 /**
303 \brief Writes the array of scene pointers to a user buffer.
304
305 Returns the number of pointers written.
306
307 The ordering of the scene pointers in the array is not specified.
308
309 \param [out] userBuffer The buffer to receive scene pointers.
310 \param [in] bufferSize The number of scene pointers which can be stored in the buffer.
311 \param [in] startIndex Index of first scene pointer to be retrieved
312 \return The number of scene pointers written to userBuffer, this should be less or equal to bufferSize.
313
314 @see getNbScenes() PxScene
315 */
316 virtual PxU32 getScenes(PxScene** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
317
318 //@}
319 /** @name Actors
320 */
321 //@{
322
323 /**
324 \brief Creates a static rigid actor with the specified pose and all other fields initialized
325 to their default values.
326
327 \param [in] pose The initial pose of the actor. Must be a valid transform
328
329 @see PxRigidStatic
330 */
331 virtual PxRigidStatic* createRigidStatic(const PxTransform& pose) = 0;
332
333 /**
334 \brief Creates a dynamic rigid actor with the specified pose and all other fields initialized
335 to their default values.
336
337 \param [in] pose The initial pose of the actor. Must be a valid transform
338
339 @see PxRigidDynamic
340 */
341 virtual PxRigidDynamic* createRigidDynamic(const PxTransform& pose) = 0;
342
343 /**
344 \brief Creates a pruning structure from actors.
345
346 \note Every provided actor needs at least one shape with the eSCENE_QUERY_SHAPE flag set.
347 \note Both static and dynamic actors can be provided.
348 \note It is not allowed to pass in actors which are already part of a scene.
349 \note Articulation links cannot be provided.
350
351 \param [in] actors Array of actors to add to the pruning structure. Must be non NULL.
352 \param [in] nbActors Number of actors in the array. Must be >0.
353 \return Pruning structure created from given actors, or NULL if any of the actors did not comply with the above requirements.
354 @see PxActor PxPruningStructure
355 */
356 virtual PxPruningStructure* createPruningStructure(PxRigidActor*const* actors, PxU32 nbActors) = 0;
357
358 //@}
359 /** @name Shapes
360 */
361 //@{
362
363 /**
364 \brief Creates a shape which may be attached to multiple actors
365
366 The shape will be created with a reference count of 1.
367
368 \param [in] geometry The geometry for the shape
369 \param [in] material The material for the shape
370 \param [in] isExclusive Whether this shape is exclusive to a single actor or maybe be shared
371 \param [in] shapeFlags The PxShapeFlags to be set
372
373 Shared shapes are not mutable when they are attached to an actor
374
375 @see PxShape
376 */
377 PX_FORCE_INLINE PxShape* createShape( const PxGeometry& geometry,
378 const PxMaterial& material,
379 bool isExclusive = false,
380 PxShapeFlags shapeFlags = PxShapeFlag::eVISUALIZATION | PxShapeFlag::eSCENE_QUERY_SHAPE | PxShapeFlag::eSIMULATION_SHAPE)
381 {
382 PxMaterial* materialPtr = const_cast<PxMaterial*>(&material);
383 return createShape(geometry, materials: &materialPtr, materialCount: 1, isExclusive, shapeFlags);
384 }
385
386 /**
387 \brief Creates a shape which may be attached to multiple actors
388
389 The shape will be created with a reference count of 1.
390
391 \param [in] geometry The geometry for the shape
392 \param [in] materials The materials for the shape
393 \param [in] materialCount The number of materials
394 \param [in] isExclusive Whether this shape is exclusive to a single actor or may be shared
395 \param [in] shapeFlags The PxShapeFlags to be set
396
397 Shared shapes are not mutable when they are attached to an actor
398
399 @see PxShape
400 */
401 virtual PxShape* createShape(const PxGeometry& geometry,
402 PxMaterial*const * materials,
403 PxU16 materialCount,
404 bool isExclusive = false,
405 PxShapeFlags shapeFlags = PxShapeFlag::eVISUALIZATION | PxShapeFlag::eSCENE_QUERY_SHAPE | PxShapeFlag::eSIMULATION_SHAPE) = 0;
406
407 /**
408 \brief Return the number of shapes that currently exist.
409
410 \return Number of shapes.
411
412 @see getShapes()
413 */
414 virtual PxU32 getNbShapes() const = 0;
415
416 /**
417 \brief Writes the array of shape pointers to a user buffer.
418
419 Returns the number of pointers written.
420
421 The ordering of the shapes in the array is not specified.
422
423 \param [out] userBuffer The buffer to receive shape pointers.
424 \param [in] bufferSize The number of shape pointers which can be stored in the buffer.
425 \param [in] startIndex Index of first shape pointer to be retrieved
426 \return The number of shape pointers written to userBuffer, this should be less or equal to bufferSize.
427
428 @see getNbShapes() PxShape
429 */
430 virtual PxU32 getShapes(PxShape** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
431
432 //@}
433 /** @name Constraints and Articulations
434 */
435 //@{
436
437 /**
438 \brief Creates a constraint shader.
439
440 \note A constraint shader will get added automatically to the scene the two linked actors belong to. Either, but not both, of actor0 and actor1 may
441 be NULL to denote attachment to the world.
442
443 \param [in] actor0 The first actor
444 \param [in] actor1 The second actor
445 \param [in] connector The connector object, which the SDK uses to communicate with the infrastructure for the constraint
446 \param [in] shaders The shader functions for the constraint
447 \param [in] dataSize The size of the data block for the shader
448
449 \return The new shader.
450
451 @see PxConstraint
452 */
453 virtual PxConstraint* createConstraint(PxRigidActor* actor0, PxRigidActor* actor1, PxConstraintConnector& connector, const PxConstraintShaderTable& shaders, PxU32 dataSize) = 0;
454
455 /**
456 \brief Creates an articulation with all fields initialized to their default values.
457
458 \return the new articulation
459
460 @see PxArticulation, PxRegisterArticulations
461 */
462 virtual PxArticulation* createArticulation() = 0;
463
464 /**
465 \brief Creates a reduced coordinate articulation with all fields initialized to their default values.
466
467 \return the new articulation
468
469 @see PxArticulationReducedCoordinate, PxRegisterArticulationsReducedCoordinate
470 */
471 virtual PxArticulationReducedCoordinate* createArticulationReducedCoordinate() = 0;
472
473
474 //@}
475 /** @name Materials
476 */
477 //@{
478
479 /**
480 \brief Creates a new material with default properties.
481
482 \return The new material.
483
484 \param [in] staticFriction The coefficient of static friction
485 \param [in] dynamicFriction The coefficient of dynamic friction
486 \param [in] restitution The coefficient of restitution
487
488 @see PxMaterial
489 */
490 virtual PxMaterial* createMaterial(PxReal staticFriction, PxReal dynamicFriction, PxReal restitution) = 0;
491
492
493 /**
494 \brief Return the number of materials that currently exist.
495
496 \return Number of materials.
497
498 @see getMaterials()
499 */
500 virtual PxU32 getNbMaterials() const = 0;
501
502 /**
503 \brief Writes the array of material pointers to a user buffer.
504
505 Returns the number of pointers written.
506
507 The ordering of the materials in the array is not specified.
508
509 \param [out] userBuffer The buffer to receive material pointers.
510 \param [in] bufferSize The number of material pointers which can be stored in the buffer.
511 \param [in] startIndex Index of first material pointer to be retrieved
512 \return The number of material pointers written to userBuffer, this should be less or equal to bufferSize.
513
514 @see getNbMaterials() PxMaterial
515 */
516 virtual PxU32 getMaterials(PxMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
517
518 //@}
519 /** @name Deletion Listeners
520 */
521 //@{
522
523 /**
524 \brief Register a deletion listener. Listeners will be called whenever an object is deleted.
525
526 It is illegal to register or unregister a deletion listener while deletions are being processed.
527
528 \note By default a registered listener will receive events from all objects. Set the restrictedObjectSet parameter to true on registration and use #registerDeletionListenerObjects to restrict the received events to specific objects.
529
530 \note The deletion events are only supported on core PhysX objects. In general, objects in extension modules do not provide this functionality, however, in the case of PxJoint objects, the underlying PxConstraint will send the events.
531
532 \param [in] observer Observer object to send notifications to.
533 \param [in] deletionEvents The deletion event types to get notified of.
534 \param [in] restrictedObjectSet If false, the deletion listener will get events from all objects, else the objects to receive events from have to be specified explicitly through #registerDeletionListenerObjects.
535
536 @see PxDeletionListener unregisterDeletionListener
537 */
538 virtual void registerDeletionListener(PxDeletionListener& observer, const PxDeletionEventFlags& deletionEvents, bool restrictedObjectSet = false) = 0;
539
540 /**
541 \brief Unregister a deletion listener.
542
543 It is illegal to register or unregister a deletion listener while deletions are being processed.
544
545 \param [in] observer Observer object to send notifications to
546
547 @see PxDeletionListener registerDeletionListener
548 */
549 virtual void unregisterDeletionListener(PxDeletionListener& observer) = 0;
550
551 /**
552 \brief Register specific objects for deletion events.
553
554 This method allows for a deletion listener to limit deletion events to specific objects only.
555
556 \note It is illegal to register or unregister objects while deletions are being processed.
557
558 \note The deletion listener has to be registered through #registerDeletionListener() and configured to support restricted objects sets prior to this method being used.
559
560 \param [in] observer Observer object to send notifications to.
561 \param [in] observables List of objects for which to receive deletion events. Only PhysX core objects are supported. In the case of PxJoint objects, the underlying PxConstraint can be used to get the events.
562 \param [in] observableCount Size of the observables list.
563
564 @see PxDeletionListener unregisterDeletionListenerObjects
565 */
566 virtual void registerDeletionListenerObjects(PxDeletionListener& observer, const PxBase* const* observables, PxU32 observableCount) = 0;
567
568 /**
569 \brief Unregister specific objects for deletion events.
570
571 This method allows to clear previously registered objects for a deletion listener (see #registerDeletionListenerObjects()).
572
573 \note It is illegal to register or unregister objects while deletions are being processed.
574
575 \note The deletion listener has to be registered through #registerDeletionListener() and configured to support restricted objects sets prior to this method being used.
576
577 \param [in] observer Observer object to stop sending notifications to.
578 \param [in] observables List of objects for which to not receive deletion events anymore.
579 \param [in] observableCount Size of the observables list.
580
581 @see PxDeletionListener registerDeletionListenerObjects
582 */
583 virtual void unregisterDeletionListenerObjects(PxDeletionListener& observer, const PxBase* const* observables, PxU32 observableCount) = 0;
584
585 /**
586 \brief Gets PxPhysics object insertion interface.
587
588 The insertion interface is needed ie. for PxCooking::createTriangleMesh, this allows runtime mesh creation. This is not advised to do, please
589 use offline cooking if possible.
590
591 @see PxCooking::createTriangleMesh PxCooking::createHeightfield
592 */
593 virtual PxPhysicsInsertionCallback& getPhysicsInsertionCallback() = 0;
594
595 //@}
596};
597
598#if !PX_DOXYGEN
599} // namespace physx
600#endif
601
602/**
603\brief Enables the usage of the articulations feature. This function is called automatically inside PxCreatePhysics().
604On resource constrained platforms, it is possible to call PxCreateBasePhysics() and then NOT call this function
605to save on code memory if your application does not use articulations. In this case the linker should strip out
606the relevant implementation code from the library. If you need to use articulations but not some other optional
607component, you shoud call PxCreateBasePhysics() followed by this call.
608*/
609PX_C_EXPORT PX_PHYSX_CORE_API void PX_CALL_CONV PxRegisterArticulations(physx::PxPhysics& physics);
610
611
612/**
613\brief Enables the usage of the reduced coordinate articulations feature. This function is called automatically inside PxCreatePhysics().
614On resource constrained platforms, it is possible to call PxCreateBasePhysics() and then NOT call this function
615to save on code memory if your application does not use articulations. In this case the linker should strip out
616the relevant implementation code from the library. If you need to use articulations but not some other optional
617component, you shoud call PxCreateBasePhysics() followed by this call.
618*/
619PX_C_EXPORT PX_PHYSX_CORE_API void PX_CALL_CONV PxRegisterArticulationsReducedCoordinate(physx::PxPhysics& physics);
620
621/**
622\brief Enables the usage of the heightfield feature.
623
624This call will link the default 'unified' implementation of heightfields which is identical to the narrow phase of triangle meshes.
625This function is called automatically inside PxCreatePhysics().
626
627On resource constrained platforms, it is possible to call PxCreateBasePhysics() and then NOT call this function
628to save on code memory if your application does not use heightfields. In this case the linker should strip out
629the relevant implementation code from the library. If you need to use heightfield but not some other optional
630component, you shoud call PxCreateBasePhysics() followed by this call.
631
632You must call this function at a time where no ::PxScene instance exists, typically before calling PxPhysics::createScene().
633This is to prevent a change to the heightfield implementation code at runtime which would have undefined results.
634
635Calling PxCreateBasePhysics() and then attempting to create a heightfield shape without first calling
636::PxRegisterHeightFields(), will result in an error.
637*/
638PX_C_EXPORT PX_PHYSX_CORE_API void PX_CALL_CONV PxRegisterHeightFields(physx::PxPhysics& physics);
639
640/**
641\brief Creates an instance of the physics SDK with minimal additional components registered
642
643Creates an instance of this class. May not be a class member to avoid name mangling.
644Pass the constant #PX_PHYSICS_VERSION as the argument.
645There may be only one instance of this class per process. Calling this method after an instance
646has been created already will result in an error message and NULL will be returned.
647
648\param version Version number we are expecting(should be #PX_PHYSICS_VERSION)
649\param foundation Foundation instance (see PxFoundation)
650\param scale values used to determine default tolerances for objects at creation time
651\param trackOutstandingAllocations true if you want to track memory allocations
652 so a debugger connection partway through your physics simulation will get
653 an accurate map of everything that has been allocated so far. This could have a memory
654 and performance impact on your simulation hence it defaults to off.
655\param pvd When pvd points to a valid PxPvd instance (PhysX Visual Debugger), a connection to the specified PxPvd instance is created.
656 If pvd is NULL no connection will be attempted.
657\return PxPhysics instance on success, NULL if operation failed
658
659@see PxPhysics, PxFoundation, PxTolerancesScale, PxPvd
660*/
661PX_C_EXPORT PX_PHYSX_CORE_API physx::PxPhysics* PX_CALL_CONV PxCreateBasePhysics(physx::PxU32 version,
662 physx::PxFoundation& foundation,
663 const physx::PxTolerancesScale& scale,
664 bool trackOutstandingAllocations = false,
665 physx::PxPvd* pvd = NULL);
666
667/**
668\brief Creates an instance of the physics SDK.
669
670Creates an instance of this class. May not be a class member to avoid name mangling.
671Pass the constant #PX_PHYSICS_VERSION as the argument.
672There may be only one instance of this class per process. Calling this method after an instance
673has been created already will result in an error message and NULL will be returned.
674
675Calling this will register all optional code modules (Articulations and HeightFields), preparing them for use.
676If you do not need some of these modules, consider calling PxCreateBasePhysics() instead and registering needed
677modules manually.
678
679\param version Version number we are expecting(should be #PX_PHYSICS_VERSION)
680\param foundation Foundation instance (see PxFoundation)
681\param scale values used to determine default tolerances for objects at creation time
682\param trackOutstandingAllocations true if you want to track memory allocations
683 so a debugger connection partway through your physics simulation will get
684 an accurate map of everything that has been allocated so far. This could have a memory
685 and performance impact on your simulation hence it defaults to off.
686\param pvd When pvd points to a valid PxPvd instance (PhysX Visual Debugger), a connection to the specified PxPvd instance is created.
687 If pvd is NULL no connection will be attempted.
688\return PxPhysics instance on success, NULL if operation failed
689
690@see PxPhysics, PxCreateBasePhysics, PxRegisterArticulations, PxRegisterArticulationsReducedCoordinate, PxRegisterHeightFields
691*/
692PX_INLINE physx::PxPhysics* PxCreatePhysics(physx::PxU32 version,
693 physx::PxFoundation& foundation,
694 const physx::PxTolerancesScale& scale,
695 bool trackOutstandingAllocations = false,
696 physx::PxPvd* pvd = NULL )
697{
698 physx::PxPhysics* physics = PxCreateBasePhysics(version, foundation, scale, trackOutstandingAllocations, pvd);
699 if(!physics)
700 return NULL;
701
702 PxRegisterArticulations(physics&: *physics);
703 PxRegisterArticulationsReducedCoordinate(physics&: *physics);
704 PxRegisterHeightFields(physics&: *physics);
705
706 return physics;
707}
708
709
710/**
711\brief Retrieves the Physics SDK after it has been created.
712
713Before using this function the user must call #PxCreatePhysics().
714
715\note The behavior of this method is undefined if the Physics SDK instance has not been created already.
716*/
717#ifdef __clang__
718#pragma clang diagnostic push
719#pragma clang diagnostic ignored "-Wreturn-type-c-linkage"
720#endif
721
722PX_C_EXPORT PX_PHYSX_CORE_API physx::PxPhysics& PX_CALL_CONV PxGetPhysics();
723
724#ifdef __clang__
725#pragma clang diagnostic pop
726#endif
727
728/** @} */
729#endif
730

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