Advertisement
keybode

PxScene.h

Jan 31st, 2015
748
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 61.47 KB | None | 0 0
  1. // This code contains NVIDIA Confidential Information and is disclosed to you
  2. // under a form of NVIDIA software license agreement provided separately to you.
  3. //
  4. // Notice
  5. // NVIDIA Corporation and its licensors retain all intellectual property and
  6. // proprietary rights in and to this software and related documentation and
  7. // any modifications thereto. Any use, reproduction, disclosure, or
  8. // distribution of this software and related documentation without an express
  9. // license agreement from NVIDIA Corporation is strictly prohibited.
  10. //
  11. // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
  12. // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
  13. // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
  14. // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
  15. //
  16. // Information and code furnished is believed to be accurate and reliable.
  17. // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
  18. // information or for any infringement of patents or other rights of third parties that may
  19. // result from its use. No license is granted by implication or otherwise under any patent
  20. // or patent rights of NVIDIA Corporation. Details are subject to change without notice.
  21. // This code supersedes and replaces all information previously supplied.
  22. // NVIDIA Corporation products are not authorized for use as critical
  23. // components in life support devices or systems without express written approval of
  24. // NVIDIA Corporation.
  25. //
  26. // Copyright (c) 2008-2012 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_SCENE
  32. #define PX_PHYSICS_NX_SCENE
  33. /** \addtogroup physics
  34. @{
  35. */
  36.  
  37. #include "PxVisualizationParameter.h"
  38. #include "PxSceneDesc.h"
  39. #include "PxSimulationStatistics.h"
  40. #include "PxSceneQueryReport.h"
  41. #include "PxSceneQueryFiltering.h"
  42. #include "PxClient.h"
  43.  
  44. #if PX_USE_PARTICLE_SYSTEM_API
  45. #include "particles/PxParticleSystem.h"
  46. #include "particles/PxParticleFluid.h"
  47. #endif
  48.  
  49. #ifndef PX_DOXYGEN
  50. namespace physx
  51. {
  52. #endif
  53.  
  54. class PxRigidStatic;
  55. class PxRigidDynamic;
  56. class PxConstraint;
  57. class PxMaterial;
  58. class PxSimulationEventCallback;
  59. class PxPhysics;
  60. class PxBatchQueryDesc;
  61. class PxBatchQuery;
  62. class PxSweepCache;
  63. class PxAggregate;
  64. class PxRenderBuffer;
  65.  
  66. class PxSphereGeometry;
  67. class PxBoxGeometry;
  68. class PxCapsuleGeometry;
  69.  
  70. typedef PxU8 PxDominanceGroup;
  71.  
  72. namespace pxtask
  73. {
  74.     class BaseTask;
  75.     class TaskManager;
  76. }
  77.  
  78. /**
  79. \brief Maximum sweep distance for scene sweeps. The distance parameter for sweep functions will be clamped to this value.
  80. The reason for this is GJK support cannot be evaluated near infinity. A viable alternative can be a sweep followed by an infinite raycast.
  81.  
  82. @see PxScene
  83. */
  84. #define PX_MAX_SWEEP_DISTANCE 1e8f
  85. /**
  86. \brief Data struct for use with Active Transform Notification.
  87. Used with PxScene::getActiveTransforms().
  88.  
  89. @see PxScene
  90. */
  91. struct PxActiveTransform
  92. {
  93.     PxActor*        actor;              //!< Affected actor
  94.     void*           userData;           //!< User data of the actor
  95.     PxTransform     actor2World;        //!< Actor-to-world transform of the actor
  96. };
  97.  
  98. /**
  99. \brief Expresses the dominance relationship of a constraint.
  100. For the time being only three settings are permitted:
  101.  
  102. (1.0f, 1.0f), (0.0f, 1.0f), and (1.0f, 0.0f).
  103.  
  104. @see getDominanceGroup() PxDominanceGroup PxScene::setDominanceGroupPair()
  105. */ 
  106. struct PxConstraintDominance
  107. {
  108.     PxConstraintDominance(PxReal a, PxReal b)
  109.         : dominance0(a), dominance1(b) {}
  110.     PxReal dominance0;
  111.     PxReal dominance1;
  112. };
  113.  
  114. /**
  115. \brief Identifies each type of actor for retrieving actors from a scene.
  116.  
  117. \note #PxArticulationLink objects are not supported. Use the #PxArticulation object to retrieve all its links.
  118.  
  119. @see PxScene::getActors(), PxScene::getNbActors()
  120. */
  121. struct PxActorTypeSelectionFlag
  122. {
  123.     enum Enum
  124.     {
  125.         /**
  126.         \brief A static rigid body
  127.         @see PxRigidStatic
  128.         */
  129.         eRIGID_STATIC       = (1 << 0),
  130.  
  131.         /**
  132.         \brief A dynamic rigid body
  133.         @see PxRigidDynamic
  134.         */
  135.         eRIGID_DYNAMIC      = (1 << 1),
  136.  
  137. #if PX_USE_PARTICLE_SYSTEM_API
  138.         /**
  139.         \brief A particle system
  140.         @see PxParticleSystem
  141.         */
  142.         ePARTICLE_SYSTEM    = (1 << 2),
  143.  
  144.         /**
  145.         \brief A particle fluid
  146.         @see PxParticleFluid
  147.         */
  148.         ePARTICLE_FLUID     = (1 << 3),
  149. #endif
  150.  
  151. #if PX_USE_CLOTH_API
  152.         /**
  153.         \brief A cloth
  154.         @see PxCloth
  155.         */
  156.         eCLOTH              = (1 << 5)
  157. #endif
  158.     };
  159. };
  160.  
  161. /**
  162. \brief Collection of set bits defined in PxActorTypeSelectionFlag.
  163.  
  164. @see PxActorTypeSelectionFlag
  165. */
  166. typedef PxFlags<PxActorTypeSelectionFlag::Enum,PxU16> PxActorTypeSelectionFlags;
  167. PX_FLAGS_OPERATORS(PxActorTypeSelectionFlag::Enum,PxU16);
  168.  
  169. /**
  170. \brief Hit cache for scene queries.
  171.  
  172. If this is supplied to a scene query, the shape is checked first for intersection.
  173. If intersection is found, the hit is assumed to be a blocking hit.
  174.  
  175. It is the user's responsibility to ensure that the shape is valid, so care must be taken when deleting shapes to invalidate cached
  176. references.
  177.  
  178. The faceIndex field is an additional hint for a mesh or height field which is not currently used.
  179.  
  180. @see PxScene.raycastAny PxScene.raycastSingle PxScene.raycastMultiple
  181. */
  182. struct PxSceneQueryCache
  183. {
  184.     /**
  185.     \brief constructor sets to default
  186.     */
  187.     PX_INLINE PxSceneQueryCache() : shape(NULL), faceIndex(0xffffffff) {}
  188.  
  189.     /**
  190.     \brief constructor to set properties
  191.     */
  192.     PX_INLINE PxSceneQueryCache(PxShape* s, PxU32 findex) : shape(s), faceIndex(findex) {}
  193.  
  194.     PxShape*    shape;          //!< Shape to test for intersection first
  195.     PxU32       faceIndex;      //!< Triangle index to test first - NOT CURRENTLY SUPPORTED
  196. };
  197.  
  198. /**
  199.  \brief A scene is a collection of bodies, particle systems and constraints which can interact.
  200.  
  201.  The scene simulates the behavior of these objects over time. Several scenes may exist
  202.  at the same time, but each body, particle system or constraint is specific to a scene
  203.  -- they may not be shared.
  204.  
  205.  @see PxSceneDesc PxPhysics.createScene() release()
  206. */
  207. class PxScene
  208. {
  209.     protected:
  210.                                         PxScene(): userData(0)  {}
  211.     virtual                             ~PxScene()  {}
  212.  
  213.     public:
  214.  
  215. /************************************************************************************************/
  216.    
  217. /** @name Basics
  218. */
  219. //@{
  220.    
  221.     /**
  222.     \brief Deletes the scene.
  223.  
  224.     Removes any actors,  particle systems, and constraint shaders from this scene
  225.     (if the user hasn't already done so).
  226.  
  227.     Be sure to not keep a reference to this object after calling release.
  228.     Avoid release calls while the scene is simulating (in between simulate() and fetchResults() calls).
  229.    
  230.     @see PxPhysics.createScene()
  231.     */
  232.     virtual     void                    release() = 0;
  233.  
  234.  
  235.     /**
  236.     \brief Saves the Scene descriptor.
  237.  
  238.     \param[out] desc The descriptor used to retrieve the state of the object.
  239.     \return True on success.
  240.  
  241.     @see PxSceneDesc
  242.     */
  243.     virtual     bool                    saveToDesc(PxSceneDesc& desc)   const   = 0;
  244.  
  245.     /**
  246.     \brief Sets a scene flag.  You can only set one flag at a time.
  247.  
  248.     Only the below flags are mutable.  Trying to change the others will
  249.     result in an error:
  250.  
  251.     PxSceneFlag::eENABLE_SWEPT_INTEGRATION
  252.  
  253.     @see PxSceneFlag
  254.     */
  255.     virtual     void                    setFlag(PxSceneFlag::Enum flag, bool value) = 0;
  256.  
  257.     /**
  258.     \brief Get the scene flags.
  259.  
  260.     \return The scene flags. See #PxSceneFlag
  261.  
  262.     @see PxSceneFlag
  263.     */
  264.     virtual     PxSceneFlags            getFlags() const = 0;
  265.  
  266.     /**
  267.     \brief Sets a constant gravity for the entire scene.
  268.  
  269.     <b>Sleeping:</b> Does <b>NOT</b> wake the actor up automatically.
  270.  
  271.     \param[in] vec A new gravity vector(e.g. PxVec3(0.0f,-9.8f,0.0f) ) <b>Range:</b> force vector
  272.  
  273.     @see PxSceneDesc.gravity getGravity()
  274.     */
  275.     virtual void                        setGravity(const PxVec3& vec) = 0;
  276.  
  277.     /**
  278.     \brief Retrieves the current gravity setting.
  279.  
  280.     \return The current gravity for the scene.
  281.  
  282.     @see setGravity() PxSceneDesc.gravity
  283.     */
  284.     virtual PxVec3                      getGravity() const = 0;
  285.    
  286.     /**
  287.     \brief Call this method to retrieve the Physics SDK.
  288.  
  289.     \return The physics SDK this scene is associated with.
  290.  
  291.     @see PxPhysics
  292.     */
  293.     virtual PxPhysics&                  getPhysics() = 0;
  294.  
  295.     /**
  296.     \brief Retrieves the scene's internal timestamp, increased each time a simulation step is completed.
  297.  
  298.     \return scene timestamp
  299.     */
  300.     virtual PxU32                       getTimestamp()  const   = 0;
  301.  
  302.     /**
  303.     \brief Retrieves the scene's internal scene query timestamp, increased each time a change to the
  304.     static scene query structure is performed.
  305.  
  306.     \return scene query static timestamp
  307.     */
  308.     virtual PxU32                       getSceneQueryStaticTimestamp()  const   = 0;
  309.  
  310.     /**
  311.     \brief Set the bounce threshold velocity.
  312.     @see PxSceneDesc.bounceThresholdVelocity
  313.     */
  314.     virtual void                        setBounceThresholdVelocity(const PxReal t) = 0;
  315.  
  316.     /**
  317.     \brief Return the bounce threshold velocity.
  318.     @see PxSceneDesc.bounceThresholdVelocity
  319.     */
  320.    
  321.     virtual PxReal                      getBounceThresholdVelocity() const = 0;
  322.  
  323.     void*   userData;   //!< user can assign this to whatever, usually to create a 1:1 relationship with a user object.
  324.  
  325. //@}
  326.  
  327. /************************************************************************************************/
  328.  
  329. /** @name Simulation
  330. */
  331. //@{
  332.  
  333.     /**
  334.     \brief Advances the simulation by an elapsedTime time.
  335.    
  336.     \note Large elapsedTime values can lead to instabilities. In such cases elapsedTime
  337.     should be subdivided into smaller time intervals and simulate() should be called
  338.     multiple times for each interval.
  339.  
  340.     Calls to simulate() should pair with calls to fetchResults():
  341.     Each fetchResults() invocation corresponds to exactly one simulate()
  342.     invocation; calling simulate() twice without an intervening fetchResults()
  343.     or fetchResults() twice without an intervening simulate() causes an error
  344.     condition.
  345.  
  346.     scene->simulate();
  347.     ...do some processing until physics is computed...
  348.     scene->fetchResults();
  349.     ...now results of run may be retrieved.
  350.  
  351.  
  352.     \param[in] elapsedTime Amount of time to advance simulation by. The parameter has to be larger than 0, else the resulting behavior will be undefined. <b>Range:</b> (0,inf)
  353.     \param[in] completionTask if non-NULL, this task will have its refcount incremented in simulate(), then
  354.     decremented when the scene is ready to have fetchResults called. So the task will not run until the
  355.     application also calls removeReference().
  356.     \param[in] scratchMemBlock a memory region for physx to use for temporary data during simulation. This block may be reused by the application
  357.     after fetchResults returns. Must be aligned on a 16-byte boundary
  358.     \param[in] scratchMemBlockSize the size of the scratch memory block. Must be a multiple of 16K.
  359.     \param[in] controlSimulation if true, the scene controls its TaskManager simulation state.  Leave
  360.     true unless the application is calling the TaskManager start/stopSimulation() methods itself.
  361.  
  362.     @see fetchResults() checkResults()
  363.     */
  364.     virtual void                        simulate(PxReal elapsedTime,
  365.                                                  physx::pxtask::BaseTask* completionTask = NULL,
  366.                                                  void* scratchMemBlock = 0,
  367.                                                  PxU32 scratchMemBlockSize = 0,
  368.                                                  bool controlSimulation = true)     = 0;
  369.    
  370.     /**
  371.     \brief This checks to see if the simulation run has completed.
  372.  
  373.     This does not cause the data available for reading to be updated with the results of the simulation, it is simply a status check.
  374.     The bool will allow it to either return immediately or block waiting for the condition to be met so that it can return true
  375.    
  376.     \param[in] block When set to true will block until the condition is met.
  377.     \return True if the results are available.
  378.  
  379.     @see simulate() fetchResults()
  380.     */
  381.     virtual bool                        checkResults(bool block = false)    = 0;
  382.  
  383.     /**
  384.     This is the big brother to checkResults() it basically does the following:
  385.    
  386.     \code
  387.     if ( checkResults(block) )
  388.     {
  389.         fire appropriate callbacks
  390.         swap buffers
  391.         return true
  392.     }
  393.     else
  394.         return false
  395.  
  396.     \endcode
  397.  
  398.     \param[in] block When set to true will block until the condition is met.
  399.     \param[out] errorState Used to retrieve hardware error codes. A non zero value indicates an error.
  400.     \return True if the results have been fetched.
  401.  
  402.     @see simulate() checkResults()
  403.     */
  404.     virtual bool                        fetchResults(bool block = false, PxU32* errorState = 0) = 0;
  405.  
  406.     /**
  407.     \brief Clear internal buffers and free memory.
  408.  
  409.     This method can be used to clear buffers and free internal memory without having to destroy the scene. Can be usefull if
  410.     the physics data gets streamed in and a checkpoint with a clean state should be created.
  411.  
  412.     \note It is not allowed to call this method while the simulation is running. The call will fail.
  413.    
  414.     \param[in] sendPendingReports When set to true pending reports will be sent out before the buffers get cleaned up (for instance lost touch contact/trigger reports due to deleted objects).
  415.     */
  416.     virtual void                        flush(bool sendPendingReports = false) = 0;
  417.    
  418. //@}
  419.  
  420. /************************************************************************************************/
  421.  
  422. /** @name Threads and Memory
  423. */
  424. //@{
  425.    
  426.     /**
  427.     \brief Get the task manager associated with this scene
  428.  
  429.     \return the task manager associated with the scene
  430.     */
  431.     virtual physx::pxtask::TaskManager*     getTaskManager() const = 0;
  432.  
  433.    
  434.     /**
  435.     \brief Sets the number of actors required to spawn a separate rigid body solver thread.
  436.  
  437.     \param[in] solverBatchSize Number of actors required to spawn a separate rigid body solver thread.
  438.  
  439.     <b>Platform:</b>
  440.     \li PC SW: Yes
  441.     \li PS3  : Not applicable
  442.     \li XB360: Yes
  443.     \li WII  : Yes
  444.  
  445.     @see PxSceneDesc.solverBatchSize getSolverBatchSize()
  446.     */
  447.     virtual void                        setSolverBatchSize(PxU32 solverBatchSize) = 0;
  448.  
  449.     /**
  450.     \brief Retrieves the number of actors required to spawn a separate rigid body solver thread.
  451.  
  452.     \return Current number of actors required to spawn a separate rigid body solver thread.
  453.  
  454.     <b>Platform:</b>
  455.     \li PC SW: Yes
  456.     \li PS3  : Not applicable
  457.     \li XB360: Yes
  458.     \li WII  : Yes
  459.  
  460.     @see PxSceneDesc.solverBatchSize setSolverBatchSize()
  461.     */
  462.     virtual PxU32                       getSolverBatchSize() const = 0;
  463.    
  464.    
  465.     /**
  466.     \brief set the cache blocks that can be used during simulate().
  467.    
  468.     Each frame the simulation requires memory to store contact, friction, and contact cache data. This memory is used in blocks of 16K.
  469.     Each frame the blocks used by the previous frame are freed, and may be retrieved by the application using PxScene::flush()
  470.  
  471.     This call will force allocation of cache blocks if the numBlocks parameter is greater than the currently allocated number
  472.     of blocks, and less than the max16KContactDataBlocks parameter specified at scene creation time.
  473.  
  474.     \param[in] numBlocks The number of blocks to allocate. 
  475.  
  476.     @see PxSceneDesc.nbContactDataBlocks PxSceneDesc.maxNbContactDataBlocks flush() getNbContactDataBlocksUsed getMaxNbContactDataBlocksUsed
  477.     */
  478.     virtual         void                setNbContactDataBlocks(PxU32 numBlocks) = 0;
  479.    
  480.  
  481.     /**
  482.     \brief get the number of cache blocks currently used by the scene
  483.  
  484.     This function may not be called while the scene is simulating
  485.  
  486.     \return the number of cache blocks currently used by the scene
  487.  
  488.     @see PxSceneDesc.nbContactDataBlocks PxSceneDesc.maxNbContactDataBlocks flush() setNbContactDataBlocks() getMaxNbContactDataBlocksUsed()
  489.     */
  490.     virtual         PxU32               getNbContactDataBlocksUsed() const = 0;
  491.  
  492.     /**
  493.     \brief get the maximum number of cache blocks used by the scene
  494.  
  495.     This function may not be called while the scene is simulating
  496.  
  497.     \return the maximum number of cache blocks ever used by the scene
  498.  
  499.     @see PxSceneDesc.nbContactDataBlocks PxSceneDesc.maxNbContactDataBlocks flush() setNbContactDataBlocks() getNbContactDataBlocksUsed()
  500.     */
  501.     virtual         PxU32               getMaxNbContactDataBlocksUsed() const = 0;
  502.  
  503.  
  504. //@}
  505.  
  506. /************************************************************************************************/
  507.  
  508. /** @name Create/Release Objects
  509. */
  510. //@{
  511.     /**
  512.     \brief Adds an articulation to this scene.
  513.  
  514.     \note If the articulation is already assigned to a scene (see #PxArticulation::getScene), the call is ignored and a error is issued.
  515.  
  516.     \param[in] articulation Articulation to add to scene. See #PxArticulation
  517.  
  518.     @see PxArticulation
  519.     */
  520.     virtual void                        addArticulation(PxArticulation& articulation) = 0;
  521.  
  522.     /**
  523.     \brief Removes an articulation from this scene.
  524.  
  525.     \note If the articulation is not part of this scene (see #PxArticulation::getScene), the call is ignored and a error is issued.
  526.    
  527.     \param[in] articulation Articulation to remove from scene. See #PxArticulation
  528.  
  529.     @see PxArticulation
  530.     */
  531.     virtual void                        removeArticulation(PxArticulation& articulation) = 0;
  532.  
  533.     /**
  534.     \brief Adds an actor to this scene.
  535.    
  536.     \note If the actor is already assigned to a scene (see #PxActor::getScene), the call is ignored and a error is issued.
  537.  
  538.     \note You can not add individual articulation links (see #PxArticulationLink) to the scene. Use #addArticulation() instead.
  539.  
  540.     \note If the actor is a PxRigidActor then each assigned PxConstraint object will get added to the scene automatically if
  541.     it connects to another actor that is part of the scene already.
  542.  
  543.     \param[in] actor Actor to add to scene.
  544.  
  545.     @see PxActor
  546.     */
  547.     virtual void                        addActor(PxActor& actor) = 0;
  548.  
  549.     // PT: work in progress. Don't use yet.
  550.     virtual void                        addActors(PxU32 nbActors, PxActor** actors) = 0;
  551.  
  552.     /**
  553.     \brief Removes an actor from this scene.
  554.  
  555.     \note If the actor is not part of this scene (see #PxActor::getScene), the call is ignored and a error is issued.
  556.  
  557.     \note You can not remove individual articulation links (see #PxArticulationLink) from the scene. Use #removeArticulation() instead.
  558.  
  559.     \note If the actor is a PxRigidActor then all assigned PxConstraint objects will get removed from the scene automatically.
  560.  
  561.     \param[in] actor Actor to remove from scene.
  562.  
  563.     @see PxActor
  564.     */
  565.     virtual void                        removeActor(PxActor& actor) = 0;
  566.  
  567.  
  568. // PX_AGGREGATE
  569.     /**
  570.     \brief Adds an aggregate to this scene.
  571.    
  572.     \note If the aggregate is already assigned to a scene (see #PxAggregate::getScene), the call is ignored and a error is issued.
  573.  
  574.     \note If the aggregate already contains actors, those actors are added to the scene as well.
  575.  
  576.     \param[in] aggregate Aggregate to add to scene.
  577.    
  578.     @see PxAggregate
  579.     */
  580.     virtual void                        addAggregate(PxAggregate& aggregate)    = 0;
  581.  
  582.     /**
  583.     \brief Removes an aggregate from this scene.
  584.  
  585.     \note If the aggregate is not part of this scene (see #PxAggregate::getScene), the call is ignored and a error is issued.
  586.  
  587.     \note If the aggregate contains actors, those actors are removed from the scene as well.
  588.  
  589.     \param[in] aggregate Aggregate to remove from scene.
  590.  
  591.     @see PxAggregate
  592.     */
  593.     virtual void                        removeAggregate(PxAggregate& aggregate) = 0;
  594.  
  595.     /**
  596.     \brief Returns the number of aggregates in the scene.
  597.  
  598.     \return the number of aggregates in this scene.
  599.  
  600.     @see getAggregates()
  601.     */
  602.     virtual         PxU32               getNbAggregates()   const   = 0;
  603.  
  604.     /**
  605.     \brief Retrieve all the aggregates in the scene.
  606.  
  607.     \param[out] userBuffer The buffer to receive aggregates pointers.
  608.     \param[in] bufferSize Size of provided user buffer.
  609.     \param[in] startIndex Index of first aggregate pointer to be retrieved
  610.     \return Number of aggregates written to the buffer.
  611.  
  612.     @see getNbAggregates()
  613.     */
  614.     virtual         PxU32               getAggregates(PxAggregate** userBuffer, PxU32 bufferSize, PxU32 startIndex=0)   const   = 0;
  615. //~PX_AGGREGATE
  616.  
  617. //@}
  618. /************************************************************************************************/
  619.  
  620. /** @name Dominance
  621. */
  622. //@{
  623.  
  624.     /**
  625.     \brief Specifies the dominance behavior of constraints between two actors with two certain dominance groups.
  626.    
  627.     It is possible to assign each actor to a dominance groups using #PxActor::setDominanceGroup().
  628.  
  629.     With dominance groups one can have all constraints (contacts and joints) created
  630.     between actors act in one direction only. This is useful if you want to make sure that the movement of the rider
  631.     of a vehicle or the pony tail of a character doesn't influence the object it is attached to, while keeping the motion of
  632.     both inherently physical.  
  633.    
  634.     Whenever a constraint (i.e. joint or contact) between two actors (a0, a1) needs to be solved, the groups (g0, g1) of both
  635.     actors are retrieved.  Then the PxConstraintDominance setting for this group pair is retrieved with getDominanceGroupPair(g0, g1).  
  636.    
  637.     In the constraint, PxConstraintDominance::dominance0 becomes the dominance setting for a0, and
  638.     PxConstraintDominance::dominance1 becomes the dominance setting for a1.  A dominanceN setting of 1.0f, the default,
  639.     will permit aN to be pushed or pulled by a(1-N) through the constraint.  A dominanceN setting of 0.0f, will however
  640.     prevent aN to be pushed or pulled by a(1-N) through the constraint.  Thus, a PxConstraintDominance of (1.0f, 0.0f) makes
  641.     the interaction one-way.
  642.    
  643.    
  644.     The matrix sampled by getDominanceGroupPair(g1, g2) is initialised by default such that:
  645.    
  646.     if g1 == g2, then (1.0f, 1.0f) is returned
  647.     if g1 <  g2, then (0.0f, 1.0f) is returned
  648.     if g1 >  g2, then (1.0f, 0.0f) is returned
  649.    
  650.     In other words, we permit actors in higher groups to be pushed around by actors in lower groups by default.
  651.        
  652.     These settings should cover most applications, and in fact not overriding these settings may likely result in higher performance.
  653.    
  654.     It is not possible to make the matrix asymetric, or to change the diagonal.  In other words:
  655.    
  656.     * it is not possible to change (g1, g2) if (g1==g2)
  657.     * if you set
  658.    
  659.     (g1, g2) to X, then (g2, g1) will implicitly and automatically be set to ~X, where:
  660.    
  661.     ~(1.0f, 1.0f) is (1.0f, 1.0f)
  662.     ~(0.0f, 1.0f) is (1.0f, 0.0f)
  663.     ~(1.0f, 0.0f) is (0.0f, 1.0f)
  664.    
  665.     These two restrictions are to make sure that constraints between two actors will always evaluate to the same dominance
  666.     setting, regardless of which order the actors are passed to the constraint.
  667.    
  668.     Dominance settings are currently specified as floats 0.0f or 1.0f because in the future we may permit arbitrary
  669.     fractional settings to express 'partly-one-way' interactions.
  670.        
  671.     <b>Sleeping:</b> Does <b>NOT</b> wake actors up automatically.
  672.  
  673.     @see getDominanceGroupPair() PxDominanceGroup PxConstraintDominance PxActor::setDominanceGroup() PxActor::getDominanceGroup()
  674.     */
  675.     virtual void                        setDominanceGroupPair(PxDominanceGroup group1, PxDominanceGroup group2, const PxConstraintDominance& dominance) = 0;
  676.  
  677.     /**
  678.     \brief Samples the dominance matrix.
  679.  
  680.     @see setDominanceGroupPair() PxDominanceGroup PxConstraintDominance PxActor::setDominanceGroup() PxActor::getDominanceGroup()
  681.     */
  682.     virtual PxConstraintDominance       getDominanceGroupPair(PxDominanceGroup group1, PxDominanceGroup group2) const = 0;
  683.  
  684. //@}
  685. /************************************************************************************************/
  686.  
  687. /** @name Enumeration
  688. */
  689. //@{
  690.  
  691.     /**
  692.     \brief Retrieve the number of actors of certain types in the scene.
  693.  
  694.     \param[in] types Combination of actor types.
  695.     \return the number of actors.
  696.  
  697.     @see getActors()
  698.     */
  699.     virtual PxU32                       getNbActors(PxActorTypeSelectionFlags types) const = 0;
  700.  
  701.     /**
  702.     \brief Retrieve an array of all the actors of certain types in the scene.
  703.  
  704.     \param[in] types Combination of actor types to retrieve.
  705.     \param[out] userBuffer The buffer to receive actor pointers.
  706.     \param[in] bufferSize Size of provided user buffer.
  707.     \param[in] startIndex Index of first actor pointer to be retrieved
  708.     \return Number of actors written to the buffer.
  709.  
  710.     @see getNbActors()
  711.     */
  712.     virtual PxU32                       getActors(PxActorTypeSelectionFlags types, PxActor** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const    = 0;
  713.  
  714.     /**
  715.     \brief Queries the PxScene for a list of the PxActors whose transforms have been
  716.     updated during the previous simulation step
  717.  
  718.     Note: PxSceneFlag::eENABLE_ACTIVETRANSFORMS must be set.
  719.     Multiclient behavior: Active transforms now return only the list of active actors owned by the specified client.
  720.  
  721.     \note Do not use this method while the simulation is running. Calls to this method while the simulation is running will be ignored and NULL will be returned.
  722.  
  723.     \param[out] nbTransformsOut The number of transforms returned.
  724.     \param[in] client The client whose actors the caller is interested in.
  725.  
  726.     \return A pointer to the list of PxActiveTransforms generated during the last call to fetchResults().
  727.  
  728.     @see PxActiveTransform
  729.     */
  730.  
  731.     virtual PxActiveTransform*          getActiveTransforms(PxU32& nbTransformsOut, PxClientID client = PX_DEFAULT_CLIENT) = 0;
  732.  
  733.     /**
  734.     \brief Returns the number of articulations in the scene.
  735.  
  736.     \return the number of articulations in this scene.
  737.  
  738.     @see getArticulations()
  739.     */
  740.     virtual PxU32                       getNbArticulations() const = 0;
  741.  
  742.     /**
  743.     \brief Retrieve all the articulations in the scene.
  744.  
  745.     \param[out] userBuffer The buffer to receive articulations pointers.
  746.     \param[in] bufferSize Size of provided user buffer.
  747.     \param[in] startIndex Index of first articulations pointer to be retrieved
  748.     \return Number of articulations written to the buffer.
  749.  
  750.     @see getNbArticulations()
  751.     */
  752.     virtual PxU32                       getArticulations(PxArticulation** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
  753.  
  754.     /**
  755.     \brief Returns the number of constraint shaders in the scene.
  756.  
  757.     \return the number of constraint shaders in this scene.
  758.  
  759.     @see getConstraints()
  760.     */
  761.     virtual PxU32                       getNbConstraints()  const   = 0;
  762.  
  763.     /**
  764.     \brief Retrieve all the constraint shaders in the scene.
  765.  
  766.     \param[out] userBuffer The buffer to receive constraint shader pointers.
  767.     \param[in] bufferSize Size of provided user buffer.
  768.     \param[in] startIndex Index of first constraint pointer to be retrieved
  769.     \return Number of constraint shaders written to the buffer.
  770.  
  771.     @see getNbConstraints()
  772.     */
  773.     virtual PxU32                       getConstraints(PxConstraint** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
  774.  
  775.  
  776. //@}
  777. /************************************************************************************************/
  778.  
  779. /** @name Multiclient
  780. */
  781. //@{
  782.     /**
  783.     \brief Reserves a new client ID.  
  784.    
  785.     PX_DEFAULT_CLIENT is always available as the default clientID.  
  786.     Additional clients are returned by this function.  Clients cannot be released once created.
  787.     An error is reported when more than a supported number of clients (currently 128) are created.
  788.     */
  789.     virtual PxClientID                  createClient() = 0;
  790.  
  791.     /**
  792.     \brief Sets behavior bits for a client.
  793.  
  794.     The behavior bits are a property of a client that determine when it receives callbacks.
  795.     PxU32 is a combo of PxClientBehaviorBit.  
  796.  
  797.     It is permissible to change the behavior for PX_DEFAULT_CLIENT with this call.
  798.     Initially all created clients, as well as PX_DEFAULT_CLIENT have all bits set to 0.
  799.  
  800.     Note that in addition to setting a client to listen to a particular foreign actor event type,
  801.     the user must also configure actors to send that particular event type to foreign clients
  802.     using PxActor::setClientBehaviorBits().
  803.  
  804.     @see PxClientBehaviorBit PxClientID createClient() getClientBehaviorBits() PxActor::setClientBehaviorBits()
  805.     */
  806.     virtual void                        setClientBehaviorBits(PxClientID client, PxU32 clientBehaviorBits) = 0;
  807.  
  808.     /**
  809.     \brief Retrieves behavior bits for a client.
  810.  
  811.     @see PxClientBehaviorBit PxClientID setClientBehaviorBits() createClient()
  812.     */
  813.     virtual PxU32                       getClientBehaviorBits(PxClientID client) const = 0;
  814. //@}
  815. /************************************************************************************************/
  816.  
  817. /** @name Callbacks
  818. */
  819. //@{
  820.  
  821.     /**
  822.     \brief Sets a user notify object which receives special simulation events when they occur.
  823.  
  824.     Multiclient behavior: Unlike the PxSimulationEventCallback that can be specified in the PxSceneDesc, this method
  825.     lets the user associate additional callbacks with clients other than PX_DEFAULT_CLIENT.  This way
  826.     each client can register its own callback class.  Each callback function has a somewhat differnt
  827.     way of determining which clients' callbacks will be called in a certain event.  Refer to the documentation
  828.     of particular callback functions inside PxSimulationEventCallback for this information.
  829.  
  830.     \note Do not set the callback while the simulation is running. Calls to this method while the simulation is running will be ignored.
  831.  
  832.     \param[in] callback User notification callback. See #PxSimulationEventCallback.
  833.     \param[in] client The client to be associated with this callback.
  834.  
  835.     @see PxSimulationEventCallback getSimulationEventCallback
  836.     */
  837.     virtual void                        setSimulationEventCallback(PxSimulationEventCallback* callback, PxClientID client = PX_DEFAULT_CLIENT) = 0;
  838.  
  839.     /**
  840.     \brief Retrieves the simulationEventCallback pointer set with setSimulationEventCallback().
  841.  
  842.     \param[in] client The client whose callback object is to be returned.
  843.     \return The current user notify pointer. See #PxSimulationEventCallback.
  844.  
  845.     @see PxSimulationEventCallback setSimulationEventCallback()
  846.     */
  847.     virtual PxSimulationEventCallback*  getSimulationEventCallback(PxClientID client = PX_DEFAULT_CLIENT) const = 0;
  848.  
  849.     /**
  850.     \brief Sets a user callback object, which receives callbacks on all contacts generated for specified actors.
  851.  
  852.     \note Do not set the callback while the simulation is running. Calls to this method while the simulation is running will be ignored.
  853.  
  854.     \param[in] callback Asynchronous user contact modification callback. See #PxContactModifyCallback.
  855.     */
  856.     virtual void                        setContactModifyCallback(PxContactModifyCallback* callback) = 0;
  857.  
  858.     /**
  859.     \brief Retrieves the PxContactModifyCallback pointer set with setContactModifyCallback().
  860.  
  861.     \return The current user contact modify callback pointer. See #PxContactModifyCallback.
  862.  
  863.     @see PxContactModifyCallback setContactModifyCallback()
  864.     */
  865.     virtual PxContactModifyCallback*    getContactModifyCallback() const = 0;
  866.  
  867. //@}
  868. /************************************************************************************************/
  869.  
  870. /** @name Collision Filtering
  871. */
  872. //@{
  873.  
  874.     /**
  875.     \brief Gets the shared global filter data in use for this scene.
  876.  
  877.     \note The reference points to a copy of the original filter data specified in PxSceneDesc.filterShaderData.
  878.  
  879.     \return Shared filter data for filter shader.
  880.  
  881.     @see getFilterShaderDataSize() PxSceneDesc.filterShaderData PxSimulationFilterShader
  882.     */
  883.     virtual const void*                 getFilterShaderData() const = 0;
  884.  
  885.     /**
  886.     \brief Gets the size of the shared global filter data (#PxSceneDesc.filterShaderData)
  887.  
  888.     \return Size of shared filter data [bytes].
  889.  
  890.     @see getFilterShaderData() PxSceneDesc.filterShaderDataSize PxSimulationFilterShader
  891.     */
  892.     virtual PxU32                       getFilterShaderDataSize() const = 0;
  893.  
  894.     /**
  895.     \brief Gets the custom collision filter shader in use for this scene.
  896.  
  897.     \return Filter shader class that defines the collision pair filtering.
  898.  
  899.     @see PxSceneDesc.filterShader PxSimulationFilterShader
  900.     */
  901.     virtual PxSimulationFilterShader    getFilterShader() const = 0;
  902.  
  903.     /**
  904.     \brief Gets the custom collision filter callback in use for this scene.
  905.  
  906.     \return Filter callback class that defines the collision pair filtering.
  907.  
  908.     @see PxSceneDesc.filterCallback PxSimulationFilterCallback
  909.     */
  910.     virtual PxSimulationFilterCallback* getFilterCallback() const = 0;
  911.  
  912. //@}
  913.  
  914. /************************************************************************************************/
  915.  
  916. /** @name Scene Query
  917. */
  918. //@{
  919.  
  920.  
  921.     /**
  922.     \brief Creates a BatchQuery object.
  923.  
  924.     Scene queries like raycasts, overlap tests and sweeps are batched in this object and are then executed at once. See #PxBatchQuery.
  925.  
  926.     \param[in] desc The descriptor of scene query. Scene Queries need to register a callback. See #PxBatchQueryDesc.
  927.  
  928.     @see PxBatchQuery PxBatchQueryDesc
  929.     */
  930.     virtual PxBatchQuery*               createBatchQuery(const PxBatchQueryDesc& desc) = 0;
  931.  
  932.     /**
  933.     \brief Creates a sweep cache, for use with PxBatchQuery::linearCompoundGeometrySweepMultiple(). See the Guide, "Sweep API" section for more information.
  934.  
  935.     \param[in] dimensions the dimensions of the sweep cache. Objects within this distance of the swept volume will be cached
  936.  
  937.     @see PxSweepCache PxBatchQuery
  938.     */
  939.     PX_DEPRECATED   virtual PxSweepCache*               createSweepCache(PxReal dimensions = 5.0f) = 0;
  940.  
  941.     /**
  942.     \brief Sets the rebuild rate of the dynamic tree pruning structure.
  943.  
  944.     \param[in] dynamicTreeRebuildRateHint Rebuild rate of the dynamic tree pruning structure.
  945.  
  946.     @see PxSceneDesc.dynamicTreeRebuildRateHint getDynamicTreeRebuildRateHint()
  947.     */
  948.     virtual void                        setDynamicTreeRebuildRateHint(PxU32 dynamicTreeRebuildRateHint) = 0;
  949.  
  950.     /**
  951.     \brief Retrieves the rebuild rate of the dynamic tree pruning structure.
  952.  
  953.     \return The rebuild rate of the dyamic tree pruning structure.
  954.  
  955.     @see PxSceneDesc.dynamicTreeRebuildRateHint setDynamicTreeRebuildRateHint()
  956.     */
  957.     virtual PxU32                       getDynamicTreeRebuildRateHint() const = 0;
  958.  
  959.  
  960.     /**
  961.     \brief Raycast returning any blocking hit, not necessarily the closest.
  962.    
  963.     Returns whether any rigid actor is hit along the ray.
  964.  
  965.     \note Shooting a ray from within an object leads to different results depending on the shape type. Please check the details in article SceneQuery. User can ignore such objects by using one of the provided filter mechanisms.
  966.  
  967.     \param[in] origin       Origin of the ray.
  968.     \param[in] unitDir      Normalized direction of the ray.
  969.     \param[in] distance     Length of the ray. Needs to be larger than 0.
  970.     \param[out] hit         Raycast hit information.
  971.     \param[in] filterData   Filtering data and simple logic.
  972.     \param[in] filterCall   Custom filtering logic (optional). Only used if the corresponding #PxSceneQueryFilterFlag flags are set. If NULL, all hits are assumed to be blocking.
  973.     \param[in] cache        Cached hit shape (optional). Ray is tested against cached shape first. If no hit is found the ray gets queried against the scene.
  974.                             Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit.
  975.     \param[in] queryClient  ID of the client doing the query (see #createClient())
  976.     \return True if a blocking hit was found.
  977.  
  978.     @see PxSceneQueryFilterData PxSceneQueryFilterCallback PxSceneQueryCache PxSceneQueryHit
  979.     */
  980.     virtual bool raycastAny(const PxVec3& origin, const PxVec3& unitDir, const PxReal distance,
  981.                             PxSceneQueryHit& hit,
  982.                             const PxSceneQueryFilterData& filterData = PxSceneQueryFilterData(),
  983.                             PxSceneQueryFilterCallback* filterCall = NULL,
  984.                             const PxSceneQueryCache* cache = NULL,
  985.                             PxClientID queryClient = PX_DEFAULT_CLIENT) const = 0;
  986.  
  987.     /**
  988.     \brief Raycast returning a single result.
  989.    
  990.     Returns the first rigid actor that is hit along the ray. Data for a blocking hit will be returned as specified by the outputFlags field. Touching hits will be ignored.
  991.  
  992.     \note Shooting a ray from within an object leads to different results depending on the shape type. Please check the details in article SceneQuery. User can ignore such objects by using one of the provided filter mechanisms.
  993.  
  994.     \param[in] origin       Origin of the ray.
  995.     \param[in] unitDir      Normalized direction of the ray.
  996.     \param[in] distance     Length of the ray. Needs to be larger than 0.
  997.     \param[in] outputFlags  Specifies which properties should be written to the hit information
  998.     \param[out] hit         Raycast hit information.
  999.     \param[in] filterData   Filtering data and simple logic.
  1000.     \param[in] filterCall   Custom filtering logic (optional). Only used if the corresponding #PxSceneQueryFilterFlag flags are set. If NULL, all hits are assumed to be blocking.
  1001.     \param[in] cache        Cached hit shape (optional). Ray is tested against cached shape first then against the scene.
  1002.                             Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit.
  1003.     \param[in] queryClient  ID of the client doing the query (see #createClient())
  1004.     \return True if a blocking hit was found.
  1005.  
  1006.     @see PxSceneQueryFlags PxRaycastHit PxSceneQueryFilterData PxSceneQueryFilterCallback PxSceneQueryCache
  1007.     */
  1008.     virtual bool raycastSingle(const PxVec3& origin, const PxVec3& unitDir, const PxReal distance,
  1009.                                PxSceneQueryFlags outputFlags,
  1010.                                PxRaycastHit& hit,
  1011.                                const PxSceneQueryFilterData& filterData = PxSceneQueryFilterData(),
  1012.                                PxSceneQueryFilterCallback* filterCall = NULL,
  1013.                                const PxSceneQueryCache* cache = NULL,
  1014.                                PxClientID queryClient = PX_DEFAULT_CLIENT) const = 0;
  1015.  
  1016.     /**
  1017.     \brief Raycast returning multiple results.
  1018.    
  1019.     Find all rigid actors that get hit along the ray. Each result contains data as specified by the outputFlags field.
  1020.  
  1021.     \note Touching hits are not ordered.
  1022.  
  1023.     \note Shooting a ray from within an object leads to different results depending on the shape type. Please check the details in article SceneQuery. User can ignore such objects by using one of the provided filter mechanisms.
  1024.  
  1025.     \param[in] origin           Origin of the ray.
  1026.     \param[in] unitDir          Normalized direction of the ray.
  1027.     \param[in] distance         Length of the ray. Needs to be larger than 0.
  1028.     \param[in] outputFlags      Specifies which properties should be written to the hit information
  1029.     \param[out] hitBuffer       Raycast hit information buffer. If the buffer overflows, the blocking hit is returned as the last entry together with an arbitrary subset
  1030.                                 of the nearer touching hits (typically the query should be restarted with a larger buffer).
  1031.     \param[in] hitBufferSize    Size of the hit buffer.
  1032.     \param[out] blockingHit     True if a blocking hit was found. If found, it is the last in the buffer, preceded by any touching hits which are closer. Otherwise the touching hits are listed.
  1033.     \param[in] filterData       Filtering data and simple logic.
  1034.     \param[in] filterCall       Custom filtering logic (optional). Only used if the corresponding #PxSceneQueryFilterFlag flags are set. If NULL, all hits are assumed to be touching.
  1035.     \param[in] cache            Cached hit shape (optional). Ray is tested against cached shape first then against the scene.
  1036.                                 Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit.
  1037.     \param[in] queryClient      ID of the client doing the query (see #createClient())
  1038.     \return Number of hits in the buffer, or -1 if the buffer overflowed.
  1039.  
  1040.     @see PxSceneQueryFlags PxRaycastHit PxSceneQueryFilterData PxSceneQueryFilterCallback PxSceneQueryCache
  1041.     */
  1042.     virtual PxI32 raycastMultiple(const PxVec3& origin, const PxVec3& unitDir, const PxReal distance,
  1043.                                   PxSceneQueryFlags outputFlags,
  1044.                                   PxRaycastHit* hitBuffer,
  1045.                                   PxU32 hitBufferSize,
  1046.                                   bool& blockingHit,
  1047.                                   const PxSceneQueryFilterData& filterData = PxSceneQueryFilterData(),
  1048.                                   PxSceneQueryFilterCallback* filterCall = NULL,
  1049.                                   const PxSceneQueryCache* cache = NULL,
  1050.                                   PxClientID queryClient = PX_DEFAULT_CLIENT) const = 0;
  1051.    
  1052.     /**
  1053.     \brief Sweep returning any blocking hit, not necessarily the closest.
  1054.    
  1055.     Returns whether any rigid actor is hit along the sweep path.
  1056.  
  1057.     \note If a shape from the scene is already overlapping with the query shape in its starting position, behavior is controlled by the PxSceneQueryFlag::eINITIAL_OVERLAP flag.
  1058.  
  1059.     \param[in] geometry     Geometry of object to sweep (supported types are: box, sphere, capsule, convex).
  1060.     \param[in] pose         Pose of the sweep object.
  1061.     \param[in] unitDir      Normalized direction of the sweep.
  1062.     \param[in] distance     Sweep distance. Needs to be larger than 0. Will be clamped to PX_MAX_SWEEP_DISTANCE.
  1063.     \param[in] queryFlags   Combination of PxSceneQueryFlag defining the query behavior
  1064.     \param[out] hit         Sweep hit information.
  1065.     \param[in] filterData   Filtering data and simple logic.
  1066.     \param[in] filterCall   Custom filtering logic (optional). Only used if the corresponding #PxSceneQueryFilterFlag flags are set. If NULL, all hits are assumed to be blocking.
  1067.     \param[in] cache        Cached hit shape (optional). Sweep is performed against cached shape first. If no hit is found the sweep gets queried against the scene.
  1068.                             Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit.
  1069.     \param[in] queryClient  ID of the client doing the query (see #createClient())
  1070.     \param[in] inflation    This parameter creates a skin around the swept geometry which increases its extents for sweeping. The sweep will register a hit as soon as the skin touches a shape, and will return the corresponding distance and normal.
  1071.     \return True if a blocking hit was found.
  1072.  
  1073.     @see PxSceneQueryFilterData PxSceneQueryFilterCallback PxSceneQueryHit PxSceneQueryCache
  1074.     */
  1075.     virtual bool sweepAny(  const PxGeometry& geometry, const PxTransform& pose, const PxVec3& unitDir, const PxReal distance,
  1076.                             PxSceneQueryFlags queryFlags,
  1077.                             PxSceneQueryHit& hit,
  1078.                             const PxSceneQueryFilterData& filterData = PxSceneQueryFilterData(),
  1079.                             PxSceneQueryFilterCallback* filterCall = NULL,
  1080.                             const PxSceneQueryCache* cache = NULL,
  1081.                             PxClientID queryClient = PX_DEFAULT_CLIENT,
  1082.                             const PxReal inflation = 0.f) const = 0;
  1083.  
  1084.     /**
  1085.     \brief Sweep of geometry compound returning any blocking hit, not necessarily the closest.
  1086.    
  1087.     The function sweeps all specified geometry objects through space and returns whether any rigid actor is hit along the sweep path.
  1088.  
  1089.     \note If a shape from the scene is already overlapping with the query shape in its starting position, behavior is controlled by the PxSceneQueryFlag::eINITIAL_OVERLAP flag.
  1090.  
  1091.     \param[in] geometryList     Geometries of objects to sweep (supported types are: box, sphere, capsule, convex).
  1092.     \param[in] poseList         The world pose for each geometry object.
  1093.     \param[in] filterDataList   Filter data for each geometry object. NULL, if no filtering should be done, all hits are assumed to be blocking in that case.
  1094.     \param[in] geometryCount    Number of geometry objects specified.
  1095.     \param[in] unitDir          Normalized direction of the sweep.
  1096.     \param[in] distance         Sweep distance. Needs to be larger than 0. Will be clamped to PX_MAX_SWEEP_DISTANCE.
  1097.     \param[in] queryFlags       Combination of PxSceneQueryFlag defining the query behavior
  1098.     \param[out] hit             Sweep hit information.
  1099.     \param[in] filterFlags      Simple filter logic.
  1100.     \param[in] filterCall       Custom filtering logic (optional). Only used if the corresponding #PxSceneQueryFilterFlag flags are set. If NULL, all hits are assumed to be blocking.
  1101.     \param[in] cache            Cached hit shape (optional). Sweep is performed against cached shape first. If no hit is found the sweep gets queried against the scene.
  1102.                                 Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit.
  1103.     \param[in] queryClient      ID of the client doing the query (see #createClient())
  1104.     \param[in] inflation    This parameter creates a skin around the swept geometry which increases its extents for sweeping. The sweep will register a hit as soon as the skin touches a shape, and will return the corresponding distance and normal.
  1105.     \return True if a blocking hit was found.
  1106.  
  1107.     @see PxSceneQueryFilterData PxSceneQueryFilterCallback PxSceneQueryHit PxSceneQueryCache
  1108.     */
  1109.     virtual bool sweepAny(  const PxGeometry** geometryList, const PxTransform* poseList, const PxFilterData* filterDataList, PxU32 geometryCount,
  1110.                             const PxVec3& unitDir, const PxReal distance,
  1111.                             PxSceneQueryFlags queryFlags,
  1112.                             PxSceneQueryHit& hit,
  1113.                             PxSceneQueryFilterFlags filterFlags = PxSceneQueryFilterFlag::eDYNAMIC | PxSceneQueryFilterFlag::eSTATIC,
  1114.                             PxSceneQueryFilterCallback* filterCall = NULL,
  1115.                             const PxSceneQueryCache* cache = NULL,
  1116.                             PxClientID queryClient = PX_DEFAULT_CLIENT,
  1117.                             const PxReal inflation = 0.f) const = 0;
  1118.  
  1119.     /**
  1120.     \brief Sweep returning a single result.
  1121.    
  1122.     Returns the first rigid actor that is hit along the ray. Data for a blocking hit will be returned as specified by the outputFlags field. Touching hits will be ignored.
  1123.  
  1124.     \note If a shape from the scene is already overlapping with the query shape in its starting position, behavior is controlled by the PxSceneQueryFlag::eINITIAL_OVERLAP flag.
  1125.  
  1126.     \param[in] geometry     Geometry of object to sweep (supported types are: box, sphere, capsule, convex).
  1127.     \param[in] pose         Pose of the sweep object.
  1128.     \param[in] unitDir      Normalized direction of the sweep.
  1129.     \param[in] distance     Sweep distance. Needs to be larger than 0. Will be clamped to PX_MAX_SWEEP_DISTANCE.
  1130.     \param[in] outputFlags  Specifies which properties should be written to the hit information.
  1131.     \param[out] hit         Sweep hit information.
  1132.     \param[in] filterData   Filtering data and simple logic.
  1133.     \param[in] filterCall   Custom filtering logic (optional). Only used if the corresponding #PxSceneQueryFilterFlag flags are set. If NULL, all hits are assumed to be blocking.
  1134.     \param[in] cache        Cached hit shape (optional). Sweep is performed against cached shape first then against the scene.
  1135.                             Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit.
  1136.     \param[in] queryClient  ID of the client doing the query (see #createClient())
  1137.     \param[in] inflation    This parameter creates a skin around the swept geometry which increases its extents for sweeping. The sweep will register a hit as soon as the skin touches a shape, and will return the corresponding distance and normal.
  1138.     \return True if a blocking hit was found.
  1139.  
  1140.     @see PxSceneQueryFlags PxSweepHit PxSceneQueryFilterData PxSceneQueryFilterCallback PxSceneQueryCache
  1141.     */
  1142.     virtual bool sweepSingle(   const PxGeometry& geometry, const PxTransform& pose, const PxVec3& unitDir, const PxReal distance,
  1143.                                 PxSceneQueryFlags outputFlags,
  1144.                                 PxSweepHit& hit,
  1145.                                 const PxSceneQueryFilterData& filterData = PxSceneQueryFilterData(),
  1146.                                 PxSceneQueryFilterCallback* filterCall = NULL,
  1147.                                 const PxSceneQueryCache* cache = NULL,
  1148.                                 PxClientID queryClient = PX_DEFAULT_CLIENT,
  1149.                                 const PxReal inflation =0.f) const = 0;
  1150.  
  1151.     /**
  1152.     \brief Sweep of geometry compound returning a single result.
  1153.    
  1154.     The function sweeps all specified geometry objects through space and returns the first rigid actor that is hit along the ray.
  1155.     Data for a blocking hit will be returned as specified by the outputFlags field. Touching hits will be ignored.
  1156.  
  1157.     \note If a shape from the scene is already overlapping with the query shape in its starting position, behavior is controlled by the PxSceneQueryFlag::eINITIAL_OVERLAP flag.
  1158.  
  1159.     \param[in] geometryList     Geometries of objects to sweep (supported types are: box, sphere, capsule, convex).
  1160.     \param[in] poseList         The world pose for each geometry object.
  1161.     \param[in] filterDataList   Filter data for each geometry object. NULL, if no filtering should be done, all hits are assumed to be blocking in that case.
  1162.     \param[in] geometryCount    Number of geometry objects specified.
  1163.     \param[in] unitDir          Normalized direction of the sweep.
  1164.     \param[in] distance         Sweep distance. Needs to be larger than 0. Will be clamped to PX_MAX_SWEEP_DISTANCE.
  1165.     \param[in] outputFlags      Specifies which properties should be written to the hit information.
  1166.     \param[out] hit             Sweep hit information.
  1167.     \param[in] filterFlags      Simple filter logic.
  1168.     \param[in] filterCall       Custom filtering logic (optional). Only used if the corresponding #PxSceneQueryFilterFlag flags are set. If NULL, all hits are assumed to be blocking.
  1169.     \param[in] cache            Cached hit shape (optional). Sweep is performed against cached shape first then against the scene.
  1170.                                 Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit.
  1171.     \param[in] queryClient      ID of the client doing the query (see #createClient())
  1172.     \param[in] inflation        This parameter creates a skin around the swept geometry which increases its extents for sweeping. The sweep will register a hit as soon as the skin touches a shape, and will return the corresponding distance and normal.
  1173.     \return True if a blocking hit was found.
  1174.  
  1175.     @see PxSceneQueryFlags PxSweepHit PxSceneQueryFilterData PxSceneQueryFilterCallback PxSceneQueryCache
  1176.     */
  1177.     virtual bool sweepSingle(   const PxGeometry** geometryList, const PxTransform* poseList, const PxFilterData* filterDataList, PxU32 geometryCount,
  1178.                                 const PxVec3& unitDir, const PxReal distance,
  1179.                                 PxSceneQueryFlags outputFlags,
  1180.                                 PxSweepHit& hit,
  1181.                                 PxSceneQueryFilterFlags filterFlags = PxSceneQueryFilterFlag::eDYNAMIC | PxSceneQueryFilterFlag::eSTATIC,
  1182.                                 PxSceneQueryFilterCallback* filterCall = NULL,
  1183.                                 const PxSceneQueryCache* cache = NULL,
  1184.                                 PxClientID queryClient = PX_DEFAULT_CLIENT,
  1185.                                 const PxReal inflation = 0.f) const = 0;
  1186.  
  1187.     /**
  1188.     \brief Sweep returning multiple results.
  1189.    
  1190.     Find all rigid actors that get hit along the sweep. Each result contains data as specified by the outputFlags field.
  1191.  
  1192.     \note Touching hits are not ordered.
  1193.  
  1194.     \note If a shape from the scene is already overlapping with the query shape in its starting position, behavior is controlled by the PxSceneQueryFlag::eINITIAL_OVERLAP flag.
  1195.  
  1196.     \param[in] geometry         Geometry of object to sweep (supported types are: box, sphere, capsule, convex).
  1197.     \param[in] pose             Pose of the sweep object.
  1198.     \param[in] unitDir          Normalized direction of the sweep.
  1199.     \param[in] distance         Sweep distance. Needs to be larger than 0. Will be clamped to PX_MAX_SWEEP_DISTANCE.
  1200.     \param[in] outputFlags      Specifies which properties should be written to the hit information.
  1201.     \param[out] hitBuffer       Sweep hit information buffer. If the buffer overflows, the blocking hit is returned as the last entry together with an arbitrary subset
  1202.                                 of the nearer touching hits (typically the query should be restarted with a larger buffer).
  1203.     \param[in] hitBufferSize    Size of the hit buffer.
  1204.     \param[out] blockingHit     True if a blocking hit was found. If found, it is the last in the buffer, preceded by any touching hits which are closer. Otherwise the touching hits are listed.
  1205.     \param[in] filterData       Filtering data and simple logic.
  1206.     \param[in] filterCall       Custom filtering logic (optional). Only used if the corresponding #PxSceneQueryFilterFlag flags are set. If NULL, all hits are assumed to be touching.
  1207.     \param[in] cache            Cached hit shape (optional). Sweep is performed against cached shape first then against the scene.
  1208.                                 Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit.
  1209.     \param[in] queryClient      ID of the client doing the query (see #createClient())
  1210.     \param[in] inflation        This parameter creates a skin around the swept geometry which increases its extents for sweeping. The sweep will register a hit as soon as the skin touches a shape, and will return the corresponding distance and normal.
  1211.     \return Number of hits in the buffer, or -1 if the buffer overflowed.
  1212.  
  1213.     @see PxSceneQueryFlags PxSweepHit PxSceneQueryFilterData PxSceneQueryFilterCallback PxSceneQueryCache
  1214.     */
  1215.     virtual PxI32 sweepMultiple(    const PxGeometry& geometry, const PxTransform& pose, const PxVec3& unitDir, const PxReal distance,
  1216.                                     PxSceneQueryFlags outputFlags,
  1217.                                     PxSweepHit* hitBuffer,
  1218.                                     PxU32 hitBufferSize,
  1219.                                     bool& blockingHit,
  1220.                                     const PxSceneQueryFilterData& filterData = PxSceneQueryFilterData(),
  1221.                                     PxSceneQueryFilterCallback* filterCall = NULL,
  1222.                                     const PxSceneQueryCache* cache = NULL,
  1223.                                     PxClientID queryClient = PX_DEFAULT_CLIENT,
  1224.                                     const PxReal inflation = 0.f) const = 0;
  1225.  
  1226.     /**
  1227.     \brief Sweep of geometry compound returning multiple results.
  1228.    
  1229.     The function sweeps all specified geometry objects through space and finds all rigid actors that get hit along the sweep.
  1230.     Each result contains data as specified by the outputFlags field.
  1231.  
  1232.     \note Touching hits are not ordered.
  1233.  
  1234.     \note If a shape from the scene is already overlapping with the query shape in its starting position, behavior is controlled by the PxSceneQueryFlag::eINITIAL_OVERLAP flag.
  1235.  
  1236.     \param[in] geometryList     Geometries of objects to sweep (supported types are: box, sphere, capsule, convex).
  1237.     \param[in] poseList         The world pose for each geometry object.
  1238.     \param[in] filterDataList   Filter data for each geometry object. NULL, if no filtering should be done, all hits are assumed to be blocking in that case.
  1239.     \param[in] geometryCount    Number of geometry objects specified.
  1240.     \param[in] unitDir          Normalized direction of the sweep.
  1241.     \param[in] distance         Sweep distance. Needs to be larger than 0. Will be clamped to PX_MAX_SWEEP_DISTANCE.
  1242.     \param[in] outputFlags      Specifies which properties should be written to the hit information.
  1243.     \param[out] hitBuffer       Sweep hit information buffer. If the buffer overflows, the blocking hit is returned as the last entry together with an arbitrary subset
  1244.                                 of the nearer touching hits (typically the query should be restarted with a larger buffer).
  1245.     \param[in] hitBufferSize    Size of the hit buffer.
  1246.     \param[out] blockingHit     True if a blocking hit was found. If found, it is the last in the buffer, preceded by any touching hits which are closer. Otherwise the touching hits are listed.
  1247.     \param[in] filterFlags      Simple filter logic.
  1248.     \param[in] filterCall       Custom filtering logic (optional). Only used if the corresponding #PxSceneQueryFilterFlag flags are set. If NULL, all hits are assumed to be touching.
  1249.     \param[in] cache            Cached hit shape (optional). Sweep is performed against cached shape first then against the scene.
  1250.                                 Note: Filtering is not executed for a cached shape if supplied; instead, if a hit is found, it is assumed to be a blocking hit.
  1251.     \param[in] queryClient      ID of the client doing the query (see #createClient())
  1252.     \param[in] inflation        This parameter creates a skin around the swept geometry which increases its extents for sweeping. The sweep will register a hit as soon as the skin touches a shape, and will return the corresponding distance and normal.
  1253.     \return Number of hits in the buffer, or -1 if the buffer overflowed.
  1254.  
  1255.     @see PxSceneQueryFlags PxSweepHit PxSceneQueryFilterData PxSceneQueryFilterCallback PxSceneQueryCache
  1256.     */
  1257.     virtual PxI32 sweepMultiple(const PxGeometry** geometryList, const PxTransform* poseList, const PxFilterData* filterDataList, PxU32 geometryCount,
  1258.                                 const PxVec3& unitDir, const PxReal distance,
  1259.                                 PxSceneQueryFlags outputFlags,
  1260.                                 PxSweepHit* hitBuffer,
  1261.                                 PxU32 hitBufferSize,
  1262.                                 bool& blockingHit,
  1263.                                 PxSceneQueryFilterFlags filterFlags = PxSceneQueryFilterFlag::eDYNAMIC | PxSceneQueryFilterFlag::eSTATIC,
  1264.                                 PxSceneQueryFilterCallback* filterCall = NULL,
  1265.                                 const PxSceneQueryCache* cache = NULL,
  1266.                                 PxClientID queryClient = PX_DEFAULT_CLIENT,
  1267.                                 const PxReal inflation = 0.f) const = 0;
  1268.  
  1269.  
  1270.     /**
  1271.     \brief Test overlap between a geometry and objects in the scene.
  1272.    
  1273.     \note Filtering: Overlap tests do not distinguish between touching and blocking hit types (see #PxSceneQueryHitType). Both get written to the hit buffer.
  1274.  
  1275.     \note PxSceneQueryFilterFlag::eMESH_MULTIPLE and PxSceneQueryFilterFlag::eBACKFACE have no effect in this case
  1276.  
  1277.     \param[in] geometry         Geometry of object to check for overlap (supported types are: box, sphere, capsule, convex).
  1278.     \param[in] pose             Pose of the object.
  1279.     \param[out] hitBuffer       Buffer to store the overlapping objects to. If the buffer overflows, an arbitrary subset of overlapping objects is stored (typically the query should be restarted with a larger buffer).
  1280.     \param[in] hitBufferSize    Size of the hit buffer.
  1281.     \param[in] filterData       Filtering data and simple logic.
  1282.     \param[in] filterCall       Custom filtering logic (optional). Only used if the corresponding #PxSceneQueryFilterFlag flags are set. If NULL, all hits are assumed to overlap.
  1283.     \param[in] queryClient      ID of the client doing the query (see #createClient())
  1284.     \return Number of hits in the buffer, or -1 if the buffer overflowed.
  1285.  
  1286.     @see PxSceneQueryFlags PxSceneQueryFilterData PxSceneQueryFilterCallback
  1287.     */
  1288.     virtual PxI32 overlapMultiple(  const PxGeometry& geometry,
  1289.                                     const PxTransform& pose,
  1290.                                     PxShape** hitBuffer,
  1291.                                     PxU32 hitBufferSize,
  1292.                                     const PxSceneQueryFilterData& filterData = PxSceneQueryFilterData(),
  1293.                                     PxSceneQueryFilterCallback* filterCall = NULL,
  1294.                                     PxClientID queryClient = PX_DEFAULT_CLIENT) const = 0;
  1295.  
  1296.     /**
  1297.     \brief Test returning, for a given geometry, any overlapping object in the scene.
  1298.    
  1299.     \note Filtering: Overlap tests do not distinguish between touching and blocking hit types (see #PxSceneQueryHitType). Both trigger a hit.
  1300.  
  1301.     \note PxSceneQueryFilterFlag::eMESH_MULTIPLE and PxSceneQueryFilterFlag::eBACKFACE have no effect in this case
  1302.    
  1303.     \param[in] geometry         Geometry of object to check for overlap (supported types are: box, sphere, capsule, convex).
  1304.     \param[in] pose             Pose of the object.
  1305.     \param[out] hit             Pointer to store the overlapping object to.
  1306.     \param[in] filterData       Filtering data and simple logic.
  1307.     \param[in] filterCall       Custom filtering logic (optional). Only used if the corresponding #PxSceneQueryFilterFlag flags are set. If NULL, all hits are assumed to overlap.
  1308.     \param[in] queryClient      ID of the client doing the query (see #createClient())
  1309.     \return True if an overlap was found.
  1310.  
  1311.     @see PxSceneQueryFlags PxSceneQueryFilterData PxSceneQueryFilterCallback
  1312.     */
  1313.     PX_INLINE bool overlapAny(const PxGeometry& geometry,
  1314.                             const PxTransform& pose,
  1315.                             PxShape*& hit,
  1316.                             const PxSceneQueryFilterData& filterData = PxSceneQueryFilterData(),
  1317.                             PxSceneQueryFilterCallback* filterCall = NULL,
  1318.                             PxClientID queryClient = PX_DEFAULT_CLIENT) const
  1319.     {
  1320.         return overlapMultiple(geometry, pose, &hit, 1, filterData, filterCall, queryClient) != 0 ? true : false;
  1321.     }
  1322.  
  1323. //@}
  1324.  
  1325. /************************************************************************************************/
  1326.  
  1327. /** @name Visualization and Statistics
  1328. */
  1329. //@{
  1330.    
  1331.     /**
  1332.     \brief Function that lets you set debug visualization parameters.
  1333.  
  1334.     Returns false if the value passed is out of range for usage specified by the enum.
  1335.  
  1336.     \param[in] param    Parameter to set. See #PxVisualizationParameter
  1337.     \param[in] value    The value to set, see #PxVisualizationParameter for allowable values.
  1338.     \return False if the parameter is out of range.
  1339.  
  1340.     @see getVisualizationParameter PxVisualizationParameter
  1341.     */
  1342.     virtual bool setVisualizationParameter(PxVisualizationParameter::Enum param, PxReal value) = 0;
  1343.  
  1344.     /**
  1345.     \brief Function that lets you query debug visualization parameters.
  1346.  
  1347.     \param[in] paramEnum The Parameter to retrieve.
  1348.     \return The value of the parameter.
  1349.  
  1350.     @see setVisualizationParameter PxVisualizationParameter
  1351.     */
  1352.     virtual PxReal getVisualizationParameter(PxVisualizationParameter::Enum paramEnum) const = 0;
  1353.  
  1354.  
  1355.     virtual void setVisualizationCullingBox(const PxBounds3& box) = 0;
  1356.     virtual const PxBounds3& getVisualizationCullingBox() const = 0;
  1357.  
  1358.     /**
  1359.     \brief Retrieves the render buffer.
  1360.    
  1361.     This will contain the results of any active visualization for this scene.
  1362.  
  1363.     \note Do not use this method while the simulation is running. Calls to this method while result in undefined behaviour.
  1364.  
  1365.     \return The render buffer.
  1366.  
  1367.     @see PxRenderBuffer
  1368.     */
  1369.     virtual const PxRenderBuffer&   getRenderBuffer() = 0;
  1370.  
  1371.    
  1372.     /**
  1373.     \brief Call this method to retrieve statistics for the current simulation step.
  1374.  
  1375.     \note Do not use this method while the simulation is running. Calls to this method while the simulation is running will be ignored.
  1376.  
  1377.     \param[out] stats Used to retrieve statistics for the current simulation step.
  1378.  
  1379.     @see PxSimulationStatistics
  1380.     */
  1381.     virtual void                    getSimulationStatistics(PxSimulationStatistics& stats) const = 0;
  1382.  
  1383.     /************************************************************************************************/
  1384.  
  1385.     /** @name Multi-threading
  1386.     */
  1387.     //@{
  1388.  
  1389.     /**
  1390.     \brief Lock the scene for reading from the calling thread.
  1391.  
  1392.     When the PxSceneFlag::eREQUIRE_RW_LOCK flag is enabled lockRead() must be
  1393.     called before any read calls are made on the scene.
  1394.  
  1395.     Multiple threads may read at the same time, no threads may read while a thread is writing.
  1396.     If a call to lockRead() is made while another thread is holding a write lock
  1397.     then the calling thread will be blocked until the writing thread calls unlockWrite().
  1398.  
  1399.     \note Lock upgrading is *not* supported, that means it is an error to
  1400.     call lockRead() followed by lockWrite().
  1401.  
  1402.     \note Recursive locking is supported but each lockRead() call must be paired with an unlockRead().
  1403.  
  1404.     \param file String representing the calling file, for debug purposes
  1405.     \param line The source file line number, for debug purposes
  1406.     */
  1407.     virtual void lockRead(const char* file=NULL, PxU32 line=0) = 0;
  1408.  
  1409.     /**
  1410.     \brief Unlock the scene from reading.
  1411.  
  1412.     \note Each unlockRead() must be paired with a lockRead() from the same thread.
  1413.     */
  1414.     virtual void unlockRead() = 0;
  1415.  
  1416.     /**
  1417.     \brief Lock the scene for writing from this thread.
  1418.  
  1419.     When the PxSceneFlag::eREQUIRE_RW_LOCK flag is enabled lockWrite() must be
  1420.     called before any write calls are made on the scene.
  1421.  
  1422.     Only one thread may write at a time and no threads may read while a thread is writing.
  1423.     If a call to lockWrite() is made and there are other threads reading then the
  1424.     calling thread will be blocked until the readers complete.
  1425.  
  1426.     Writers have priority. If a thread is blocked waiting to write then subsequent calls to
  1427.     lockRead() from other threads will be blocked until the writer completes.
  1428.  
  1429.     \note If multiple threads are waiting to write then the thread that is first
  1430.     granted access depends on OS scheduling.
  1431.  
  1432.     \note Recursive locking is supported but each lockWrite() call must be paired with an unlockWrite().
  1433.  
  1434.     \note Lock 'downgrading' is supported. If a thread has already locked the scene for writing
  1435.     then it may call lockRead() and unlockRead().
  1436.  
  1437.     \param file String representing the calling file, for debug purposes
  1438.     \param line The source file line number, for debug purposes
  1439.     */
  1440.     virtual void lockWrite(const char* file=NULL, PxU32 line=0) = 0;
  1441.  
  1442.     /**
  1443.     \brief Unlock the scene from writing.
  1444.  
  1445.     \note Each unlockWrite() must be paired with a lockWrite() from the same thread.
  1446.     */
  1447.     virtual void unlockWrite() = 0;
  1448.  
  1449.     //@}
  1450. };
  1451.  
  1452. #ifndef PX_DOXYGEN
  1453. } // namespace physx
  1454. #endif
  1455.  
  1456. /** @} */
  1457. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement