PxScene.h

Go to the documentation of this file.
00001 //
00002 // Redistribution and use in source and binary forms, with or without
00003 // modification, are permitted provided that the following conditions
00004 // are met:
00005 //  * Redistributions of source code must retain the above copyright
00006 //    notice, this list of conditions and the following disclaimer.
00007 //  * Redistributions in binary form must reproduce the above copyright
00008 //    notice, this list of conditions and the following disclaimer in the
00009 //    documentation and/or other materials provided with the distribution.
00010 //  * Neither the name of NVIDIA CORPORATION nor the names of its
00011 //    contributors may be used to endorse or promote products derived
00012 //    from this software without specific prior written permission.
00013 //
00014 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
00015 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00016 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00017 // PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
00018 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00019 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00020 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00021 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00022 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00023 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00024 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00025 //
00026 // Copyright (c) 2008-2018 NVIDIA Corporation. All rights reserved.
00027 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
00028 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.  
00029 
00030 
00031 #ifndef PX_PHYSICS_NX_SCENE
00032 #define PX_PHYSICS_NX_SCENE
00033 
00037 #include "PxVisualizationParameter.h"
00038 #include "PxSceneDesc.h"
00039 #include "PxSimulationStatistics.h"
00040 #include "PxQueryReport.h"
00041 #include "PxQueryFiltering.h"
00042 #include "PxClient.h"
00043 #include "task/PxTask.h"
00044 
00045 #if PX_USE_PARTICLE_SYSTEM_API
00046 #include "particles/PxParticleSystem.h"
00047 #include "particles/PxParticleFluid.h"
00048 #endif
00049 
00050 #include "pvd/PxPvdSceneClient.h"
00051 
00052 #if !PX_DOXYGEN
00053 namespace physx
00054 {
00055 #endif
00056 
00057 class PxRigidStatic;
00058 class PxRigidDynamic;
00059 class PxConstraint;
00060 class PxMaterial;
00061 class PxSimulationEventCallback;
00062 class PxPhysics;
00063 class PxBatchQueryDesc;
00064 class PxBatchQuery;
00065 class PxAggregate;
00066 class PxRenderBuffer;
00067 class PxVolumeCache;
00068 
00069 class PxSphereGeometry;
00070 class PxBoxGeometry;
00071 class PxCapsuleGeometry;
00072 
00073 class PxPruningStructure;
00074 struct PxContactPairHeader;
00075 
00076 typedef PxU8 PxDominanceGroup;
00077 
00078 class PxPvdSceneClient;
00079 
00086 struct PX_DEPRECATED PxActiveTransform
00087 {
00088     PxActor*        actor;              
00089     void*           userData;           
00090     PxTransform     actor2World;        
00091 };
00092 
00101 struct PxDominanceGroupPair
00102 {
00103     PxDominanceGroupPair(PxU8 a, PxU8 b) 
00104         : dominance0(a), dominance1(b) {}
00105     PxU8 dominance0;
00106     PxU8 dominance1;
00107 };
00108 
00109 
00117 struct PxActorTypeFlag
00118 {
00119     enum Enum
00120     {
00125         eRIGID_STATIC       = (1 << 0),
00126 
00131         eRIGID_DYNAMIC      = (1 << 1),
00132 
00133 #if PX_USE_PARTICLE_SYSTEM_API
00134 
00139         ePARTICLE_SYSTEM    PX_DEPRECATED = (1 << 2),
00140 
00146         ePARTICLE_FLUID     PX_DEPRECATED = (1 << 3),
00147 #endif
00148 
00149 #if PX_USE_CLOTH_API
00150 
00155         eCLOTH              PX_DEPRECATED = (1 << 5)
00156 #endif
00157     };
00158 };
00159 
00165 typedef PxFlags<PxActorTypeFlag::Enum,PxU16> PxActorTypeFlags;
00166 PX_FLAGS_OPERATORS(PxActorTypeFlag::Enum,PxU16)
00167 
00168 
00186 struct PxQueryCache
00187 {
00191     PX_INLINE PxQueryCache() : shape(NULL), actor(NULL), faceIndex(0xffffffff) {}
00192 
00196     PX_INLINE PxQueryCache(PxShape* s, PxU32 findex) : shape(s), actor(NULL), faceIndex(findex) {}
00197 
00198     PxShape*        shape;          
00199     PxRigidActor*   actor;          
00200     PxU32           faceIndex;      
00201 };
00202 
00212 class PxScene
00213 {
00214     protected:
00215     
00216     /************************************************************************************************/
00217 
00221     
00222                                 PxScene(): userData(0)  {}
00223     virtual                     ~PxScene()  {}
00224 
00225     public:
00226 
00238     virtual     void            release() = 0;
00239 
00247     virtual     void            setFlag(PxSceneFlag::Enum flag, bool value) = 0;
00248 
00256     virtual     PxSceneFlags    getFlags() const = 0;
00257 
00258 
00269     virtual void                setLimits(const PxSceneLimits& limits) = 0;
00270 
00276     virtual PxSceneLimits       getLimits() const = 0;
00277 
00278 
00286     virtual PxPhysics&          getPhysics() = 0;
00287 
00293     virtual PxU32               getTimestamp()  const   = 0;
00294 
00295     
00297     /************************************************************************************************/
00298 
00311     virtual void                addArticulation(PxArticulation& articulation) = 0;
00312 
00325     virtual void                removeArticulation(PxArticulation& articulation, bool wakeOnLostTouch = true) = 0;
00326 
00342     virtual void                addActor(PxActor& actor) = 0;
00343 
00362     virtual void                addActors(PxActor*const* actors, PxU32 nbActors) = 0;
00363 
00382     virtual void                addActors(const PxPruningStructure& pruningStructure) = 0;
00383 
00400     virtual void                removeActor(PxActor& actor, bool wakeOnLostTouch = true) = 0;
00401 
00417     virtual void                removeActors(PxActor*const* actors, PxU32 nbActors, bool wakeOnLostTouch = true) = 0;
00418 
00431     virtual void                addAggregate(PxAggregate& aggregate)    = 0;
00432 
00445     virtual void                removeAggregate(PxAggregate& aggregate, bool wakeOnLostTouch = true)    = 0;
00446 
00459     virtual void                addCollection(const PxCollection& collection) = 0;
00461     /************************************************************************************************/
00462 
00466 
00475     virtual PxU32               getNbActors(PxActorTypeFlags types) const = 0;
00476 
00488     virtual PxU32               getActors(PxActorTypeFlags types, PxActor** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
00489 
00506     PX_DEPRECATED virtual const PxActiveTransform*
00507                                 getActiveTransforms(PxU32& nbTransformsOut, PxClientID client = PX_DEFAULT_CLIENT) = 0;
00508 
00509 
00528     virtual PxActor**       getActiveActors(PxU32& nbActorsOut, PX_DEPRECATED PxClientID client = PX_DEFAULT_CLIENT) = 0;
00529 
00537     virtual PxU32               getNbArticulations() const = 0;
00538 
00549     virtual PxU32               getArticulations(PxArticulation** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
00550 
00558     virtual PxU32               getNbConstraints()  const   = 0;
00559 
00570     virtual PxU32               getConstraints(PxConstraint** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const = 0;
00571 
00572 
00580     virtual         PxU32       getNbAggregates()   const   = 0;
00581 
00592     virtual         PxU32       getAggregates(PxAggregate** userBuffer, PxU32 bufferSize, PxU32 startIndex=0)   const   = 0;
00593 
00595     /************************************************************************************************/
00596 
00600 
00651     virtual void                setDominanceGroupPair(
00652                                     PxDominanceGroup group1, PxDominanceGroup group2, const PxDominanceGroupPair& dominance) = 0;
00653 
00659     virtual PxDominanceGroupPair getDominanceGroupPair(PxDominanceGroup group1, PxDominanceGroup group2) const = 0;
00660 
00662     /************************************************************************************************/
00663 
00667 
00673     virtual PxCpuDispatcher* getCpuDispatcher() const = 0;
00674 
00682     virtual PxGpuDispatcher* getGpuDispatcher() const = 0;
00683 
00685     /************************************************************************************************/
00698     virtual PxClientID          createClient() = 0;
00699 
00716     PX_DEPRECATED virtual void              setClientBehaviorFlags(PxClientID client, PxClientBehaviorFlags clientBehaviorFlags) = 0; 
00717 
00725     PX_DEPRECATED virtual PxClientBehaviorFlags getClientBehaviorFlags(PxClientID client) const = 0;
00727 
00728 
00729     #if PX_USE_CLOTH_API
00730 
00731     /************************************************************************************************/
00732 
00750     PX_DEPRECATED virtual void  setClothInterCollisionDistance(PxF32 distance) = 0;
00751 
00757     PX_DEPRECATED virtual PxF32 getClothInterCollisionDistance() const = 0;
00758 
00768     PX_DEPRECATED virtual void  setClothInterCollisionStiffness(PxF32 stiffness) = 0; 
00774     PX_DEPRECATED virtual PxF32 getClothInterCollisionStiffness() const = 0; 
00775 
00785     PX_DEPRECATED virtual void  setClothInterCollisionNbIterations(PxU32 nbIterations) = 0;     
00791     PX_DEPRECATED virtual PxU32 getClothInterCollisionNbIterations() const = 0; 
00793 
00794     #endif // PX_USE_CLOTH_API
00795 
00796     /************************************************************************************************/
00797 
00801 
00818     virtual void                setSimulationEventCallback(PxSimulationEventCallback* callback, PX_DEPRECATED PxClientID client = PX_DEFAULT_CLIENT) = 0;
00819 
00830     virtual PxSimulationEventCallback*
00831                                 getSimulationEventCallback(PX_DEPRECATED PxClientID client = PX_DEFAULT_CLIENT) const = 0;
00832 
00840     virtual void                setContactModifyCallback(PxContactModifyCallback* callback) = 0;
00841 
00849     virtual void                setCCDContactModifyCallback(PxCCDContactModifyCallback* callback) = 0;
00850 
00858     virtual PxContactModifyCallback*
00859                                 getContactModifyCallback() const = 0;
00860 
00868     virtual PxCCDContactModifyCallback*
00869                                 getCCDContactModifyCallback() const = 0;
00870 
00887     virtual void                setBroadPhaseCallback(PxBroadPhaseCallback* callback, PX_DEPRECATED PxClientID client = PX_DEFAULT_CLIENT) = 0;
00888 
00900     virtual PxBroadPhaseCallback* getBroadPhaseCallback(PX_DEPRECATED PxClientID client = PX_DEFAULT_CLIENT)    const = 0;
00901 
00903     /************************************************************************************************/
00904 
00908 
00925     virtual void                setFilterShaderData(const void* data, PxU32 dataSize) = 0;
00926 
00936     virtual const void*         getFilterShaderData() const = 0;
00937 
00945     virtual PxU32               getFilterShaderDataSize() const = 0;
00946 
00954     virtual PxSimulationFilterShader
00955                                 getFilterShader() const = 0;
00956 
00964     virtual PxSimulationFilterCallback*
00965                                 getFilterCallback() const = 0;
00966 
00996     virtual void                resetFiltering(PxActor& actor) = 0;
00997 
01012     virtual void                resetFiltering(PxRigidActor& actor, PxShape*const* shapes, PxU32 shapeCount) = 0;
01013 
01015     /************************************************************************************************/
01016 
01051     virtual void                simulate(PxReal elapsedTime, physx::PxBaseTask* completionTask = NULL,
01052                                     void* scratchMemBlock = 0, PxU32 scratchMemBlockSize = 0, bool controlSimulation = true) = 0;
01053 
01054 
01065     virtual void                advance(physx::PxBaseTask* completionTask = 0) = 0;
01066 
01084     virtual void                collide(PxReal elapsedTime, physx::PxBaseTask* completionTask = 0, void* scratchMemBlock = 0,
01085                                     PxU32 scratchMemBlockSize = 0, bool controlSimulation = true) = 0;  
01086     
01098     virtual bool                checkResults(bool block = false) = 0;
01099 
01107     virtual bool                fetchCollision(bool block = false)  = 0;            
01108 
01130     virtual bool                fetchResults(bool block = false, PxU32* errorState = 0) = 0;
01131 
01132 
01148     virtual bool                fetchResultsStart(const PxContactPairHeader*& contactPairs, PxU32& nbContactPairs, bool block = false) = 0;
01149 
01150 
01159     virtual void                processCallbacks(physx::PxBaseTask* continuation) = 0;
01160 
01161 
01173     virtual void                fetchResultsFinish(PxU32* errorState = 0) = 0;
01174 
01175 
01186     virtual void                flushSimulation(bool sendPendingReports = false) = 0;
01187     
01197     virtual void                setGravity(const PxVec3& vec) = 0;
01198 
01206     virtual PxVec3              getGravity() const = 0;
01207 
01213     virtual void                setBounceThresholdVelocity(const PxReal t) = 0;
01214 
01220     virtual PxReal              getBounceThresholdVelocity() const = 0;
01221 
01222 
01231     virtual void                setCCDMaxPasses(PxU32 ccdMaxPasses) = 0;
01232 
01241     virtual PxU32               getCCDMaxPasses() const = 0;    
01242 
01248     virtual PxReal              getFrictionOffsetThreshold() const = 0;
01249 
01254     virtual void setFrictionType(PxFrictionType::Enum frictionType) = 0;
01255 
01260     virtual PxFrictionType::Enum getFrictionType() const = 0;
01261 
01263     /************************************************************************************************/
01264 
01279     virtual bool                setVisualizationParameter(PxVisualizationParameter::Enum param, PxReal value) = 0;
01280 
01289     virtual PxReal              getVisualizationParameter(PxVisualizationParameter::Enum paramEnum) const = 0;
01290 
01291 
01298     virtual void                setVisualizationCullingBox(const PxBounds3& box) = 0;
01299 
01306     virtual PxBounds3           getVisualizationCullingBox() const = 0;
01307     
01319     virtual const PxRenderBuffer& getRenderBuffer() = 0;
01320     
01330     virtual void                getSimulationStatistics(PxSimulationStatistics& stats) const = 0;
01331     
01332     
01334     /************************************************************************************************/
01335 
01339 
01345     virtual PxPruningStructureType::Enum getStaticStructure() const = 0;
01346 
01352     virtual PxPruningStructureType::Enum getDynamicStructure() const = 0;
01353 
01369     virtual void                flushQueryUpdates() = 0;
01370 
01382     PX_DEPRECATED virtual   PxBatchQuery*       createBatchQuery(const PxBatchQueryDesc& desc) = 0;
01383 
01391     PX_DEPRECATED virtual   PxVolumeCache*      createVolumeCache(PxU32 maxStaticShapes = 32, PxU32 maxDynamicShapes = 8) = 0;
01392 
01400     virtual void                setDynamicTreeRebuildRateHint(PxU32 dynamicTreeRebuildRateHint) = 0;
01401 
01409     virtual PxU32               getDynamicTreeRebuildRateHint() const = 0;
01410 
01419     virtual void                forceDynamicTreeRebuild(bool rebuildStaticStructure, bool rebuildDynamicStructure)  = 0;
01420 
01428     virtual void                setSceneQueryUpdateMode(PxSceneQueryUpdateMode::Enum updateMode) = 0;
01429 
01437     virtual PxSceneQueryUpdateMode::Enum getSceneQueryUpdateMode() const = 0;
01438 
01456     virtual void                sceneQueriesUpdate(physx::PxBaseTask* completionTask = NULL, bool controlSimulation = true) = 0;
01457 
01469     virtual bool                checkQueries(bool block = false) = 0;
01470 
01480     virtual bool                fetchQueries(bool block = false)    = 0;    
01481 
01504     virtual bool                raycast(
01505                                     const PxVec3& origin, const PxVec3& unitDir, const PxReal distance,
01506                                     PxRaycastCallback& hitCall, PxHitFlags hitFlags = PxHitFlags(PxHitFlag::eDEFAULT),
01507                                     const PxQueryFilterData& filterData = PxQueryFilterData(), PxQueryFilterCallback* filterCall = NULL,
01508                                     const PxQueryCache* cache = NULL) const = 0;
01509 
01537     virtual bool                sweep(const PxGeometry& geometry, const PxTransform& pose, const PxVec3& unitDir, const PxReal distance,
01538                                     PxSweepCallback& hitCall, PxHitFlags hitFlags = PxHitFlags(PxHitFlag::eDEFAULT),
01539                                     const PxQueryFilterData& filterData = PxQueryFilterData(), PxQueryFilterCallback* filterCall = NULL,
01540                                     const PxQueryCache* cache = NULL, const PxReal inflation = 0.f) const = 0;
01541 
01542 
01562     virtual bool                overlap(const PxGeometry& geometry, const PxTransform& pose, PxOverlapCallback& hitCall,
01563                                     const PxQueryFilterData& filterData = PxQueryFilterData(), PxQueryFilterCallback* filterCall = NULL
01564                                     ) const = 0;
01565 
01566 
01573     virtual PxU32   getSceneQueryStaticTimestamp()  const   = 0;
01575     
01576     /************************************************************************************************/
01580 
01586     virtual PxBroadPhaseType::Enum  getBroadPhaseType()                             const = 0;
01587 
01594     virtual bool                    getBroadPhaseCaps(PxBroadPhaseCaps& caps)           const = 0;
01595 
01601     virtual PxU32                   getNbBroadPhaseRegions()                            const = 0;
01602 
01611     virtual PxU32                   getBroadPhaseRegions(PxBroadPhaseRegionInfo* userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const    = 0;
01612 
01629     virtual PxU32                   addBroadPhaseRegion(const PxBroadPhaseRegion& region, bool populateRegion=false)        = 0;
01630 
01644     virtual bool                    removeBroadPhaseRegion(PxU32 handle)                = 0;
01645 
01647 
01648     /************************************************************************************************/
01649 
01653 
01659     virtual PxTaskManager*          getTaskManager() const = 0;
01660 
01661 
01680     virtual void lockRead(const char* file=NULL, PxU32 line=0) = 0;
01681 
01687     virtual void unlockRead() = 0;
01688 
01714     virtual void lockWrite(const char* file=NULL, PxU32 line=0) = 0;
01715 
01721     virtual void unlockWrite() = 0;
01722     
01723 
01737     virtual         void                setNbContactDataBlocks(PxU32 numBlocks) = 0;
01738     
01739 
01749     virtual         PxU32               getNbContactDataBlocksUsed() const = 0;
01750 
01760     virtual         PxU32               getMaxNbContactDataBlocksUsed() const = 0;
01761 
01762 
01768     virtual PxU32 getContactReportStreamBufferSize() const = 0;
01769 
01770     
01778     virtual void                        setSolverBatchSize(PxU32 solverBatchSize) = 0;
01779 
01787     virtual PxU32                       getSolverBatchSize() const = 0;
01788     
01789 
01791 
01799     virtual PxReal                      getWakeCounterResetValue() const = 0;
01800 
01817     virtual void                    shiftOrigin(const PxVec3& shift) = 0;
01818 
01823     virtual PxPvdSceneClient*       getScenePvdClient() = 0;
01824 
01825     void*   userData;   
01826 };
01827 
01828 #if !PX_DOXYGEN
01829 } // namespace physx
01830 #endif
01831 
01833 #endif


Copyright © 2008-2018 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com