file_path
stringlengths
21
207
content
stringlengths
5
1.02M
size
int64
5
1.02M
lang
stringclasses
9 values
avg_line_length
float64
1.33
100
max_line_length
int64
4
993
alphanum_fraction
float64
0.27
0.93
NVIDIA-Omniverse/PhysX/physx/source/physx/src/NpSceneAccessor.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef NP_SCENE_ACCESSOR_H #define NP_SCENE_ACCESSOR_H #include "PxScene.h" namespace physx { class PxsSimulationController; class NpSceneAccessor : public PxScene { PX_NOCOPY(NpSceneAccessor) public: NpSceneAccessor() {} virtual ~NpSceneAccessor() {} virtual PxsSimulationController* getSimulationController() = 0; virtual void setActiveActors(PxActor** actors, PxU32 nbActors) = 0; virtual PxActor** getFrozenActors(PxU32& nbActorsOut) = 0; virtual void setFrozenActorFlag(const bool buildFrozenActors) = 0; virtual void forceSceneQueryRebuild() = 0; virtual void frameEnd() = 0; }; } #endif
2,389
C
40.929824
74
0.740477
NVIDIA-Omniverse/PhysX/physx/source/physx/src/PvdPhysicsClient.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. // PX_DUMMY_SYMBOL #include "foundation/PxPreprocessor.h" #if PX_SUPPORT_PVD #include "pvd/PxPvdTransport.h" #include "PxPhysics.h" #include "PxPvdClient.h" #include "PxPvdDataStream.h" #include "PxPvdObjectModelBaseTypes.h" #include "PvdPhysicsClient.h" #include "PvdTypeNames.h" using namespace physx; using namespace physx::Vd; PvdPhysicsClient::PvdPhysicsClient(PsPvd* pvd) : mPvd(pvd), mPvdDataStream(NULL), mIsConnected(false) { } PvdPhysicsClient::~PvdPhysicsClient() { mPvd->removeClient(this); } PvdDataStream* PvdPhysicsClient::getDataStream() { return mPvdDataStream; } bool PvdPhysicsClient::isConnected() const { return mIsConnected; } void PvdPhysicsClient::onPvdConnected() { if(mIsConnected || !mPvd) return; mIsConnected = true; mPvdDataStream = PvdDataStream::create(mPvd); sendEntireSDK(); } void PvdPhysicsClient::onPvdDisconnected() { if(!mIsConnected) return; mIsConnected = false; mPvdDataStream->release(); mPvdDataStream = NULL; } void PvdPhysicsClient::flush() { } void PvdPhysicsClient::sendEntireSDK() { PxPhysics& physics = PxGetPhysics(); mMetaDataBinding.registerSDKProperties(*mPvdDataStream); mPvdDataStream->createInstance(&physics); mPvdDataStream->setIsTopLevelUIElement(&physics, true); mMetaDataBinding.sendAllProperties(*mPvdDataStream, physics); #define SEND_BUFFER_GROUP(type, name) \ { \ physx::PxArray<type*> buffers; \ PxU32 numBuffers = physics.getNb##name(); \ buffers.resize(numBuffers); \ physics.get##name(buffers.begin(), numBuffers); \ for(PxU32 i = 0; i < numBuffers; i++) \ { \ if(mPvd->registerObject(buffers[i])) \ createPvdInstance(buffers[i]); \ } \ } SEND_BUFFER_GROUP(PxMaterial, Materials); SEND_BUFFER_GROUP(PxTriangleMesh, TriangleMeshes); SEND_BUFFER_GROUP(PxConvexMesh, ConvexMeshes); SEND_BUFFER_GROUP(PxTetrahedronMesh, TetrahedronMeshes); SEND_BUFFER_GROUP(PxHeightField, HeightFields); } void PvdPhysicsClient::destroyPvdInstance(const PxPhysics* physics) { if(mPvdDataStream) mPvdDataStream->destroyInstance(physics); } void PvdPhysicsClient::createPvdInstance(const PxTriangleMesh* triMesh) { mMetaDataBinding.createInstance(*mPvdDataStream, *triMesh, PxGetPhysics()); } void PvdPhysicsClient::destroyPvdInstance(const PxTriangleMesh* triMesh) { mMetaDataBinding.destroyInstance(*mPvdDataStream, *triMesh, PxGetPhysics()); } void PvdPhysicsClient::createPvdInstance(const PxTetrahedronMesh* tetMesh) { mMetaDataBinding.createInstance(*mPvdDataStream, *tetMesh, PxGetPhysics()); } void PvdPhysicsClient::destroyPvdInstance(const PxTetrahedronMesh* tetMesh) { mMetaDataBinding.destroyInstance(*mPvdDataStream, *tetMesh, PxGetPhysics()); } void PvdPhysicsClient::createPvdInstance(const PxConvexMesh* convexMesh) { mMetaDataBinding.createInstance(*mPvdDataStream, *convexMesh, PxGetPhysics()); } void PvdPhysicsClient::destroyPvdInstance(const PxConvexMesh* convexMesh) { mMetaDataBinding.destroyInstance(*mPvdDataStream, *convexMesh, PxGetPhysics()); } void PvdPhysicsClient::createPvdInstance(const PxHeightField* heightField) { mMetaDataBinding.createInstance(*mPvdDataStream, *heightField, PxGetPhysics()); } void PvdPhysicsClient::destroyPvdInstance(const PxHeightField* heightField) { mMetaDataBinding.destroyInstance(*mPvdDataStream, *heightField, PxGetPhysics()); } void PvdPhysicsClient::createPvdInstance(const PxMaterial* mat) { mMetaDataBinding.createInstance(*mPvdDataStream, *mat, PxGetPhysics()); } void PvdPhysicsClient::updatePvdProperties(const PxMaterial* mat) { mMetaDataBinding.sendAllProperties(*mPvdDataStream, *mat); } void PvdPhysicsClient::destroyPvdInstance(const PxMaterial* mat) { mMetaDataBinding.destroyInstance(*mPvdDataStream, *mat, PxGetPhysics()); } void PvdPhysicsClient::createPvdInstance(const PxFEMSoftBodyMaterial* mat) { mMetaDataBinding.createInstance(*mPvdDataStream, *mat, PxGetPhysics()); } void PvdPhysicsClient::updatePvdProperties(const PxFEMSoftBodyMaterial* mat) { mMetaDataBinding.sendAllProperties(*mPvdDataStream, *mat); } void PvdPhysicsClient::destroyPvdInstance(const PxFEMSoftBodyMaterial* mat) { mMetaDataBinding.destroyInstance(*mPvdDataStream, *mat, PxGetPhysics()); } void PvdPhysicsClient::createPvdInstance(const PxFEMClothMaterial* /*mat*/) { // jcarius: Commented-out until FEMCloth is not under construction anymore PX_ASSERT(0); // mMetaDataBinding.createInstance(*mPvdDataStream, *mat, PxGetPhysics()); } void PvdPhysicsClient::updatePvdProperties(const PxFEMClothMaterial* /*mat*/) { // jcarius: Commented-out until FEMCloth is not under construction anymore PX_ASSERT(0); // mMetaDataBinding.sendAllProperties(*mPvdDataStream, *mat); } void PvdPhysicsClient::destroyPvdInstance(const PxFEMClothMaterial* /*mat*/) { // jcarius: Commented-out until FEMCloth is not under construction anymore PX_ASSERT(0); // mMetaDataBinding.destroyInstance(*mPvdDataStream, *mat, PxGetPhysics()); } void PvdPhysicsClient::createPvdInstance(const PxPBDMaterial* mat) { mMetaDataBinding.createInstance(*mPvdDataStream, *mat, PxGetPhysics()); } void PvdPhysicsClient::updatePvdProperties(const PxPBDMaterial* mat) { mMetaDataBinding.sendAllProperties(*mPvdDataStream, *mat); } void PvdPhysicsClient::destroyPvdInstance(const PxPBDMaterial* mat) { mMetaDataBinding.destroyInstance(*mPvdDataStream, *mat, PxGetPhysics()); } void PvdPhysicsClient::onMeshFactoryBufferRelease(const PxBase* object, PxType typeID) { if(!mIsConnected || !mPvd) return; if(mPvd->unRegisterObject(object)) { switch(typeID) { case PxConcreteType::eHEIGHTFIELD: destroyPvdInstance(static_cast<const PxHeightField*>(object)); break; case PxConcreteType::eCONVEX_MESH: destroyPvdInstance(static_cast<const PxConvexMesh*>(object)); break; case PxConcreteType::eTRIANGLE_MESH_BVH33: case PxConcreteType::eTRIANGLE_MESH_BVH34: destroyPvdInstance(static_cast<const PxTriangleMesh*>(object)); break; case PxConcreteType::eTETRAHEDRON_MESH: destroyPvdInstance(static_cast<const PxTetrahedronMesh*>(object)); break; default: break; } } } void PvdPhysicsClient::reportError(PxErrorCode::Enum code, const char* message, const char* file, int line) { if(mIsConnected) { mPvdDataStream->sendErrorMessage(code, message, file, PxU32(line)); } } #endif // PX_SUPPORT_PVD
8,266
C++
28.952898
107
0.755021
NVIDIA-Omniverse/PhysX/physx/source/physx/src/NpScene.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #include "NpScene.h" #include "NpRigidStatic.h" #include "NpRigidDynamic.h" #include "NpArticulationReducedCoordinate.h" #include "NpArticulationTendon.h" #include "NpArticulationSensor.h" #include "NpAggregate.h" #if PX_SUPPORT_GPU_PHYSX #include "NpSoftBody.h" #include "NpParticleSystem.h" #include "NpFEMCloth.h" #include "NpHairSystem.h" #include "cudamanager/PxCudaContextManager.h" #include "cudamanager/PxCudaContext.h" #endif #include "ScArticulationSim.h" #include "ScArticulationTendonSim.h" #include "CmCollection.h" #include "PxsSimulationController.h" #include "common/PxProfileZone.h" #include "BpBroadPhase.h" #include "BpAABBManagerBase.h" #include "omnipvd/NpOmniPvdSetData.h" using namespace physx; // enable thread checks in all debug builds #if PX_DEBUG || PX_CHECKED #define NP_ENABLE_THREAD_CHECKS 1 #else #define NP_ENABLE_THREAD_CHECKS 0 #endif using namespace Sq; using namespace Gu; /////////////////////////////////////////////////////////////////////////////// #if PX_SUPPORT_PVD #define CREATE_PVD_INSTANCE(obj) \ { \ if(mScenePvdClient.checkPvdDebugFlag()) \ { \ PX_PROFILE_ZONE("PVD.createPVDInstance", mScene.getContextId());\ mScenePvdClient.createPvdInstance(obj); \ } \ } #define RELEASE_PVD_INSTANCE(obj) \ { \ if(mScenePvdClient.checkPvdDebugFlag()) \ { \ PX_PROFILE_ZONE("PVD.releasePVDInstance", mScene.getContextId());\ mScenePvdClient.releasePvdInstance(obj); \ } \ } #define UPDATE_PVD_PROPERTIES(obj) \ { \ if(mScenePvdClient.checkPvdDebugFlag()) \ { \ PX_PROFILE_ZONE("PVD.updatePVDProperties", mScene.getContextId());\ mScenePvdClient.updatePvdProperties(obj); \ } \ } #define PVD_ORIGIN_SHIFT(shift) \ { \ if(mScenePvdClient.checkPvdDebugFlag()) \ { \ PX_PROFILE_ZONE("PVD.originShift", mScene.getContextId());\ mScenePvdClient.originShift(shift); \ } \ } #else #define CREATE_PVD_INSTANCE(obj) {} #define RELEASE_PVD_INSTANCE(obj) {} #define UPDATE_PVD_PROPERTIES(obj) {} #define PVD_ORIGIN_SHIFT(shift){} #endif /////////////////////////////////////////////////////////////////////////////// PX_IMPLEMENT_OUTPUT_ERROR /////////////////////////////////////////////////////////////////////////////// static PX_FORCE_INLINE bool removeFromSceneCheck(NpScene* npScene, PxScene* scene, const char* name) { if(scene == static_cast<PxScene*>(npScene)) return true; else return PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "%s not assigned to scene or assigned to another scene. Call will be ignored!", name); } /////////////////////////////////////////////////////////////////////////////// #if PX_SUPPORT_OMNI_PVD static void SleepingStateChanged(PxRigidDynamic& actor, bool sleeping) { OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxRigidDynamic, isSleeping, actor, sleeping) } #endif NpScene::NpScene(const PxSceneDesc& desc, NpPhysics& physics) : mNpSQ (desc, #if PX_SUPPORT_PVD &mScenePvdClient, #else NULL, #endif getContextId()), mSceneQueriesStaticPrunerUpdate (getContextId(), 0, "NpScene.sceneQueriesStaticPrunerUpdate"), mSceneQueriesDynamicPrunerUpdate(getContextId(), 0, "NpScene.sceneQueriesDynamicPrunerUpdate"), mRigidDynamics ("sceneRigidDynamics"), mRigidStatics ("sceneRigidStatics"), mArticulations ("sceneArticulations"), mAggregates ("sceneAggregates"), mSanityBounds (desc.sanityBounds), mNbClients (1), //we always have the default client. mSceneCompletion (getContextId(), mPhysicsDone), mCollisionCompletion (getContextId(), mCollisionDone), mSceneQueriesCompletion (getContextId(), mSceneQueriesDone), mSceneExecution (getContextId(), 0, "NpScene.execution"), mSceneCollide (getContextId(), 0, "NpScene.collide"), mSceneAdvance (getContextId(), 0, "NpScene.solve"), mStaticBuildStepHandle (NULL), mDynamicBuildStepHandle (NULL), mControllingSimulation (false), mIsAPIReadForbidden (false), mIsAPIWriteForbidden (false), mSimThreadStackSize (0), mConcurrentWriteCount (0), mConcurrentReadCount (0), mConcurrentErrorCount (0), mCurrentWriter (0), mSQUpdateRunning (false), mBetweenFetchResults (false), mBuildFrozenActors (false), mScene (desc, getContextId()), #if PX_SUPPORT_PVD mScenePvdClient (*this), #endif mWakeCounterResetValue (desc.wakeCounterResetValue), mPhysics (physics), mName (NULL) { mGpuDynamicsConfig = desc.gpuDynamicsConfig; mSceneQueriesStaticPrunerUpdate.setObject(this); mSceneQueriesDynamicPrunerUpdate.setObject(this); mPrunerType[0] = desc.staticStructure; mPrunerType[1] = desc.dynamicStructure; mSceneExecution.setObject(this); mSceneCollide.setObject(this); mSceneAdvance.setObject(this); mTaskManager = mScene.getTaskManagerPtr(); mCudaContextManager = mScene.getCudaContextManager(); mThreadReadWriteDepth = PxTlsAlloc(); updatePhysXIndicator(); createInOmniPVD(desc); #if PX_SUPPORT_OMNI_PVD if (NpPhysics::getInstance().mOmniPvdSampler) mScene.mOnSleepingStateChanged = SleepingStateChanged; #endif } NpScene::~NpScene() { OMNI_PVD_DESTROY(OMNI_PVD_CONTEXT_HANDLE, PxScene, static_cast<PxScene &>(*this)) // PT: we need to do that one first, now that we don't release the objects anymore. Otherwise we end up with a sequence like: // - actor is part of an aggregate, and part of a scene // - actor gets removed from the scene. This does *not* remove it from the aggregate. // - aggregate gets removed from the scene, sees that one contained actor ain't in the scene => we get a warning message PxU32 aggregateCount = mAggregates.size(); while(aggregateCount--) removeAggregate(*mAggregates.getEntries()[aggregateCount], false); PxU32 rigidDynamicCount = mRigidDynamics.size(); while(rigidDynamicCount--) removeRigidDynamic(*mRigidDynamics[rigidDynamicCount], false, true); PxU32 rigidStaticCount = mRigidStatics.size(); while(rigidStaticCount--) removeRigidStatic(*mRigidStatics[rigidStaticCount], false, true); PxU32 articCount = mArticulations.size(); while(articCount--) removeArticulation(*mArticulations.getEntries()[articCount], false); #if PX_SUPPORT_GPU_PHYSX PxU32 particleCount = mPBDParticleSystems.size(); while(particleCount--) removeParticleSystem(*mPBDParticleSystems.getEntries()[particleCount], false); #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION particleCount = mFLIPParticleSystems.size(); while (particleCount--) removeParticleSystem(*mFLIPParticleSystems.getEntries()[particleCount], false); particleCount = mMPMParticleSystems.size(); while (particleCount--) removeParticleSystem(*mMPMParticleSystems.getEntries()[particleCount], false); #endif PxU32 softBodyCount = mSoftBodies.size(); while(softBodyCount--) removeSoftBody(*mSoftBodies.getEntries()[softBodyCount], false); #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION PxU32 femClothCount = mFEMCloths.size(); while (femClothCount--) removeFEMCloth(*mFEMCloths.getEntries()[femClothCount], false); PxU32 hairSystemsCount = mHairSystems.size(); while (hairSystemsCount--) removeHairSystem(*mHairSystems.getEntries()[hairSystemsCount], false); #endif #endif bool unlock = mScene.getFlags() & PxSceneFlag::eREQUIRE_RW_LOCK; #if PX_SUPPORT_PVD mNpSQ.getSingleSqCollector().release(); #endif #if PX_SUPPORT_PVD mScenePvdClient.releasePvdInstance(); #endif mScene.release(); // unlock the lock taken in release(), must unlock before // mRWLock is destroyed otherwise behavior is undefined if (unlock) unlockWrite(); PxTlsFree(mThreadReadWriteDepth); } /////////////////////////////////////////////////////////////////////////////// void NpScene::release() { // need to acquire lock for release, note this is unlocked in the destructor if (mScene.getFlags() & PxSceneFlag::eREQUIRE_RW_LOCK) lockWrite(PX_FL); // It will be hard to do a write check here since all object release calls in the scene destructor do it and would mess // up the test. If we really want it on scene destruction as well, we need to either have internal and external release // calls or come up with a different approach (for example using thread ID as detector variable). if(getSimulationStage() != Sc::SimulationStage::eCOMPLETE) { outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::release(): Scene is still being simulated! PxScene::fetchResults() is called implicitly."); if(getSimulationStage() == Sc::SimulationStage::eCOLLIDE) fetchCollision(true); if(getSimulationStage() == Sc::SimulationStage::eFETCHCOLLIDE) // need to call getSimulationStage() again beacause fetchCollision() might change the value. { // this is for split sim advance(NULL); } fetchResults(true, NULL); } NpPhysics::getInstance().releaseSceneInternal(*this); } /////////////////////////////////////////////////////////////////////////////// bool NpScene::loadFromDesc(const PxSceneDesc& desc) { if (desc.limits.maxNbBodies) mRigidDynamics.reserve(desc.limits.maxNbBodies); if (desc.limits.maxNbActors) mRigidStatics.reserve(desc.limits.maxNbActors); // to be consistent with code below (but to match previous interpretation // it would rather be desc.limits.maxNbActors - desc.limits.maxNbBodies) mScene.preAllocate(desc.limits.maxNbActors, desc.limits.maxNbBodies, desc.limits.maxNbStaticShapes, desc.limits.maxNbDynamicShapes); userData = desc.userData; return true; } /////////////////////////////////////////////////////////////////////////////// void NpScene::setGravity(const PxVec3& g) { NP_WRITE_CHECK(this); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(this, "PxScene::setGravity() not allowed while simulation is running. Call will be ignored.") mScene.setGravity(g); OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxScene, gravity, static_cast<PxScene&>(*this), g) updatePvdProperties(); } PxVec3 NpScene::getGravity() const { NP_READ_CHECK(this); return mScene.getGravity(); } /////////////////////////////////////////////////////////////////////////////// void NpScene::setBounceThresholdVelocity(const PxReal t) { NP_WRITE_CHECK(this); PX_CHECK_AND_RETURN((t>0.0f), "PxScene::setBounceThresholdVelocity(): threshold value has to be in (0, PX_MAX_F32)!"); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(this, "PxScene::setBounceThresholdVelocity() not allowed while simulation is running. Call will be ignored.") mScene.setBounceThresholdVelocity(t); updatePvdProperties(); OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxScene, bounceThresholdVelocity, static_cast<PxScene&>(*this), t) } PxReal NpScene::getBounceThresholdVelocity() const { NP_READ_CHECK(this) return mScene.getBounceThresholdVelocity(); } /////////////////////////////////////////////////////////////////////////////// void NpScene::setLimits(const PxSceneLimits& limits) { NP_WRITE_CHECK(this); if (limits.maxNbBodies) mRigidDynamics.reserve(limits.maxNbBodies); if (limits.maxNbActors) mRigidStatics.reserve(limits.maxNbActors); // to be consistent with code below (but to match previous interpretation // it would rather be desc.limits.maxNbActors - desc.limits.maxNbBodies) mScene.preAllocate(limits.maxNbActors, limits.maxNbBodies, limits.maxNbStaticShapes, limits.maxNbDynamicShapes); mScene.setLimits(limits); // PT: TODO: there is no guarantee that all simulation shapes will be SQ shapes so this is wrong getSQAPI().preallocate(PX_SCENE_PRUNER_STATIC, limits.maxNbStaticShapes); getSQAPI().preallocate(PX_SCENE_PRUNER_DYNAMIC, limits.maxNbDynamicShapes); updatePvdProperties(); OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, limitsMaxNbActors, static_cast<PxScene&>(*this), limits.maxNbActors) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, limitsMaxNbBodies, static_cast<PxScene&>(*this), limits.maxNbBodies) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, limitsMaxNbStaticShapes, static_cast<PxScene&>(*this), limits.maxNbStaticShapes) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, limitsMaxNbDynamicShapes, static_cast<PxScene&>(*this), limits.maxNbDynamicShapes) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, limitsMaxNbAggregates, static_cast<PxScene&>(*this), limits.maxNbAggregates) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, limitsMaxNbConstraints, static_cast<PxScene&>(*this), limits.maxNbConstraints) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, limitsMaxNbRegions, static_cast<PxScene&>(*this), limits.maxNbRegions) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, limitsMaxNbBroadPhaseOverlaps, static_cast<PxScene&>(*this), limits.maxNbBroadPhaseOverlaps) OMNI_PVD_WRITE_SCOPE_END } ////////////////////////////////////////////////////////////////////////// PxSceneLimits NpScene::getLimits() const { NP_READ_CHECK(this); return mScene.getLimits(); } /////////////////////////////////////////////////////////////////////////////// void NpScene::setFlag(PxSceneFlag::Enum flag, bool value) { NP_WRITE_CHECK(this); // this call supports mutable flags only PX_CHECK_AND_RETURN(PxSceneFlags(flag) & PxSceneFlags(PxSceneFlag::eMUTABLE_FLAGS), "PxScene::setFlag: This flag is not mutable - you can only set it once in PxSceneDesc at startup!"); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(this, "PxScene::setFlag() not allowed while simulation is running. Call will be ignored.") PxSceneFlags currentFlags = mScene.getFlags(); if(value) currentFlags |= flag; else currentFlags &= ~PxSceneFlags(flag); mScene.setFlags(currentFlags); const bool pcm = (currentFlags & PxSceneFlag::eENABLE_PCM); mScene.setPCM(pcm); const bool contactCache = !(currentFlags & PxSceneFlag::eDISABLE_CONTACT_CACHE); mScene.setContactCache(contactCache); updatePvdProperties(); OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxScene, flags, static_cast<PxScene&>(*this), getFlags()) } PxSceneFlags NpScene::getFlags() const { NP_READ_CHECK(this); return mScene.getFlags(); } void NpScene::setName(const char* name) { mName = name; #if PX_SUPPORT_OMNI_PVD PxScene & s = *this; streamSceneName(s, mName); #endif } const char* NpScene::getName() const { return mName; } /////////////////////////////////////////////////////////////////////////////// template<class actorT> static PX_NOINLINE bool doRigidActorChecks(const actorT& actor, const PruningStructure* ps, const NpScene* scene) { if(!ps && actor.getShapeManager().getPruningStructure()) return outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::addActors(): actor is in a pruning structure and cannot be added to a scene directly, use addActors(const PxPruningStructure& )"); if(actor.getNpScene()) return outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::addActors(): Actor already assigned to a scene. Call will be ignored!"); #if PX_CHECKED if(!actor.checkConstraintValidity()) return outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::addActors(): actor has invalid constraint and may not be added to scene"); scene->checkPositionSanity(actor, actor.getGlobalPose(), "PxScene::addActors"); #else PX_UNUSED(scene); #endif return true; } // PT: make sure we always add to array and set the array index properly / at the same time template<class T> static PX_FORCE_INLINE void addRigidActorToArray(T& a, PxArray<T*>& rigidActors, Cm::IDPool& idPool) { a.setRigidActorArrayIndex(rigidActors.size()); rigidActors.pushBack(&a); a.setRigidActorSceneIndex(idPool.getNewID()); } bool NpScene::addActor(PxActor& actor, const PxBVH* bvh) { PX_PROFILE_ZONE("API.addActor", getContextId()); NP_WRITE_CHECK(this); PX_CHECK_SCENE_API_WRITE_FORBIDDEN_AND_RETURN_VAL(this, "PxScene::addActor() not allowed while simulation is running. Call will be ignored.", false) PX_SIMD_GUARD; NpScene* scene = NpActor::getFromPxActor(actor).getNpScene(); if (scene) return outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::addActor(): Actor already assigned to a scene. Call will be ignored!"); return addActorInternal(actor, bvh); } bool NpScene::addActorInternal(PxActor& actor, const PxBVH* bvh) { if(bvh) { PxRigidActor* ra = &static_cast<PxRigidActor&>(actor); if(!ra || bvh->getNbBounds() == 0 || bvh->getNbBounds() > ra->getNbShapes()) return outputError<PxErrorCode::eINVALID_PARAMETER>(__LINE__, "PxRigidActor::setBVH: BVH is empty or does not match shapes in the actor."); } PxType type = actor.getConcreteType(); switch (type) { case (PxConcreteType::eRIGID_STATIC): { NpRigidStatic& npStatic = static_cast<NpRigidStatic&>(actor); if (!doRigidActorChecks(npStatic, NULL, this)) return false; return addRigidStatic(npStatic, static_cast<const BVH*>(bvh)); } case (PxConcreteType::eRIGID_DYNAMIC): { NpRigidDynamic& npDynamic = static_cast<NpRigidDynamic&>(actor); if (!doRigidActorChecks(npDynamic, NULL, this)) return false; return addRigidDynamic(npDynamic, static_cast<const BVH*>(bvh)); } case (PxConcreteType::eARTICULATION_LINK): { return outputError<PxErrorCode::eINVALID_PARAMETER>(__LINE__, "PxScene::addActor(): Individual articulation links can not be added to the scene"); } #if PX_SUPPORT_GPU_PHYSX case (PxConcreteType::eSOFT_BODY): { return addSoftBody(static_cast<PxSoftBody&>(actor)); } case (PxConcreteType::eFEM_CLOTH): { #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION return addFEMCloth(static_cast<PxFEMCloth&>(actor)); #else return false; #endif } case (PxConcreteType::ePBD_PARTICLESYSTEM): case (PxConcreteType::eFLIP_PARTICLESYSTEM): case (PxConcreteType::eMPM_PARTICLESYSTEM): { return addParticleSystem(static_cast<PxParticleSystem&>(actor)); } case (PxConcreteType::eHAIR_SYSTEM): { #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION return addHairSystem(static_cast<PxHairSystem&>(actor)); #else return false; #endif } #endif default: PX_ASSERT(false); // should not happen return false; } } static void updateScStateAndSetupSq(NpScene* scene, PxSceneQuerySystem& sqManager, NpActor& npActor, const PxRigidActor& actor, NpShapeManager& shapeManager, bool actorDynamic, const PxBounds3* bounds, const PruningStructure* ps) { npActor.setNpScene(scene); NpShape*const * shapes = shapeManager.getShapes(); PxU32 nbShapes = shapeManager.getNbShapes(); for(PxU32 i=0;i<nbShapes;i++) shapes[i]->setSceneIfExclusive(scene); shapeManager.setupAllSceneQuery(sqManager, npActor, actor, ps, bounds, actorDynamic); } bool NpScene::addActors(PxActor*const* actors, PxU32 nbActors) { return addActorsInternal(actors, nbActors, NULL); } bool NpScene::addActors(const PxPruningStructure& ps) { const PruningStructure& prunerStructure = static_cast<const PruningStructure&>(ps); if(!prunerStructure.isValid()) return outputError<PxErrorCode::eINVALID_PARAMETER>(__LINE__, "PxScene::addActors(): Provided pruning structure is not valid."); return addActorsInternal(prunerStructure.getActors(), prunerStructure.getNbActors(), &prunerStructure); } ///////////// bool NpScene::addActorsInternal(PxActor*const* PX_RESTRICT actors, PxU32 nbActors, const PruningStructure* ps) { NP_WRITE_CHECK(this); PX_PROFILE_ZONE("API.addActors", getContextId()); PX_SIMD_GUARD; if(getSimulationStage() != Sc::SimulationStage::eCOMPLETE) return outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::addActors() not allowed while simulation is running. Call will be ignored."); Sc::Scene& scScene = mScene; PxU32 actorsDone; Sc::BatchInsertionState scState; scScene.startBatchInsertion(scState); scState.staticActorOffset = ptrdiff_t(NpRigidStatic::getCoreOffset()); scState.staticShapeTableOffset = ptrdiff_t(NpRigidStatic::getNpShapeManagerOffset() + NpShapeManager::getShapeTableOffset()); scState.dynamicActorOffset = ptrdiff_t(NpRigidDynamic::getCoreOffset()); scState.dynamicShapeTableOffset = ptrdiff_t(NpRigidDynamic::getNpShapeManagerOffset() + NpShapeManager::getShapeTableOffset()); scState.shapeOffset = ptrdiff_t(NpShape::getCoreOffset()); PxInlineArray<PxBounds3, 8> shapeBounds; for(actorsDone=0; actorsDone<nbActors; actorsDone++) { if(actorsDone+1<nbActors) PxPrefetch(actors[actorsDone+1], sizeof(NpRigidDynamic)); // worst case: PxRigidStatic is smaller const PxType type = actors[actorsDone]->getConcreteType(); if(type == PxConcreteType::eRIGID_STATIC) { NpRigidStatic& a = *static_cast<NpRigidStatic*>(actors[actorsDone]); if(!doRigidActorChecks(a, ps, this)) break; if(!(a.getCore().getActorFlags().isSet(PxActorFlag::eDISABLE_SIMULATION))) { shapeBounds.resizeUninitialized(a.NpRigidStatic::getNbShapes()+1); // PT: +1 for safe reads in addPrunerData/inflateBounds scScene.addStatic(&a, scState, shapeBounds.begin()); // PT: must call this one before doing SQ calls addRigidActorToArray(a, mRigidStatics, mRigidActorIndexPool); updateScStateAndSetupSq(this, getSQAPI(), a, a, a.getShapeManager(), false, shapeBounds.begin(), ps); a.addConstraintsToScene(); } else addRigidStatic(a, NULL, ps); } else if(type == PxConcreteType::eRIGID_DYNAMIC) { NpRigidDynamic& a = *static_cast<NpRigidDynamic*>(actors[actorsDone]); if(!doRigidActorChecks(a, ps, this)) break; if(!(a.getCore().getActorFlags().isSet(PxActorFlag::eDISABLE_SIMULATION))) { shapeBounds.resizeUninitialized(a.NpRigidDynamic::getNbShapes()+1); // PT: +1 for safe reads in addPrunerData/inflateBounds scScene.addBody(&a, scState, shapeBounds.begin(), false); // PT: must call this one before doing SQ calls addRigidActorToArray(a, mRigidDynamics, mRigidActorIndexPool); updateScStateAndSetupSq(this, getSQAPI(), a, a, a.getShapeManager(), true, shapeBounds.begin(), ps); a.addConstraintsToScene(); } else addRigidDynamic(a, NULL, ps); } else { PxGetFoundation().error(PxErrorCode::eDEBUG_WARNING, PX_FL, "PxScene::addActors(): Batch addition is not permitted for this actor type, aborting at index %u!", actorsDone); break; } } // merge sq PrunerStructure if(ps) { getSQAPI().merge(*ps); } scScene.finishBatchInsertion(scState); // if we failed, still complete everything for the successful inserted actors before backing out #if PX_SUPPORT_PVD for(PxU32 i=0;i<actorsDone;i++) { if ((actors[i]->getConcreteType()==PxConcreteType::eRIGID_STATIC) && (!(static_cast<NpRigidStatic*>(actors[i])->getCore().getActorFlags().isSet(PxActorFlag::eDISABLE_SIMULATION)))) mScenePvdClient.addStaticAndShapesToPvd(*static_cast<NpRigidStatic*>(actors[i])); else if ((actors[i]->getConcreteType() == PxConcreteType::eRIGID_DYNAMIC) && (!(static_cast<NpRigidDynamic*>(actors[i])->getCore().getActorFlags().isSet(PxActorFlag::eDISABLE_SIMULATION)))) mScenePvdClient.addBodyAndShapesToPvd(*static_cast<NpRigidDynamic*>(actors[i])); } #endif if(actorsDone<nbActors) // Everything is consistent up to the failure point, so just use removeActor to back out gracefully if necessary { for(PxU32 j=0;j<actorsDone;j++) removeActorInternal(*actors[j], false, true); return false; } return true; } /////////////////////////////////////////////////////////////////////////////// template<typename T> static PX_FORCE_INLINE void removeFromRigidActorListT(T& rigidActor, PxArray<T*>& rigidActorList, Cm::IDPool& idPool) { const PxU32 index = rigidActor.getRigidActorArrayIndex(); PX_ASSERT(index != 0xFFFFFFFF); PX_ASSERT(index < rigidActorList.size()); const PxU32 size = rigidActorList.size() - 1; rigidActorList.replaceWithLast(index); if (size && size != index) { T& swappedActor = *rigidActorList[index]; swappedActor.setRigidActorArrayIndex(index); } idPool.freeID(rigidActor.getRigidActorSceneIndex()); rigidActor.setRigidActorSceneIndex(NP_UNUSED_BASE_INDEX); } // PT: TODO: inline this one in the header for consistency void NpScene::removeFromRigidDynamicList(NpRigidDynamic& rigidDynamic) { removeFromRigidActorListT(rigidDynamic, mRigidDynamics, mRigidActorIndexPool); } // PT: TODO: inline this one in the header for consistency void NpScene::removeFromRigidStaticList(NpRigidStatic& rigidStatic) { removeFromRigidActorListT(rigidStatic, mRigidStatics, mRigidActorIndexPool); } /////////////////////////////////////////////////////////////////////////////// template<class ActorT> static void removeActorT(NpScene* npScene, ActorT& actor, PxArray<ActorT*>& actors, bool wakeOnLostTouch) { const PxActorFlags actorFlags = actor.getCore().getActorFlags(); if(actor.getShapeManager().getNbShapes()) PxPrefetch(actor.getShapeManager().getShapes()[0],sizeof(NpShape)); PxPrefetch(actors[actors.size()-1],sizeof(ActorT)); const bool noSim = actorFlags.isSet(PxActorFlag::eDISABLE_SIMULATION); if (!noSim) actor.removeConstraintsFromScene(); actor.getShapeManager().teardownAllSceneQuery(npScene->getSQAPI(), actor); npScene->scRemoveActor(actor, wakeOnLostTouch, noSim); removeFromRigidActorListT(actor, actors, npScene->mRigidActorIndexPool); OMNI_PVD_REMOVE(OMNI_PVD_CONTEXT_HANDLE, PxScene, actors, static_cast<PxScene &>(*npScene), static_cast<PxActor &>(actor)) } void NpScene::removeActors(PxActor*const* PX_RESTRICT actors, PxU32 nbActors, bool wakeOnLostTouch) { PX_PROFILE_ZONE("API.removeActors", getContextId()); NP_WRITE_CHECK(this); Sc::Scene& scScene = mScene; // resize the bitmap so it does not allocate each remove actor call scScene.resizeReleasedBodyIDMaps(mRigidDynamics.size() + mRigidStatics.size(), nbActors); Sc::BatchRemoveState removeState; scScene.setBatchRemove(&removeState); for(PxU32 actorsDone=0; actorsDone<nbActors; actorsDone++) { if(actorsDone+1<nbActors) PxPrefetch(actors[actorsDone+1], sizeof(NpRigidDynamic)); // worst case: PxRigidStatic is smaller PxType type = actors[actorsDone]->getConcreteType(); if(!removeFromSceneCheck(this, actors[actorsDone]->getScene(), "PxScene::removeActors(): Actor")) break; removeState.bufferedShapes.clear(); removeState.removedShapes.clear(); if(type == PxConcreteType::eRIGID_STATIC) { NpRigidStatic& actor = *static_cast<NpRigidStatic*>(actors[actorsDone]); removeActorT(this, actor, mRigidStatics, wakeOnLostTouch); } else if(type == PxConcreteType::eRIGID_DYNAMIC) { NpRigidDynamic& actor = *static_cast<NpRigidDynamic*>(actors[actorsDone]); removeActorT(this, actor, mRigidDynamics, wakeOnLostTouch); } else { PxGetFoundation().error(PxErrorCode::eDEBUG_WARNING, PX_FL, "PxScene::removeActor(): Batch removal is not supported for this actor type, aborting at index %u!", actorsDone); break; } } scScene.setBatchRemove(NULL); } void NpScene::removeActor(PxActor& actor, bool wakeOnLostTouch) { if(0) // PT: repro for PX-1999 { PxActor* toRemove = &actor; removeActors(&toRemove, 1, wakeOnLostTouch); return; } PX_PROFILE_ZONE("API.removeActor", getContextId()); NP_WRITE_CHECK(this); if(removeFromSceneCheck(this, actor.getScene(), "PxScene::removeActor(): Actor")) removeActorInternal(actor, wakeOnLostTouch, true); } void NpScene::removeActorInternal(PxActor& actor, bool wakeOnLostTouch, bool removeFromAggregate) { switch(actor.getType()) { case PxActorType::eRIGID_STATIC: { NpRigidStatic& npStatic = static_cast<NpRigidStatic&>(actor); removeRigidStatic(npStatic, wakeOnLostTouch, removeFromAggregate); } break; case PxActorType::eRIGID_DYNAMIC: { NpRigidDynamic& npDynamic = static_cast<NpRigidDynamic&>(actor); removeRigidDynamic(npDynamic, wakeOnLostTouch, removeFromAggregate); } break; case PxActorType::eARTICULATION_LINK: { outputError<PxErrorCode::eINVALID_PARAMETER>(__LINE__, "PxScene::removeActor(): Individual articulation links can not be removed from the scene"); } break; #if PX_SUPPORT_GPU_PHYSX case PxActorType::eSOFTBODY: { NpSoftBody& npSoftBody = static_cast<NpSoftBody&>(actor); removeSoftBody(npSoftBody, wakeOnLostTouch); } break; #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION case PxActorType::eFEMCLOTH: { NpFEMCloth& npFEMCloth= static_cast<NpFEMCloth&>(actor); removeFEMCloth(npFEMCloth, wakeOnLostTouch); } break; #endif case PxActorType::ePBD_PARTICLESYSTEM: { PxPBDParticleSystem& npParticleSystem = static_cast<PxPBDParticleSystem&>(actor); removeParticleSystem(npParticleSystem, wakeOnLostTouch); } break; #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION case PxActorType::eFLIP_PARTICLESYSTEM: { PxFLIPParticleSystem& npParticleSystem = static_cast<PxFLIPParticleSystem&>(actor); removeParticleSystem(npParticleSystem, wakeOnLostTouch); } break; case PxActorType::eMPM_PARTICLESYSTEM: { PxMPMParticleSystem& npParticleSystem = static_cast<PxMPMParticleSystem&>(actor); removeParticleSystem(npParticleSystem, wakeOnLostTouch); } break; case PxActorType::eHAIRSYSTEM: { NpHairSystem& npHairSystem = static_cast<NpHairSystem&>(actor); removeHairSystem(npHairSystem, wakeOnLostTouch); } break; #endif #endif default: PX_ASSERT(0); } } /////////////////////////////////////////////////////////////////////////////// template<class T> static PX_FORCE_INLINE bool addRigidActorT(T& rigidActor, PxArray<T*>& rigidActorList, NpScene* scene, const BVH* bvh, const PruningStructure* ps) { PX_CHECK_SCENE_API_WRITE_FORBIDDEN_AND_RETURN_VAL(scene, "PxScene::addActor() not allowed while simulation is running. Call will be ignored.", false) #if PX_CHECKED if (!scene->getScScene().isUsingGpuDynamics()) { for (PxU32 i = 0; i < rigidActor.getShapeManager().getNbShapes(); ++i) { const NpShape* shape = rigidActor.getShapeManager().getShapes()[i]; const PxGeometry& geom = shape->getGeometry(); const PxGeometryType::Enum t = geom.getType(); if (t == PxGeometryType::eTRIANGLEMESH) { const PxTriangleMeshGeometry& triGeom = static_cast<const PxTriangleMeshGeometry&>(geom); if (triGeom.triangleMesh->getSDF() != NULL) { return outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::addRigidActor(): Rigid actors with SDFs are currently only supported with GPU-accelerated scenes!"); } } } } #endif const bool isNoSimActor = rigidActor.getActorFlags().isSet(PxActorFlag::eDISABLE_SIMULATION); PxBounds3 bounds[8+1]; // PT: +1 for safe reads in addPrunerData/inflateBounds const bool canReuseBounds = !isNoSimActor && rigidActor.getShapeManager().getNbShapes()<=8; PxBounds3* uninflatedBounds = canReuseBounds ? bounds : NULL; scene->scAddActor(rigidActor, isNoSimActor, uninflatedBounds, bvh); // PT: must call this one before doing SQ calls addRigidActorToArray(rigidActor, rigidActorList, scene->mRigidActorIndexPool); // PT: SQ_CODEPATH1 rigidActor.getShapeManager().setupAllSceneQuery(scene->getSQAPI(), rigidActor, ps, uninflatedBounds, bvh); if(!isNoSimActor) rigidActor.addConstraintsToScene(); OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxActor, worldBounds, static_cast<PxActor &>(rigidActor), rigidActor.getWorldBounds()) OMNI_PVD_ADD(OMNI_PVD_CONTEXT_HANDLE, PxScene, actors, static_cast<PxScene &>(*scene), static_cast<PxActor &>(rigidActor)) return true; } bool NpScene::addRigidStatic(NpRigidStatic& actor, const BVH* bvh, const PruningStructure* ps) { return addRigidActorT(actor, mRigidStatics, this, bvh, ps); } bool NpScene::addRigidDynamic(NpRigidDynamic& body, const BVH* bvh, const PruningStructure* ps) { return addRigidActorT(body, mRigidDynamics, this, bvh, ps); } /////////////////////////////////////////////////////////////////////////////// template<class T> static PX_FORCE_INLINE void removeRigidActorT(T& rigidActor, NpScene* scene, bool wakeOnLostTouch, bool removeFromAggregate) { PX_ASSERT(rigidActor.getNpScene() == scene); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(scene, "PxScene::removeActor() not allowed while simulation is running. Call will be ignored.") const bool isNoSimActor = rigidActor.getActorFlags().isSet(PxActorFlag::eDISABLE_SIMULATION); if(removeFromAggregate) { PxU32 index = 0xffffffff; NpAggregate* aggregate = rigidActor.getNpAggregate(index); if(aggregate) { aggregate->removeActorAndReinsert(rigidActor, false); PX_ASSERT(!rigidActor.getAggregate()); } } rigidActor.getShapeManager().teardownAllSceneQuery(scene->getSQAPI(), rigidActor); if(!isNoSimActor) rigidActor.removeConstraintsFromScene(); scene->scRemoveActor(rigidActor, wakeOnLostTouch, isNoSimActor); scene->removeFromRigidActorList(rigidActor); OMNI_PVD_REMOVE(OMNI_PVD_CONTEXT_HANDLE, PxScene, actors, static_cast<PxScene &>(*scene), static_cast<PxActor &>(rigidActor)) } void NpScene::removeRigidStatic(NpRigidStatic& actor, bool wakeOnLostTouch, bool removeFromAggregate) { removeRigidActorT(actor, this, wakeOnLostTouch, removeFromAggregate); } void NpScene::removeRigidDynamic(NpRigidDynamic& body, bool wakeOnLostTouch, bool removeFromAggregate) { removeRigidActorT(body, this, wakeOnLostTouch, removeFromAggregate); } /////////////////////////////////////////////////////////////////////////////// bool NpScene::addArticulation(PxArticulationReducedCoordinate& articulation) { PX_PROFILE_ZONE("API.addArticulation", getContextId()); NP_WRITE_CHECK(this); PX_CHECK_AND_RETURN_VAL(articulation.getNbLinks()>0, "PxScene::addArticulation: Empty articulations may not be added to a scene.", false); NpArticulationReducedCoordinate& npa = static_cast<NpArticulationReducedCoordinate&>(articulation); // check that any tendons are not empty #if PX_CHECKED for(PxU32 i = 0u; i < articulation.getNbFixedTendons(); ++i) { PX_CHECK_AND_RETURN_VAL(npa.getFixedTendon(i)->getNbTendonJoints() > 0u, "PxScene::addArticulation: Articulations with empty fixed tendons may not be added to a scene.", false) } for(PxU32 i = 0u; i < articulation.getNbSpatialTendons(); ++i) { PX_CHECK_AND_RETURN_VAL(npa.getSpatialTendon(i)->getNbAttachments() > 0u, "PxScene::addArticulation: Articulations with empty spatial tendons may not be added to a scene.", false) } #endif PX_CHECK_SCENE_API_WRITE_FORBIDDEN_AND_RETURN_VAL(this, "PxScene::addArticulation() not allowed while simulation is running. Call will be ignored.", false); PX_SIMD_GUARD; if(this->getFlags() & PxSceneFlag::eENABLE_GPU_DYNAMICS && articulation.getConcreteType() != PxConcreteType::eARTICULATION_REDUCED_COORDINATE) return outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::addArticulation(): Only Reduced coordinate articulations are currently supported when PxSceneFlag::eENABLE_GPU_DYNAMICS is set!"); if(getSimulationStage() != Sc::SimulationStage::eCOMPLETE && articulation.getConcreteType() == PxConcreteType::eARTICULATION_REDUCED_COORDINATE) return outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::addArticulation(): this call is not allowed while the simulation is running. Call will be ignored!"); if(!npa.getNpScene()) return addArticulationInternal(articulation); else return outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::addArticulation(): Articulation already assigned to a scene. Call will be ignored!"); } static void checkArticulationLink(NpScene* scene, NpArticulationLink* link) { #if PX_CHECKED scene->checkPositionSanity(*link, link->getGlobalPose(), "PxScene::addArticulation or PxScene::addAggregate"); #else PX_UNUSED(scene); #endif if(link->getMass()==0.0f) { outputError<PxErrorCode::eDEBUG_WARNING>(__LINE__, "PxScene::addArticulation(): Articulation link with zero mass added to scene; defaulting mass to 1"); link->setMass(1.0f); } const PxVec3 inertia0 = link->getMassSpaceInertiaTensor(); if(inertia0.x == 0.0f || inertia0.y == 0.0f || inertia0.z == 0.0f) { outputError<PxErrorCode::eDEBUG_WARNING>(__LINE__, "PxScene::addArticulation(): Articulation link with zero moment of inertia added to scene; defaulting inertia to (1,1,1)"); link->setMassSpaceInertiaTensor(PxVec3(1.0f, 1.0f, 1.0f)); } } bool NpScene::addSpatialTendonInternal(NpArticulationReducedCoordinate* npaRC, Sc::ArticulationSim* scArtSim) { const PxU32 nbTendons = npaRC->getNbSpatialTendons(); PxU32 maxAttachments = 0; for (PxU32 i = 0; i < nbTendons; ++i) { NpArticulationSpatialTendon* tendon = npaRC->getSpatialTendon(i); const PxU32 numAttachments = tendon->getNbAttachments(); maxAttachments = PxMax(numAttachments, maxAttachments); } PxU32 stackSize = 1; // Add spatial tendons PX_ALLOCA(attachmentStack, NpArticulationAttachment*, maxAttachments); for (PxU32 i = 0; i < nbTendons; ++i) { NpArticulationSpatialTendon* tendon = npaRC->getSpatialTendon(i); scAddArticulationSpatialTendon(*tendon); //add tendon sim to articulation sim Sc::ArticulationSpatialTendonSim* tendonSim = tendon->getTendonCore().getSim(); scArtSim->addTendon(tendonSim); const PxU32 numAttachments = tendon->getNbAttachments(); // Np check on addArticulation does not allow empty tendons, but assert here. PX_ASSERT(numAttachments); NpArticulationAttachment* attachment = tendon->getAttachment(0); NpArticulationLink* pLink = static_cast<NpArticulationLink*>(attachment->mLink); Sc::ArticulationAttachmentCore& lcore = attachment->getCore(); lcore.mLLLinkIndex = pLink->getLinkIndex(); tendonSim->addAttachment(lcore); attachmentStack[0] = attachment; PxU32 curAttachment = 0; stackSize = 1; while (curAttachment < (numAttachments - 1)) { PX_ASSERT(curAttachment < stackSize); NpArticulationAttachment* p = attachmentStack[curAttachment]; const PxU32 numChildrens = p->getNumChildren(); NpArticulationAttachment*const* children = p->getChildren(); for (PxU32 j = 0; j < numChildrens; j++) { NpArticulationAttachment* child = children[j]; NpArticulationLink* cLink = static_cast<NpArticulationLink*>(child->mLink); Sc::ArticulationAttachmentCore& cCore = child->getCore(); cCore.mLLLinkIndex = cLink->getLinkIndex(); tendonSim->addAttachment(cCore); attachmentStack[stackSize] = child; stackSize++; } curAttachment++; } } return true; } bool NpScene::addFixedTendonInternal(NpArticulationReducedCoordinate* npaRC, Sc::ArticulationSim* scArtSim) { const PxU32 nbFixedTendons = npaRC->getNbFixedTendons(); PxU32 maxTendonJoints = 0; for (PxU32 i = 0; i < nbFixedTendons; ++i) { NpArticulationFixedTendon* tendon = npaRC->getFixedTendon(i); const PxU32 numTendonJoints = tendon->getNbTendonJoints(); maxTendonJoints = PxMax(numTendonJoints, maxTendonJoints); } PxU32 stackSize = 1; // Add fixed tendon joint PX_ALLOCA(tendonJointStack, NpArticulationTendonJoint*, maxTendonJoints); for (PxU32 i = 0; i < nbFixedTendons; ++i) { NpArticulationFixedTendon* tendon = npaRC->getFixedTendon(i); //addTendon(npaRC->getImpl(), *tendon); scAddArticulationFixedTendon(*tendon); //add tendon sim to articulation sim Sc::ArticulationFixedTendonSim* tendonSim = tendon->getTendonCore().getSim(); scArtSim->addTendon(tendonSim); const PxU32 numTendonJoints = tendon->getNbTendonJoints(); // Np check on addArticulation does not allow empty tendons, but assert here. PX_ASSERT(numTendonJoints); NpArticulationTendonJoint* tendonJoint = tendon->getTendonJoint(0); NpArticulationLink* pLink = static_cast<NpArticulationLink*>(tendonJoint->mLink); Sc::ArticulationTendonJointCore& lcore = tendonJoint->getCore(); lcore.mLLLinkIndex = pLink->getLinkIndex(); //add parent joint tendonSim->addTendonJoint(lcore); tendonJointStack[0] = tendonJoint; PxU32 curTendonJoint = 0; stackSize = 1; while (curTendonJoint < (numTendonJoints - 1)) { PX_ASSERT(curTendonJoint < stackSize); NpArticulationTendonJoint* p = tendonJointStack[curTendonJoint]; const PxU32 numChildrens = p->getNumChildren(); NpArticulationTendonJoint*const* children = p->getChildren(); for (PxU32 j = 0; j < numChildrens; j++) { NpArticulationTendonJoint* child = children[j]; NpArticulationLink* cLink = static_cast<NpArticulationLink*>(child->mLink); Sc::ArticulationTendonJointCore& cCore = child->getCore(); cCore.mLLLinkIndex = cLink->getLinkIndex(); tendonSim->addTendonJoint(cCore); tendonJointStack[stackSize] = child; stackSize++; } curTendonJoint++; } } return true; } bool NpScene::addArticulationSensorInternal(NpArticulationReducedCoordinate* npaRC, Sc::ArticulationSim* scArtSim) { const PxU32 nbSensors = npaRC->getNbSensors(); for (PxU32 i = 0; i < nbSensors; ++i) { NpArticulationSensor* sensor = npaRC->getSensor(i); scAddArticulationSensor(*sensor); //add tendon sim to articulation sim Sc::ArticulationSensorSim* sensorSim = sensor->getSensorCore().getSim(); scArtSim->addSensor(sensorSim, sensor->getLink()->getLinkIndex()); } return true; } bool NpScene::addArticulationInternal(PxArticulationReducedCoordinate& npa) { // Add root link first const PxU32 nbLinks = npa.getNbLinks(); PX_ASSERT(nbLinks > 0); NpArticulationReducedCoordinate& npaRC = static_cast<NpArticulationReducedCoordinate&>(npa); NpArticulationLink* rootLink = static_cast<NpArticulationLink*>(npaRC.getRoot()); checkArticulationLink(this, rootLink); bool linkTriggersWakeUp = !rootLink->scCheckSleepReadinessBesidesWakeCounter(); addArticulationLinkBody(*rootLink); // Add articulation scAddArticulation(npaRC); if (npaRC.mTopologyChanged) { //increase cache version npaRC.mCacheVersion++; npaRC.mTopologyChanged = false; } Sc::ArticulationCore& scArtCore = npaRC.getCore(); Sc::ArticulationSim* scArtSim = scArtCore.getSim(); PxU32 handle = scArtSim->findBodyIndex(*rootLink->getCore().getSim()); rootLink->setLLIndex(handle); rootLink->setInboundJointDof(0); addArticulationLinkConstraint(*rootLink); // Add links & joints PX_ALLOCA(linkStack, NpArticulationLink*, nbLinks); linkStack[0] = rootLink; PxU32 curLink = 0; PxU32 stackSize = 1; while(curLink < (nbLinks-1)) { PX_ASSERT(curLink < stackSize); NpArticulationLink* l = linkStack[curLink]; NpArticulationLink*const* children = l->getChildren(); for(PxU32 i=0; i < l->getNbChildren(); i++) { NpArticulationLink* child = children[i]; NpArticulationJointReducedCoordinate* joint = static_cast<NpArticulationJointReducedCoordinate*>(child->getInboundJoint()); Sc::ArticulationJointCore& jCore = joint->getCore(); jCore.getCore().jointDirtyFlag = Dy::ArticulationJointCoreDirtyFlag::eALL; checkArticulationLink(this, child); linkTriggersWakeUp = linkTriggersWakeUp || (!child->scCheckSleepReadinessBesidesWakeCounter()); addArticulationLink(*child); // Adds joint too //child->setInboundJointDof(scArtSim->getDof(child->getLinkIndex())); linkStack[stackSize] = child; stackSize++; } curLink++; } //create low-level tendons addSpatialTendonInternal(&npaRC, scArtSim); addFixedTendonInternal(&npaRC, scArtSim); addArticulationSensorInternal(&npaRC, scArtSim); scArtSim->createLLStructure(); if ((scArtCore.getWakeCounter() == 0.0f) && linkTriggersWakeUp) { //The articulation needs to wake up, if one of the links triggers activation. npaRC.wakeUpInternal(true, false); } mArticulations.insert(&npa); //add loop joints if(scArtCore.getArticulationFlags() & PxArticulationFlag::eFIX_BASE) rootLink->setFixedBaseLink(true); //This method will prepare link data for the gpu mScene.addArticulationSimControl(scArtCore); const PxU32 maxLinks = mScene.getMaxArticulationLinks(); if (maxLinks < nbLinks) mScene.setMaxArticulationLinks(nbLinks); for (PxU32 i = 0; i < npaRC.mLoopJoints.size(); ++i) { Sc::ConstraintSim* cSim = npaRC.mLoopJoints[i]->getCore().getSim(); scArtSim->addLoopConstraint(cSim); } scArtSim->initializeConfiguration(); npaRC.updateKinematic(PxArticulationKinematicFlag::ePOSITION | PxArticulationKinematicFlag::eVELOCITY); if (scArtSim) { //scArtSim->checkResize(); linkStack[0] = rootLink; curLink = 0; stackSize = 1; while (curLink < (nbLinks - 1)) { PX_ASSERT(curLink < stackSize); NpArticulationLink* l = linkStack[curLink]; NpArticulationLink*const* children = l->getChildren(); for (PxU32 i = 0; i < l->getNbChildren(); i++) { NpArticulationLink* child = children[i]; child->setInboundJointDof(scArtSim->getDof(child->getLinkIndex())); NpArticulationJointReducedCoordinate* joint = static_cast<NpArticulationJointReducedCoordinate*>(child->getInboundJoint()); PxArticulationJointType::Enum jointType = joint->getJointType(); if (jointType == PxArticulationJointType::eUNDEFINED) { #if PX_CHECKED outputError<PxErrorCode::eDEBUG_WARNING>(__LINE__, "PxScene::addArticulation(): The application need to set joint type. defaulting joint type to eFix"); #endif joint->scSetJointType(PxArticulationJointType::eFIX); child->setInboundJointDof(0); } if (jointType != PxArticulationJointType::eFIX) { PxArticulationMotion::Enum motionX = joint->getMotion(PxArticulationAxis::eX); PxArticulationMotion::Enum motionY = joint->getMotion(PxArticulationAxis::eY); PxArticulationMotion::Enum motionZ = joint->getMotion(PxArticulationAxis::eZ); PxArticulationMotion::Enum motionSwing1 = joint->getMotion(PxArticulationAxis::eSWING1); PxArticulationMotion::Enum motionSwing2 = joint->getMotion(PxArticulationAxis::eSWING2); PxArticulationMotion::Enum motionTwist = joint->getMotion(PxArticulationAxis::eTWIST); //PxArticulationMotion::eLOCKED is 0 if (!(motionX | motionY | motionZ | motionSwing1 | motionSwing2 | motionTwist)) { //if all axis are locked, which means the user doesn't set the motion. In this case, we should change the joint type to be //fix to avoid crash in the solver #if PX_CHECKED outputError<PxErrorCode::eDEBUG_WARNING>(__LINE__, "PxScene::addArticulation(): Encountered a joint with all motions fixed. Switching joint type to eFix"); #endif joint->scSetJointType(PxArticulationJointType::eFIX); child->setInboundJointDof(0); } } linkStack[stackSize] = child; stackSize++; } curLink++; } } OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) OMNI_PVD_ADD_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, articulations, static_cast<PxScene &>(*this), static_cast<PxArticulationReducedCoordinate&>(npa)); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationReducedCoordinate, dofs, static_cast<PxArticulationReducedCoordinate&>(npa), npa.getDofs()); OMNI_PVD_WRITE_SCOPE_END return true; } void NpScene::removeArticulation(PxArticulationReducedCoordinate& articulation, bool wakeOnLostTouch) { PX_PROFILE_ZONE("API.removeArticulation", getContextId()); NP_WRITE_CHECK(this); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(this, "PxScene::removeArticulation() not allowed while simulation is running. Call will be ignored.") if(removeFromSceneCheck(this, articulation.getScene(), "PxScene::removeArticulation(): Articulation")) removeArticulationInternal(articulation, wakeOnLostTouch, true); } void NpScene::removeArticulationInternal(PxArticulationReducedCoordinate& pxa, bool wakeOnLostTouch, bool removeFromAggregate) { NpArticulationReducedCoordinate& npArticulation = static_cast<NpArticulationReducedCoordinate&>(pxa); PxU32 nbLinks = npArticulation.getNbLinks(); PX_ASSERT(nbLinks > 0); if(removeFromAggregate && npArticulation.getAggregate()) { static_cast<NpAggregate*>(npArticulation.getAggregate())->removeArticulationAndReinsert(npArticulation, false); PX_ASSERT(!npArticulation.getAggregate()); } //!!!AL // Inefficient. We might want to introduce a LL method to kill the whole LL articulation together with all joints in one go, then // the order of removing the links/joints does not matter anymore. // Remove links & joints PX_ALLOCA(linkStack, NpArticulationLink*, nbLinks); linkStack[0] = npArticulation.getLinks()[0]; PxU32 curLink = 0, stackSize = 1; while(curLink < (nbLinks-1)) { PX_ASSERT(curLink < stackSize); NpArticulationLink* l = linkStack[curLink]; NpArticulationLink*const* children = l->getChildren(); for(PxU32 i=0; i < l->getNbChildren(); i++) { linkStack[stackSize] = children[i]; stackSize++; } curLink++; } PxRigidBodyFlags flag; for(PxI32 j=PxI32(nbLinks); j-- > 0; ) { flag |= linkStack[j]->getCore().getCore().mFlags; removeArticulationLink(*linkStack[j], wakeOnLostTouch); } // Remove tendons (RC checked in method) removeArticulationTendons(npArticulation); //Remove sensors removeArticulationSensors(npArticulation); if (flag & PxRigidBodyFlag::eENABLE_SPECULATIVE_CCD) { PxNodeIndex index = npArticulation.getCore().getIslandNodeIndex(); if (index.isValid()) mScene.resetSpeculativeCCDArticulationLink(index.index()); } // Remove articulation scRemoveArticulation(npArticulation); removeFromArticulationList(npArticulation); OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) OMNI_PVD_REMOVE_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, articulations, static_cast<PxScene &>(*this), pxa) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationReducedCoordinate, dofs, pxa, pxa.getDofs()); OMNI_PVD_WRITE_SCOPE_END } /////////////////////////////////////////////////////////////////////////////// bool NpScene::addSoftBody(PxSoftBody& softBody) { if (!(this->getFlags() & PxSceneFlag::eENABLE_GPU_DYNAMICS)) return outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::addActor(): Soft bodies can only be simulated by GPU-accelerated scenes!"); #if PX_SUPPORT_GPU_PHYSX if (!softBody.getSimulationMesh()) return outputError<PxErrorCode::eINVALID_PARAMETER>(__LINE__, "PxScene::addActor(): Soft body does not have simulation mesh, will not be added to scene!"); // Add soft body NpSoftBody& npSB = static_cast<NpSoftBody&>(softBody); scAddSoftBody(npSB); NpShape* npShape = static_cast<NpShape*>(npSB.getShape()); Sc::ShapeCore* shapeCore = &npShape->getCore(); npSB.getCore().attachShapeCore(shapeCore); npSB.getCore().attachSimulationMesh(softBody.getSimulationMesh(), softBody.getSoftBodyAuxData()); mSoftBodies.insert(&softBody); //for gpu soft body mScene.addSoftBodySimControl(npSB.getCore()); return true; #else PX_UNUSED(softBody); return false; #endif } void NpScene::removeSoftBody(PxSoftBody& softBody, bool /*wakeOnLostTouch*/) { #if PX_SUPPORT_GPU_PHYSX // Remove soft body NpSoftBody& npSB = reinterpret_cast<NpSoftBody&>(softBody); scRemoveSoftBody(npSB); removeFromSoftBodyList(softBody); #else PX_UNUSED(softBody); #endif } PxU32 NpScene::getNbSoftBodies() const { #if PX_SUPPORT_GPU_PHYSX NP_READ_CHECK(this); return mSoftBodies.size(); #else return 0; #endif } PxU32 NpScene::getSoftBodies(PxSoftBody** userBuffer, PxU32 bufferSize, PxU32 startIndex) const { #if PX_SUPPORT_GPU_PHYSX NP_READ_CHECK(this); return Cm::getArrayOfPointers(userBuffer, bufferSize, startIndex, mSoftBodies.getEntries(), mSoftBodies.size()); #else PX_UNUSED(userBuffer); PX_UNUSED(bufferSize); PX_UNUSED(startIndex); return 0; #endif } /////////////////////////////////////////////////////////////////////////////// #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION bool NpScene::addFEMCloth(PxFEMCloth& femCloth) { if (!(this->getFlags() & PxSceneFlag::eENABLE_GPU_DYNAMICS)) return PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "PxScene::addFEMCloth(): FEM-cloth can only be simulated by GPU-accelerated scenes!"); #if PX_SUPPORT_GPU_PHYSX // Add FEM-cloth NpFEMCloth& npCloth = static_cast<NpFEMCloth&>(femCloth); scAddFEMCloth(this, npCloth); NpShape* npShape = static_cast<NpShape*>(npCloth.getShape()); Sc::ShapeCore* shapeCore = &npShape->getCore(); npCloth.getCore().attachShapeCore(shapeCore); mFEMCloths.insert(&femCloth); //for gpu FEM-cloth mScene.addFEMClothSimControl(npCloth.getCore()); return true; #else PX_UNUSED(femCloth); return false; #endif } void NpScene::removeFEMCloth(PxFEMCloth& femCloth, bool /*wakeOnLostTouch*/) { #if PX_SUPPORT_GPU_PHYSX // Remove FEM-cloth NpFEMCloth& npCloth = reinterpret_cast<NpFEMCloth&>(femCloth); scRemoveFEMCloth(npCloth); removeFromFEMClothList(femCloth); #else PX_UNUSED(femCloth); #endif } #endif PxU32 NpScene::getNbFEMCloths() const { #if PX_SUPPORT_GPU_PHYSX && PX_ENABLE_FEATURES_UNDER_CONSTRUCTION NP_READ_CHECK(this); return mFEMCloths.size(); #else return 0; #endif } #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION PxU32 NpScene::getFEMCloths(PxFEMCloth** userBuffer, PxU32 bufferSize, PxU32 startIndex) const { #if PX_SUPPORT_GPU_PHYSX NP_READ_CHECK(this); return Cm::getArrayOfPointers(userBuffer, bufferSize, startIndex, mFEMCloths.getEntries(), mFEMCloths.size()); #else PX_UNUSED(userBuffer); PX_UNUSED(bufferSize); PX_UNUSED(startIndex); return 0; #endif } #else PxU32 NpScene::getFEMCloths(PxFEMCloth**, PxU32, PxU32) const { return 0; } #endif /////////////////////////////////////////////////////////////////////////////// bool NpScene::addParticleSystem(PxParticleSystem& particleSystem) { if (!mScene.isUsingGpuDynamicsAndBp()) return outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::addActor(): Particle systems only currently supported with GPU-accelerated scenes!"); #if PX_SUPPORT_GPU_PHYSX switch(particleSystem.getConcreteType()) { case PxConcreteType::ePBD_PARTICLESYSTEM: { NpPBDParticleSystem& npPS = static_cast<NpPBDParticleSystem&>(particleSystem); scAddParticleSystem(npPS); PxPBDParticleSystem& pxPs = static_cast<PxPBDParticleSystem&>(particleSystem); mPBDParticleSystems.insert(&pxPs); mScene.addParticleSystemSimControl(npPS.getCore()); return true; } #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION case PxConcreteType::eFLIP_PARTICLESYSTEM: { NpFLIPParticleSystem& npPS = static_cast<NpFLIPParticleSystem&>(particleSystem); scAddParticleSystem(npPS); PxFLIPParticleSystem& pxPS = static_cast<PxFLIPParticleSystem&>(particleSystem); mFLIPParticleSystems.insert(&pxPS); mScene.addParticleSystemSimControl(npPS.getCore()); return true; } case PxConcreteType::eMPM_PARTICLESYSTEM: { NpMPMParticleSystem& npPS = static_cast<NpMPMParticleSystem&>(particleSystem); scAddParticleSystem(npPS); PxMPMParticleSystem& pxPS = static_cast<PxMPMParticleSystem&>(particleSystem); mMPMParticleSystems.insert(&pxPS); //for gpu particle system mScene.addParticleSystemSimControl(npPS.getCore()); return true; } #endif default: { PX_ASSERT(false); return false; } } #else PX_UNUSED(particleSystem); return false; #endif } void NpScene::removeParticleSystem(PxParticleSystem& particleSystem, bool /*wakeOnLostTouch*/) { #if PX_SUPPORT_GPU_PHYSX switch(particleSystem.getConcreteType()) { case PxConcreteType::ePBD_PARTICLESYSTEM: { // Remove particle system NpPBDParticleSystem& npPS = reinterpret_cast<NpPBDParticleSystem&>(particleSystem); scRemoveParticleSystem(npPS); PxPBDParticleSystem& pxPS = static_cast<PxPBDParticleSystem&>(particleSystem); removeFromParticleSystemList(pxPS); return; } #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION case PxConcreteType::eFLIP_PARTICLESYSTEM: { // Remove particle system NpFLIPParticleSystem& npPS = reinterpret_cast<NpFLIPParticleSystem&>(particleSystem); scRemoveParticleSystem(npPS); PxFLIPParticleSystem& pxPS = static_cast<PxFLIPParticleSystem&>(particleSystem); removeFromParticleSystemList(pxPS); return; } case PxConcreteType::eMPM_PARTICLESYSTEM: { // Remove particle system NpMPMParticleSystem& npPS = reinterpret_cast<NpMPMParticleSystem&>(particleSystem); scRemoveParticleSystem(npPS); PxMPMParticleSystem& pxPS = static_cast<PxMPMParticleSystem&>(particleSystem); removeFromParticleSystemList(pxPS); return; } #endif default: PX_ASSERT(false); } #else PX_UNUSED(particleSystem); #endif } PxU32 NpScene::getNbParticleSystems(PxParticleSolverType::Enum type) const { NP_READ_CHECK(this); #if PX_SUPPORT_GPU_PHYSX switch (type) { case PxParticleSolverType::ePBD: { return mPBDParticleSystems.size(); } case PxParticleSolverType::eFLIP: { #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION return mFLIPParticleSystems.size(); #else return 0; #endif } case PxParticleSolverType::eMPM: { #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION return mMPMParticleSystems.size(); #else return 0; #endif } default: { PX_ASSERT(false); return 0; } } #else PX_UNUSED(type); return 0; #endif } PxU32 NpScene::getParticleSystems(PxParticleSolverType::Enum type, PxParticleSystem** userBuffer, PxU32 bufferSize, PxU32 startIndex) const { NP_READ_CHECK(this); #if PX_SUPPORT_GPU_PHYSX switch (type) { case PxParticleSolverType::ePBD: { return Cm::getArrayOfPointers(userBuffer, bufferSize, startIndex, mPBDParticleSystems.getEntries(), mPBDParticleSystems.size()); } #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION case PxParticleSolverType::eFLIP: { return Cm::getArrayOfPointers(userBuffer, bufferSize, startIndex, mFLIPParticleSystems.getEntries(), mFLIPParticleSystems.size()); } case PxParticleSolverType::eMPM: { return Cm::getArrayOfPointers(userBuffer, bufferSize, startIndex, mMPMParticleSystems.getEntries(), mMPMParticleSystems.size()); } #endif default: { PX_ASSERT(false); return 0; } } #else PX_UNUSED(type); PX_UNUSED(userBuffer); PX_UNUSED(bufferSize); PX_UNUSED(startIndex); return 0; #endif } /////////////////////////////////////////////////////////////////////////////// #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION bool NpScene::addHairSystem(PxHairSystem& hairSystem) { if (!mScene.isUsingGpuDynamicsAndBp()) { return outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::addHairSystem(): Hair systems only currently supported with GPU-accelerated scenes!"); } #if PX_SUPPORT_GPU_PHYSX NpHairSystem& npHairSystem = static_cast<NpHairSystem&>(hairSystem); scAddHairSystem(npHairSystem); mHairSystems.insert(&npHairSystem); mScene.addHairSystemSimControl(npHairSystem.getCore()); return true; #else PX_UNUSED(hairSystem); return false; #endif } void NpScene::removeHairSystem(PxHairSystem& hairSystem, bool /*wakeOnLostTouch*/) { #if PX_SUPPORT_GPU_PHYSX NpHairSystem& npHairSystem = static_cast<NpHairSystem&>(hairSystem); scRemoveHairSystem(npHairSystem); removeFromHairSystemList(hairSystem); #else PX_UNUSED(hairSystem); #endif } #endif PxU32 NpScene::getNbHairSystems() const { #if PX_SUPPORT_GPU_PHYSX && PX_ENABLE_FEATURES_UNDER_CONSTRUCTION NP_READ_CHECK(this); return mHairSystems.size(); #else return 0; #endif } PxU32 NpScene::getHairSystems(PxHairSystem** userBuffer, PxU32 bufferSize, PxU32 startIndex) const { #if PX_SUPPORT_GPU_PHYSX && PX_ENABLE_FEATURES_UNDER_CONSTRUCTION NP_READ_CHECK(this); return Cm::getArrayOfPointers(userBuffer, bufferSize, startIndex, mHairSystems.getEntries(), mHairSystems.size()); #else PX_UNUSED(userBuffer); PX_UNUSED(bufferSize); PX_UNUSED(startIndex); return 0; #endif } /////////////////////////////////////////////////////////////////////////////// void NpScene::addArticulationLinkBody(NpArticulationLink& link) { scAddActor(link, false, NULL, NULL); link.setRigidActorSceneIndex(mRigidActorIndexPool.getNewID()); link.getShapeManager().setupAllSceneQuery(getSQAPI(), link, NULL); } void NpScene::addArticulationLinkConstraint(NpArticulationLink& link) { NpArticulationJointReducedCoordinate* j = static_cast<NpArticulationJointReducedCoordinate*>(link.getInboundJoint()); if (j) { scAddArticulationJoint(*j); } link.addConstraintsToScene(); } void NpScene::addArticulationLink(NpArticulationLink& link) { Sc::ArticulationCore& scArtCore = static_cast<NpArticulationReducedCoordinate&>(link.getArticulation()).getCore(); Sc::ArticulationSim* scArtSim = scArtCore.getSim(); Sc::ArticulationSimDirtyFlags dirtyFlags = scArtSim->getDirtyFlag(); addArticulationLinkBody(link); addArticulationLinkConstraint(link); if (scArtSim) { PxU32 cHandle = scArtSim->findBodyIndex(*link.getCore().getSim()); link.setLLIndex(cHandle); NpArticulationJointReducedCoordinate* j = static_cast<NpArticulationJointReducedCoordinate*>(link.getInboundJoint()); j->getCore().setLLIndex(cHandle); const bool isDirty = (dirtyFlags & Sc::ArticulationSimDirtyFlag::eUPDATE); if (j && (!isDirty)) { getScScene().addDirtyArticulationSim(scArtSim); } } } void NpScene::removeArticulationLink(NpArticulationLink& link, bool wakeOnLostTouch) { NpArticulationJointReducedCoordinate* j = static_cast<NpArticulationJointReducedCoordinate*>(link.getInboundJoint()); link.removeConstraintsFromScene(); link.getShapeManager().teardownAllSceneQuery(getSQAPI(), link); Sc::ArticulationCore& scArtCore = static_cast<NpArticulationReducedCoordinate&>(link.getArticulation()).getCore(); Sc::ArticulationSim* scArtSim = scArtCore.getSim(); Sc::ArticulationSimDirtyFlags dirtyFlags = scArtSim->getDirtyFlag(); if (j) { const bool isDirty = (dirtyFlags & Sc::ArticulationSimDirtyFlag::eUPDATE); if (!isDirty) { getScScene().addDirtyArticulationSim(scArtSim); } const PxU32 linkIndex = link.getLinkIndex(); scArtSim->copyJointStatus(linkIndex); scRemoveArticulationJoint(*j); } scRemoveActor(link, wakeOnLostTouch, false); mRigidActorIndexPool.freeID(link.getRigidActorSceneIndex()); link.setRigidActorSceneIndex(NP_UNUSED_BASE_INDEX); } //////////////////////////////////////////////////////////////////////////////// void NpScene::addArticulationAttachment(NpArticulationAttachment& attachment) { Sc::ArticulationSpatialTendonCore& tendonCore = attachment.getTendon().getTendonCore(); Sc::ArticulationSpatialTendonSim* sim = tendonCore.getSim(); if (sim) { Sc::ArticulationAttachmentCore& attachmentCore = attachment.getCore(); attachmentCore.mLLLinkIndex = attachment.mLink->getLinkIndex(); sim->addAttachment(attachmentCore); } } void NpScene::removeArticulationAttachment(NpArticulationAttachment& attachment) { Sc::ArticulationSpatialTendonCore& tendonCore = attachment.getTendon().getTendonCore(); Sc::ArticulationSpatialTendonSim* sim = tendonCore.getSim(); if (sim) { Sc::ArticulationAttachmentCore& attachmentCore = attachment.getCore(); sim->removeAttachment(attachmentCore); } } //////////////////////////////////////////////////////////////////////////////////// void NpScene::addArticulationTendonJoint(NpArticulationTendonJoint& tendonJoint) { Sc::ArticulationFixedTendonCore& tendonCore = tendonJoint.getTendon().getTendonCore(); Sc::ArticulationFixedTendonSim* sim = tendonCore.getSim(); if (sim) { Sc::ArticulationTendonJointCore& jointCore = tendonJoint.getCore(); jointCore.mLLLinkIndex = tendonJoint.mLink->getLinkIndex(); sim->addTendonJoint(jointCore); } } void NpScene::removeArticulationTendonJoint(NpArticulationTendonJoint& joint) { Sc::ArticulationFixedTendonCore& tendonCore = joint.getTendon().getTendonCore(); Sc::ArticulationFixedTendonSim* sim = tendonCore.getSim(); if (sim) { Sc::ArticulationTendonJointCore& jointCore = joint.getCore(); sim->removeTendonJoint(jointCore); } } void NpScene::removeArticulationTendons(PxArticulationReducedCoordinate& articulation) { NpArticulationReducedCoordinate* npaRC = static_cast<NpArticulationReducedCoordinate*>(&articulation); // Remove spatial tendons const PxU32 nbSpatialTendons = npaRC->getNbSpatialTendons(); for(PxU32 i = 0; i < nbSpatialTendons; i++) { NpArticulationSpatialTendon* tendon = npaRC->getSpatialTendon(i); npaRC->removeSpatialTendonInternal(tendon); } //Remove fixed tendons const PxU32 nbFixedTendons = npaRC->getNbFixedTendons(); for(PxU32 i = 0; i < nbFixedTendons; i++) { NpArticulationFixedTendon* tendon = npaRC->getFixedTendon(i); npaRC->removeFixedTendonInternal(tendon); } } void NpScene::removeArticulationSensors(PxArticulationReducedCoordinate& articulation) { NpArticulationReducedCoordinate* npaRC = static_cast<NpArticulationReducedCoordinate*>(&articulation); //Remove sensors const PxU32 nbSensors = npaRC->getNbSensors(); for (PxU32 i = 0; i < nbSensors; i++) { NpArticulationSensor* sensor = npaRC->getSensor(i); npaRC->removeSensorInternal(sensor); } } /////////////////////////////////////////////////////////////////////////////// void NpScene::scAddAggregate(NpAggregate& agg) { PX_ASSERT(!isAPIWriteForbidden()); agg.setNpScene(this); const PxU32 aggregateID = mScene.createAggregate(&agg, agg.getMaxNbShapesFast(), agg.getFilterHint()); agg.setAggregateID(aggregateID); #if PX_SUPPORT_PVD //Sending pvd events after all aggregates's actors are inserted into scene mScenePvdClient.createPvdInstance(&agg); #endif } void NpScene::scRemoveAggregate(NpAggregate& agg) { PX_ASSERT(!isAPIWriteForbidden()); mScene.deleteAggregate(agg.getAggregateID()); agg.setNpScene(NULL); #if PX_SUPPORT_PVD mScenePvdClient.releasePvdInstance(&agg); #endif } bool NpScene::addAggregate(PxAggregate& aggregate) { PX_PROFILE_ZONE("API.addAggregate", getContextId()); NP_WRITE_CHECK(this); PX_CHECK_SCENE_API_WRITE_FORBIDDEN_AND_RETURN_VAL(this, "PxScene::addAggregate() not allowed while simulation is running. Call will be ignored.", false) PX_SIMD_GUARD; NpAggregate& np = static_cast<NpAggregate&>(aggregate); #if PX_CHECKED { const PxU32 nb = np.getCurrentSizeFast(); for(PxU32 i=0;i<nb;i++) { PxRigidStatic* a = np.getActorFast(i)->is<PxRigidStatic>(); if(a && !static_cast<NpRigidStatic*>(a)->checkConstraintValidity()) return outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::addAggregate(): Aggregate contains an actor with an invalid constraint!"); } } #endif if(mScene.isUsingGpuDynamicsOrBp() && np.getMaxNbShapesFast() == PX_MAX_U32) return outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::addAggregate(): Aggregates cannot be added to GPU scene unless you provide a maxNbShapes!"); if(np.getNpScene()) return outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::addAggregate(): Aggregate already assigned to a scene. Call will be ignored!"); scAddAggregate(np); np.addToScene(*this); mAggregates.insert(&aggregate); OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) OMNI_PVD_ADD_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, aggregates, static_cast<PxScene&>(*this), aggregate); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxAggregate, scene, aggregate, static_cast<PxScene const*>(this)); OMNI_PVD_WRITE_SCOPE_END return true; } void NpScene::removeAggregate(PxAggregate& aggregate, bool wakeOnLostTouch) { PX_PROFILE_ZONE("API.removeAggregate", getContextId()); NP_WRITE_CHECK(this); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(this, "PxScene::removeAggregate() not allowed while simulation is running. Call will be ignored.") if(!removeFromSceneCheck(this, aggregate.getScene(), "PxScene::removeAggregate(): Aggregate")) return; NpAggregate& np = static_cast<NpAggregate&>(aggregate); if(np.getScene()!=this) return; const PxU32 nb = np.getCurrentSizeFast(); for(PxU32 j=0;j<nb;j++) { PxActor* a = np.getActorFast(j); PX_ASSERT(a); if (a->getType() != PxActorType::eARTICULATION_LINK) { NpActor& sc = NpActor::getFromPxActor(*a); np.scRemoveActor(sc, false); // This is only here to make sure the aggregateID gets set to invalid removeActorInternal(*a, wakeOnLostTouch, false); } else if (a->getScene()) { NpArticulationLink& al = static_cast<NpArticulationLink&>(*a); NpArticulationReducedCoordinate& npArt = static_cast<NpArticulationReducedCoordinate&>(al.getRoot()); NpArticulationLink* const* links = npArt.getLinks(); for(PxU32 i=0; i < npArt.getNbLinks(); i++) { np.scRemoveActor(*links[i], false); // This is only here to make sure the aggregateID gets set to invalid } removeArticulationInternal(npArt, wakeOnLostTouch, false); } } scRemoveAggregate(np); removeFromAggregateList(aggregate); OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) OMNI_PVD_REMOVE_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, aggregates, static_cast<PxScene&>(*this), aggregate); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxAggregate, scene, aggregate, static_cast<PxScene const*>(NULL)); OMNI_PVD_WRITE_SCOPE_END } PxU32 NpScene::getNbAggregates() const { NP_READ_CHECK(this); return mAggregates.size(); } PxU32 NpScene::getAggregates(PxAggregate** userBuffer, PxU32 bufferSize, PxU32 startIndex) const { NP_READ_CHECK(this); return Cm::getArrayOfPointers(userBuffer, bufferSize, startIndex, mAggregates.getEntries(), mAggregates.size()); } /////////////////////////////////////////////////////////////////////////////// void NpScene::scSwitchRigidToNoSim(NpActor& r) { PX_ASSERT(!isAPIWriteForbidden()); if(r.getNpScene()) { PxInlineArray<const Sc::ShapeCore*, 64> scShapes; const NpType::Enum npType = r.getNpType(); if(npType==NpType::eRIGID_STATIC) getScScene().removeStatic(static_cast<NpRigidStatic&>(r).getCore(), scShapes, true); else if(npType==NpType::eBODY) getScScene().removeBody(static_cast<NpRigidDynamic&>(r).getCore(), scShapes, true); else if(npType==NpType::eBODY_FROM_ARTICULATION_LINK) getScScene().removeBody(static_cast<NpArticulationLink&>(r).getCore(), scShapes, true); else PX_ASSERT(0); } } void NpScene::scSwitchRigidFromNoSim(NpActor& r) { PX_ASSERT(!isAPIWriteForbidden()); if(r.getNpScene()) { NpShape* const* shapes; const size_t shapePtrOffset = NpShape::getCoreOffset(); PxU32 nbShapes; { bool isCompound; const NpType::Enum npType = r.getNpType(); if(npType==NpType::eRIGID_STATIC) { NpRigidStatic& np = static_cast<NpRigidStatic&>(r); nbShapes = NpRigidStaticGetShapes(np, shapes); getScScene().addStatic(np.getCore(), shapes, nbShapes, shapePtrOffset, NULL); } else if(npType==NpType::eBODY) { NpRigidDynamic& np = static_cast<NpRigidDynamic&>(r); nbShapes = NpRigidDynamicGetShapes(np, shapes, &isCompound); getScScene().addBody(np.getCore(), shapes, nbShapes, shapePtrOffset, NULL, isCompound); } else if(npType==NpType::eBODY_FROM_ARTICULATION_LINK) { NpArticulationLink& np = static_cast<NpArticulationLink&>(r); nbShapes = NpArticulationGetShapes(np, shapes, &isCompound); getScScene().addBody(np.getCore(), shapes, nbShapes, shapePtrOffset, NULL, isCompound); } else { nbShapes = 0; shapes = NULL; isCompound = false; PX_ASSERT(0); } } } } /////////////////////////////////////////////////////////////////////////////// bool NpScene::addCollection(const PxCollection& collection) { PX_PROFILE_ZONE("API.addCollection", getContextId()); const Cm::Collection& col = static_cast<const Cm::Collection&>(collection); PxU32 nb = col.internalGetNbObjects(); #if PX_CHECKED for(PxU32 i=0;i<nb;i++) { PxRigidStatic* a = col.internalGetObject(i)->is<PxRigidStatic>(); if(a && !static_cast<NpRigidStatic*>(a)->checkConstraintValidity()) return outputError<PxErrorCode::eINVALID_OPERATION>( __LINE__, "PxScene::addCollection(): collection contains an actor with an invalid constraint!"); } #endif PxArray<PxActor*> actorsToInsert; actorsToInsert.reserve(nb); struct Local { static void addActorIfNeeded(PxActor* actor, PxArray<PxActor*>& actorArray) { if(actor->getAggregate()) return; // The actor will be added when the aggregate is added actorArray.pushBack(actor); } }; for(PxU32 i=0;i<nb;i++) { PxBase* s = col.internalGetObject(i); const PxType serialType = s->getConcreteType(); //NpArticulationLink, NpArticulationJoint are added with the NpArticulation //Actors and Articulations that are members of an Aggregate are added with the NpAggregate if(serialType==PxConcreteType::eRIGID_DYNAMIC) { NpRigidDynamic* np = static_cast<NpRigidDynamic*>(s); // if pruner structure exists for the actor, actor will be added with the pruner structure if(!np->getShapeManager().getPruningStructure()) Local::addActorIfNeeded(np, actorsToInsert); } else if(serialType==PxConcreteType::eRIGID_STATIC) { NpRigidStatic* np = static_cast<NpRigidStatic*>(s); // if pruner structure exists for the actor, actor will be added with the pruner structure if(!np->getShapeManager().getPruningStructure()) Local::addActorIfNeeded(np, actorsToInsert); } else if(serialType==PxConcreteType::eSHAPE) { } else if (serialType == PxConcreteType::eARTICULATION_REDUCED_COORDINATE) { NpArticulationReducedCoordinate* np = static_cast<NpArticulationReducedCoordinate*>(s); if (!np->getAggregate()) // The actor will be added when the aggregate is added { addArticulation(static_cast<PxArticulationReducedCoordinate&>(*np)); } } else if(serialType==PxConcreteType::eAGGREGATE) { NpAggregate* np = static_cast<NpAggregate*>(s); addAggregate(*np); } else if(serialType == PxConcreteType::ePRUNING_STRUCTURE) { PxPruningStructure* ps = static_cast<PxPruningStructure*>(s); addActors(*ps); } } if(!actorsToInsert.empty()) addActorsInternal(&actorsToInsert[0], actorsToInsert.size(), NULL); return true; } /////////////////////////////////////////////////////////////////////////////// PxU32 NpScene::getNbActors(PxActorTypeFlags types) const { NP_READ_CHECK(this); PxU32 nbActors = 0; if(types & PxActorTypeFlag::eRIGID_STATIC) nbActors += mRigidStatics.size(); if(types & PxActorTypeFlag::eRIGID_DYNAMIC) nbActors += mRigidDynamics.size(); return nbActors; } static PxU32 getArrayOfPointers_RigidActors(PxActor** PX_RESTRICT userBuffer, PxU32 bufferSize, PxU32 startIndex, NpRigidStatic*const* PX_RESTRICT src0, PxU32 size0, NpRigidDynamic*const* PX_RESTRICT src1, PxU32 size1) { // PT: we run the same code as getArrayOfPointers but with a virtual array containing both static & dynamic actors. const PxU32 size = size0 + size1; const PxU32 remainder = PxU32(PxMax<PxI32>(PxI32(size - startIndex), 0)); const PxU32 writeCount = PxMin(remainder, bufferSize); for(PxU32 i=0;i<writeCount;i++) { const PxU32 index = startIndex+i; PX_ASSERT(index<size); if(index<size0) userBuffer[i] = src0[index]; else userBuffer[i] = src1[index-size0]; } return writeCount; } PxU32 NpScene::getActors(PxActorTypeFlags types, PxActor** buffer, PxU32 bufferSize, PxU32 startIndex) const { NP_READ_CHECK(this); const bool wantsStatic = types & PxActorTypeFlag::eRIGID_STATIC; const bool wantsDynamic = types & PxActorTypeFlag::eRIGID_DYNAMIC; if(wantsStatic && !wantsDynamic) return Cm::getArrayOfPointers(buffer, bufferSize, startIndex, mRigidStatics.begin(), mRigidStatics.size()); if(!wantsStatic && wantsDynamic) return Cm::getArrayOfPointers(buffer, bufferSize, startIndex, mRigidDynamics.begin(), mRigidDynamics.size()); if(wantsStatic && wantsDynamic) { return getArrayOfPointers_RigidActors(buffer, bufferSize, startIndex, mRigidStatics.begin(), mRigidStatics.size(), mRigidDynamics.begin(), mRigidDynamics.size()); } return 0; } /////////////////////////////////////////////////////////////////////////////// PxActor** NpScene::getActiveActors(PxU32& nbActorsOut) { NP_READ_CHECK(this); if(!isAPIWriteForbidden()) return mScene.getActiveActors(nbActorsOut); else { outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::getActiveActors() not allowed while simulation is running. Call will be ignored."); nbActorsOut = 0; return NULL; } } PxActor** NpScene::getFrozenActors(PxU32& nbActorsOut) { NP_READ_CHECK(this); if(!isAPIWriteForbidden()) return mScene.getFrozenActors(nbActorsOut); else { outputError<PxErrorCode::eDEBUG_WARNING>(__LINE__, "PxScene::getFrozenActors() not allowed while simulation is running. Call will be ignored."); nbActorsOut = 0; return NULL; } } void NpScene::setFrozenActorFlag(const bool buildFrozenActors) { #if PX_CHECKED PxSceneFlags combinedFlag(PxSceneFlag::eENABLE_ACTIVE_ACTORS | PxSceneFlag::eENABLE_STABILIZATION); PX_CHECK_AND_RETURN((getFlags() & combinedFlag)== combinedFlag, "NpScene::setFrozenActorFlag: Cannot raise BuildFrozenActors if PxSceneFlag::eENABLE_STABILIZATION and PxSceneFlag::eENABLE_ACTIVE_ACTORS is not raised!"); #endif mBuildFrozenActors = buildFrozenActors; } /////////////////////////////////////////////////////////////////////////////// PxU32 NpScene::getNbArticulations() const { NP_READ_CHECK(this); return mArticulations.size(); } PxU32 NpScene::getArticulations(PxArticulationReducedCoordinate** userBuffer, PxU32 bufferSize, PxU32 startIndex) const { NP_READ_CHECK(this); return Cm::getArrayOfPointers(userBuffer, bufferSize, startIndex, mArticulations.getEntries(), mArticulations.size()); } /////////////////////////////////////////////////////////////////////////////// PxU32 NpScene::getNbConstraints() const { NP_READ_CHECK(this); return mScene.getNbConstraints(); } static PX_FORCE_INLINE PxU32 getArrayOfPointers(PxConstraint** PX_RESTRICT userBuffer, PxU32 bufferSize, PxU32 startIndex, Sc::ConstraintCore*const* PX_RESTRICT src, PxU32 size) { const PxU32 remainder = PxU32(PxMax<PxI32>(PxI32(size - startIndex), 0)); const PxU32 writeCount = PxMin(remainder, bufferSize); src += startIndex; for(PxU32 i=0;i<writeCount;i++) { PxConstraint* pxc = src[i]->getPxConstraint(); userBuffer[i] = static_cast<PxConstraint*>(pxc); } return writeCount; } PxU32 NpScene::getConstraints(PxConstraint** userBuffer, PxU32 bufferSize, PxU32 startIndex) const { NP_READ_CHECK(this); return ::getArrayOfPointers(userBuffer, bufferSize, startIndex, mScene.getConstraints(), mScene.getNbConstraints()); } /////////////////////////////////////////////////////////////////////////////// const PxRenderBuffer& NpScene::getRenderBuffer() { if (getSimulationStage() != Sc::SimulationStage::eCOMPLETE) { // will be reading the Sc::Scene renderable which is getting written // during the sim, hence, avoid call while simulation is running. outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::getRenderBuffer() not allowed while simulation is running. Call will be ignored."); } return mRenderBuffer; } /////////////////////////////////////////////////////////////////////////////// void NpScene::getSimulationStatistics(PxSimulationStatistics& s) const { NP_READ_CHECK(this); if (getSimulationStage() == Sc::SimulationStage::eCOMPLETE) { #if PX_ENABLE_SIM_STATS mScene.getStats(s); #else PX_CATCH_UNDEFINED_ENABLE_SIM_STATS PX_UNUSED(s); #endif } else { //will be reading data that is getting written during the sim, hence, avoid call while simulation is running. outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::getSimulationStatistics() not allowed while simulation is running. Call will be ignored."); } } /////////////////////////////////////////////////////////////////////////////// PxClientID NpScene::createClient() { NP_WRITE_CHECK(this); // PT: mNbClients starts at 1, 0 reserved for PX_DEFAULT_CLIENT const PxClientID clientID = PxClientID(mNbClients); mNbClients++; return clientID; } /////////////////////////////////////////////////////////////////////////////// PxSolverType::Enum NpScene::getSolverType() const { NP_READ_CHECK(this); return mScene.getSolverType(); } //FrictionModel PxFrictionType::Enum NpScene::getFrictionType() const { NP_READ_CHECK(this); return mScene.getFrictionType(); } /////////////////////////////////////////////////////////////////////////////// // Callbacks void NpScene::setSimulationEventCallback(PxSimulationEventCallback* callback) { NP_WRITE_CHECK(this); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(this, "PxScene::setSimulationEventCallback() not allowed while simulation is running. Call will be ignored.") mScene.setSimulationEventCallback(callback); updatePvdProperties(); OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxScene, hasSimulationEventCallback, static_cast<PxScene&>(*this), callback ? true : false) } PxSimulationEventCallback* NpScene::getSimulationEventCallback() const { NP_READ_CHECK(this); return mScene.getSimulationEventCallback(); } void NpScene::setContactModifyCallback(PxContactModifyCallback* callback) { NP_WRITE_CHECK(this); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(this, "PxScene::setContactModifyCallback() not allowed while simulation is running. Call will be ignored.") mScene.setContactModifyCallback(callback); updatePvdProperties(); OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxScene, hasContactModifyCallback, static_cast<PxScene&>(*this), callback ? true : false) } PxContactModifyCallback* NpScene::getContactModifyCallback() const { NP_READ_CHECK(this); return mScene.getContactModifyCallback(); } void NpScene::setCCDContactModifyCallback(PxCCDContactModifyCallback* callback) { NP_WRITE_CHECK(this); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(this, "PxScene::setCCDContactModifyCallback() not allowed while simulation is running. Call will be ignored.") mScene.setCCDContactModifyCallback(callback); updatePvdProperties(); OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxScene, hasCCDContactModifyCallback, static_cast<PxScene&>(*this), callback ? true : false) } PxCCDContactModifyCallback* NpScene::getCCDContactModifyCallback() const { NP_READ_CHECK(this); return mScene.getCCDContactModifyCallback(); } void NpScene::setBroadPhaseCallback(PxBroadPhaseCallback* callback) { NP_WRITE_CHECK(this); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(this, "PxScene::setBroadPhaseCallback() not allowed while simulation is running. Call will be ignored.") mScene.getBroadphaseManager().setBroadPhaseCallback(callback); updatePvdProperties(); OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxScene, hasBroadPhaseCallback, static_cast<PxScene&>(*this), callback ? true : false) } PxBroadPhaseCallback* NpScene::getBroadPhaseCallback() const { NP_READ_CHECK(this); return mScene.getBroadphaseManager().getBroadPhaseCallback(); } void NpScene::setCCDMaxPasses(PxU32 ccdMaxPasses) { NP_WRITE_CHECK(this); PX_CHECK_AND_RETURN((ccdMaxPasses!=0), "PxScene::setCCDMaxPasses(): ccd max passes cannot be zero!"); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(this, "PxScene::setCCDMaxPasses() not allowed while simulation is running. Call will be ignored.") mScene.setCCDMaxPasses(ccdMaxPasses); updatePvdProperties(); OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxScene, ccdMaxPasses, static_cast<PxScene&>(*this), ccdMaxPasses) } PxU32 NpScene::getCCDMaxPasses() const { NP_READ_CHECK(this); return mScene.getCCDMaxPasses(); } void NpScene::setCCDMaxSeparation(const PxReal separation) { NP_WRITE_CHECK(this); PX_CHECK_AND_RETURN((separation>=0.0f), "PxScene::setCCDMaxSeparation(): separation value has to be in [0, PX_MAX_F32)!"); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(this, "PxScene::setCCDMaxSeparation() not allowed while simulation is running. Call will be ignored.") mScene.setCCDMaxSeparation(separation); updatePvdProperties(); OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxScene, ccdMaxSeparation, static_cast<PxScene&>(*this), separation) } PxReal NpScene::getCCDMaxSeparation() const { NP_READ_CHECK(this); return mScene.getCCDMaxSeparation(); } void NpScene::setCCDThreshold(const PxReal t) { NP_WRITE_CHECK(this); PX_CHECK_AND_RETURN((t>0.0f), "PxScene::setCCDThreshold(): threshold value has to be in [eps, PX_MAX_F32)!"); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(this, "PxScene::setCCDThreshold() not allowed while simulation is running. Call will be ignored.") mScene.setCCDThreshold(t); updatePvdProperties(); OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxScene, ccdThreshold, static_cast<PxScene&>(*this), t) } PxReal NpScene::getCCDThreshold() const { NP_READ_CHECK(this); return mScene.getCCDThreshold(); } PxBroadPhaseType::Enum NpScene::getBroadPhaseType() const { NP_READ_CHECK(this); const Bp::BroadPhase* bp = mScene.getAABBManager()->getBroadPhase(); return bp->getType(); } bool NpScene::getBroadPhaseCaps(PxBroadPhaseCaps& caps) const { NP_READ_CHECK(this); const Bp::BroadPhase* bp = mScene.getAABBManager()->getBroadPhase(); bp->getCaps(caps); return true; } PxU32 NpScene::getNbBroadPhaseRegions() const { NP_READ_CHECK(this); const Bp::BroadPhase* bp = mScene.getAABBManager()->getBroadPhase(); return bp->getNbRegions(); } PxU32 NpScene::getBroadPhaseRegions(PxBroadPhaseRegionInfo* userBuffer, PxU32 bufferSize, PxU32 startIndex) const { NP_READ_CHECK(this); const Bp::BroadPhase* bp = mScene.getAABBManager()->getBroadPhase(); return bp->getRegions(userBuffer, bufferSize, startIndex); } PxU32 NpScene::addBroadPhaseRegion(const PxBroadPhaseRegion& region, bool populateRegion) { PX_PROFILE_ZONE("BroadPhase.addBroadPhaseRegion", getContextId()); NP_WRITE_CHECK(this); PX_CHECK_MSG(region.mBounds.isValid(), "PxScene::addBroadPhaseRegion(): invalid bounds provided!"); PX_CHECK_SCENE_API_WRITE_FORBIDDEN_AND_RETURN_VAL(this, "PxScene::addBroadPhaseRegion() not allowed while simulation is running. Call will be ignored.", 0xffffffff) if(region.mBounds.isEmpty()) { outputError<PxErrorCode::eINVALID_PARAMETER>(__LINE__, "PxScene::addBroadPhaseRegion(): region bounds are empty. Call will be ignored."); return 0xffffffff; } Bp::AABBManagerBase* aabbManager = mScene.getAABBManager(); Bp::BroadPhase* bp = aabbManager->getBroadPhase(); return bp->addRegion(region, populateRegion, aabbManager->getBoundsArray().begin(), aabbManager->getContactDistances()); } bool NpScene::removeBroadPhaseRegion(PxU32 handle) { NP_WRITE_CHECK(this); PX_CHECK_SCENE_API_WRITE_FORBIDDEN_AND_RETURN_VAL(this, "PxScene::removeBroadPhaseRegion() not allowed while simulation is running. Call will be ignored.", false) Bp::BroadPhase* bp = mScene.getAABBManager()->getBroadPhase(); return bp->removeRegion(handle); } /////////////////////////////////////////////////////////////////////////////// // Filtering void NpScene::setFilterShaderData(const void* data, PxU32 dataSize) { NP_WRITE_CHECK(this); PX_CHECK_AND_RETURN(( ((dataSize == 0) && (data == NULL)) || ((dataSize > 0) && (data != NULL)) ), "PxScene::setFilterShaderData(): data pointer must not be NULL unless the specified data size is 0 too and vice versa."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(this, "PxScene::setFilterShaderData() not allowed while simulation is running. Call will be ignored.") mScene.setFilterShaderData(data, dataSize); updatePvdProperties(); } const void* NpScene::getFilterShaderData() const { NP_READ_CHECK(this); return mScene.getFilterShaderDataFast(); } PxU32 NpScene::getFilterShaderDataSize() const { NP_READ_CHECK(this); return mScene.getFilterShaderDataSizeFast(); } PxSimulationFilterShader NpScene::getFilterShader() const { NP_READ_CHECK(this); return mScene.getFilterShaderFast(); } PxSimulationFilterCallback* NpScene::getFilterCallback() const { NP_READ_CHECK(this); return mScene.getFilterCallbackFast(); } bool NpScene::resetFiltering(PxActor& actor) { NP_WRITE_CHECK(this); PX_CHECK_AND_RETURN_VAL(NpActor::getNpSceneFromActor(actor) && (NpActor::getNpSceneFromActor(actor) == this), "PxScene::resetFiltering(): Actor must be in a scene.", false); PX_CHECK_SCENE_API_WRITE_FORBIDDEN_AND_RETURN_VAL(this, "PxScene::resetFiltering() not allowed while simulation is running. Call will be ignored.", false) bool status; switch(actor.getConcreteType()) { case PxConcreteType::eRIGID_STATIC: { NpRigidStatic& npStatic = static_cast<NpRigidStatic&>(actor); status = npStatic.NpRigidStaticT::resetFiltering_(npStatic, npStatic.getCore(), NULL, 0); } break; case PxConcreteType::eRIGID_DYNAMIC: { NpRigidDynamic& npDynamic = static_cast<NpRigidDynamic&>(actor); status = npDynamic.resetFiltering_(npDynamic, npDynamic.getCore(), NULL, 0); if(status) npDynamic.wakeUpInternal(); } break; case PxConcreteType::eARTICULATION_LINK: { NpArticulationLink& npLink = static_cast<NpArticulationLink&>(actor); status = npLink.resetFiltering_(npLink, npLink.getCore(), NULL, 0); if(status) { NpArticulationReducedCoordinate& npArticulation = static_cast<NpArticulationReducedCoordinate&>(npLink.getRoot()); npArticulation.wakeUpInternal(false, true); } } break; default: status = outputError<PxErrorCode::eINVALID_PARAMETER>(__LINE__, "PxScene::resetFiltering(): only PxRigidActor supports this operation!"); } return status; } bool NpScene::resetFiltering(PxRigidActor& actor, PxShape*const* shapes, PxU32 shapeCount) { NP_WRITE_CHECK(this); PX_CHECK_AND_RETURN_VAL(NpActor::getNpSceneFromActor(actor) && (NpActor::getNpSceneFromActor(actor) == this), "PxScene::resetFiltering(): Actor must be in a scene.", false); PX_CHECK_SCENE_API_WRITE_FORBIDDEN_AND_RETURN_VAL(this, "PxScene::resetFiltering() not allowed while simulation is running. Call will be ignored.", false) PX_SIMD_GUARD; bool status = false; switch(actor.getConcreteType()) { case PxConcreteType::eRIGID_STATIC: { NpRigidStatic& npStatic = static_cast<NpRigidStatic&>(actor); status = npStatic.NpRigidStaticT::resetFiltering_(npStatic, npStatic.getCore(), shapes, shapeCount); } break; case PxConcreteType::eRIGID_DYNAMIC: { NpRigidDynamic& npDynamic = static_cast<NpRigidDynamic&>(actor); status = npDynamic.resetFiltering_(npDynamic, npDynamic.getCore(), shapes, shapeCount); if(status) npDynamic.wakeUpInternal(); } break; case PxConcreteType::eARTICULATION_LINK: { NpArticulationLink& npLink = static_cast<NpArticulationLink&>(actor); status = npLink.resetFiltering_(npLink, npLink.getCore(), shapes, shapeCount); if(status) { NpArticulationReducedCoordinate& impl = static_cast<NpArticulationReducedCoordinate&>(npLink.getRoot()); impl.wakeUpInternal(false, true); } } break; } return status; } PxPairFilteringMode::Enum NpScene::getKinematicKinematicFilteringMode() const { NP_READ_CHECK(this); return mScene.getKineKineFilteringMode(); } PxPairFilteringMode::Enum NpScene::getStaticKinematicFilteringMode() const { NP_READ_CHECK(this); return mScene.getStaticKineFilteringMode(); } /////////////////////////////////////////////////////////////////////////////// PxPhysics& NpScene::getPhysics() { return mPhysics; } void NpScene::updateConstants(const PxArray<NpConstraint*>& constraints) { PxsSimulationController* simController = mScene.getSimulationController(); PX_ASSERT(simController); PxU32 nbConstraints = constraints.size(); NpConstraint*const* currentConstraint = constraints.begin(); while(nbConstraints--) { (*currentConstraint)->updateConstants(*simController); currentConstraint++; } } void NpScene::updateDirtyShaders() { PX_PROFILE_ZONE("Sim.updateDirtyShaders", getContextId()); // this should continue to be done in the Np layer even after SC has taken over // all vital simulation functions, because it needs to complete before simulate() // returns to the application #ifdef NEW_DIRTY_SHADERS_CODE if(1) { updateConstants(mAlwaysUpdatedConstraints); updateConstants(mDirtyConstraints); mDirtyConstraints.clear(); } else #endif { // However, the implementation needs fixing so that it does work proportional to // the number of dirty shaders PxsSimulationController* simController = mScene.getSimulationController(); PX_ASSERT(simController); const PxU32 nbConstraints = mScene.getNbConstraints(); Sc::ConstraintCore*const* constraints = mScene.getConstraints(); for(PxU32 i=0;i<nbConstraints;i++) { PxConstraint* pxc = constraints[i]->getPxConstraint(); static_cast<NpConstraint*>(pxc)->updateConstants(*simController); } } } // PT: TODO // - do we really need a different mutex per material type? // - classes like PxsMaterialManager are already typedef of templated types so maybe we don't need them here template<class NpMaterialT, class MaterialManagerT, class MaterialCoreT> static void updateLowLevelMaterials(NpPhysics& physics, PxMutex& sceneMaterialBufferLock, MaterialManagerT& pxsMaterialManager, PxArray<NpScene::MaterialEvent>& materialBuffer, PxvNphaseImplementationContext* context) { PxMutex::ScopedLock lock(sceneMaterialBufferLock); NpMaterialT** masterMaterial = NpMaterialAccessor<NpMaterialT>::getMaterialManager(physics).getMaterials(); //sync all the material events const PxU32 size = materialBuffer.size(); for(PxU32 i=0; i<size; i++) { const NpScene::MaterialEvent& event = materialBuffer[i]; const NpMaterialT* masMat = masterMaterial[event.mHandle]; switch(event.mType) { case NpScene::MATERIAL_ADD: if(masMat) { MaterialCoreT* materialCore = &masterMaterial[event.mHandle]->mMaterial; pxsMaterialManager.setMaterial(materialCore); context->registerMaterial(*materialCore); } break; case NpScene::MATERIAL_UPDATE: if(masMat) { MaterialCoreT* materialCore = &masterMaterial[event.mHandle]->mMaterial; pxsMaterialManager.updateMaterial(materialCore); context->updateMaterial(*materialCore); } break; case NpScene::MATERIAL_REMOVE: if (event.mHandle < pxsMaterialManager.getMaxSize()) // materials might get added and then removed again immediately. However, the add does not get processed (see case MATERIAL_ADD above), { // so the remove might end up reading out of bounds memory unless checked. MaterialCoreT* materialCore = pxsMaterialManager.getMaterial(event.mHandle); if (materialCore->mMaterialIndex == event.mHandle) { context->unregisterMaterial(*materialCore); pxsMaterialManager.removeMaterial(materialCore); } } break; }; } materialBuffer.resize(0); } void NpScene::syncMaterialEvents() { //sync all the material events PxvNphaseImplementationContext* context = mScene.getLowLevelContext()->getNphaseImplementationContext(); updateLowLevelMaterials<NpMaterial, PxsMaterialManager, PxsMaterialCore>(mPhysics, mSceneMaterialBufferLock, mScene.getMaterialManager(), mSceneMaterialBuffer, context); #if PX_SUPPORT_GPU_PHYSX updateLowLevelMaterials<NpFEMSoftBodyMaterial, PxsFEMMaterialManager, PxsFEMSoftBodyMaterialCore> (mPhysics, mSceneFEMSoftBodyMaterialBufferLock, mScene.getFEMMaterialManager(), mSceneFEMSoftBodyMaterialBuffer, context); updateLowLevelMaterials<NpPBDMaterial, PxsPBDMaterialManager, PxsPBDMaterialCore> (mPhysics, mScenePBDMaterialBufferLock, mScene.getPBDMaterialManager(), mScenePBDMaterialBuffer, context); #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION updateLowLevelMaterials<NpFEMClothMaterial, PxsFEMClothMaterialManager, PxsFEMClothMaterialCore> (mPhysics, mSceneFEMClothMaterialBufferLock, mScene.getFEMClothMaterialManager(), mSceneFEMClothMaterialBuffer, context); updateLowLevelMaterials<NpFLIPMaterial, PxsFLIPMaterialManager, PxsFLIPMaterialCore> (mPhysics, mSceneFLIPMaterialBufferLock, mScene.getFLIPMaterialManager(), mSceneFLIPMaterialBuffer, context); updateLowLevelMaterials<NpMPMMaterial, PxsMPMMaterialManager, PxsMPMMaterialCore> (mPhysics, mSceneMPMMaterialBufferLock, mScene.getMPMMaterialManager(), mSceneMPMMaterialBuffer, context); #endif #endif } /////////////////////////////////////////////////////////////////////////////// bool NpScene::simulateOrCollide(PxReal elapsedTime, PxBaseTask* completionTask, void* scratchBlock, PxU32 scratchBlockSize, bool controlSimulation, const char* invalidCallMsg, Sc::SimulationStage::Enum simStage) { PX_SIMD_GUARD; { // write guard must end before simulation kicks off worker threads // otherwise the simulation callbacks could overlap with this function // and perform API reads,triggering an error NP_WRITE_CHECK(this); PX_PROFILE_START_CROSSTHREAD("Basic.simulate", getContextId()); if(getSimulationStage() != Sc::SimulationStage::eCOMPLETE) { //fetchResult doesn't get called return outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, invalidCallMsg); } #if PX_SUPPORT_GPU_PHYSX if (mCudaContextManager) { if (mScene.isUsingGpuDynamicsOrBp()) { PxCUresult lastError = mCudaContextManager->getCudaContext()->getLastError(); if (lastError) { PxGetFoundation().error(PxErrorCode::eINTERNAL_ERROR, PX_FL, "PhysX Internal CUDA error. Simulation can not continue! Error code %i!\n", PxI32(lastError)); //return outputError<PxErrorCode::eINTERNAL_ERROR>(__LINE__, "PhysX Internal CUDA error. Simulation can not continue!"); } } } #endif PX_CHECK_AND_RETURN_VAL(elapsedTime > 0, "PxScene::collide/simulate: The elapsed time must be positive!", false); PX_CHECK_AND_RETURN_VAL((size_t(scratchBlock)&15) == 0, "PxScene::simulate: scratch block must be 16-byte aligned!", false); PX_CHECK_AND_RETURN_VAL((scratchBlockSize&16383) == 0, "PxScene::simulate: scratch block size must be a multiple of 16K", false); #if PX_SUPPORT_PVD //signal the frame is starting. mScenePvdClient.frameStart(elapsedTime); #endif #if PX_ENABLE_DEBUG_VISUALIZATION visualize(); #else PX_CATCH_UNDEFINED_ENABLE_DEBUG_VISUALIZATION #endif updateDirtyShaders(); #if PX_SUPPORT_PVD mScenePvdClient.updateJoints(); #endif mScene.setScratchBlock(scratchBlock, scratchBlockSize); mElapsedTime = elapsedTime; if (simStage == Sc::SimulationStage::eCOLLIDE) mScene.setElapsedTime(elapsedTime); mControllingSimulation = controlSimulation; syncMaterialEvents(); setSimulationStage(simStage); setAPIWriteToForbidden(); setAPIReadToForbidden(); mScene.setCollisionPhaseToActive(); } { PX_PROFILE_ZONE("Sim.taskFrameworkSetup", getContextId()); if (controlSimulation) { { PX_PROFILE_ZONE("Sim.resetDependencies", getContextId()); // Only reset dependencies, etc if we own the TaskManager. Will be false // when an NpScene is controlled by an APEX scene. mTaskManager->resetDependencies(); } mTaskManager->startSimulation(); } if (simStage == Sc::SimulationStage::eCOLLIDE) { mCollisionCompletion.setContinuation(*mTaskManager, completionTask); mSceneCollide.setContinuation(&mCollisionCompletion); //Initialize scene completion task mSceneCompletion.setContinuation(*mTaskManager, NULL); mCollisionCompletion.removeReference(); mSceneCollide.removeReference(); } else { mSceneCompletion.setContinuation(*mTaskManager, completionTask); mSceneExecution.setContinuation(*mTaskManager, &mSceneCompletion); mSceneCompletion.removeReference(); mSceneExecution.removeReference(); } } return true; } bool NpScene::simulate(PxReal elapsedTime, PxBaseTask* completionTask, void* scratchBlock, PxU32 scratchBlockSize, bool controlSimulation) { return simulateOrCollide( elapsedTime, completionTask, scratchBlock, scratchBlockSize, controlSimulation, "PxScene::simulate: Simulation is still processing last simulate call, you should call fetchResults()!", Sc::SimulationStage::eADVANCE); } bool NpScene::advance(PxBaseTask* completionTask) { NP_WRITE_CHECK(this); //issue error if advance() doesn't get called between fetchCollision() and fetchResult() if(getSimulationStage() != Sc::SimulationStage::eFETCHCOLLIDE) return outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::advance: advance() called illegally! advance() needed to be called after fetchCollision() and before fetchResult()!!"); //if mSimulateStage == eFETCHCOLLIDE, which means collide() has been kicked off and finished running, we can run advance() safely { //change the mSimulateStaget to eADVANCE to indicate the next stage to run is fetchResult() setSimulationStage(Sc::SimulationStage::eADVANCE); setAPIReadToForbidden(); { PX_PROFILE_ZONE("Sim.taskFrameworkSetup", getContextId()); mSceneCompletion.setDependent(completionTask); mSceneAdvance.setContinuation(*mTaskManager, &mSceneCompletion); mSceneCompletion.removeReference(); mSceneAdvance.removeReference(); } } return true; } bool NpScene::collide(PxReal elapsedTime, PxBaseTask* completionTask, void* scratchBlock, PxU32 scratchBlockSize, bool controlSimulation) { return simulateOrCollide( elapsedTime, completionTask, scratchBlock, scratchBlockSize, controlSimulation, "PxScene::collide: collide() called illegally! If it isn't the first frame, collide() needed to be called between fetchResults() and fetchCollision(). Otherwise, collide() needed to be called before fetchCollision()", Sc::SimulationStage::eCOLLIDE); } bool NpScene::checkCollisionInternal(bool block) { PX_PROFILE_ZONE("Basic.checkCollision", getContextId()); return mCollisionDone.wait(block ? PxSync::waitForever : 0); } bool NpScene::checkCollision(bool block) { return checkCollisionInternal(block); } bool NpScene::fetchCollision(bool block) { if(getSimulationStage() != Sc::SimulationStage::eCOLLIDE) { return outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::fetchCollision: fetchCollision() should be called after collide() and before advance()!"); } //if collision isn't finish running (and block is false), then return false if(!checkCollisionInternal(block)) return false; // take write check *after* collision() finished, otherwise // we will block fetchCollision() from using the API NP_WRITE_CHECK_NOREENTRY(this); setSimulationStage(Sc::SimulationStage::eFETCHCOLLIDE); setAPIReadToAllowed(); return true; } void NpScene::flushSimulation(bool sendPendingReports) { PX_PROFILE_ZONE("API.flushSimulation", getContextId()); NP_WRITE_CHECK_NOREENTRY(this); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(this, "PxScene::flushSimulation(): This call is not allowed while the simulation is running. Call will be ignored") PX_SIMD_GUARD; mScene.flush(sendPendingReports); getSQAPI().flushMemory(); //!!! TODO: Shrink all NpObject lists? } /* Replaces finishRun() with the addition of appropriate thread sync(pulled out of PhysicsThread()) Note: this function can be called from the application thread or the physics thread, depending on the scene flags. */ void NpScene::executeScene(PxBaseTask* continuation) { mScene.simulate(mElapsedTime, continuation); } void NpScene::executeCollide(PxBaseTask* continuation) { mScene.collide(mElapsedTime, continuation); } void NpScene::executeAdvance(PxBaseTask* continuation) { mScene.advance(mElapsedTime, continuation); } /////////////////////////////////////////////////////////////////////////////// #define IMPLEMENT_MATERIAL(MaterialType, CoreType, LockName, BufferName) \ void NpScene::addMaterial(const MaterialType& mat) \ { \ const CoreType& material = mat.mMaterial; \ PxMutex::ScopedLock lock(LockName); \ BufferName.pushBack(MaterialEvent(material.mMaterialIndex, MATERIAL_ADD)); \ CREATE_PVD_INSTANCE(&material) \ } \ \ void NpScene::updateMaterial(const MaterialType& mat) \ { \ const CoreType& material = mat.mMaterial; \ PxMutex::ScopedLock lock(LockName); \ BufferName.pushBack(MaterialEvent(material.mMaterialIndex, MATERIAL_UPDATE)); \ UPDATE_PVD_PROPERTIES(&material) \ } \ \ void NpScene::removeMaterial(const MaterialType& mat) \ { \ const CoreType& material = mat.mMaterial; \ if(material.mMaterialIndex == MATERIAL_INVALID_HANDLE) \ return; \ PxMutex::ScopedLock lock(LockName); \ BufferName.pushBack(MaterialEvent(material.mMaterialIndex, MATERIAL_REMOVE)); \ RELEASE_PVD_INSTANCE(&material); \ } IMPLEMENT_MATERIAL(NpMaterial, PxsMaterialCore, mSceneMaterialBufferLock, mSceneMaterialBuffer) #if PX_SUPPORT_GPU_PHYSX IMPLEMENT_MATERIAL(NpFEMSoftBodyMaterial, PxsFEMSoftBodyMaterialCore, mSceneFEMSoftBodyMaterialBufferLock, mSceneFEMSoftBodyMaterialBuffer) #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION IMPLEMENT_MATERIAL(NpFEMClothMaterial, PxsFEMClothMaterialCore, mSceneFEMClothMaterialBufferLock, mSceneFEMClothMaterialBuffer) #endif IMPLEMENT_MATERIAL(NpPBDMaterial, PxsPBDMaterialCore, mScenePBDMaterialBufferLock, mScenePBDMaterialBuffer) #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION IMPLEMENT_MATERIAL(NpFLIPMaterial, PxsFLIPMaterialCore, mSceneFLIPMaterialBufferLock, mSceneFLIPMaterialBuffer) IMPLEMENT_MATERIAL(NpMPMMaterial, PxsMPMMaterialCore, mSceneMPMMaterialBufferLock, mSceneMPMMaterialBuffer) #endif #endif /////////////////////////////////////////////////////////////////////////////// void NpScene::setDominanceGroupPair(PxDominanceGroup group1, PxDominanceGroup group2, const PxDominanceGroupPair& dominance) { NP_WRITE_CHECK(this); PX_CHECK_AND_RETURN((group1 < PX_MAX_DOMINANCE_GROUP && group2 < PX_MAX_DOMINANCE_GROUP), "PxScene::setDominanceGroupPair: invalid params! Groups must be <= 31!"); //can't change matrix diagonal PX_CHECK_AND_RETURN(group1 != group2, "PxScene::setDominanceGroupPair: invalid params! Groups must be unequal! Can't change matrix diagonal!"); PX_CHECK_AND_RETURN( ((dominance.dominance0) == 1.0f && (dominance.dominance1 == 1.0f)) || ((dominance.dominance0) == 1.0f && (dominance.dominance1 == 0.0f)) || ((dominance.dominance0) == 0.0f && (dominance.dominance1 == 1.0f)) , "PxScene::setDominanceGroupPair: invalid params! dominance must be one of (1,1), (1,0), or (0,1)!"); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(this, "PxScene::setDominanceGroupPair() not allowed while simulation is running. Call will be ignored.") mScene.setDominanceGroupPair(group1, group2, dominance); updatePvdProperties(); } PxDominanceGroupPair NpScene::getDominanceGroupPair(PxDominanceGroup group1, PxDominanceGroup group2) const { NP_READ_CHECK(this); PX_CHECK_AND_RETURN_VAL((group1 < PX_MAX_DOMINANCE_GROUP && group2 < PX_MAX_DOMINANCE_GROUP), "PxScene::getDominanceGroupPair: invalid params! Groups must be <= 31!", PxDominanceGroupPair(PxU8(1u), PxU8(1u))); return mScene.getDominanceGroupPair(group1, group2); } /////////////////////////////////////////////////////////////////////////////// #if PX_SUPPORT_GPU_PHYSX void NpScene::updatePhysXIndicator() { PxIntBool isGpu = mScene.isUsingGpuDynamicsOrBp(); mPhysXIndicator.setIsGpu(isGpu != 0); } #endif //PX_SUPPORT_GPU_PHYSX /////////////////////////////////////////////////////////////////////////////// void NpScene::setSolverBatchSize(PxU32 solverBatchSize) { NP_WRITE_CHECK(this); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(this, "PxScene::setSolverBatchSize() not allowed while simulation is running. Call will be ignored.") mScene.setSolverBatchSize(solverBatchSize); updatePvdProperties(); OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxScene, solverBatchSize, static_cast<PxScene&>(*this), solverBatchSize) } PxU32 NpScene::getSolverBatchSize(void) const { NP_READ_CHECK(this); // get from our local copy return mScene.getSolverBatchSize(); } void NpScene::setSolverArticulationBatchSize(PxU32 solverBatchSize) { NP_WRITE_CHECK(this); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(this, "PxScene::setSolverArticulationBatchSize() not allowed while simulation is running. Call will be ignored.") mScene.setSolverArticBatchSize(solverBatchSize); updatePvdProperties(); OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxScene, solverArticulationBatchSize, static_cast<PxScene&>(*this), solverBatchSize) } PxU32 NpScene::getSolverArticulationBatchSize(void) const { NP_READ_CHECK(this); // get from our local copy return mScene.getSolverArticBatchSize(); } /////////////////////////////////////////////////////////////////////////////// bool NpScene::setVisualizationParameter(PxVisualizationParameter::Enum param, PxReal value) { NP_WRITE_CHECK(this); PX_CHECK_AND_RETURN_VAL(PxIsFinite(value), "PxScene::setVisualizationParameter: value is not valid.", false); PX_CHECK_SCENE_API_WRITE_FORBIDDEN_AND_RETURN_VAL(this, "PxScene::setVisualizationParameter() not allowed while simulation is running. Call will be ignored.", false) if (param >= PxVisualizationParameter::eNUM_VALUES) return outputError<PxErrorCode::eINVALID_PARAMETER>(__LINE__, "setVisualizationParameter: parameter out of range."); else if (value < 0.0f) return outputError<PxErrorCode::eINVALID_PARAMETER>(__LINE__, "setVisualizationParameter: value must be larger or equal to 0."); else { mScene.setVisualizationParameter(param, value); return true; } } PxReal NpScene::getVisualizationParameter(PxVisualizationParameter::Enum param) const { if (param < PxVisualizationParameter::eNUM_VALUES) return mScene.getVisualizationParameter(param); else outputError<PxErrorCode::eINVALID_PARAMETER>(__LINE__, "getVisualizationParameter: param is not an enum."); return 0.0f; } void NpScene::setVisualizationCullingBox(const PxBounds3& box) { NP_WRITE_CHECK(this); PX_CHECK_MSG(box.isValid(), "PxScene::setVisualizationCullingBox(): invalid bounds provided!"); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(this, "PxScene::setVisualizationCullingBox() not allowed while simulation is running. Call will be ignored.") mScene.setVisualizationCullingBox(box); } PxBounds3 NpScene::getVisualizationCullingBox() const { NP_READ_CHECK(this); const PxBounds3& bounds = mScene.getVisualizationCullingBox(); PX_ASSERT(bounds.isValid()); return bounds; } void NpScene::setNbContactDataBlocks(PxU32 numBlocks) { PX_CHECK_AND_RETURN((getSimulationStage() == Sc::SimulationStage::eCOMPLETE), "PxScene::setNbContactDataBlock: This call is not allowed while the simulation is running. Call will be ignored!"); mScene.setNbContactDataBlocks(numBlocks); OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxScene, nbContactDataBlocks, static_cast<PxScene&>(*this), numBlocks) } PxU32 NpScene::getNbContactDataBlocksUsed() const { PX_CHECK_AND_RETURN_VAL((getSimulationStage() == Sc::SimulationStage::eCOMPLETE), "PxScene::getNbContactDataBlocksUsed: This call is not allowed while the simulation is running. Returning 0.", 0); return mScene.getNbContactDataBlocksUsed(); } PxU32 NpScene::getMaxNbContactDataBlocksUsed() const { PX_CHECK_AND_RETURN_VAL((getSimulationStage() == Sc::SimulationStage::eCOMPLETE), "PxScene::getMaxNbContactDataBlocksUsed: This call is not allowed while the simulation is running. Returning 0.", 0); return mScene.getMaxNbContactDataBlocksUsed(); } PxU32 NpScene::getTimestamp() const { return mScene.getTimeStamp(); } PxCpuDispatcher* NpScene::getCpuDispatcher() const { return mTaskManager->getCpuDispatcher(); } PxCudaContextManager* NpScene::getCudaContextManager() const { return mCudaContextManager; } void NpScene::setMaxBiasCoefficient(const PxReal coeff) { NP_WRITE_CHECK(this); PX_CHECK_AND_RETURN((coeff>=0.0f), "PxScene::setMaxBiasCoefficient(): coefficient has to be in [0, PX_MAX_F32]!"); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(this, "PxScene::setMaxBiasCoefficient() not allowed while simulation is running. Call will be ignored.") mScene.setMaxBiasCoefficient(coeff); updatePvdProperties(); OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxScene, maxBiasCoefficient, static_cast<PxScene&>(*this), coeff) } PxReal NpScene::getMaxBiasCoefficient() const { NP_READ_CHECK(this); return mScene.getMaxBiasCoefficient(); } void NpScene::setFrictionOffsetThreshold(const PxReal t) { NP_WRITE_CHECK(this); PX_CHECK_AND_RETURN((t>=0.0f), "PxScene::setFrictionOffsetThreshold(): threshold value has to be in [0, PX_MAX_F32)!"); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(this, "PxScene::setFrictionOffsetThreshold() not allowed while simulation is running. Call will be ignored.") mScene.setFrictionOffsetThreshold(t); updatePvdProperties(); OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxScene, frictionOffsetThreshold, static_cast<PxScene&>(*this), t) } PxReal NpScene::getFrictionOffsetThreshold() const { NP_READ_CHECK(this); return mScene.getFrictionOffsetThreshold(); } void NpScene::setFrictionCorrelationDistance(const PxReal t) { NP_WRITE_CHECK(this); PX_CHECK_AND_RETURN((t >= 0.0f), "PxScene::setFrictionCorrelationDistance(): threshold value has to be in [0, PX_MAX_F32)!"); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(this, "PxScene::setFrictionCorrelationDistance() not allowed while simulation is running. Call will be ignored.") mScene.setFrictionCorrelationDistance(t); updatePvdProperties(); OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxScene, frictionCorrelationDistance, static_cast<PxScene&>(*this), t) } PxReal NpScene::getFrictionCorrelationDistance() const { NP_READ_CHECK(this); return mScene.getFrictionCorrelationDistance(); } PxU32 NpScene::getContactReportStreamBufferSize() const { NP_READ_CHECK(this); return mScene.getDefaultContactReportStreamBufferSize(); } #if PX_CHECKED void NpScene::checkPositionSanity(const PxRigidActor& a, const PxTransform& pose, const char* fnName) const { if(!mSanityBounds.contains(pose.p)) PxGetFoundation().error(PxErrorCode::eDEBUG_WARNING, PX_FL, "%s: actor pose for %lp is outside sanity bounds\n", fnName, &a); } #endif namespace { struct ThreadReadWriteCount { ThreadReadWriteCount(const size_t data) : readDepth(data & 0xFF), writeDepth((data >> 8) & 0xFF), readLockDepth((data >> 16) & 0xFF), writeLockDepth((data >> 24) & 0xFF) { } size_t getData() const { return size_t(writeLockDepth) << 24 | size_t(readLockDepth) << 16 | size_t(writeDepth) << 8 | size_t(readDepth); } PxU8 readDepth; // depth of re-entrant reads PxU8 writeDepth; // depth of re-entrant writes PxU8 readLockDepth; // depth of read-locks PxU8 writeLockDepth; // depth of write-locks }; } #if NP_ENABLE_THREAD_CHECKS NpScene::StartWriteResult::Enum NpScene::startWrite(bool allowReentry) { PX_COMPILE_TIME_ASSERT(sizeof(ThreadReadWriteCount) == 4); if (mScene.getFlags() & PxSceneFlag::eREQUIRE_RW_LOCK) { ThreadReadWriteCount localCounts(PxTlsGetValue(mThreadReadWriteDepth)); if (mBetweenFetchResults) return StartWriteResult::eIN_FETCHRESULTS; // ensure we already have the write lock return localCounts.writeLockDepth > 0 ? StartWriteResult::eOK : StartWriteResult::eNO_LOCK; } { ThreadReadWriteCount localCounts(PxTlsGetValue(mThreadReadWriteDepth)); StartWriteResult::Enum result; if (mBetweenFetchResults) result = StartWriteResult::eIN_FETCHRESULTS; // check we are the only thread reading (allows read->write order on a single thread) and no other threads are writing else if (mConcurrentReadCount != localCounts.readDepth || mConcurrentWriteCount != localCounts.writeDepth) result = StartWriteResult::eRACE_DETECTED; else result = StartWriteResult::eOK; // increment shared write counter PxAtomicIncrement(&mConcurrentWriteCount); // in the normal case (re-entry is allowed) then we simply increment // the writeDepth by 1, otherwise (re-entry is not allowed) increment // by 2 to force subsequent writes to fail by creating a mismatch between // the concurrent write counter and the local counter, any value > 1 will do localCounts.writeDepth += allowReentry ? 1 : 2; PxTlsSetValue(mThreadReadWriteDepth, localCounts.getData()); if (result != StartWriteResult::eOK) PxAtomicIncrement(&mConcurrentErrorCount); return result; } } void NpScene::stopWrite(bool allowReentry) { if (!(mScene.getFlags() & PxSceneFlag::eREQUIRE_RW_LOCK)) { PxAtomicDecrement(&mConcurrentWriteCount); // decrement depth of writes for this thread ThreadReadWriteCount localCounts (PxTlsGetValue(mThreadReadWriteDepth)); // see comment in startWrite() if (allowReentry) localCounts.writeDepth--; else localCounts.writeDepth-=2; PxTlsSetValue(mThreadReadWriteDepth, localCounts.getData()); } } bool NpScene::startRead() const { if (mScene.getFlags() & PxSceneFlag::eREQUIRE_RW_LOCK) { ThreadReadWriteCount localCounts (PxTlsGetValue(mThreadReadWriteDepth)); // ensure we already have the write or read lock return localCounts.writeLockDepth > 0 || localCounts.readLockDepth > 0; } else { PxAtomicIncrement(&mConcurrentReadCount); // update current threads read depth ThreadReadWriteCount localCounts (PxTlsGetValue(mThreadReadWriteDepth)); localCounts.readDepth++; PxTlsSetValue(mThreadReadWriteDepth, localCounts.getData()); // success if the current thread is already performing a write (API re-entry) or no writes are in progress const bool success = (localCounts.writeDepth > 0 || mConcurrentWriteCount == 0); if (!success) PxAtomicIncrement(&mConcurrentErrorCount); return success; } } void NpScene::stopRead() const { if (!(mScene.getFlags() & PxSceneFlag::eREQUIRE_RW_LOCK)) { PxAtomicDecrement(&mConcurrentReadCount); // update local threads read depth ThreadReadWriteCount localCounts (PxTlsGetValue(mThreadReadWriteDepth)); localCounts.readDepth--; PxTlsSetValue(mThreadReadWriteDepth, localCounts.getData()); } } #else NpScene::StartWriteResult::Enum NpScene::startWrite(bool) { PX_ASSERT(0); return NpScene::StartWriteResult::eOK; } void NpScene::stopWrite(bool) {} bool NpScene::startRead() const { PX_ASSERT(0); return false; } void NpScene::stopRead() const {} #endif // NP_ENABLE_THREAD_CHECKS void NpScene::lockRead(const char* /*file*/, PxU32 /*line*/) { // increment this threads read depth ThreadReadWriteCount localCounts (PxTlsGetValue(mThreadReadWriteDepth)); localCounts.readLockDepth++; PxTlsSetValue(mThreadReadWriteDepth, localCounts.getData()); // if we are the current writer then increment the reader count but don't actually lock (allow reading from threads with write ownership) if(localCounts.readLockDepth == 1) mRWLock.lockReader(mCurrentWriter != PxThread::getId()); } void NpScene::unlockRead() { // increment this threads read depth ThreadReadWriteCount localCounts (PxTlsGetValue(mThreadReadWriteDepth)); if(localCounts.readLockDepth < 1) { outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::unlockRead() called without matching call to PxScene::lockRead(), behaviour will be undefined."); return; } localCounts.readLockDepth--; PxTlsSetValue(mThreadReadWriteDepth, localCounts.getData()); // only unlock on last read if(localCounts.readLockDepth == 0) mRWLock.unlockReader(); } void NpScene::lockWrite(const char* file, PxU32 line) { // increment this threads write depth ThreadReadWriteCount localCounts (PxTlsGetValue(mThreadReadWriteDepth)); if (localCounts.writeLockDepth == 0 && localCounts.readLockDepth > 0) { PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, file?file:__FILE__, file?int(line):__LINE__, "PxScene::lockWrite() detected after a PxScene::lockRead(), lock upgrading is not supported, behaviour will be undefined."); return; } localCounts.writeLockDepth++; PxTlsSetValue(mThreadReadWriteDepth, localCounts.getData()); // only lock on first call if (localCounts.writeLockDepth == 1) mRWLock.lockWriter(); PX_ASSERT(mCurrentWriter == 0 || mCurrentWriter == PxThread::getId()); // set ourselves as the current writer mCurrentWriter = PxThread::getId(); } void NpScene::unlockWrite() { // increment this thread's write depth ThreadReadWriteCount localCounts (PxTlsGetValue(mThreadReadWriteDepth)); if (localCounts.writeLockDepth < 1) { outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::unlockWrite() called without matching call to PxScene::lockWrite(), behaviour will be undefined."); return; } localCounts.writeLockDepth--; PxTlsSetValue(mThreadReadWriteDepth, localCounts.getData()); PX_ASSERT(mCurrentWriter == PxThread::getId()); if (localCounts.writeLockDepth == 0) { mCurrentWriter = 0; mRWLock.unlockWriter(); } } PxReal NpScene::getWakeCounterResetValue() const { NP_READ_CHECK(this); return getWakeCounterResetValueInternal(); } static PX_FORCE_INLINE void shiftRigidActor(PxRigidActor* a, const PxVec3& shift) { PxActorType::Enum t = a->getType(); if (t == PxActorType::eRIGID_DYNAMIC) { NpRigidDynamic* rd = static_cast<NpRigidDynamic*>(a); rd->getCore().onOriginShift(shift); } else if (t == PxActorType::eRIGID_STATIC) { NpRigidStatic* rs = static_cast<NpRigidStatic*>(a); rs->getCore().onOriginShift(shift); } else { PX_ASSERT(t == PxActorType::eARTICULATION_LINK); NpArticulationLink* al = static_cast<NpArticulationLink*>(a); al->getCore().onOriginShift(shift); } } template<typename T> static void shiftRigidActors(PxArray<T*>& rigidActorList, const PxVec3& shift) { const PxU32 prefetchLookAhead = 4; PxU32 rigidCount = rigidActorList.size(); T*const* rigidActors = rigidActorList.begin(); PxU32 batchIterCount = rigidCount / prefetchLookAhead; PxU32 idx = 0; for(PxU32 i=0; i < batchIterCount; i++) { // prefetch elements for next batch if (i < (batchIterCount-1)) { PxPrefetchLine(rigidActors[idx + prefetchLookAhead]); PxPrefetchLine(reinterpret_cast<PxU8*>(rigidActors[idx + prefetchLookAhead]) + 128); PxPrefetchLine(rigidActors[idx + prefetchLookAhead + 1]); PxPrefetchLine(reinterpret_cast<PxU8*>(rigidActors[idx + prefetchLookAhead + 1]) + 128); PxPrefetchLine(rigidActors[idx + prefetchLookAhead + 2]); PxPrefetchLine(reinterpret_cast<PxU8*>(rigidActors[idx + prefetchLookAhead + 2]) + 128); PxPrefetchLine(rigidActors[idx + prefetchLookAhead + 3]); PxPrefetchLine(reinterpret_cast<PxU8*>(rigidActors[idx + prefetchLookAhead + 3]) + 128); } else { for(PxU32 k=(idx + prefetchLookAhead); k < rigidCount; k++) { PxPrefetchLine(rigidActors[k]); PxPrefetchLine(reinterpret_cast<PxU8*>(rigidActors[k]) + 128); } } for(PxU32 j=idx; j < (idx + prefetchLookAhead); j++) { shiftRigidActor(rigidActors[j], shift); } idx += prefetchLookAhead; } // process remaining objects for(PxU32 i=idx; i < rigidCount; i++) { shiftRigidActor(rigidActors[i], shift); } } void NpScene::shiftOrigin(const PxVec3& shift) { PX_PROFILE_ZONE("API.shiftOrigin", getContextId()); NP_WRITE_CHECK(this); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(this, "PxScene::shiftOrigin() not allowed while simulation is running. Call will be ignored.") PX_SIMD_GUARD; shiftRigidActors(mRigidDynamics, shift); shiftRigidActors(mRigidStatics, shift); PxArticulationReducedCoordinate*const* articulations = mArticulations.getEntries(); for(PxU32 i=0; i < mArticulations.size(); i++) { PxArticulationReducedCoordinate* np = (articulations[i]); NpArticulationLink*const* links = static_cast<NpArticulationReducedCoordinate*>(np)->getLinks(); for(PxU32 j=0; j < np->getNbLinks(); j++) { shiftRigidActor(links[j], shift); } } mScene.shiftOrigin(shift); PVD_ORIGIN_SHIFT(shift); // shift scene query related data structures getSQAPI().shiftOrigin(shift); #if PX_ENABLE_DEBUG_VISUALIZATION // debug visualization mRenderBuffer.shift(-shift); #else PX_CATCH_UNDEFINED_ENABLE_DEBUG_VISUALIZATION #endif } PxPvdSceneClient* NpScene::getScenePvdClient() { #if PX_SUPPORT_PVD return &mScenePvdClient; #else return NULL; #endif } void NpScene::copyArticulationData(void* jointData, void* index, PxArticulationGpuDataType::Enum dataType, const PxU32 nbCopyArticulations, CUevent copyEvent) { PX_CHECK_SCENE_API_READ_FORBIDDEN(this, "PxScene::copyArticulationData() not allowed while simulation is running. Call will be ignored."); if (!isDirectGPUAPIInitialized()) { outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::copyArticulationData(): it is illegal to call this function if the scene is not configured for direct-GPU access or the direct-GPU API has not been initialized yet."); return; } if (dataType == PxArticulationGpuDataType::eLINK_FORCE || dataType == PxArticulationGpuDataType::eLINK_TORQUE || dataType == PxArticulationGpuDataType::eFIXED_TENDON || dataType == PxArticulationGpuDataType::eFIXED_TENDON_JOINT || dataType == PxArticulationGpuDataType::eSPATIAL_TENDON || dataType == PxArticulationGpuDataType::eSPATIAL_TENDON_ATTACHMENT) { outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::copyArticulationData, specified data is write only."); return; } mScene.getSimulationController()->copyArticulationData(jointData, index, dataType, nbCopyArticulations, copyEvent); } void NpScene::applyArticulationData(void* data, void* index, PxArticulationGpuDataType::Enum dataType, const PxU32 nbUpdatedArticulations, CUevent waitEvent, CUevent signalEvent) { PX_CHECK_SCENE_API_WRITE_FORBIDDEN(this, "PxScene::applyArticulationData() not allowed while simulation is running. Call will be ignored."); if (!data || !index) { outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::applyArticulationData, data and/or index has to be valid pointer."); return; } if (!isDirectGPUAPIInitialized()) { outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::applyArticulationData(): it is illegal to call this function if the scene is not configured for direct-GPU access or the direct-GPU API has not been initialized yet."); return; } if (dataType == PxArticulationGpuDataType::eJOINT_ACCELERATION || dataType == PxArticulationGpuDataType::eJOINT_SOLVER_FORCE || dataType == PxArticulationGpuDataType::eSENSOR_FORCE || dataType == PxArticulationGpuDataType::eLINK_TRANSFORM || dataType == PxArticulationGpuDataType::eLINK_VELOCITY || dataType == PxArticulationGpuDataType::eLINK_ACCELERATION || dataType == PxArticulationGpuDataType::eLINK_INCOMING_JOINT_FORCE ) { outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::applyArticulationData, specified data is read only."); return; } mScene.getSimulationController()->applyArticulationData(data,index, dataType, nbUpdatedArticulations, waitEvent, signalEvent); } void NpScene::updateArticulationsKinematic(CUevent signalEvent) { PX_CHECK_SCENE_API_WRITE_FORBIDDEN(this, "PxScene::updateArticulationsKinematic() not allowed while simulation is running. Call will be ignored."); if (!isDirectGPUAPIInitialized()) { outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::updateArticulationsKinematic(): it is illegal to call this function if the scene is not configured for direct-GPU access or the direct-GPU API has not been initialized yet."); return; } mScene.getSimulationController()->updateArticulationsKinematic(signalEvent); } void NpScene::copySoftBodyData(void** data, void* dataSizes, void* softBodyIndices, PxSoftBodyGpuDataFlag::Enum flag, const PxU32 nbCopySoftBodies, const PxU32 maxSize, CUevent copyEvent) { PX_CHECK_SCENE_API_READ_FORBIDDEN(this, "PxScene::copySoftBodyData() not allowed while simulation is running. Call will be ignored."); //if ((mScene.getFlags() & PxSceneFlag::eENABLE_DIRECT_GPU_API) && mScene.isUsingGpuRigidBodies()) mScene.getSimulationController()->copySoftBodyData(data, dataSizes, softBodyIndices, flag, nbCopySoftBodies, maxSize, copyEvent); } void NpScene::applySoftBodyData(void** data, void* dataSizes, void* softBodyIndices, PxSoftBodyGpuDataFlag::Enum flag, const PxU32 nbUpdatedSoftBodies, const PxU32 maxSize, CUevent applyEvent, CUevent signalEvent) { PX_CHECK_SCENE_API_WRITE_FORBIDDEN(this, "PxScene::applySoftBodyData() not allowed while simulation is running. Call will be ignored."); //if ((mScene.getFlags() & PxSceneFlag::eENABLE_DIRECT_GPU_API) && mScene.isUsingGpuRigidBodies()) mScene.getSimulationController()->applySoftBodyData(data, dataSizes, softBodyIndices, flag, nbUpdatedSoftBodies, maxSize, applyEvent, signalEvent); } void NpScene::copyContactData(void* data, const PxU32 maxContactPairs, void* numContactPairs, CUevent copyEvent) { PX_CHECK_SCENE_API_READ_FORBIDDEN(this, "PxScene::copyContactData() not allowed while simulation is running. Call will be ignored."); if (!data || !numContactPairs) { outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::copyContactData, data and/or count has to be valid pointer."); return; } if (!isDirectGPUAPIInitialized()) { outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::copyContactData(): it is illegal to call this function if the scene is not configured for direct-GPU access or the direct-GPU API has not been initialized yet."); return; } mScene.getSimulationController()->copyContactData(mScene.getDynamicsContext(), data, maxContactPairs, numContactPairs, copyEvent); } void NpScene::copyBodyData(PxGpuBodyData* data, PxGpuActorPair* index, const PxU32 nbCopyActors, CUevent copyEvent) { PX_CHECK_SCENE_API_READ_FORBIDDEN(this, "PxScene::copyBodyData() not allowed while simulation is running. Call will be ignored."); if (!data) { outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::copyBodyData, data has to be valid pointer."); return; } if (!isDirectGPUAPIInitialized()) { outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::copyBodyData(): it is illegal to call this function if the scene is not configured for direct-GPU access or the direct-GPU API has not been initialized yet."); return; } mScene.getSimulationController()->copyBodyData(data, index, nbCopyActors, copyEvent); } void NpScene::applyActorData(void* data, PxGpuActorPair* index, PxActorCacheFlag::Enum flag, const PxU32 nbUpdatedActors, CUevent waitEvent, CUevent signalEvent) { PX_CHECK_SCENE_API_WRITE_FORBIDDEN(this, "PxScene::applyActorData() not allowed while simulation is running. Call will be ignored."); if (!data || !index) { outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::applyActorData, data and/or index has to be valid pointer."); return; } if (!isDirectGPUAPIInitialized()) { outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::applyActorData(): it is illegal to call this function if the scene is not configured for direct-GPU access or the direct-GPU API has not been initialized yet."); return; } mScene.getSimulationController()->applyActorData(data, index, flag, nbUpdatedActors, waitEvent, signalEvent); } void NpScene::evaluateSDFDistances(const PxU32* sdfShapeIds, const PxU32 nbShapes, const PxVec4* samplePointsConcatenated, const PxU32* samplePointCountPerShape, const PxU32 maxPointCount, PxVec4* localGradientAndSDFConcatenated, CUevent event) { PX_CHECK_SCENE_API_WRITE_FORBIDDEN(this, "PxScene::evaluateSDFDistances() not allowed while simulation is running. Call will be ignored."); if (!isDirectGPUAPIInitialized()) { outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::evaluateSDFDistances(): it is illegal to call this function if the scene is not configured for direct-GPU access or the direct-GPU API has not been initialized yet."); return; } mScene.getSimulationController()->evaluateSDFDistances(sdfShapeIds, nbShapes, samplePointsConcatenated, samplePointCountPerShape, maxPointCount, localGradientAndSDFConcatenated, event); } void NpScene::computeDenseJacobians(const PxIndexDataPair* indices, PxU32 nbIndices, CUevent computeEvent) { PX_CHECK_SCENE_API_READ_FORBIDDEN(this, "PxScene::computeDenseJacobians() not allowed while simulation is running. Call will be ignored."); if (!indices) { outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::computeDenseJacobians, indices have to be a valid pointer."); return; } if (!isDirectGPUAPIInitialized()) { outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::computeDenseJacobians(): it is illegal to call this function if the scene is not configured for direct-GPU access or the direct-GPU API has not been initialized yet."); return; } mScene.getSimulationController()->computeDenseJacobians(indices, nbIndices, computeEvent); } void NpScene::computeGeneralizedMassMatrices(const PxIndexDataPair* indices, PxU32 nbIndices, CUevent computeEvent) { PX_CHECK_SCENE_API_READ_FORBIDDEN(this, "PxScene::computeGeneralizedMassMatrices() not allowed while simulation is running. Call will be ignored."); if (!indices) { outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::computeGeneralizedMassMatrices, indices have to be a valid pointer."); return; } if (!isDirectGPUAPIInitialized()) { outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::computeGeneralizedMassMatrices(): it is illegal to call this function if the scene is not configured for direct-GPU access or the direct-GPU API has not been initialized yet."); return; } mScene.getSimulationController()->computeGeneralizedMassMatrices(indices, nbIndices, computeEvent); } void NpScene::computeGeneralizedGravityForces(const PxIndexDataPair* indices, PxU32 nbIndices, CUevent computeEvent) { PX_CHECK_SCENE_API_READ_FORBIDDEN(this, "PxScene::computeGeneralizedGravityForces() not allowed while simulation is running. Call will be ignored."); if (!indices) { outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::computeGeneralizedGravityForces, indices have to be a valid pointer."); return; } if (!isDirectGPUAPIInitialized()) { outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::computeGeneralizedGravityForces(): it is illegal to call this function if the scene is not configured for direct-GPU access or the direct-GPU API has not been initialized yet."); return; } mScene.getSimulationController()->computeGeneralizedGravityForces(indices, nbIndices, getGravity(), computeEvent); } void NpScene::computeCoriolisAndCentrifugalForces(const PxIndexDataPair* indices, PxU32 nbIndices, CUevent computeEvent) { PX_CHECK_SCENE_API_READ_FORBIDDEN(this, "PxScene::computeCoriolisAndCentrifugalForces() not allowed while simulation is running. Call will be ignored."); if (!indices) { outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::computeCoriolisAndCentrifugalForces, indices have to be a valid pointer."); return; } if (!isDirectGPUAPIInitialized()) { outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::computeCoriolisAndCentrifugalForces(): it is illegal to call this function if the scene is not configured for direct-GPU access or the direct-GPU API has not been initialized yet."); return; } mScene.getSimulationController()->computeCoriolisAndCentrifugalForces(indices, nbIndices, computeEvent); } void NpScene::applyParticleBufferData(const PxU32* indices, const PxGpuParticleBufferIndexPair* indexPairs, const PxParticleBufferFlags* flags, PxU32 nbUpdatedBuffers, CUevent waitEvent, CUevent signalEvent) { PX_CHECK_SCENE_API_WRITE_FORBIDDEN(this, "PxScene::applyParticleBufferData() not allowed while simulation is running. Call will be ignored."); if (!indices || !flags) { outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::applyParticleBufferData, indices and/or flags has to be valid pointer."); return; } if (!isDirectGPUAPIInitialized()) { outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::applyParticleBufferData(): it is illegal to call this function if the scene is not configured for direct-GPU access or the direct-GPU API has not been initialized yet."); return; } mScene.getSimulationController()->applyParticleBufferData(indices, indexPairs, flags, nbUpdatedBuffers, waitEvent, signalEvent); } PxsSimulationController* NpScene::getSimulationController() { return mScene.getSimulationController(); } void NpScene::setActiveActors(PxActor** actors, PxU32 nbActors) { NP_WRITE_CHECK(this); mScene.setActiveActors(actors, nbActors); } void NpScene::frameEnd() { #if PX_SUPPORT_PVD mScenePvdClient.frameEnd(); #endif } /////////////////////////////////////////////////////////////////////////////// PX_FORCE_INLINE PxU32 getShapes(NpRigidStatic& rigid, NpShape* const *& shapes) { return NpRigidStaticGetShapes(rigid, shapes); } PX_FORCE_INLINE PxU32 getShapes(NpRigidDynamic& rigid, NpShape* const *& shapes) { return NpRigidDynamicGetShapes(rigid, shapes); } PX_FORCE_INLINE PxU32 getShapes(NpArticulationLink& rigid, NpShape* const *& shapes) { return NpArticulationGetShapes(rigid, shapes); } PX_FORCE_INLINE NpShape* getShape(NpShape* const* shapeArray, const PxU32 i) { return shapeArray[i]; } PX_FORCE_INLINE NpShape* getShape(Sc::ShapeCore* const* shapeArray, const PxU32 i) { return static_cast<NpShape*>(shapeArray[i]->getPxShape()); } template<class T> PX_FORCE_INLINE static void addActorShapes(T* const* shapeArray, const PxU32 nbShapes, PxActor* pxActor, NpScene* scScene) { PX_ASSERT(pxActor); PX_ASSERT(scScene); PX_ASSERT((0==nbShapes) || shapeArray); for (PxU32 i = 0; i < nbShapes; i++) { NpShape* npShape = getShape(shapeArray, i); PX_ASSERT(npShape); npShape->setSceneIfExclusive(scScene); #if PX_SUPPORT_PVD scScene->getScenePvdClientInternal().createPvdInstance(npShape, *pxActor); #else PX_UNUSED(pxActor); #endif } } template<class T> PX_FORCE_INLINE static void removeActorShapes(T* const* shapeArray, const PxU32 nbShapes, PxActor* pxActor, NpScene* scScene) { PX_ASSERT(pxActor); PX_ASSERT(scScene); PX_ASSERT((0 == nbShapes) || shapeArray); for (PxU32 i = 0; i < nbShapes; i++) { NpShape* npShape = getShape(shapeArray, i); PX_ASSERT(npShape); #if PX_SUPPORT_PVD scScene->getScenePvdClientInternal().releasePvdInstance(npShape, *pxActor); #else PX_UNUSED(pxActor); PX_UNUSED(scScene); #endif npShape->setSceneIfExclusive(NULL); } } void addSimActorToScScene(Sc::Scene& s, NpRigidStatic& staticObject, NpShape* const* npShapes, PxU32 nbShapes, PxBounds3* uninflatedBounds, const BVH* bvh) { PX_UNUSED(bvh); const size_t shapePtrOffset = NpShape::getCoreOffset(); s.addStatic(staticObject.getCore(), npShapes, nbShapes, shapePtrOffset, uninflatedBounds); } template <class T> void addSimActorToScSceneT(Sc::Scene& s, NpRigidBodyTemplate<T>& dynamicObject, NpShape* const* npShapes, PxU32 nbShapes, PxBounds3* uninflatedBounds, const BVH* bvh) { const bool isCompound = bvh ? true : false; const size_t shapePtrOffset = NpShape::getCoreOffset(); s.addBody(dynamicObject.getCore(), npShapes, nbShapes, shapePtrOffset, uninflatedBounds, isCompound); } void addSimActorToScScene(Sc::Scene& s, NpRigidDynamic& dynamicObject, NpShape* const* npShapes, PxU32 nbShapes, PxBounds3* uninflatedBounds, const BVH* bvh) { addSimActorToScSceneT<PxRigidDynamic>(s, dynamicObject, npShapes, nbShapes, uninflatedBounds, bvh); } void addSimActorToScScene(Sc::Scene& s, NpArticulationLink& dynamicObject, NpShape* const* npShapes, PxU32 nbShapes, PxBounds3* uninflatedBounds, const BVH* bvh) { addSimActorToScSceneT<PxArticulationLink>(s, dynamicObject, npShapes, nbShapes, uninflatedBounds, bvh); } PX_FORCE_INLINE static void removeSimActorFromScScene(Sc::Scene& s, NpRigidStatic& staticObject, PxInlineArray<const Sc::ShapeCore*, 64>& scBatchRemovedShapes, bool wakeOnLostTouch) { s.removeStatic(staticObject.getCore(), scBatchRemovedShapes, wakeOnLostTouch); } template <class T> PX_FORCE_INLINE static void removeSimActorFromScSceneT(Sc::Scene& s, NpRigidBodyTemplate<T>& dynamicObject, PxInlineArray<const Sc::ShapeCore*, 64>& scBatchRemovedShapes, bool wakeOnLostTouch) { s.removeBody(dynamicObject.getCore(), scBatchRemovedShapes, wakeOnLostTouch); } PX_FORCE_INLINE static void removeSimActorFromScScene(Sc::Scene& s, NpRigidDynamic& dynamicObject, PxInlineArray<const Sc::ShapeCore*, 64>& scBatchRemovedShapes, bool wakeOnLostTouch) { removeSimActorFromScSceneT<PxRigidDynamic>(s, dynamicObject, scBatchRemovedShapes, wakeOnLostTouch); } PX_FORCE_INLINE static void removeSimActorFromScScene(Sc::Scene& s, NpArticulationLink& dynamicObject, PxInlineArray<const Sc::ShapeCore*, 64>& scBatchRemovedShapes, bool wakeOnLostTouch) { removeSimActorFromScSceneT<PxArticulationLink>(s, dynamicObject, scBatchRemovedShapes, wakeOnLostTouch); } template <class T> PX_FORCE_INLINE static void addSimActor(Sc::Scene& s, T& object, PxBounds3* uninflatedBounds, const BVH* bvh) { NpShape* const* npShapes = NULL; const PxU32 nbShapes = getShapes(object, npShapes); PX_ASSERT((0 == nbShapes) || npShapes); addSimActorToScScene(s, object, npShapes, nbShapes, uninflatedBounds, bvh); NpScene* scScene = object.getNpScene(); addActorShapes(npShapes, nbShapes, &object, scScene); } template <class T> PX_FORCE_INLINE static void removeSimActor(Sc::Scene& s, T& object, bool wakeOnLostTouch) { NpScene* scScene = object.getNpScene(); PxInlineArray<const Sc::ShapeCore*, 64> localShapes; PxInlineArray<const Sc::ShapeCore*, 64>& scBatchRemovedShapes = s.getBatchRemove() ? s.getBatchRemove()->removedShapes : localShapes; removeSimActorFromScScene(s, object, scBatchRemovedShapes, wakeOnLostTouch); Sc::ShapeCore* const* scShapes = const_cast<Sc::ShapeCore*const*>(scBatchRemovedShapes.begin()); const PxU32 nbShapes = scBatchRemovedShapes.size(); PX_ASSERT((0 == nbShapes) || scShapes); removeActorShapes(scShapes, nbShapes, &object, scScene); } // PT: TODO: consider unifying addNonSimActor / removeNonSimActor template <class T> PX_FORCE_INLINE static void addNonSimActor(T& rigid) { NpShape* const* npShapes = NULL; const PxU32 nbShapes = getShapes(rigid, npShapes); PX_ASSERT((0 == nbShapes) || npShapes); NpScene* scScene = rigid.getNpScene(); PX_ASSERT(scScene); addActorShapes(npShapes, nbShapes, &rigid, scScene); } template <class T> PX_FORCE_INLINE static void removeNonSimActor(T& rigid) { NpShape* const* npShapes = NULL; const PxU32 nbShapes = getShapes(rigid, npShapes); PX_ASSERT((0 == nbShapes) || npShapes); NpScene* scScene = rigid.getNpScene(); PX_ASSERT(scScene); removeActorShapes(npShapes, nbShapes, &rigid, scScene); } template <typename T>struct ScSceneFns {}; #if PX_SUPPORT_GPU_PHYSX template<> struct ScSceneFns<NpSoftBody> { static PX_FORCE_INLINE void insert(Sc::Scene& s, NpSoftBody& v, PxBounds3*, const BVH*, bool) { s.addSoftBody(v.getCore()); } static PX_FORCE_INLINE void remove(Sc::Scene& s, NpSoftBody& v, bool /*wakeOnLostTouch*/) { s.removeSoftBody(v.getCore()); } }; #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION template<> struct ScSceneFns<NpFEMCloth> { static PX_FORCE_INLINE void insert(Sc::Scene& s, NpFEMCloth& v, PxBounds3*, const Gu::BVH*, bool) { s.addFEMCloth(v.getCore()); } static PX_FORCE_INLINE void remove(Sc::Scene& s, NpFEMCloth& v, bool /*wakeOnLostTouch*/) { s.removeFEMCloth(v.getCore()); } }; #endif template<> struct ScSceneFns<NpPBDParticleSystem> { static PX_FORCE_INLINE void insert(Sc::Scene& s, NpPBDParticleSystem& v, PxBounds3*, const BVH*, bool) { s.addParticleSystem(v.getCore()); } static PX_FORCE_INLINE void remove(Sc::Scene& s, NpPBDParticleSystem& v, bool /*wakeOnLostTouch*/) { s.removeParticleSystem(v.getCore()); } }; #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION template<> struct ScSceneFns<NpFLIPParticleSystem> { static PX_FORCE_INLINE void insert(Sc::Scene& s, NpFLIPParticleSystem& v, PxBounds3*, const BVH*, bool) { s.addParticleSystem(v.getCore()); } static PX_FORCE_INLINE void remove(Sc::Scene& s, NpFLIPParticleSystem& v, bool /*wakeOnLostTouch*/) { s.removeParticleSystem(v.getCore()); } }; template<> struct ScSceneFns<NpMPMParticleSystem> { static PX_FORCE_INLINE void insert(Sc::Scene& s, NpMPMParticleSystem& v, PxBounds3*, const BVH*, bool) { s.addParticleSystem(v.getCore()); } static PX_FORCE_INLINE void remove(Sc::Scene& s, NpMPMParticleSystem& v, bool /*wakeOnLostTouch*/) { s.removeParticleSystem(v.getCore()); } }; template<> struct ScSceneFns<NpHairSystem> { static PX_FORCE_INLINE void insert(Sc::Scene& s, NpHairSystem& v, PxBounds3*, const BVH*, bool) { s.addHairSystem(v.getCore()); } static PX_FORCE_INLINE void remove(Sc::Scene& s, NpHairSystem& v, bool /*wakeOnLostTouch*/) { s.removeHairSystem(v.getCore()); } }; #endif #endif template<> struct ScSceneFns<NpArticulationReducedCoordinate> { static PX_FORCE_INLINE void insert(Sc::Scene& s, NpArticulationReducedCoordinate& v, PxBounds3*, const BVH*, bool) { s.addArticulation(v.getCore(), v.getRoot()->getCore()); } static PX_FORCE_INLINE void remove(Sc::Scene& s, NpArticulationReducedCoordinate& v, bool /*wakeOnLostTouch*/) { s.removeArticulation(v.getCore()); } }; template<> struct ScSceneFns<NpArticulationJointReducedCoordinate> { static PX_FORCE_INLINE void insert(Sc::Scene& s, NpArticulationJointReducedCoordinate& v, PxBounds3*, const BVH*, bool) { s.addArticulationJoint(v.getCore(), v.getParent().getCore(), v.getChild().getCore()); } static PX_FORCE_INLINE void remove(Sc::Scene& s, NpArticulationJointReducedCoordinate& v, bool /*wakeOnLostTouch*/) { s.removeArticulationJoint(v.getCore()); } }; template<> struct ScSceneFns<NpArticulationSpatialTendon> { static PX_FORCE_INLINE void insert(Sc::Scene& s, NpArticulationSpatialTendon& v, PxBounds3*, const BVH*, bool) { s.addArticulationTendon(v.getTendonCore()); } static PX_FORCE_INLINE void remove(Sc::Scene& s, NpArticulationSpatialTendon& v, bool /*wakeOnLostTouch*/) { s.removeArticulationTendon(v.getTendonCore()); } }; template<> struct ScSceneFns<NpArticulationFixedTendon> { static PX_FORCE_INLINE void insert(Sc::Scene& s, NpArticulationFixedTendon& v, PxBounds3*, const BVH*, bool) { s.addArticulationTendon(v.getTendonCore()); } static PX_FORCE_INLINE void remove(Sc::Scene& s, NpArticulationFixedTendon& v, bool /*wakeOnLostTouch*/) { s.removeArticulationTendon(v.getTendonCore()); } }; template<> struct ScSceneFns<NpArticulationSensor> { static PX_FORCE_INLINE void insert(Sc::Scene& s, NpArticulationSensor& v, PxBounds3*, const BVH*, bool) { s.addArticulationSensor(v.getSensorCore()); } static PX_FORCE_INLINE void remove(Sc::Scene& s, NpArticulationSensor& v, bool /*wakeOnLostTouch*/) { s.removeArticulationSensor(v.getSensorCore()); } }; // PT: TODO: refactor with version in NpConstraint.cpp & with NpActor::getFromPxActor static NpActor* getNpActor(PxRigidActor* a) { if(!a) return NULL; const PxType type = a->getConcreteType(); if(type == PxConcreteType::eRIGID_DYNAMIC) return static_cast<NpRigidDynamic*>(a); else if(type == PxConcreteType::eARTICULATION_LINK) return static_cast<NpArticulationLink*>(a); else { PX_ASSERT(type == PxConcreteType::eRIGID_STATIC); return static_cast<NpRigidStatic*>(a); } } template<> struct ScSceneFns<NpConstraint> { static PX_FORCE_INLINE void insert(Sc::Scene& s, NpConstraint& v, PxBounds3*, const BVH*, bool) { PxRigidActor* a0, * a1; v.getActors(a0, a1); NpActor* sc0 = getNpActor(a0); NpActor* sc1 = getNpActor(a1); PX_ASSERT((!sc0) || (!(sc0->getActorFlags().isSet(PxActorFlag::eDISABLE_SIMULATION)))); PX_ASSERT((!sc1) || (!(sc1->getActorFlags().isSet(PxActorFlag::eDISABLE_SIMULATION)))); s.addConstraint(v.getCore(), sc0 ? &sc0->getScRigidCore() : NULL, sc1 ? &sc1->getScRigidCore() : NULL); } static PX_FORCE_INLINE void remove(Sc::Scene& s, NpConstraint& v, bool /*wakeOnLostTouch*/) { s.removeConstraint(v.getCore()); } }; template<> struct ScSceneFns<NpRigidStatic> { static PX_FORCE_INLINE void insert(Sc::Scene& s, NpRigidStatic& v, PxBounds3* uninflatedBounds, const BVH* bvh, bool noSim) { PX_ASSERT(v.getCore().getActorFlags().isSet(PxActorFlag::eDISABLE_SIMULATION)==noSim); if(!noSim) addSimActor(s, v, uninflatedBounds, bvh); else addNonSimActor(v); } static PX_FORCE_INLINE void remove(Sc::Scene& s, NpRigidStatic& v, bool wakeOnLostTouch) { if(!v.getActorFlags().isSet(PxActorFlag::eDISABLE_SIMULATION)) removeSimActor(s, v, wakeOnLostTouch); else removeNonSimActor(v); } }; template<> struct ScSceneFns<NpRigidDynamic> { static PX_FORCE_INLINE void insert(Sc::Scene& s, NpRigidDynamic& v, PxBounds3* uninflatedBounds, const BVH* bvh, bool noSim) { PX_ASSERT(v.getCore().getActorFlags().isSet(PxActorFlag::eDISABLE_SIMULATION)==noSim); if(!noSim) addSimActor(s, v, uninflatedBounds, bvh); else addNonSimActor(v); } static PX_FORCE_INLINE void remove(Sc::Scene& s, NpRigidDynamic& v, bool wakeOnLostTouch) { if(!v.getActorFlags().isSet(PxActorFlag::eDISABLE_SIMULATION)) removeSimActor(s, v, wakeOnLostTouch); else removeNonSimActor(v); } }; template<> struct ScSceneFns<NpArticulationLink> { static PX_FORCE_INLINE void insert(Sc::Scene& s, NpArticulationLink& v, PxBounds3* uninflatedBounds, const BVH* bvh, bool noSim) { PX_UNUSED(noSim); PX_ASSERT(!noSim); // PT: the flag isn't supported on NpArticulationLink PX_ASSERT(!v.getActorFlags().isSet(PxActorFlag::eDISABLE_SIMULATION)); //if(!noSim) addSimActor(s, v, uninflatedBounds, bvh); //else // addNonSimActor(v); } static PX_FORCE_INLINE void remove(Sc::Scene& s, NpArticulationLink& v, bool wakeOnLostTouch) { PX_ASSERT(!v.getActorFlags().isSet(PxActorFlag::eDISABLE_SIMULATION)); //if(!v.getActorFlags().isSet(PxActorFlag::eDISABLE_SIMULATION)) removeSimActor(s, v, wakeOnLostTouch); //else // removeNonSimActor(v); } }; /////////////////////////////////////////////////////////////////////////////// #if PX_SUPPORT_PVD template<typename T> struct PvdFns { // PT: in the following functions, checkPvdDebugFlag() is done by the callers to save time when functions are called from a loop. static void createInstance(NpScene& scene, Vd::PvdSceneClient& d, T* v) { PX_PROFILE_ZONE("PVD.createPVDInstance", scene.getScScene().getContextId()); PX_UNUSED(scene); d.createPvdInstance(v); } static void updateInstance(NpScene& scene, Vd::PvdSceneClient& d, T* v) { PX_UNUSED(scene); { PX_PROFILE_ZONE("PVD.updatePVDProperties", scene.getScScene().getContextId()); d.updatePvdProperties(v); } } static void releaseInstance(NpScene& scene, Vd::PvdSceneClient& d, T* v) { PX_UNUSED(scene); PX_PROFILE_ZONE("PVD.releasePVDInstance", scene.getScScene().getContextId()); d.releasePvdInstance(v); } }; #endif /////////////////////////////////////////////////////////////////////////////// template<typename T> static void add(NpScene* npScene, T& v, PxBounds3* uninflatedBounds=NULL, const BVH* bvh=NULL, bool noSim=false) { PX_ASSERT(!npScene->isAPIWriteForbidden()); v.setNpScene(npScene); ScSceneFns<T>::insert(npScene->getScScene(), v, uninflatedBounds, bvh, noSim); #if PX_SUPPORT_PVD Vd::PvdSceneClient& pvdClient = npScene->getScenePvdClientInternal(); if(pvdClient.checkPvdDebugFlag()) PvdFns<T>::createInstance(*npScene, pvdClient, &v); #endif } template<typename T> static void remove(NpScene* npScene, T& v, bool wakeOnLostTouch=false) { PX_ASSERT(!npScene->isAPIWriteForbidden()); ScSceneFns<T>::remove(npScene->getScScene(), v, wakeOnLostTouch); #if PX_SUPPORT_PVD Vd::PvdSceneClient& pvdClient = npScene->getScenePvdClientInternal(); if(pvdClient.checkPvdDebugFlag()) PvdFns<T>::releaseInstance(*npScene, pvdClient, &v); #endif v.setNpScene(NULL); } template<class T> static void removeRigidNoSimT(NpScene* npScene, T& v) { PX_ASSERT(!npScene->isAPIWriteForbidden()); PX_ASSERT(v.getActorFlags().isSet(PxActorFlag::eDISABLE_SIMULATION)); removeNonSimActor(v); #if PX_SUPPORT_PVD Vd::PvdSceneClient& pvdClient = npScene->getScenePvdClientInternal(); if(pvdClient.checkPvdDebugFlag()) PvdFns<T>::releaseInstance(*npScene, pvdClient, &v); #else PX_UNUSED(npScene); #endif v.setNpScene(NULL); } template<class T> static PX_FORCE_INLINE void addActorT(NpScene* npScene, T& actor, bool noSim, PxBounds3* uninflatedBounds, const BVH* bvh) { PX_ASSERT(!npScene->isAPIWriteForbidden()); PX_PROFILE_ZONE("API.addActorToSim", npScene->getScScene().getContextId()); if(!noSim) { // PT: TODO: this codepath re-tests the sim flag and actually supports both cases!!! add<T>(npScene, actor, uninflatedBounds, bvh, noSim); } else { PX_ASSERT(actor.getActorFlags().isSet(PxActorFlag::eDISABLE_SIMULATION)); actor.setNpScene(npScene); #if PX_SUPPORT_PVD Vd::PvdSceneClient& pvdClient = npScene->getScenePvdClientInternal(); if(pvdClient.checkPvdDebugFlag()) PvdFns<T>::createInstance(*npScene, pvdClient, &actor); #endif OMNI_PVD_ADD(OMNI_PVD_CONTEXT_HANDLE, PxScene, actors, static_cast<PxScene &>(*npScene), static_cast<PxActor &>(actor)) addNonSimActor(actor); } } /////////////////////////////////////////////////////////////////////////////// void NpScene::scAddActor(NpRigidStatic& rigidStatic, bool noSim, PxBounds3* uninflatedBounds, const BVH* bvh) { addActorT(this, rigidStatic, noSim, uninflatedBounds, bvh); } void NpScene::scAddActor(NpRigidDynamic& body, bool noSim, PxBounds3* uninflatedBounds, const BVH* bvh) { addActorT(this, body, noSim, uninflatedBounds, bvh); } void NpScene::scAddActor(NpArticulationLink& body, bool noSim, PxBounds3* uninflatedBounds, const BVH* bvh) { addActorT(this, body, noSim, uninflatedBounds, bvh); } /////////////////////////////////////////////////////////////////////////////// // PT: TODO: refactor scRemoveActor for NpRigidStatic & NpRigidDynamic void NpScene::scRemoveActor(NpRigidStatic& rigidStatic, bool wakeOnLostTouch, bool noSim) { PX_ASSERT(!isAPIWriteForbidden()); PX_PROFILE_ZONE("API.removeActorFromSim", getScScene().getContextId()); if(!noSim) remove<NpRigidStatic>(this, rigidStatic, wakeOnLostTouch); else removeRigidNoSimT(this, rigidStatic); } void NpScene::scRemoveActor(NpRigidDynamic& body, bool wakeOnLostTouch, bool noSim) { PX_ASSERT(!isAPIWriteForbidden()); PX_PROFILE_ZONE("API.removeActorFromSim", getScScene().getContextId()); if(!noSim) remove<NpRigidDynamic>(this, body, wakeOnLostTouch); else removeRigidNoSimT(this, body); } void NpScene::scRemoveActor(NpArticulationLink& body, bool wakeOnLostTouch, bool noSim) { PX_ASSERT(!noSim); PX_UNUSED(noSim); PX_ASSERT(!isAPIWriteForbidden()); PX_PROFILE_ZONE("API.removeActorFromSim", getScScene().getContextId()); remove<NpArticulationLink>(this, body, wakeOnLostTouch); } /////////////////////////////////////////////////////////////////////////////// #ifdef NEW_DIRTY_SHADERS_CODE void NpScene::addDirtyConstraint(NpConstraint* constraint) { PX_ASSERT(!constraint->isDirty()); // PT: lock needed because PxConstraint::markDirty() can be called from multiple threads. // PT: TODO: consider optimizing this PxMutex::ScopedLock lock(mDirtyConstraintsLock); mDirtyConstraints.pushBack(constraint); } #endif void NpScene::addToConstraintList(PxConstraint& constraint) { NpConstraint& npConstraint = static_cast<NpConstraint&>(constraint); add<NpConstraint>(this, npConstraint); #ifdef NEW_DIRTY_SHADERS_CODE if(npConstraint.getCore().getFlags() & PxConstraintFlag::eALWAYS_UPDATE) mAlwaysUpdatedConstraints.pushBack(&npConstraint); else { // PT: mark all new constraints dirty to make sure their data is copied at least once mDirtyConstraints.pushBack(&npConstraint); npConstraint.getCore().setDirty(); } #endif } void NpScene::removeFromConstraintList(PxConstraint& constraint) { PX_ASSERT(!isAPIWriteForbidden()); NpConstraint& npConstraint = static_cast<NpConstraint&>(constraint); #ifdef NEW_DIRTY_SHADERS_CODE // PT: TODO: consider optimizing this { if(npConstraint.getCore().isDirty()) mDirtyConstraints.findAndReplaceWithLast(&npConstraint); if(npConstraint.getCore().getFlags() & PxConstraintFlag::eALWAYS_UPDATE) mAlwaysUpdatedConstraints.findAndReplaceWithLast(&npConstraint); } #endif mScene.removeConstraint(npConstraint.getCore()); // Release pvd constraint immediately since delayed removal with already released ext::joints does not work, can't call callback. RELEASE_PVD_INSTANCE(&npConstraint) npConstraint.setNpScene(NULL); } /////////////////////////////////////////////////////////////////////////////// #if PX_SUPPORT_GPU_PHYSX void NpScene::scAddSoftBody(NpSoftBody& softBody) { add<NpSoftBody>(this, softBody); } void NpScene::scRemoveSoftBody(NpSoftBody& softBody) { mScene.removeSoftBodySimControl(softBody.getCore()); remove<NpSoftBody>(this, softBody); } //////////////////////////////////////////////////////////////////////////////// #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION void NpScene::scAddFEMCloth(NpScene* npScene, NpFEMCloth& femCloth) { add<NpFEMCloth>(npScene, femCloth, NULL, NULL); } void NpScene::scRemoveFEMCloth(NpFEMCloth& femCloth) { mScene.removeFEMClothSimControl(femCloth.getCore()); remove<NpFEMCloth>(this, femCloth, false); } #endif //////////////////////////////////////////////////////////////////////////////// void NpScene::scAddParticleSystem(NpPBDParticleSystem& particleSystem) { add<NpPBDParticleSystem>(this, particleSystem); } void NpScene::scRemoveParticleSystem(NpPBDParticleSystem& particleSystem) { mScene.removeParticleSystemSimControl(particleSystem.getCore()); remove<NpPBDParticleSystem>(this, particleSystem); } //////////////////////////////////////////////////////////////////////////////// #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION void NpScene::scAddParticleSystem(NpFLIPParticleSystem& particleSystem) { add<NpFLIPParticleSystem>(this, particleSystem); } void NpScene::scRemoveParticleSystem(NpFLIPParticleSystem& particleSystem) { mScene.removeParticleSystemSimControl(particleSystem.getCore()); remove<NpFLIPParticleSystem>(this, particleSystem); } //////////////////////////////////////////////////////////////////////////////// void NpScene::scAddParticleSystem(NpMPMParticleSystem& particleSystem) { add<NpMPMParticleSystem>(this, particleSystem); } void NpScene::scRemoveParticleSystem(NpMPMParticleSystem& particleSystem) { mScene.removeParticleSystemSimControl(particleSystem.getCore()); remove<NpMPMParticleSystem>(this, particleSystem); } //////////////////////////////////////////////////////////////////////////////// void NpScene::scAddHairSystem(NpHairSystem& hairSystem) { add<NpHairSystem>(this, hairSystem); } void NpScene::scRemoveHairSystem(NpHairSystem& hairSystem) { mScene.removeHairSystemSimControl(hairSystem.getCore()); remove<NpHairSystem>(this, hairSystem); } #endif #endif /////////////////////////////////////////////////////////////////////////////// void NpScene::scAddArticulation(NpArticulationReducedCoordinate& articulation) { add<NpArticulationReducedCoordinate>(this, articulation); } void NpScene::scRemoveArticulation(NpArticulationReducedCoordinate& articulation) { mScene.removeArticulationSimControl(articulation.getCore()); remove<NpArticulationReducedCoordinate>(this, articulation); } /////////////////////////////////////////////////////////////////////////////// void NpScene::scAddArticulationJoint(NpArticulationJointReducedCoordinate& joint) { add<NpArticulationJointReducedCoordinate>(this, joint); } void NpScene::scRemoveArticulationJoint(NpArticulationJointReducedCoordinate& joint) { remove<NpArticulationJointReducedCoordinate>(this, joint); } /////////////////////////////////////////////////////////////////////////////// void NpScene::scAddArticulationSpatialTendon(NpArticulationSpatialTendon& tendon) { add<NpArticulationSpatialTendon>(this, tendon); } void NpScene::scRemoveArticulationSpatialTendon(NpArticulationSpatialTendon& tendon) { remove<NpArticulationSpatialTendon>(this, tendon); } /////////////////////////////////////////////////////////////////////////////// void NpScene::scAddArticulationFixedTendon(NpArticulationFixedTendon& tendon) { add<NpArticulationFixedTendon>(this, tendon); } void NpScene::scRemoveArticulationFixedTendon(NpArticulationFixedTendon& tendon) { remove<NpArticulationFixedTendon>(this, tendon); } void NpScene::scAddArticulationSensor(NpArticulationSensor& sensor) { add<NpArticulationSensor>(this, sensor); } void NpScene::scRemoveArticulationSensor(NpArticulationSensor& sensor) { remove<NpArticulationSensor>(this, sensor); } /////////////////////////////////////////////////////////////////////////////// void NpScene::createInOmniPVD(const PxSceneDesc& desc) { PX_UNUSED(desc); OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) OMNI_PVD_CREATE_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, static_cast<PxScene &>(*this)) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, gravity, static_cast<PxScene &>(*this), getGravity()) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, flags, static_cast<PxScene&>(*this), getFlags()) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, frictionType, static_cast<PxScene&>(*this), getFrictionType()) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, broadPhaseType, static_cast<PxScene&>(*this), getBroadPhaseType()) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, kineKineFilteringMode, static_cast<PxScene&>(*this), getKinematicKinematicFilteringMode()) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, staticKineFilteringMode, static_cast<PxScene&>(*this), getStaticKinematicFilteringMode()) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, solverType, static_cast<PxScene&>(*this), getSolverType()) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, bounceThresholdVelocity, static_cast<PxScene&>(*this), getBounceThresholdVelocity()) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, frictionOffsetThreshold, static_cast<PxScene&>(*this), getFrictionOffsetThreshold()) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, frictionCorrelationDistance, static_cast<PxScene&>(*this), getFrictionCorrelationDistance()) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, solverBatchSize, static_cast<PxScene&>(*this), getSolverBatchSize()) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, solverArticulationBatchSize, static_cast<PxScene&>(*this), getSolverArticulationBatchSize()) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, nbContactDataBlocks, static_cast<PxScene&>(*this), getNbContactDataBlocksUsed()) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, maxNbContactDataBlocks, static_cast<PxScene&>(*this), getMaxNbContactDataBlocksUsed())//naming problem of functions OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, maxBiasCoefficient, static_cast<PxScene&>(*this), getMaxBiasCoefficient()) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, contactReportStreamBufferSize, static_cast<PxScene&>(*this), getContactReportStreamBufferSize()) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, ccdMaxPasses, static_cast<PxScene&>(*this), getCCDMaxPasses()) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, ccdThreshold, static_cast<PxScene&>(*this), getCCDThreshold()) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, ccdMaxSeparation, static_cast<PxScene&>(*this), getCCDMaxSeparation()) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, wakeCounterResetValue, static_cast<PxScene&>(*this), getWakeCounterResetValue()) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, limitsMaxNbActors, static_cast<PxScene&>(*this), desc.limits.maxNbActors) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, limitsMaxNbBodies, static_cast<PxScene&>(*this), desc.limits.maxNbBodies) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, limitsMaxNbStaticShapes, static_cast<PxScene&>(*this), desc.limits.maxNbStaticShapes) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, limitsMaxNbDynamicShapes, static_cast<PxScene&>(*this), desc.limits.maxNbDynamicShapes) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, limitsMaxNbAggregates, static_cast<PxScene&>(*this), desc.limits.maxNbAggregates) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, limitsMaxNbConstraints, static_cast<PxScene&>(*this), desc.limits.maxNbConstraints) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, limitsMaxNbRegions, static_cast<PxScene&>(*this), desc.limits.maxNbRegions) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, limitsMaxNbBroadPhaseOverlaps, static_cast<PxScene&>(*this), desc.limits.maxNbBroadPhaseOverlaps) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, hasCPUDispatcher, static_cast<PxScene&>(*this), getCpuDispatcher() ? true : false) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, hasCUDAContextManager, static_cast<PxScene&>(*this), getCudaContextManager() ? true : false) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, hasSimulationEventCallback, static_cast<PxScene&>(*this), getSimulationEventCallback() ? true : false) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, hasContactModifyCallback, static_cast<PxScene&>(*this), getContactModifyCallback() ? true : false) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, hasCCDContactModifyCallback, static_cast<PxScene&>(*this), getCCDContactModifyCallback() ? true : false) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, hasBroadPhaseCallback, static_cast<PxScene&>(*this), getBroadPhaseCallback() ? true : false) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, hasFilterCallback, static_cast<PxScene&>(*this), getFilterCallback() ? true : false) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, sanityBounds, static_cast<PxScene&>(*this), desc.sanityBounds) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, gpuDynamicsConfig, static_cast<PxScene&>(*this), desc.gpuDynamicsConfig) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, gpuMaxNumPartitions, static_cast<PxScene&>(*this), desc.gpuMaxNumPartitions) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, gpuMaxNumStaticPartitions, static_cast<PxScene&>(*this), desc.gpuMaxNumStaticPartitions) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, gpuComputeVersion, static_cast<PxScene&>(*this), desc.gpuComputeVersion) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, contactPairSlabSize, static_cast<PxScene&>(*this), desc.contactPairSlabSize) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, tolerancesScale, static_cast<PxScene&>(*this), desc.getTolerancesScale()) OMNI_PVD_WRITE_SCOPE_END }
168,633
C++
33.464337
249
0.735787
NVIDIA-Omniverse/PhysX/physx/source/physx/src/NpSerializerAdapter.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #include "common/PxBase.h" #include "common/PxSerialFramework.h" #include "common/PxSerializer.h" #include "PxPhysicsSerialization.h" #include "GuHeightField.h" #include "GuConvexMesh.h" #include "GuTriangleMesh.h" #include "GuTriangleMeshBV4.h" #include "GuTriangleMeshRTree.h" #include "GuHeightFieldData.h" #include "NpPruningStructure.h" #include "NpRigidStatic.h" #include "NpRigidDynamic.h" #include "NpArticulationReducedCoordinate.h" #include "NpArticulationLink.h" #include "NpArticulationSensor.h" #include "NpMaterial.h" #include "NpAggregate.h" namespace physx { using namespace physx::Gu; template<> void PxSerializerDefaultAdapter<NpMaterial>::registerReferences(PxBase& obj, PxSerializationContext& context) const { NpMaterial& t = static_cast<NpMaterial&>(obj); context.registerReference(obj, PX_SERIAL_REF_KIND_PXBASE, size_t(&obj)); context.registerReference(obj, PX_SERIAL_REF_KIND_MATERIAL_IDX, size_t(t.mMaterial.mMaterialIndex)); } template<> void PxSerializerDefaultAdapter<NpRigidDynamic>::registerReferences(PxBase& obj, PxSerializationContext& context) const { NpRigidDynamic& dynamic = static_cast<NpRigidDynamic&>(obj); context.registerReference(obj, PX_SERIAL_REF_KIND_PXBASE, size_t(&obj)); struct RequiresCallback : public PxProcessPxBaseCallback { RequiresCallback(physx::PxSerializationContext& c) : context(c) {} RequiresCallback& operator=(const RequiresCallback&) { PX_ASSERT(0); return *this; } //PX_NOCOPY doesn't work for local classes void process(PxBase& base) { context.registerReference(base, PX_SERIAL_REF_KIND_PXBASE, size_t(&base)); } PxSerializationContext& context; }; RequiresCallback callback(context); dynamic.requiresObjects(callback); } template<> bool PxSerializerDefaultAdapter<NpArticulationLink>::isSubordinate() const { return true; } template<> void PxSerializerDefaultAdapter<NpShape>::registerReferences(PxBase& obj, PxSerializationContext& context) const { NpShape& shape = static_cast<NpShape&>(obj); context.registerReference(obj, PX_SERIAL_REF_KIND_PXBASE, size_t(&obj)); struct RequiresCallback : public PxProcessPxBaseCallback { RequiresCallback(physx::PxSerializationContext& c) : context(c) {} RequiresCallback &operator=(const RequiresCallback&) { PX_ASSERT(0); return *this; } //PX_NOCOPY doesn't work for local classes void process(PxBase& base) { PxMaterial* pxMaterial = base.is<PxMaterial>(); if (!pxMaterial) { context.registerReference(base, PX_SERIAL_REF_KIND_PXBASE, size_t(&base)); } else { //ideally we would move this part to ScShapeCore but we don't yet have a MaterialManager available there. const PxU16 index = static_cast<NpMaterial*>(pxMaterial)->mMaterial.mMaterialIndex; context.registerReference(base, PX_SERIAL_REF_KIND_MATERIAL_IDX, size_t(index)); } } PxSerializationContext& context; }; RequiresCallback callback(context); shape.requiresObjects(callback); } template<> bool PxSerializerDefaultAdapter<NpConstraint>::isSubordinate() const { return true; } template<> bool PxSerializerDefaultAdapter<NpArticulationJointReducedCoordinate>::isSubordinate() const { return true; } } using namespace physx; void PxRegisterPhysicsSerializers(PxSerializationRegistry& sr) { sr.registerSerializer(PxConcreteType::eCONVEX_MESH, PX_NEW_SERIALIZER_ADAPTER(ConvexMesh)); sr.registerSerializer(PxConcreteType::eTRIANGLE_MESH_BVH33, PX_NEW_SERIALIZER_ADAPTER(RTreeTriangleMesh)); sr.registerSerializer(PxConcreteType::eTRIANGLE_MESH_BVH34, PX_NEW_SERIALIZER_ADAPTER(BV4TriangleMesh)); sr.registerSerializer(PxConcreteType::eHEIGHTFIELD, PX_NEW_SERIALIZER_ADAPTER(HeightField)); sr.registerSerializer(PxConcreteType::eRIGID_DYNAMIC, PX_NEW_SERIALIZER_ADAPTER(NpRigidDynamic)); sr.registerSerializer(PxConcreteType::eRIGID_STATIC, PX_NEW_SERIALIZER_ADAPTER(NpRigidStatic)); sr.registerSerializer(PxConcreteType::eSHAPE, PX_NEW_SERIALIZER_ADAPTER(NpShape)); sr.registerSerializer(PxConcreteType::eMATERIAL, PX_NEW_SERIALIZER_ADAPTER(NpMaterial)); sr.registerSerializer(PxConcreteType::eCONSTRAINT, PX_NEW_SERIALIZER_ADAPTER(NpConstraint)); sr.registerSerializer(PxConcreteType::eAGGREGATE, PX_NEW_SERIALIZER_ADAPTER(NpAggregate)); sr.registerSerializer(PxConcreteType::eARTICULATION_REDUCED_COORDINATE, PX_NEW_SERIALIZER_ADAPTER(NpArticulationReducedCoordinate)); sr.registerSerializer(PxConcreteType::eARTICULATION_LINK, PX_NEW_SERIALIZER_ADAPTER(NpArticulationLink)); sr.registerSerializer(PxConcreteType::eARTICULATION_JOINT_REDUCED_COORDINATE, PX_NEW_SERIALIZER_ADAPTER(NpArticulationJointReducedCoordinate)); sr.registerSerializer(PxConcreteType::eARTICULATION_SENSOR, PX_NEW_SERIALIZER_ADAPTER(NpArticulationSensor)); sr.registerSerializer(PxConcreteType::eARTICULATION_SPATIAL_TENDON, PX_NEW_SERIALIZER_ADAPTER(NpArticulationSpatialTendon)); sr.registerSerializer(PxConcreteType::eARTICULATION_ATTACHMENT, PX_NEW_SERIALIZER_ADAPTER(NpArticulationAttachment)); sr.registerSerializer(PxConcreteType::eARTICULATION_FIXED_TENDON, PX_NEW_SERIALIZER_ADAPTER(NpArticulationFixedTendon)); sr.registerSerializer(PxConcreteType::eARTICULATION_TENDON_JOINT, PX_NEW_SERIALIZER_ADAPTER(NpArticulationTendonJoint)); sr.registerSerializer(PxConcreteType::ePRUNING_STRUCTURE, PX_NEW_SERIALIZER_ADAPTER(Sq::PruningStructure)); } void PxUnregisterPhysicsSerializers(PxSerializationRegistry& sr) { PX_DELETE_SERIALIZER_ADAPTER(sr.unregisterSerializer(PxConcreteType::eCONVEX_MESH)); PX_DELETE_SERIALIZER_ADAPTER(sr.unregisterSerializer(PxConcreteType::eTRIANGLE_MESH_BVH33)); PX_DELETE_SERIALIZER_ADAPTER(sr.unregisterSerializer(PxConcreteType::eTRIANGLE_MESH_BVH34)); PX_DELETE_SERIALIZER_ADAPTER(sr.unregisterSerializer(PxConcreteType::eHEIGHTFIELD)); PX_DELETE_SERIALIZER_ADAPTER(sr.unregisterSerializer(PxConcreteType::eRIGID_DYNAMIC)); PX_DELETE_SERIALIZER_ADAPTER(sr.unregisterSerializer(PxConcreteType::eRIGID_STATIC)); PX_DELETE_SERIALIZER_ADAPTER(sr.unregisterSerializer(PxConcreteType::eSHAPE)); PX_DELETE_SERIALIZER_ADAPTER(sr.unregisterSerializer(PxConcreteType::eMATERIAL)); PX_DELETE_SERIALIZER_ADAPTER(sr.unregisterSerializer(PxConcreteType::eCONSTRAINT)); PX_DELETE_SERIALIZER_ADAPTER(sr.unregisterSerializer(PxConcreteType::eAGGREGATE)); PX_DELETE_SERIALIZER_ADAPTER(sr.unregisterSerializer(PxConcreteType::eARTICULATION_REDUCED_COORDINATE)); PX_DELETE_SERIALIZER_ADAPTER(sr.unregisterSerializer(PxConcreteType::eARTICULATION_LINK)); PX_DELETE_SERIALIZER_ADAPTER(sr.unregisterSerializer(PxConcreteType::eARTICULATION_JOINT_REDUCED_COORDINATE)); PX_DELETE_SERIALIZER_ADAPTER(sr.unregisterSerializer(PxConcreteType::eARTICULATION_SENSOR)); PX_DELETE_SERIALIZER_ADAPTER(sr.unregisterSerializer(PxConcreteType::eARTICULATION_SPATIAL_TENDON)); PX_DELETE_SERIALIZER_ADAPTER(sr.unregisterSerializer(PxConcreteType::eARTICULATION_ATTACHMENT)); PX_DELETE_SERIALIZER_ADAPTER(sr.unregisterSerializer(PxConcreteType::eARTICULATION_FIXED_TENDON)); PX_DELETE_SERIALIZER_ADAPTER(sr.unregisterSerializer(PxConcreteType::eARTICULATION_TENDON_JOINT)); PX_DELETE_SERIALIZER_ADAPTER(sr.unregisterSerializer(PxConcreteType::ePRUNING_STRUCTURE)); }
9,015
C++
48.267759
144
0.78924
NVIDIA-Omniverse/PhysX/physx/source/physx/src/NpArticulationLink.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #include "NpArticulationReducedCoordinate.h" #include "NpRigidActorTemplateInternal.h" #include "omnipvd/NpOmniPvdSetData.h" using namespace physx; using namespace Cm; // PX_SERIALIZATION void NpArticulationLink::requiresObjects(PxProcessPxBaseCallback& c) { NpArticulationLinkT::requiresObjects(c); if(mInboundJoint) c.process(*mInboundJoint); } void NpArticulationLink::exportExtraData(PxSerializationContext& stream) { NpArticulationLinkT::exportExtraData(stream); exportInlineArray(mChildLinks, stream); } void NpArticulationLink::importExtraData(PxDeserializationContext& context) { NpArticulationLinkT::importExtraData(context); importInlineArray(mChildLinks, context); } void NpArticulationLink::resolveReferences(PxDeserializationContext& context) { context.translatePxBase(mRoot); context.translatePxBase(mInboundJoint); context.translatePxBase(mParent); NpArticulationLinkT::resolveReferences(context); const PxU32 nbLinks = mChildLinks.size(); for(PxU32 i=0;i<nbLinks;i++) context.translatePxBase(mChildLinks[i]); } NpArticulationLink* NpArticulationLink::createObject(PxU8*& address, PxDeserializationContext& context) { NpArticulationLink* obj = PX_PLACEMENT_NEW(address, NpArticulationLink(PxBaseFlags(0))); address += sizeof(NpArticulationLink); obj->importExtraData(context); obj->resolveReferences(context); return obj; } //~PX_SERIALIZATION NpArticulationLink::NpArticulationLink(const PxTransform& bodyPose, PxArticulationReducedCoordinate& root, NpArticulationLink* parent) : NpArticulationLinkT (PxConcreteType::eARTICULATION_LINK, PxBaseFlag::eOWNS_MEMORY, PxActorType::eARTICULATION_LINK, NpType::eBODY_FROM_ARTICULATION_LINK, bodyPose), mRoot (&root), mInboundJoint (NULL), mParent (parent), mLLIndex (0xffffffff), mInboundJointDof (0xffffffff) { if (parent) parent->addToChildList(*this); } NpArticulationLink::~NpArticulationLink() { } void NpArticulationLink::releaseInternal() { NpPhysics::getInstance().notifyDeletionListenersUserRelease(this, userData); NpArticulationReducedCoordinate* npArticulation = static_cast<NpArticulationReducedCoordinate*>(mRoot); npArticulation->removeLinkFromList(*this); if (mParent) mParent->removeFromChildList(*this); if (mInboundJoint) mInboundJoint->release(); //Remove constraints, aggregates, scene, shapes. removeRigidActorT<PxArticulationLink>(*this); PX_ASSERT(!isAPIWriteForbidden()); NpDestroyArticulationLink(this); } void NpArticulationLink::release() { if(getNpScene()) { PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "PxArticulationLink::release() not allowed while the articulation link is in a scene. Call will be ignored."); return; } //! this function doesn't get called when the articulation root is released // therefore, put deregistration code etc. into dtor, not here if (mChildLinks.empty()) { releaseInternal(); } else { PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "PxArticulationLink::release(): Only leaf articulation links can be released. Call will be ignored."); } } PxTransform NpArticulationLink::getGlobalPose() const { NP_READ_CHECK(getNpScene()); PX_CHECK_SCENE_API_READ_FORBIDDEN_EXCEPT_COLLIDE_AND_RETURN_VAL(getNpScene(), "PxArticulationLink::getGlobalPose() not allowed while simulation is running (except during PxScene::collide()).", PxTransform(PxIdentity)); // PT:: tag: scalar transform*transform return mCore.getBody2World() * mCore.getBody2Actor().getInverse(); } bool NpArticulationLink::attachShape(PxShape& shape) { static_cast<NpArticulationReducedCoordinate*>(mRoot)->incrementShapeCount(); return NpRigidActorTemplate::attachShape(shape); } void NpArticulationLink::detachShape(PxShape& shape, bool wakeOnLostTouch) { static_cast<NpArticulationReducedCoordinate*>(mRoot)->decrementShapeCount(); NpRigidActorTemplate::detachShape(shape, wakeOnLostTouch); } PxArticulationReducedCoordinate& NpArticulationLink::getArticulation() const { NP_READ_CHECK(getNpScene()); return *mRoot; } PxArticulationJointReducedCoordinate* NpArticulationLink::getInboundJoint() const { NP_READ_CHECK(getNpScene()); return mInboundJoint; } PxU32 NpArticulationLink::getInboundJointDof() const { NP_READ_CHECK(getNpScene()); return getNpScene() ? mInboundJointDof : 0xffffffffu; } PxU32 NpArticulationLink::getNbChildren() const { NP_READ_CHECK(getNpScene()); return mChildLinks.size(); } PxU32 NpArticulationLink::getChildren(PxArticulationLink** userBuffer, PxU32 bufferSize, PxU32 startIndex) const { NP_READ_CHECK(getNpScene()); return getArrayOfPointers(userBuffer, bufferSize, startIndex, mChildLinks.begin(), mChildLinks.size()); } PxU32 NpArticulationLink::getLinkIndex() const { NP_READ_CHECK(getNpScene()); return getNpScene() ? mLLIndex : 0xffffffffu; } void NpArticulationLink::setCMassLocalPose(const PxTransform& pose) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_AND_RETURN(pose.isSane(), "PxArticulationLink::setCMassLocalPose: invalid parameter"); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxArticulationLink::setCMassLocalPose() not allowed while simulation is running. Call will be ignored.") const PxTransform p = pose.getNormalized(); const PxTransform oldpose = mCore.getBody2Actor(); const PxTransform comShift = p.transformInv(oldpose); NpArticulationLinkT::setCMassLocalPoseInternal(p); if(mInboundJoint) { NpArticulationJointReducedCoordinate* j =static_cast<NpArticulationJointReducedCoordinate*>(mInboundJoint); // PT:: tag: scalar transform*transform j->scSetChildPose(comShift.transform(j->getCore().getChildPose())); } for(PxU32 i=0; i<mChildLinks.size(); i++) { NpArticulationJointReducedCoordinate* j = static_cast<NpArticulationJointReducedCoordinate*>(mChildLinks[i]->getInboundJoint()); // PT:: tag: scalar transform*transform j->scSetParentPose(comShift.transform(j->getCore().getParentPose())); } } void NpArticulationLink::addForce(const PxVec3& force, PxForceMode::Enum mode, bool autowake) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_AND_RETURN(force.isFinite(), "PxArticulationLink::addForce: force is not valid."); PX_CHECK_AND_RETURN(npScene, "PxArticulationLink::addForce: Articulation link must be in a scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN_EXCEPT_SPLIT_SIM(npScene, "PxArticulationLink::addForce() not allowed while simulation is running, except in a split simulation in-between PxScene::fetchCollision() and PxScene::advance().Call will be ignored.") if (npScene && (npScene->getFlags() & PxSceneFlag::eENABLE_DIRECT_GPU_API) && npScene->isDirectGPUAPIInitialized()) { PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "PxArticulationLink::addForce(): it is illegal to call this method if PxSceneFlag::eENABLE_DIRECT_GPU_API is enabled!"); } addSpatialForce(&force, NULL, mode); static_cast<NpArticulationReducedCoordinate*>(mRoot)->wakeUpInternal((!force.isZero()), autowake); } void NpArticulationLink::addTorque(const PxVec3& torque, PxForceMode::Enum mode, bool autowake) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_AND_RETURN(torque.isFinite(), "PxArticulationLink::addTorque: force is not valid."); PX_CHECK_AND_RETURN(npScene, "PxArticulationLink::addTorque: Articulation link must be in a scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN_EXCEPT_SPLIT_SIM(npScene, "PxArticulationLink::addTorque() not allowed while simulation is running, except in a split simulation in-between PxScene::fetchCollision() and PxScene::advance().Call will be ignored.") if (npScene && (npScene->getFlags() & PxSceneFlag::eENABLE_DIRECT_GPU_API) && npScene->isDirectGPUAPIInitialized()) { PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "PxArticulationLink::addTorque(): it is illegal to call this method if PxSceneFlag::eENABLE_DIRECT_GPU_API is enabled!"); } addSpatialForce(NULL, &torque, mode); static_cast<NpArticulationReducedCoordinate*>(mRoot)->wakeUpInternal((!torque.isZero()), autowake); } void NpArticulationLink::setForceAndTorque(const PxVec3& force, const PxVec3& torque, PxForceMode::Enum mode) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_AND_RETURN(torque.isFinite(), "PxArticulationLink::setForceAndTorque: torque is not valid."); PX_CHECK_AND_RETURN(force.isFinite(), "PxArticulationLink::setForceAndTorque: force is not valid."); PX_CHECK_AND_RETURN(npScene, "PxArticulationLink::addTorque: Articulation link must be in a scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN_EXCEPT_SPLIT_SIM(npScene, "PxArticulationLink::setForceAndTorque() not allowed while simulation is running, except in a split simulation in-between PxScene::fetchCollision() and PxScene::advance().Call will be ignored."); if (npScene && (npScene->getFlags() & PxSceneFlag::eENABLE_DIRECT_GPU_API) && npScene->isDirectGPUAPIInitialized()) { PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "PxArticulationLink::setForceAndTorque(): it is illegal to call this method if PxSceneFlag::eENABLE_DIRECT_GPU_API is enabled!"); } setSpatialForce(&force, &torque, mode); static_cast<NpArticulationReducedCoordinate*>(mRoot)->wakeUpInternal((!torque.isZero()), true); } void NpArticulationLink::clearForce(PxForceMode::Enum mode) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_AND_RETURN(npScene, "PxArticulationLink::clearForce: Articulation link must be in a scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN_EXCEPT_SPLIT_SIM(npScene, "PxArticulationLink::clearForce() not allowed while simulation is running, except in a split simulation in-between PxScene::fetchCollision() and PxScene::advance().Call will be ignored."); if (npScene && (npScene->getFlags() & PxSceneFlag::eENABLE_DIRECT_GPU_API) && npScene->isDirectGPUAPIInitialized()) { PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "PxArticulationLink::clearForce(): it is illegal to call this method if PxSceneFlag::eENABLE_DIRECT_GPU_API is enabled!"); } clearSpatialForce(mode, true, false); } void NpArticulationLink::clearTorque(PxForceMode::Enum mode) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_AND_RETURN(npScene, "PxArticulationLink::clearTorque: Articulation link must be in a scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN_EXCEPT_SPLIT_SIM(npScene, "PxArticulationLink::clearTorque() not allowed while simulation is running, except in a split simulation in-between PxScene::fetchCollision() and PxScene::advance().Call will be ignored."); if (npScene && (npScene->getFlags() & PxSceneFlag::eENABLE_DIRECT_GPU_API) && npScene->isDirectGPUAPIInitialized()) { PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "PxArticulationLink::clearTorque(): it is illegal to call this method if PxSceneFlag::eENABLE_DIRECT_GPU_API is enabled!"); } clearSpatialForce(mode, false, true); } void NpArticulationLink::setCfmScale(const PxReal cfmScale) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(cfmScale >= 0.f && cfmScale <= 1.f, "PxArticulationLink::setCfmScale: cfm is not valid."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "PxArticulationLink::setCfmScale() not allowed while simulation is running. Call will be ignored.") mCore.getCore().cfmScale = cfmScale; OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxArticulationLink, CFMScale, static_cast<PxArticulationLink&>(*this), cfmScale); // @@@ } PxReal NpArticulationLink::getCfmScale() const { NP_READ_CHECK(getNpScene()); return mCore.getCore().cfmScale; } void NpArticulationLink::setGlobalPoseInternal(const PxTransform& pose, bool autowake) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_AND_RETURN(pose.isSane(), "PxArticulationLink::setGlobalPose: pose is not valid."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxArticulationLink::setGlobalPose() not allowed while simulation is running. Call will be ignored.") if (npScene && (npScene->getFlags() & PxSceneFlag::eENABLE_DIRECT_GPU_API) && npScene->isDirectGPUAPIInitialized()) { PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "PxArticulationLink::setGlobalPose(): it is illegal to call this method if PxSceneFlag::eENABLE_DIRECT_GPU_API is enabled!"); } #if PX_CHECKED if (npScene) npScene->checkPositionSanity(*this, pose, "PxArticulationLink::setGlobalPose"); #endif const PxTransform newPose = pose.getNormalized(); //AM: added to fix 1461 where users read and write orientations for no reason. // PT:: tag: scalar transform*transform const PxTransform body2World = newPose * mCore.getBody2Actor(); scSetBody2World(body2World); if (npScene && autowake) static_cast<NpArticulationReducedCoordinate*>(mRoot)->wakeUpInternal(false, true); if (npScene) static_cast<NpArticulationReducedCoordinate*>(mRoot)->setGlobalPose(); } void NpArticulationLink::setInboundJointDof(const PxU32 index) { mInboundJointDof = index; OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxArticulationLink, inboundJointDOF, static_cast<PxArticulationLink&>(*this), mInboundJointDof); } void NpArticulationLink::setFixedBaseLink(bool value) { NP_WRITE_CHECK(getNpScene()); mCore.setFixedBaseLink(value); } PxU32 physx::NpArticulationGetShapes(NpArticulationLink& actor, NpShape* const*& shapes, bool* isCompound) { NpShapeManager& sm = actor.getShapeManager(); shapes = sm.getShapes(); if (isCompound) *isCompound = sm.isSqCompound(); return sm.getNbShapes(); }
15,233
C++
38.466321
257
0.772139
NVIDIA-Omniverse/PhysX/physx/source/physx/src/NpConstraint.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #include "PxConstraint.h" #include "NpConstraint.h" #include "NpPhysics.h" #include "NpRigidDynamic.h" #include "NpRigidStatic.h" #include "NpArticulationLink.h" #include "ScConstraintSim.h" #include "ScConstraintInteraction.h" #include "PxsSimulationController.h" using namespace physx; using namespace Sc; /////////////////////////////////////////////////////////////////////////////// PX_IMPLEMENT_OUTPUT_ERROR /////////////////////////////////////////////////////////////////////////////// static PX_FORCE_INLINE PxConstraintFlags scGetFlags(const ConstraintCore& core) { // return core.getFlags() & (~(PxConstraintFlag::eBROKEN | PxConstraintFlag::eGPU_COMPATIBLE)); return core.getFlags() & (~(PxConstraintFlag::eGPU_COMPATIBLE)); } static NpScene* getSceneFromActors(const PxRigidActor* actor0, const PxRigidActor* actor1) { NpScene* s0 = NULL; NpScene* s1 = NULL; if(actor0 && (!(actor0->getActorFlags().isSet(PxActorFlag::eDISABLE_SIMULATION)))) s0 = static_cast<NpScene*>(actor0->getScene()); if(actor1 && (!(actor1->getActorFlags().isSet(PxActorFlag::eDISABLE_SIMULATION)))) s1 = static_cast<NpScene*>(actor1->getScene()); #if PX_CHECKED if ((s0 && s1) && (s0 != s1)) outputError<PxErrorCode::eINVALID_PARAMETER>(__LINE__, "Adding constraint to scene: Actors belong to different scenes, undefined behavior expected!"); #endif if ((!actor0 || s0) && (!actor1 || s1)) return s0 ? s0 : s1; else return NULL; } // PT: TODO: refactor with version in ScScene.cpp & with NpActor::getFromPxActor static NpActor* getNpActor(PxRigidActor* a) { if(!a) return NULL; const PxType type = a->getConcreteType(); if (type == PxConcreteType::eRIGID_DYNAMIC) return static_cast<NpRigidDynamic*>(a); else if (type == PxConcreteType::eARTICULATION_LINK) return static_cast<NpArticulationLink*>(a); else { PX_ASSERT(type == PxConcreteType::eRIGID_STATIC); return static_cast<NpRigidStatic*>(a); } } void NpConstraint::setConstraintFunctions(PxConstraintConnector& n, const PxConstraintShaderTable& shaders) { mCore.setConstraintFunctions(n, shaders); //update mConnectorArray, since mActor0 or mActor1 should be in external reference bool bNeedUpdate = false; if(mActor0) { NpActor& npActor = NpActor::getFromPxActor(*mActor0); if(npActor.findConnector(NpConnectorType::eConstraint, this) == 0xffffffff) { bNeedUpdate = true; npActor.addConnector(NpConnectorType::eConstraint, this, "PxConstraint: Add to rigid actor 0: Constraint already added"); } } if(mActor1) { NpActor& npActor = NpActor::getFromPxActor(*mActor1); if(npActor.findConnector(NpConnectorType::eConstraint, this) == 0xffffffff) { bNeedUpdate = true; npActor.addConnector(NpConnectorType::eConstraint, this, "PxConstraint: Add to rigid actor 1: Constraint already added"); } } if(bNeedUpdate) { NpScene* newScene = ::getSceneFromActors(mActor0, mActor1); NpScene* oldScene = getNpScene(); if (oldScene != newScene) { if(oldScene) oldScene->removeFromConstraintList(*this); if(newScene) newScene->addToConstraintList(*this); } } } void NpConstraint::addConnectors(PxRigidActor* actor0, PxRigidActor* actor1) { if(actor0) NpActor::getFromPxActor(*actor0).addConnector(NpConnectorType::eConstraint, this, "PxConstraint: Add to rigid actor 0: Constraint already added"); if(actor1) NpActor::getFromPxActor(*actor1).addConnector(NpConnectorType::eConstraint, this, "PxConstraint: Add to rigid actor 1: Constraint already added"); } void NpConstraint::removeConnectors(const char* errorMsg0, const char* errorMsg1) { if(mActor0) NpActor::getFromPxActor(*mActor0).removeConnector(*mActor0, NpConnectorType::eConstraint, this, errorMsg0); if(mActor1) NpActor::getFromPxActor(*mActor1).removeConnector(*mActor1, NpConnectorType::eConstraint, this, errorMsg1); } NpConstraint::NpConstraint(PxRigidActor* actor0, PxRigidActor* actor1, PxConstraintConnector& connector, const PxConstraintShaderTable& shaders, PxU32 dataSize) : PxConstraint(PxConcreteType::eCONSTRAINT, PxBaseFlag::eOWNS_MEMORY), NpBase (NpType::eCONSTRAINT), mActor0 (actor0), mActor1 (actor1), mCore (connector, shaders, dataSize) { scSetFlags(shaders.flag); addConnectors(actor0, actor1); NpScene* s = ::getSceneFromActors(actor0, actor1); if (s) { if(s->isAPIWriteForbidden()) { outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxConstraint creation not allowed while simulation is running. Call will be ignored."); return; } s->addToConstraintList(*this); } } NpConstraint::~NpConstraint() { if(getBaseFlags()&PxBaseFlag::eOWNS_MEMORY) mCore.getPxConnector()->onConstraintRelease(); NpFactory::getInstance().onConstraintRelease(this); } static const char* gRemoveConnectorMsg = "PxConstraint::release(): internal error, mConnectorArray not created."; void NpConstraint::release() { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxConstraint::release() not allowed while simulation is running. Call will be ignored.") NpPhysics::getInstance().notifyDeletionListenersUserRelease(this, NULL); removeConnectors(gRemoveConnectorMsg, gRemoveConnectorMsg); if(npScene) npScene->removeFromConstraintList(*this); NpDestroyConstraint(this); } // PX_SERIALIZATION void NpConstraint::resolveReferences(PxDeserializationContext& context) { context.translatePxBase(mActor0); context.translatePxBase(mActor1); } NpConstraint* NpConstraint::createObject(PxU8*& address, PxDeserializationContext& context) { NpConstraint* obj = PX_PLACEMENT_NEW(address, NpConstraint(PxBaseFlags(0))); address += sizeof(NpConstraint); obj->importExtraData(context); obj->resolveReferences(context); return obj; } // ~PX_SERIALIZATION PxScene* NpConstraint::getScene() const { return getNpScene(); } void NpConstraint::getActors(PxRigidActor*& actor0, PxRigidActor*& actor1) const { NP_READ_CHECK(getNpScene()); actor0 = mActor0; actor1 = mActor1; } static PX_INLINE void scSetBodies(ConstraintCore& core, NpActor* r0, NpActor* r1) { Sc::RigidCore* scR0 = r0 ? &r0->getScRigidCore() : NULL; Sc::RigidCore* scR1 = r1 ? &r1->getScRigidCore() : NULL; core.setBodies(scR0, scR1); } void NpConstraint::setActors(PxRigidActor* actor0, PxRigidActor* actor1) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_AND_RETURN((actor0 && actor0->getConcreteType()!=PxConcreteType::eRIGID_STATIC) || (actor1 && actor1->getConcreteType()!=PxConcreteType::eRIGID_STATIC), "PxConstraint: at least one actor must be non-static"); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxConstraint::setActors() not allowed while simulation is running. Call will be ignored.") if(mActor0 == actor0 && mActor1 == actor1) return; removeConnectors( "PxConstraint: Add to rigid actor 0: Constraint already added", "PxConstraint: Add to rigid actor 1: Constraint already added"); addConnectors(actor0, actor1); mActor0 = actor0; mActor1 = actor1; NpScene* newScene = ::getSceneFromActors(actor0, actor1); NpScene* oldScene = getNpScene(); // PT: bypassing the calls to removeFromConstraintList / addToConstraintList creates issues like PX-2363, where // various internal structures are not properly updated. Always going through the slower codepath fixes them. // if(oldScene != newScene) { if(oldScene) oldScene->removeFromConstraintList(*this); scSetBodies(mCore, getNpActor(actor0), getNpActor(actor1)); if(newScene) newScene->addToConstraintList(*this); } // else // scSetBodies(mCore, getNpActor(actor0), getNpActor(actor1)); UPDATE_PVD_PROPERTY } PxConstraintFlags NpConstraint::getFlags() const { NP_READ_CHECK(getNpScene()); return scGetFlags(mCore); } void NpConstraint::setFlags(PxConstraintFlags flags) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_AND_RETURN(!(flags & PxConstraintFlag::eBROKEN), "PxConstraintFlag::eBROKEN is a read only flag"); PX_CHECK_AND_RETURN(!(flags & PxConstraintFlag::eGPU_COMPATIBLE), "PxConstraintFlag::eGPU_COMPATIBLE is an internal flag and is illegal to set via the API"); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxConstraint::setFlags() not allowed while simulation is running. Call will be ignored.") scSetFlags(flags); } void NpConstraint::setFlag(PxConstraintFlag::Enum flag, bool value) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_AND_RETURN(flag != PxConstraintFlag::eBROKEN, "PxConstraintFlag::eBROKEN is a read only flag"); PX_CHECK_AND_RETURN(flag != PxConstraintFlag::eGPU_COMPATIBLE, "PxConstraintFlag::eGPU_COMPATIBLE is an internal flag and is illegal to set via the API"); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxConstraint::setFlag() not allowed while simulation is running. Call will be ignored.") const PxConstraintFlags f = scGetFlags(mCore); scSetFlags(value ? f|flag : f&~flag); } void NpConstraint::getForce(PxVec3& linear, PxVec3& angular) const { NP_READ_CHECK(getNpScene()); PX_CHECK_SCENE_API_READ_FORBIDDEN_EXCEPT_COLLIDE(getNpScene(), "PxConstraint::getForce() not allowed while simulation is running (except during PxScene::collide())."); mCore.getForce(linear, angular); } void NpConstraint::markDirty() { #ifdef NEW_DIRTY_SHADERS_CODE if(mCore.getFlags() & PxConstraintFlag::eALWAYS_UPDATE) return; if(!mCore.isDirty()) { NpScene* npScene = getNpScene(); if(npScene) npScene->addDirtyConstraint(this); mCore.setDirty(); } #else mCore.setDirty(); #endif } void NpConstraint::updateConstants(PxsSimulationController& simController) { if(!mCore.isDirty() && !(mCore.getFlags() & PxConstraintFlag::eALWAYS_UPDATE)) return; PX_ASSERT(!isAPIWriteForbidden()); Sc::ConstraintSim* sim = mCore.getSim(); if(sim) { Dy::Constraint& LLC = sim->getLowLevelConstraint(); PxMemCopy(LLC.constantBlock, mCore.getPxConnector()->prepareData(), LLC.constantBlockSize); simController.updateJoint(sim->getInteraction()->getEdgeIndex(), &LLC); } mCore.clearDirty(); #if PX_SUPPORT_PVD NpScene* npScene = getNpScene(); //Changed to use the visual scenes update system which respects //the debugger's connection type flag. if(npScene) npScene->getScenePvdClientInternal().updatePvdProperties(this); #endif } void NpConstraint::setBreakForce(PxReal linear, PxReal angular) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxConstraint::setBreakForce() not allowed while simulation is running. Call will be ignored.") mCore.setBreakForce(linear, angular); markDirty(); UPDATE_PVD_PROPERTY } void NpConstraint::getBreakForce(PxReal& linear, PxReal& angular) const { NP_READ_CHECK(getNpScene()); mCore.getBreakForce(linear, angular); } void NpConstraint::setMinResponseThreshold(PxReal threshold) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_AND_RETURN(PxIsFinite(threshold) && threshold>=0, "PxConstraint::setMinResponseThreshold: threshold must be non-negative"); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxConstraint::setMinResponseThreshold() not allowed while simulation is running. Call will be ignored.") mCore.setMinResponseThreshold(threshold); UPDATE_PVD_PROPERTY } PxReal NpConstraint::getMinResponseThreshold() const { NP_READ_CHECK(getNpScene()); return mCore.getMinResponseThreshold(); } bool NpConstraint::isValid() const { NP_READ_CHECK(getNpScene()); const bool isValid0 = mActor0 && mActor0->getConcreteType()!=PxConcreteType::eRIGID_STATIC; const bool isValid1 = mActor1 && mActor1->getConcreteType()!=PxConcreteType::eRIGID_STATIC; return isValid0 || isValid1; } void* NpConstraint::getExternalReference(PxU32& typeID) { NP_READ_CHECK(getNpScene()); return mCore.getPxConnector()->getExternalReference(typeID); } void NpConstraint::comShift(PxRigidActor* actor) { PX_ASSERT(actor == mActor0 || actor == mActor1); PxConstraintConnector* connector = mCore.getPxConnector(); if(actor == mActor0) connector->onComShift(0); if(actor == mActor1) connector->onComShift(1); } void NpConstraint::actorDeleted(PxRigidActor* actor) { // the actor cannot be deleted without also removing it from the scene, // which means that the joint will also have been removed from the scene, // so we can just reset the actor here. PX_ASSERT(actor == mActor0 || actor == mActor1); if(actor == mActor0) mActor0 = NULL; else mActor1 = NULL; } NpScene* NpConstraint::getSceneFromActors() const { return ::getSceneFromActors(mActor0, mActor1); }
14,240
C++
31.292517
218
0.744031
NVIDIA-Omniverse/PhysX/physx/source/physx/src/NpShape.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef NP_SHAPE_H #define NP_SHAPE_H #include "common/PxMetaData.h" #include "PxShape.h" #include "NpBase.h" #include "ScShapeCore.h" #include "NpPhysics.h" #include "CmPtrTable.h" namespace physx { class NpScene; class NpShape : public PxShape, public NpBase { public: // PX_SERIALIZATION NpShape(PxBaseFlags baseFlags); void preExportDataReset(); virtual void exportExtraData(PxSerializationContext& context); void importExtraData(PxDeserializationContext& context); virtual void requiresObjects(PxProcessPxBaseCallback& c); void resolveReferences(PxDeserializationContext& context); static NpShape* createObject(PxU8*& address, PxDeserializationContext& context); static void getBinaryMetaData(PxOutputStream& stream); //~PX_SERIALIZATION NpShape(const PxGeometry& geometry, PxShapeFlags shapeFlags, const PxU16* materialIndices, PxU16 materialCount, bool isExclusive, PxShapeCoreFlag::Enum flag = PxShapeCoreFlag::Enum(0)); virtual ~NpShape(); // PxRefCounted virtual PxU32 getReferenceCount() const PX_OVERRIDE; virtual void acquireReference() PX_OVERRIDE; //~PxRefCounted // PxShape virtual void release() PX_OVERRIDE; //!< call to release from actor virtual void setGeometry(const PxGeometry&) PX_OVERRIDE; virtual const PxGeometry& getGeometry() const PX_OVERRIDE; virtual PxRigidActor* getActor() const PX_OVERRIDE; virtual void setLocalPose(const PxTransform& pose) PX_OVERRIDE; virtual PxTransform getLocalPose() const PX_OVERRIDE; virtual void setSimulationFilterData(const PxFilterData& data) PX_OVERRIDE; virtual PxFilterData getSimulationFilterData() const PX_OVERRIDE; virtual void setQueryFilterData(const PxFilterData& data) PX_OVERRIDE; virtual PxFilterData getQueryFilterData() const PX_OVERRIDE; virtual void setMaterials(PxMaterial*const* materials, PxU16 materialCount) PX_OVERRIDE; virtual void setSoftBodyMaterials(PxFEMSoftBodyMaterial*const* materials, PxU16 materialCount) PX_OVERRIDE; virtual void setClothMaterials(PxFEMClothMaterial*const* materials, PxU16 materialCount) PX_OVERRIDE; virtual PxU16 getNbMaterials() const PX_OVERRIDE; virtual PxU32 getMaterials(PxMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const PX_OVERRIDE; virtual PxU32 getSoftBodyMaterials(PxFEMSoftBodyMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex = 0) const PX_OVERRIDE; virtual PxU32 getClothMaterials(PxFEMClothMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex = 0) const PX_OVERRIDE; virtual PxBaseMaterial* getMaterialFromInternalFaceIndex(PxU32 faceIndex) const PX_OVERRIDE; virtual void setContactOffset(PxReal) PX_OVERRIDE; virtual PxReal getContactOffset() const PX_OVERRIDE; virtual void setRestOffset(PxReal) PX_OVERRIDE; virtual PxReal getRestOffset() const PX_OVERRIDE; virtual void setDensityForFluid(PxReal) PX_OVERRIDE; virtual PxReal getDensityForFluid() const PX_OVERRIDE; virtual void setTorsionalPatchRadius(PxReal) PX_OVERRIDE; virtual PxReal getTorsionalPatchRadius() const PX_OVERRIDE; virtual void setMinTorsionalPatchRadius(PxReal) PX_OVERRIDE; virtual PxReal getMinTorsionalPatchRadius() const PX_OVERRIDE; virtual PxU32 getInternalShapeIndex() const PX_OVERRIDE; virtual void setFlag(PxShapeFlag::Enum flag, bool value) PX_OVERRIDE; virtual void setFlags(PxShapeFlags inFlags) PX_OVERRIDE; virtual PxShapeFlags getFlags() const PX_OVERRIDE; virtual bool isExclusive() const PX_OVERRIDE; virtual void setName(const char* debugName) PX_OVERRIDE; virtual const char* getName() const PX_OVERRIDE; //~PxShape // Ref counting for shapes works like this: // * for exclusive shapes the actor has a counted reference // * for shared shapes, each actor has a counted reference, and the user has a counted reference // * for either kind, each instance of the shape in a scene (i.e. each shapeSim) causes the reference count to be incremented by 1. // Because these semantics aren't clear to users, this reference count should not be exposed in the API // PxBase virtual void onRefCountZero() PX_OVERRIDE; //~PxBase PX_FORCE_INLINE PxShapeFlags getFlagsFast() const { return mCore.getFlags(); } PX_FORCE_INLINE const PxTransform& getLocalPoseFast() const { return mCore.getShape2Actor(); } PX_FORCE_INLINE PxGeometryType::Enum getGeometryTypeFast() const { return mCore.getGeometryType(); } PX_FORCE_INLINE const PxFilterData& getQueryFilterDataFast() const { return mQueryFilterData; } PX_FORCE_INLINE PxU32 getActorCount() const { return mFreeSlot; } PX_FORCE_INLINE bool isExclusiveFast() const { return mCore.getCore().mShapeCoreFlags.isSet(PxShapeCoreFlag::eIS_EXCLUSIVE); } PX_FORCE_INLINE const Sc::ShapeCore& getCore() const { return mCore; } PX_FORCE_INLINE Sc::ShapeCore& getCore() { return mCore; } static PX_FORCE_INLINE size_t getCoreOffset() { return PX_OFFSET_OF_RT(NpShape, mCore); } // PT: TODO: this one only used internally and by NpFactory template <typename PxMaterialType, typename NpMaterialType> PX_INLINE PxMaterialType* getMaterial(PxU32 index) const { return scGetMaterial<NpMaterialType>(index); } PX_FORCE_INLINE void setSceneIfExclusive(NpScene* s) { if(isExclusiveFast()) setNpScene(s); } void releaseInternal(); // PT: it's "internal" but called by the NpFactory #if PX_CHECKED template <typename PxMaterialType> static bool checkMaterialSetup(const PxGeometry& geom, const char* errorMsgPrefix, PxMaterialType*const* materials, PxU16 materialCount); #endif void onActorAttach(PxActor& actor); void onActorDetach(); void incActorCount(); void decActorCount(); //Always returns 0xffffffff for shared shapes. PX_FORCE_INLINE PxU32 getShapeManagerArrayIndex(const Cm::PtrTable& shapes) const { if(isExclusiveFast()) { PX_ASSERT(isExclusiveFast() || NP_UNUSED_BASE_INDEX == getBaseIndex()); PX_ASSERT(!isExclusiveFast() || NP_UNUSED_BASE_INDEX != getBaseIndex()); const PxU32 index = getBaseIndex(); return index!=NP_UNUSED_BASE_INDEX ? index : 0xffffffff; } else return shapes.find(this); } PX_FORCE_INLINE bool checkShapeManagerArrayIndex(const Cm::PtrTable& shapes) const { return ((!isExclusiveFast() && NP_UNUSED_BASE_INDEX==getBaseIndex()) || ((getBaseIndex() < shapes.getCount()) && (shapes.getPtrs()[getBaseIndex()] == this))); } PX_FORCE_INLINE void setShapeManagerArrayIndex(const PxU32 id) { setBaseIndex(isExclusiveFast() ? id : NP_UNUSED_BASE_INDEX); } PX_FORCE_INLINE void clearShapeManagerArrayIndex() { setBaseIndex(NP_UNUSED_BASE_INDEX); } private: PxActor* mExclusiveShapeActor; Sc::ShapeCore mCore; PxFilterData mQueryFilterData; // Query filter data PT: TODO: consider moving this to SQ structures private: void notifyActorAndUpdatePVD(Sc::ShapeChangeNotifyFlags notifyFlags); void notifyActorAndUpdatePVD(const PxShapeFlags oldShapeFlags); // PT: for shape flags change void incMeshRefCount(); void decMeshRefCount(); PxRefCounted* getMeshRefCountable(); bool isWritable(); void updateSQ(const char* errorMessage); template <typename PxMaterialType, typename NpMaterialType> bool setMaterialsHelper(PxMaterialType* const* materials, PxU16 materialCount); void setFlagsInternal(PxShapeFlags inFlags); Sc::RigidCore& getScRigidObjectExclusive() const; PX_FORCE_INLINE Sc::RigidCore* getScRigidObjectSLOW() { return NpShape::getActor() ? &getScRigidObjectExclusive() : NULL; } PX_INLINE PxU16 scGetNbMaterials() const { return mCore.getNbMaterialIndices(); } template <typename Material> PX_INLINE Material* scGetMaterial(PxU32 index) const { PX_ASSERT(index < scGetNbMaterials()); NpMaterialManager<Material>& matManager = NpMaterialAccessor<Material>::getMaterialManager(NpPhysics::getInstance()); // PT: TODO: revisit this indirection const PxU16 matTableIndex = mCore.getMaterialIndices()[index]; return matManager.getMaterial(matTableIndex); } // PT: TODO: this one only used internally template <typename PxMaterialType, typename NpMaterialType> PX_INLINE PxU32 scGetMaterials(PxMaterialType** buffer, PxU32 bufferSize, PxU32 startIndex=0) const { const PxU16* materialIndices; PxU32 matCount; NpMaterialManager<NpMaterialType>& matManager = NpMaterialAccessor<NpMaterialType>::getMaterialManager(NpPhysics::getInstance()); materialIndices = mCore.getMaterialIndices(); matCount = mCore.getNbMaterialIndices(); // PT: this is copied from Cm::getArrayOfPointers(). We cannot use the Cm function here // because of the extra indirection needed to access the materials. PxU32 size = matCount; const PxU32 remainder = PxU32(PxMax<PxI32>(PxI32(size - startIndex), 0)); const PxU32 writeCount = PxMin(remainder, bufferSize); materialIndices += startIndex; for(PxU32 i=0;i<writeCount;i++) buffer[i] = matManager.getMaterial(materialIndices[i]); return writeCount; } template<typename PxMaterialType, typename NpMaterialType> void setMaterialsInternal(PxMaterialType* const * materials, PxU16 materialCount); }; #if PX_CHECKED template <typename PxMaterialType> bool NpShape::checkMaterialSetup(const PxGeometry& geom, const char* errorMsgPrefix, PxMaterialType*const* materials, PxU16 materialCount) { for(PxU32 i=0; i<materialCount; ++i) { if(!materials[i]) { PxGetFoundation().error(PxErrorCode::eINVALID_PARAMETER, PX_FL, "material pointer %d is NULL!", i); return false; } } if(materialCount > 1) { const PxGeometryType::Enum type = geom.getType(); // verify we provide all materials required if(type == PxGeometryType::eTRIANGLEMESH) { const PxTriangleMeshGeometry& meshGeom = static_cast<const PxTriangleMeshGeometry&>(geom); const PxTriangleMesh& mesh = *meshGeom.triangleMesh; // do not allow SDF multi-material tri-meshes: if(mesh.getSDF()) { PxGetFoundation().error(PxErrorCode::eINVALID_PARAMETER, PX_FL, "%s: multiple materials defined for an SDF triangle-mesh geometry!", errorMsgPrefix); return false; } const Gu::TriangleMesh& tmesh = static_cast<const Gu::TriangleMesh&>(mesh); if(tmesh.hasPerTriangleMaterials()) { const PxU32 nbTris = tmesh.getNbTrianglesFast(); for(PxU32 i=0; i<nbTris; i++) { const PxMaterialTableIndex meshMaterialIndex = mesh.getTriangleMaterialIndex(i); if(meshMaterialIndex >= materialCount) { PxGetFoundation().error(PxErrorCode::eINVALID_PARAMETER, PX_FL, "%s: PxTriangleMesh material indices reference more materials than provided!", errorMsgPrefix); break; } } } else { PxGetFoundation().error(PxErrorCode::eINVALID_PARAMETER, PX_FL, "%s: multiple materials defined for a triangle-mesh that does not have per-triangle materials!", errorMsgPrefix); } } else if(type == PxGeometryType::eTETRAHEDRONMESH) { const PxTetrahedronMeshGeometry& meshGeom = static_cast<const PxTetrahedronMeshGeometry&>(geom); const PxTetrahedronMesh& mesh = *meshGeom.tetrahedronMesh; PX_UNUSED(mesh); //Need to fill in material /*if (mesh.getTriangleMaterialIndex(0) != 0xffff) { for (PxU32 i = 0; i < mesh.getNbTriangles(); i++) { const PxMaterialTableIndex meshMaterialIndex = mesh.getTriangleMaterialIndex(i); if (meshMaterialIndex >= materialCount) { PxGetFoundation().error(PxErrorCode::eINVALID_PARAMETER, PX_FL, "%s: PxTriangleMesh material indices reference more materials than provided!", errorMsgPrefix); break; } } }*/ } else if(type == PxGeometryType::eHEIGHTFIELD) { const PxHeightFieldGeometry& meshGeom = static_cast<const PxHeightFieldGeometry&>(geom); const PxHeightField& mesh = *meshGeom.heightField; if (mesh.getTriangleMaterialIndex(0) != 0xffff) { const PxU32 nbTris = mesh.getNbColumns()*mesh.getNbRows() * 2; for (PxU32 i = 0; i < nbTris; i++) { const PxMaterialTableIndex meshMaterialIndex = mesh.getTriangleMaterialIndex(i); if (meshMaterialIndex != PxHeightFieldMaterial::eHOLE && meshMaterialIndex >= materialCount) { PxGetFoundation().error(PxErrorCode::eINVALID_PARAMETER, PX_FL, "%s: PxHeightField material indices reference more materials than provided!", errorMsgPrefix); break; } } } else { PxGetFoundation().error(PxErrorCode::eINVALID_PARAMETER, PX_FL, "%s: multiple materials defined for a heightfield that does not have per-triangle materials!", errorMsgPrefix); } } else { // check that simple shapes don't get assigned multiple materials PxGetFoundation().error(PxErrorCode::eINVALID_PARAMETER, PX_FL, "%s: multiple materials defined for single material geometry!", errorMsgPrefix); return false; } } return true; } #endif } #endif
15,708
C
43.126404
145
0.695187
NVIDIA-Omniverse/PhysX/physx/source/physx/src/NpDebugViz.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #include "NpDebugViz.h" // PT: moving "all" debug viz code to the same file to improve cache locality when debug drawing things, // share more code, and make sure all actors do thing consistently. #include "NpScene.h" #include "NpCheck.h" #include "common/PxProfileZone.h" using namespace physx; #if PX_ENABLE_DEBUG_VISUALIZATION #include "NpShapeManager.h" #include "NpRigidStatic.h" #include "NpRigidDynamic.h" #include "NpArticulationReducedCoordinate.h" #if PX_SUPPORT_GPU_PHYSX #include "NpSoftBody.h" #include "NpParticleSystem.h" #include "NpHairSystem.h" #endif #include "foundation/PxVecMath.h" #include "geometry/PxMeshQuery.h" #include "GuHeightFieldUtil.h" #include "GuConvexEdgeFlags.h" #include "GuMidphaseInterface.h" #include "GuEdgeList.h" #include "GuBounds.h" #include "BpBroadPhase.h" #include "BpAABBManager.h" using namespace physx::aos; using namespace Gu; using namespace Cm; ///// static const PxU32 gCollisionShapeColor = PxU32(PxDebugColor::eARGB_MAGENTA); static PX_FORCE_INLINE Vec4V multiply3x3V(const Vec4V p, const PxMat34& mat) { Vec4V ResV = V4Scale(V4LoadU(&mat.m.column0.x), V4GetX(p)); ResV = V4Add(ResV, V4Scale(V4LoadU(&mat.m.column1.x), V4GetY(p))); ResV = V4Add(ResV, V4Scale(V4LoadU(&mat.m.column2.x), V4GetZ(p))); return ResV; } // PT: beware, needs padding at the end of dst/src static PX_FORCE_INLINE void transformV(PxVec3* dst, const PxVec3* src, const Vec4V p, const PxMat34& mat) { const Vec4V vertexV = V4LoadU(&src->x); const Vec4V transformedV = V4Add(multiply3x3V(vertexV, mat), p); V4StoreU(transformedV, &dst->x); } static void visualizeSphere(const PxSphereGeometry& geometry, PxRenderOutput& out, const PxTransform& absPose) { out << gCollisionShapeColor; // PT: no need to output this for each segment! out << absPose; renderOutputDebugCircle(out, 100, geometry.radius); PxMat44 rotPose(absPose); PxSwap(rotPose.column1, rotPose.column2); rotPose.column1 = -rotPose.column1; out << rotPose; renderOutputDebugCircle(out, 100, geometry.radius); PxSwap(rotPose.column0, rotPose.column2); rotPose.column0 = -rotPose.column0; out << rotPose; renderOutputDebugCircle(out, 100, geometry.radius); } static void visualizePlane(const PxPlaneGeometry& /*geometry*/, PxRenderOutput& out, const PxTransform& absPose) { PxMat44 rotPose(absPose); PxSwap(rotPose.column1, rotPose.column2); rotPose.column1 = -rotPose.column1; PxSwap(rotPose.column0, rotPose.column2); rotPose.column0 = -rotPose.column0; out << rotPose << gCollisionShapeColor; // PT: no need to output this for each segment! for(PxReal radius = 2.0f; radius < 20.0f ; radius += 2.0f) renderOutputDebugCircle(out, 100, radius*radius); } static void visualizeCapsule(const PxCapsuleGeometry& geometry, PxRenderOutput& out, const PxTransform& absPose) { out << gCollisionShapeColor; out.outputCapsule(geometry.radius, geometry.halfHeight, absPose); } static void visualizeBox(const PxBoxGeometry& geometry, PxRenderOutput& out, const PxTransform& absPose) { out << gCollisionShapeColor; out << absPose; renderOutputDebugBox(out, PxBounds3(-geometry.halfExtents, geometry.halfExtents)); } static void visualizeConvexMesh(const PxConvexMeshGeometry& geometry, PxRenderOutput& out, const PxTransform& absPose) { const ConvexMesh* convexMesh = static_cast<const ConvexMesh*>(geometry.convexMesh); const ConvexHullData& hullData = convexMesh->getHull(); const PxVec3* vertices = hullData.getHullVertices(); const PxU8* indexBuffer = hullData.getVertexData8(); const PxU32 nbPolygons = convexMesh->getNbPolygonsFast(); const PxMat33Padded m33(absPose.q); const PxMat44 m44(m33 * toMat33(geometry.scale), absPose.p); out << m44 << gCollisionShapeColor; // PT: no need to output this for each segment! for(PxU32 i=0; i<nbPolygons; i++) { const PxU32 pnbVertices = hullData.mPolygons[i].mNbVerts; PxVec3 begin = m44.transform(vertices[indexBuffer[0]]); // PT: transform it only once before the loop starts for(PxU32 j=1; j<pnbVertices; j++) { const PxVec3 end = m44.transform(vertices[indexBuffer[j]]); out.outputSegment(begin, end); begin = end; } out.outputSegment(begin, m44.transform(vertices[indexBuffer[0]])); indexBuffer += pnbVertices; } } static void getTriangle(PxU32 i, PxVec3* wp, const PxVec3* vertices, const void* indices, bool has16BitIndices) { PxU32 ref0, ref1, ref2; getVertexRefs(i, ref0, ref1, ref2, indices, has16BitIndices); wp[0] = vertices[ref0]; wp[1] = vertices[ref1]; wp[2] = vertices[ref2]; } // PT: beware with wp, needs padding static void getWorldTriangle(PxU32 i, PxVec3* wp, const PxVec3* vertices, const void* indices, const PxMat34& absPose, bool has16BitIndices) { // PxVec3 localVerts[3]; // getTriangle(i, localVerts, vertices, indices, has16BitIndices); // wp[0] = absPose.transform(localVerts[0]); // wp[1] = absPose.transform(localVerts[1]); // wp[2] = absPose.transform(localVerts[2]); PxU32 ref0, ref1, ref2; getVertexRefs(i, ref0, ref1, ref2, indices, has16BitIndices); const Vec4V posV = Vec4V_From_Vec3V(V3LoadU(&absPose.p.x)); transformV(&wp[0], &vertices[ref0], posV, absPose); transformV(&wp[1], &vertices[ref1], posV, absPose); transformV(&wp[2], &vertices[ref2], posV, absPose); } static void visualizeActiveEdges(PxRenderOutput& out, const TriangleMesh& mesh, PxU32 nbTriangles, const PxU32* results, const PxMat34& absPose) { const PxU8* extraTrigData = mesh.getExtraTrigData(); const PxVec3* vertices = mesh.getVerticesFast(); const void* indices = mesh.getTrianglesFast(); out << PxU32(PxDebugColor::eARGB_YELLOW); // PT: no need to output this for each segment! const bool has16Bit = mesh.has16BitIndices(); for(PxU32 i=0; i<nbTriangles; i++) { const PxU32 index = results ? results[i] : i; PxVec3 wp[3+1]; getWorldTriangle(index, wp, vertices, indices, absPose, has16Bit); const PxU32 flags = getConvexEdgeFlags(extraTrigData, index); if(flags & ETD_CONVEX_EDGE_01) out.outputSegment(wp[0], wp[1]); if(flags & ETD_CONVEX_EDGE_12) out.outputSegment(wp[1], wp[2]); if(flags & ETD_CONVEX_EDGE_20) out.outputSegment(wp[0], wp[2]); } } static void visualizeFaceNormals( PxReal fscale, PxRenderOutput& out, PxU32 nbTriangles, const PxVec3* vertices, const void* indices, bool has16Bit, const PxU32* results, const PxMat34& absPose, const PxMat44& midt) { out << midt << PxU32(PxDebugColor::eARGB_DARKRED); // PT: no need to output this for each segment! const float coeff = 1.0f / 3.0f; PxDebugLine* segments = out.reserveSegments(nbTriangles); for(PxU32 i=0; i<nbTriangles; i++) { const PxU32 index = results ? results[i] : i; PxVec3 wp[3+1]; getWorldTriangle(index, wp, vertices, indices, absPose, has16Bit); const PxVec3 center = (wp[0] + wp[1] + wp[2]) * coeff; PxVec3 normal = (wp[0] - wp[1]).cross(wp[0] - wp[2]); PX_ASSERT(!normal.isZero()); normal = normal.getNormalized(); segments->pos0 = center; segments->pos1 = center + normal * fscale; segments->color0 = segments->color1 = PxU32(PxDebugColor::eARGB_DARKRED); segments++; } } static PxU32 MakeSolidColor(PxU32 alpha, PxU32 red, PxU32 green, PxU32 blue) { return (alpha<<24) | (red << 16) | (green << 8) | blue; } static void decodeTriple(PxU32 id, PxU32& x, PxU32& y, PxU32& z) { x = id & 0x000003FF; id = id >> 10; y = id & 0x000003FF; id = id >> 10; z = id & 0x000003FF; } PX_FORCE_INLINE PxU32 idx(PxU32 x, PxU32 y, PxU32 z, PxU32 width, PxU32 height) { return z * (width) * (height) + y * width + x; } PX_FORCE_INLINE PxReal decode(PxU8* data, PxU32 bytesPerSparsePixel, PxReal subgridsMinSdfValue, PxReal subgridsMaxSdfValue) { switch (bytesPerSparsePixel) { case 1: return PxReal(data[0]) * (1.0f / 255.0f) * (subgridsMaxSdfValue - subgridsMinSdfValue) + subgridsMinSdfValue; case 2: { PxU16* ptr = reinterpret_cast<PxU16*>(data); return PxReal(ptr[0]) * (1.0f / 65535.0f) * (subgridsMaxSdfValue - subgridsMinSdfValue) + subgridsMinSdfValue; } case 4: //If 4 bytes per subgrid pixel are available, then normal floats are used. No need to //de-normalize integer values since the floats already contain real distance values PxReal* ptr = reinterpret_cast<PxReal*>(data); return ptr[0]; } return 0; } PX_FORCE_INLINE PxU32 makeColor(PxReal v, PxReal invRange0, PxReal invRange1) { PxVec3 midColor(0.f, 0, 255.f); PxVec3 lowColor(255.f, 0, 0); PxVec3 outColor(0, 255.f, 0.f); PxU32 color; if (v > 0.f) { PxReal scale = PxPow(v * invRange0, 0.25f); PxVec3 blendColor = midColor + (outColor - midColor) * scale; color = MakeSolidColor( 0xff000000, PxU32(blendColor.x), PxU32(blendColor.y), PxU32(blendColor.z) ); } else { PxReal scale = PxPow(v * invRange1, 0.25f); PxVec3 blendColor = midColor + (lowColor - midColor) * scale; color = MakeSolidColor( 0xff000000, PxU32(blendColor.x), PxU32(blendColor.y), PxU32(blendColor.z) ); } return color; } //Returns true if the number of samples chosen to visualize was reduced (to speed up rendering) compared to the total number of sdf samples available static bool visualizeSDF(PxRenderOutput& out, const Gu::SDF& sdf, const PxMat34& absPose, bool limitNumberOfVisualizedSamples = false) { bool dataReductionActive = false; PxU32 upperByteLimit = 512u * 512u * 512u * sizeof(PxDebugPoint); //2GB - sizeof(PxDebugPoint)=16bytes bool repeat = true; PxReal low = 0.0f, high = 0.0f; PxU32 count = 0; PxU32 upperLimit = limitNumberOfVisualizedSamples ? 128 : 4096; PxReal sdfSpacing = 0.0f; PxU32 strideX = 0; PxU32 strideY = 0; PxU32 strideZ = 0; PxU32 nbX = 0, nbY = 0, nbZ = 0; PxU32 subgridSize = 0; PxU32 subgridStride = 1; while (repeat) { repeat = false; PxU32 nbTargetSamplesPerAxis = upperLimit; subgridStride = 1; if (sdf.mSubgridSize == 0) { subgridSize = 1; sdfSpacing = sdf.mSpacing; nbX = sdf.mDims.x; nbY = sdf.mDims.y; nbZ = sdf.mDims.z; } else { subgridSize = sdf.mSubgridSize; sdfSpacing = subgridSize * sdf.mSpacing; nbX = sdf.mDims.x / subgridSize + 1; nbY = sdf.mDims.y / subgridSize + 1; nbZ = sdf.mDims.z / subgridSize + 1; //Limit the max number of visualized sparse grid samples if (limitNumberOfVisualizedSamples && subgridSize > 4) { subgridStride = (subgridSize + 3) / 4; dataReductionActive = true; } } //KS - a bit arbitrary, but let's limit how many points we churn out strideX = (nbX + nbTargetSamplesPerAxis - 1) / nbTargetSamplesPerAxis; strideY = (nbY + nbTargetSamplesPerAxis - 1) / nbTargetSamplesPerAxis; strideZ = (nbZ + nbTargetSamplesPerAxis - 1) / nbTargetSamplesPerAxis; if (strideX != 1 || strideY != 1 || strideZ != 1) dataReductionActive = true; low = PX_MAX_F32; high = -PX_MAX_F32; count = 0; for (PxU32 k = 0; k < nbZ; k += strideZ) { for (PxU32 j = 0; j < nbY; j += strideY) { for (PxU32 i = 0; i < nbX; i += strideX) { PxReal v = sdf.mSdf[k*nbX*nbY + j * nbX + i]; count++; low = PxMin(low, v); high = PxMax(high, v); if (sdf.mSubgridSize > 0 && k < nbZ - 1 && j < nbY - 1 && i < nbX - 1) { PxU32 startId = sdf.mSubgridStartSlots[k*(nbX - 1)*(nbY - 1) + j * (nbX - 1) + i]; if (startId != 0xFFFFFFFFu) { PxU32 xBase, yBase, zBase; decodeTriple(startId, xBase, yBase, zBase); PX_ASSERT(xBase < sdf.mSdfSubgrids3DTexBlockDim.x); PX_ASSERT(yBase < sdf.mSdfSubgrids3DTexBlockDim.y); PX_ASSERT(zBase < sdf.mSdfSubgrids3DTexBlockDim.z); PxU32 localCount = subgridSize / subgridStride + 1; count += localCount * localCount * localCount; } } if (count * sizeof(PxDebugPoint) > upperByteLimit) break; } if (count * sizeof(PxDebugPoint) > upperByteLimit) break; } if (count * sizeof(PxDebugPoint) > upperByteLimit) break; } if (count * sizeof(PxDebugPoint) > upperByteLimit) { upperLimit /= 2; repeat = true; if (upperLimit == 1) return true; } } const PxReal range0 = high; const PxReal range1 = low; const PxReal invRange0 = 1.f / range0; const PxReal invRange1 = 1.f / range1; PxDebugPoint* points = out.reservePoints(count); PxVec3 localPos = sdf.mMeshLower; PxReal spacingX = sdfSpacing * strideX; PxReal spacingY = sdfSpacing * strideY; PxReal spacingZ = sdfSpacing * strideZ; for (PxU32 k = 0; k < nbZ; k += strideZ, localPos.z += spacingZ) { localPos.y = sdf.mMeshLower.y; for (PxU32 j = 0; j < nbY; j += strideY, localPos.y += spacingY) { localPos.x = sdf.mMeshLower.x; for (PxU32 i = 0; i < nbX; i += strideX, localPos.x += spacingX) { PxU32 color; if (sdf.mSubgridSize > 0 && k < nbZ - 1 && j < nbY - 1 && i < nbX - 1) { PxU32 startId = sdf.mSubgridStartSlots[k * (nbX - 1) * (nbY - 1) + j * (nbX - 1) + i]; if (startId != 0xFFFFFFFFu) { PxU32 xBase, yBase, zBase; decodeTriple(startId, xBase, yBase, zBase); xBase *= (subgridSize + 1); yBase *= (subgridSize + 1); zBase *= (subgridSize + 1); //Visualize the subgrid for (PxU32 z = 0; z <= subgridSize; z += subgridStride) { for (PxU32 y = 0; y <= subgridSize; y += subgridStride) { for (PxU32 x = 0; x <= subgridSize; x += subgridStride) { PxReal value = decode(&sdf.mSubgridSdf[sdf.mBytesPerSparsePixel * idx(xBase + x, yBase + y, zBase + z, sdf.mSdfSubgrids3DTexBlockDim.x * (subgridSize + 1), sdf.mSdfSubgrids3DTexBlockDim.y * (subgridSize + 1))], sdf.mBytesPerSparsePixel, sdf.mSubgridsMinSdfValue, sdf.mSubgridsMaxSdfValue); color = makeColor(value, invRange0, invRange1); PxVec3 subgridLocalPos = localPos + sdf.mSpacing * PxVec3(PxReal(x), PxReal(y), PxReal(z)); *points = PxDebugPoint(absPose.transform(subgridLocalPos), color); points++; } } } } } PxReal v = sdf.mSdf[k*nbX*nbY + j * nbX + i]; color = makeColor(v, invRange0, invRange1); *points = PxDebugPoint(absPose.transform(localPos), color); points++; } } } return dataReductionActive; } static PX_FORCE_INLINE void outputTriangle(PxDebugLine* segments, const PxVec3& v0, const PxVec3& v1, const PxVec3& v2, PxU32 color) { // PT: TODO: use SIMD segments[0] = PxDebugLine(v0, v1, color); segments[1] = PxDebugLine(v1, v2, color); segments[2] = PxDebugLine(v2, v0, color); } static void visualizeTriangleMesh(const PxTriangleMeshGeometry& geometry, PxRenderOutput& out, const PxTransform& pose, const PxBounds3& cullbox, PxReal fscale, bool visualizeShapes, bool visualizeEdges, bool useCullBox, bool visualizeSDFs) { const TriangleMesh* triangleMesh = static_cast<const TriangleMesh*>(geometry.triangleMesh); const PxMat44 midt(PxIdentity); // PT: TODO: why do we compute it that way sometimes? // const PxMat34 vertex2worldSkew = pose * geometry.scale; const PxMat33Padded m33(pose.q); const PxMat34 absPose(m33 * toMat33(geometry.scale), pose.p); PxU32 nbTriangles = triangleMesh->getNbTrianglesFast(); const PxU32 nbVertices = triangleMesh->getNbVerticesFast(); const PxVec3* vertices = triangleMesh->getVerticesFast(); const void* indices = triangleMesh->getTrianglesFast(); const bool has16Bit = triangleMesh->has16BitIndices(); bool drawSDF = visualizeSDFs && triangleMesh->getSDF(); PxU32* results = NULL; if (!drawSDF) { if (useCullBox) { const Box worldBox( (cullbox.maximum + cullbox.minimum)*0.5f, (cullbox.maximum - cullbox.minimum)*0.5f, PxMat33(PxIdentity)); // PT: TODO: use the callback version here to avoid allocating this huge array results = PX_ALLOCATE(PxU32, nbTriangles, "tmp triangle indices"); LimitedResults limitedResults(results, nbTriangles, 0); Midphase::intersectBoxVsMesh(worldBox, *triangleMesh, pose, geometry.scale, &limitedResults); nbTriangles = limitedResults.mNbResults; if (visualizeShapes) { const PxU32 scolor = gCollisionShapeColor; out << midt << scolor; // PT: no need to output this for each segment! // PT: TODO: don't render the same edge multiple times PxDebugLine* segments = out.reserveSegments(nbTriangles * 3); for (PxU32 i = 0; i < nbTriangles; i++) { PxVec3 wp[3 + 1]; getWorldTriangle(results[i], wp, vertices, indices, absPose, has16Bit); outputTriangle(segments, wp[0], wp[1], wp[2], scolor); segments += 3; } } } else { if (visualizeShapes) { const PxU32 scolor = gCollisionShapeColor; out << midt << scolor; // PT: no need to output this for each segment! const Vec4V posV = Vec4V_From_Vec3V(V3LoadU(&absPose.p.x)); PxVec3* transformed = PX_ALLOCATE(PxVec3, (nbVertices + 1), "PxVec3"); // for(PxU32 i=0;i<nbVertices;i++) // transformed[i] = absPose.transform(vertices[i]); for (PxU32 i = 0; i < nbVertices; i++) { //const Vec4V vertexV = V4LoadU(&vertices[i].x); //const Vec4V transformedV = V4Add(multiply3x3V(vertexV, absPose), posV); //V4StoreU(transformedV, &transformed[i].x); transformV(&transformed[i], &vertices[i], posV, absPose); } const Gu::EdgeList* edgeList = triangleMesh->requestEdgeList(); if (edgeList) { PxU32 nbEdges = edgeList->getNbEdges(); PxDebugLine* segments = out.reserveSegments(nbEdges); const Gu::EdgeData* edges = edgeList->getEdges(); while (nbEdges--) { segments->pos0 = transformed[edges->Ref0]; segments->pos1 = transformed[edges->Ref1]; segments->color0 = segments->color1 = scolor; segments++; edges++; } } else { PxDebugLine* segments = out.reserveSegments(nbTriangles * 3); for (PxU32 i = 0; i < nbTriangles; i++) { PxVec3 wp[3]; getTriangle(i, wp, transformed, indices, has16Bit); outputTriangle(segments, wp[0], wp[1], wp[2], scolor); segments += 3; } } PX_FREE(transformed); } } } if(fscale!=0.0f) { if(geometry.scale.hasNegativeDeterminant()) fscale = -fscale; visualizeFaceNormals(fscale, out, nbTriangles, vertices, indices, has16Bit, results, absPose, midt); } if(visualizeEdges) visualizeActiveEdges(out, *triangleMesh, nbTriangles, results, absPose); if (drawSDF) { const Gu::SDF& sdf = triangleMesh->getSdfDataFast(); //We have an SDF, we should debug render it... visualizeSDF(out, sdf, absPose); } PX_FREE(results); } static void visualizeHeightField(const PxHeightFieldGeometry& hfGeometry, PxRenderOutput& out, const PxTransform& absPose, const PxBounds3& cullbox, bool useCullBox) { const HeightField* heightfield = static_cast<const HeightField*>(hfGeometry.heightField); // PT: TODO: the debug viz for HFs is minimal at the moment... const PxU32 scolor = gCollisionShapeColor; const PxMat44 midt = PxMat44(PxIdentity); HeightFieldUtil hfUtil(hfGeometry); const PxU32 nbRows = heightfield->getNbRowsFast(); const PxU32 nbColumns = heightfield->getNbColumnsFast(); const PxU32 nbVerts = nbRows * nbColumns; const PxU32 nbTriangles = 2 * nbVerts; out << midt << scolor; // PT: no need to output the same matrix/color for each triangle if(useCullBox) { const PxTransform pose0((cullbox.maximum + cullbox.minimum)*0.5f); const PxBoxGeometry boxGeometry((cullbox.maximum - cullbox.minimum)*0.5f); PxU32* results = PX_ALLOCATE(PxU32, nbTriangles, "tmp triangle indices"); bool overflow = false; PxU32 nbTouchedTris = PxMeshQuery::findOverlapHeightField(boxGeometry, pose0, hfGeometry, absPose, results, nbTriangles, 0, overflow); PxDebugLine* segments = out.reserveSegments(nbTouchedTris*3); for(PxU32 i=0; i<nbTouchedTris; i++) { const PxU32 index = results[i]; PxTriangle currentTriangle; PxMeshQuery::getTriangle(hfGeometry, absPose, index, currentTriangle); //The check has been done in the findOverlapHeightField //if(heightfield->isValidTriangle(index) && heightfield->getTriangleMaterial(index) != PxHeightFieldMaterial::eHOLE) { outputTriangle(segments, currentTriangle.verts[0], currentTriangle.verts[1], currentTriangle.verts[2], scolor); segments+=3; } } PX_FREE(results); } else { // PT: transform vertices only once PxVec3* tmpVerts = PX_ALLOCATE(PxVec3, nbVerts, "PxVec3"); // PT: TODO: optimize the following line for(PxU32 i=0;i<nbVerts;i++) tmpVerts[i] = absPose.transform(hfUtil.hf2shapep(heightfield->getVertex(i))); for(PxU32 i=0; i<nbTriangles; i++) { if(heightfield->isValidTriangle(i) && heightfield->getTriangleMaterial(i) != PxHeightFieldMaterial::eHOLE) { PxU32 vi0, vi1, vi2; heightfield->getTriangleVertexIndices(i, vi0, vi1, vi2); PxDebugLine* segments = out.reserveSegments(3); outputTriangle(segments, tmpVerts[vi0], tmpVerts[vi1], tmpVerts[vi2], scolor); } } PX_FREE(tmpVerts); } } static void visualize(const PxGeometry& geometry, PxRenderOutput& out, const PxTransform& absPose, const PxBounds3& cullbox, const PxReal fscale, bool visualizeShapes, bool visualizeEdges, bool useCullBox, bool visualizeSDFs) { // triangle meshes can render active edges or face normals, but for other types we can just early out if there are no collision shapes if(!visualizeShapes && geometry.getType() != PxGeometryType::eTRIANGLEMESH) return; switch(geometry.getType()) { case PxGeometryType::eSPHERE: visualizeSphere(static_cast<const PxSphereGeometry&>(geometry), out, absPose); break; case PxGeometryType::eBOX: visualizeBox(static_cast<const PxBoxGeometry&>(geometry), out, absPose); break; case PxGeometryType::ePLANE: visualizePlane(static_cast<const PxPlaneGeometry&>(geometry), out, absPose); break; case PxGeometryType::eCAPSULE: visualizeCapsule(static_cast<const PxCapsuleGeometry&>(geometry), out, absPose); break; case PxGeometryType::eCONVEXMESH: visualizeConvexMesh(static_cast<const PxConvexMeshGeometry&>(geometry), out, absPose); break; case PxGeometryType::eTRIANGLEMESH: visualizeTriangleMesh(static_cast<const PxTriangleMeshGeometry&>(geometry), out, absPose, cullbox, fscale, visualizeShapes, visualizeEdges, useCullBox, visualizeSDFs); break; case PxGeometryType::eHEIGHTFIELD: visualizeHeightField(static_cast<const PxHeightFieldGeometry&>(geometry), out, absPose, cullbox, useCullBox); break; case PxGeometryType::eTETRAHEDRONMESH: case PxGeometryType::ePARTICLESYSTEM: // A.B. missing visualization code break; case PxGeometryType::eHAIRSYSTEM: break; case PxGeometryType::eCUSTOM: PX_ASSERT(static_cast<const PxCustomGeometry&>(geometry).isValid()); static_cast<const PxCustomGeometry&>(geometry).callbacks->visualize(geometry, out, absPose, cullbox); break; case PxGeometryType::eINVALID: break; case PxGeometryType::eGEOMETRY_COUNT: break; } } void NpShapeManager::visualize(PxRenderOutput& out, NpScene& scene, const PxRigidActor& actor, float scale) const { PX_ASSERT(scale!=0.0f); // Else we shouldn't have been called const Sc::Scene& scScene = scene.getScScene(); const PxU32 nbShapes = getNbShapes(); NpShape*const* PX_RESTRICT shapes = getShapes(); const bool visualizeCompounds = (nbShapes>1) && scScene.getVisualizationParameter(PxVisualizationParameter::eCOLLISION_COMPOUNDS)!=0.0f; // PT: moved all these out of the loop, no need to grab them once per shape const PxBounds3& cullbox = scScene.getVisualizationCullingBox(); const bool visualizeAABBs = scScene.getVisualizationParameter(PxVisualizationParameter::eCOLLISION_AABBS)!=0.0f; const bool visualizeShapes = scScene.getVisualizationParameter(PxVisualizationParameter::eCOLLISION_SHAPES)!=0.0f; const bool visualizeEdges = scScene.getVisualizationParameter(PxVisualizationParameter::eCOLLISION_EDGES)!=0.0f; const bool visualizeSDFs = scScene.getVisualizationParameter(PxVisualizationParameter::eSDF)!=0.0f; const float fNormals = scScene.getVisualizationParameter(PxVisualizationParameter::eCOLLISION_FNORMALS); const bool visualizeFNormals = fNormals!=0.0f; const bool visualizeCollision = visualizeShapes || visualizeFNormals || visualizeEdges || visualizeSDFs; const bool useCullBox = !cullbox.isEmpty(); const bool needsShapeBounds0 = visualizeCompounds || (visualizeCollision && useCullBox); const PxReal collisionAxes = scale * scScene.getVisualizationParameter(PxVisualizationParameter::eCOLLISION_AXES); const PxReal fscale = scale * fNormals; const PxTransform32 actorPose(actor.getGlobalPose()); PxBounds3 compoundBounds(PxBounds3::empty()); for(PxU32 i=0;i<nbShapes;i++) { const NpShape& npShape = *shapes[i]; PxTransform32 absPose; aos::transformMultiply<true, true>(absPose, actorPose, npShape.getCore().getShape2Actor()); const PxGeometry& geom = npShape.getCore().getGeometry(); const bool shapeDebugVizEnabled = npShape.getCore().getFlags() & PxShapeFlag::eVISUALIZATION; const bool needsShapeBounds = needsShapeBounds0 || (visualizeAABBs && shapeDebugVizEnabled); const PxBounds3 currentShapeBounds = needsShapeBounds ? computeBounds(geom, absPose) : PxBounds3::empty(); if(shapeDebugVizEnabled) { if(visualizeAABBs) { out << PxU32(PxDebugColor::eARGB_YELLOW) << PxMat44(PxIdentity); renderOutputDebugBox(out, currentShapeBounds); } if(collisionAxes != 0.0f) { out << PxMat44(absPose); Cm::renderOutputDebugBasis(out, PxDebugBasis(PxVec3(collisionAxes), 0xcf0000, 0x00cf00, 0x0000cf)); } if(visualizeCollision) { if(!useCullBox || cullbox.intersects(currentShapeBounds)) ::visualize(geom, out, absPose, cullbox, fscale, visualizeShapes, visualizeEdges, useCullBox, visualizeSDFs); } } if(visualizeCompounds) compoundBounds.include(currentShapeBounds); } if(visualizeCompounds && !compoundBounds.isEmpty()) { out << gCollisionShapeColor << PxMat44(PxIdentity); renderOutputDebugBox(out, compoundBounds); } } ///// static PX_FORCE_INLINE void visualizeActor(PxRenderOutput& out, const Sc::Scene& scScene, const PxRigidActor& actor, float scale) { //visualize actor frames const PxReal actorAxes = scale * scScene.getVisualizationParameter(PxVisualizationParameter::eACTOR_AXES); if(actorAxes != 0.0f) { out << actor.getGlobalPose(); Cm::renderOutputDebugBasis(out, PxDebugBasis(PxVec3(actorAxes))); } } void physx::visualizeRigidBody(PxRenderOutput& out, NpScene& scene, const PxRigidActor& actor, const Sc::BodyCore& core, float scale) { PX_ASSERT(scale!=0.0f); // Else we shouldn't have been called PX_ASSERT(core.getActorFlags() & PxActorFlag::eVISUALIZATION); // Else we shouldn't have been called const Sc::Scene& scScene = scene.getScScene(); visualizeActor(out, scScene, actor, scale); const PxTransform& body2World = core.getBody2World(); const PxReal bodyAxes = scale * scScene.getVisualizationParameter(PxVisualizationParameter::eBODY_AXES); if(bodyAxes != 0.0f) { out << body2World; Cm::renderOutputDebugBasis(out, PxDebugBasis(PxVec3(bodyAxes))); } const PxReal linVelocity = scale * scScene.getVisualizationParameter(PxVisualizationParameter::eBODY_LIN_VELOCITY); if(linVelocity != 0.0f) { out << 0xffffff << PxMat44(PxIdentity); Cm::renderOutputDebugArrow(out, PxDebugArrow(body2World.p, core.getLinearVelocity() * linVelocity, 0.2f * linVelocity)); } const PxReal angVelocity = scale * scScene.getVisualizationParameter(PxVisualizationParameter::eBODY_ANG_VELOCITY); if(angVelocity != 0.0f) { out << 0x000000 << PxMat44(PxIdentity); Cm::renderOutputDebugArrow(out, PxDebugArrow(body2World.p, core.getAngularVelocity() * angVelocity, 0.2f * angVelocity)); } const PxReal massAxes = scale * scScene.getVisualizationParameter(PxVisualizationParameter::eBODY_MASS_AXES); if(massAxes != 0.0f) { const PxReal sleepTime = core.getWakeCounter() / scene.getWakeCounterResetValueInternal(); PxU32 color = PxU32(0xff * (sleepTime>1.0f ? 1.0f : sleepTime)); color = core.isSleeping() ? 0xff0000 : (color<<16 | color<<8 | color); PxVec3 dims = invertDiagInertia(core.getInverseInertia()); dims = getDimsFromBodyInertia(dims, 1.0f / core.getInverseMass()); out << color << core.getBody2World(); const PxVec3 extents = dims * 0.5f; Cm::renderOutputDebugBox(out, PxBounds3(-extents, extents)); } } void NpRigidStatic::visualize(PxRenderOutput& out, NpScene& scene, float scale) const { PX_ASSERT(scale!=0.0f); // Else we shouldn't have been called if(!(mCore.getActorFlags() & PxActorFlag::eVISUALIZATION)) return; NpRigidStaticT::visualize(out, scene, scale); visualizeActor(out, scene.getScScene(), *this, scale); } void NpRigidDynamic::visualize(PxRenderOutput& out, NpScene& scene, float scale) const { PX_ASSERT(scale!=0.0f); // Else we shouldn't have been called if(!(mCore.getActorFlags() & PxActorFlag::eVISUALIZATION)) return; NpRigidDynamicT::visualize(out, scene, scale); } void NpArticulationLink::visualize(PxRenderOutput& out, NpScene& scene, float scale) const { PX_ASSERT(scale!=0.0f); // Else we shouldn't have been called if(!(mCore.getActorFlags() & PxActorFlag::eVISUALIZATION)) return; NpArticulationLinkT::visualize(out, scene, scale); const Sc::Scene& scScene = scene.getScScene(); const PxReal frameScale = scale * scScene.getVisualizationParameter(PxVisualizationParameter::eJOINT_LOCAL_FRAMES); const PxReal limitScale = scale * scScene.getVisualizationParameter(PxVisualizationParameter::eJOINT_LIMITS); if(frameScale != 0.0f || limitScale != 0.0f) { ConstraintImmediateVisualizer viz(frameScale, limitScale, out); visualizeJoint(viz); } } void NpArticulationLink::visualizeJoint(PxConstraintVisualizer& jointViz) const { const NpArticulationLink* parent = getParent(); if(parent) { // PT:: tag: scalar transform*transform PxTransform cA2w = getGlobalPose().transform(mInboundJoint->getChildPose()); // PT:: tag: scalar transform*transform PxTransform cB2w = parent->getGlobalPose().transform(mInboundJoint->getParentPose()); jointViz.visualizeJointFrames(cA2w, cB2w); NpArticulationJointReducedCoordinate* impl = static_cast<NpArticulationJointReducedCoordinate*>(mInboundJoint); PX_ASSERT(getArticulation().getConcreteType() == PxConcreteType::eARTICULATION_REDUCED_COORDINATE); //(1) visualize any angular dofs/limits... const PxMat33 cA2w_m(cA2w.q), cB2w_m(cB2w.q); PxTransform parentFrame = cB2w; if (cA2w.q.dot(cB2w.q) < 0) cB2w.q = -cB2w.q; //const PxTransform cB2cA = cA2w.transformInv(cB2w); const PxTransform cA2cB = cB2w.transformInv(cA2w); Sc::ArticulationJointCore& joint = impl->getCore(); if(joint.getMotion(PxArticulationAxis::eTWIST)) { const PxArticulationLimit pair = joint.getLimit(PxArticulationAxis::Enum(PxArticulationAxis::eTWIST)); jointViz.visualizeAngularLimit(parentFrame, pair.low, pair.high); } if (joint.getMotion(PxArticulationAxis::eSWING1)) { const PxArticulationLimit pair = joint.getLimit(PxArticulationAxis::Enum(PxArticulationAxis::eSWING1)); PxTransform tmp = parentFrame; tmp.q = tmp.q * PxQuat(-PxPiDivTwo, PxVec3(0.f, 0.f, 1.f)); jointViz.visualizeAngularLimit(tmp, -pair.high, -pair.low); } if (joint.getMotion(PxArticulationAxis::eSWING2)) { const PxArticulationLimit pair = joint.getLimit(PxArticulationAxis::Enum(PxArticulationAxis::eSWING2)); PxTransform tmp = parentFrame; tmp.q = tmp.q * PxQuat(PxPiDivTwo, PxVec3(0.f, 1.f, 0.f)); jointViz.visualizeAngularLimit(tmp, -pair.high, -pair.low); } for (PxU32 i = PxArticulationAxis::eX; i <= PxArticulationAxis::eZ; ++i) { if (joint.getMotion(PxArticulationAxis::Enum(i)) == PxArticulationMotion::eLIMITED) { const PxU32 index = i - PxArticulationAxis::eX; const PxArticulationLimit pair = joint.getLimit(PxArticulationAxis::Enum(i)); const PxReal ordinate = cA2cB.p[index]; const PxVec3& origin = cB2w.p; const PxVec3& axis = cA2w_m[index]; const bool active = ordinate < pair.low || ordinate > pair.high; const PxVec3 p0 = origin + axis * pair.low; const PxVec3 p1 = origin + axis * pair.high; jointViz.visualizeLine(p0, p1, active ? 0xff0000u : 0xffffffu); } } } } void NpArticulationReducedCoordinate::visualize(PxRenderOutput& out, NpScene& scene, float scale) const { const PxU32 nbLinks = mArticulationLinks.size(); for (PxU32 i = 0; i < nbLinks; i++) mArticulationLinks[i]->visualize(out, scene, scale); } #else PX_CATCH_UNDEFINED_ENABLE_DEBUG_VISUALIZATION #endif void NpScene::visualize() { PX_PROFILE_ZONE("NpScene::visualize", getContextId()); NP_READ_CHECK(this); mRenderBuffer.clear(); // clear last frame visualizations #if PX_ENABLE_DEBUG_VISUALIZATION const PxReal scale = mScene.getVisualizationParameter(PxVisualizationParameter::eSCALE); if(scale == 0.0f) return; PxRenderOutput out(mRenderBuffer); // Visualize scene axes const PxReal worldAxes = scale * mScene.getVisualizationParameter(PxVisualizationParameter::eWORLD_AXES); if(worldAxes != 0) Cm::renderOutputDebugBasis(out, PxDebugBasis(PxVec3(worldAxes))); // Visualize articulations const PxU32 articulationCount = mArticulations.size(); for(PxU32 i=0;i<articulationCount;i++) static_cast<const NpArticulationReducedCoordinate *>(mArticulations.getEntries()[i])->visualize(out, *this, scale); // Visualize rigid actors const PxU32 rigidDynamicCount = mRigidDynamics.size(); for(PxU32 i=0; i<rigidDynamicCount; i++) mRigidDynamics[i]->visualize(out, *this, scale); const PxU32 rigidStaticCount = mRigidStatics.size(); for(PxU32 i=0; i<rigidStaticCount; i++) mRigidStatics[i]->visualize(out, *this, scale); // Visualize pruning structures const bool visStatic = mScene.getVisualizationParameter(PxVisualizationParameter::eCOLLISION_STATIC) != 0.0f; const bool visDynamic = mScene.getVisualizationParameter(PxVisualizationParameter::eCOLLISION_DYNAMIC) != 0.0f; //flushQueryUpdates(); // DE7834 if(visStatic) getSQAPI().visualize(PxU32(PX_SCENE_PRUNER_STATIC), out); if(visDynamic) getSQAPI().visualize(PxU32(PX_SCENE_PRUNER_DYNAMIC), out); if(visStatic || visDynamic) getSQAPI().visualize(PxU32(PX_SCENE_COMPOUND_PRUNER), out); if(mScene.getVisualizationParameter(PxVisualizationParameter::eMBP_REGIONS) != 0.0f) { out << PxTransform(PxIdentity); const Bp::BroadPhase* bp = mScene.getAABBManager()->getBroadPhase(); const PxU32 nbRegions = bp->getNbRegions(); for(PxU32 i=0;i<nbRegions;i++) { PxBroadPhaseRegionInfo info; bp->getRegions(&info, 1, i); if(info.mActive) out << PxU32(PxDebugColor::eARGB_YELLOW); else out << PxU32(PxDebugColor::eARGB_BLACK); Cm::renderOutputDebugBox(out, info.mRegion.mBounds); } } if(mScene.getVisualizationParameter(PxVisualizationParameter::eCULL_BOX)!=0.0f) { const PxBounds3& cullbox = mScene.getVisualizationCullingBox(); if(!cullbox.isEmpty()) { out << PxU32(PxDebugColor::eARGB_YELLOW); Cm::renderOutputDebugBox(out, cullbox); } } #if PX_SUPPORT_GPU_PHYSX // Visualize particle systems { { PxPBDParticleSystem*const* particleSystems = mPBDParticleSystems.getEntries(); const PxU32 particleSystemCount = mPBDParticleSystems.size(); for (PxU32 i = 0; i < particleSystemCount; i++) static_cast<NpPBDParticleSystem*>(particleSystems[i])->visualize(out, *this); } #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION { PxFLIPParticleSystem*const* particleSystems = mFLIPParticleSystems.getEntries(); const PxU32 particleSystemCount = mFLIPParticleSystems.size(); for (PxU32 i = 0; i < particleSystemCount; i++) static_cast<NpFLIPParticleSystem*>(particleSystems[i])->visualize(out, *this); } { PxMPMParticleSystem*const* particleSystems = mMPMParticleSystems.getEntries(); const PxU32 particleSystemCount = mMPMParticleSystems.size(); for (PxU32 i = 0; i < particleSystemCount; i++) static_cast<NpMPMParticleSystem*>(particleSystems[i])->visualize(out, *this); } #endif } // Visualize soft bodies { PxSoftBody*const* softBodies = mSoftBodies.getEntries(); const PxU32 softBodyCount = mSoftBodies.size(); const bool visualize = mScene.getVisualizationParameter(PxVisualizationParameter::eSIMULATION_MESH) != 0.0f; for(PxU32 i=0; i<softBodyCount; i++) softBodies[i]->setSoftBodyFlag(PxSoftBodyFlag::eDISPLAY_SIM_MESH, visualize); } // FEM-cloth // no change // visualize hair systems { #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION const PxHairSystem*const* hairSystems = mHairSystems.getEntries(); const PxU32 hairSystemCount = mHairSystems.size(); for (PxU32 i = 0; i < hairSystemCount; i++) static_cast<const NpHairSystem*>(hairSystems[i])->visualize(out, *this); #endif } #endif #if PX_SUPPORT_PVD mScenePvdClient.visualize(mRenderBuffer); #endif #else PX_CATCH_UNDEFINED_ENABLE_DEBUG_VISUALIZATION #endif }
38,518
C++
32.436632
240
0.718391
NVIDIA-Omniverse/PhysX/physx/source/physx/src/NpFactory.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef NP_FACTORY_H #define NP_FACTORY_H #include "foundation/PxPool.h" #include "foundation/PxMutex.h" #include "foundation/PxHashSet.h" #include "GuMeshFactory.h" #include "PxPhysXConfig.h" #include "PxShape.h" #include "PxAggregate.h" #include "PxvGeometry.h" #include "NpFEMCloth.h" // to be deleted namespace physx { class PxCudaContextManager; class PxActor; class PxRigidActor; class PxRigidStatic; class NpRigidStatic; class PxRigidDynamic; class NpRigidDynamic; class NpConnectorArray; struct PxConstraintShaderTable; class PxConstraintConnector; class PxConstraint; class NpConstraint; class PxArticulationReducedCoordinate; class NpArticulationReducedCoordinate; class PxArticulationLink; class NpArticulationLink; class NpArticulationJointReducedCoordinate; class PxSoftBody; class PxFEMCloth; class PxParticleSystem; class PxHairSystem; #if PX_SUPPORT_GPU_PHYSX class NpSoftBody; class NpFEMCloth; class NpPBDParticleSystem; class NpFLIPParticleSystem; class NpMPMParticleSystem; class NpHairSystem; class NpFEMSoftBodyMaterial; class NpFEMClothMaterial; class NpPBDMaterial; class NpFLIPMaterial; class NpMPMMaterial; #endif class PxMaterial; class NpMaterial; class PxFEMSoftBodyMaterial; class PxFEMClothMaterial; class PxPBDMaterial; class PxFLIPMaterial; class PxMPMMaterial; class PxGeometry; class NpShape; class NpAggregate; class NpPtrTableStorageManager; namespace Cm { class Collection; } class NpFactoryListener : public Gu::MeshFactoryListener { protected: virtual ~NpFactoryListener(){} }; class NpFactory : public Gu::MeshFactory { PX_NOCOPY(NpFactory) public: NpFactory(); private: ~NpFactory(); template <typename PxMaterialType, typename NpMaterialType> NpShape* createShapeInternal(const PxGeometry& geometry, PxShapeFlags shapeFlags, PxMaterialType*const* materials, PxU16 materialCount, bool isExclusive, PxShapeCoreFlag::Enum flag); public: static void createInstance(); static void destroyInstance(); static void onParticleBufferRelease(PxParticleBuffer* buffer); void release(); void addCollection(const Cm::Collection& collection); PX_INLINE static NpFactory& getInstance() { return *mInstance; } // Rigid dynamic PxRigidDynamic* createRigidDynamic(const PxTransform& pose); void addRigidDynamic(PxRigidDynamic*, bool lock=true); void releaseRigidDynamicToPool(NpRigidDynamic&); // PT: TODO: add missing functions // PxU32 getNbRigidDynamics() const; // PxU32 getRigidDynamics(PxRigidDynamic** userBuffer, PxU32 bufferSize, PxU32 startIndex) const; // Rigid static PxRigidStatic* createRigidStatic(const PxTransform& pose); void addRigidStatic(PxRigidStatic*, bool lock=true); void releaseRigidStaticToPool(NpRigidStatic&); // PT: TODO: add missing functions // PxU32 getNbRigidStatics() const; // PxU32 getRigidStatics(PxRigidStatic** userBuffer, PxU32 bufferSize, PxU32 startIndex) const; // Shapes NpShape* createShape(const PxGeometry& geometry, PxShapeFlags shapeFlags, PxMaterial*const* materials, PxU16 materialCount, bool isExclusive); NpShape* createShape(const PxGeometry& geometry, PxShapeFlags shapeFlags, PxFEMSoftBodyMaterial*const* materials, PxU16 materialCount, bool isExclusive); #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION && PX_SUPPORT_GPU_PHYSX NpShape* createShape(const PxGeometry& geometry, PxShapeFlags shapeFlags, PxFEMClothMaterial*const* materials, PxU16 materialCount, bool isExclusive); #endif void addShape(PxShape*, bool lock=true); void releaseShapeToPool(NpShape&); PxU32 getNbShapes() const; PxU32 getShapes(PxShape** userBuffer, PxU32 bufferSize, PxU32 startIndex) const; // Constraints PxConstraint* createConstraint(PxRigidActor* actor0, PxRigidActor* actor1, PxConstraintConnector& connector, const PxConstraintShaderTable& shaders, PxU32 dataSize); void addConstraint(PxConstraint*, bool lock=true); void releaseConstraintToPool(NpConstraint&); // PT: TODO: add missing functions // PxU32 getNbConstraints() const; // PxU32 getConstraints(PxConstraint** userBuffer, PxU32 bufferSize, PxU32 startIndex) const; // Articulations void addArticulation(PxArticulationReducedCoordinate*, bool lock=true); void releaseArticulationToPool(PxArticulationReducedCoordinate& articulation); PxArticulationReducedCoordinate* createArticulationRC(); NpArticulationReducedCoordinate* createNpArticulationRC(); // Articulation links NpArticulationLink* createNpArticulationLink(NpArticulationReducedCoordinate& root, NpArticulationLink* parent, const PxTransform& pose); void releaseArticulationLinkToPool(NpArticulationLink& articulation); PxArticulationLink* createArticulationLink(NpArticulationReducedCoordinate& root, NpArticulationLink* parent, const PxTransform& pose); NpArticulationJointReducedCoordinate* createNpArticulationJointRC(NpArticulationLink& parent, const PxTransform& parentFrame, NpArticulationLink& child, const PxTransform& childFrame); void releaseArticulationJointRCToPool(NpArticulationJointReducedCoordinate& articulationJoint); #if PX_SUPPORT_GPU_PHYSX //Soft bodys PxSoftBody* createSoftBody(PxCudaContextManager& cudaContextManager); void releaseSoftBodyToPool(PxSoftBody& softBody); #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION // FEMCloth PxFEMCloth* createFEMCloth(PxCudaContextManager& cudaContextManager); void releaseFEMClothToPool(PxFEMCloth& femCloth); #endif //Particle systems PxPBDParticleSystem* createPBDParticleSystem(PxU32 maxNeighborhood, PxCudaContextManager& cudaContextManager); void releasePBDParticleSystemToPool(PxPBDParticleSystem& particleSystem); #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION //Particle systems PxFLIPParticleSystem* createFLIPParticleSystem(PxCudaContextManager& cudaContextManager); void releaseFLIPParticleSystemToPool(PxFLIPParticleSystem& particleSystem); //Particle systems PxMPMParticleSystem* createMPMParticleSystem(PxCudaContextManager& cudaContextManager); void releaseMPMParticleSystemToPool(PxMPMParticleSystem& particleSystem); #endif //Particle buffers PxParticleBuffer* createParticleBuffer(PxU32 maxParticles, PxU32 maxVolumes, PxCudaContextManager* cudaContextManager); //Diffuse Particle buffers PxParticleAndDiffuseBuffer* createParticleAndDiffuseBuffer(PxU32 maxParticles, PxU32 maxVolumes, PxU32 maxDiffuseParticles, PxCudaContextManager* cudaContextManager); //Particle cloth buffers PxParticleClothBuffer* createParticleClothBuffer(PxU32 maxParticles, PxU32 maxNumVolumes, PxU32 maxNumCloths, PxU32 maxNumTriangles, PxU32 maxNumSprings, PxCudaContextManager* cudaContextManager); //Particle rigid buffers PxParticleRigidBuffer* createParticleRigidBuffer(PxU32 maxParticles, PxU32 maxNumVolumes, PxU32 maxNumRigids, PxCudaContextManager* cudaContextManager); #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION // HairSystem PxHairSystem* createHairSystem(PxCudaContextManager& cudaContextManager); void releaseHairSystemToPool(PxHairSystem& hairSystem); #endif #endif // Aggregates PxAggregate* createAggregate(PxU32 maxActors, PxU32 maxShapes, PxAggregateFilterHint filterHint); void addAggregate(PxAggregate*, bool lock=true); void releaseAggregateToPool(NpAggregate&); // PT: TODO: add missing functions // PxU32 getNbAggregates() const; // PxU32 getAggregates(PxAggregate** userBuffer, PxU32 bufferSize, PxU32 startIndex) const; // Materials PxMaterial* createMaterial(PxReal staticFriction, PxReal dynamicFriction, PxReal restitution); void releaseMaterialToPool(NpMaterial& material); #if PX_SUPPORT_GPU_PHYSX PxFEMSoftBodyMaterial* createFEMSoftBodyMaterial(PxReal youngs, PxReal poissons, PxReal dynamicFriction); void releaseFEMMaterialToPool(PxFEMSoftBodyMaterial& material); PxFEMClothMaterial* createFEMClothMaterial(PxReal youngs, PxReal poissons, PxReal dynamicFriction, PxReal thickness); void releaseFEMClothMaterialToPool(PxFEMClothMaterial& material); PxPBDMaterial* createPBDMaterial(PxReal friction, PxReal damping, PxReal adhesion, PxReal viscosity, PxReal vorticityConfinement, PxReal surfaceTension, PxReal cohesion, PxReal lift, PxReal drag, PxReal cflCoefficient, PxReal gravityScale); void releasePBDMaterialToPool(PxPBDMaterial& material); #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION PxFLIPMaterial* createFLIPMaterial(PxReal friction, PxReal damping, PxReal adhesion, PxReal viscosity, PxReal gravityScale); void releaseFLIPMaterialToPool(PxFLIPMaterial& material); #endif PxMPMMaterial* createMPMMaterial(PxReal friction, PxReal damping, PxReal adhesion, bool isPlastic, PxReal youngsModulus, PxReal poissons, PxReal hardening, PxReal criticalCompression, PxReal criticalStretch, PxReal tensileDamageSensitivity, PxReal compressiveDamageSensitivity, PxReal attractiveForceResidual, PxReal gravityScale); void releaseMPMMaterialToPool(PxMPMMaterial& material); #endif // It's easiest to track these uninvasively, so it's OK to use the Px pointers void onActorRelease(PxActor*); void onConstraintRelease(PxConstraint*); void onAggregateRelease(PxAggregate*); void onArticulationRelease(PxArticulationReducedCoordinate*); void onShapeRelease(PxShape*); #if PX_SUPPORT_GPU_PHYSX void addParticleBuffer(PxParticleBuffer* buffer, bool lock = true); void onParticleBufferReleaseInternal(PxParticleBuffer* buffer); #endif NpConnectorArray* acquireConnectorArray(); void releaseConnectorArray(NpConnectorArray*); PX_FORCE_INLINE NpPtrTableStorageManager& getPtrTableStorageManager() { return *mPtrTableStorageManager; } #if PX_SUPPORT_PVD void setNpFactoryListener( NpFactoryListener& ); #endif private: PxPool<NpConnectorArray> mConnectorArrayPool; PxMutex mConnectorArrayPoolLock; NpPtrTableStorageManager* mPtrTableStorageManager; PxHashSet<PxAggregate*> mAggregateTracking; PxHashSet<PxArticulationReducedCoordinate*> mArticulationTracking; PxHashSet<PxConstraint*> mConstraintTracking; PxHashSet<PxActor*> mActorTracking; PxCoalescedHashSet<PxShape*> mShapeTracking; #if PX_SUPPORT_GPU_PHYSX PxHashSet<PxParticleBuffer*> mParticleBufferTracking; #endif PxPool2<NpRigidDynamic, 4096> mRigidDynamicPool; PxMutex mRigidDynamicPoolLock; PxPool2<NpRigidStatic, 4096> mRigidStaticPool; PxMutex mRigidStaticPoolLock; PxPool2<NpShape, 4096> mShapePool; PxMutex mShapePoolLock; PxPool2<NpAggregate, 4096> mAggregatePool; PxMutex mAggregatePoolLock; PxPool2<NpConstraint, 4096> mConstraintPool; PxMutex mConstraintPoolLock; PxPool2<NpMaterial, 4096> mMaterialPool; PxMutex mMaterialPoolLock; PxPool2<NpArticulationReducedCoordinate, 4096> mArticulationRCPool; PxMutex mArticulationRCPoolLock; PxPool2<NpArticulationLink, 4096> mArticulationLinkPool; PxMutex mArticulationLinkPoolLock; PxPool2<NpArticulationJointReducedCoordinate, 4096> mArticulationRCJointPool; PxMutex mArticulationJointRCPoolLock; #if PX_SUPPORT_GPU_PHYSX PxPool2<NpSoftBody, 4096> mSoftBodyPool; PxMutex mSoftBodyPoolLock; #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION PxPool2<NpFEMCloth, 4096> mFEMClothPool; PxMutex mFEMClothPoolLock; #endif PxPool2<NpPBDParticleSystem, 4096> mPBDParticleSystemPool; PxMutex mPBDParticleSystemPoolLock; #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION PxPool2<NpFLIPParticleSystem, 4096> mFLIPParticleSystemPool; PxMutex mFLIPParticleSystemPoolLock; PxPool2<NpMPMParticleSystem, 4096> mMPMParticleSystemPool; PxMutex mMPMParticleSystemPoolLock; #endif PxPool2<NpFEMSoftBodyMaterial, 4096> mFEMMaterialPool; PxMutex mFEMMaterialPoolLock; #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION PxPool2<NpFEMClothMaterial, 4096> mFEMClothMaterialPool; PxMutex mFEMClothMaterialPoolLock; #endif PxPool2<NpPBDMaterial, 4096> mPBDMaterialPool; PxMutex mPBDMaterialPoolLock; #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION PxPool2<NpFLIPMaterial, 4096> mFLIPMaterialPool; PxMutex mFLIPMaterialPoolLock; PxPool2<NpMPMMaterial, 4096> mMPMMaterialPool; PxMutex mMPMMaterialPoolLock; /*PxPool2<NpFEMSoftBodyMaterial, 4096> mFEMMaterialPool; PxMutex mFEMMaterialPoolLock;*/ PxPool2<NpHairSystem, 4096> mHairSystemPool; PxMutex mHairSystemPoolLock; #endif #endif static NpFactory* mInstance; PxU64 mGpuMemStat; #if PX_SUPPORT_PVD NpFactoryListener* mNpFactoryListener; #endif }; void NpDestroyRigidActor(NpRigidStatic* np); void NpDestroyRigidDynamic(NpRigidDynamic* np); void NpDestroyArticulationLink(NpArticulationLink* np); void NpDestroyArticulationJoint(PxArticulationJointReducedCoordinate* np); void NpDestroyArticulation(PxArticulationReducedCoordinate* artic); void NpDestroyAggregate(NpAggregate* np); void NpDestroyShape(NpShape* np); void NpDestroyConstraint(NpConstraint* np); #if PX_SUPPORT_GPU_PHYSX void NpDestroySoftBody(NpSoftBody* softBody); void NpDestroyFEMCloth(NpFEMCloth* femCloth); void NpDestroyParticleSystem(NpPBDParticleSystem* particleSystem); void NpDestroyParticleSystem(NpFLIPParticleSystem* particleSystem); void NpDestroyParticleSystem(NpMPMParticleSystem* particleSystem); void NpDestroyHairSystem(NpHairSystem* hairSystem); #endif } #endif
15,981
C
40.084833
341
0.757212
NVIDIA-Omniverse/PhysX/physx/source/physx/src/NpArticulationJointReducedCoordinate.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #include "NpCheck.h" #include "NpArticulationJointReducedCoordinate.h" #include "NpArticulationReducedCoordinate.h" #include "omnipvd/NpOmniPvdSetData.h" using namespace physx; namespace physx { //PX_SERIALIZATION NpArticulationJointReducedCoordinate* NpArticulationJointReducedCoordinate::createObject(PxU8*& address, PxDeserializationContext& context) { NpArticulationJointReducedCoordinate* obj = PX_PLACEMENT_NEW(address, NpArticulationJointReducedCoordinate(PxBaseFlags(0))); address += sizeof(NpArticulationJointReducedCoordinate); obj->importExtraData(context); obj->resolveReferences(context); return obj; } void NpArticulationJointReducedCoordinate::resolveReferences(PxDeserializationContext& context) { //mImpl.resolveReferences(context, *this); context.translatePxBase(mParent); context.translatePxBase(mChild); mCore.setRoot(this); NpArticulationReducedCoordinate* articulation = static_cast<NpArticulationReducedCoordinate*>(&mParent->getRoot()); mCore.setArticulation(&articulation->getCore()); } //~PX_SERIALIZATION NpArticulationJointReducedCoordinate::NpArticulationJointReducedCoordinate(NpArticulationLink& parent, const PxTransform& parentFrame, NpArticulationLink& child, const PxTransform& childFrame) : PxArticulationJointReducedCoordinate(PxConcreteType::eARTICULATION_JOINT_REDUCED_COORDINATE, PxBaseFlag::eOWNS_MEMORY), NpBase(NpType::eARTICULATION_JOINT), mCore(parentFrame, childFrame), mParent(&parent), mChild(&child) { NpArticulationReducedCoordinate* articulation = static_cast<NpArticulationReducedCoordinate*>(&parent.getRoot()); mCore.setArticulation(&articulation->getCore()); mCore.setRoot(this); } NpArticulationJointReducedCoordinate::~NpArticulationJointReducedCoordinate() { } void NpArticulationJointReducedCoordinate::setJointType(PxArticulationJointType::Enum jointType) { if(getNpScene()) { PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "PxArticulationJointReducedCoordinate::setJointType() not allowed while the articulation is in a scene. Call will be ignored."); return; } PX_CHECK_AND_RETURN(jointType != PxArticulationJointType::eUNDEFINED, "PxArticulationJointReducedCoordinate::setJointType valid joint type(ePRISMATIC, eREVOLUTE, eREVOLUTE_UNWRAPPED, eSPHERICAL, eFIX) need to be set"); OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, type, static_cast<PxArticulationJointReducedCoordinate&>(*this), jointType) scSetJointType(jointType); } PxArticulationJointType::Enum NpArticulationJointReducedCoordinate::getJointType() const { return mCore.getJointType(); } #if PX_CHECKED bool NpArticulationJointReducedCoordinate::isValidMotion(PxArticulationAxis::Enum axis, PxArticulationMotion::Enum motion) { bool valid = true; switch (mCore.getJointType()) { case PxArticulationJointType::ePRISMATIC: { if (axis < PxArticulationAxis::eX && motion != PxArticulationMotion::eLOCKED) valid = false; else if(motion != PxArticulationMotion::eLOCKED) { //Check to ensure that we only have zero DOFs already active... for (PxU32 i = PxArticulationAxis::eX; i <= PxArticulationAxis::eZ; i++) { if(i != PxU32(axis) && mCore.getMotion(PxArticulationAxis::Enum(i)) != PxArticulationMotion::eLOCKED) valid = false; } } break; } case PxArticulationJointType::eREVOLUTE: case PxArticulationJointType::eREVOLUTE_UNWRAPPED: { if (axis >= PxArticulationAxis::eX && motion != PxArticulationMotion::eLOCKED) valid = false; else if (motion != PxArticulationMotion::eLOCKED) { for (PxU32 i = PxArticulationAxis::eTWIST; i < PxArticulationAxis::eX; i++) { if (i != PxU32(axis) && mCore.getMotion(PxArticulationAxis::Enum(i)) != PxArticulationMotion::eLOCKED) valid = false; } } break; } case PxArticulationJointType::eSPHERICAL: { if (axis >= PxArticulationAxis::eX && motion != PxArticulationMotion::eLOCKED) valid = false; break; } case PxArticulationJointType::eFIX: { if (motion != PxArticulationMotion::eLOCKED) valid = false; break; } case PxArticulationJointType::eUNDEFINED: { valid = false; break; } default: break; } return valid; } #endif void NpArticulationJointReducedCoordinate::setMotion(PxArticulationAxis::Enum axis, PxArticulationMotion::Enum motion) { if(getNpScene()) { PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "PxArticulationJointReducedCoordinate::setMotion() not allowed while the articulation is in a scene. Call will be ignored."); return; } PX_CHECK_AND_RETURN(getJointType() != PxArticulationJointType::eUNDEFINED, "PxArticulationJointReducedCoordinate::setMotion valid joint type(ePRISMATIC, eREVOLUTE, eREVOUTE_UNWRAPPED, eSPHERICAL or eFIX) has to be set before setMotion"); PX_CHECK_AND_RETURN(isValidMotion(axis, motion), "PxArticulationJointReducedCoordinate::setMotion illegal configuration for the joint type that is set."); scSetMotion(axis, motion); #if PX_SUPPORT_OMNI_PVD PxArticulationMotion::Enum motions[PxArticulationAxis::eCOUNT]; for (PxU32 ax = 0; ax < PxArticulationAxis::eCOUNT; ++ax) motions[ax] = mCore.getMotion(static_cast<PxArticulationAxis::Enum>(ax)); OMNI_PVD_SET_ARRAY(OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, motion, static_cast<PxArticulationJointReducedCoordinate&>(*this), motions, PxArticulationAxis::eCOUNT); #endif static_cast<NpArticulationReducedCoordinate*>(&getChild().getArticulation())->mTopologyChanged = true; } PxArticulationMotion::Enum NpArticulationJointReducedCoordinate::getMotion(PxArticulationAxis::Enum axis) const { return mCore.getMotion(axis); } void NpArticulationJointReducedCoordinate::setFrictionCoefficient(const PxReal coefficient) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "PxArticulationJointReducedCoordinate::setFrictionCoefficient() not allowed while simulation is running. Call will be ignored.") OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, frictionCoefficient, static_cast<PxArticulationJointReducedCoordinate&>(*this), coefficient); scSetFrictionCoefficient(coefficient); } PxReal NpArticulationJointReducedCoordinate::getFrictionCoefficient() const { NP_READ_CHECK(getNpScene()); return mCore.getFrictionCoefficient(); } void NpArticulationJointReducedCoordinate::setMaxJointVelocity(const PxReal maxJointV) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "PxArticulationJointReducedCoordinate::setMaxJointVelocity() not allowed while simulation is running. Call will be ignored.") OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, maxJointVelocity, static_cast<PxArticulationJointReducedCoordinate&>(*this), maxJointV); scSetMaxJointVelocity(maxJointV); } PxReal NpArticulationJointReducedCoordinate::getMaxJointVelocity() const { NP_READ_CHECK(getNpScene()); return mCore.getMaxJointVelocity(); } void NpArticulationJointReducedCoordinate::setLimitParams(PxArticulationAxis::Enum axis, const PxArticulationLimit& pair) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(PxIsFinite(pair.low) && PxIsFinite(pair.high) && pair.low <= pair.high, "PxArticulationJointReducedCoordinate::setLimitParams(): Invalid limit parameters; lowLimit must be <= highLimit."); PX_CHECK_AND_RETURN(getJointType() != PxArticulationJointType::eSPHERICAL || (PxAbs(pair.low) <= PxPi && PxAbs(pair.high) <= PxPi), "PxArticulationJointReducedCoordinate::setLimitParams() only supports limit angles in range [-Pi, Pi] for joints of type PxArticulationJointType::eSPHERICAL"); PX_CHECK_AND_RETURN(getJointType() != PxArticulationJointType::eREVOLUTE || (PxAbs(pair.low) <= 2.0f*PxPi && PxAbs(pair.high) <= 2.0f*PxPi), "PxArticulationJointReducedCoordinate::setLimitParams() only supports limit angles in range [-2Pi, 2Pi] for joints of type PxArticulationJointType::eREVOLUTE"); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "PxArticulationJointReducedCoordinate::setLimitParams() not allowed while simulation is running. Call will be ignored.") scSetLimit(axis, pair); #if PX_SUPPORT_OMNI_PVD OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) PxArticulationJointReducedCoordinate& joint = *this; PxReal limits[PxArticulationAxis::eCOUNT]; for (PxU32 ax = 0; ax < PxArticulationAxis::eCOUNT; ++ax) limits[ax] = mCore.getLimit(static_cast<PxArticulationAxis::Enum>(ax)).low; OMNI_PVD_SET_ARRAY_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, limitLow, joint, limits, PxArticulationAxis::eCOUNT); for (PxU32 ax = 0; ax < PxArticulationAxis::eCOUNT; ++ax) limits[ax] = mCore.getLimit(static_cast<PxArticulationAxis::Enum>(ax)).high; OMNI_PVD_SET_ARRAY_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, limitHigh, joint, limits, PxArticulationAxis::eCOUNT); OMNI_PVD_WRITE_SCOPE_END #endif } PxArticulationLimit NpArticulationJointReducedCoordinate::getLimitParams(PxArticulationAxis::Enum axis) const { NP_READ_CHECK(getNpScene()); return mCore.getLimit(axis); } void NpArticulationJointReducedCoordinate::setDriveParams(PxArticulationAxis::Enum axis, const PxArticulationDrive& drive) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "PxArticulationJointReducedCoordinate::setDriveParams() not allowed while simulation is running. Call will be ignored.") scSetDrive(axis, drive); #if PX_SUPPORT_OMNI_PVD OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) PxArticulationJointReducedCoordinate& joint = *this; PxReal stiffnesss[PxArticulationAxis::eCOUNT]; for (PxU32 ax = 0; ax < PxArticulationAxis::eCOUNT; ++ax) stiffnesss[ax] = mCore.getDrive(static_cast<PxArticulationAxis::Enum>(ax)).stiffness; OMNI_PVD_SET_ARRAY_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, driveStiffness, joint, stiffnesss, PxArticulationAxis::eCOUNT); PxReal dampings[PxArticulationAxis::eCOUNT]; for (PxU32 ax = 0; ax < PxArticulationAxis::eCOUNT; ++ax) dampings[ax] = mCore.getDrive(static_cast<PxArticulationAxis::Enum>(ax)).damping; OMNI_PVD_SET_ARRAY_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, driveDamping, joint, dampings, PxArticulationAxis::eCOUNT); PxReal maxforces[PxArticulationAxis::eCOUNT]; for (PxU32 ax = 0; ax < PxArticulationAxis::eCOUNT; ++ax) maxforces[ax] = mCore.getDrive(static_cast<PxArticulationAxis::Enum>(ax)).maxForce; OMNI_PVD_SET_ARRAY_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, driveMaxForce, joint, maxforces, PxArticulationAxis::eCOUNT); PxArticulationDriveType::Enum drivetypes[PxArticulationAxis::eCOUNT]; for (PxU32 ax = 0; ax < PxArticulationAxis::eCOUNT; ++ax) drivetypes[ax] = mCore.getDrive(static_cast<PxArticulationAxis::Enum>(ax)).driveType; OMNI_PVD_SET_ARRAY_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, driveType, joint, drivetypes, PxArticulationAxis::eCOUNT); OMNI_PVD_WRITE_SCOPE_END #endif } PxArticulationDrive NpArticulationJointReducedCoordinate::getDriveParams(PxArticulationAxis::Enum axis) const { NP_READ_CHECK(getNpScene()); return mCore.getDrive(axis); } void NpArticulationJointReducedCoordinate::setDriveTarget(PxArticulationAxis::Enum axis, const PxReal target, bool autowake) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_AND_RETURN(getJointType() != PxArticulationJointType::eSPHERICAL || PxAbs(target) <= PxPi, "PxArticulationJointReducedCoordinate::setDriveTarget() only supports target angle in range [-Pi, Pi] for joints of type PxArticulationJointType::eSPHERICAL"); PX_CHECK_AND_RETURN(getJointType() != PxArticulationJointType::eREVOLUTE || PxAbs(target) <= 2.0f*PxPi, "PxArticulationJointReducedCoordinate::setDriveTarget() only supports target angle in range [-2Pi, 2Pi] for joints of type PxArticulationJointType::eREVOLUTE"); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxArticulationJointReducedCoordinate::setDriveTarget() not allowed while simulation is running. Call will be ignored.") if (npScene && (npScene->getFlags() & PxSceneFlag::eENABLE_DIRECT_GPU_API) && npScene->isDirectGPUAPIInitialized()) { PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "PxArticulationJointReducedCoordinate::setDriveTarget(): it is illegal to call this method if PxSceneFlag::eENABLE_DIRECT_GPU_API is enabled!"); } if (autowake && npScene) { NpArticulationReducedCoordinate* npArticulation = static_cast<NpArticulationReducedCoordinate*>(&mParent->getArticulation()); npArticulation->autoWakeInternal(); } scSetDriveTarget(axis, target); #if PX_SUPPORT_OMNI_PVD PxReal targets[PxArticulationAxis::eCOUNT]; for (PxU32 ax = 0; ax < PxArticulationAxis::eCOUNT; ++ax) targets[ax] = mCore.getTargetP(static_cast<PxArticulationAxis::Enum>(ax)); OMNI_PVD_SET_ARRAY(OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, driveTarget, static_cast<PxArticulationJointReducedCoordinate&>(*this), targets, PxArticulationAxis::eCOUNT); #endif } void NpArticulationJointReducedCoordinate::setDriveVelocity(PxArticulationAxis::Enum axis, const PxReal targetVel, bool autowake) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxArticulationJointReducedCoordinate::setDriveVelocity() not allowed while simulation is running. Call will be ignored.") if (npScene && (npScene->getFlags() & PxSceneFlag::eENABLE_DIRECT_GPU_API) && npScene->isDirectGPUAPIInitialized()) { PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "PxArticulationJointReducedCoordinate::setDriveVelocity(): it is illegal to call this method if PxSceneFlag::eENABLE_DIRECT_GPU_API is enabled!"); } if (autowake && npScene) { NpArticulationReducedCoordinate* npArticulation = static_cast<NpArticulationReducedCoordinate*>(&mParent->getArticulation()); npArticulation->autoWakeInternal(); } scSetDriveVelocity(axis, targetVel); #if PX_SUPPORT_OMNI_PVD PxReal velocities[PxArticulationAxis::eCOUNT]; for (PxU32 ax = 0; ax < PxArticulationAxis::eCOUNT; ++ax) velocities[ax] = mCore.getTargetV(static_cast<PxArticulationAxis::Enum>(ax)); OMNI_PVD_SET_ARRAY(OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, driveVelocity, static_cast<PxArticulationJointReducedCoordinate&>(*this), velocities, PxArticulationAxis::eCOUNT); #endif } PxReal NpArticulationJointReducedCoordinate::getDriveTarget(PxArticulationAxis::Enum axis) const { NP_READ_CHECK(getNpScene()); return mCore.getTargetP(axis); } PxReal NpArticulationJointReducedCoordinate::getDriveVelocity(PxArticulationAxis::Enum axis) const { NP_READ_CHECK(getNpScene()); return mCore.getTargetV(axis); } void NpArticulationJointReducedCoordinate::setArmature(PxArticulationAxis::Enum axis, const PxReal armature) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "PxArticulationJointReducedCoordinate::setArmature() not allowed while simulation is running. Call will be ignored.") scSetArmature(axis, armature); #if PX_SUPPORT_OMNI_PVD PxReal armatures[PxArticulationAxis::eCOUNT]; for (PxU32 ax = 0; ax < PxArticulationAxis::eCOUNT; ++ax) armatures[ax] = mCore.getArmature(static_cast<PxArticulationAxis::Enum>(ax)); OMNI_PVD_SET_ARRAY(OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, armature, static_cast<PxArticulationJointReducedCoordinate&>(*this), armatures, PxArticulationAxis::eCOUNT); #endif } PxReal NpArticulationJointReducedCoordinate::getArmature(PxArticulationAxis::Enum axis) const { NP_READ_CHECK(getNpScene()); return mCore.getArmature(axis); } PxTransform NpArticulationJointReducedCoordinate::getParentPose() const { NP_READ_CHECK(getNpScene()); // PT:: tag: scalar transform*transform return mParent->getCMassLocalPose().transform(mCore.getParentPose()); } void NpArticulationJointReducedCoordinate::setParentPose(const PxTransform& t) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(t.isSane(), "PxArticulationJointReducedCoordinate::setParentPose: Input pose is not valid."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "PxArticulationJointReducedCoordinate::setParentPose() not allowed while simulation is running. Call will be ignored.") #if PX_SUPPORT_OMNI_PVD OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) PxArticulationJointReducedCoordinate& joint = *this; OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, parentTranslation, joint, t.p) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, parentRotation, joint, t.q) OMNI_PVD_WRITE_SCOPE_END #endif if (mParent == NULL) return; scSetParentPose(mParent->getCMassLocalPose().transformInv(t.getNormalized())); } PxTransform NpArticulationJointReducedCoordinate::getChildPose() const { NP_READ_CHECK(getNpScene()); // PT:: tag: scalar transform*transform return mChild->getCMassLocalPose().transform(mCore.getChildPose()); } void NpArticulationJointReducedCoordinate::setChildPose(const PxTransform& t) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(t.isSane(), "PxArticulationJointReducedCoordinate::setChildPose: Input pose is not valid."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "PxArticulationJointReducedCoordinate::setChildPose() not allowed while simulation is running. Call will be ignored.") #if PX_SUPPORT_OMNI_PVD OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) PxArticulationJointReducedCoordinate& joint = *this; OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, childTranslation, joint, t.p) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, childRotation, joint, t.q) OMNI_PVD_WRITE_SCOPE_END #endif scSetChildPose(mChild->getCMassLocalPose().transformInv(t.getNormalized())); } void NpArticulationJointReducedCoordinate::setJointPosition(PxArticulationAxis::Enum axis, const PxReal jointPos) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_AND_RETURN(PxIsFinite(jointPos), "PxArticulationJointReducedCoordinate::setJointPosition: jointPos is not valid."); PX_CHECK_AND_RETURN(getJointType() != PxArticulationJointType::eSPHERICAL || PxAbs(jointPos) <= PxPi, "PxArticulationJointReducedCoordinate::setJointPosition() only supports jointPos in range [-Pi, Pi] for joints of type PxArticulationJointType::eSPHERICAL"); PX_CHECK_AND_RETURN(getJointType() != PxArticulationJointType::eREVOLUTE || PxAbs(jointPos) <= 2.0f*PxPi, "PxArticulationJointReducedCoordinate::setJointPosition() only supports jointPos in range [-2Pi, 2Pi] for joints of type PxArticulationJointType::eREVOLUTE"); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxArticulationJointReducedCoordinate::setJointPosition() not allowed while simulation is running. Call will be ignored."); if (npScene && (npScene->getFlags() & PxSceneFlag::eENABLE_DIRECT_GPU_API) && npScene->isDirectGPUAPIInitialized()) { PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "PxArticulationJointReducedCoordinate::setJointPosition(): it is illegal to call this method if PxSceneFlag::eENABLE_DIRECT_GPU_API is enabled!"); } scSetJointPosition(axis, jointPos); #if PX_SUPPORT_OMNI_PVD PxReal positions[PxArticulationAxis::eCOUNT]; for (PxU32 ax = 0; ax < PxArticulationAxis::eCOUNT; ++ax) positions[ax] = mCore.getJointPosition(static_cast<PxArticulationAxis::Enum>(ax)); OMNI_PVD_SET_ARRAY(OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, jointPosition, static_cast<PxArticulationJointReducedCoordinate&>(*this), positions, PxArticulationAxis::eCOUNT); #endif } PxReal NpArticulationJointReducedCoordinate::getJointPosition(PxArticulationAxis::Enum axis) const { NP_READ_CHECK(getNpScene()); PX_CHECK_SCENE_API_READ_FORBIDDEN_EXCEPT_COLLIDE_AND_RETURN_VAL(getNpScene(), "PxArticulationJointReducedCoordinate::getJointPosition() not allowed while simulation is running, except in a split simulation during PxScene::collide() and up to PxScene::advance().", 0.f); return mCore.getJointPosition(axis); } void NpArticulationJointReducedCoordinate::setJointVelocity(PxArticulationAxis::Enum axis, const PxReal jointVel) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_AND_RETURN(PxIsFinite(jointVel), "PxArticulationJointReducedCoordinate::setJointVelocity: jointVel is not valid."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxArticulationJointReducedCoordinate::setJointVelocity() not allowed while simulation is running. Call will be ignored."); if (npScene && (npScene->getFlags() & PxSceneFlag::eENABLE_DIRECT_GPU_API) && npScene->isDirectGPUAPIInitialized()) { PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "PxArticulationJointReducedCoordinate::setJointVelocity(): it is illegal to call this method if PxSceneFlag::eENABLE_DIRECT_GPU_API is enabled!"); } scSetJointVelocity(axis, jointVel); #if PX_SUPPORT_OMNI_PVD PxReal velocities[PxArticulationAxis::eCOUNT]; for (PxU32 ax = 0; ax < PxArticulationAxis::eCOUNT; ++ax) velocities[ax] = mCore.getJointVelocity(static_cast<PxArticulationAxis::Enum>(ax)); OMNI_PVD_SET_ARRAY(OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, jointVelocity, static_cast<PxArticulationJointReducedCoordinate&>(*this), velocities, PxArticulationAxis::eCOUNT); #endif } PxReal NpArticulationJointReducedCoordinate::getJointVelocity(PxArticulationAxis::Enum axis) const { NP_READ_CHECK(getNpScene()); PX_CHECK_SCENE_API_READ_FORBIDDEN_EXCEPT_COLLIDE_AND_RETURN_VAL(getNpScene(), "PxArticulationJointReducedCoordinate::getJointVelocity() not allowed while simulation is running, except in a split simulation during PxScene::collide() and up to PxScene::advance().", 0.f); return mCore.getJointVelocity(axis); } void NpArticulationJointReducedCoordinate::release() { NpPhysics::getInstance().notifyDeletionListenersUserRelease(this, NULL); if(getNpScene()) getNpScene()->scRemoveArticulationJoint(*this); PX_ASSERT(!isAPIWriteForbidden()); NpDestroyArticulationJoint(mCore.getRoot()); } }
24,393
C++
45.553435
305
0.779732
NVIDIA-Omniverse/PhysX/physx/source/physx/src/NpPvdSceneClient.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #include "foundation/PxPreprocessor.h" #if PX_SUPPORT_PVD #include "common/PxProfileZone.h" #include "common/PxRenderBuffer.h" #include "PxParticleSystem.h" #include "PxPBDParticleSystem.h" //#include "PxFLIPParticleSystem.h" //#include "PxMPMParticleSystem.h" #include "PxPhysics.h" #include "PxConstraintDesc.h" #include "NpPvdSceneClient.h" #include "ScBodySim.h" #include "ScConstraintSim.h" #include "ScConstraintCore.h" #include "PxsMaterialManager.h" #include "PvdTypeNames.h" #include "PxPvdUserRenderer.h" #include "PxvNphaseImplementationContext.h" #include "NpConstraint.h" #include "NpRigidStatic.h" #include "NpRigidDynamic.h" #include "NpArticulationLink.h" #include "NpSoftBody.h" //#include "NpFEMCloth.h" #include "NpHairSystem.h" #include "NpAggregate.h" #include "NpScene.h" #include "NpArticulationJointReducedCoordinate.h" #include "NpArticulationReducedCoordinate.h" using namespace physx; using namespace physx::Vd; using namespace physx::pvdsdk; namespace { PX_FORCE_INLINE PxU64 getContextId(NpScene& scene) { return scene.getScScene().getContextId(); } /////////////////////////////////////////////////////////////////////////////// // Sc-to-Np PX_FORCE_INLINE static NpConstraint* getNpConstraint(Sc::ConstraintCore* scConstraint) { return reinterpret_cast<NpConstraint*>(reinterpret_cast<char*>(scConstraint) - NpConstraint::getCoreOffset()); } /////////////////////////////////////////////////////////////////////////////// PX_FORCE_INLINE static const PxActor* getPxActor(const NpActor* scActor) { return scActor->getPxActor(); } struct CreateOp { CreateOp& operator=(const CreateOp&); physx::pvdsdk::PvdDataStream& mStream; PvdMetaDataBinding& mBinding; PsPvd* mPvd; PxScene& mScene; CreateOp(physx::pvdsdk::PvdDataStream& str, PvdMetaDataBinding& bind, PsPvd* pvd, PxScene& scene) : mStream(str), mBinding(bind), mPvd(pvd), mScene(scene) { } template <typename TDataType> void operator()(const TDataType& dtype) { mBinding.createInstance(mStream, dtype, mScene, PxGetPhysics(), mPvd); } void operator()(const PxArticulationLink&) { } }; struct UpdateOp { UpdateOp& operator=(const UpdateOp&); physx::pvdsdk::PvdDataStream& mStream; PvdMetaDataBinding& mBinding; UpdateOp(physx::pvdsdk::PvdDataStream& str, PvdMetaDataBinding& bind) : mStream(str), mBinding(bind) { } template <typename TDataType> void operator()(const TDataType& dtype) { mBinding.sendAllProperties(mStream, dtype); } }; struct DestroyOp { DestroyOp& operator=(const DestroyOp&); physx::pvdsdk::PvdDataStream& mStream; PvdMetaDataBinding& mBinding; PxScene& mScene; DestroyOp(physx::pvdsdk::PvdDataStream& str, PvdMetaDataBinding& bind, PxScene& scene) : mStream(str), mBinding(bind), mScene(scene) { } template <typename TDataType> void operator()(const TDataType& dtype) { mBinding.destroyInstance(mStream, dtype, mScene); } void operator()(const PxArticulationLink& dtype) { mBinding.destroyInstance(mStream, dtype); } }; template <typename TOperator> inline void BodyTypeOperation(const NpActor* scBody, TOperator op) { // const bool isArticulationLink = scBody->getActorType_() == PxActorType::eARTICULATION_LINK; const bool isArticulationLink = scBody->getNpType() == NpType::eBODY_FROM_ARTICULATION_LINK; if(isArticulationLink) { const NpArticulationLink* link = static_cast<const NpArticulationLink*>(scBody); op(*static_cast<const PxArticulationLink*>(link)); } else { const NpRigidDynamic* npRigidDynamic = static_cast<const NpRigidDynamic*>(scBody); op(*static_cast<const PxRigidDynamic*>(npRigidDynamic)); } } template <typename TOperator> inline void ActorTypeOperation(const PxActor* actor, TOperator op) { switch(actor->getType()) { case PxActorType::eRIGID_STATIC: op(*static_cast<const PxRigidStatic*>(actor)); break; case PxActorType::eRIGID_DYNAMIC: op(*static_cast<const PxRigidDynamic*>(actor)); break; case PxActorType::eARTICULATION_LINK: op(*static_cast<const PxArticulationLink*>(actor)); break; case PxActorType::eSOFTBODY: #if PX_SUPPORT_GPU_PHYSX op(*static_cast<const PxSoftBody*>(actor)); #endif break; case PxActorType::eFEMCLOTH: //op(*static_cast<const PxFEMCloth*>(actor)); break; case PxActorType::ePBD_PARTICLESYSTEM: op(*static_cast<const PxPBDParticleSystem*>(actor)); break; case PxActorType::eFLIP_PARTICLESYSTEM: //op(*static_cast<const PxFLIPParticleSystem*>(actor)); break; case PxActorType::eMPM_PARTICLESYSTEM: //op(*static_cast<const PxMPMParticleSystem*>(actor)); break; case PxActorType::eHAIRSYSTEM: //op(*static_cast<const PxHairSystem*>(actor)); break; case PxActorType::eACTOR_COUNT: case PxActorType::eACTOR_FORCE_DWORD: PX_ASSERT(false); break; }; } namespace { struct PvdConstraintVisualizer : public PxConstraintVisualizer { PX_NOCOPY(PvdConstraintVisualizer) public: physx::pvdsdk::PvdUserRenderer& mRenderer; PvdConstraintVisualizer(const void* id, physx::pvdsdk::PvdUserRenderer& r) : mRenderer(r) { mRenderer.setInstanceId(id); } virtual void visualizeJointFrames(const PxTransform& parent, const PxTransform& child) PX_OVERRIDE { mRenderer.visualizeJointFrames(parent, child); } virtual void visualizeLinearLimit(const PxTransform& t0, const PxTransform& t1, PxReal value) PX_OVERRIDE { mRenderer.visualizeLinearLimit(t0, t1, PxF32(value)); } virtual void visualizeAngularLimit(const PxTransform& t0, PxReal lower, PxReal upper) PX_OVERRIDE { mRenderer.visualizeAngularLimit(t0, PxF32(lower), PxF32(upper)); } virtual void visualizeLimitCone(const PxTransform& t, PxReal tanQSwingY, PxReal tanQSwingZ) PX_OVERRIDE { mRenderer.visualizeLimitCone(t, PxF32(tanQSwingY), PxF32(tanQSwingZ)); } virtual void visualizeDoubleCone(const PxTransform& t, PxReal angle) PX_OVERRIDE { mRenderer.visualizeDoubleCone(t, PxF32(angle)); } virtual void visualizeLine( const PxVec3& p0, const PxVec3& p1, PxU32 color) PX_OVERRIDE { const PxDebugLine line(p0, p1, color); mRenderer.drawLines(&line, 1); } }; } class SceneRendererClient : public RendererEventClient, public physx::PxUserAllocated { PX_NOCOPY(SceneRendererClient) public: SceneRendererClient(PvdUserRenderer* renderer, PxPvd* pvd):mRenderer(renderer) { mStream = PvdDataStream::create(pvd); mStream->createInstance(renderer); } ~SceneRendererClient() { mStream->destroyInstance(mRenderer); mStream->release(); } virtual void handleBufferFlush(const uint8_t* inData, uint32_t inLength) { mStream->setPropertyValue(mRenderer, "events", inData, inLength); } private: PvdUserRenderer* mRenderer; PvdDataStream* mStream; }; } // namespace PvdSceneClient::PvdSceneClient(NpScene& scene) : mPvd (NULL), mScene (scene), mPvdDataStream (NULL), mUserRender (NULL), mRenderClient (NULL), mIsConnected (false) { } PvdSceneClient::~PvdSceneClient() { if(mPvd) mPvd->removeClient(this); } void PvdSceneClient::updateCamera(const char* name, const PxVec3& origin, const PxVec3& up, const PxVec3& target) { if(mIsConnected) mPvdDataStream->updateCamera(name, origin, up, target); } void PvdSceneClient::drawPoints(const PxDebugPoint* points, PxU32 count) { if(mUserRender) mUserRender->drawPoints(points, count); } void PvdSceneClient::drawLines(const PxDebugLine* lines, PxU32 count) { if(mUserRender) mUserRender->drawLines(lines, count); } void PvdSceneClient::drawTriangles(const PxDebugTriangle* triangles, PxU32 count) { if(mUserRender) mUserRender->drawTriangles(triangles, count); } void PvdSceneClient::drawText(const PxDebugText& text) { if(mUserRender) mUserRender->drawText(text); } void PvdSceneClient::setScenePvdFlag(PxPvdSceneFlag::Enum flag, bool value) { if(value) mFlags |= flag; else mFlags &= ~flag; } void PvdSceneClient::onPvdConnected() { if(mIsConnected || !mPvd) return; mIsConnected = true; mPvdDataStream = PvdDataStream::create(mPvd); mUserRender = PvdUserRenderer::create(); mRenderClient = PX_NEW(SceneRendererClient)(mUserRender, mPvd); mUserRender->setClient(mRenderClient); sendEntireScene(); } void PvdSceneClient::onPvdDisconnected() { if(!mIsConnected) return; mIsConnected = false; PX_DELETE(mRenderClient); mUserRender->release(); mUserRender = NULL; mPvdDataStream->release(); mPvdDataStream = NULL; } void PvdSceneClient::updatePvdProperties() { mMetaDataBinding.sendAllProperties(*mPvdDataStream, mScene); } void PvdSceneClient::releasePvdInstance() { if(mPvdDataStream) { PxScene* theScene = &mScene; // remove from parent mPvdDataStream->removeObjectRef(&PxGetPhysics(), "Scenes", theScene); mPvdDataStream->destroyInstance(theScene); } } // PT: this is only called once, from "onPvdConnected" void PvdSceneClient::sendEntireScene() { NpScene* npScene = &mScene; if(npScene->getFlagsFast() & PxSceneFlag::eREQUIRE_RW_LOCK) // getFlagsFast() will trigger a warning of lock check npScene->lockRead(PX_FL); PxPhysics& physics = PxGetPhysics(); { PxScene* theScene = &mScene; mPvdDataStream->createInstance(theScene); updatePvdProperties(); // Create parent/child relationship. mPvdDataStream->setPropertyValue(theScene, "Physics", reinterpret_cast<const void*>(&physics)); mPvdDataStream->pushBackObjectRef(&physics, "Scenes", theScene); } // materials: { PxsMaterialManager& manager = mScene.getScScene().getMaterialManager(); PxsMaterialManagerIterator<PxsMaterialCore> iter(manager); PxsMaterialCore* mat; while(iter.getNextMaterial(mat)) { const PxMaterial* theMaterial = mat->mMaterial; if(mPvd->registerObject(theMaterial)) mMetaDataBinding.createInstance(*mPvdDataStream, *theMaterial, physics); }; } if(mPvd->getInstrumentationFlags() & PxPvdInstrumentationFlag::eDEBUG) { PxArray<PxActor*> actorArray; // RBs // static: { PxU32 numActors = npScene->getNbActors(PxActorTypeFlag::eRIGID_STATIC | PxActorTypeFlag::eRIGID_DYNAMIC); actorArray.resize(numActors); npScene->getActors(PxActorTypeFlag::eRIGID_STATIC | PxActorTypeFlag::eRIGID_DYNAMIC, actorArray.begin(), actorArray.size()); for(PxU32 i = 0; i < numActors; i++) { PxActor* pxActor = actorArray[i]; if(pxActor->getConcreteType()==PxConcreteType::eRIGID_STATIC) mMetaDataBinding.createInstance(*mPvdDataStream, *static_cast<PxRigidStatic*>(pxActor), *npScene, physics, mPvd); else mMetaDataBinding.createInstance(*mPvdDataStream, *static_cast<PxRigidDynamic*>(pxActor), *npScene, physics, mPvd); } } // articulations & links { PxArray<PxArticulationReducedCoordinate*> articulations; PxU32 numArticulations = npScene->getNbArticulations(); articulations.resize(numArticulations); npScene->getArticulations(articulations.begin(), articulations.size()); for(PxU32 i = 0; i < numArticulations; i++) mMetaDataBinding.createInstance(*mPvdDataStream, *articulations[i], *npScene, physics, mPvd); } // joints { Sc::ConstraintCore*const * constraints = mScene.getScScene().getConstraints(); PxU32 nbConstraints = mScene.getScScene().getNbConstraints(); for(PxU32 i = 0; i < nbConstraints; i++) { updateConstraint(*constraints[i], PxPvdUpdateType::CREATE_INSTANCE); updateConstraint(*constraints[i], PxPvdUpdateType::UPDATE_ALL_PROPERTIES); } } } if(npScene->getFlagsFast() & PxSceneFlag::eREQUIRE_RW_LOCK) npScene->unlockRead(); } void PvdSceneClient::updateConstraint(const Sc::ConstraintCore& scConstraint, PxU32 updateType) { PxConstraintConnector* conn = scConstraint.getPxConnector(); if(conn && checkPvdDebugFlag()) conn->updatePvdProperties(*mPvdDataStream, scConstraint.getPxConstraint(), PxPvdUpdateType::Enum(updateType)); } void PvdSceneClient::createPvdInstance(const PxActor* actor) { if(checkPvdDebugFlag()) ActorTypeOperation(actor, CreateOp(*mPvdDataStream, mMetaDataBinding, mPvd, mScene)); } void PvdSceneClient::updatePvdProperties(const PxActor* actor) { if(checkPvdDebugFlag()) ActorTypeOperation(actor, UpdateOp(*mPvdDataStream, mMetaDataBinding)); } void PvdSceneClient::releasePvdInstance(const PxActor* actor) { if(checkPvdDebugFlag()) ActorTypeOperation(actor, DestroyOp(*mPvdDataStream, mMetaDataBinding, mScene)); } /////////////////////////////////////////////////////////////////////////////// void PvdSceneClient::createPvdInstance(const NpActor* actor) { // PT: why not UPDATE_PVD_PROPERTIES_CHECK() here? createPvdInstance(getPxActor(actor)); } void PvdSceneClient::updatePvdProperties(const NpActor* actor) { // PT: why not UPDATE_PVD_PROPERTIES_CHECK() here? updatePvdProperties(getPxActor(actor)); } void PvdSceneClient::releasePvdInstance(const NpActor* actor) { // PT: why not UPDATE_PVD_PROPERTIES_CHECK() here? releasePvdInstance(getPxActor(actor)); } /////////////////////////////////////////////////////////////////////////////// void PvdSceneClient::createPvdInstance(const NpRigidDynamic* body) { if(checkPvdDebugFlag() && body->getNpType() != NpType::eBODY_FROM_ARTICULATION_LINK) BodyTypeOperation(body, CreateOp(*mPvdDataStream, mMetaDataBinding, mPvd, mScene)); } void PvdSceneClient::createPvdInstance(const NpArticulationLink* body) { if(checkPvdDebugFlag() && body->getNpType() != NpType::eBODY_FROM_ARTICULATION_LINK) BodyTypeOperation(body, CreateOp(*mPvdDataStream, mMetaDataBinding, mPvd, mScene)); } void PvdSceneClient::releasePvdInstance(const NpRigidDynamic* body) { releasePvdInstance(getPxActor(body)); } void PvdSceneClient::releasePvdInstance(const NpArticulationLink* body) { releasePvdInstance(getPxActor(body)); } void PvdSceneClient::updateBodyPvdProperties(const NpActor* body) { if(checkPvdDebugFlag()) { if(body->getNpType() == NpType::eBODY_FROM_ARTICULATION_LINK) updatePvdProperties(static_cast<const NpArticulationLink*>(body)); else if(body->getNpType() == NpType::eBODY) updatePvdProperties(static_cast<const NpRigidDynamic*>(body)); else PX_ASSERT(0); } } void PvdSceneClient::updatePvdProperties(const NpRigidDynamic* body) { if(checkPvdDebugFlag()) BodyTypeOperation(body, UpdateOp(*mPvdDataStream, mMetaDataBinding)); } void PvdSceneClient::updatePvdProperties(const NpArticulationLink* body) { if(checkPvdDebugFlag()) BodyTypeOperation(body, UpdateOp(*mPvdDataStream, mMetaDataBinding)); } void PvdSceneClient::updateKinematicTarget(const NpActor* body, const PxTransform& p) { if(checkPvdDebugFlag()) { if(body->getNpType() == NpType::eBODY_FROM_ARTICULATION_LINK) mPvdDataStream->setPropertyValue(static_cast<const NpArticulationLink*>(body), "KinematicTarget", p); else if(body->getNpType() == NpType::eBODY) mPvdDataStream->setPropertyValue(static_cast<const NpRigidDynamic*>(body), "KinematicTarget", p); else PX_ASSERT(0); } } /////////////////////////////////////////////////////////////////////////////// void PvdSceneClient::releasePvdInstance(const NpRigidStatic* rigidStatic) { releasePvdInstance(static_cast<const NpActor*>(rigidStatic)); } void PvdSceneClient::createPvdInstance(const NpRigidStatic* rigidStatic) { if(checkPvdDebugFlag()) mMetaDataBinding.createInstance(*mPvdDataStream, *rigidStatic, mScene, PxGetPhysics(), mPvd); } void PvdSceneClient::updatePvdProperties(const NpRigidStatic* rigidStatic) { if(checkPvdDebugFlag()) mMetaDataBinding.sendAllProperties(*mPvdDataStream, *rigidStatic); } /////////////////////////////////////////////////////////////////////////////// void PvdSceneClient::createPvdInstance(const NpConstraint* constraint) { if(checkPvdDebugFlag()) updateConstraint(constraint->getCore(), PxPvdUpdateType::CREATE_INSTANCE); } void PvdSceneClient::updatePvdProperties(const NpConstraint* constraint) { if(checkPvdDebugFlag()) updateConstraint(constraint->getCore(), PxPvdUpdateType::UPDATE_ALL_PROPERTIES); } void PvdSceneClient::releasePvdInstance(const NpConstraint* constraint) { const Sc::ConstraintCore& scConstraint = constraint->getCore(); PxConstraintConnector* conn; if(checkPvdDebugFlag() && (conn = scConstraint.getPxConnector()) != NULL) conn->updatePvdProperties(*mPvdDataStream, scConstraint.getPxConstraint(), PxPvdUpdateType::RELEASE_INSTANCE); } /////////////////////////////////////////////////////////////////////////////// void PvdSceneClient::createPvdInstance(const NpArticulationReducedCoordinate* articulation) { if (checkPvdDebugFlag()) { mMetaDataBinding.createInstance(*mPvdDataStream, *articulation, mScene, PxGetPhysics(), mPvd); } } void PvdSceneClient::updatePvdProperties(const NpArticulationReducedCoordinate* articulation) { if(checkPvdDebugFlag()) { mMetaDataBinding.sendAllProperties(*mPvdDataStream, *articulation); } } void PvdSceneClient::releasePvdInstance(const NpArticulationReducedCoordinate* articulation) { if (checkPvdDebugFlag()) { mMetaDataBinding.destroyInstance(*mPvdDataStream, *articulation, mScene); } } /////////////////////////////////////////////////////////////////////////////// void PvdSceneClient::createPvdInstance(const NpArticulationJointReducedCoordinate* articulationJoint) { PX_UNUSED(articulationJoint); } void PvdSceneClient::updatePvdProperties(const NpArticulationJointReducedCoordinate* articulationJoint) { if (checkPvdDebugFlag()) { mMetaDataBinding.sendAllProperties(*mPvdDataStream, *articulationJoint); } } void PvdSceneClient::releasePvdInstance(const NpArticulationJointReducedCoordinate* articulationJoint) { PX_UNUSED(articulationJoint); } ///////////////////////////////////////////////////////////////////////////////// void PvdSceneClient::createPvdInstance(const NpArticulationSpatialTendon* articulationTendon) { PX_UNUSED(articulationTendon); } void PvdSceneClient::updatePvdProperties(const NpArticulationSpatialTendon* articulationTendon) { PX_UNUSED(articulationTendon); } void PvdSceneClient::releasePvdInstance(const NpArticulationSpatialTendon* articulationTendon) { PX_UNUSED(articulationTendon); } ///////////////////////////////////////////////////////////////////////////////// void PvdSceneClient::createPvdInstance(const NpArticulationFixedTendon* articulationTendon) { PX_UNUSED(articulationTendon); } void PvdSceneClient::updatePvdProperties(const NpArticulationFixedTendon* articulationTendon) { PX_UNUSED(articulationTendon); } void PvdSceneClient::releasePvdInstance(const NpArticulationFixedTendon* articulationTendon) { PX_UNUSED(articulationTendon); } ///////////////////////////////////////////////////////////////////////////////// void PvdSceneClient::createPvdInstance(const NpArticulationSensor* sensor) { PX_UNUSED(sensor); } void PvdSceneClient::updatePvdProperties(const NpArticulationSensor* sensor) { PX_UNUSED(sensor); } void PvdSceneClient::releasePvdInstance(const NpArticulationSensor* sensor) { PX_UNUSED(sensor); } /////////////////////////////////////////////////////////////////////////////// void PvdSceneClient::createPvdInstance(const PxsMaterialCore* materialCore) { if(checkPvdDebugFlag()) { const PxMaterial* theMaterial = materialCore->mMaterial; if(mPvd->registerObject(theMaterial)) mMetaDataBinding.createInstance(*mPvdDataStream, *theMaterial, PxGetPhysics()); } } void PvdSceneClient::updatePvdProperties(const PxsMaterialCore* materialCore) { if(checkPvdDebugFlag()) mMetaDataBinding.sendAllProperties(*mPvdDataStream, *materialCore->mMaterial); } void PvdSceneClient::releasePvdInstance(const PxsMaterialCore* materialCore) { if(checkPvdDebugFlag() && mPvd->unRegisterObject(materialCore->mMaterial)) mMetaDataBinding.destroyInstance(*mPvdDataStream, *materialCore->mMaterial, PxGetPhysics()); } /////////////////////////////////////////////////////////////////////////////// void PvdSceneClient::createPvdInstance(const PxsFEMSoftBodyMaterialCore* materialCore) { if (checkPvdDebugFlag()) { const PxFEMSoftBodyMaterial* theMaterial = materialCore->mMaterial; if (mPvd->registerObject(theMaterial)) mMetaDataBinding.createInstance(*mPvdDataStream, *theMaterial, PxGetPhysics()); } } void PvdSceneClient::updatePvdProperties(const PxsFEMSoftBodyMaterialCore* materialCore) { if (checkPvdDebugFlag()) mMetaDataBinding.sendAllProperties(*mPvdDataStream, *materialCore->mMaterial); } void PvdSceneClient::releasePvdInstance(const PxsFEMSoftBodyMaterialCore* materialCore) { if (checkPvdDebugFlag() && mPvd->unRegisterObject(materialCore->mMaterial)) mMetaDataBinding.destroyInstance(*mPvdDataStream, *materialCore->mMaterial, PxGetPhysics()); } /////////////////////////////////////////////////////////////////////////////// void PvdSceneClient::createPvdInstance(const PxsFEMClothMaterialCore*) { // no PVD support but method is "needed" since macro code is shared among all material types } void PvdSceneClient::updatePvdProperties(const PxsFEMClothMaterialCore*) { // no PVD support but method is "needed" since macro code is shared among all material types } void PvdSceneClient::releasePvdInstance(const PxsFEMClothMaterialCore*) { // no PVD support but method is "needed" since macro code is shared among all material types } /////////////////////////////////////////////////////////////////////////////// void PvdSceneClient::createPvdInstance(const PxsPBDMaterialCore* /*materialCore*/) { // PX_ASSERT(0); } void PvdSceneClient::updatePvdProperties(const PxsPBDMaterialCore* /*materialCore*/) { // PX_ASSERT(0); } void PvdSceneClient::releasePvdInstance(const PxsPBDMaterialCore* /*materialCore*/) { // PX_ASSERT(0); } void PvdSceneClient::createPvdInstance(const PxsFLIPMaterialCore* /*materialCore*/) { // PX_ASSERT(0); } void PvdSceneClient::updatePvdProperties(const PxsFLIPMaterialCore* /*materialCore*/) { // PX_ASSERT(0); } void PvdSceneClient::releasePvdInstance(const PxsFLIPMaterialCore* /*materialCore*/) { // PX_ASSERT(0); } void PvdSceneClient::createPvdInstance(const PxsMPMMaterialCore* /*materialCore*/) { // PX_ASSERT(0); } void PvdSceneClient::updatePvdProperties(const PxsMPMMaterialCore* /*materialCore*/) { // PX_ASSERT(0); } void PvdSceneClient::releasePvdInstance(const PxsMPMMaterialCore* /*materialCore*/) { // PX_ASSERT(0); } /////////////////////////////////////////////////////////////////////////////// void PvdSceneClient::createPvdInstance(const NpShape* npShape, PxActor& owner) { if(checkPvdDebugFlag()) { PX_PROFILE_ZONE("PVD.createPVDInstance", getContextId(mScene)); mMetaDataBinding.createInstance(*mPvdDataStream, *npShape, static_cast<PxRigidActor&>(owner), PxGetPhysics(), mPvd); } } static void addShapesToPvd(PxU32 nbShapes, NpShape* const* shapes, PxActor& pxActor, PsPvd* pvd, PvdDataStream& stream, PvdMetaDataBinding& binding) { PxPhysics& physics = PxGetPhysics(); for(PxU32 i=0;i<nbShapes;i++) { const NpShape* npShape = shapes[i]; binding.createInstance(stream, *npShape, static_cast<PxRigidActor&>(pxActor), physics, pvd); } } void PvdSceneClient::addBodyAndShapesToPvd(NpRigidDynamic& b) { if(checkPvdDebugFlag()) { PX_PROFILE_ZONE("PVD.createPVDInstance", getContextId(mScene)); createPvdInstance(&b); PxActor& pxActor = *b.getCore().getPxActor(); NpShape* const* shapes; const PxU32 nbShapes = NpRigidDynamicGetShapes(b, shapes); addShapesToPvd(nbShapes, shapes, pxActor, mPvd, *mPvdDataStream, mMetaDataBinding); } } void PvdSceneClient::addStaticAndShapesToPvd(NpRigidStatic& s) { if(checkPvdDebugFlag()) { PX_PROFILE_ZONE("PVD.createPVDInstance", getContextId(mScene)); createPvdInstance(&s); PxActor& pxActor = static_cast<PxRigidStatic&>(s); NpShape* const* shapes; const PxU32 nbShapes = NpRigidStaticGetShapes(s, shapes); addShapesToPvd(nbShapes, shapes, pxActor, mPvd, *mPvdDataStream, mMetaDataBinding); } } void PvdSceneClient::updateMaterials(const NpShape* npShape) { if(checkPvdDebugFlag()) mMetaDataBinding.updateMaterials(*mPvdDataStream, *npShape, mPvd); } void PvdSceneClient::updatePvdProperties(const NpShape* npShape) { if(checkPvdDebugFlag()) mMetaDataBinding.sendAllProperties(*mPvdDataStream, *npShape); } void PvdSceneClient::releaseAndRecreateGeometry(const NpShape* npShape) { if(checkPvdDebugFlag()) mMetaDataBinding.releaseAndRecreateGeometry(*mPvdDataStream, *npShape, NpPhysics::getInstance(), mPvd); } void PvdSceneClient::releasePvdInstance(const NpShape* npShape, PxActor& owner) { if(checkPvdDebugFlag()) { PX_PROFILE_ZONE("PVD.releasePVDInstance", getContextId(mScene)); mMetaDataBinding.destroyInstance(*mPvdDataStream, *npShape, static_cast<PxRigidActor&>(owner)); const PxU32 numMaterials = npShape->getNbMaterials(); PX_ALLOCA(materialPtr, PxMaterial*, numMaterials); npShape->getMaterials(materialPtr, numMaterials); for(PxU32 idx = 0; idx < numMaterials; ++idx) releasePvdInstance(&(static_cast<NpMaterial*>(materialPtr[idx])->mMaterial)); } } /////////////////////////////////////////////////////////////////////////////// void PvdSceneClient::originShift(PxVec3 shift) { mMetaDataBinding.originShift(*mPvdDataStream, &mScene, shift); } void PvdSceneClient::frameStart(PxReal simulateElapsedTime) { PX_PROFILE_ZONE("Basic.pvdFrameStart", mScene.getScScene().getContextId()); if(!mIsConnected) return; mPvdDataStream->flushPvdCommand(); mMetaDataBinding.sendBeginFrame(*mPvdDataStream, &mScene, simulateElapsedTime); } void PvdSceneClient::frameEnd() { PX_PROFILE_ZONE("Basic.pvdFrameEnd", mScene.getScScene().getContextId()); if(!mIsConnected) { if(mPvd) mPvd->flush(); // Even if we aren't connected, we may need to flush buffered events. return; } PxScene* theScene = &mScene; mMetaDataBinding.sendStats(*mPvdDataStream, theScene); // flush our data to the main connection mPvd->flush(); // End the frame *before* we send the dynamic object current data. // This ensures that contacts end up synced with the rest of the system. // Note that contacts were sent much earler in NpScene::fetchResults. mMetaDataBinding.sendEndFrame(*mPvdDataStream, &mScene); if(mPvd->getInstrumentationFlags() & PxPvdInstrumentationFlag::eDEBUG) { PX_PROFILE_ZONE("PVD.sceneUpdate", getContextId(mScene)); PvdVisualizer* vizualizer = NULL; const bool visualizeJoints = getScenePvdFlagsFast() & PxPvdSceneFlag::eTRANSMIT_CONSTRAINTS; if(visualizeJoints) vizualizer = this; mMetaDataBinding.updateDynamicActorsAndArticulations(*mPvdDataStream, theScene, vizualizer); } // frame end moved to update contacts to have them in the previous frame. } /////////////////////////////////////////////////////////////////////////////// void PvdSceneClient::createPvdInstance(const NpAggregate* npAggregate) { if(checkPvdDebugFlag()) { PX_PROFILE_ZONE("PVD.createPVDInstance", getContextId(mScene)); mMetaDataBinding.createInstance(*mPvdDataStream, *npAggregate, mScene); } } void PvdSceneClient::updatePvdProperties(const NpAggregate* npAggregate) { if(checkPvdDebugFlag()) mMetaDataBinding.sendAllProperties(*mPvdDataStream, *npAggregate); } void PvdSceneClient::attachAggregateActor(const NpAggregate* npAggregate, NpActor* actor) { if(checkPvdDebugFlag()) mMetaDataBinding.attachAggregateActor(*mPvdDataStream, *npAggregate, *getPxActor(actor)); } void PvdSceneClient::detachAggregateActor(const NpAggregate* npAggregate, NpActor* actor) { if(checkPvdDebugFlag()) mMetaDataBinding.detachAggregateActor(*mPvdDataStream, *npAggregate, *getPxActor(actor)); } void PvdSceneClient::releasePvdInstance(const NpAggregate* npAggregate) { if(checkPvdDebugFlag()) { PX_PROFILE_ZONE("PVD.releasePVDInstance", getContextId(mScene)); mMetaDataBinding.destroyInstance(*mPvdDataStream, *npAggregate, mScene); } } /////////////////////////////////////////////////////////////////////////////// #if PX_SUPPORT_GPU_PHYSX void PvdSceneClient::createPvdInstance(const NpSoftBody* softBody) { PX_UNUSED(softBody); //Todo } void PvdSceneClient::updatePvdProperties(const NpSoftBody* softBody) { PX_UNUSED(softBody); //Todo } void PvdSceneClient::attachAggregateActor(const NpSoftBody* softBody, NpActor* actor) { PX_UNUSED(softBody); PX_UNUSED(actor); //Todo } void PvdSceneClient::detachAggregateActor(const NpSoftBody* softBody, NpActor* actor) { PX_UNUSED(softBody); PX_UNUSED(actor); //Todo } void PvdSceneClient::releasePvdInstance(const NpSoftBody* softBody) { PX_UNUSED(softBody); //Todo } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void PvdSceneClient::createPvdInstance(const NpFEMCloth* femCloth) { PX_UNUSED(femCloth); //Todo } void PvdSceneClient::updatePvdProperties(const NpFEMCloth* femCloth) { PX_UNUSED(femCloth); //Todo } void PvdSceneClient::attachAggregateActor(const NpFEMCloth* femCloth, NpActor* actor) { PX_UNUSED(femCloth); PX_UNUSED(actor); //Todo } void PvdSceneClient::detachAggregateActor(const NpFEMCloth* femCloth, NpActor* actor) { PX_UNUSED(femCloth); PX_UNUSED(actor); //Todo } void PvdSceneClient::releasePvdInstance(const NpFEMCloth* femCloth) { PX_UNUSED(femCloth); //Todo } /////////////////////////////////////////////////////////////////////////////// void PvdSceneClient::createPvdInstance(const NpPBDParticleSystem* particleSystem) { PX_UNUSED(particleSystem); //Todo } void PvdSceneClient::updatePvdProperties(const NpPBDParticleSystem* particleSystem) { PX_UNUSED(particleSystem); //Todo } void PvdSceneClient::attachAggregateActor(const NpPBDParticleSystem* particleSystem, NpActor* actor) { PX_UNUSED(particleSystem); PX_UNUSED(actor); //Todo } void PvdSceneClient::detachAggregateActor(const NpPBDParticleSystem* particleSystem, NpActor* actor) { PX_UNUSED(particleSystem); PX_UNUSED(actor); //Todo } void PvdSceneClient::releasePvdInstance(const NpPBDParticleSystem* particleSystem) { PX_UNUSED(particleSystem); //Todo } /////////////////////////////////////////////////////////////////////////////// void PvdSceneClient::createPvdInstance(const NpFLIPParticleSystem* particleSystem) { PX_UNUSED(particleSystem); //Todo } void PvdSceneClient::updatePvdProperties(const NpFLIPParticleSystem* particleSystem) { PX_UNUSED(particleSystem); //Todo } void PvdSceneClient::attachAggregateActor(const NpFLIPParticleSystem* particleSystem, NpActor* actor) { PX_UNUSED(particleSystem); PX_UNUSED(actor); //Todo } void PvdSceneClient::detachAggregateActor(const NpFLIPParticleSystem* particleSystem, NpActor* actor) { PX_UNUSED(particleSystem); PX_UNUSED(actor); //Todo } void PvdSceneClient::releasePvdInstance(const NpFLIPParticleSystem* particleSystem) { PX_UNUSED(particleSystem); //Todo } /////////////////////////////////////////////////////////////////////////////// void PvdSceneClient::createPvdInstance(const NpMPMParticleSystem* particleSystem) { PX_UNUSED(particleSystem); //Todo } void PvdSceneClient::updatePvdProperties(const NpMPMParticleSystem* particleSystem) { PX_UNUSED(particleSystem); //Todo } void PvdSceneClient::attachAggregateActor(const NpMPMParticleSystem* particleSystem, NpActor* actor) { PX_UNUSED(particleSystem); PX_UNUSED(actor); //Todo } void PvdSceneClient::detachAggregateActor(const NpMPMParticleSystem* particleSystem, NpActor* actor) { PX_UNUSED(particleSystem); PX_UNUSED(actor); //Todo } void PvdSceneClient::releasePvdInstance(const NpMPMParticleSystem* particleSystem) { PX_UNUSED(particleSystem); //Todo } /////////////////////////////////////////////////////////////////////////////// void PvdSceneClient::createPvdInstance(const NpHairSystem* hairSystem) { PX_UNUSED(hairSystem); //Todo } void PvdSceneClient::updatePvdProperties(const NpHairSystem* hairSystem) { PX_UNUSED(hairSystem); //Todo } void PvdSceneClient::attachAggregateActor(const NpHairSystem* hairSystem, NpActor* actor) { PX_UNUSED(hairSystem); PX_UNUSED(actor); //Todo } void PvdSceneClient::detachAggregateActor(const NpHairSystem* hairSystem, NpActor* actor) { PX_UNUSED(hairSystem); PX_UNUSED(actor); //Todo } void PvdSceneClient::releasePvdInstance(const NpHairSystem* hairSystem) { PX_UNUSED(hairSystem); //Todo } #endif /////////////////////////////////////////////////////////////////////////////// void PvdSceneClient::updateJoints() { if(checkPvdDebugFlag()) { PX_PROFILE_ZONE("PVD.updateJoints", getContextId(mScene)); const bool visualizeJoints = getScenePvdFlagsFast() & PxPvdSceneFlag::eTRANSMIT_CONSTRAINTS; Sc::ConstraintCore*const * constraints = mScene.getScScene().getConstraints(); const PxU32 nbConstraints = mScene.getScScene().getNbConstraints(); PxI64 constraintCount = 0; for(PxU32 i=0; i<nbConstraints; i++) { Sc::ConstraintCore* constraint = constraints[i]; PxPvdUpdateType::Enum updateType = getNpConstraint(constraint)->isDirty() ? PxPvdUpdateType::UPDATE_ALL_PROPERTIES : PxPvdUpdateType::UPDATE_SIM_PROPERTIES; updateConstraint(*constraint, updateType); PxConstraintConnector* conn = constraint->getPxConnector(); // visualization is updated here { PxU32 typeId = 0; void* joint = NULL; if(conn) joint = conn->getExternalReference(typeId); // visualize: Sc::ConstraintSim* sim = constraint->getSim(); if(visualizeJoints && sim && sim->getConstantsLL() && joint && constraint->getVisualize()) { Sc::BodySim* b0 = sim->getBody(0); Sc::BodySim* b1 = sim->getBody(1); PxTransform t0 = b0 ? b0->getBody2World() : PxTransform(PxIdentity); PxTransform t1 = b1 ? b1->getBody2World() : PxTransform(PxIdentity); PvdConstraintVisualizer viz(joint, *mUserRender); (*constraint->getVisualize())(viz, sim->getConstantsLL(), t0, t1, 0xffffFFFF); } } ++constraintCount; } mUserRender->flushRenderEvents(); } } void PvdSceneClient::updateContacts() { if(!checkPvdDebugFlag()) return; PX_PROFILE_ZONE("PVD.updateContacts", getContextId(mScene)); // if contacts are disabled, send empty array and return const PxScene* theScene = &mScene; if(!(getScenePvdFlagsFast() & PxPvdSceneFlag::eTRANSMIT_CONTACTS)) { mMetaDataBinding.sendContacts(*mPvdDataStream, *theScene); return; } PxsContactManagerOutputIterator outputIter; Sc::ContactIterator contactIter; mScene.getScScene().initContactsIterator(contactIter, outputIter); Sc::ContactIterator::Pair* pair; Sc::Contact* contact; PxArray<Sc::Contact> contacts; while ((pair = contactIter.getNextPair()) != NULL) { while ((contact = pair->getNextContact()) != NULL) contacts.pushBack(*contact); } mMetaDataBinding.sendContacts(*mPvdDataStream, *theScene, contacts); } void PvdSceneClient::updateSceneQueries() { if(checkPvdDebugFlag() && (getScenePvdFlagsFast() & PxPvdSceneFlag::eTRANSMIT_SCENEQUERIES)) mMetaDataBinding.sendSceneQueries(*mPvdDataStream, mScene, mPvd); } void PvdSceneClient::visualize(PxArticulationLink& link) { #if PX_ENABLE_DEBUG_VISUALIZATION NpArticulationLink& npLink = static_cast<NpArticulationLink&>(link); const void* itemId = npLink.getInboundJoint(); if(itemId && mUserRender) { PvdConstraintVisualizer viz(itemId, *mUserRender); npLink.visualizeJoint(viz); } #else PX_CATCH_UNDEFINED_ENABLE_DEBUG_VISUALIZATION PX_UNUSED(link); #endif } void PvdSceneClient::visualize(const PxRenderBuffer& debugRenderable) { if(mUserRender) { // PT: I think the mUserRender object can contain extra data (including things coming from the user), because the various // draw functions are exposed e.g. in PxPvdSceneClient.h. So I suppose we have to keep the render buffer around regardless // of the connection flags. Thus I only skip the "drawRenderbuffer" call, for minimal intrusion into this file. if(checkPvdDebugFlag()) { mUserRender->drawRenderbuffer( reinterpret_cast<const PxDebugPoint*>(debugRenderable.getPoints()), debugRenderable.getNbPoints(), reinterpret_cast<const PxDebugLine*>(debugRenderable.getLines()), debugRenderable.getNbLines(), reinterpret_cast<const PxDebugTriangle*>(debugRenderable.getTriangles()), debugRenderable.getNbTriangles()); } mUserRender->flushRenderEvents(); } } #endif
37,936
C++
28.115119
158
0.721926
NVIDIA-Omniverse/PhysX/physx/source/physx/src/NpArticulationSensor.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #include "PxArticulationReducedCoordinate.h" #include "foundation/PxUserAllocated.h" #include "foundation/PxMemory.h" #include "ScArticulationSensor.h" #include "NpBase.h" #ifndef NP_ARTICULATION_SENSOR_H #define NP_ARTICULATION_SENSOR_H namespace physx { typedef PxU32 ArticulationSensorHandle; class NpArticulationSensor : public PxArticulationSensor, public NpBase { public: // PX_SERIALIZATION NpArticulationSensor(PxBaseFlags baseFlags) : PxArticulationSensor(baseFlags), NpBase(PxEmpty), mCore(PxEmpty) {} void preExportDataReset() {} virtual void exportExtraData(PxSerializationContext& ) {} void importExtraData(PxDeserializationContext& ) {} void resolveReferences(PxDeserializationContext& ); virtual void requiresObjects(PxProcessPxBaseCallback&) {} virtual bool isSubordinate() const { return true; } static NpArticulationSensor* createObject(PxU8*& address, PxDeserializationContext& context); static void getBinaryMetaData(PxOutputStream& stream); //~PX_SERIALIZATION NpArticulationSensor(PxArticulationLink* link, const PxTransform& relativePose); virtual ~NpArticulationSensor() {} virtual void release(); virtual PxSpatialForce getForces() const; virtual PxTransform getRelativePose() const; virtual void setRelativePose(const PxTransform&); virtual PxArticulationLink* getLink() const; virtual PxU32 getIndex() const; virtual PxArticulationReducedCoordinate* getArticulation() const; virtual PxArticulationSensorFlags getFlags() const; virtual void setFlag(PxArticulationSensorFlag::Enum flag, bool enabled); PX_FORCE_INLINE Sc::ArticulationSensorCore& getSensorCore() { return mCore; } PX_FORCE_INLINE const Sc::ArticulationSensorCore& getSensorCore() const { return mCore; } PX_FORCE_INLINE ArticulationSensorHandle getHandle() { return mHandle; } PX_FORCE_INLINE void setHandle(ArticulationSensorHandle handle) { mHandle = handle; } private: PxArticulationLink* mLink; Sc::ArticulationSensorCore mCore; ArticulationSensorHandle mHandle; }; } #endif //NP_ARTICULATION_SENSOR_H
3,817
C
43.395348
96
0.771024
NVIDIA-Omniverse/PhysX/physx/source/physx/src/PvdPhysicsClient.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PVD_PHYSICS_CLIENT_H #define PVD_PHYSICS_CLIENT_H #if PX_SUPPORT_PVD #include "foundation/PxErrorCallback.h" #include "foundation/PxHashMap.h" #include "PxPvdClient.h" #include "PvdMetaDataPvdBinding.h" #include "NpFactory.h" #include "foundation/PxMutex.h" #include "PsPvd.h" namespace physx { class PxProfileMemoryEventBuffer; namespace Vd { class PvdPhysicsClient : public PvdClient, public PxErrorCallback, public NpFactoryListener, public PxUserAllocated { PX_NOCOPY(PvdPhysicsClient) public: PvdPhysicsClient(PsPvd* pvd); virtual ~PvdPhysicsClient(); bool isConnected() const; void onPvdConnected(); void onPvdDisconnected(); void flush(); physx::pvdsdk::PvdDataStream* getDataStream(); void sendEntireSDK(); void destroyPvdInstance(const PxPhysics* physics); // NpFactoryListener virtual void onMeshFactoryBufferRelease(const PxBase* object, PxType typeID); /// NpFactoryListener // PxErrorCallback void reportError(PxErrorCode::Enum code, const char* message, const char* file, int line); private: void createPvdInstance(const PxTriangleMesh* triMesh); void destroyPvdInstance(const PxTriangleMesh* triMesh); void createPvdInstance(const PxTetrahedronMesh* tetMesh); void destroyPvdInstance(const PxTetrahedronMesh* tetMesh); void createPvdInstance(const PxConvexMesh* convexMesh); void destroyPvdInstance(const PxConvexMesh* convexMesh); void createPvdInstance(const PxHeightField* heightField); void destroyPvdInstance(const PxHeightField* heightField); void createPvdInstance(const PxMaterial* mat); void destroyPvdInstance(const PxMaterial* mat); void updatePvdProperties(const PxMaterial* mat); void createPvdInstance(const PxFEMSoftBodyMaterial* mat); void destroyPvdInstance(const PxFEMSoftBodyMaterial* mat); void updatePvdProperties(const PxFEMSoftBodyMaterial* mat); void createPvdInstance(const PxFEMClothMaterial* mat); void destroyPvdInstance(const PxFEMClothMaterial* mat); void updatePvdProperties(const PxFEMClothMaterial* mat); void createPvdInstance(const PxPBDMaterial* mat); void destroyPvdInstance(const PxPBDMaterial* mat); void updatePvdProperties(const PxPBDMaterial* mat); PsPvd* mPvd; PvdDataStream* mPvdDataStream; PvdMetaDataBinding mMetaDataBinding; bool mIsConnected; }; } // namespace Vd } // namespace physx #endif // PX_SUPPORT_PVD #endif // PVD_PHYSICS_CLIENT_H
4,071
C
37.056074
115
0.787276
NVIDIA-Omniverse/PhysX/physx/source/physx/src/NpFEMCloth.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #include "foundation/PxPreprocessor.h" #if PX_SUPPORT_GPU_PHYSX #include "NpFEMCloth.h" #include "NpCheck.h" #include "NpScene.h" #include "NpShape.h" #include "geometry/PxTriangleMesh.h" #include "geometry/PxTriangleMeshGeometry.h" #include "PxPhysXGpu.h" #include "PxvGlobals.h" #include "GuTriangleMesh.h" #include "NpRigidDynamic.h" #include "NpRigidStatic.h" #include "NpArticulationLink.h" #include "GuTriangleMesh.h" #include "ScFEMClothSim.h" using namespace physx; namespace physx { #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION NpFEMCloth::NpFEMCloth(PxCudaContextManager& cudaContextManager) : NpActorTemplate(PxConcreteType::eFEM_CLOTH, PxBaseFlag::eOWNS_MEMORY | PxBaseFlag::eIS_RELEASABLE, NpType::eFEMCLOTH), mShape(NULL), mCudaContextManager(&cudaContextManager) { } NpFEMCloth::NpFEMCloth(PxBaseFlags baseFlags, PxCudaContextManager& cudaContextManager) : NpActorTemplate(baseFlags), mShape(NULL), mCudaContextManager(&cudaContextManager) { } PxBounds3 NpFEMCloth::getWorldBounds(float inflation) const { NP_READ_CHECK(getNpScene()); if (!getNpScene()) { PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "Querying bounds of a PxFEMCloth which is not part of a PxScene is not supported."); return PxBounds3::empty(); } const Sc::FEMClothSim* sim = mCore.getSim(); PX_ASSERT(sim); PX_SIMD_GUARD; const PxBounds3 bounds = sim->getBounds(); PX_ASSERT(bounds.isValid()); // PT: unfortunately we can't just scale the min/max vectors, we need to go through center/extents. const PxVec3 center = bounds.getCenter(); const PxVec3 inflatedExtents = bounds.getExtents() * inflation; return PxBounds3::centerExtents(center, inflatedExtents); } void NpFEMCloth::setFEMClothFlag(PxFEMClothFlag::Enum flag, bool val) { PxFEMClothFlags flags = mCore.getFlags(); if (val) flags.raise(flag); else flags.clear(flag); mCore.setFlags(flags); } void NpFEMCloth::setFEMClothFlags(PxFEMClothFlags flags) { mCore.setFlags(flags); } PxFEMClothFlags NpFEMCloth::getFEMClothFlag() const { return mCore.getFlags(); } #if 0 // disabled until future use. void NpFEMCloth::setDrag(const PxReal drag) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxFEMCloth::setDrag() not allowed while simulation is running. Call will be ignored.") mCore.setDrag(drag); UPDATE_PVD_PROPERTY } PxReal NpFEMCloth::getDrag() const { return mCore.getDrag(); } void NpFEMCloth::setLift(const PxReal lift) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxFEMCloth::setLift() not allowed while simulation is running. Call will be ignored.") mCore.setLift(lift); UPDATE_PVD_PROPERTY } PxReal NpFEMCloth::getLift() const { return mCore.getLift(); } void NpFEMCloth::setWind(const PxVec3& wind) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxFEMCloth::setWind() not allowed while simulation is running. Call will be ignored.") mCore.setWind(wind); UPDATE_PVD_PROPERTY } PxVec3 NpFEMCloth::getWind() const { return mCore.getWind(); } void NpFEMCloth::setAirDensity(const PxReal airDensity) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxFEMCloth::setAirDensity() not allowed while simulation is running. Call will be ignored.") mCore.setAirDensity(airDensity); UPDATE_PVD_PROPERTY } float NpFEMCloth::getAirDensity() const { return mCore.getAirDensity(); } void NpFEMCloth::setBendingActivationAngle(const PxReal angle) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxFEMCloth::setBendingActivationAngle() not allowed while simulation is running. Call will be ignored.") mCore.setBendingActivationAngle(angle); UPDATE_PVD_PROPERTY } PxReal NpFEMCloth::getBendingActivationAngle() const { return mCore.getBendingActivationAngle(); } #endif void NpFEMCloth::setParameter(const PxFEMParameters& paramters) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxFEMCloth::setParameter() not allowed while simulation is running. Call will be ignored.") mCore.setParameter(paramters); UPDATE_PVD_PROPERTY } PxFEMParameters NpFEMCloth::getParameter() const { NP_READ_CHECK(getNpScene()); return mCore.getParameter(); } void NpFEMCloth::setBendingScales(const PxReal* const bendingScales, PxU32 nbElements) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxFEMCloth::setBendingScales() not allowed while simulation is running. Call will be ignored.") mCore.setBendingScales(bendingScales, nbElements); UPDATE_PVD_PROPERTY } const PxReal* NpFEMCloth::getBendingScales() const { NP_READ_CHECK(getNpScene()); return mCore.getBendingScales(); } PxU32 NpFEMCloth::getNbBendingScales() const { NP_READ_CHECK(getNpScene()); return mCore.getNbBendingScales(); } void NpFEMCloth::setMaxVelocity(const PxReal v) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxFEMCloth::setMaxVelocity() not allowed while simulation is running. Call will be ignored.") mCore.setMaxVelocity(v); UPDATE_PVD_PROPERTY } PxReal NpFEMCloth::getMaxVelocity() const { return mCore.getMaxVelocity(); } void NpFEMCloth::setMaxDepenetrationVelocity(const PxReal v) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxFEMCloth::setMaxDepenetrationVelocity() not allowed while simulation is running. Call will be ignored.") mCore.setMaxDepenetrationVelocity(v); UPDATE_PVD_PROPERTY } PxReal NpFEMCloth::getMaxDepenetrationVelocity() const { return mCore.getMaxDepenetrationVelocity(); } void NpFEMCloth::setNbCollisionPairUpdatesPerTimestep(const PxU32 frequency) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxFEMCloth::setNbCollisionPairUpdatesPerTimestep() not allowed while simulation is running. Call will be ignored.") mCore.setNbCollisionPairUpdatesPerTimestep(frequency); UPDATE_PVD_PROPERTY } PxU32 NpFEMCloth::getNbCollisionPairUpdatesPerTimestep() const { return mCore.getNbCollisionPairUpdatesPerTimestep(); } void NpFEMCloth::setNbCollisionSubsteps(const PxU32 frequency) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxFEMCloth::setNbCollisionSubsteps() not allowed while simulation is running. Call will be ignored.") mCore.setNbCollisionSubsteps(frequency); UPDATE_PVD_PROPERTY } PxU32 NpFEMCloth::getNbCollisionSubsteps() const { return mCore.getNbCollisionSubsteps(); } PxVec4* NpFEMCloth::getPositionInvMassBufferD() { PX_CHECK_AND_RETURN_NULL(mShape != NULL, " NpFEMCloth::getPositionInvMassBufferD: FEM cloth does not have a shape, attach shape first."); Dy::FEMClothCore& core = mCore.getCore(); return core.mPositionInvMass; } PxVec4* NpFEMCloth::getVelocityBufferD() { PX_CHECK_AND_RETURN_NULL(mShape != NULL, " NpFEMCloth::getVelocityBufferD: FEM cloth does not have a shape, attach shape first."); Dy::FEMClothCore& core = mCore.getCore(); return core.mVelocity; } PxVec4* NpFEMCloth::getRestPositionBufferD() { PX_CHECK_AND_RETURN_NULL(mShape != NULL, " NpFEMCloth::getRestPositionBufferD: FEM cloth does not have a shape, attach shape first."); Dy::FEMClothCore& core = mCore.getCore(); return core.mRestPosition; } void NpFEMCloth::markDirty(PxFEMClothDataFlags flags) { NP_WRITE_CHECK(getNpScene()); Dy::FEMClothCore& core = mCore.getCore(); core.mDirtyFlags |= flags; } PxCudaContextManager* NpFEMCloth::getCudaContextManager() const { return mCudaContextManager; } void NpFEMCloth::setCudaContextManager(PxCudaContextManager* cudaContextManager) { mCudaContextManager = cudaContextManager; } void NpFEMCloth::setSolverIterationCounts(PxU32 positionIters) // maybe use PxU16? { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_AND_RETURN(positionIters > 0, "NpFEMCloth::setSolverIterationCounts: positionIters must be more than zero!"); PX_CHECK_AND_RETURN(positionIters <= 255, "NpFEMCloth::setSolverIterationCounts: positionIters must be no greater than 255!"); //PX_CHECK_AND_RETURN(velocityIters > 0, "NpFEMCloth::setSolverIterationCounts: velocityIters must be more than zero!"); //PX_CHECK_AND_RETURN(velocityIters <= 255, "NpFEMCloth::setSolverIterationCounts: velocityIters must be no greater than 255!"); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxFEMCloth::setSolverIterationCounts() not allowed while simulation is running. Call will be ignored.") //mCore.setSolverIterationCounts((velocityIters & 0xff) << 8 | (positionIters & 0xff)); mCore.setSolverIterationCounts(positionIters & 0xff); } void NpFEMCloth::getSolverIterationCounts(PxU32& positionIters) const { NP_READ_CHECK(getNpScene()); PxU16 x = mCore.getSolverIterationCounts(); //velocityIters = PxU32(x >> 8); positionIters = PxU32(x & 0xff); } PxShape* NpFEMCloth::getShape() { return mShape; } bool NpFEMCloth::attachShape(PxShape& shape) { NpShape* npShape = static_cast<NpShape*>(&shape); PX_CHECK_AND_RETURN_NULL(npShape->getGeometryTypeFast() == PxGeometryType::eTRIANGLEMESH, "NpFEMCloth::attachShape: Geometry type must be triangle mesh geometry"); PX_CHECK_AND_RETURN_NULL(mShape == NULL, "NpFEMCloth::attachShape: FEM-cloth can just have one shape"); PX_CHECK_AND_RETURN_NULL(shape.isExclusive(), "NpFEMCloth::attachShape: shape must be exclusive"); Dy::FEMClothCore& core = mCore.getCore(); PX_CHECK_AND_RETURN_NULL(core.mPositionInvMass == NULL, "NpFEMCloth::attachShape: mPositionInvMass already exists, overwrite not allowed, call detachShape first"); PX_CHECK_AND_RETURN_NULL(core.mVelocity == NULL, "NpFEMCloth::attachShape: mClothVelocity already exists, overwrite not allowed, call detachShape first"); PX_CHECK_AND_RETURN_NULL(core.mRestPosition == NULL, "NpFEMCloth::attachShape: mClothRestPosition already exists, overwrite not allowed, call detachShape first"); const PxTriangleMeshGeometry& geom = static_cast<const PxTriangleMeshGeometry&>(npShape->getGeometry()); Gu::TriangleMesh* guMesh = static_cast<Gu::TriangleMesh*>(geom.triangleMesh); #if PX_CHECKED const PxU32 triangleReference = guMesh->getNbTriangleReferences(); PX_CHECK_AND_RETURN_NULL(triangleReference > 0, "NpFEMCloth::attachShape: cloth triangle mesh has cooked with eENABLE_VERT_MAPPING"); #endif mShape = npShape; PX_ASSERT(shape.getActor() == NULL); npShape->onActorAttach(*this); updateMaterials(); const PxU32 numVerts = guMesh->getNbVerticesFast(); core.mPositionInvMass = PX_DEVICE_ALLOC_T(PxVec4, mCudaContextManager, numVerts); core.mVelocity = PX_DEVICE_ALLOC_T(PxVec4, mCudaContextManager, numVerts); core.mRestPosition = PX_DEVICE_ALLOC_T(PxVec4, mCudaContextManager, numVerts); return true; } void NpFEMCloth::addRigidFilter(PxRigidActor* actor, PxU32 vertId) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(getNpScene() != NULL, "NpFEMCloth::addRigidFilter: Cloth must be inserted into the scene."); PX_CHECK_AND_RETURN((actor == NULL || actor->getScene() != NULL), "NpFEMCloth::addRigidFilter: actor must be inserted into the scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "NpFEMCloth::addRigidFilter: Illegal to call while simulation is running."); Sc::BodyCore* core = getBodyCore(actor); return mCore.addRigidFilter(core, vertId); } void NpFEMCloth::removeRigidFilter(PxRigidActor* actor, PxU32 vertId) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(getNpScene() != NULL, "NpFEMCloth::removeRigidFilter: cloth must be inserted into the scene."); PX_CHECK_AND_RETURN((actor == NULL || actor->getScene() != NULL), "NpFEMCloth::removeRigidFilter: actor must be inserted into the scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "NpFEMCloth::removeRigidFilter: Illegal to call while simulation is running."); Sc::BodyCore* core = getBodyCore(actor); mCore.removeRigidFilter(core, vertId); } PxU32 NpFEMCloth::addRigidAttachment(PxRigidActor* actor, PxU32 vertId, const PxVec3& actorSpacePose, PxConeLimitedConstraint* constraint) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN_VAL(getNpScene() != NULL, "NpFEMCloth::addRigidAttachment: cloth must be inserted into the scene.", 0xFFFFFFFF); PX_CHECK_AND_RETURN_VAL((actor == NULL || actor->getScene() != NULL), "NpFEMCloth::addRigidAttachment: actor must be inserted into the scene.", 0xFFFFFFFF); PX_CHECK_AND_RETURN_VAL(constraint == NULL || constraint->isValid(), "NpFEMCloth::addRigidAttachment: PxConeLimitedConstraint needs to be valid if specified.", 0xFFFFFFFF); PX_CHECK_SCENE_API_WRITE_FORBIDDEN_AND_RETURN_VAL(getNpScene(), "NpFEMCloth::addRigidAttachment: Illegal to call while simulation is running.", 0xFFFFFFFF); Sc::BodyCore* core = getBodyCore(actor); PxVec3 aPose = actorSpacePose; if(actor && actor->getConcreteType()==PxConcreteType::eRIGID_STATIC) { NpRigidStatic* stat = static_cast<NpRigidStatic*>(actor); aPose = stat->getGlobalPose().transform(aPose); } return mCore.addRigidAttachment(core, vertId, aPose, constraint); } void NpFEMCloth::removeRigidAttachment(PxRigidActor* actor, PxU32 handle) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(getNpScene() != NULL, "NpFEMCloth::removeRigidAttachment: cloth must be inserted into the scene."); PX_CHECK_AND_RETURN((actor == NULL || actor->getScene() != NULL), "NpFEMCloth::removeRigidAttachment: actor must be inserted into the scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "NpFEMCloth::removeRigidAttachment: Illegal to call while simulation is running."); Sc::BodyCore* core = getBodyCore(actor); mCore.removeRigidAttachment(core, handle); } void NpFEMCloth::addTriRigidFilter(PxRigidActor* actor, PxU32 triangleIdx) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(getNpScene() != NULL, "NpFEMCloth::addTriRigidFilter: cloth must be inserted into the scene."); PX_CHECK_AND_RETURN((actor == NULL || actor->getScene() != NULL), "NpFEMCloth::addTriRigidFilter: actor must be inserted into the scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "NpFEMCloth::addTriRigidFilter: Illegal to call while simulation is running."); Sc::BodyCore* core = getBodyCore(actor); return mCore.addTriRigidFilter(core, triangleIdx); } void NpFEMCloth::removeTriRigidFilter(PxRigidActor* actor, PxU32 triangleId) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(getNpScene() != NULL, "NpFEMCloth::releaseTriRigidAttachment: cloth must be inserted into the scene."); PX_CHECK_AND_RETURN((actor == NULL || actor->getScene() != NULL), "NpFEMCloth::releaseTriRigidAttachment: actor must be inserted into the scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "NpFEMCloth::releaseTriRigidAttachment: Illegal to call while simulation is running."); Sc::BodyCore* core = getBodyCore(actor); mCore.removeTriRigidFilter(core, triangleId); } PxU32 NpFEMCloth::addTriRigidAttachment(PxRigidActor* actor, PxU32 triangleIdx, const PxVec4& barycentric, const PxVec3& actorSpacePose, PxConeLimitedConstraint* constraint) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN_VAL(getNpScene() != NULL, "NpFEMCloth::addTriRigidAttachment: cloth must be inserted into the scene.", 0xFFFFFFFF); PX_CHECK_AND_RETURN_VAL((actor == NULL || actor->getScene() != NULL), "NpFEMCloth::addTriRigidAttachment: actor must be inserted into the scene.", 0xFFFFFFFF); PX_CHECK_AND_RETURN_VAL(constraint == NULL || constraint->isValid(), "NpFEMCloth::addTriRigidAttachment: PxConeLimitedConstraint needs to be valid if specified.", 0xFFFFFFFF); PX_CHECK_SCENE_API_WRITE_FORBIDDEN_AND_RETURN_VAL(getNpScene(), "NpFEMCloth::addTriRigidAttachment: Illegal to call while simulation is running.", 0xFFFFFFFF); Sc::BodyCore* core = getBodyCore(actor); PxVec3 aPose = actorSpacePose; if(actor && actor->getConcreteType()==PxConcreteType::eRIGID_STATIC) { NpRigidStatic* stat = static_cast<NpRigidStatic*>(actor); aPose = stat->getGlobalPose().transform(aPose); } return mCore.addTriRigidAttachment(core, triangleIdx, barycentric, aPose, constraint); } void NpFEMCloth::removeTriRigidAttachment(PxRigidActor* actor, PxU32 handle) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(getNpScene() != NULL, "NpFEMCloth::releaseTriRigidAttachment: cloth must be inserted into the scene."); PX_CHECK_AND_RETURN((actor == NULL || actor->getScene() != NULL), "NpFEMCloth::releaseTriRigidAttachment: actor must be inserted into the scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "NpFEMCloth::releaseTriRigidAttachment: Illegal to call while simulation is running."); Sc::BodyCore* core = getBodyCore(actor); mCore.removeTriRigidAttachment(core, handle); } void NpFEMCloth::addClothFilter(PxFEMCloth* otherCloth, PxU32 otherTriIdx, PxU32 triIdx) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(getNpScene() != NULL, "NpFEMCloth::addClothAttachment: cloth must be inserted into the scene."); PX_CHECK_AND_RETURN((otherCloth == NULL || otherCloth->getScene() != NULL), "NpFEMCloth::addClothFilter: actor must be inserted into the scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "NpFEMCloth::addClothFilter: Illegal to call while simulation is running."); NpFEMCloth* dyn = static_cast<NpFEMCloth*>(otherCloth); Sc::FEMClothCore* otherCore = &dyn->getCore(); return mCore.addClothFilter(otherCore, otherTriIdx, triIdx); } void NpFEMCloth::removeClothFilter(PxFEMCloth* otherCloth, PxU32 otherTriIdx, PxU32 triIdx) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(otherCloth != NULL, "NpFEMCloth::removeClothFilter: actor must not be null"); PX_CHECK_AND_RETURN(getNpScene() != NULL, "NpFEMCloth::removeClothFilter: cloth must be inserted into the scene."); PX_CHECK_AND_RETURN(otherCloth->getScene() != NULL, "NpFEMCloth::removeClothFilter: actor must be inserted into the scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "NpFEMCloth::removeClothFilter: Illegal to call while simulation is running."); NpFEMCloth* dyn = static_cast<NpFEMCloth*>(otherCloth); Sc::FEMClothCore* otherCore = &dyn->getCore(); mCore.removeClothFilter(otherCore, otherTriIdx, triIdx); } PxU32 NpFEMCloth::addClothAttachment(PxFEMCloth* otherCloth, PxU32 otherTriIdx, const PxVec4& otherTriBarycentric, PxU32 triIdx, const PxVec4& triBarycentric) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN_VAL(getNpScene() != NULL, "NpFEMCloth::addClothAttachment: cloth must be inserted into the scene.", 0xFFFFFFFF); PX_CHECK_AND_RETURN_VAL((otherCloth == NULL || otherCloth->getScene() != NULL), "NpFEMCloth::addClothAttachment: actor must be inserted into the scene.", 0xFFFFFFFF); PX_CHECK_SCENE_API_WRITE_FORBIDDEN_AND_RETURN_VAL(getNpScene(), "NpFEMCloth::addClothAttachment: Illegal to call while simulation is running.", 0xFFFFFFFF); NpFEMCloth* dyn = static_cast<NpFEMCloth*>(otherCloth); Sc::FEMClothCore* otherCore = &dyn->getCore(); return mCore.addClothAttachment(otherCore, otherTriIdx, otherTriBarycentric, triIdx, triBarycentric); } void NpFEMCloth::removeClothAttachment(PxFEMCloth* otherCloth, PxU32 handle) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(otherCloth != NULL, "NpFEMCloth::releaseClothAttachment: actor must not be null"); PX_CHECK_AND_RETURN(getNpScene() != NULL, "NpFEMCloth::releaseClothAttachment: cloth must be inserted into the scene."); PX_CHECK_AND_RETURN(otherCloth->getScene() != NULL, "NpFEMCloth::releaseClothAttachment: actor must be inserted into the scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "NpFEMCloth::releaseClothAttachment: Illegal to call while simulation is running."); NpFEMCloth* dyn = static_cast<NpFEMCloth*>(otherCloth); Sc::FEMClothCore* otherCore = &dyn->getCore(); mCore.removeClothAttachment(otherCore, handle); } void NpFEMCloth::detachShape() { Dy::FEMClothCore& core = mCore.getCore(); if (core.mPositionInvMass) { PX_DEVICE_FREE(mCudaContextManager, core.mPositionInvMass); core.mPositionInvMass = NULL; } if (core.mVelocity) { PX_DEVICE_FREE(mCudaContextManager, core.mVelocity); core.mVelocity = NULL; } if (core.mRestPosition) { PX_DEVICE_FREE(mCudaContextManager, core.mRestPosition); core.mRestPosition = NULL; } if (mShape) mShape->onActorDetach(); mShape = NULL; } void NpFEMCloth::release() { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); if (npScene) { npScene->scRemoveFEMCloth(*this); npScene->removeFromFEMClothList(*this); } detachShape(); PX_ASSERT(!isAPIWriteForbidden()); NpDestroyFEMCloth(this); } void NpFEMCloth::setName(const char* debugName) { NP_WRITE_CHECK(getNpScene()); mName = debugName; } const char* NpFEMCloth::getName() const { NP_READ_CHECK(getNpScene()); return mName; } bool NpFEMCloth::isSleeping() const { Sc::FEMClothSim* sim = mCore.getSim(); if (sim) { return sim->isSleeping(); } return true; } void NpFEMCloth::updateMaterials() { Dy::FEMClothCore& core = mCore.getCore(); core.clearMaterials(); for (PxU32 i = 0; i < mShape->getNbMaterials(); ++i) { PxFEMClothMaterial* material; mShape->getClothMaterials(&material, 1, i); core.setMaterial(static_cast<NpFEMClothMaterial*>(material)->mMaterial.mMaterialIndex); } } #endif } #endif //PX_SUPPORT_GPU_PHYSX
23,752
C++
34.665165
177
0.745874
NVIDIA-Omniverse/PhysX/physx/source/physx/src/NpSceneQueries.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #include "NpSceneQueries.h" #include "common/PxProfileZone.h" #include "GuBounds.h" #include "CmTransformUtils.h" #include "NpShape.h" #include "NpActor.h" #include "NpRigidStatic.h" #include "NpRigidDynamic.h" #include "NpArticulationLink.h" #include "GuActorShapeMap.h" using namespace physx; using namespace Sq; using namespace Gu; #if PX_SUPPORT_PVD #include "NpPvdSceneQueryCollector.h" #endif PX_IMPLEMENT_OUTPUT_ERROR static PX_FORCE_INLINE NpShape* getShapeFromPayload(const PrunerPayload& payload) { return reinterpret_cast<NpShape*>(payload.data[0]); } static PX_FORCE_INLINE NpActor* getActorFromPayload(const PrunerPayload& payload) { return reinterpret_cast<NpActor*>(payload.data[1]); } /////////////////////////////////////////////////////////////////////////////// static PX_FORCE_INLINE ActorShapeData createActorShapeData(PrunerData data, PrunerCompoundId id) { return (ActorShapeData(id) << 32) | ActorShapeData(data); } static PX_FORCE_INLINE PrunerData getPrunerData(ActorShapeData data) { return PrunerData(data); } static PX_FORCE_INLINE PrunerCompoundId getCompoundID(ActorShapeData data) { return PrunerCompoundId(data >> 32); } /////////////////////////////////////////////////////////////////////////////// namespace { class NpSqAdapter : public QueryAdapter { public: NpSqAdapter() {} virtual ~NpSqAdapter() {} // Adapter virtual const PxGeometry& getGeometry(const PrunerPayload& payload) const; //~Adapter // QueryAdapter virtual PrunerHandle findPrunerHandle(const PxQueryCache& cache, PrunerCompoundId& compoundId, PxU32& prunerIndex) const; virtual void getFilterData(const PrunerPayload& payload, PxFilterData& filterData) const; virtual void getActorShape(const PrunerPayload& payload, PxActorShape& actorShape) const; //~QueryAdapter ActorShapeMap mDatabase; }; } PrunerHandle NpSqAdapter::findPrunerHandle(const PxQueryCache& cache, PrunerCompoundId& compoundId, PxU32& prunerIndex) const { const NpActor& npActor = NpActor::getFromPxActor(*cache.actor); const PxU32 actorIndex = npActor.getBaseIndex(); PX_ASSERT(actorIndex!=NP_UNUSED_BASE_INDEX); const ActorShapeData actorShapeData = mDatabase.find(actorIndex, &npActor, static_cast<NpShape*>(cache.shape)); const PrunerData prunerData = getPrunerData(actorShapeData); compoundId = getCompoundID(actorShapeData); prunerIndex = getPrunerIndex(prunerData); return getPrunerHandle(prunerData); } void NpSqAdapter::getFilterData(const PrunerPayload& payload, PxFilterData& filterData) const { NpShape* npShape = getShapeFromPayload(payload); filterData = npShape->getQueryFilterData(); } void NpSqAdapter::getActorShape(const PrunerPayload& payload, PxActorShape& actorShape) const { NpShape* npShape = getShapeFromPayload(payload); NpActor* npActor = getActorFromPayload(payload); actorShape.actor = static_cast<PxRigidActor*>(static_cast<const Sc::RigidCore&>(npActor->getActorCore()).getPxActor()); actorShape.shape = npShape; PX_ASSERT(actorShape.shape == npShape->getCore().getPxShape()); } const PxGeometry& NpSqAdapter::getGeometry(const PrunerPayload& payload) const { NpShape* npShape = getShapeFromPayload(payload); return npShape->getCore().getGeometry(); } #if PX_SUPPORT_PVD bool NpSceneQueries::transmitSceneQueries() { if(!mPVDClient) return false; if(!(mPVDClient->checkPvdDebugFlag() && (mPVDClient->getScenePvdFlagsFast() & PxPvdSceneFlag::eTRANSMIT_SCENEQUERIES))) return false; return true; } void NpSceneQueries::raycast(const PxVec3& origin, const PxVec3& unitDir, PxReal distance, const PxRaycastHit* hit, PxU32 hitsNum, const PxQueryFilterData& filterData, bool multipleHits) { mSingleSqCollector.raycast(origin, unitDir, distance, hit, hitsNum, filterData, multipleHits); } void NpSceneQueries::sweep(const PxGeometry& geometry, const PxTransform& pose, const PxVec3& unitDir, PxReal distance, const PxSweepHit* hit, PxU32 hitsNum, const PxQueryFilterData& filterData, bool multipleHits) { mSingleSqCollector.sweep(geometry, pose, unitDir, distance, hit, hitsNum, filterData, multipleHits); } void NpSceneQueries::overlap(const PxGeometry& geometry, const PxTransform& pose, const PxOverlapHit* hit, PxU32 hitsNum, const PxQueryFilterData& filterData) { mSingleSqCollector.overlapMultiple(geometry, pose, hit, hitsNum, filterData); } #endif static PX_FORCE_INLINE void setPayload(PrunerPayload& pp, const NpShape* npShape, const NpActor* npActor) { pp.data[0] = size_t(npShape); pp.data[1] = size_t(npActor); } static PX_FORCE_INLINE bool isDynamicActor(const PxRigidActor& actor) { const PxType actorType = actor.getConcreteType(); return actorType != PxConcreteType::eRIGID_STATIC; } namespace { struct DatabaseCleaner : PrunerPayloadRemovalCallback { DatabaseCleaner(NpSqAdapter& adapter) : mAdapter(adapter){} virtual void invoke(PxU32 nbRemoved, const PrunerPayload* removed) { PxU32 actorIndex = NP_UNUSED_BASE_INDEX; const NpActor* cachedActor = NULL; while(nbRemoved--) { const PrunerPayload& payload = *removed++; const NpActor* npActor = getActorFromPayload(payload); if(npActor!=cachedActor) { actorIndex = npActor->getBaseIndex(); cachedActor = npActor; } PX_ASSERT(actorIndex!=NP_UNUSED_BASE_INDEX); bool status = mAdapter.mDatabase.remove(actorIndex, npActor, getShapeFromPayload(payload), NULL); PX_ASSERT(status); PX_UNUSED(status); } } NpSqAdapter& mAdapter; PX_NOCOPY(DatabaseCleaner) }; } namespace { class InternalPxSQ : public PxSceneQuerySystem, public PxUserAllocated { public: InternalPxSQ(const PxSceneDesc& desc, PVDCapture* pvd, PxU64 contextID, Pruner* staticPruner, Pruner* dynamicPruner) : mQueries(pvd, contextID, staticPruner, dynamicPruner, desc.dynamicTreeRebuildRateHint, SQ_PRUNER_EPSILON, desc.limits, mAdapter), mUpdateMode (desc.sceneQueryUpdateMode), mRefCount (1) {} virtual ~InternalPxSQ(){} PX_FORCE_INLINE Sq::PrunerManager& SQ() { return mQueries.mSQManager; } PX_FORCE_INLINE const Sq::PrunerManager& SQ() const { return mQueries.mSQManager; } virtual void release() { mRefCount--; if(!mRefCount) PX_DELETE_THIS; } virtual void acquireReference() { mRefCount++; } virtual void preallocate(PxU32 prunerIndex, PxU32 nbShapes) { SQ().preallocate(prunerIndex, nbShapes); } // PT: TODO: returning PxSQShapeHandle means we have to store them in PhysX, inside the shape manager's mSceneQueryData array. But if we'd change the API here // and also pass the actor/shape couple instead of cached PxSQShapeHandle to functions like removeSQShape, it would simplify the internal PhysX code and truly // decouple the SQ parts from the rest. It is unclear what the consequences would be on performance: on one hand the PxSQ implementation would need a // hashmap or something to remap actor/shape to the SQ data, on the other hand the current code for that in PhysX is only fast for non-shared shapes. // (see findSceneQueryData) // // Another appealing side-effect here is that there probably wouldn't be a "compound ID" anymore: we just pass the actor/shape couple and it's up to // the implementation to know that this actor was added "as a compound" or not. Again, consequences on the code are unknown. We might have to just try. // // It might become quite tedious for the sync function though, since that one caches *PxSQPrunerHandles*. We don't want to do the "ref finding" equivalent each // frame for each shape, so some kind of cache is needed. That probably means these cached items must appear and be handled on the PhysX/internal side of // the API. That being said and as noted already in another part of the code: // PT: TODO: this is similar to findPrunerData in QueryAdapter. Maybe we could unify these. // => so the ref-finding code could stay, and just reuse findPrunerData (like the query cache). It wouldn't fully decouple the internal PhysX code from SQ, // since we'd still store an array of "PrunerData" internally. *BUT* we could still drop mSceneQueryData. So, still worth trying. // // The nail in the coffin for this idea though is that we still need to provide an internal implementation of PxSQ, and that one does use mSceneQueryData. // So we're struck with this array, unless we decide that there is NO internal implementation, and it's all moved to Extensions all the time. // // If we move the implementation to Extension, suddenly we need to link to SceneQuery.lib, which was not the case previously. At this point it becomes // appealing to just move the Sq code to Gu: it solves the link errors, we could finally include it from Sc, we'd get rid of cross-DLL calls between // Sq and Gu, etc virtual void addSQShape( const PxRigidActor& actor, const PxShape& shape, const PxBounds3& bounds, const PxTransform& transform, const PxSQCompoundHandle* compoundHandle, bool hasPruningStructure) { const NpShape& npShape = static_cast<const NpShape&>(shape); const NpActor& npActor = NpActor::getFromPxActor(actor); PrunerPayload payload; setPayload(payload, &npShape, &npActor); const PrunerCompoundId pcid = compoundHandle ? PrunerCompoundId(*compoundHandle) : INVALID_COMPOUND_ID; const PrunerData prunerData = SQ().addPrunerShape(payload, isDynamicActor(actor), pcid, bounds, transform, hasPruningStructure); const PxU32 actorIndex = npActor.getBaseIndex(); PX_ASSERT(actorIndex!=NP_UNUSED_BASE_INDEX); mAdapter.mDatabase.add(actorIndex, &npActor, &npShape, createActorShapeData(prunerData, pcid)); } virtual void removeSQShape(const PxRigidActor& actor, const PxShape& shape) { const NpActor& npActor = NpActor::getFromPxActor(actor); const NpShape& npShape = static_cast<const NpShape&>(shape); const PxU32 actorIndex = npActor.getBaseIndex(); PX_ASSERT(actorIndex!=NP_UNUSED_BASE_INDEX); ActorShapeData actorShapeData; mAdapter.mDatabase.remove(actorIndex, &npActor, &npShape, &actorShapeData); const PrunerData data = getPrunerData(actorShapeData); const PrunerCompoundId compoundId = getCompoundID(actorShapeData); SQ().removePrunerShape(compoundId, data, NULL); } virtual void updateSQShape(const PxRigidActor& actor, const PxShape& shape, const PxTransform& transform) { const NpActor& npActor = NpActor::getFromPxActor(actor); const NpShape& npShape = static_cast<const NpShape&>(shape); const PxU32 actorIndex = npActor.getBaseIndex(); PX_ASSERT(actorIndex!=NP_UNUSED_BASE_INDEX); const ActorShapeData actorShapeData = mAdapter.mDatabase.find(actorIndex, &npActor, &npShape); const PrunerData shapeHandle = getPrunerData(actorShapeData); const PrunerCompoundId pcid = getCompoundID(actorShapeData); SQ().markForUpdate(pcid, shapeHandle, transform); } virtual PxSQCompoundHandle addSQCompound(const PxRigidActor& actor, const PxShape** shapes, const PxBVH& pxbvh, const PxTransform* transforms) { const BVH& bvh = static_cast<const BVH&>(pxbvh); const PxU32 numSqShapes = bvh.BVH::getNbBounds(); const NpActor& npActor = NpActor::getFromPxActor(actor); PX_ALLOCA(payloads, PrunerPayload, numSqShapes); for(PxU32 i=0; i<numSqShapes; i++) setPayload(payloads[i], static_cast<const NpShape*>(shapes[i]), &npActor); const PxU32 actorIndex = npActor.getBaseIndex(); PX_ASSERT(actorIndex!=NP_UNUSED_BASE_INDEX); PX_ALLOCA(shapeHandles, PrunerData, numSqShapes); SQ().addCompoundShape(bvh, PrunerCompoundId(actorIndex), actor.getGlobalPose(), shapeHandles, payloads, transforms, isDynamicActor(actor)); for(PxU32 i=0; i<numSqShapes; i++) { // PT: TODO: actorIndex is now redundant! mAdapter.mDatabase.add(actorIndex, &npActor, static_cast<const NpShape*>(shapes[i]), createActorShapeData(shapeHandles[i], actorIndex)); } return PxSQCompoundHandle(actorIndex); } virtual void removeSQCompound(PxSQCompoundHandle compoundHandle) { DatabaseCleaner cleaner(mAdapter); SQ().removeCompoundActor(PrunerCompoundId(compoundHandle), &cleaner); } virtual void updateSQCompound(PxSQCompoundHandle compoundHandle, const PxTransform& compoundTransform) { SQ().updateCompoundActor(PrunerCompoundId(compoundHandle), compoundTransform); } virtual void flushUpdates() { SQ().flushUpdates(); } virtual void flushMemory() { SQ().flushMemory(); } virtual void visualize(PxU32 prunerIndex, PxRenderOutput& out) const { SQ().visualize(prunerIndex, out); } virtual void shiftOrigin(const PxVec3& shift) { SQ().shiftOrigin(shift); } virtual PxSQBuildStepHandle prepareSceneQueryBuildStep(PxU32 prunerIndex) { return SQ().prepareSceneQueriesUpdate(PruningIndex::Enum(prunerIndex)); } virtual void sceneQueryBuildStep(PxSQBuildStepHandle handle) { SQ().sceneQueryBuildStep(handle); } virtual void setDynamicTreeRebuildRateHint(PxU32 dynTreeRebuildRateHint) { SQ().setDynamicTreeRebuildRateHint(dynTreeRebuildRateHint); } virtual PxU32 getDynamicTreeRebuildRateHint() const { return SQ().getDynamicTreeRebuildRateHint(); } virtual void forceRebuildDynamicTree(PxU32 prunerIndex) { SQ().forceRebuildDynamicTree(prunerIndex); } virtual PxSceneQueryUpdateMode::Enum getUpdateMode() const { return mUpdateMode; } virtual void setUpdateMode(PxSceneQueryUpdateMode::Enum mode) { mUpdateMode = mode; } virtual PxU32 getStaticTimestamp() const { return SQ().getStaticTimestamp(); } virtual void finalizeUpdates() { switch(mUpdateMode) { case PxSceneQueryUpdateMode::eBUILD_ENABLED_COMMIT_ENABLED: SQ().afterSync(true, true); break; case PxSceneQueryUpdateMode::eBUILD_ENABLED_COMMIT_DISABLED: SQ().afterSync(true, false); break; case PxSceneQueryUpdateMode::eBUILD_DISABLED_COMMIT_DISABLED: SQ().afterSync(false, false); break; } } virtual void merge(const PxPruningStructure& pxps) { Pruner* staticPruner = SQ().getPruner(PruningIndex::eSTATIC); if(staticPruner) staticPruner->merge(pxps.getStaticMergeData()); Pruner* dynamicPruner = SQ().getPruner(PruningIndex::eDYNAMIC); if(dynamicPruner) dynamicPruner->merge(pxps.getDynamicMergeData()); } virtual bool raycast( const PxVec3& origin, const PxVec3& unitDir, const PxReal distance, PxRaycastCallback& hitCall, PxHitFlags hitFlags, const PxQueryFilterData& filterData, PxQueryFilterCallback* filterCall, const PxQueryCache* cache, PxGeometryQueryFlags flags) const { return mQueries._raycast(origin, unitDir, distance, hitCall, hitFlags, filterData, filterCall, cache, flags); } virtual bool sweep( const PxGeometry& geometry, const PxTransform& pose, const PxVec3& unitDir, const PxReal distance, PxSweepCallback& hitCall, PxHitFlags hitFlags, const PxQueryFilterData& filterData, PxQueryFilterCallback* filterCall, const PxQueryCache* cache, const PxReal inflation, PxGeometryQueryFlags flags) const { return mQueries._sweep(geometry, pose, unitDir, distance, hitCall, hitFlags, filterData, filterCall, cache, inflation, flags); } virtual bool overlap( const PxGeometry& geometry, const PxTransform& transform, PxOverlapCallback& hitCall, const PxQueryFilterData& filterData, PxQueryFilterCallback* filterCall, const PxQueryCache* cache, PxGeometryQueryFlags flags) const { return mQueries._overlap( geometry, transform, hitCall, filterData, filterCall, cache, flags); } virtual PxSQPrunerHandle getHandle(const PxRigidActor& actor, const PxShape& shape, PxU32& prunerIndex) const { const NpActor& npActor = NpActor::getFromPxActor(actor); const NpShape& npShape = static_cast<const NpShape&>(shape); const PxU32 actorIndex = npActor.getBaseIndex(); PX_ASSERT(actorIndex!=NP_UNUSED_BASE_INDEX); const ActorShapeData actorShapeData = mAdapter.mDatabase.find(actorIndex, &npActor, &npShape); const PrunerData prunerData = getPrunerData(actorShapeData); prunerIndex = getPrunerIndex(prunerData); return PxSQPrunerHandle(getPrunerHandle(prunerData)); } virtual void sync(PxU32 prunerIndex, const PxSQPrunerHandle* handles, const PxU32* boundsIndices, const PxBounds3* bounds, const PxTransform32* transforms, PxU32 count, const PxBitMap& ignoredIndices) { PX_ASSERT(prunerIndex==PruningIndex::eDYNAMIC); if(prunerIndex==PruningIndex::eDYNAMIC) SQ().sync(handles, boundsIndices, bounds, transforms, count, ignoredIndices); } SceneQueries mQueries; NpSqAdapter mAdapter; PxSceneQueryUpdateMode::Enum mUpdateMode; PxU32 mRefCount; }; } #include "SqFactory.h" static CompanionPrunerType getCompanionType(PxDynamicTreeSecondaryPruner::Enum type) { switch(type) { case PxDynamicTreeSecondaryPruner::eNONE: return COMPANION_PRUNER_NONE; case PxDynamicTreeSecondaryPruner::eBUCKET: return COMPANION_PRUNER_BUCKET; case PxDynamicTreeSecondaryPruner::eINCREMENTAL: return COMPANION_PRUNER_INCREMENTAL; case PxDynamicTreeSecondaryPruner::eBVH: return COMPANION_PRUNER_AABB_TREE; case PxDynamicTreeSecondaryPruner::eLAST: return COMPANION_PRUNER_NONE; } return COMPANION_PRUNER_NONE; } static BVHBuildStrategy getBuildStrategy(PxBVHBuildStrategy::Enum bs) { switch(bs) { case PxBVHBuildStrategy::eFAST: return BVH_SPLATTER_POINTS; case PxBVHBuildStrategy::eDEFAULT: return BVH_SPLATTER_POINTS_SPLIT_GEOM_CENTER; case PxBVHBuildStrategy::eSAH: return BVH_SAH; case PxBVHBuildStrategy::eLAST: return BVH_SPLATTER_POINTS; } return BVH_SPLATTER_POINTS; } static Pruner* create(PxPruningStructureType::Enum type, PxU64 contextID, PxDynamicTreeSecondaryPruner::Enum secondaryType, PxBVHBuildStrategy::Enum buildStrategy, PxU32 nbObjectsPerNode) { // PT: to force testing the bucket pruner // return createBucketPruner(contextID); // return createIncrementalPruner(contextID); const CompanionPrunerType cpType = getCompanionType(secondaryType); const BVHBuildStrategy bs = getBuildStrategy(buildStrategy); Pruner* pruner = NULL; switch(type) { case PxPruningStructureType::eNONE: { pruner = createBucketPruner(contextID); break; } case PxPruningStructureType::eDYNAMIC_AABB_TREE: { pruner = createAABBPruner(contextID, true, cpType, bs, nbObjectsPerNode); break; } case PxPruningStructureType::eSTATIC_AABB_TREE: { pruner = createAABBPruner(contextID, false, cpType, bs, nbObjectsPerNode); break; } // PT: for tests case PxPruningStructureType::eLAST: { pruner = createIncrementalPruner(contextID); break; } // case PxPruningStructureType::eLAST: break; } return pruner; } static PxSceneQuerySystem* getPxSQ(const PxSceneDesc& desc, PVDCapture* pvd, PxU64 contextID) { if(desc.sceneQuerySystem) { desc.sceneQuerySystem->acquireReference(); return desc.sceneQuerySystem; } else { Pruner* staticPruner = create(desc.staticStructure, contextID, desc.dynamicTreeSecondaryPruner, desc.staticBVHBuildStrategy, desc.staticNbObjectsPerNode); Pruner* dynamicPruner = create(desc.dynamicStructure, contextID, desc.dynamicTreeSecondaryPruner, desc.dynamicBVHBuildStrategy, desc.dynamicNbObjectsPerNode); return PX_NEW(InternalPxSQ)(desc, pvd, contextID, staticPruner, dynamicPruner); } } #if PX_SUPPORT_PVD #define PVD_PARAM this #else #define PVD_PARAM NULL #endif NpSceneQueries::NpSceneQueries(const PxSceneDesc& desc, Vd::PvdSceneClient* pvd, PxU64 contextID) : mSQ (getPxSQ(desc, PVD_PARAM, contextID)) #if PX_SUPPORT_PVD // PT: warning, pvd object not created yet at this point ,mPVDClient (pvd) ,mSingleSqCollector (pvd, false) #endif { PX_UNUSED(pvd); PX_UNUSED(contextID); } NpSceneQueries::~NpSceneQueries() { if(mSQ) { mSQ->release(); mSQ = NULL; } } void NpSceneQueries::sync(PxU32 prunerIndex, const ScPrunerHandle* handles, const PxU32* indices, const PxBounds3* bounds, const PxTransform32* transforms, PxU32 count, const PxBitMap& ignoredIndices) { mSQ->sync(prunerIndex, handles, indices, bounds, transforms, count, ignoredIndices); } #include "NpScene.h" // PT: TODO: eventually move NP_READ_CHECK to internal PxSQ version ? bool NpScene::raycast( const PxVec3& origin, const PxVec3& unitDir, const PxReal distance, PxHitCallback<PxRaycastHit>& hits, PxHitFlags hitFlags, const PxQueryFilterData& filterData, PxQueryFilterCallback* filterCall, const PxQueryCache* cache, PxGeometryQueryFlags flags) const { NP_READ_CHECK(this); return mNpSQ.mSQ->raycast(origin, unitDir, distance, hits, hitFlags, filterData, filterCall, cache, flags); } bool NpScene::overlap( const PxGeometry& geometry, const PxTransform& pose, PxOverlapCallback& hits, const PxQueryFilterData& filterData, PxQueryFilterCallback* filterCall, const PxQueryCache* cache, PxGeometryQueryFlags flags) const { NP_READ_CHECK(this); return mNpSQ.mSQ->overlap(geometry, pose, hits, filterData, filterCall, cache, flags); } bool NpScene::sweep( const PxGeometry& geometry, const PxTransform& pose, const PxVec3& unitDir, const PxReal distance, PxHitCallback<PxSweepHit>& hits, PxHitFlags hitFlags, const PxQueryFilterData& filterData, PxQueryFilterCallback* filterCall, const PxQueryCache* cache, const PxReal inflation, PxGeometryQueryFlags flags) const { NP_READ_CHECK(this); return mNpSQ.mSQ->sweep(geometry, pose, unitDir, distance, hits, hitFlags, filterData, filterCall, cache, inflation, flags); } void NpScene::setUpdateMode(PxSceneQueryUpdateMode::Enum updateMode) { NP_WRITE_CHECK(this); getSQAPI().setUpdateMode(updateMode); updatePvdProperties(); } PxSceneQueryUpdateMode::Enum NpScene::getUpdateMode() const { NP_READ_CHECK(this); return getSQAPI().getUpdateMode(); } void NpScene::setDynamicTreeRebuildRateHint(PxU32 dynamicTreeRebuildRateHint) { NP_WRITE_CHECK(this); PX_CHECK_AND_RETURN((dynamicTreeRebuildRateHint >= 4), "PxScene::setDynamicTreeRebuildRateHint(): Param has to be >= 4!"); getSQAPI().setDynamicTreeRebuildRateHint(dynamicTreeRebuildRateHint); updatePvdProperties(); } PxU32 NpScene::getDynamicTreeRebuildRateHint() const { NP_READ_CHECK(this); return getSQAPI().getDynamicTreeRebuildRateHint(); } void NpScene::forceRebuildDynamicTree(PxU32 prunerIndex) { PX_PROFILE_ZONE("API.forceDynamicTreeRebuild", getContextId()); NP_WRITE_CHECK(this); PX_SIMD_GUARD; getSQAPI().forceRebuildDynamicTree(prunerIndex); } PxU32 NpScene::getStaticTimestamp() const { return getSQAPI().getStaticTimestamp(); } PxPruningStructureType::Enum NpScene::getStaticStructure() const { return mPrunerType[0]; } PxPruningStructureType::Enum NpScene::getDynamicStructure() const { return mPrunerType[1]; } void NpScene::flushUpdates() { PX_PROFILE_ZONE("API.flushQueryUpdates", getContextId()); NP_WRITE_CHECK(this); PX_SIMD_GUARD; getSQAPI().flushUpdates(); } namespace { class SqRefFinder: public Sc::SqRefFinder { PX_NOCOPY(SqRefFinder) public: SqRefFinder(const PxSceneQuerySystem& pxsq) : mPXSQ(pxsq) {} const PxSceneQuerySystem& mPXSQ; virtual ScPrunerHandle find(const PxRigidBody* body, const PxShape* shape, PxU32& prunerIndex) { return mPXSQ.getHandle(*body, *shape, prunerIndex); } }; } void NpScene::syncSQ() { PxSceneQuerySystem& pm = getSQAPI(); { const PxU32 numBodies = mScene.getNumActiveCompoundBodies(); const Sc::BodyCore*const* bodies = mScene.getActiveCompoundBodiesArray(); // PT: we emulate "getGlobalPose" here by doing the equivalent matrix computation directly. // This works because the code is the same for rigid dynamic & articulation links. // PT: TODO: SIMD for(PxU32 i = 0; i < numBodies; i++) { // PT: we don't have access to Np from here so we have to go through Px, which is a bit ugly. // If this creates perf issues an alternative would be to just store the ID along with the body // pointer in the active compound bodies array. PxActor* actor = bodies[i]->getPxActor(); PX_ASSERT(actor); const PxU32 id = static_cast<PxRigidActor*>(actor)->getInternalActorIndex(); PX_ASSERT(id!=0xffffffff); pm.updateSQCompound(PxSQCompoundHandle(id), bodies[i]->getBody2World() * bodies[i]->getBody2Actor().getInverse()); } } SqRefFinder sqRefFinder(pm); mScene.syncSceneQueryBounds(mNpSQ, sqRefFinder); pm.finalizeUpdates(); } void NpScene::forceSceneQueryRebuild() { // PT: what is this function anyway? What's the difference between this and forceDynamicTreeRebuild ? Why is the implementation different? syncSQ(); } void NpScene::sceneQueriesStaticPrunerUpdate(PxBaseTask* ) { PX_PROFILE_ZONE("SceneQuery.sceneQueriesStaticPrunerUpdate", getContextId()); // run pruner build only, this will build the new tree only, no commit happens getSQAPI().sceneQueryBuildStep(mStaticBuildStepHandle); } void NpScene::sceneQueriesDynamicPrunerUpdate(PxBaseTask*) { PX_PROFILE_ZONE("SceneQuery.sceneQueriesDynamicPrunerUpdate", getContextId()); // run pruner build only, this will build the new tree only, no commit happens getSQAPI().sceneQueryBuildStep(mDynamicBuildStepHandle); } void NpScene::sceneQueriesUpdate(PxBaseTask* completionTask, bool controlSimulation) { PX_SIMD_GUARD; PxSQBuildStepHandle runUpdateTasksStatic = NULL; PxSQBuildStepHandle runUpdateTasksDynamic = NULL; { // write guard must end before scene queries tasks kicks off worker threads NP_WRITE_CHECK(this); PX_PROFILE_START_CROSSTHREAD("Basic.sceneQueriesUpdate", getContextId()); if(mSQUpdateRunning) { //fetchSceneQueries doesn't get called outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::fetchSceneQueries was not called!"); return; } PxSceneQuerySystem& pxsq = getSQAPI(); // flush scene queries updates pxsq.flushUpdates(); // prepare scene queries for build - copy bounds runUpdateTasksStatic = pxsq.prepareSceneQueryBuildStep(PX_SCENE_PRUNER_STATIC); runUpdateTasksDynamic = pxsq.prepareSceneQueryBuildStep(PX_SCENE_PRUNER_DYNAMIC); mStaticBuildStepHandle = runUpdateTasksStatic; mDynamicBuildStepHandle = runUpdateTasksDynamic; mSQUpdateRunning = true; } { PX_PROFILE_ZONE("Sim.sceneQueriesTaskSetup", getContextId()); if (controlSimulation) { { PX_PROFILE_ZONE("Sim.resetDependencies", getContextId()); // Only reset dependencies, etc if we own the TaskManager. Will be false // when an NpScene is controlled by an APEX scene. mTaskManager->resetDependencies(); } mTaskManager->startSimulation(); } mSceneQueriesCompletion.setContinuation(*mTaskManager, completionTask); if(runUpdateTasksStatic) mSceneQueriesStaticPrunerUpdate.setContinuation(&mSceneQueriesCompletion); if(runUpdateTasksDynamic) mSceneQueriesDynamicPrunerUpdate.setContinuation(&mSceneQueriesCompletion); mSceneQueriesCompletion.removeReference(); if(runUpdateTasksStatic) mSceneQueriesStaticPrunerUpdate.removeReference(); if(runUpdateTasksDynamic) mSceneQueriesDynamicPrunerUpdate.removeReference(); } } bool NpScene::checkSceneQueriesInternal(bool block) { PX_PROFILE_ZONE("Basic.checkSceneQueries", getContextId()); return mSceneQueriesDone.wait(block ? PxSync::waitForever : 0); } bool NpScene::checkQueries(bool block) { return checkSceneQueriesInternal(block); } bool NpScene::fetchQueries(bool block) { if(!mSQUpdateRunning) { //fetchSceneQueries doesn't get called outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxScene::fetchQueries: fetchQueries() called illegally! It must be called after sceneQueriesUpdate()"); return false; } if(!checkSceneQueriesInternal(block)) return false; { PX_SIMD_GUARD; NP_WRITE_CHECK(this); // we use cross thread profile here, to show the event in cross thread view // PT: TODO: why do we want to show it in the cross thread view? PX_PROFILE_START_CROSSTHREAD("Basic.fetchQueries", getContextId()); // flush updates and commit if work is done getSQAPI().flushUpdates(); PX_PROFILE_STOP_CROSSTHREAD("Basic.fetchQueries", getContextId()); PX_PROFILE_STOP_CROSSTHREAD("Basic.sceneQueriesUpdate", getContextId()); mSceneQueriesDone.reset(); mSQUpdateRunning = false; } return true; }
30,251
C++
36.862328
213
0.747645
NVIDIA-Omniverse/PhysX/physx/source/physx/src/NpActor.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef NP_ACTOR_H #define NP_ACTOR_H #include "NpConnector.h" #include "NpBase.h" namespace physx { class NpShapeManager; class NpAggregate; class NpScene; class NpShape; const Sc::BodyCore* getBodyCore(const PxRigidActor* actor); PX_FORCE_INLINE Sc::BodyCore* getBodyCore(PxRigidActor* actor) { const Sc::BodyCore* core = getBodyCore(static_cast<const PxRigidActor*>(actor)); return const_cast<Sc::BodyCore*>(core); } class NpActor : public NpBase { public: // PX_SERIALIZATION NpActor(const PxEMPTY) : NpBase(PxEmpty) {} void exportExtraData(PxSerializationContext& stream); void importExtraData(PxDeserializationContext& context); void resolveReferences(PxDeserializationContext& context); static void getBinaryMetaData(PxOutputStream& stream); //~PX_SERIALIZATION NpActor(NpType::Enum type); void removeConstraints(PxRigidActor& owner); void removeFromAggregate(PxActor& owner); NpAggregate* getNpAggregate(PxU32& index) const; void setAggregate(NpAggregate* np, PxActor& owner); PxAggregate* getAggregate() const; void scSetDominanceGroup(PxDominanceGroup v); void scSetOwnerClient(PxClientID inId); void removeConstraintsFromScene(); PX_FORCE_INLINE void addConstraintsToScene() // inline the fast path for addActors() { if(mConnectorArray) addConstraintsToSceneInternal(); } PxU32 findConnector(NpConnectorType::Enum type, PxBase* object) const; void addConnector(NpConnectorType::Enum type, PxBase* object, const char* errMsg); void removeConnector(PxActor& owner, NpConnectorType::Enum type, PxBase* object, const char* errorMsg); PxU32 getNbConnectors(NpConnectorType::Enum type) const; static NpShapeManager* getShapeManager_(PxRigidActor& actor); // bit misplaced here, but we don't want a separate subclass just for this static const NpShapeManager* getShapeManager_(const PxRigidActor& actor); // bit misplaced here, but we don't want a separate subclass just for this static NpActor& getFromPxActor(PxActor& actor) { return *PxPointerOffset<NpActor*>(&actor, ptrdiff_t(sOffsets.pxActorToNpActor[actor.getConcreteType()])); } static const NpActor& getFromPxActor(const PxActor& actor) { return *PxPointerOffset<const NpActor*>(&actor, ptrdiff_t(sOffsets.pxActorToNpActor[actor.getConcreteType()])); } const PxActor* getPxActor() const; static NpScene* getNpSceneFromActor(const PxActor& actor) { return getFromPxActor(actor).getNpScene(); } PX_FORCE_INLINE NpConnectorIterator getConnectorIterator(NpConnectorType::Enum type) { if (mConnectorArray) return NpConnectorIterator(&mConnectorArray->front(), mConnectorArray->size(), type); else return NpConnectorIterator(NULL, 0, type); } static void onActorRelease(PxActor* actor); template<typename T> PxU32 getConnectors(NpConnectorType::Enum type, T** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const { PxU32 nbConnectors = 0; if(mConnectorArray) { for(PxU32 i=0; i<mConnectorArray->size(); i++) { NpConnector& c = (*mConnectorArray)[i]; if(c.mType == type && nbConnectors < bufferSize && i>=startIndex) userBuffer[nbConnectors++] = static_cast<T*>(c.mObject); } } return nbConnectors; } PX_INLINE PxActorFlags getActorFlags() const { return getActorCore().getActorFlags(); } PX_INLINE PxDominanceGroup getDominanceGroup() const { return getActorCore().getDominanceGroup(); } PX_INLINE PxClientID getOwnerClient() const { return getActorCore().getOwnerClient(); } PX_INLINE void scSetActorFlags(PxActorFlags v) { PX_ASSERT(!isAPIWriteForbidden()); // PT: TODO: move this check out of here, they should be done in Np! #if PX_CHECKED const PxActorFlags aFlags = getActorFlags(); const NpType::Enum npType = getNpType(); if((!aFlags.isSet(PxActorFlag::eDISABLE_SIMULATION)) && v.isSet(PxActorFlag::eDISABLE_SIMULATION) && (npType != NpType::eBODY) && (npType != NpType::eRIGID_STATIC)) { PxGetFoundation().error(PxErrorCode::eINVALID_PARAMETER, PX_FL, "PxActor::setActorFlag: PxActorFlag::eDISABLE_SIMULATION is only supported by PxRigidDynamic and PxRigidStatic objects."); } #endif getActorCore().setActorFlags(v); UPDATE_PVD_PROPERTY } PX_FORCE_INLINE const Sc::ActorCore& getActorCore() const { return *reinterpret_cast<const Sc::ActorCore*>(size_t(this) + sNpOffsets.npToSc[getNpType()]); } PX_FORCE_INLINE Sc::ActorCore& getActorCore() { return *reinterpret_cast<Sc::ActorCore*>(size_t(this) + sNpOffsets.npToSc[getNpType()]); } PX_INLINE const Sc::RigidCore& getScRigidCore() const { return static_cast<const Sc::RigidCore&>(getActorCore()); } PX_INLINE Sc::RigidCore& getScRigidCore() { return static_cast<Sc::RigidCore&>(getActorCore()); } PX_FORCE_INLINE void scSwitchToNoSim() { NpScene* scene = getNpScene(); if(scene && (!scene->isAPIWriteForbidden())) scene->scSwitchRigidToNoSim(*this); } PX_FORCE_INLINE void scSwitchFromNoSim() { NpScene* scene = getNpScene(); if(scene && (!scene->isAPIWriteForbidden())) scene->scSwitchRigidFromNoSim(*this); } protected: ~NpActor() {} const char* mName; // Lazy-create array for connector objects like constraints, observers, ... // Most actors have no such objects, so we bias this class accordingly: NpConnectorArray* mConnectorArray; private: void addConstraintsToSceneInternal(); void removeConnector(PxActor& owner, PxU32 index); struct Offsets { size_t pxActorToNpActor[PxConcreteType::ePHYSX_CORE_COUNT]; Offsets(); }; public: static const Offsets sOffsets; struct NpOffsets { size_t npToSc[NpType::eTYPE_COUNT]; NpOffsets(); }; static const NpOffsets sNpOffsets; }; } #endif
8,230
C
39.348039
179
0.669623
NVIDIA-Omniverse/PhysX/physx/source/physx/src/NpPhysics.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef NP_PHYSICS_H #define NP_PHYSICS_H #include "PxPhysics.h" #include "foundation/PxUserAllocated.h" #include "foundation/PxHashSet.h" #include "foundation/PxHashMap.h" #include "GuMeshFactory.h" #include "NpMaterial.h" #include "NpFEMSoftBodyMaterial.h" #include "NpFEMClothMaterial.h" #include "NpPBDMaterial.h" #include "NpFLIPMaterial.h" #include "NpMPMMaterial.h" #include "NpPhysicsInsertionCallback.h" #include "NpMaterialManager.h" #include "ScPhysics.h" #ifdef LINUX #include <string.h> #endif #if PX_SUPPORT_GPU_PHYSX #include "device/PhysXIndicator.h" #endif #include "PsPvd.h" #if PX_SUPPORT_OMNI_PVD class OmniPvdPxSampler; namespace physx { class PxOmniPvd; } #endif namespace physx { #if PX_SUPPORT_PVD namespace Vd { class PvdPhysicsClient; } #endif struct NpMaterialIndexTranslator { NpMaterialIndexTranslator() : indicesNeedTranslation(false) {} PxHashMap<PxU16, PxU16> map; bool indicesNeedTranslation; }; class NpScene; struct PxvOffsetTable; #if PX_VC #pragma warning(push) #pragma warning(disable:4996) // We have to implement deprecated member functions, do not warn. #endif template <typename T> class NpMaterialAccessor; class NpPhysics : public PxPhysics, public PxUserAllocated { PX_NOCOPY(NpPhysics) struct NpDelListenerEntry : public PxUserAllocated { NpDelListenerEntry(const PxDeletionEventFlags& de, bool restrictedObjSet) : flags(de) , restrictedObjectSet(restrictedObjSet) { } PxHashSet<const PxBase*> registeredObjects; // specifically registered objects for deletion events PxDeletionEventFlags flags; bool restrictedObjectSet; }; NpPhysics( const PxTolerancesScale& scale, const PxvOffsetTable& pxvOffsetTable, bool trackOutstandingAllocations, physx::pvdsdk::PsPvd* pvd, PxFoundation&, physx::PxOmniPvd* omniPvd); virtual ~NpPhysics(); public: static NpPhysics* createInstance( PxU32 version, PxFoundation& foundation, const PxTolerancesScale& scale, bool trackOutstandingAllocations, physx::pvdsdk::PsPvd* pvd, physx::PxOmniPvd* omniPvd); static PxU32 releaseInstance(); static NpPhysics& getInstance() { return *mInstance; } virtual void release() PX_OVERRIDE; virtual PxOmniPvd* getOmniPvd() PX_OVERRIDE; virtual PxScene* createScene(const PxSceneDesc&) PX_OVERRIDE; void releaseSceneInternal(PxScene&); virtual PxU32 getNbScenes() const PX_OVERRIDE; virtual PxU32 getScenes(PxScene** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const PX_OVERRIDE; virtual PxRigidStatic* createRigidStatic(const PxTransform&) PX_OVERRIDE; virtual PxRigidDynamic* createRigidDynamic(const PxTransform&) PX_OVERRIDE; virtual PxArticulationReducedCoordinate* createArticulationReducedCoordinate() PX_OVERRIDE; virtual PxSoftBody* createSoftBody(PxCudaContextManager& cudaContextManager) PX_OVERRIDE; virtual PxHairSystem* createHairSystem(PxCudaContextManager& cudaContextManager) PX_OVERRIDE; virtual PxFEMCloth* createFEMCloth(PxCudaContextManager& cudaContextManager) PX_OVERRIDE; virtual PxPBDParticleSystem* createPBDParticleSystem(PxCudaContextManager& cudaContextManager, PxU32 maxNeighborhood) PX_OVERRIDE; virtual PxFLIPParticleSystem* createFLIPParticleSystem(PxCudaContextManager& cudaContextManager) PX_OVERRIDE; virtual PxMPMParticleSystem* createMPMParticleSystem(PxCudaContextManager& cudaContextManager) PX_OVERRIDE; virtual PxConstraint* createConstraint(PxRigidActor* actor0, PxRigidActor* actor1, PxConstraintConnector& connector, const PxConstraintShaderTable& shaders, PxU32 dataSize) PX_OVERRIDE; virtual PxAggregate* createAggregate(PxU32 maxActors, PxU32 maxShapes, PxAggregateFilterHint filterHint) PX_OVERRIDE; virtual PxShape* createShape(const PxGeometry&, PxMaterial*const *, PxU16, bool, PxShapeFlags shapeFlags) PX_OVERRIDE; virtual PxShape* createShape(const PxGeometry&, PxFEMSoftBodyMaterial*const *, PxU16, bool, PxShapeFlags shapeFlags) PX_OVERRIDE; virtual PxShape* createShape(const PxGeometry&, PxFEMClothMaterial*const *, PxU16, bool, PxShapeFlags shapeFlags) PX_OVERRIDE; virtual PxU32 getNbShapes() const PX_OVERRIDE; virtual PxU32 getShapes(PxShape** userBuffer, PxU32 bufferSize, PxU32 startIndex) const PX_OVERRIDE; virtual PxMaterial* createMaterial(PxReal staticFriction, PxReal dynamicFriction, PxReal restitution) PX_OVERRIDE; virtual PxU32 getNbMaterials() const PX_OVERRIDE; virtual PxU32 getMaterials(PxMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const PX_OVERRIDE; virtual PxFEMSoftBodyMaterial* createFEMSoftBodyMaterial(PxReal youngs, PxReal poissons, PxReal dynamicFriction) PX_OVERRIDE; virtual PxU32 getNbFEMSoftBodyMaterials() const PX_OVERRIDE; virtual PxU32 getFEMSoftBodyMaterials(PxFEMSoftBodyMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex = 0) const PX_OVERRIDE; virtual PxFEMClothMaterial* createFEMClothMaterial(PxReal youngs, PxReal poissons, PxReal dynamicFriction, PxReal thickness) PX_OVERRIDE; virtual PxU32 getNbFEMClothMaterials() const PX_OVERRIDE; virtual PxU32 getFEMClothMaterials(PxFEMClothMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex = 0) const PX_OVERRIDE; virtual PxPBDMaterial* createPBDMaterial(PxReal friction, PxReal damping, PxReal adhesion, PxReal viscosity, PxReal vorticityConfinement, PxReal surfaceTension, PxReal cohesion, PxReal lift, PxReal drag, PxReal cflCoefficient, PxReal gravityScale) PX_OVERRIDE; virtual PxU32 getNbPBDMaterials() const PX_OVERRIDE; virtual PxU32 getPBDMaterials(PxPBDMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex = 0) const PX_OVERRIDE; virtual PxFLIPMaterial* createFLIPMaterial(PxReal friction, PxReal damping, PxReal maxVelocity, PxReal viscosity, PxReal gravityScale) PX_OVERRIDE; virtual PxU32 getNbFLIPMaterials() const PX_OVERRIDE; virtual PxU32 getFLIPMaterials(PxFLIPMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex = 0) const PX_OVERRIDE; virtual PxMPMMaterial* createMPMMaterial(PxReal friction, PxReal damping, PxReal maxVelocity, bool isPlastic, PxReal youngsModulus, PxReal poissons, PxReal hardening, PxReal criticalCompression, PxReal criticalStretch, PxReal tensileDamageSensitivity, PxReal compressiveDamageSensitivity, PxReal attractiveForceResidual, PxReal gravityScale) PX_OVERRIDE; virtual PxU32 getNbMPMMaterials() const PX_OVERRIDE; virtual PxU32 getMPMMaterials(PxMPMMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex = 0) const PX_OVERRIDE; virtual PxTriangleMesh* createTriangleMesh(PxInputStream&) PX_OVERRIDE; virtual PxU32 getNbTriangleMeshes() const PX_OVERRIDE; virtual PxU32 getTriangleMeshes(PxTriangleMesh** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const PX_OVERRIDE; virtual PxTetrahedronMesh* createTetrahedronMesh(PxInputStream&) PX_OVERRIDE; virtual PxU32 getNbTetrahedronMeshes() const PX_OVERRIDE; virtual PxU32 getTetrahedronMeshes(PxTetrahedronMesh** userBuffer, PxU32 bufferSize, PxU32 startIndex = 0) const PX_OVERRIDE; virtual PxSoftBodyMesh* createSoftBodyMesh(PxInputStream&) PX_OVERRIDE; virtual PxHeightField* createHeightField(PxInputStream& stream) PX_OVERRIDE; virtual PxU32 getNbHeightFields() const PX_OVERRIDE; virtual PxU32 getHeightFields(PxHeightField** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const PX_OVERRIDE; virtual PxConvexMesh* createConvexMesh(PxInputStream&) PX_OVERRIDE; virtual PxU32 getNbConvexMeshes() const PX_OVERRIDE; virtual PxU32 getConvexMeshes(PxConvexMesh** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const PX_OVERRIDE; virtual PxBVH* createBVH(PxInputStream&) PX_OVERRIDE; virtual PxU32 getNbBVHs() const PX_OVERRIDE; virtual PxU32 getBVHs(PxBVH** userBuffer, PxU32 bufferSize, PxU32 startIndex=0) const PX_OVERRIDE; virtual PxParticleBuffer* createParticleBuffer(PxU32 maxParticles, PxU32 maxVolumes, PxCudaContextManager* cudaContextManager) PX_OVERRIDE; virtual PxParticleAndDiffuseBuffer* createParticleAndDiffuseBuffer(PxU32 maxParticles, PxU32 maxVolumes, PxU32 maxDiffuseParticles, PxCudaContextManager* cudaContextManager) PX_OVERRIDE; virtual PxParticleClothBuffer* createParticleClothBuffer(PxU32 maxParticles, PxU32 maxNumVolumes, PxU32 maxNumCloths, PxU32 maxNumTriangles, PxU32 maxNumSprings, PxCudaContextManager* cudaContextManager) PX_OVERRIDE; virtual PxParticleRigidBuffer* createParticleRigidBuffer(PxU32 maxParticles, PxU32 maxNumVolumes, PxU32 maxNumRigids, PxCudaContextManager* cudaContextManager) PX_OVERRIDE; #if PX_SUPPORT_GPU_PHYSX void registerPhysXIndicatorGpuClient(); void unregisterPhysXIndicatorGpuClient(); #else PX_FORCE_INLINE void registerPhysXIndicatorGpuClient() {} PX_FORCE_INLINE void unregisterPhysXIndicatorGpuClient() {} #endif virtual PxPruningStructure* createPruningStructure(PxRigidActor*const* actors, PxU32 nbActors) PX_OVERRIDE; virtual const PxTolerancesScale& getTolerancesScale() const PX_OVERRIDE; virtual PxFoundation& getFoundation() PX_OVERRIDE; PX_INLINE NpScene* getScene(PxU32 i) const { return mSceneArray[i]; } PX_INLINE PxU32 getNumScenes() const { return mSceneArray.size(); } virtual void registerDeletionListener(PxDeletionListener& observer, const PxDeletionEventFlags& deletionEvents, bool restrictedObjectSet) PX_OVERRIDE; virtual void unregisterDeletionListener(PxDeletionListener& observer) PX_OVERRIDE; virtual void registerDeletionListenerObjects(PxDeletionListener& observer, const PxBase* const* observables, PxU32 observableCount) PX_OVERRIDE; virtual void unregisterDeletionListenerObjects(PxDeletionListener& observer, const PxBase* const* observables, PxU32 observableCount) PX_OVERRIDE; void notifyDeletionListeners(const PxBase*, void* userData, PxDeletionEventFlag::Enum deletionEvent); PX_FORCE_INLINE void notifyDeletionListenersUserRelease(const PxBase* b, void* userData) { notifyDeletionListeners(b, userData, PxDeletionEventFlag::eUSER_RELEASE); } PX_FORCE_INLINE void notifyDeletionListenersMemRelease(const PxBase* b, void* userData) { notifyDeletionListeners(b, userData, PxDeletionEventFlag::eMEMORY_RELEASE); } virtual PxInsertionCallback& getPhysicsInsertionCallback() PX_OVERRIDE { return mObjectInsertion; } bool sendMaterialTable(NpScene&); NpMaterialManager<NpMaterial>& getMaterialManager() { return mMasterMaterialManager; } #if PX_SUPPORT_GPU_PHYSX NpMaterialManager<NpFEMSoftBodyMaterial>& getFEMSoftBodyMaterialManager() { return mMasterFEMSoftBodyMaterialManager; } NpMaterialManager<NpPBDMaterial>& getPBDMaterialManager() { return mMasterPBDMaterialManager; } #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION NpMaterialManager<NpFEMClothMaterial>& getFEMClothMaterialManager() { return mMasterFEMClothMaterialManager; } NpMaterialManager<NpFLIPMaterial>& getFLIPMaterialManager() { return mMasterFLIPMaterialManager; } NpMaterialManager<NpMPMMaterial>& getMPMMaterialManager() { return mMasterMPMMaterialManager; } #endif #endif NpMaterial* addMaterial(NpMaterial* np); void removeMaterialFromTable(NpMaterial&); void updateMaterial(NpMaterial&); #if PX_SUPPORT_GPU_PHYSX NpFEMSoftBodyMaterial* addMaterial(NpFEMSoftBodyMaterial* np); void removeMaterialFromTable(NpFEMSoftBodyMaterial&); void updateMaterial(NpFEMSoftBodyMaterial&); NpPBDMaterial* addMaterial(NpPBDMaterial* np); void removeMaterialFromTable(NpPBDMaterial&); void updateMaterial(NpPBDMaterial&); #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION NpFEMClothMaterial* addMaterial(NpFEMClothMaterial* np); void removeMaterialFromTable(NpFEMClothMaterial&); void updateMaterial(NpFEMClothMaterial&); NpFLIPMaterial* addMaterial(NpFLIPMaterial* np); void removeMaterialFromTable(NpFLIPMaterial&); void updateMaterial(NpFLIPMaterial&); NpMPMMaterial* addMaterial(NpMPMMaterial* np); void removeMaterialFromTable(NpMPMMaterial&); void updateMaterial(NpMPMMaterial&); #endif #endif static void initOffsetTables(PxvOffsetTable& pxvOffsetTable); static bool apiReentryLock; #if PX_SUPPORT_OMNI_PVD OmniPvdPxSampler* mOmniPvdSampler; PxOmniPvd* mOmniPvd; #endif private: typedef PxCoalescedHashMap<PxDeletionListener*, NpDelListenerEntry*> DeletionListenerMap; PxArray<NpScene*> mSceneArray; Sc::Physics mPhysics; NpMaterialManager<NpMaterial> mMasterMaterialManager; #if PX_SUPPORT_GPU_PHYSX NpMaterialManager<NpFEMSoftBodyMaterial> mMasterFEMSoftBodyMaterialManager; NpMaterialManager<NpPBDMaterial> mMasterPBDMaterialManager; #endif NpPhysicsInsertionCallback mObjectInsertion; struct MeshDeletionListener: public Gu::MeshFactoryListener { void onMeshFactoryBufferRelease(const PxBase* object, PxType type) { PX_UNUSED(type); NpPhysics::getInstance().notifyDeletionListeners(object, NULL, PxDeletionEventFlag::eMEMORY_RELEASE); } }; PxMutex mDeletionListenerMutex; DeletionListenerMap mDeletionListenerMap; MeshDeletionListener mDeletionMeshListener; bool mDeletionListenersExist; PxMutex mSceneAndMaterialMutex; // guarantees thread safety for API calls related to scene and material containers PxFoundation& mFoundation; #if PX_SUPPORT_GPU_PHYSX PhysXIndicator mPhysXIndicator; PxU32 mNbRegisteredGpuClients; PxMutex mPhysXIndicatorMutex; #endif #if PX_SUPPORT_PVD physx::pvdsdk::PsPvd* mPvd; Vd::PvdPhysicsClient* mPvdPhysicsClient; #endif static PxU32 mRefCount; static NpPhysics* mInstance; friend class NpCollection; #if PX_SUPPORT_OMNI_PVD public: class OmniPvdListener : public physx::NpFactoryListener { public: virtual void onMeshFactoryBufferRelease(const PxBase*, PxType) {} virtual void onObjectAdd(const PxBase*); virtual void onObjectRemove(const PxBase*); } mOmniPvdListener; private: #endif // GW: these must be the last defined members for now. Otherwise it appears to mess up the offsets // expected when linking SDK dlls against unit tests due to differing values of PX_ENABLE_FEATURES_UNDER_CONSTRUCTION... // this warrants further investigation and hopefully a better solution #if PX_SUPPORT_GPU_PHYSX #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION NpMaterialManager<NpFEMClothMaterial> mMasterFEMClothMaterialManager; NpMaterialManager<NpFLIPMaterial> mMasterFLIPMaterialManager; NpMaterialManager<NpMPMMaterial> mMasterMPMMaterialManager; #endif #endif }; template <> class NpMaterialAccessor<NpMaterial> { public: static NpMaterialManager<NpMaterial>& getMaterialManager(NpPhysics& physics) { return physics.getMaterialManager(); } }; #if PX_SUPPORT_GPU_PHYSX template <> class NpMaterialAccessor<NpFEMSoftBodyMaterial> { public: static NpMaterialManager<NpFEMSoftBodyMaterial>& getMaterialManager(NpPhysics& physics) { return physics.getFEMSoftBodyMaterialManager(); } }; template <> class NpMaterialAccessor<NpPBDMaterial> { public: static NpMaterialManager<NpPBDMaterial>& getMaterialManager(NpPhysics& physics) { return physics.getPBDMaterialManager(); } }; #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION template <> class NpMaterialAccessor<NpFEMClothMaterial> { public: static NpMaterialManager<NpFEMClothMaterial>& getMaterialManager(NpPhysics& physics) { return physics.getFEMClothMaterialManager(); } }; template <> class NpMaterialAccessor<NpFLIPMaterial> { public: static NpMaterialManager<NpFLIPMaterial>& getMaterialManager(NpPhysics& physics) { return physics.getFLIPMaterialManager(); } }; template <> class NpMaterialAccessor<NpMPMMaterial> { public: static NpMaterialManager<NpMPMMaterial>& getMaterialManager(NpPhysics& physics) { return physics.getMPMMaterialManager(); } }; #endif #endif #if PX_VC #pragma warning(pop) #endif } #endif
18,160
C
42.035545
359
0.77109
NVIDIA-Omniverse/PhysX/physx/source/physx/src/NpBounds.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef NP_BOUNDS_H #define NP_BOUNDS_H namespace physx { class PxBounds3; class NpShape; class NpActor; namespace Sq { typedef void(*ComputeBoundsFunc) (PxBounds3& bounds, const NpShape& scShape, const NpActor& npActor); extern const ComputeBoundsFunc gComputeBoundsTable[2]; // #define SQ_PRUNER_EPSILON 0.01f #define SQ_PRUNER_EPSILON 0.005f #define SQ_PRUNER_INFLATION (1.0f + SQ_PRUNER_EPSILON) // pruner test shape inflation (not narrow phase shape) } } #endif
2,177
C
41.705882
111
0.763895
NVIDIA-Omniverse/PhysX/physx/source/physx/src/NpArticulationReducedCoordinate.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #include "NpArticulationReducedCoordinate.h" #include "NpArticulationTendon.h" #include "NpArticulationSensor.h" #include "DyFeatherstoneArticulation.h" #include "ScArticulationSim.h" #include "ScConstraintSim.h" #include "foundation/PxAlignedMalloc.h" #include "foundation/PxPool.h" #include "PxPvdDataStream.h" #include "NpAggregate.h" #include "omnipvd/NpOmniPvdSetData.h" using namespace physx; void PxArticulationCache::release() { PxcScratchAllocator* scratchAlloc = reinterpret_cast<PxcScratchAllocator*>(scratchAllocator); PX_DELETE(scratchAlloc); scratchAllocator = NULL; PX_FREE(scratchMemory); PX_FREE_THIS; } // PX_SERIALIZATION NpArticulationReducedCoordinate* NpArticulationReducedCoordinate::createObject(PxU8*& address, PxDeserializationContext& context) { NpArticulationReducedCoordinate* obj = PX_PLACEMENT_NEW(address, NpArticulationReducedCoordinate(PxBaseFlag::eIS_RELEASABLE)); address += sizeof(NpArticulationReducedCoordinate); obj->importExtraData(context); obj->resolveReferences(context); return obj; } void NpArticulationReducedCoordinate::preExportDataReset() { //for now, no support for loop joint serialization PxArray<NpConstraint*> emptyLoopJoints; PxMemCopy(&mLoopJoints, &emptyLoopJoints, sizeof(PxArray<NpConstraint*>)); } //~PX_SERIALIZATION NpArticulationReducedCoordinate::NpArticulationReducedCoordinate() : PxArticulationReducedCoordinate(PxConcreteType::eARTICULATION_REDUCED_COORDINATE, PxBaseFlag::eOWNS_MEMORY | PxBaseFlag::eIS_RELEASABLE), NpBase(NpType::eARTICULATION), mNumShapes(0), mAggregate(NULL), mName(NULL), mCacheVersion(0), mTopologyChanged(false) { } void NpArticulationReducedCoordinate::setArticulationFlags(PxArticulationFlags flags) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "PxArticulationReducedCoordinate::setArticulationFlags() not allowed while simulation is running. Call will be ignored."); scSetArticulationFlags(flags); OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxArticulationReducedCoordinate, articulationFlags, static_cast<const PxArticulationReducedCoordinate&>(*this), flags); } void NpArticulationReducedCoordinate::setArticulationFlag(PxArticulationFlag::Enum flag, bool value) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "PxArticulationReducedCoordinate::setArticulationFlag() not allowed while simulation is running. Call will be ignored."); PxArticulationFlags flags = mCore.getArticulationFlags(); if(value) flags |= flag; else flags &= (~flag); scSetArticulationFlags(flags); OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxArticulationReducedCoordinate, articulationFlags, static_cast<const PxArticulationReducedCoordinate&>(*this), flags); } PxArticulationFlags NpArticulationReducedCoordinate::getArticulationFlags() const { NP_READ_CHECK(getNpScene()); return mCore.getArticulationFlags(); } PxU32 NpArticulationReducedCoordinate::getDofs() const { NP_READ_CHECK(getNpScene()); // core will check if in scene and return 0xFFFFFFFF if not. return mCore.getDofs(); } PxArticulationCache* NpArticulationReducedCoordinate::createCache() const { NP_READ_CHECK(getNpScene()); // doesn't modify the scene, only reads PX_CHECK_AND_RETURN_NULL(getNpScene(), "PxArticulationReducedCoordinate::createCache: Articulation must be in a scene."); PxArticulationCache* cache = mCore.createCache(); if (cache) cache->version = mCacheVersion; return cache; } PxU32 NpArticulationReducedCoordinate::getCacheDataSize() const { NP_READ_CHECK(getNpScene()); // doesn't modify the scene, only reads // core will check if in scene and return 0xFFFFFFFF if not. return mCore.getCacheDataSize(); } void NpArticulationReducedCoordinate::zeroCache(PxArticulationCache& cache) const { NP_READ_CHECK(getNpScene()); // doesn't modify the scene, only reads PX_CHECK_AND_RETURN(getNpScene(), "PxArticulationReducedCoordinate::zeroCache: Articulation must be in a scene."); // need to check cache version as correct cache size is required for zeroing PX_CHECK_AND_RETURN(cache.version == mCacheVersion, "PxArticulationReducedCoordinate::zeroCache: cache is invalid, articulation configuration has changed! "); return mCore.zeroCache(cache); } void NpArticulationReducedCoordinate::applyCache(PxArticulationCache& cache, const PxArticulationCacheFlags flags, bool autowake) { PX_CHECK_AND_RETURN(getNpScene(), "PxArticulationReducedCoordinate::applyCache: Articulation must be in a scene."); PX_CHECK_AND_RETURN(cache.version == mCacheVersion, "PxArticulationReducedCoordinate::applyCache: cache is invalid, articulation configuration has changed! "); PX_CHECK_AND_RETURN(!(getScene()->getFlags() & PxSceneFlag::eENABLE_DIRECT_GPU_API), "PxArticulationReducedCoordinate::applyCache : it is illegal to call this method if PxSceneFlag::eENABLE_DIRECT_GPU_API is enabled!"); //if we try to do a bulk op when sim is running, return with error if (getNpScene()->getSimulationStage() != Sc::SimulationStage::eCOMPLETE) { PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "PxArticulationReducedCoordinate::applyCache() not allowed while simulation is running. Call will be ignored."); return; } if (!(getScene()->getFlags() & PxSceneFlag::eENABLE_DIRECT_GPU_API)) { const bool forceWake = mCore.applyCache(cache, flags); if (flags & (PxArticulationCacheFlag::ePOSITION | PxArticulationCacheFlag::eROOT_TRANSFORM)) { const PxU32 linkCount = mArticulationLinks.size(); //KS - the below code forces contact managers to be updated/cached data to be dropped and //shape transforms to be updated. for (PxU32 i = 0; i < linkCount; ++i) { NpArticulationLink* link = mArticulationLinks[i]; //in the lowlevel articulation, we have already updated bodyCore's body2World const PxTransform internalPose = link->getCore().getBody2World(); link->scSetBody2World(internalPose); } } wakeUpInternal(forceWake, autowake); } } void NpArticulationReducedCoordinate::copyInternalStateToCache(PxArticulationCache& cache, const PxArticulationCacheFlags flags) const { PX_CHECK_AND_RETURN(getNpScene(), "PxArticulationReducedCoordinate::copyInternalStateToCache: Articulation must be in a scene."); PX_CHECK_AND_RETURN(cache.version == mCacheVersion, "PxArticulationReducedCoordinate::copyInternalStateToCache: cache is invalid, articulation configuration has changed! "); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "PxArticulationReducedCoordinate::copyInternalStateToCache() not allowed while simulation is running. Call will be ignored."); PX_CHECK_AND_RETURN(!(getScene()->getFlags() & PxSceneFlag::eENABLE_DIRECT_GPU_API), "PxArticulationReducedCoordinate::copyInternalStateToCache : it is illegal to call this method if PxSceneFlag::eENABLE_DIRECT_GPU_API is enabled!"); const bool isGpuSimEnabled = getNpScene()->getFlags() & PxSceneFlag::eENABLE_GPU_DYNAMICS; mCore.copyInternalStateToCache(cache, flags, isGpuSimEnabled); } void NpArticulationReducedCoordinate::packJointData(const PxReal* maximum, PxReal* reduced) const { NP_READ_CHECK(getNpScene()); PX_CHECK_AND_RETURN(getNpScene(), "PxArticulationReducedCoordinate::packJointData: Articulation must be in a scene."); mCore.packJointData(maximum, reduced); } void NpArticulationReducedCoordinate::unpackJointData(const PxReal* reduced, PxReal* maximum) const { NP_READ_CHECK(getNpScene()); PX_CHECK_AND_RETURN(getNpScene(), "PxArticulationReducedCoordinate::unpackJointData: Articulation must be in a scene."); mCore.unpackJointData(reduced, maximum); } void NpArticulationReducedCoordinate::commonInit() const { NP_READ_CHECK(getNpScene()); PX_CHECK_AND_RETURN(getNpScene(), "PxArticulationReducedCoordinate::commonInit: Articulation must be in a scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "PxArticulationReducedCoordinate::commonInit() not allowed while simulation is running. Call will be ignored."); mCore.commonInit(); } void NpArticulationReducedCoordinate::computeGeneralizedGravityForce(PxArticulationCache& cache) const { NP_READ_CHECK(getNpScene()); PX_CHECK_AND_RETURN(getNpScene(), "PxArticulationReducedCoordinate::computeGeneralizedGravityForce: Articulation must be in a scene."); PX_CHECK_AND_RETURN(cache.version ==mCacheVersion, "PxArticulationReducedCoordinate::computeGeneralizedGravityForce: cache is invalid, articulation configuration has changed! "); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "PxArticulationReducedCoordinate::computeGeneralizedGravityForce() not allowed while simulation is running. Call will be ignored."); mCore.computeGeneralizedGravityForce(cache); } void NpArticulationReducedCoordinate::computeCoriolisAndCentrifugalForce(PxArticulationCache& cache) const { NP_READ_CHECK(getNpScene()); PX_CHECK_AND_RETURN(getNpScene(), "PxArticulationReducedCoordinate::computeCoriolisAndCentrifugalForce: Articulation must be in a scene."); PX_CHECK_AND_RETURN(cache.version == mCacheVersion, "PxArticulationReducedCoordinate::computeCoriolisAndCentrifugalForce: cache is invalid, articulation configuration has changed! "); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "PxArticulationReducedCoordinate::computeCoriolisAndCentrifugalForce() not allowed while simulation is running. Call will be ignored."); mCore.computeCoriolisAndCentrifugalForce(cache); } void NpArticulationReducedCoordinate::computeGeneralizedExternalForce(PxArticulationCache& cache) const { NP_READ_CHECK(getNpScene()); PX_CHECK_AND_RETURN(getNpScene(), "PxArticulationReducedCoordinate::computeGeneralizedExternalForce: Articulation must be in a scene."); PX_CHECK_AND_RETURN(cache.version == mCacheVersion, "PxArticulationReducedCoordinate::computeGeneralizedExternalForce: cache is invalid, articulation configuration has changed! "); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "PxArticulationReducedCoordinate::computeGeneralizedExternalForce() not allowed while simulation is running. Call will be ignored."); mCore.computeGeneralizedExternalForce(cache); } void NpArticulationReducedCoordinate::computeJointAcceleration(PxArticulationCache& cache) const { NP_READ_CHECK(getNpScene()); PX_CHECK_AND_RETURN(getNpScene(), "PxArticulationReducedCoordinate::computeJointAcceleration: Articulation must be in a scene."); PX_CHECK_AND_RETURN(cache.version == mCacheVersion, "PxArticulationReducedCoordinate::computeJointAcceleration: cache is invalid, articulation configuration has changed! "); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "PxArticulationReducedCoordinate::computeJointAcceleration() not allowed while simulation is running. Call will be ignored."); mCore.computeJointAcceleration(cache); } void NpArticulationReducedCoordinate::computeJointForce(PxArticulationCache& cache) const { NP_READ_CHECK(getNpScene()); PX_CHECK_AND_RETURN(getNpScene(), "PxArticulationReducedCoordinate::computeJointForce: Articulation must be in a scene."); PX_CHECK_AND_RETURN(cache.version == mCacheVersion, "PxArticulationReducedCoordinate::computeJointForce: cache is invalid, articulation configuration has changed! "); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "PxArticulationReducedCoordinate::computeJointForce() not allowed while simulation is running. Call will be ignored."); mCore.computeJointForce(cache); } void NpArticulationReducedCoordinate::computeDenseJacobian(PxArticulationCache& cache, PxU32& nRows, PxU32& nCols) const { NP_READ_CHECK(getNpScene()); PX_CHECK_AND_RETURN(getNpScene(), "PxArticulationReducedCoordinate::computeDenseJacobian: Articulation must be in a scene."); PX_CHECK_AND_RETURN(cache.version == mCacheVersion, "PxArticulationReducedCoordinate::computeDenseJacobian: cache is invalid, articulation configuration has changed! "); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "PxArticulationReducedCoordinate::computeDenseJacobian() not allowed while simulation is running. Call will be ignored."); mCore.computeDenseJacobian(cache, nRows, nCols); } void NpArticulationReducedCoordinate::computeCoefficientMatrix(PxArticulationCache& cache) const { NpScene* npScene = getNpScene(); NP_READ_CHECK(npScene); PX_CHECK_AND_RETURN(npScene, "PxArticulationReducedCoordinate::computeCoefficientMatrix: Articulation must be in a scene."); PX_CHECK_AND_RETURN(cache.version == mCacheVersion, "PxArticulationReducedCoordinate::computeCoefficientMatrix: cache is invalid, articulation configuration has changed! "); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxArticulationReducedCoordinate::computeCoefficientMatrix() not allowed while simulation is running. Call will be ignored."); npScene->updateConstants(mLoopJoints); mCore.computeCoefficientMatrix(cache); } bool NpArticulationReducedCoordinate::computeLambda(PxArticulationCache& cache, PxArticulationCache& initialState, const PxReal* const jointTorque, const PxU32 maxIter) const { if (!getNpScene()) return PxGetFoundation().error(physx::PxErrorCode::eINVALID_PARAMETER, PX_FL, "PxArticulationReducedCoordinate::computeLambda: Articulation must be in a scene."); NP_READ_CHECK(getNpScene()); PX_CHECK_SCENE_API_WRITE_FORBIDDEN_AND_RETURN_VAL(getNpScene(), "PxArticulationReducedCoordinate::computeLambda() not allowed while simulation is running. Call will be ignored.", false); if (cache.version != mCacheVersion) return PxGetFoundation().error(physx::PxErrorCode::eINVALID_PARAMETER, PX_FL, "PxArticulationReducedCoordinate::computeLambda: cache is invalid, articulation configuration has changed!"); return mCore.computeLambda(cache, initialState, jointTorque, getScene()->getGravity(), maxIter); } void NpArticulationReducedCoordinate::computeGeneralizedMassMatrix(PxArticulationCache& cache) const { NP_READ_CHECK(getNpScene()); PX_CHECK_AND_RETURN(getNpScene(), "PxArticulationReducedCoordinate::computeGeneralizedMassMatrix: Articulation must be in a scene."); PX_CHECK_AND_RETURN(cache.version == mCacheVersion, "PxArticulationReducedCoordinate::computeGeneralizedMassMatrix: cache is invalid, articulation configuration has changed!"); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "PxArticulationReducedCoordinate::computeGeneralizedMassMatrix() not allowed while simulation is running. Call will be ignored."); mCore.computeGeneralizedMassMatrix(cache); } void NpArticulationReducedCoordinate::addLoopJoint(PxConstraint* joint) { NP_WRITE_CHECK(getNpScene()); #if PX_CHECKED PxRigidActor* actor0; PxRigidActor* actor1; joint->getActors(actor0, actor1); PxArticulationLink* link0 = NULL; PxArticulationLink* link1 = NULL; if(actor0 && actor0->getConcreteType()==PxConcreteType::eARTICULATION_LINK) link0 = static_cast<PxArticulationLink*>(actor0); if(actor1 && actor1->getConcreteType()==PxConcreteType::eARTICULATION_LINK) link1 = static_cast<PxArticulationLink*>(actor1); PX_CHECK_AND_RETURN((link0 || link1), "PxArticulationReducedCoordinate::addLoopJoint : at least one of the PxRigidActors need to be PxArticulationLink!"); PxArticulationReducedCoordinate* base0 = NULL; PxArticulationReducedCoordinate* base1 = NULL; if (link0) base0 = &link0->getArticulation(); if (link1) base1 = &link1->getArticulation(); PX_CHECK_AND_RETURN((base0 == this || base1 == this), "PxArticulationReducedCoordinate::addLoopJoint : at least one of the PxArticulationLink belongs to this articulation!"); #endif PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "PxArticulationReducedCoordinate::addLoopJoint() not allowed while simulation is running. Call will be ignored.") const PxU32 size = mLoopJoints.size(); if (size >= mLoopJoints.capacity()) mLoopJoints.reserve(size * 2 + 1); NpConstraint* constraint = static_cast<NpConstraint*>(joint); mLoopJoints.pushBack(constraint); Sc::ArticulationSim* scArtSim = mCore.getSim(); Sc::ConstraintSim* cSim = constraint->getCore().getSim(); if(scArtSim) scArtSim->addLoopConstraint(cSim); } void NpArticulationReducedCoordinate::removeLoopJoint(PxConstraint* joint) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "PxArticulationReducedCoordinate::removeLoopJoint() not allowed while simulation is running. Call will be ignored.") NpConstraint* constraint = static_cast<NpConstraint*>(joint); mLoopJoints.findAndReplaceWithLast(constraint); Sc::ArticulationSim* scArtSim = mCore.getSim(); Sc::ConstraintSim* cSim = constraint->getCore().getSim(); scArtSim->removeLoopConstraint(cSim); } PxU32 NpArticulationReducedCoordinate::getNbLoopJoints() const { NP_READ_CHECK(getNpScene()); return mLoopJoints.size(); } PxU32 NpArticulationReducedCoordinate::getLoopJoints(PxConstraint** userBuffer, PxU32 bufferSize, PxU32 startIndex) const { NP_READ_CHECK(getNpScene()); return Cm::getArrayOfPointers(userBuffer, bufferSize, startIndex, mLoopJoints.begin(), mLoopJoints.size()); } PxU32 NpArticulationReducedCoordinate::getCoefficientMatrixSize() const { NP_READ_CHECK(getNpScene()); PX_CHECK_AND_RETURN_NULL(getNpScene(), "PxArticulationReducedCoordinate::getCoefficientMatrixSize: Articulation must be in a scene."); // core will check if in scene and return 0xFFFFFFFF if not. return mCore.getCoefficientMatrixSize(); } void NpArticulationReducedCoordinate::setRootGlobalPose(const PxTransform& pose, bool autowake) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(!mArticulationLinks.empty(), "PxArticulationReducedCoordinate::setRootGlobalPose() called on empty articulation."); PX_CHECK_AND_RETURN(pose.isValid(), "PxArticulationReducedCoordinate::setRootGlobalPose pose is not valid."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "PxArticulationReducedCoordinate::setRootGlobalPose() not allowed while simulation is running. Call will be ignored."); NpArticulationLink* root = mArticulationLinks[0]; root->setGlobalPoseInternal(pose, autowake); } PxTransform NpArticulationReducedCoordinate::getRootGlobalPose() const { NP_READ_CHECK(getNpScene()); PX_CHECK_AND_RETURN_VAL(!mArticulationLinks.empty(), "PxArticulationReducedCoordinate::getRootGlobalPose() called on empty articulation.", PxTransform(PxIdentity)); PX_CHECK_SCENE_API_READ_FORBIDDEN_EXCEPT_COLLIDE_AND_RETURN_VAL(getNpScene(), "PxArticulationReducedCoordinate::getRootGlobalPose() not allowed while simulation is running, except in a split simulation during PxScene::collide() and up to PxScene::advance().", PxTransform(PxIdentity)); NpArticulationLink* root = mArticulationLinks[0]; return root->getGlobalPose(); } void NpArticulationReducedCoordinate::setRootLinearVelocity(const PxVec3& linearVelocity, bool autowake) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(!mArticulationLinks.empty(), "PxArticulationReducedCoordinate::setRootLinearVelocity() called on empty articulation."); PX_CHECK_AND_RETURN(linearVelocity.isFinite(), "PxArticulationReducedCoordinate::setRootLinearVelocity velocity is not finite."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN_EXCEPT_SPLIT_SIM(getNpScene(), "PxArticulationReducedCoordinate::setRootLinearVelocity() not allowed while simulation is running, except in a split simulation in-between PxScene::fetchCollision() and PxScene::advance(). Call will be ignored."); if (getNpScene() && (getNpScene()->getFlags() & PxSceneFlag::eENABLE_DIRECT_GPU_API) && getNpScene()->isDirectGPUAPIInitialized()) { PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "PxArticulationReducedCoordinate::setRootLinearVelocity(): it is illegal to call this method if PxSceneFlag::eENABLE_DIRECT_GPU_API is enabled!"); } NpArticulationLink* root = mArticulationLinks[0]; root->scSetLinearVelocity(linearVelocity); if(getNpScene()) { const bool forceWakeup = !(linearVelocity.isZero()); wakeUpInternal(forceWakeup, autowake); } } void NpArticulationReducedCoordinate::setRootAngularVelocity(const PxVec3& angularVelocity, bool autowake) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(!mArticulationLinks.empty(), "PxArticulationReducedCoordinate::setRootAngularVelocity() called on empty articulation."); PX_CHECK_AND_RETURN(angularVelocity.isFinite(), "PxArticulationReducedCoordinate::setRootAngularVelocity velocity is not finite."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN_EXCEPT_SPLIT_SIM(getNpScene(), "PxArticulationReducedCoordinate::setRootAngularVelocity() not allowed while simulation is running, except in a split simulation in-between PxScene::fetchCollision() and PxScene::advance(). Call will be ignored."); if (getNpScene() && (getNpScene()->getFlags() & PxSceneFlag::eENABLE_DIRECT_GPU_API) && getNpScene()->isDirectGPUAPIInitialized()) { PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "PxArticulationReducedCoordinate::setRootAngularVelocity(): it is illegal to call this method if PxSceneFlag::eENABLE_DIRECT_GPU_API is enabled!"); } NpArticulationLink* root = mArticulationLinks[0]; root->scSetAngularVelocity(angularVelocity); if (getNpScene()) { const bool forceWakeup = !(angularVelocity.isZero()); wakeUpInternal(forceWakeup, autowake); } } PxVec3 NpArticulationReducedCoordinate::getRootLinearVelocity() const { NP_READ_CHECK(getNpScene()); PX_CHECK_AND_RETURN_VAL(!mArticulationLinks.empty(), "PxArticulationReducedCoordinate::getRootLinearVelocity() called on empty articulation.", PxVec3(0.0f)); PX_CHECK_SCENE_API_READ_FORBIDDEN_EXCEPT_COLLIDE_AND_RETURN_VAL(getNpScene(), "PxArticulationReducedCoordinate::getRootLinearVelocity() not allowed while simulation is running, except in a split simulation during PxScene::collide() and up to PxScene::advance().", PxVec3(0.f)); NpArticulationLink* root = mArticulationLinks[0]; return root->getLinearVelocity(); } PxVec3 NpArticulationReducedCoordinate::getRootAngularVelocity() const { NP_READ_CHECK(getNpScene()); PX_CHECK_AND_RETURN_VAL(!mArticulationLinks.empty(), "PxArticulationReducedCoordinate::getRootAngularVelocity() called on empty articulation.", PxVec3(0.0f)); PX_CHECK_SCENE_API_READ_FORBIDDEN_EXCEPT_COLLIDE_AND_RETURN_VAL(getNpScene(), "PxArticulationReducedCoordinate::getRootAngularVelocity() not allowed while simulation is running, except in a split simulation during PxScene::collide() and up to PxScene::advance().", PxVec3(0.f)); NpArticulationLink* root = mArticulationLinks[0]; return root->getAngularVelocity(); } PxSpatialVelocity NpArticulationReducedCoordinate::getLinkAcceleration(const PxU32 linkId) { NP_READ_CHECK(getNpScene()); PX_CHECK_AND_RETURN_VAL(getNpScene(), "PxArticulationReducedCoordinate::getLinkAcceleration: Articulation must be in a scene.", PxSpatialVelocity()); PX_CHECK_AND_RETURN_VAL(linkId < 64, "PxArticulationReducedCoordinate::getLinkAcceleration index is not valid.", PxSpatialVelocity()); PX_CHECK_SCENE_API_READ_FORBIDDEN_EXCEPT_COLLIDE_AND_RETURN_VAL(getNpScene(), "PxArticulationReducedCoordinate::getLinkAcceleration() not allowed while simulation is running, except in a split simulation during PxScene::collide() and up to PxScene::advance().", PxSpatialVelocity()); const bool isGpuSimEnabled = (getNpScene()->getFlags() & PxSceneFlag::eENABLE_GPU_DYNAMICS) ? true : false; return mCore.getLinkAcceleration(linkId, isGpuSimEnabled); } PxU32 NpArticulationReducedCoordinate::getGpuArticulationIndex() { NP_READ_CHECK(getNpScene()); PX_CHECK_AND_RETURN_VAL(getNpScene(), "PxArticulationReducedCoordinate::getGpuArticulationIndex: Articulation must be in a scene.", 0xffffffff); if (getScene()->getFlags() & PxSceneFlag::eENABLE_DIRECT_GPU_API) return mCore.getGpuArticulationIndex(); return 0xffffffff; } PxArticulationSpatialTendon* NpArticulationReducedCoordinate::createSpatialTendon() { if(getNpScene()) { PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "PxArticulationReducedCoordinate::createSpatialTendon() not allowed while the articulation is in a scene. Call will be ignored."); return NULL; } void* tendonMem = PX_ALLOC(sizeof(NpArticulationSpatialTendon), "NpArticulationSpatialTendon"); PxMarkSerializedMemory(tendonMem, sizeof(NpArticulationSpatialTendon)); NpArticulationSpatialTendon* tendon = PX_PLACEMENT_NEW(tendonMem, NpArticulationSpatialTendon)(this); tendon->setHandle(mSpatialTendons.size()); mSpatialTendons.pushBack(tendon); return tendon; } void NpArticulationReducedCoordinate::removeSpatialTendonInternal(NpArticulationSpatialTendon* npTendon) { //we don't need to remove low-level tendon from the articulation sim because the only case the tendon can be removed is //when the whole articulation is removed from the scene and the ArticulationSim get destroyed getNpScene()->scRemoveArticulationSpatialTendon(*npTendon); } PxArticulationFixedTendon* NpArticulationReducedCoordinate::createFixedTendon() { if(getNpScene()) { PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "PxArticulationReducedCoordinate::createFixedTendon() not allowed while the articulation is in a scene. Call will be ignored."); return NULL; } void* tendonMem = PX_ALLOC(sizeof(NpArticulationFixedTendon), "NpArticulationFixedTendon"); PxMarkSerializedMemory(tendonMem, sizeof(NpArticulationFixedTendon)); NpArticulationFixedTendon* tendon = PX_PLACEMENT_NEW(tendonMem, NpArticulationFixedTendon)(this); tendon->setHandle(mFixedTendons.size()); mFixedTendons.pushBack(tendon); return tendon; } void NpArticulationReducedCoordinate::removeFixedTendonInternal(NpArticulationFixedTendon* npTendon) { //we don't need to remove low-level tendon from the articulation sim because the only case the tendon can be removed is //when the whole articulation is removed from the scene and the ArticulationSim get destroyed getNpScene()->scRemoveArticulationFixedTendon(*npTendon); } void NpArticulationReducedCoordinate::removeSensorInternal(NpArticulationSensor* npSensor) { //we don't need to remove low-level sensor from the articulation sim because the only case the tendon can be removed is //when the whole articulation is removed from the scene and the ArticulationSim get destroyed getNpScene()->scRemoveArticulationSensor(*npSensor); } PxArticulationSensor* NpArticulationReducedCoordinate::createSensor(PxArticulationLink* link, const PxTransform& relativePose) { if (getNpScene()) { PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "PxArticulationReducedCoordinate::createSensor() not allowed while the articulation is in a scene. Call will be ignored."); return NULL; } void* sensorMem = PX_ALLOC(sizeof(NpArticulationSensor), "NpArticulationSensor"); PxMarkSerializedMemory(sensorMem, sizeof(NpArticulationSensor)); NpArticulationSensor* sensor = PX_PLACEMENT_NEW(sensorMem, NpArticulationSensor)(link, relativePose); sensor->setHandle(mSensors.size()); mSensors.pushBack(sensor); mTopologyChanged = true; return sensor; } void NpArticulationReducedCoordinate::releaseSensor(PxArticulationSensor& sensor) { if (getNpScene()) { PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "PxArticulationReducedCoordinate::releaseSensor() not allowed while the articulation is in a scene. Call will be ignored."); return; } NpArticulationSensor* npSensor = static_cast<NpArticulationSensor*>(&sensor); const PxU32 handle = npSensor->getHandle(); PX_CHECK_AND_RETURN(handle < mSensors.size() && mSensors[handle] == npSensor, "PxArticulationReducedCoordinate::releaseSensor: Attempt to release sensor that is not part of this articulation."); mSensors.back()->setHandle(handle); mSensors.replaceWithLast(handle); npSensor->~NpArticulationSensor(); if (npSensor->getBaseFlags() & PxBaseFlag::eOWNS_MEMORY) PX_FREE(npSensor); mTopologyChanged = true; } PxU32 NpArticulationReducedCoordinate::getSensors(PxArticulationSensor** userBuffer, PxU32 bufferSize, PxU32 startIndex) const { return Cm::getArrayOfPointers(userBuffer, bufferSize, startIndex, mSensors.begin(), mSensors.size()); } PxU32 NpArticulationReducedCoordinate::getNbSensors() { return mSensors.size(); } NpArticulationSensor* NpArticulationReducedCoordinate::getSensor(const PxU32 index) const { return mSensors[index]; } PxU32 NpArticulationReducedCoordinate::getSpatialTendons(PxArticulationSpatialTendon** userBuffer, PxU32 bufferSize, PxU32 startIndex) const { return Cm::getArrayOfPointers(userBuffer, bufferSize, startIndex, mSpatialTendons.begin(), mSpatialTendons.size()); } PxU32 NpArticulationReducedCoordinate::getNbSpatialTendons() { return mSpatialTendons.size(); } NpArticulationSpatialTendon* NpArticulationReducedCoordinate::getSpatialTendon(const PxU32 index) const { return mSpatialTendons[index]; } PxU32 NpArticulationReducedCoordinate::getFixedTendons(PxArticulationFixedTendon** userBuffer, PxU32 bufferSize, PxU32 startIndex) const { return Cm::getArrayOfPointers(userBuffer, bufferSize, startIndex, mFixedTendons.begin(), mFixedTendons.size()); } PxU32 NpArticulationReducedCoordinate::getNbFixedTendons() { return mFixedTendons.size(); } NpArticulationFixedTendon* NpArticulationReducedCoordinate::getFixedTendon(const PxU32 index) const { return mFixedTendons[index]; } void NpArticulationReducedCoordinate::updateKinematic(PxArticulationKinematicFlags flags) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(getNpScene(), "PxArticulationReducedCoordinate::updateKinematic: Articulation must be in a scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "PxArticulationReducedCoordinate::updateKinematic() not allowed while simulation is running. Call will be ignored."); if (getNpScene() && (getNpScene()->getFlags() & PxSceneFlag::eENABLE_DIRECT_GPU_API) && getNpScene()->isDirectGPUAPIInitialized()) { PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "PxArticulationReducedCoordinate::updateKinematic(): it is illegal to call this method if PxSceneFlag::eENABLE_DIRECT_GPU_API is enabled!"); } if(getNpScene()) { mCore.updateKinematic(flags); const PxU32 linkCount = mArticulationLinks.size(); //KS - the below code forces contact managers to be updated/cached data to be dropped and //shape transforms to be updated. for(PxU32 i = 0; i < linkCount; ++i) { NpArticulationLink* link = mArticulationLinks[i]; //in the lowlevel articulation, we have already updated bodyCore's body2World const PxTransform internalPose = link->getCore().getBody2World(); link->scSetBody2World(internalPose); } } } NpArticulationReducedCoordinate::~NpArticulationReducedCoordinate() { //release tendons for (PxU32 i = 0; i < mSpatialTendons.size(); ++i) { if (mSpatialTendons[i]) { mSpatialTendons[i]->~NpArticulationSpatialTendon(); if(mSpatialTendons[i]->getBaseFlags() & PxBaseFlag::eOWNS_MEMORY) PX_FREE(mSpatialTendons[i]); } } for (PxU32 i = 0; i < mFixedTendons.size(); ++i) { if (mFixedTendons[i]) { mFixedTendons[i]->~NpArticulationFixedTendon(); if(mFixedTendons[i]->getBaseFlags() & PxBaseFlag::eOWNS_MEMORY) PX_FREE(mFixedTendons[i]); } } for (PxU32 i = 0; i < mSensors.size(); ++i) { if (mSensors[i]) { mSensors[i]->~NpArticulationSensor(); if(mSensors[i]->getBaseFlags() & PxBaseFlag::eOWNS_MEMORY) PX_FREE(mSensors[i]); } } NpFactory::getInstance().onArticulationRelease(this); } PxArticulationJointReducedCoordinate* NpArticulationReducedCoordinate::createArticulationJoint(PxArticulationLink& parent, const PxTransform& parentFrame, PxArticulationLink& child, const PxTransform& childFrame) { return NpFactory::getInstance().createNpArticulationJointRC(static_cast<NpArticulationLink&>(parent), parentFrame, static_cast<NpArticulationLink&>(child), childFrame); } void NpArticulationReducedCoordinate::recomputeLinkIDs() { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(getNpScene(), "PxArticulationReducedCoordinate::recomputeLinkIDs: Articulation must be in a scene."); if (!isAPIWriteForbidden()) { Sc::ArticulationSim* scArtSim = getCore().getSim(); if (scArtSim) { physx::NpArticulationLink*const* links = getLinks(); const PxU32 nbLinks = getNbLinks(); for (PxU32 i = 1; i < nbLinks; ++i) { physx::NpArticulationLink* link = links[i]; PxU32 cHandle = scArtSim->findBodyIndex(*link->getCore().getSim()); link->setLLIndex(cHandle); } } } } // PX_SERIALIZATION void NpArticulationReducedCoordinate::requiresObjects(PxProcessPxBaseCallback& c) { // Collect articulation links const PxU32 nbLinks = mArticulationLinks.size(); for (PxU32 i = 0; i < nbLinks; i++) c.process(*mArticulationLinks[i]); const PxU32 nbSensors = mSensors.size(); for (PxU32 i = 0; i < nbSensors; i++) c.process(*mSensors[i]); const PxU32 nbSpatialTendons = mSpatialTendons.size(); for (PxU32 i = 0; i < nbSpatialTendons; i++) c.process(*mSpatialTendons[i]); const PxU32 nbFixedTendons = mFixedTendons.size(); for (PxU32 i = 0; i < nbFixedTendons; i++) c.process(*mFixedTendons[i]); } void NpArticulationReducedCoordinate::exportExtraData(PxSerializationContext& stream) { Cm::exportInlineArray(mArticulationLinks, stream); Cm::exportArray(mSpatialTendons, stream); Cm::exportArray(mFixedTendons, stream); Cm::exportArray(mSensors, stream); stream.writeName(mName); } void NpArticulationReducedCoordinate::importExtraData(PxDeserializationContext& context) { Cm::importInlineArray(mArticulationLinks, context); Cm::importArray(mSpatialTendons, context); Cm::importArray(mFixedTendons, context); Cm::importArray(mSensors, context); context.readName(mName); } void NpArticulationReducedCoordinate::resolveReferences(PxDeserializationContext& context) { const PxU32 nbLinks = mArticulationLinks.size(); for (PxU32 i = 0; i < nbLinks; i++) { NpArticulationLink*& link = mArticulationLinks[i]; context.translatePxBase(link); } const PxU32 nbSensors = mSensors.size(); for (PxU32 i = 0; i < nbSensors; i++) { NpArticulationSensor*& sensor = mSensors[i]; context.translatePxBase(sensor); } const PxU32 nbSpatialTendons = mSpatialTendons.size(); for (PxU32 i = 0; i < nbSpatialTendons; i++) { NpArticulationSpatialTendon*& spatialTendon = mSpatialTendons[i]; context.translatePxBase(spatialTendon); } const PxU32 nbFixedTendons = mFixedTendons.size(); for (PxU32 i = 0; i < nbFixedTendons; i++) { NpArticulationFixedTendon*& fixedTendon = mFixedTendons[i]; context.translatePxBase(fixedTendon); } mAggregate = NULL; } // ~PX_SERIALIZATION void NpArticulationReducedCoordinate::release() { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxArticulationReducedCoordinate::release() not allowed while simulation is running. Call will be ignored."); NpPhysics::getInstance().notifyDeletionListenersUserRelease(this, PxArticulationReducedCoordinate::userData); //!!!AL TODO: Order should not matter in this case. Optimize by having a path which does not restrict release to leaf links or // by using a more advanced data structure PxU32 idx = 0; while (mArticulationLinks.size()) { idx = idx % mArticulationLinks.size(); if (mArticulationLinks[idx]->getNbChildren() == 0) { mArticulationLinks[idx]->releaseInternal(); // deletes joint, link and removes link from list } else { idx++; } } if (npScene) { npScene->removeArticulationTendons(*this); npScene->removeArticulationSensors(*this); npScene->scRemoveArticulation(*this); npScene->removeFromArticulationList(*this); } mArticulationLinks.clear(); NpDestroyArticulation(this); } PxArticulationLink* NpArticulationReducedCoordinate::createLink(PxArticulationLink* parent, const PxTransform& pose) { if(getNpScene()) { PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "PxArticulationReducedCoordinate::createLink() not allowed while the articulation is in a scene. Call will be ignored."); return NULL; } PX_CHECK_AND_RETURN_NULL(pose.isSane(), "PxArticulationReducedCoordinate::createLink: pose is not valid."); if (parent && mArticulationLinks.empty()) { PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "PxArticulationReducedCoordinate::createLink: Root articulation link must have NULL parent pointer!"); return NULL; } // Check if parent is in same articulation is done internally for checked builds if (!parent && !mArticulationLinks.empty()) { PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "PxArticulationReducedCoordinate::createLink: Non-root articulation link must have valid parent pointer!"); return NULL; } NpArticulationLink* parentLink = static_cast<NpArticulationLink*>(parent); NpArticulationLink* link = static_cast<NpArticulationLink*>(NpFactory::getInstance().createArticulationLink(*this, parentLink, pose.getNormalized())); if (link) { addToLinkList(*link); mTopologyChanged = true; } return link; } void NpArticulationReducedCoordinate::setSolverIterationCounts(PxU32 positionIters, PxU32 velocityIters) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(positionIters > 0, "PxArticulationReducedCoordinate::setSolverIterationCount: positionIters must be more than zero!"); PX_CHECK_AND_RETURN(positionIters <= 255, "PxArticulationReducedCoordinate::setSolverIterationCount: positionIters must be no greater than 255!"); PX_CHECK_AND_RETURN(velocityIters <= 255, "PxArticulationReducedCoordinate::setSolverIterationCount: velocityIters must be no greater than 255!"); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "PxArticulationReducedCoordinate::setSolverIterationCounts() not allowed while simulation is running. Call will be ignored."); scSetSolverIterationCounts((velocityIters & 0xff) << 8 | (positionIters & 0xff)); OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationReducedCoordinate, positionIterations, static_cast<const PxArticulationReducedCoordinate&>(*this), positionIters); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationReducedCoordinate, velocityIterations, static_cast<const PxArticulationReducedCoordinate&>(*this), velocityIters); OMNI_PVD_WRITE_SCOPE_END } void NpArticulationReducedCoordinate::getSolverIterationCounts(PxU32& positionIters, PxU32& velocityIters) const { NP_READ_CHECK(getNpScene()); const PxU16 x = mCore.getSolverIterationCounts(); velocityIters = PxU32(x >> 8); positionIters = PxU32(x & 0xff); } void NpArticulationReducedCoordinate::setGlobalPose() { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(getNpScene(), "PxArticulationReducedCoordinate::setGlobalPose: Articulation must be in a scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "PxArticulationReducedCoordinate::setGlobalPose() not allowed while simulation is running. Call will be ignored."); PX_ASSERT(!isAPIWriteForbidden()); mCore.setGlobalPose(); //This code is force PVD to update other links position { physx::NpArticulationLink*const* links = getLinks(); const PxU32 nbLinks = getNbLinks(); for (PxU32 i = 1; i < nbLinks; ++i) { physx::NpArticulationLink* link = links[i]; //in the lowlevel articulation, we have already updated bodyCore's body2World const PxTransform internalPose = link->getCore().getBody2World(); link->scSetBody2World(internalPose); } } } bool NpArticulationReducedCoordinate::isSleeping() const { NP_READ_CHECK(getNpScene()); PX_CHECK_AND_RETURN_VAL(getNpScene(), "PxArticulationReducedCoordinate::isSleeping: Articulation must be in a scene.", true); PX_CHECK_SCENE_API_READ_FORBIDDEN_AND_RETURN_VAL(getNpScene(), "PxArticulationReducedCoordinate::isSleeping() not allowed while simulation is running, except in a split simulation in-between PxScene::fetchCollision() and PxScene::advance().", true); return mCore.isSleeping(); } void NpArticulationReducedCoordinate::setSleepThreshold(PxReal threshold) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "PxArticulationReducedCoordinate::setSleepThreshold() not allowed while simulation is running. Call will be ignored."); scSetSleepThreshold(threshold); OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxArticulationReducedCoordinate, sleepThreshold, static_cast<const PxArticulationReducedCoordinate&>(*this), threshold); } PxReal NpArticulationReducedCoordinate::getSleepThreshold() const { NP_READ_CHECK(getNpScene()); return mCore.getSleepThreshold(); } void NpArticulationReducedCoordinate::setStabilizationThreshold(PxReal threshold) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "PxArticulationReducedCoordinate::setStabilizationThreshold() not allowed while simulation is running. Call will be ignored."); scSetFreezeThreshold(threshold); OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxArticulationReducedCoordinate, stabilizationThreshold, static_cast<const PxArticulationReducedCoordinate&>(*this), threshold); } PxReal NpArticulationReducedCoordinate::getStabilizationThreshold() const { NP_READ_CHECK(getNpScene()); return mCore.getFreezeThreshold(); } void NpArticulationReducedCoordinate::setWakeCounter(PxReal wakeCounterValue) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_SCENE_API_WRITE_FORBIDDEN_EXCEPT_SPLIT_SIM(getNpScene(), "PxArticulationReducedCoordinate::setWakeCounter() not allowed while simulation is running, except in a split simulation in-between PxScene::fetchCollision() and PxScene::advance(). Call will be ignored."); for (PxU32 i = 0; i < mArticulationLinks.size(); i++) { mArticulationLinks[i]->scSetWakeCounter(wakeCounterValue); } scSetWakeCounter(wakeCounterValue); OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxArticulationReducedCoordinate, wakeCounter, static_cast<const PxArticulationReducedCoordinate&>(*this), wakeCounterValue); } PxReal NpArticulationReducedCoordinate::getWakeCounter() const { NP_READ_CHECK(getNpScene()); PX_CHECK_SCENE_API_READ_FORBIDDEN_AND_RETURN_VAL(getNpScene(), "PxArticulationReducedCoordinate::getWakeCounter() not allowed while simulation is running, except in a split simulation in-between PxScene::fetchCollision() and PxScene::advance().", 0.0f); return mCore.getWakeCounter(); } // follows D6 wakeup logic and is used for joint and tendon autowake void NpArticulationReducedCoordinate::autoWakeInternal(void) { PxReal wakeCounter = mCore.getWakeCounter(); if (wakeCounter < getNpScene()->getWakeCounterResetValueInternal()) { wakeCounter = getNpScene()->getWakeCounterResetValueInternal(); for (PxU32 i = 0; i < mArticulationLinks.size(); i++) { mArticulationLinks[i]->scWakeUpInternal(wakeCounter); } scWakeUpInternal(wakeCounter); } } // Follows RB wakeup logic. If autowake is true, increase wakeup counter to at least the scene reset valu // If forceWakeUp is true, wakeup and leave wakeup counter unchanged, so that articulation goes to sleep // again if wakecounter was zero at forceWakeup. The value of forceWakeup has no effect if autowake is true. void NpArticulationReducedCoordinate::wakeUpInternal(bool forceWakeUp, bool autowake) { PX_ASSERT(getNpScene()); PxReal wakeCounterResetValue = getNpScene()->getWakeCounterResetValueInternal(); PxReal wakeCounter = mCore.getWakeCounter(); bool needsWakingUp = isSleeping() && (autowake || forceWakeUp); if (autowake && (wakeCounter < wakeCounterResetValue)) { wakeCounter = wakeCounterResetValue; needsWakingUp = true; } if (needsWakingUp) { for (PxU32 i = 0; i < mArticulationLinks.size(); i++) { mArticulationLinks[i]->scWakeUpInternal(wakeCounter); } scWakeUpInternal(wakeCounter); } } void NpArticulationReducedCoordinate::wakeUp() { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(getNpScene(), "PxArticulationReducedCoordinate::wakeUp: Articulation must be in a scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN_EXCEPT_SPLIT_SIM(getNpScene(), "PxArticulationReducedCoordinate::wakeUp() not allowed while simulation is running, except in a split simulation in-between PxScene::fetchCollision() and PxScene::advance(). Call will be ignored."); for (PxU32 i = 0; i < mArticulationLinks.size(); i++) { mArticulationLinks[i]->scWakeUpInternal(getNpScene()->getWakeCounterResetValueInternal()); } PX_ASSERT(getNpScene()); // only allowed for an object in a scene scWakeUpInternal(getNpScene()->getWakeCounterResetValueInternal()); } void NpArticulationReducedCoordinate::putToSleep() { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(getNpScene(), "PxArticulationReducedCoordinate::putToSleep: Articulation must be in a scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "PxArticulationReducedCoordinate::putToSleep() not allowed while simulation is running. Call will be ignored."); for (PxU32 i = 0; i < mArticulationLinks.size(); i++) { mArticulationLinks[i]->scPutToSleepInternal(); } PX_ASSERT(!isAPIWriteForbidden()); mCore.putToSleep(); } void NpArticulationReducedCoordinate::setMaxCOMLinearVelocity(const PxReal maxLinearVelocity) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "PxArticulationReducedCoordinate::setMaxCOMLinearVelocity() not allowed while simulation is running. Call will be ignored."); scSetMaxLinearVelocity(maxLinearVelocity); OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxArticulationReducedCoordinate, maxLinearVelocity, static_cast<const PxArticulationReducedCoordinate&>(*this), maxLinearVelocity); } PxReal NpArticulationReducedCoordinate::getMaxCOMLinearVelocity() const { NP_READ_CHECK(getNpScene()); return mCore.getMaxLinearVelocity(); } void NpArticulationReducedCoordinate::setMaxCOMAngularVelocity(const PxReal maxAngularVelocity) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "PxArticulationReducedCoordinate::setMaxCOMAngularVelocity() not allowed while simulation is running. Call will be ignored."); scSetMaxAngularVelocity(maxAngularVelocity); OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxArticulationReducedCoordinate, maxAngularVelocity, static_cast<const PxArticulationReducedCoordinate&>(*this), maxAngularVelocity); } PxReal NpArticulationReducedCoordinate::getMaxCOMAngularVelocity() const { NP_READ_CHECK(getNpScene()); return mCore.getMaxAngularVelocity(); } PxU32 NpArticulationReducedCoordinate::getNbLinks() const { NP_READ_CHECK(getNpScene()); return mArticulationLinks.size(); } PxU32 NpArticulationReducedCoordinate::getLinks(PxArticulationLink** userBuffer, PxU32 bufferSize, PxU32 startIndex) const { NP_READ_CHECK(getNpScene()); return Cm::getArrayOfPointers(userBuffer, bufferSize, startIndex, mArticulationLinks.begin(), mArticulationLinks.size()); } PxU32 NpArticulationReducedCoordinate::getNbShapes() const { NP_READ_CHECK(getNpScene()); return mNumShapes; } PxBounds3 NpArticulationReducedCoordinate::getWorldBounds(float inflation) const { NP_READ_CHECK(getNpScene()); PX_CHECK_SCENE_API_READ_FORBIDDEN_EXCEPT_COLLIDE_AND_RETURN_VAL(getNpScene(), "PxArticulationReducedCoordinate::getWorldBounds() not allowed while simulation is running, except in a split simulation during PxScene::collide() and up to PxScene::advance().", PxBounds3::empty()); PxBounds3 bounds = PxBounds3::empty(); for (PxU32 i = 0; i < mArticulationLinks.size(); i++) { bounds.include(mArticulationLinks[i]->getWorldBounds()); } PX_ASSERT(bounds.isValid()); // PT: unfortunately we can't just scale the min/max vectors, we need to go through center/extents. const PxVec3 center = bounds.getCenter(); const PxVec3 inflatedExtents = bounds.getExtents() * inflation; return PxBounds3::centerExtents(center, inflatedExtents); } PxAggregate* NpArticulationReducedCoordinate::getAggregate() const { NP_READ_CHECK(getNpScene()); return mAggregate; } void NpArticulationReducedCoordinate::setName(const char* debugName) { NP_WRITE_CHECK(getNpScene()); mName = debugName; } const char* NpArticulationReducedCoordinate::getName() const { NP_READ_CHECK(getNpScene()); return mName; } NpArticulationLink* NpArticulationReducedCoordinate::getRoot() { if (!mArticulationLinks.size()) return NULL; PX_ASSERT(mArticulationLinks[0]->getInboundJoint() == NULL); return mArticulationLinks[0]; } void NpArticulationReducedCoordinate::setAggregate(PxAggregate* a) { mAggregate = static_cast<NpAggregate*>(a); }
49,981
C++
39.536902
286
0.786319
NVIDIA-Omniverse/PhysX/physx/source/physx/src/NpPruningStructure.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #include "NpPruningStructure.h" #include "GuAABBTree.h" #include "GuAABBTreeNode.h" #include "NpBounds.h" #include "NpRigidDynamic.h" #include "NpRigidStatic.h" #include "NpShape.h" #include "GuBounds.h" #include "CmTransformUtils.h" #include "CmUtils.h" #include "SqPrunerData.h" using namespace physx; using namespace Sq; using namespace Gu; ////////////////////////////////////////////////////////////////////////// #define PS_NB_OBJECTS_PER_NODE 4 ////////////////////////////////////////////////////////////////////////// PruningStructure::PruningStructure(PxBaseFlags baseFlags) : PxPruningStructure(baseFlags) { } ////////////////////////////////////////////////////////////////////////// PruningStructure::PruningStructure() : PxPruningStructure(PxConcreteType::ePRUNING_STRUCTURE, PxBaseFlag::eOWNS_MEMORY | PxBaseFlag::eIS_RELEASABLE), mNbActors(0), mActors(0), mValid(true) { for(PxU32 i=0; i<2; i++) mData[i].init(); } ////////////////////////////////////////////////////////////////////////// PruningStructure::~PruningStructure() { if(getBaseFlags() & PxBaseFlag::eOWNS_MEMORY) { for(PxU32 i=0; i<2; i++) { PX_FREE(mData[i].mAABBTreeIndices); PX_FREE(mData[i].mAABBTreeNodes); } PX_FREE(mActors); } } ////////////////////////////////////////////////////////////////////////// void PruningStructure::release() { // if we release the pruning structure we set the pruner structure to NUUL for (PxU32 i = 0; i < mNbActors; i++) { PX_ASSERT(mActors[i]); PxType type = mActors[i]->getConcreteType(); if (type == PxConcreteType::eRIGID_STATIC) static_cast<NpRigidStatic*>(mActors[i])->getShapeManager().setPruningStructure(NULL); else if (type == PxConcreteType::eRIGID_DYNAMIC) static_cast<NpRigidDynamic*>(mActors[i])->getShapeManager().setPruningStructure(NULL); } if(getBaseFlags() & PxBaseFlag::eOWNS_MEMORY) PX_DELETE_THIS; else this->~PruningStructure(); } template <typename ActorType> static void getShapeBounds(PxRigidActor* actor, bool dynamic, PxBounds3* bounds, PxU32& numShapes) { PruningIndex::Enum treeStructure = dynamic ? PruningIndex::eDYNAMIC : PruningIndex::eSTATIC; ActorType& a = *static_cast<ActorType*>(actor); const PxU32 nbShapes = a.getNbShapes(); for (PxU32 iShape = 0; iShape < nbShapes; iShape++) { NpShape* shape = a.getShapeManager().getShapes()[iShape]; if (shape->getFlags() & PxShapeFlag::eSCENE_QUERY_SHAPE) { (gComputeBoundsTable[treeStructure])(*bounds, *shape, a); bounds++; numShapes++; } } } ////////////////////////////////////////////////////////////////////////// bool PruningStructure::build(PxRigidActor*const* actors, PxU32 nbActors) { PX_ASSERT(actors); PX_ASSERT(nbActors > 0); PxU32 numShapes[2] = { 0, 0 }; // parse the actors first to get the shapes size for (PxU32 actorsDone = 0; actorsDone < nbActors; actorsDone++) { if (actorsDone + 1 < nbActors) PxPrefetch(actors[actorsDone + 1], sizeof(NpRigidDynamic)); // worst case: PxRigidStatic is smaller PxType type = actors[actorsDone]->getConcreteType(); const PxRigidActor& actor = *(actors[actorsDone]); NpScene* scene = NpActor::getFromPxActor(actor).getNpScene(); if(scene) { PxGetFoundation().error(PxErrorCode::eINVALID_PARAMETER, PX_FL, "PrunerStructure::build: Actor already assigned to a scene!"); return false; } const PxU32 nbShapes = actor.getNbShapes(); bool hasQueryShape = false; for (PxU32 iShape = 0; iShape < nbShapes; iShape++) { PxShape* shape; actor.getShapes(&shape, 1, iShape); if(shape->getFlags() & PxShapeFlag::eSCENE_QUERY_SHAPE) { hasQueryShape = true; if (type == PxConcreteType::eRIGID_STATIC) numShapes[PruningIndex::eSTATIC]++; else numShapes[PruningIndex::eDYNAMIC]++; } } // each provided actor must have a query shape if(!hasQueryShape) { PxGetFoundation().error(PxErrorCode::eINVALID_PARAMETER, PX_FL, "PrunerStructure::build: Provided actor has no scene query shape!"); return false; } if (type == PxConcreteType::eRIGID_STATIC) { NpRigidStatic* rs = static_cast<NpRigidStatic*>(actors[actorsDone]); if(rs->getShapeManager().getPruningStructure()) { PxGetFoundation().error(PxErrorCode::eINVALID_PARAMETER, PX_FL, "PrunerStructure::build: Provided actor has already a pruning structure!"); return false; } rs->getShapeManager().setPruningStructure(this); } else if (type == PxConcreteType::eRIGID_DYNAMIC) { NpRigidDynamic* rd = static_cast<NpRigidDynamic*>(actors[actorsDone]); if (rd->getShapeManager().getPruningStructure()) { PxGetFoundation().error(PxErrorCode::eINVALID_PARAMETER, PX_FL, "PrunerStructure::build: Provided actor has already a pruning structure!"); return false; } rd->getShapeManager().setPruningStructure(this); } else { PxGetFoundation().error(PxErrorCode::eINVALID_PARAMETER, PX_FL, "PrunerStructure::build: Provided actor is not a rigid actor!"); return false; } } AABBTreeBounds bounds[2]; for (PxU32 i = 0; i < 2; i++) { if(numShapes[i]) { bounds[i].init(numShapes[i]); } } // now I go again and gather bounds and payload numShapes[PruningIndex::eSTATIC] = 0; numShapes[PruningIndex::eDYNAMIC] = 0; for (PxU32 actorsDone = 0; actorsDone < nbActors; actorsDone++) { PxType type = actors[actorsDone]->getConcreteType(); if (type == PxConcreteType::eRIGID_STATIC) { getShapeBounds<NpRigidStatic>(actors[actorsDone], false, &bounds[PruningIndex::eSTATIC].getBounds()[numShapes[PruningIndex::eSTATIC]], numShapes[PruningIndex::eSTATIC]); } else if (type == PxConcreteType::eRIGID_DYNAMIC) { getShapeBounds<NpRigidDynamic>(actors[actorsDone], true, &bounds[PruningIndex::eDYNAMIC].getBounds()[numShapes[PruningIndex::eDYNAMIC]], numShapes[PruningIndex::eDYNAMIC]); } } AABBTree aabbTrees[2]; for (PxU32 i = 0; i < 2; i++) { mData[i].mNbObjects = numShapes[i]; if (numShapes[i]) { // create the AABB tree NodeAllocator nodeAllocator; bool status = aabbTrees[i].build(AABBTreeBuildParams(PS_NB_OBJECTS_PER_NODE, numShapes[i], &bounds[i]), nodeAllocator); PX_UNUSED(status); PX_ASSERT(status); // store the tree nodes mData[i].mNbNodes = aabbTrees[i].getNbNodes(); mData[i].mAABBTreeNodes = PX_ALLOCATE(BVHNode, mData[i].mNbNodes, "BVHNode"); PxMemCopy(mData[i].mAABBTreeNodes, aabbTrees[i].getNodes(), sizeof(BVHNode)*mData[i].mNbNodes); mData[i].mAABBTreeIndices = PX_ALLOCATE(PxU32, mData[i].mNbObjects, "PxU32"); PxMemCopy(mData[i].mAABBTreeIndices, aabbTrees[i].getIndices(), sizeof(PxU32)*mData[i].mNbObjects); // discard the data bounds[i].release(); } } // store the actors for verification and serialization mNbActors = nbActors; mActors = PX_ALLOCATE(PxActor*, mNbActors, "PxActor*"); PxMemCopy(mActors, actors, sizeof(PxActor*)*mNbActors); return true; } ////////////////////////////////////////////////////////////////////////// PruningStructure* PruningStructure::createObject(PxU8*& address, PxDeserializationContext& context) { PruningStructure* obj = PX_PLACEMENT_NEW(address, PruningStructure(PxBaseFlag::eIS_RELEASABLE)); address += sizeof(PruningStructure); obj->importExtraData(context); obj->resolveReferences(context); return obj; } ////////////////////////////////////////////////////////////////////////// void PruningStructure::resolveReferences(PxDeserializationContext& context) { if (!isValid()) return; for (PxU32 i = 0; i < mNbActors; i++) context.translatePxBase(mActors[i]); } ////////////////////////////////////////////////////////////////////////// void PruningStructure::requiresObjects(PxProcessPxBaseCallback& c) { if (!isValid()) return; for (PxU32 i = 0; i < mNbActors; i++) c.process(*mActors[i]); } ////////////////////////////////////////////////////////////////////////// void PruningStructure::exportExtraData(PxSerializationContext& stream) { if (!isValid()) { PxGetFoundation().error(PxErrorCode::eDEBUG_WARNING, PX_FL, "PrunerStructure::exportExtraData: Pruning structure is invalid!"); return; } for (PxU32 i = 0; i < 2; i++) { if (mData[i].mAABBTreeNodes) { // store nodes stream.alignData(PX_SERIAL_ALIGN); stream.writeData(mData[i].mAABBTreeNodes, mData[i].mNbNodes * sizeof(BVHNode)); } if(mData[i].mAABBTreeIndices) { // store indices stream.alignData(PX_SERIAL_ALIGN); stream.writeData(mData[i].mAABBTreeIndices, mData[i].mNbObjects * sizeof(PxU32)); } } if(mActors) { // store actor pointers stream.alignData(PX_SERIAL_ALIGN); stream.writeData(mActors, mNbActors * sizeof(PxActor*)); } } ////////////////////////////////////////////////////////////////////////// void PruningStructure::importExtraData(PxDeserializationContext& context) { if (!isValid()) { PxGetFoundation().error(PxErrorCode::eDEBUG_WARNING, PX_FL, "PrunerStructure::importExtraData: Pruning structure is invalid!"); return; } for (PxU32 i = 0; i < 2; i++) { if (mData[i].mAABBTreeNodes) mData[i].mAABBTreeNodes = context.readExtraData<BVHNode, PX_SERIAL_ALIGN>(mData[i].mNbNodes); if(mData[i].mAABBTreeIndices) mData[i].mAABBTreeIndices = context.readExtraData<PxU32, PX_SERIAL_ALIGN>(mData[i].mNbObjects); } if (mActors) { // read actor pointers mActors = context.readExtraData<PxActor*, PX_SERIAL_ALIGN>(mNbActors); } } ////////////////////////////////////////////////////////////////////////// PxU32 PruningStructure::getNbRigidActors() const { return mNbActors; } const void* PruningStructure::getStaticMergeData() const { return &mData[PruningIndex::eSTATIC]; } const void* PruningStructure::getDynamicMergeData() const { return &mData[PruningIndex::eDYNAMIC]; } PxU32 PruningStructure::getRigidActors(PxRigidActor** userBuffer, PxU32 bufferSize, PxU32 startIndex/* =0 */) const { if(!isValid()) { PxGetFoundation().error(PxErrorCode::eDEBUG_WARNING, PX_FL, "PrunerStructure::getRigidActors: Pruning structure is invalid!"); return 0; } return Cm::getArrayOfPointers(userBuffer, bufferSize, startIndex, mActors, mNbActors); } ////////////////////////////////////////////////////////////////////////// void PruningStructure::invalidate(PxActor* actor) { PX_ASSERT(actor); // remove actor from the actor list to avoid mem corruption // this slow, but should be called only with error msg send to user about invalid behavior for (PxU32 i = 0; i < mNbActors; i++) { if(mActors[i] == actor) { // set pruning structure to NULL and remove the actor from the list PxType type = mActors[i]->getConcreteType(); if (type == PxConcreteType::eRIGID_STATIC) static_cast<NpRigidStatic*>(mActors[i])->getShapeManager().setPruningStructure(NULL); else if (type == PxConcreteType::eRIGID_DYNAMIC) static_cast<NpRigidDynamic*>(mActors[i])->getShapeManager().setPruningStructure(NULL); mActors[i] = mActors[mNbActors--]; break; } } mValid = false; }
12,679
C++
30.542288
175
0.664642
NVIDIA-Omniverse/PhysX/physx/source/physx/src/NpPBDMaterial.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef NP_PBD_MATERIAL_H #define NP_PBD_MATERIAL_H #include "common/PxSerialFramework.h" #include "foundation/PxUserAllocated.h" #include "foundation/PxUtilities.h" #include "CmRefCountable.h" #include "PxsPBDMaterialCore.h" #include "PxPBDMaterial.h" namespace physx { // Compared to other objects, materials are special since they belong to the SDK and not to scenes // (similar to meshes). That's why the NpPBDMaterial does have direct access to the core material instead // of having a buffered interface for it. Scenes will have copies of the SDK material table and there // the materials will be buffered. class NpPBDMaterial : public PxPBDMaterial, public PxUserAllocated { public: // PX_SERIALIZATION NpPBDMaterial(PxBaseFlags baseFlags) : PxPBDMaterial(baseFlags), mMaterial(PxEmpty) {} virtual void resolveReferences(PxDeserializationContext& context); static NpPBDMaterial* createObject(PxU8*& address, PxDeserializationContext& context); static void getBinaryMetaData(PxOutputStream& stream); void preExportDataReset() { Cm::RefCountable_preExportDataReset(*this); } void exportExtraData(PxSerializationContext&) {} void importExtraData(PxDeserializationContext&) {} virtual void requiresObjects(PxProcessPxBaseCallback&) {} //~PX_SERIALIZATION NpPBDMaterial(const PxsPBDMaterialCore& desc); virtual ~NpPBDMaterial(); // PxBase virtual void release() PX_OVERRIDE; //~PxBase // PxRefCounted virtual void acquireReference() PX_OVERRIDE; virtual PxU32 getReferenceCount() const PX_OVERRIDE; virtual void onRefCountZero() PX_OVERRIDE; //~PxRefCounted // PxParticleMaterial virtual void setFriction(PxReal friction) PX_OVERRIDE; virtual PxReal getFriction() const PX_OVERRIDE; virtual void setDamping(PxReal damping) PX_OVERRIDE; virtual PxReal getDamping() const PX_OVERRIDE; virtual void setAdhesion(PxReal adhesion) PX_OVERRIDE; virtual PxReal getAdhesion() const PX_OVERRIDE; virtual void setGravityScale(PxReal scale) PX_OVERRIDE; virtual PxReal getGravityScale() const PX_OVERRIDE; virtual void setAdhesionRadiusScale(PxReal scale) PX_OVERRIDE; virtual PxReal getAdhesionRadiusScale() const PX_OVERRIDE; //~PxParticleMaterial // PxPBDMaterial virtual void setViscosity(PxReal viscosity) PX_OVERRIDE; virtual PxReal getViscosity() const PX_OVERRIDE; virtual void setVorticityConfinement(PxReal vorticityConfinement) PX_OVERRIDE; virtual PxReal getVorticityConfinement() const PX_OVERRIDE; virtual void setSurfaceTension(PxReal surfaceTension) PX_OVERRIDE; virtual PxReal getSurfaceTension() const PX_OVERRIDE; virtual void setCohesion(PxReal cohesion) PX_OVERRIDE; virtual PxReal getCohesion() const PX_OVERRIDE; virtual void setLift(PxReal lift) PX_OVERRIDE; virtual PxReal getLift() const PX_OVERRIDE; virtual void setDrag(PxReal drag) PX_OVERRIDE; virtual PxReal getDrag() const PX_OVERRIDE; virtual void setCFLCoefficient(PxReal coefficient) PX_OVERRIDE; virtual PxReal getCFLCoefficient() const PX_OVERRIDE; virtual void setParticleFrictionScale(PxReal scale) PX_OVERRIDE; virtual PxReal getParticleFrictionScale() const PX_OVERRIDE; virtual void setParticleAdhesionScale(PxReal adhesion) PX_OVERRIDE; virtual PxReal getParticleAdhesionScale() const PX_OVERRIDE; //~PxPBDMaterial PX_FORCE_INLINE static void getMaterialIndices(NpPBDMaterial*const* materials, PxU16* materialIndices, PxU32 materialCount); private: PX_INLINE void updateMaterial(); // PX_SERIALIZATION public: //~PX_SERIALIZATION PxsPBDMaterialCore mMaterial; }; PX_FORCE_INLINE void NpPBDMaterial::getMaterialIndices(NpPBDMaterial*const* materials, PxU16* materialIndices, PxU32 materialCount) { for (PxU32 i = 0; i < materialCount; i++) materialIndices[i] = static_cast<NpPBDMaterial*>(materials[i])->mMaterial.mMaterialIndex; } } #endif
5,769
C
44.79365
132
0.753337
NVIDIA-Omniverse/PhysX/physx/source/physx/src/NpArticulationTendon.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef NP_ARTICULATION_TENDON_H #define NP_ARTICULATION_TENDON_H #include "foundation/PxInlineArray.h" #include "PxArticulationTendon.h" #include "ScArticulationTendonCore.h" #include "ScArticulationAttachmentCore.h" #include "ScArticulationTendonJointCore.h" #include "NpBase.h" namespace physx { typedef PxU32 ArticulationAttachmentHandle; typedef PxU32 ArticulationTendonHandle; class NpArticulationReducedCoordinate; class NpArticulationAttachment; class NpArticulationSpatialTendon; class NpArticulationTendonJoint; class NpArticulationFixedTendon; class NpArticulationAttachmentArray : public PxInlineArray<NpArticulationAttachment*, 4> //!!!AL TODO: check if default of 4 elements makes sense { public: // PX_SERIALIZATION NpArticulationAttachmentArray(const PxEMPTY) : PxInlineArray<NpArticulationAttachment*, 4>(PxEmpty) {} static void getBinaryMetaData(PxOutputStream& stream); //~PX_SERIALIZATION NpArticulationAttachmentArray() : PxInlineArray<NpArticulationAttachment*, 4>("NpArticulationAttachmentArray") {} }; class NpArticulationTendonJointArray : public PxInlineArray<NpArticulationTendonJoint*, 4> //!!!AL TODO: check if default of 4 elements makes sense { public: // PX_SERIALIZATION NpArticulationTendonJointArray(const PxEMPTY) : PxInlineArray<NpArticulationTendonJoint*, 4>(PxEmpty) {} static void getBinaryMetaData(PxOutputStream& stream); //~PX_SERIALIZATION NpArticulationTendonJointArray() : PxInlineArray<NpArticulationTendonJoint*, 4>("NpArticulationTendonJointArray") {} }; class NpArticulationAttachment : public PxArticulationAttachment, public NpBase { public: // PX_SERIALIZATION NpArticulationAttachment(PxBaseFlags baseFlags) : PxArticulationAttachment(baseFlags), NpBase(PxEmpty), mHandle(PxEmpty), mChildren(PxEmpty), mCore(PxEmpty) {} void preExportDataReset() { mCore.preExportDataReset(); } virtual void exportExtraData(PxSerializationContext& ); void importExtraData(PxDeserializationContext& ); void resolveReferences(PxDeserializationContext& ); virtual void requiresObjects(PxProcessPxBaseCallback&); virtual bool isSubordinate() const { return true; } static NpArticulationAttachment* createObject(PxU8*& address, PxDeserializationContext& context); static void getBinaryMetaData(PxOutputStream& stream); //~PX_SERIALIZATION NpArticulationAttachment(PxArticulationAttachment* parent, const PxReal coefficient, const PxVec3 relativeOffset, PxArticulationLink* link); virtual ~NpArticulationAttachment(); virtual void setRestLength(const PxReal restLength); virtual PxReal getRestLength() const; virtual void setLimitParameters(const PxArticulationTendonLimit& paramters); virtual PxArticulationTendonLimit getLimitParameters() const; virtual void setRelativeOffset(const PxVec3& offset); virtual PxVec3 getRelativeOffset() const; virtual void setCoefficient(const PxReal coefficient); virtual PxReal getCoefficient() const; virtual PxArticulationLink* getLink() const { return mLink; } virtual PxArticulationAttachment* getParent() const { return mParent; } virtual PxArticulationSpatialTendon* getTendon() const; virtual bool isLeaf() const { return mChildren.empty(); } virtual void release(); PX_FORCE_INLINE NpArticulationAttachment** getChildren() { return mChildren.begin(); } PX_FORCE_INLINE PxU32 getNumChildren() { return mChildren.size(); } PX_FORCE_INLINE void setTendon(NpArticulationSpatialTendon* tendon) { mTendon = tendon; } PX_FORCE_INLINE NpArticulationSpatialTendon& getTendon() { return *mTendon; } PX_FORCE_INLINE Sc::ArticulationAttachmentCore& getCore() { return mCore; } void removeChild(NpArticulationAttachment* child); PxArticulationLink* mLink; //the link this attachment attach to PxArticulationAttachment* mParent; ArticulationAttachmentHandle mHandle; NpArticulationAttachmentArray mChildren; NpArticulationSpatialTendon* mTendon; Sc::ArticulationAttachmentCore mCore; }; class NpArticulationSpatialTendon : public PxArticulationSpatialTendon, public NpBase { public: // PX_SERIALIZATION NpArticulationSpatialTendon(PxBaseFlags baseFlags) : PxArticulationSpatialTendon(baseFlags), NpBase(PxEmpty), mAttachments(PxEmpty), mCore(PxEmpty) {} void preExportDataReset() { mCore.preExportDataReset(); } virtual void exportExtraData(PxSerializationContext& ); void importExtraData(PxDeserializationContext& ); void resolveReferences(PxDeserializationContext& ); virtual void requiresObjects(PxProcessPxBaseCallback&); virtual bool isSubordinate() const { return true; } static NpArticulationSpatialTendon* createObject(PxU8*& address, PxDeserializationContext& context); static void getBinaryMetaData(PxOutputStream& stream); //~PX_SERIALIZATION NpArticulationSpatialTendon(NpArticulationReducedCoordinate* articulation); virtual ~NpArticulationSpatialTendon(); virtual PxArticulationAttachment* createAttachment(PxArticulationAttachment* parent, const PxReal coefficient, const PxVec3 relativeOffset, PxArticulationLink* link); NpArticulationAttachment* getAttachment(const PxU32 index); virtual PxU32 getAttachments(PxArticulationAttachment** userBuffer, PxU32 bufferSize, PxU32 startIndex) const; PxU32 getNbAttachments() const; virtual void setStiffness(const PxReal stiffness); virtual PxReal getStiffness() const; virtual void setDamping(const PxReal damping); virtual PxReal getDamping() const; virtual void setLimitStiffness(const PxReal stiffness); virtual PxReal getLimitStiffness() const; virtual void setOffset(const PxReal offset, bool autowake = true); virtual PxReal getOffset() const; virtual PxArticulationReducedCoordinate* getArticulation() const; virtual void release(); PX_FORCE_INLINE Sc::ArticulationSpatialTendonCore& getTendonCore() { return mCore; } PX_FORCE_INLINE ArticulationTendonHandle getHandle() { return mHandle; } PX_FORCE_INLINE void setHandle(ArticulationTendonHandle handle) { mHandle = handle; } PX_FORCE_INLINE NpArticulationAttachmentArray& getAttachments() { return mAttachments; } private: NpArticulationAttachmentArray mAttachments; NpArticulationReducedCoordinate* mArticulation; PxU32 mLLIndex; Sc::ArticulationSpatialTendonCore mCore; ArticulationTendonHandle mHandle; }; class NpArticulationTendonJoint : public PxArticulationTendonJoint, public NpBase { public: // PX_SERIALIZATION NpArticulationTendonJoint(PxBaseFlags baseFlags) : PxArticulationTendonJoint(baseFlags), NpBase(PxEmpty), mChildren(PxEmpty), mCore(PxEmpty), mHandle(PxEmpty) {} void preExportDataReset() { mCore.preExportDataReset(); } virtual void exportExtraData(PxSerializationContext& ); void importExtraData(PxDeserializationContext& ); void resolveReferences(PxDeserializationContext& ); virtual void requiresObjects(PxProcessPxBaseCallback&); virtual bool isSubordinate() const { return true; } static NpArticulationTendonJoint* createObject(PxU8*& address, PxDeserializationContext& context); static void getBinaryMetaData(PxOutputStream& stream); //~PX_SERIALIZATION NpArticulationTendonJoint(PxArticulationTendonJoint* parent, PxArticulationAxis::Enum axis, const PxReal coefficient, const PxReal recipCoefficient, PxArticulationLink* link); virtual ~NpArticulationTendonJoint(){} virtual PxArticulationLink* getLink() const { return mLink; } virtual PxArticulationTendonJoint* getParent() const { return mParent; } virtual PxArticulationFixedTendon* getTendon() const; virtual void setCoefficient(const PxArticulationAxis::Enum axis, const PxReal coefficient, const PxReal recipCoefficient); virtual void getCoefficient(PxArticulationAxis::Enum& axis, PxReal& coefficient, PxReal& recipCoefficient) const; virtual void release(); PX_FORCE_INLINE NpArticulationTendonJoint** getChildren() { return mChildren.begin(); } PX_FORCE_INLINE PxU32 getNumChildren() { return mChildren.size(); } PX_FORCE_INLINE void setTendon(NpArticulationFixedTendon* tendon) { mTendon = tendon; } PX_FORCE_INLINE NpArticulationFixedTendon& getTendon() { return *mTendon; } PX_FORCE_INLINE Sc::ArticulationTendonJointCore& getCore() { return mCore; } void removeChild(NpArticulationTendonJoint* child); PxArticulationLink* mLink; //the link this joint associated with PxArticulationTendonJoint* mParent; NpArticulationTendonJointArray mChildren; NpArticulationFixedTendon* mTendon; Sc::ArticulationTendonJointCore mCore; PxU32 mHandle; }; class NpArticulationFixedTendon : public PxArticulationFixedTendon, public NpBase { public: // PX_SERIALIZATION NpArticulationFixedTendon(PxBaseFlags baseFlags): PxArticulationFixedTendon(baseFlags), NpBase(PxEmpty), mTendonJoints(PxEmpty), mCore(PxEmpty), mHandle(PxEmpty) {} void preExportDataReset() {} virtual void exportExtraData(PxSerializationContext& ); void importExtraData(PxDeserializationContext& ); void resolveReferences(PxDeserializationContext& ); virtual void requiresObjects(PxProcessPxBaseCallback&); virtual bool isSubordinate() const { return true; } static NpArticulationFixedTendon* createObject(PxU8*& address, PxDeserializationContext& context); static void getBinaryMetaData(PxOutputStream& stream); //~PX_SERIALIZATION NpArticulationFixedTendon(NpArticulationReducedCoordinate* articulation); virtual ~NpArticulationFixedTendon(); virtual PxArticulationTendonJoint* createTendonJoint(PxArticulationTendonJoint* parent, PxArticulationAxis::Enum axis, const PxReal scale, const PxReal recipScale, PxArticulationLink* link); NpArticulationTendonJoint* getTendonJoint(const PxU32 index); virtual PxU32 getTendonJoints(PxArticulationTendonJoint** userBuffer, PxU32 bufferSize, PxU32 startIndex) const; virtual PxU32 getNbTendonJoints(void) const; virtual void setStiffness(const PxReal stiffness); virtual PxReal getStiffness() const; virtual void setDamping(const PxReal damping); virtual PxReal getDamping() const; virtual void setLimitStiffness(const PxReal damping); virtual PxReal getLimitStiffness() const; virtual void setRestLength(const PxReal restLength); virtual PxReal getRestLength() const; virtual void setLimitParameters(const PxArticulationTendonLimit& paramters); virtual PxArticulationTendonLimit getLimitParameters() const; virtual void setOffset(const PxReal offset, bool autowake = true); virtual PxReal getOffset() const; virtual PxArticulationReducedCoordinate* getArticulation() const; virtual void release(); PX_FORCE_INLINE ArticulationTendonHandle getHandle() { return mHandle; } PX_FORCE_INLINE void setHandle(ArticulationTendonHandle handle) { mHandle = handle; } PX_FORCE_INLINE Sc::ArticulationFixedTendonCore& getTendonCore() { return mCore; } PX_FORCE_INLINE NpArticulationTendonJointArray& getTendonJoints() { return mTendonJoints; } private: NpArticulationTendonJointArray mTendonJoints; NpArticulationReducedCoordinate* mArticulation; PxU32 mLLIndex; Sc::ArticulationFixedTendonCore mCore; ArticulationTendonHandle mHandle; }; } #endif
13,267
C
41.8
193
0.772292
NVIDIA-Omniverse/PhysX/physx/source/physx/src/PvdMetaDataPvdBinding.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. // suppress LNK4221 #include "foundation/PxPreprocessor.h" PX_DUMMY_SYMBOL #if PX_SUPPORT_PVD #include "foundation/PxSimpleTypes.h" #include "foundation/Px.h" #include "PxMetaDataObjects.h" #include "PxPvdDataStream.h" #include "PxScene.h" #include "ScBodyCore.h" #include "PvdMetaDataExtensions.h" #include "PvdMetaDataPropertyVisitor.h" #include "PvdMetaDataDefineProperties.h" #include "PvdMetaDataBindingData.h" #include "PxRigidDynamic.h" #include "PxArticulationReducedCoordinate.h" #include "PxArticulationLink.h" #include "NpScene.h" #include "NpPhysics.h" #include "PvdTypeNames.h" #include "PvdMetaDataPvdBinding.h" using namespace physx; using namespace Sc; using namespace Vd; using namespace Sq; namespace physx { namespace Vd { struct NameValuePair { const char* mName; PxU32 mValue; }; #if PX_LINUX && PX_CLANG #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wreserved-identifier" #endif static const NameValuePair g_physx_Sq_SceneQueryID__EnumConversion[] = { { "QUERY_RAYCAST_ANY_OBJECT", PxU32(QueryID::QUERY_RAYCAST_ANY_OBJECT) }, { "QUERY_RAYCAST_CLOSEST_OBJECT", PxU32(QueryID::QUERY_RAYCAST_CLOSEST_OBJECT) }, { "QUERY_RAYCAST_ALL_OBJECTS", PxU32(QueryID::QUERY_RAYCAST_ALL_OBJECTS) }, { "QUERY_OVERLAP_SPHERE_ALL_OBJECTS", PxU32(QueryID::QUERY_OVERLAP_SPHERE_ALL_OBJECTS) }, { "QUERY_OVERLAP_AABB_ALL_OBJECTS", PxU32(QueryID::QUERY_OVERLAP_AABB_ALL_OBJECTS) }, { "QUERY_OVERLAP_OBB_ALL_OBJECTS", PxU32(QueryID::QUERY_OVERLAP_OBB_ALL_OBJECTS) }, { "QUERY_OVERLAP_CAPSULE_ALL_OBJECTS", PxU32(QueryID::QUERY_OVERLAP_CAPSULE_ALL_OBJECTS) }, { "QUERY_OVERLAP_CONVEX_ALL_OBJECTS", PxU32(QueryID::QUERY_OVERLAP_CONVEX_ALL_OBJECTS) }, { "QUERY_LINEAR_OBB_SWEEP_CLOSEST_OBJECT", PxU32(QueryID::QUERY_LINEAR_OBB_SWEEP_CLOSEST_OBJECT) }, { "QUERY_LINEAR_CAPSULE_SWEEP_CLOSEST_OBJECT", PxU32(QueryID::QUERY_LINEAR_CAPSULE_SWEEP_CLOSEST_OBJECT) }, { "QUERY_LINEAR_CONVEX_SWEEP_CLOSEST_OBJECT", PxU32(QueryID::QUERY_LINEAR_CONVEX_SWEEP_CLOSEST_OBJECT) }, { NULL, 0 } }; #if PX_LINUX && PX_CLANG #pragma clang diagnostic pop #endif struct SceneQueryIDConvertor { const NameValuePair* NameConversion; SceneQueryIDConvertor() : NameConversion(g_physx_Sq_SceneQueryID__EnumConversion) { } }; PvdMetaDataBinding::PvdMetaDataBinding() : mBindingData(PX_NEW(PvdMetaDataBindingData)()) { } PvdMetaDataBinding::~PvdMetaDataBinding() { for(OwnerActorsMap::Iterator iter = mBindingData->mOwnerActorsMap.getIterator(); !iter.done(); iter++) { iter->second->~OwnerActorsValueType(); PX_FREE(iter->second); } PX_DELETE(mBindingData); } template <typename TDataType, typename TValueType, typename TClassType> static inline void definePropertyStruct(PvdDataStream& inStream, const char* pushName = NULL) { PvdPropertyDefinitionHelper& helper(inStream.getPropertyDefinitionHelper()); PvdClassInfoValueStructDefine definitionObj(helper); bool doPush = pushName && *pushName; if(doPush) definitionObj.pushName(pushName); visitAllPvdProperties<TDataType>(definitionObj); if(doPush) definitionObj.popName(); helper.addPropertyMessage(getPvdNamespacedNameForType<TClassType>(), getPvdNamespacedNameForType<TValueType>(), sizeof(TValueType)); } template <typename TDataType> static inline void createClassAndDefineProperties(PvdDataStream& inStream) { inStream.createClass<TDataType>(); PvdPropertyDefinitionHelper& helper(inStream.getPropertyDefinitionHelper()); PvdClassInfoDefine definitionObj(helper, getPvdNamespacedNameForType<TDataType>()); visitAllPvdProperties<TDataType>(definitionObj); } template <typename TDataType, typename TParentType> static inline void createClassDeriveAndDefineProperties(PvdDataStream& inStream) { inStream.createClass<TDataType>(); inStream.deriveClass<TParentType, TDataType>(); PvdPropertyDefinitionHelper& helper(inStream.getPropertyDefinitionHelper()); PvdClassInfoDefine definitionObj(helper, getPvdNamespacedNameForType<TDataType>()); visitInstancePvdProperties<TDataType>(definitionObj); } template <typename TDataType, typename TConvertSrc, typename TConvertData> static inline void defineProperty(PvdDataStream& inStream, const char* inPropertyName, const char* semantic) { PvdPropertyDefinitionHelper& helper(inStream.getPropertyDefinitionHelper()); // PxEnumTraits< TValueType > filterFlagsEnum; TConvertSrc filterFlagsEnum; const TConvertData* convertor = filterFlagsEnum.NameConversion; for(; convertor->mName != NULL; ++convertor) helper.addNamedValue(convertor->mName, convertor->mValue); inStream.createProperty<TDataType, PxU32>(inPropertyName, semantic, PropertyType::Scalar, helper.getNamedValues()); helper.clearNamedValues(); } template <typename TDataType, typename TConvertSrc, typename TConvertData> static inline void definePropertyFlags(PvdDataStream& inStream, const char* inPropertyName) { defineProperty<TDataType, TConvertSrc, TConvertData>(inStream, inPropertyName, "Bitflag"); } template <typename TDataType, typename TConvertSrc, typename TConvertData> static inline void definePropertyEnums(PvdDataStream& inStream, const char* inPropertyName) { defineProperty<TDataType, TConvertSrc, TConvertData>(inStream, inPropertyName, "Enumeration Value"); } static PX_FORCE_INLINE void registerPvdRaycast(PvdDataStream& inStream) { inStream.createClass<PvdRaycast>(); definePropertyEnums<PvdRaycast, SceneQueryIDConvertor, NameValuePair>(inStream, "type"); inStream.createProperty<PvdRaycast, PxFilterData>("filterData"); definePropertyFlags<PvdRaycast, PxEnumTraits<physx::PxQueryFlag::Enum>, PxU32ToName>(inStream, "filterFlags"); inStream.createProperty<PvdRaycast, PxVec3>("origin"); inStream.createProperty<PvdRaycast, PxVec3>("unitDir"); inStream.createProperty<PvdRaycast, PxF32>("distance"); inStream.createProperty<PvdRaycast, String>("hits_arrayName"); inStream.createProperty<PvdRaycast, PxU32>("hits_baseIndex"); inStream.createProperty<PvdRaycast, PxU32>("hits_count"); } static PX_FORCE_INLINE void registerPvdSweep(PvdDataStream& inStream) { inStream.createClass<PvdSweep>(); definePropertyEnums<PvdSweep, SceneQueryIDConvertor, NameValuePair>(inStream, "type"); definePropertyFlags<PvdSweep, PxEnumTraits<physx::PxQueryFlag::Enum>, PxU32ToName>(inStream, "filterFlags"); inStream.createProperty<PvdSweep, PxVec3>("unitDir"); inStream.createProperty<PvdSweep, PxF32>("distance"); inStream.createProperty<PvdSweep, String>("geom_arrayName"); inStream.createProperty<PvdSweep, PxU32>("geom_baseIndex"); inStream.createProperty<PvdSweep, PxU32>("geom_count"); inStream.createProperty<PvdSweep, String>("pose_arrayName"); inStream.createProperty<PvdSweep, PxU32>("pose_baseIndex"); inStream.createProperty<PvdSweep, PxU32>("pose_count"); inStream.createProperty<PvdSweep, String>("filterData_arrayName"); inStream.createProperty<PvdSweep, PxU32>("filterData_baseIndex"); inStream.createProperty<PvdSweep, PxU32>("filterData_count"); inStream.createProperty<PvdSweep, String>("hits_arrayName"); inStream.createProperty<PvdSweep, PxU32>("hits_baseIndex"); inStream.createProperty<PvdSweep, PxU32>("hits_count"); } static PX_FORCE_INLINE void registerPvdOverlap(PvdDataStream& inStream) { inStream.createClass<PvdOverlap>(); definePropertyEnums<PvdOverlap, SceneQueryIDConvertor, NameValuePair>(inStream, "type"); inStream.createProperty<PvdOverlap, PxFilterData>("filterData"); definePropertyFlags<PvdOverlap, PxEnumTraits<physx::PxQueryFlag::Enum>, PxU32ToName>(inStream, "filterFlags"); inStream.createProperty<PvdOverlap, PxTransform>("pose"); inStream.createProperty<PvdOverlap, String>("geom_arrayName"); inStream.createProperty<PvdOverlap, PxU32>("geom_baseIndex"); inStream.createProperty<PvdOverlap, PxU32>("geom_count"); inStream.createProperty<PvdOverlap, String>("hits_arrayName"); inStream.createProperty<PvdOverlap, PxU32>("hits_baseIndex"); inStream.createProperty<PvdOverlap, PxU32>("hits_count"); } static PX_FORCE_INLINE void registerPvdSqHit(PvdDataStream& inStream) { inStream.createClass<PvdSqHit>(); inStream.createProperty<PvdSqHit, ObjectRef>("Shape"); inStream.createProperty<PvdSqHit, ObjectRef>("Actor"); inStream.createProperty<PvdSqHit, PxU32>("FaceIndex"); definePropertyFlags<PvdSqHit, PxEnumTraits<physx::PxHitFlag::Enum>, PxU32ToName>(inStream, "Flags"); inStream.createProperty<PvdSqHit, PxVec3>("Impact"); inStream.createProperty<PvdSqHit, PxVec3>("Normal"); inStream.createProperty<PvdSqHit, PxF32>("Distance"); inStream.createProperty<PvdSqHit, PxF32>("U"); inStream.createProperty<PvdSqHit, PxF32>("V"); } void PvdMetaDataBinding::registerSDKProperties(PvdDataStream& inStream) { if (inStream.isClassExist<PxPhysics>()) return; // PxPhysics { inStream.createClass<PxPhysics>(); PvdPropertyDefinitionHelper& helper(inStream.getPropertyDefinitionHelper()); PvdClassInfoDefine definitionObj(helper, getPvdNamespacedNameForType<PxPhysics>()); helper.pushName("TolerancesScale"); visitAllPvdProperties<PxTolerancesScale>(definitionObj); helper.popName(); inStream.createProperty<PxPhysics, ObjectRef>("Scenes", "children", PropertyType::Array); inStream.createProperty<PxPhysics, ObjectRef>("SharedShapes", "children", PropertyType::Array); inStream.createProperty<PxPhysics, ObjectRef>("Materials", "children", PropertyType::Array); inStream.createProperty<PxPhysics, ObjectRef>("HeightFields", "children", PropertyType::Array); inStream.createProperty<PxPhysics, ObjectRef>("ConvexMeshes", "children", PropertyType::Array); inStream.createProperty<PxPhysics, ObjectRef>("TriangleMeshes", "children", PropertyType::Array); inStream.createProperty<PxPhysics, PxU32>("Version.Major"); inStream.createProperty<PxPhysics, PxU32>("Version.Minor"); inStream.createProperty<PxPhysics, PxU32>("Version.Bugfix"); inStream.createProperty<PxPhysics, String>("Version.Build"); definePropertyStruct<PxTolerancesScale, PxTolerancesScaleGeneratedValues, PxPhysics>(inStream, "TolerancesScale"); } { // PxGeometry inStream.createClass<PxGeometry>(); inStream.createProperty<PxGeometry, ObjectRef>("Shape", "parents", PropertyType::Scalar); } { // PxBoxGeometry createClassDeriveAndDefineProperties<PxBoxGeometry, PxGeometry>(inStream); definePropertyStruct<PxBoxGeometry, PxBoxGeometryGeneratedValues, PxBoxGeometry>(inStream); } { // PxSphereGeometry createClassDeriveAndDefineProperties<PxSphereGeometry, PxGeometry>(inStream); definePropertyStruct<PxSphereGeometry, PxSphereGeometryGeneratedValues, PxSphereGeometry>(inStream); } { // PxCapsuleGeometry createClassDeriveAndDefineProperties<PxCapsuleGeometry, PxGeometry>(inStream); definePropertyStruct<PxCapsuleGeometry, PxCapsuleGeometryGeneratedValues, PxCapsuleGeometry>(inStream); } { // PxPlaneGeometry createClassDeriveAndDefineProperties<PxPlaneGeometry, PxGeometry>(inStream); } { // PxConvexMeshGeometry createClassDeriveAndDefineProperties<PxConvexMeshGeometry, PxGeometry>(inStream); definePropertyStruct<PxConvexMeshGeometry, PxConvexMeshGeometryGeneratedValues, PxConvexMeshGeometry>(inStream); } { // PxTetrahedronMeshGeometry createClassDeriveAndDefineProperties<PxTetrahedronMeshGeometry, PxGeometry>(inStream); definePropertyStruct<PxTetrahedronMeshGeometry, PxTetrahedronMeshGeometryGeneratedValues, PxTetrahedronMeshGeometry>(inStream); } { // PxTriangleMeshGeometry createClassDeriveAndDefineProperties<PxTriangleMeshGeometry, PxGeometry>(inStream); definePropertyStruct<PxTriangleMeshGeometry, PxTriangleMeshGeometryGeneratedValues, PxTriangleMeshGeometry>(inStream); } { // PxHeightFieldGeometry createClassDeriveAndDefineProperties<PxHeightFieldGeometry, PxGeometry>(inStream); definePropertyStruct<PxHeightFieldGeometry, PxHeightFieldGeometryGeneratedValues, PxHeightFieldGeometry>(inStream); } { // PxCustomGeometry createClassDeriveAndDefineProperties<PxCustomGeometry, PxGeometry>(inStream); definePropertyStruct<PxCustomGeometry, PxCustomGeometryGeneratedValues, PxCustomGeometry>(inStream); } // PxScene { // PT: TODO: why inline this for PvdContact but do PvdRaycast/etc in separate functions? { // contact information inStream.createClass<PvdContact>(); inStream.createProperty<PvdContact, PxVec3>("Point"); inStream.createProperty<PvdContact, PxVec3>("Axis"); inStream.createProperty<PvdContact, ObjectRef>("Shapes[0]"); inStream.createProperty<PvdContact, ObjectRef>("Shapes[1]"); inStream.createProperty<PvdContact, PxF32>("Separation"); inStream.createProperty<PvdContact, PxF32>("NormalForce"); inStream.createProperty<PvdContact, PxU32>("InternalFaceIndex[0]"); inStream.createProperty<PvdContact, PxU32>("InternalFaceIndex[1]"); inStream.createProperty<PvdContact, bool>("NormalForceValid"); } registerPvdSqHit(inStream); registerPvdRaycast(inStream); registerPvdSweep(inStream); registerPvdOverlap(inStream); inStream.createClass<PxScene>(); PvdPropertyDefinitionHelper& helper(inStream.getPropertyDefinitionHelper()); PvdClassInfoDefine definitionObj(helper, getPvdNamespacedNameForType<PxScene>()); visitAllPvdProperties<PxSceneDesc>(definitionObj); helper.pushName("SimulationStatistics"); visitAllPvdProperties<PxSimulationStatistics>(definitionObj); helper.popName(); inStream.createProperty<PxScene, ObjectRef>("Physics", "parents", PropertyType::Scalar); inStream.createProperty<PxScene, PxU32>("Timestamp"); inStream.createProperty<PxScene, PxReal>("SimulateElapsedTime"); definePropertyStruct<PxSceneDesc, PxSceneDescGeneratedValues, PxScene>(inStream); definePropertyStruct<PxSimulationStatistics, PxSimulationStatisticsGeneratedValues, PxScene>(inStream, "SimulationStatistics"); inStream.createProperty<PxScene, PvdContact>("Contacts", "", PropertyType::Array); inStream.createProperty<PxScene, PvdOverlap>("SceneQueries.Overlaps", "", PropertyType::Array); inStream.createProperty<PxScene, PvdSweep>("SceneQueries.Sweeps", "", PropertyType::Array); inStream.createProperty<PxScene, PvdSqHit>("SceneQueries.Hits", "", PropertyType::Array); inStream.createProperty<PxScene, PvdRaycast>("SceneQueries.Raycasts", "", PropertyType::Array); inStream.createProperty<PxScene, PxTransform>("SceneQueries.PoseList", "", PropertyType::Array); inStream.createProperty<PxScene, PxFilterData>("SceneQueries.FilterDataList", "", PropertyType::Array); inStream.createProperty<PxScene, ObjectRef>("SceneQueries.GeometryList", "", PropertyType::Array); inStream.createProperty<PxScene, PvdOverlap>("BatchedQueries.Overlaps", "", PropertyType::Array); inStream.createProperty<PxScene, PvdSweep>("BatchedQueries.Sweeps", "", PropertyType::Array); inStream.createProperty<PxScene, PvdSqHit>("BatchedQueries.Hits", "", PropertyType::Array); inStream.createProperty<PxScene, PvdRaycast>("BatchedQueries.Raycasts", "", PropertyType::Array); inStream.createProperty<PxScene, PxTransform>("BatchedQueries.PoseList", "", PropertyType::Array); inStream.createProperty<PxScene, PxFilterData>("BatchedQueries.FilterDataList", "", PropertyType::Array); inStream.createProperty<PxScene, ObjectRef>("BatchedQueries.GeometryList", "", PropertyType::Array); inStream.createProperty<PxScene, ObjectRef>("RigidStatics", "children", PropertyType::Array); inStream.createProperty<PxScene, ObjectRef>("RigidDynamics", "children", PropertyType::Array); inStream.createProperty<PxScene, ObjectRef>("Articulations", "children", PropertyType::Array); inStream.createProperty<PxScene, ObjectRef>("Joints", "children", PropertyType::Array); inStream.createProperty<PxScene, ObjectRef>("Aggregates", "children", PropertyType::Array); } // PxMaterial { createClassAndDefineProperties<PxMaterial>(inStream); definePropertyStruct<PxMaterial, PxMaterialGeneratedValues, PxMaterial>(inStream); inStream.createProperty<PxMaterial, ObjectRef>("Physics", "parents", PropertyType::Scalar); } // PxHeightField { { inStream.createClass<PxHeightFieldSample>(); inStream.createProperty<PxHeightFieldSample, PxU16>("Height"); inStream.createProperty<PxHeightFieldSample, PxU8>("MaterialIndex[0]"); inStream.createProperty<PxHeightFieldSample, PxU8>("MaterialIndex[1]"); } inStream.createClass<PxHeightField>(); // It is important the PVD fields match the RepX fields, so this has // to be hand coded. PvdPropertyDefinitionHelper& helper(inStream.getPropertyDefinitionHelper()); PvdClassInfoDefine definitionObj(helper, getPvdNamespacedNameForType<PxHeightField>()); visitAllPvdProperties<PxHeightFieldDesc>(definitionObj); inStream.createProperty<PxHeightField, PxHeightFieldSample>("Samples", "", PropertyType::Array); inStream.createProperty<PxHeightField, ObjectRef>("Physics", "parents", PropertyType::Scalar); definePropertyStruct<PxHeightFieldDesc, PxHeightFieldDescGeneratedValues, PxHeightField>(inStream); } // PxConvexMesh { { // hull polygon data. inStream.createClass<PvdHullPolygonData>(); inStream.createProperty<PvdHullPolygonData, PxU16>("NumVertices"); inStream.createProperty<PvdHullPolygonData, PxU16>("IndexBase"); } inStream.createClass<PxConvexMesh>(); inStream.createProperty<PxConvexMesh, PxF32>("Mass"); inStream.createProperty<PxConvexMesh, PxMat33>("LocalInertia"); inStream.createProperty<PxConvexMesh, PxVec3>("LocalCenterOfMass"); inStream.createProperty<PxConvexMesh, PxVec3>("Points", "", PropertyType::Array); inStream.createProperty<PxConvexMesh, PvdHullPolygonData>("HullPolygons", "", PropertyType::Array); inStream.createProperty<PxConvexMesh, PxU8>("PolygonIndexes", "", PropertyType::Array); inStream.createProperty<PxConvexMesh, ObjectRef>("Physics", "parents", PropertyType::Scalar); } // PxTriangleMesh { inStream.createClass<PxTriangleMesh>(); inStream.createProperty<PxTriangleMesh, PxVec3>("Points", "", PropertyType::Array); inStream.createProperty<PxTriangleMesh, PxU32>("NbTriangles", "", PropertyType::Scalar); inStream.createProperty<PxTriangleMesh, PxU32>("Triangles", "", PropertyType::Array); inStream.createProperty<PxTriangleMesh, PxU16>("MaterialIndices", "", PropertyType::Array); inStream.createProperty<PxTriangleMesh, ObjectRef>("Physics", "parents", PropertyType::Scalar); } // PxTetrahedronMesh { inStream.createClass<PxTetrahedronMesh>(); inStream.createProperty<PxTetrahedronMesh, PxVec3>("Points", "", PropertyType::Array); inStream.createProperty<PxTetrahedronMesh, PxU32>("NbTriangles", "", PropertyType::Scalar); inStream.createProperty<PxTetrahedronMesh, PxU32>("Triangles", "", PropertyType::Array); inStream.createProperty<PxTetrahedronMesh, ObjectRef>("Physics", "parents", PropertyType::Scalar); } // PxFEMSoftBodyMaterial { createClassAndDefineProperties<PxFEMSoftBodyMaterial>(inStream); definePropertyStruct<PxFEMSoftBodyMaterial, PxFEMSoftBodyMaterialGeneratedValues, PxFEMSoftBodyMaterial>(inStream); inStream.createProperty<PxFEMSoftBodyMaterial, ObjectRef>("Physics", "parents", PropertyType::Scalar); } // PxFEMClothMaterial // jcarius: Commented-out until FEMCloth is not under construction anymore // { // createClassAndDefineProperties<PxFEMClothMaterial>(inStream); // definePropertyStruct<PxFEMClothMaterial, PxFEMClothMaterialGeneratedValues, PxFEMClothMaterial>(inStream); // inStream.createProperty<PxFEMClothMaterial, ObjectRef>("Physics", "parents", PropertyType::Scalar); // } { // PxShape createClassAndDefineProperties<PxShape>(inStream); definePropertyStruct<PxShape, PxShapeGeneratedValues, PxShape>(inStream); inStream.createProperty<PxShape, ObjectRef>("Geometry", "children"); inStream.createProperty<PxShape, ObjectRef>("Materials", "children", PropertyType::Array); inStream.createProperty<PxShape, ObjectRef>("Actor", "parents"); } // PxActor { createClassAndDefineProperties<PxActor>(inStream); inStream.createProperty<PxActor, ObjectRef>("Scene", "parents"); } // PxRigidActor { createClassDeriveAndDefineProperties<PxRigidActor, PxActor>(inStream); inStream.createProperty<PxRigidActor, ObjectRef>("Shapes", "children", PropertyType::Array); inStream.createProperty<PxRigidActor, ObjectRef>("Joints", "children", PropertyType::Array); } // PxRigidStatic { createClassDeriveAndDefineProperties<PxRigidStatic, PxRigidActor>(inStream); definePropertyStruct<PxRigidStatic, PxRigidStaticGeneratedValues, PxRigidStatic>(inStream); } { // PxRigidBody createClassDeriveAndDefineProperties<PxRigidBody, PxRigidActor>(inStream); } // PxRigidDynamic { createClassDeriveAndDefineProperties<PxRigidDynamic, PxRigidBody>(inStream); // If anyone adds a 'getKinematicTarget' to PxRigidDynamic you can remove the line // below (after the code generator has run). inStream.createProperty<PxRigidDynamic, PxTransform>("KinematicTarget"); definePropertyStruct<PxRigidDynamic, PxRigidDynamicGeneratedValues, PxRigidDynamic>(inStream); // Manually define the update struct. PvdPropertyDefinitionHelper& helper(inStream.getPropertyDefinitionHelper()); /*struct PxRigidDynamicUpdateBlock { Transform GlobalPose; Float3 LinearVelocity; Float3 AngularVelocity; PxU8 IsSleeping; PxU8 padding[3]; }; */ helper.pushName("GlobalPose"); helper.addPropertyMessageArg<PxTransform>(PX_OFFSET_OF_RT(PxRigidDynamicUpdateBlock, GlobalPose)); helper.popName(); helper.pushName("LinearVelocity"); helper.addPropertyMessageArg<PxVec3>(PX_OFFSET_OF_RT(PxRigidDynamicUpdateBlock, LinearVelocity)); helper.popName(); helper.pushName("AngularVelocity"); helper.addPropertyMessageArg<PxVec3>(PX_OFFSET_OF_RT(PxRigidDynamicUpdateBlock, AngularVelocity)); helper.popName(); helper.pushName("IsSleeping"); helper.addPropertyMessageArg<bool>(PX_OFFSET_OF_RT(PxRigidDynamicUpdateBlock, IsSleeping)); helper.popName(); helper.addPropertyMessage<PxRigidDynamic, PxRigidDynamicUpdateBlock>(); } // PxArticulationReducedCoordinate { createClassAndDefineProperties<PxArticulationReducedCoordinate>(inStream); inStream.createProperty<PxArticulationReducedCoordinate, ObjectRef>("Scene", "parents"); inStream.createProperty<PxArticulationReducedCoordinate, ObjectRef>("Links", "children", PropertyType::Array); definePropertyStruct<PxArticulationReducedCoordinate, PxArticulationReducedCoordinateGeneratedValues, PxArticulationReducedCoordinate>(inStream); } { // PxArticulationLink createClassDeriveAndDefineProperties<PxArticulationLink, PxRigidBody>(inStream); inStream.createProperty<PxArticulationLink, ObjectRef>("Parent", "parents"); inStream.createProperty<PxArticulationLink, ObjectRef>("Links", "children", PropertyType::Array); inStream.createProperty<PxArticulationLink, ObjectRef>("InboundJoint", "children"); definePropertyStruct<PxArticulationLink, PxArticulationLinkGeneratedValues, PxArticulationLink>(inStream); PvdPropertyDefinitionHelper& helper(inStream.getPropertyDefinitionHelper()); /*struct PxArticulationLinkUpdateBlock { Transform GlobalPose; Float3 LinearVelocity; Float3 AngularVelocity; };*/ helper.pushName("GlobalPose"); helper.addPropertyMessageArg<PxTransform>(PX_OFFSET_OF(PxArticulationLinkUpdateBlock, GlobalPose)); helper.popName(); helper.pushName("LinearVelocity"); helper.addPropertyMessageArg<PxVec3>(PX_OFFSET_OF(PxArticulationLinkUpdateBlock, LinearVelocity)); helper.popName(); helper.pushName("AngularVelocity"); helper.addPropertyMessageArg<PxVec3>(PX_OFFSET_OF(PxArticulationLinkUpdateBlock, AngularVelocity)); helper.popName(); helper.addPropertyMessage<PxArticulationLink, PxArticulationLinkUpdateBlock>(); } { // PxArticulationJoint createClassAndDefineProperties<PxArticulationJointReducedCoordinate>(inStream); inStream.createProperty<PxArticulationJointReducedCoordinate, ObjectRef>("Link", "parents"); definePropertyStruct<PxArticulationJointReducedCoordinate, PxArticulationJointReducedCoordinateGeneratedValues, PxArticulationJointReducedCoordinate>(inStream); PvdPropertyDefinitionHelper& helper(inStream.getPropertyDefinitionHelper()); helper.pushName("JointPosition[eX]"); helper.addPropertyMessageArg<PxReal>(PX_OFFSET_OF(PxArticulationJointUpdateBlock, JointPosition_eX)); helper.popName(); helper.pushName("JointPosition[eY]"); helper.addPropertyMessageArg<PxReal>(PX_OFFSET_OF(PxArticulationJointUpdateBlock, JointPosition_eY)); helper.popName(); helper.pushName("JointPosition[eZ]"); helper.addPropertyMessageArg<PxReal>(PX_OFFSET_OF(PxArticulationJointUpdateBlock, JointPosition_eZ)); helper.popName(); helper.pushName("JointPosition[eTWIST]"); helper.addPropertyMessageArg<PxReal>(PX_OFFSET_OF(PxArticulationJointUpdateBlock, JointPosition_eTwist)); helper.popName(); helper.pushName("JointPosition[eSWING1]"); helper.addPropertyMessageArg<PxReal>(PX_OFFSET_OF(PxArticulationJointUpdateBlock, JointPosition_eSwing1)); helper.popName(); helper.pushName("JointPosition[eSWING2]"); helper.addPropertyMessageArg<PxReal>(PX_OFFSET_OF(PxArticulationJointUpdateBlock, JointPosition_eSwing2)); helper.popName(); helper.pushName("JointVelocity[eX]"); helper.addPropertyMessageArg<PxReal>(PX_OFFSET_OF(PxArticulationJointUpdateBlock, JointVelocity_eX)); helper.popName(); helper.pushName("JointVelocity[eY]"); helper.addPropertyMessageArg<PxReal>(PX_OFFSET_OF(PxArticulationJointUpdateBlock, JointVelocity_eY)); helper.popName(); helper.pushName("JointVelocity[eZ]"); helper.addPropertyMessageArg<PxReal>(PX_OFFSET_OF(PxArticulationJointUpdateBlock, JointVelocity_eZ)); helper.popName(); helper.pushName("JointVelocity[eTWIST]"); helper.addPropertyMessageArg<PxReal>(PX_OFFSET_OF(PxArticulationJointUpdateBlock, JointVelocity_eTwist)); helper.popName(); helper.pushName("JointVelocity[eSWING1]"); helper.addPropertyMessageArg<PxReal>(PX_OFFSET_OF(PxArticulationJointUpdateBlock, JointVelocity_eSwing1)); helper.popName(); helper.pushName("JointVelocity[eSWING2]"); helper.addPropertyMessageArg<PxReal>(PX_OFFSET_OF(PxArticulationJointUpdateBlock, JointVelocity_eSwing2)); helper.popName(); helper.addPropertyMessage<PxArticulationJointReducedCoordinate, PxArticulationJointUpdateBlock>(); } { // PxConstraint createClassAndDefineProperties<PxConstraint>(inStream); definePropertyStruct<PxConstraint, PxConstraintGeneratedValues, PxConstraint>(inStream); } { // PxAggregate createClassAndDefineProperties<PxAggregate>(inStream); inStream.createProperty<PxAggregate, ObjectRef>("Scene", "parents"); definePropertyStruct<PxAggregate, PxAggregateGeneratedValues, PxAggregate>(inStream); inStream.createProperty<PxAggregate, ObjectRef>("Actors", "children", PropertyType::Array); inStream.createProperty<PxAggregate, ObjectRef>("Articulations", "children", PropertyType::Array); } } template <typename TClassType, typename TValueType, typename TDataType> static void doSendAllProperties(PvdDataStream& inStream, const TDataType* inDatatype, const void* instanceId) { TValueType theValues(inDatatype); inStream.setPropertyMessage(instanceId, theValues); } void PvdMetaDataBinding::sendAllProperties(PvdDataStream& inStream, const PxPhysics& inPhysics) { PxTolerancesScale theScale(inPhysics.getTolerancesScale()); doSendAllProperties<PxPhysics, PxTolerancesScaleGeneratedValues>(inStream, &theScale, &inPhysics); inStream.setPropertyValue(&inPhysics, "Version.Major", PxU32(PX_PHYSICS_VERSION_MAJOR)); inStream.setPropertyValue(&inPhysics, "Version.Minor", PxU32(PX_PHYSICS_VERSION_MINOR)); inStream.setPropertyValue(&inPhysics, "Version.Bugfix", PxU32(PX_PHYSICS_VERSION_BUGFIX)); #if PX_DEBUG String buildType = "Debug"; #elif PX_CHECKED String buildType = "Checked"; #elif PX_PROFILE String buildType = "Profile"; #else String buildType = "Release"; #endif inStream.setPropertyValue(&inPhysics, "Version.Build", buildType); } void PvdMetaDataBinding::sendAllProperties(PvdDataStream& inStream, const PxScene& inScene) { const PxPhysics& physics(const_cast<PxScene&>(inScene).getPhysics()); PxTolerancesScale theScale; PxSceneDesc theDesc(theScale); { // setDominanceGroupPair ? theDesc.gravity = inScene.getGravity(); theDesc.simulationEventCallback = inScene.getSimulationEventCallback(); theDesc.contactModifyCallback = inScene.getContactModifyCallback(); theDesc.ccdContactModifyCallback = inScene.getCCDContactModifyCallback(); theDesc.filterShaderData = inScene.getFilterShaderData(); theDesc.filterShaderDataSize = inScene.getFilterShaderDataSize(); theDesc.filterShader = inScene.getFilterShader(); theDesc.filterCallback = inScene.getFilterCallback(); // PxPairFilteringMode::Enum KineKineFilteringMode; // PxPairFilteringMode::Enum StaticKineFilteringMode; theDesc.broadPhaseType = inScene.getBroadPhaseType(); theDesc.broadPhaseCallback = inScene.getBroadPhaseCallback(); theDesc.limits = inScene.getLimits(); theDesc.frictionType = inScene.getFrictionType(); // PxSolverType::Enum SolverType; theDesc.bounceThresholdVelocity = inScene.getBounceThresholdVelocity(); theDesc.frictionOffsetThreshold = inScene.getFrictionOffsetThreshold(); theDesc.frictionCorrelationDistance = inScene.getFrictionCorrelationDistance(); theDesc.flags = inScene.getFlags(); theDesc.cpuDispatcher = inScene.getCpuDispatcher(); theDesc.cudaContextManager = inScene.getCudaContextManager(); theDesc.staticStructure = inScene.getStaticStructure(); theDesc.dynamicStructure = inScene.getDynamicStructure(); theDesc.dynamicTreeRebuildRateHint = inScene.getDynamicTreeRebuildRateHint(); theDesc.sceneQueryUpdateMode = inScene.getSceneQueryUpdateMode(); theDesc.userData = inScene.userData; theDesc.solverBatchSize = inScene.getSolverBatchSize(); theDesc.solverArticulationBatchSize = inScene.getSolverArticulationBatchSize(); // PxU32 NbContactDataBlocks; // PxU32 MaxNbContactDataBlocks; // theDesc.nbContactDataBlocks = inScene.getNbContactDataBlocksUsed(); // theDesc.maxNbContactDataBlocks = inScene.getMaxNbContactDataBlocksUsed(); theDesc.maxBiasCoefficient = inScene.getMaxBiasCoefficient(); theDesc.contactReportStreamBufferSize = inScene.getContactReportStreamBufferSize(); theDesc.ccdMaxPasses = inScene.getCCDMaxPasses(); theDesc.ccdThreshold = inScene.getCCDThreshold(); theDesc.ccdMaxSeparation = inScene.getCCDMaxSeparation(); // theDesc.simulationOrder = inScene.getSimulationOrder(); theDesc.wakeCounterResetValue = inScene.getWakeCounterResetValue(); theDesc.gpuDynamicsConfig = inScene.getGpuDynamicsConfig(); // PxBounds3 SanityBounds; // PxgDynamicsMemoryConfig GpuDynamicsConfig; // PxU32 GpuMaxNumPartitions; // PxU32 GpuComputeVersion; // PxReal BroadPhaseInflation; // PxU32 ContactPairSlabSize; } PxSceneDescGeneratedValues theValues(&theDesc); inStream.setPropertyMessage(&inScene, theValues); // Create parent/child relationship. inStream.setPropertyValue(&inScene, "Physics", reinterpret_cast<const void*>(&physics)); inStream.pushBackObjectRef(&physics, "Scenes", &inScene); } void PvdMetaDataBinding::sendBeginFrame(PvdDataStream& inStream, const PxScene* inScene, PxReal simulateElapsedTime) { inStream.beginSection(inScene, "frame"); inStream.setPropertyValue(inScene, "Timestamp", inScene->getTimestamp()); inStream.setPropertyValue(inScene, "SimulateElapsedTime", simulateElapsedTime); } template <typename TDataType> struct NullConverter { void operator()(TDataType& data, const TDataType& src) { data = src; } }; template <typename TTargetType, PxU32 T_NUM_ITEMS, typename TSourceType = TTargetType, typename Converter = NullConverter<TTargetType> > class ScopedPropertyValueSender { TTargetType mStack[T_NUM_ITEMS]; TTargetType* mCur; const TTargetType* mEnd; PvdDataStream& mStream; public: ScopedPropertyValueSender(PvdDataStream& inStream, const void* inObj, String name) : mCur(mStack), mEnd(&mStack[T_NUM_ITEMS]), mStream(inStream) { mStream.beginSetPropertyValue(inObj, name, getPvdNamespacedNameForType<TTargetType>()); } ~ScopedPropertyValueSender() { if(mStack != mCur) { PxU32 size = sizeof(TTargetType) * PxU32(mCur - mStack); mStream.appendPropertyValueData(DataRef<const PxU8>(reinterpret_cast<PxU8*>(mStack), size)); } mStream.endSetPropertyValue(); } void append(const TSourceType& data) { Converter()(*mCur, data); if(mCur < mEnd - 1) ++mCur; else { mStream.appendPropertyValueData(DataRef<const PxU8>(reinterpret_cast<PxU8*>(mStack), sizeof mStack)); mCur = mStack; } } private: ScopedPropertyValueSender& operator=(const ScopedPropertyValueSender&); }; void PvdMetaDataBinding::sendContacts(PvdDataStream& inStream, const PxScene& inScene) { inStream.setPropertyValue(&inScene, "Contacts", DataRef<const PxU8>(), getPvdNamespacedNameForType<PvdContact>()); } void PvdMetaDataBinding::sendStats(PvdDataStream& inStream, const PxScene* inScene) { PxSimulationStatistics theStats; inScene->getSimulationStatistics(theStats); PxSimulationStatisticsGeneratedValues values(&theStats); inStream.setPropertyMessage(inScene, values); } struct PvdContactConverter { void operator()(PvdContact& data, const Sc::Contact& src) { data.point = src.point; data.axis = src.normal; data.shape0 = src.shape0; data.shape1 = src.shape1; data.separation = src.separation; data.normalForce = src.normalForce; data.internalFaceIndex0 = src.faceIndex0; data.internalFaceIndex1 = src.faceIndex1; data.normalForceAvailable = src.normalForceAvailable; } }; void PvdMetaDataBinding::sendContacts(PvdDataStream& inStream, const PxScene& inScene, PxArray<Contact>& inContacts) { ScopedPropertyValueSender<PvdContact, 32, Sc::Contact, PvdContactConverter> sender(inStream, &inScene, "Contacts"); for(PxU32 i = 0; i < inContacts.size(); i++) { sender.append(inContacts[i]); } } void PvdMetaDataBinding::sendEndFrame(PvdDataStream& inStream, const PxScene* inScene) { //flush other client inStream.endSection(inScene, "frame"); } template <typename TDataType> static void addPhysicsGroupProperty(PvdDataStream& inStream, const char* groupName, const TDataType& inData, const PxPhysics& ownerPhysics) { inStream.setPropertyValue(&inData, "Physics", reinterpret_cast<const void*>(&ownerPhysics)); inStream.pushBackObjectRef(&ownerPhysics, groupName, &inData); // Buffer type objects *have* to be flushed directly out once created else scene creation doesn't work. } template <typename TDataType> static void removePhysicsGroupProperty(PvdDataStream& inStream, const char* groupName, const TDataType& inData, const PxPhysics& ownerPhysics) { inStream.removeObjectRef(&ownerPhysics, groupName, &inData); inStream.destroyInstance(&inData); } void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxMaterial& inMaterial, const PxPhysics& ownerPhysics) { inStream.createInstance(&inMaterial); sendAllProperties(inStream, inMaterial); addPhysicsGroupProperty(inStream, "Materials", inMaterial, ownerPhysics); } void PvdMetaDataBinding::sendAllProperties(PvdDataStream& inStream, const PxMaterial& inMaterial) { PxMaterialGeneratedValues values(&inMaterial); inStream.setPropertyMessage(&inMaterial, values); } void PvdMetaDataBinding::destroyInstance(PvdDataStream& inStream, const PxMaterial& inMaterial, const PxPhysics& ownerPhysics) { removePhysicsGroupProperty(inStream, "Materials", inMaterial, ownerPhysics); } void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxFEMSoftBodyMaterial& inMaterial, const PxPhysics& ownerPhysics) { inStream.createInstance(&inMaterial); sendAllProperties(inStream, inMaterial); addPhysicsGroupProperty(inStream, "FEMMaterials", inMaterial, ownerPhysics); } void PvdMetaDataBinding::sendAllProperties(PvdDataStream& /*inStream*/, const PxFEMSoftBodyMaterial& /*inMaterial*/) { /*PxMaterialGeneratedValues values(&inMaterial); inStream.setPropertyMessage(&inMaterial, values);*/ } void PvdMetaDataBinding::destroyInstance(PvdDataStream& /*inStream*/, const PxFEMSoftBodyMaterial& /*inMaterial*/, const PxPhysics& /*ownerPhysics*/) { //removePhysicsGroupProperty(inStream, "Materials", inMaterial, ownerPhysics); } // jcarius: Commented-out until FEMCloth is not under construction anymore // void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxFEMClothMaterial& inMaterial, const PxPhysics& ownerPhysics) // { // inStream.createInstance(&inMaterial); // sendAllProperties(inStream, inMaterial); // addPhysicsGroupProperty(inStream, "FEMMaterials", inMaterial, ownerPhysics); // } // void PvdMetaDataBinding::sendAllProperties(PvdDataStream& /*inStream*/, const PxFEMClothMaterial& /*inMaterial*/) // { // /*PxMaterialGeneratedValues values(&inMaterial); // inStream.setPropertyMessage(&inMaterial, values);*/ // } // void PvdMetaDataBinding::destroyInstance(PvdDataStream& /*inStream*/, const PxFEMClothMaterial& /*inMaterial*/, const PxPhysics& /*ownerPhysics*/) // { // //removePhysicsGroupProperty(inStream, "Materials", inMaterial, ownerPhysics); // } void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxPBDMaterial& inMaterial, const PxPhysics& ownerPhysics) { inStream.createInstance(&inMaterial); sendAllProperties(inStream, inMaterial); addPhysicsGroupProperty(inStream, "PBDMaterials", inMaterial, ownerPhysics); } void PvdMetaDataBinding::sendAllProperties(PvdDataStream& /*inStream*/, const PxPBDMaterial& /*inMaterial*/) { /*PxMaterialGeneratedValues values(&inMaterial); inStream.setPropertyMessage(&inMaterial, values);*/ } void PvdMetaDataBinding::destroyInstance(PvdDataStream& /*inStream*/, const PxPBDMaterial& /*inMaterial*/, const PxPhysics& /*ownerPhysics*/) { //removePhysicsGroupProperty(inStream, "Materials", inMaterial, ownerPhysics); } void PvdMetaDataBinding::sendAllProperties(PvdDataStream& inStream, const PxHeightField& inData) { PxHeightFieldDesc theDesc; // Save the height field to desc. theDesc.nbRows = inData.getNbRows(); theDesc.nbColumns = inData.getNbColumns(); theDesc.format = inData.getFormat(); theDesc.samples.stride = inData.getSampleStride(); theDesc.samples.data = NULL; theDesc.convexEdgeThreshold = inData.getConvexEdgeThreshold(); theDesc.flags = inData.getFlags(); PxU32 theCellCount = inData.getNbRows() * inData.getNbColumns(); PxU32 theSampleStride = sizeof(PxHeightFieldSample); PxU32 theSampleBufSize = theCellCount * theSampleStride; mBindingData->mTempU8Array.resize(theSampleBufSize); PxHeightFieldSample* theSamples = reinterpret_cast<PxHeightFieldSample*>(mBindingData->mTempU8Array.begin()); inData.saveCells(theSamples, theSampleBufSize); theDesc.samples.data = theSamples; PxHeightFieldDescGeneratedValues values(&theDesc); inStream.setPropertyMessage(&inData, values); PxHeightFieldSample* theSampleData = reinterpret_cast<PxHeightFieldSample*>(mBindingData->mTempU8Array.begin()); inStream.setPropertyValue(&inData, "Samples", theSampleData, theCellCount); } void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxHeightField& inData, const PxPhysics& ownerPhysics) { inStream.createInstance(&inData); sendAllProperties(inStream, inData); addPhysicsGroupProperty(inStream, "HeightFields", inData, ownerPhysics); } void PvdMetaDataBinding::destroyInstance(PvdDataStream& inStream, const PxHeightField& inData, const PxPhysics& ownerPhysics) { removePhysicsGroupProperty(inStream, "HeightFields", inData, ownerPhysics); } void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxConvexMesh& inData, const PxPhysics& ownerPhysics) { inStream.createInstance(&inData); PxReal mass; PxMat33 localInertia; PxVec3 localCom; inData.getMassInformation(mass, localInertia, localCom); inStream.setPropertyValue(&inData, "Mass", mass); inStream.setPropertyValue(&inData, "LocalInertia", localInertia); inStream.setPropertyValue(&inData, "LocalCenterOfMass", localCom); // update arrays: // vertex Array: { const PxVec3* vertexPtr = inData.getVertices(); const PxU32 numVertices = inData.getNbVertices(); inStream.setPropertyValue(&inData, "Points", vertexPtr, numVertices); } // HullPolyArray: PxU16 maxIndices = 0; { PxU32 numPolygons = inData.getNbPolygons(); PvdHullPolygonData* tempData = mBindingData->allocateTemp<PvdHullPolygonData>(numPolygons); // Get the polygon data stripping the plane equations for(PxU32 index = 0; index < numPolygons; index++) { PxHullPolygon curOut; inData.getPolygonData(index, curOut); maxIndices = PxMax(maxIndices, PxU16(curOut.mIndexBase + curOut.mNbVerts)); tempData[index].mIndexBase = curOut.mIndexBase; tempData[index].mNumVertices = curOut.mNbVerts; } inStream.setPropertyValue(&inData, "HullPolygons", tempData, numPolygons); } // poly index Array: { const PxU8* indices = inData.getIndexBuffer(); inStream.setPropertyValue(&inData, "PolygonIndexes", indices, maxIndices); } addPhysicsGroupProperty(inStream, "ConvexMeshes", inData, ownerPhysics); } void PvdMetaDataBinding::destroyInstance(PvdDataStream& inStream, const PxConvexMesh& inData, const PxPhysics& ownerPhysics) { removePhysicsGroupProperty(inStream, "ConvexMeshes", inData, ownerPhysics); } void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxTetrahedronMesh& inData, const PxPhysics& ownerPhysics) { inStream.createInstance(&inData); // vertex Array: { const PxVec3* vertexPtr = inData.getVertices(); const PxU32 numVertices = inData.getNbVertices(); inStream.setPropertyValue(&inData, "Vertices", vertexPtr, numVertices); } ////invert mass array //{ // const float* invMassPtr = inData.getVertInvMasses(); // const PxU32 numVertices = inData.getCollisionMesh().getNbVertices(); // inStream.setPropertyValue(&inData, "invert mass", invMassPtr, numVertices); //} // index Array: { const bool has16BitIndices = inData.getTetrahedronMeshFlags() & PxTetrahedronMeshFlag::e16_BIT_INDICES ? true : false; const PxU32 numTetrahedrons= inData.getNbTetrahedrons(); inStream.setPropertyValue(&inData, "NbTetrahedron", numTetrahedrons); const PxU32 numIndexes = numTetrahedrons * 4; const PxU8* tetrahedronsPtr = reinterpret_cast<const PxU8*>(inData.getTetrahedrons()); // We declared this type as a 32 bit integer above. // PVD will automatically unsigned-extend data that is smaller than the target type. if (has16BitIndices) inStream.setPropertyValue(&inData, "Tetrahedrons", reinterpret_cast<const PxU16*>(tetrahedronsPtr), numIndexes); else inStream.setPropertyValue(&inData, "Tetrahedrons", reinterpret_cast<const PxU32*>(tetrahedronsPtr), numIndexes); } addPhysicsGroupProperty(inStream, "TetrahedronMeshes", inData, ownerPhysics); } void PvdMetaDataBinding::destroyInstance(PvdDataStream& inStream, const PxTetrahedronMesh& inData, const PxPhysics& ownerPhysics) { removePhysicsGroupProperty(inStream, "TetrahedronMeshes", inData, ownerPhysics); } void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxTriangleMesh& inData, const PxPhysics& ownerPhysics) { inStream.createInstance(&inData); bool hasMatIndex = inData.getTriangleMaterialIndex(0) != 0xffff; // update arrays: // vertex Array: { const PxVec3* vertexPtr = inData.getVertices(); const PxU32 numVertices = inData.getNbVertices(); inStream.setPropertyValue(&inData, "Points", vertexPtr, numVertices); } // index Array: { const bool has16BitIndices = inData.getTriangleMeshFlags() & PxTriangleMeshFlag::e16_BIT_INDICES ? true : false; const PxU32 numTriangles = inData.getNbTriangles(); inStream.setPropertyValue(&inData, "NbTriangles", numTriangles); const PxU32 numIndexes = numTriangles * 3; const PxU8* trianglePtr = reinterpret_cast<const PxU8*>(inData.getTriangles()); // We declared this type as a 32 bit integer above. // PVD will automatically unsigned-extend data that is smaller than the target type. if(has16BitIndices) inStream.setPropertyValue(&inData, "Triangles", reinterpret_cast<const PxU16*>(trianglePtr), numIndexes); else inStream.setPropertyValue(&inData, "Triangles", reinterpret_cast<const PxU32*>(trianglePtr), numIndexes); } // material Array: if(hasMatIndex) { PxU32 numMaterials = inData.getNbTriangles(); PxU16* matIndexData = mBindingData->allocateTemp<PxU16>(numMaterials); for(PxU32 m = 0; m < numMaterials; m++) matIndexData[m] = inData.getTriangleMaterialIndex(m); inStream.setPropertyValue(&inData, "MaterialIndices", matIndexData, numMaterials); } addPhysicsGroupProperty(inStream, "TriangleMeshes", inData, ownerPhysics); } void PvdMetaDataBinding::destroyInstance(PvdDataStream& inStream, const PxTriangleMesh& inData, const PxPhysics& ownerPhysics) { removePhysicsGroupProperty(inStream, "TriangleMeshes", inData, ownerPhysics); } template <typename TDataType> void PvdMetaDataBinding::registrarPhysicsObject(PvdDataStream&, const TDataType&, PsPvd*) { } template <> void PvdMetaDataBinding::registrarPhysicsObject<PxConvexMeshGeometry>(PvdDataStream& inStream, const PxConvexMeshGeometry& geom, PsPvd* pvd) { if(pvd->registerObject(geom.convexMesh)) createInstance(inStream, *geom.convexMesh, PxGetPhysics()); } template <> void PvdMetaDataBinding::registrarPhysicsObject<PxTetrahedronMeshGeometry>(PvdDataStream& inStream, const PxTetrahedronMeshGeometry& geom, PsPvd* pvd) { if (pvd->registerObject(geom.tetrahedronMesh)) createInstance(inStream, *geom.tetrahedronMesh, PxGetPhysics()); } template <> void PvdMetaDataBinding::registrarPhysicsObject<PxTriangleMeshGeometry>(PvdDataStream& inStream, const PxTriangleMeshGeometry& geom, PsPvd* pvd) { if(pvd->registerObject(geom.triangleMesh)) createInstance(inStream, *geom.triangleMesh, PxGetPhysics()); } template <> void PvdMetaDataBinding::registrarPhysicsObject<PxHeightFieldGeometry>(PvdDataStream& inStream, const PxHeightFieldGeometry& geom, PsPvd* pvd) { if(pvd->registerObject(geom.heightField)) createInstance(inStream, *geom.heightField, PxGetPhysics()); } template <typename TGeneratedValuesType, typename TGeomType> static void sendGeometry(PvdMetaDataBinding& metaBind, PvdDataStream& inStream, const PxShape& inShape, const TGeomType& geom, PsPvd* pvd) { const void* geomInst = (reinterpret_cast<const PxU8*>(&inShape)) + 4; inStream.createInstance(getPvdNamespacedNameForType<TGeomType>(), geomInst); metaBind.registrarPhysicsObject<TGeomType>(inStream, geom, pvd); TGeneratedValuesType values(&geom); inStream.setPropertyMessage(geomInst, values); inStream.setPropertyValue(&inShape, "Geometry", geomInst); inStream.setPropertyValue(geomInst, "Shape", reinterpret_cast<const void*>(&inShape)); } static void setGeometry(PvdMetaDataBinding& metaBind, PvdDataStream& inStream, const PxShape& inObj, PsPvd* pvd) { const PxGeometry& geom = inObj.getGeometry(); switch(geom.getType()) { #define SEND_PVD_GEOM_TYPE(enumType, geomType, valueType) \ case PxGeometryType::enumType: \ { \ Px##geomType geomT = static_cast<const Px##geomType&>(geom); \ sendGeometry<valueType>(metaBind, inStream, inObj, geomT, pvd); \ } \ break; SEND_PVD_GEOM_TYPE(eSPHERE, SphereGeometry, PxSphereGeometryGeneratedValues); // Plane geometries don't have any properties, so this avoids using a property // struct for them. case PxGeometryType::ePLANE: { const void* geomInst = (reinterpret_cast<const PxU8*>(&inObj)) + 4; inStream.createInstance(getPvdNamespacedNameForType<PxPlaneGeometry>(), geomInst); inStream.setPropertyValue(&inObj, "Geometry", geomInst); inStream.setPropertyValue(geomInst, "Shape", reinterpret_cast<const void*>(&inObj)); } break; SEND_PVD_GEOM_TYPE(eCAPSULE, CapsuleGeometry, PxCapsuleGeometryGeneratedValues); SEND_PVD_GEOM_TYPE(eBOX, BoxGeometry, PxBoxGeometryGeneratedValues); SEND_PVD_GEOM_TYPE(eCONVEXMESH, ConvexMeshGeometry, PxConvexMeshGeometryGeneratedValues); SEND_PVD_GEOM_TYPE(eTETRAHEDRONMESH, TetrahedronMeshGeometry, PxTetrahedronMeshGeometryGeneratedValues); SEND_PVD_GEOM_TYPE(eTRIANGLEMESH, TriangleMeshGeometry, PxTriangleMeshGeometryGeneratedValues); SEND_PVD_GEOM_TYPE(eHEIGHTFIELD, HeightFieldGeometry, PxHeightFieldGeometryGeneratedValues); SEND_PVD_GEOM_TYPE(eCUSTOM, CustomGeometry, PxCustomGeometryGeneratedValues); #undef SEND_PVD_GEOM_TYPE case PxGeometryType::ePARTICLESYSTEM: // A.B. implement later break; case PxGeometryType::eHAIRSYSTEM: break; case PxGeometryType::eGEOMETRY_COUNT: case PxGeometryType::eINVALID: PX_ASSERT(false); break; } } static void setMaterials(PvdMetaDataBinding& metaBing, PvdDataStream& inStream, const PxShape& inObj, PsPvd* pvd, PvdMetaDataBindingData* mBindingData) { PxU32 numMaterials = inObj.getNbMaterials(); PxMaterial** materialPtr = mBindingData->allocateTemp<PxMaterial*>(numMaterials); inObj.getMaterials(materialPtr, numMaterials); for(PxU32 idx = 0; idx < numMaterials; ++idx) { if(pvd->registerObject(materialPtr[idx])) metaBing.createInstance(inStream, *materialPtr[idx], PxGetPhysics()); inStream.pushBackObjectRef(&inObj, "Materials", materialPtr[idx]); } } void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxShape& inObj, const PxRigidActor& owner, const PxPhysics& ownerPhysics, PsPvd* pvd) { if(!inStream.isInstanceValid(&owner)) return; const OwnerActorsMap::Entry* entry = mBindingData->mOwnerActorsMap.find(&inObj); if(entry != NULL) { if(!mBindingData->mOwnerActorsMap[&inObj]->contains(&owner)) mBindingData->mOwnerActorsMap[&inObj]->insert(&owner); } else { OwnerActorsValueType* data = reinterpret_cast<OwnerActorsValueType*>( PX_ALLOC(sizeof(OwnerActorsValueType), "mOwnerActorsMapValue")); //( 1 ); OwnerActorsValueType* actors = PX_PLACEMENT_NEW(data, OwnerActorsValueType); actors->insert(&owner); mBindingData->mOwnerActorsMap.insert(&inObj, actors); } if(inStream.isInstanceValid(&inObj)) { inStream.pushBackObjectRef(&owner, "Shapes", &inObj); return; } inStream.createInstance(&inObj); inStream.pushBackObjectRef(&owner, "Shapes", &inObj); inStream.setPropertyValue(&inObj, "Actor", reinterpret_cast<const void*>(&owner)); sendAllProperties(inStream, inObj); setGeometry(*this, inStream, inObj, pvd); setMaterials(*this, inStream, inObj, pvd, mBindingData); if(!inObj.isExclusive()) inStream.pushBackObjectRef(&ownerPhysics, "SharedShapes", &inObj); } void PvdMetaDataBinding::sendAllProperties(PvdDataStream& inStream, const PxShape& inObj) { PxShapeGeneratedValues values(&inObj); inStream.setPropertyMessage(&inObj, values); } void PvdMetaDataBinding::releaseAndRecreateGeometry(PvdDataStream& inStream, const PxShape& inObj, PxPhysics& /*ownerPhysics*/, PsPvd* pvd) { const void* geomInst = (reinterpret_cast<const PxU8*>(&inObj)) + 4; inStream.destroyInstance(geomInst); const PxGeometry& geom = inObj.getGeometry(); // Quick fix for HF modify, PxConvexMesh and PxTriangleMesh need recook, they should always be new if modified if(geom.getType() == PxGeometryType::eHEIGHTFIELD) { const PxHeightFieldGeometry& hfGeom = static_cast<const PxHeightFieldGeometry&>(geom); if(inStream.isInstanceValid(hfGeom.heightField)) sendAllProperties(inStream, *hfGeom.heightField); } setGeometry(*this, inStream, inObj, pvd); // Need update actor cause PVD takes actor-shape as a pair. { PxRigidActor* actor = inObj.getActor(); if(actor != NULL) { if(const PxRigidStatic* rgS = actor->is<PxRigidStatic>()) sendAllProperties(inStream, *rgS); else if(const PxRigidDynamic* rgD = actor->is<PxRigidDynamic>()) sendAllProperties(inStream, *rgD); } } } void PvdMetaDataBinding::updateMaterials(PvdDataStream& inStream, const PxShape& inObj, PsPvd* pvd) { // Clear the shape's materials array. inStream.setPropertyValue(&inObj, "Materials", DataRef<const PxU8>(), getPvdNamespacedNameForType<ObjectRef>()); setMaterials(*this, inStream, inObj, pvd, mBindingData); } void PvdMetaDataBinding::destroyInstance(PvdDataStream& inStream, const PxShape& inObj, const PxRigidActor& owner) { if(inStream.isInstanceValid(&inObj)) { inStream.removeObjectRef(&owner, "Shapes", &inObj); bool bDestroy = true; const OwnerActorsMap::Entry* entry0 = mBindingData->mOwnerActorsMap.find(&inObj); if(entry0 != NULL) { entry0->second->erase(&owner); if(entry0->second->size() > 0) bDestroy = false; else { mBindingData->mOwnerActorsMap[&inObj]->~OwnerActorsValueType(); PX_FREE(mBindingData->mOwnerActorsMap[&inObj]); mBindingData->mOwnerActorsMap.erase(&inObj); } } if(bDestroy) { if(!inObj.isExclusive()) inStream.removeObjectRef(&PxGetPhysics(), "SharedShapes", &inObj); const void* geomInst = (reinterpret_cast<const PxU8*>(&inObj)) + 4; inStream.destroyInstance(geomInst); inStream.destroyInstance(&inObj); const OwnerActorsMap::Entry* entry = mBindingData->mOwnerActorsMap.find(&inObj); if(entry != NULL) { entry->second->~OwnerActorsValueType(); OwnerActorsValueType* ptr = entry->second; PX_FREE(ptr); mBindingData->mOwnerActorsMap.erase(&inObj); } } } } template <typename TDataType> static void addSceneGroupProperty(PvdDataStream& inStream, const char* groupName, const TDataType& inObj, const PxScene& inScene) { inStream.createInstance(&inObj); inStream.pushBackObjectRef(&inScene, groupName, &inObj); inStream.setPropertyValue(&inObj, "Scene", reinterpret_cast<const void*>(&inScene)); } template <typename TDataType> static void removeSceneGroupProperty(PvdDataStream& inStream, const char* groupName, const TDataType& inObj, const PxScene& inScene) { inStream.removeObjectRef(&inScene, groupName, &inObj); inStream.destroyInstance(&inObj); } static void sendShapes(PvdMetaDataBinding& binding, PvdDataStream& inStream, const PxRigidActor& inObj, const PxPhysics& ownerPhysics, PsPvd* pvd) { PxInlineArray<PxShape*, 5> shapeData; PxU32 nbShapes = inObj.getNbShapes(); shapeData.resize(nbShapes); inObj.getShapes(shapeData.begin(), nbShapes); for(PxU32 idx = 0; idx < nbShapes; ++idx) binding.createInstance(inStream, *shapeData[idx], inObj, ownerPhysics, pvd); } static void releaseShapes(PvdMetaDataBinding& binding, PvdDataStream& inStream, const PxRigidActor& inObj) { PxInlineArray<PxShape*, 5> shapeData; PxU32 nbShapes = inObj.getNbShapes(); shapeData.resize(nbShapes); inObj.getShapes(shapeData.begin(), nbShapes); for(PxU32 idx = 0; idx < nbShapes; ++idx) binding.destroyInstance(inStream, *shapeData[idx], inObj); } void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxRigidStatic& inObj, const PxScene& ownerScene, const PxPhysics& ownerPhysics, PsPvd* pvd) { addSceneGroupProperty(inStream, "RigidStatics", inObj, ownerScene); sendAllProperties(inStream, inObj); sendShapes(*this, inStream, inObj, ownerPhysics, pvd); } void PvdMetaDataBinding::sendAllProperties(PvdDataStream& inStream, const PxRigidStatic& inObj) { PxRigidStaticGeneratedValues values(&inObj); inStream.setPropertyMessage(&inObj, values); } void PvdMetaDataBinding::destroyInstance(PvdDataStream& inStream, const PxRigidStatic& inObj, const PxScene& ownerScene) { releaseShapes(*this, inStream, inObj); removeSceneGroupProperty(inStream, "RigidStatics", inObj, ownerScene); } void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxRigidDynamic& inObj, const PxScene& ownerScene, const PxPhysics& ownerPhysics, PsPvd* pvd) { addSceneGroupProperty(inStream, "RigidDynamics", inObj, ownerScene); sendAllProperties(inStream, inObj); sendShapes(*this, inStream, inObj, ownerPhysics, pvd); } void PvdMetaDataBinding::sendAllProperties(PvdDataStream& inStream, const PxRigidDynamic& inObj) { PxRigidDynamicGeneratedValues values(&inObj); inStream.setPropertyMessage(&inObj, values); } void PvdMetaDataBinding::destroyInstance(PvdDataStream& inStream, const PxRigidDynamic& inObj, const PxScene& ownerScene) { releaseShapes(*this, inStream, inObj); removeSceneGroupProperty(inStream, "RigidDynamics", inObj, ownerScene); } static void addChild(PvdDataStream& inStream, const void* inParent, const PxArticulationLink& inChild) { inStream.pushBackObjectRef(inParent, "Links", &inChild); inStream.setPropertyValue(&inChild, "Parent", inParent); } void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxArticulationReducedCoordinate& inObj, const PxScene& ownerScene, const PxPhysics& ownerPhysics, PsPvd* pvd) { addSceneGroupProperty(inStream, "Articulations", inObj, ownerScene); sendAllProperties(inStream, inObj); PxU32 numLinks = inObj.getNbLinks(); mBindingData->mArticulationLinks.resize(numLinks); inObj.getLinks(mBindingData->mArticulationLinks.begin(), numLinks); // From Dilip Sequiera: /* No, there can only be one root, and in all the code I wrote (which is not 100% of the HL code for articulations), the index of a child is always > the index of the parent. */ // Create all the links for(PxU32 idx = 0; idx < numLinks; ++idx) { if(!inStream.isInstanceValid(mBindingData->mArticulationLinks[idx])) createInstance(inStream, *mBindingData->mArticulationLinks[idx], ownerPhysics, pvd); } // Setup the link graph for(PxU32 idx = 0; idx < numLinks; ++idx) { PxArticulationLink* link = mBindingData->mArticulationLinks[idx]; if(idx == 0) addChild(inStream, &inObj, *link); PxU32 numChildren = link->getNbChildren(); PxArticulationLink** children = mBindingData->allocateTemp<PxArticulationLink*>(numChildren); link->getChildren(children, numChildren); for(PxU32 i = 0; i < numChildren; ++i) addChild(inStream, link, *children[i]); } } void PvdMetaDataBinding::sendAllProperties(PvdDataStream& inStream, const PxArticulationReducedCoordinate& inObj) { PxArticulationReducedCoordinateGeneratedValues values(&inObj); inStream.setPropertyMessage(&inObj, values); } void PvdMetaDataBinding::destroyInstance(PvdDataStream& inStream, const PxArticulationReducedCoordinate& inObj, const PxScene& ownerScene) { removeSceneGroupProperty(inStream, "Articulations", inObj, ownerScene); } void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxArticulationLink& inObj, const PxPhysics& ownerPhysics, PsPvd* pvd) { inStream.createInstance(&inObj); PxArticulationJointReducedCoordinate* joint(inObj.getInboundJoint()); if(joint) { inStream.createInstance(joint); inStream.setPropertyValue(&inObj, "InboundJoint", reinterpret_cast<const void*>(joint)); inStream.setPropertyValue(joint, "Link", reinterpret_cast<const void*>(&inObj)); sendAllProperties(inStream, *joint); } sendAllProperties(inStream, inObj); sendShapes(*this, inStream, inObj, ownerPhysics, pvd); } void PvdMetaDataBinding::sendAllProperties(PvdDataStream& inStream, const PxArticulationLink& inObj) { PxArticulationLinkGeneratedValues values(&inObj); inStream.setPropertyMessage(&inObj, values); } void PvdMetaDataBinding::destroyInstance(PvdDataStream& inStream, const PxArticulationLink& inObj) { PxArticulationJointReducedCoordinate* joint(inObj.getInboundJoint()); if(joint) inStream.destroyInstance(joint); releaseShapes(*this, inStream, inObj); inStream.destroyInstance(&inObj); } // These are created as part of the articulation link's creation process, so outside entities don't need to // create them. void PvdMetaDataBinding::sendAllProperties(PvdDataStream& inStream, const PxArticulationJointReducedCoordinate& inObj) { PxArticulationJointReducedCoordinateGeneratedValues values(&inObj); inStream.setPropertyMessage(&inObj, values); } void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxSoftBody& inObj, const PxScene& ownerScene, const PxPhysics& ownerPhysics, PsPvd* pvd) { PX_UNUSED(inStream); PX_UNUSED(inObj); PX_UNUSED(ownerScene); PX_UNUSED(ownerPhysics); PX_UNUSED(pvd); } void PvdMetaDataBinding::sendAllProperties(PvdDataStream& inStream, const PxSoftBody& inObj) { PX_UNUSED(inStream); PX_UNUSED(inObj); } void PvdMetaDataBinding::destroyInstance(PvdDataStream& inStream, const PxSoftBody& inObj, const PxScene& ownerScene) { PX_UNUSED(inStream); PX_UNUSED(inObj); PX_UNUSED(ownerScene); } void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxFEMCloth& inObj, const PxScene& ownerScene, const PxPhysics& ownerPhysics, PsPvd* pvd) { PX_UNUSED(inStream); PX_UNUSED(inObj); PX_UNUSED(ownerScene); PX_UNUSED(ownerPhysics); PX_UNUSED(pvd); } void PvdMetaDataBinding::sendAllProperties(PvdDataStream& inStream, const PxFEMCloth& inObj) { PX_UNUSED(inStream); PX_UNUSED(inObj); } void PvdMetaDataBinding::destroyInstance(PvdDataStream& inStream, const PxFEMCloth& inObj, const PxScene& ownerScene) { PX_UNUSED(inStream); PX_UNUSED(inObj); PX_UNUSED(ownerScene); } void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxPBDParticleSystem& inObj, const PxScene& ownerScene, const PxPhysics& ownerPhysics, PsPvd* pvd) { PX_UNUSED(inStream); PX_UNUSED(inObj); PX_UNUSED(ownerScene); PX_UNUSED(ownerPhysics); PX_UNUSED(pvd); } void PvdMetaDataBinding::sendAllProperties(PvdDataStream& inStream, const PxPBDParticleSystem& inObj) { PX_UNUSED(inStream); PX_UNUSED(inObj); } void PvdMetaDataBinding::destroyInstance(PvdDataStream& inStream, const PxPBDParticleSystem& inObj, const PxScene& ownerScene) { PX_UNUSED(inStream); PX_UNUSED(inObj); PX_UNUSED(ownerScene); } void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxFLIPParticleSystem& inObj, const PxScene& ownerScene, const PxPhysics& ownerPhysics, PsPvd* pvd) { PX_UNUSED(inStream); PX_UNUSED(inObj); PX_UNUSED(ownerScene); PX_UNUSED(ownerPhysics); PX_UNUSED(pvd); } void PvdMetaDataBinding::sendAllProperties(PvdDataStream& inStream, const PxFLIPParticleSystem& inObj) { PX_UNUSED(inStream); PX_UNUSED(inObj); } void PvdMetaDataBinding::destroyInstance(PvdDataStream& inStream, const PxFLIPParticleSystem& inObj, const PxScene& ownerScene) { PX_UNUSED(inStream); PX_UNUSED(inObj); PX_UNUSED(ownerScene); } void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxMPMParticleSystem& inObj, const PxScene& ownerScene, const PxPhysics& ownerPhysics, PsPvd* pvd) { PX_UNUSED(inStream); PX_UNUSED(inObj); PX_UNUSED(ownerScene); PX_UNUSED(ownerPhysics); PX_UNUSED(pvd); } void PvdMetaDataBinding::sendAllProperties(PvdDataStream& inStream, const PxMPMParticleSystem& inObj) { PX_UNUSED(inStream); PX_UNUSED(inObj); } void PvdMetaDataBinding::destroyInstance(PvdDataStream& inStream, const PxMPMParticleSystem& inObj, const PxScene& ownerScene) { PX_UNUSED(inStream); PX_UNUSED(inObj); PX_UNUSED(ownerScene); } void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxHairSystem& inObj, const PxScene& ownerScene, const PxPhysics& ownerPhysics, PsPvd* pvd) { PX_UNUSED(inStream); PX_UNUSED(inObj); PX_UNUSED(ownerScene); PX_UNUSED(ownerPhysics); PX_UNUSED(pvd); } void PvdMetaDataBinding::sendAllProperties(PvdDataStream& inStream, const PxHairSystem& inObj) { PX_UNUSED(inStream); PX_UNUSED(inObj); } void PvdMetaDataBinding::destroyInstance(PvdDataStream& inStream, const PxHairSystem& inObj, const PxScene& ownerScene) { PX_UNUSED(inStream); PX_UNUSED(inObj); PX_UNUSED(ownerScene); } void PvdMetaDataBinding::originShift(PvdDataStream& inStream, const PxScene* inScene, PxVec3 shift) { inStream.originShift(inScene, shift); } template <typename TBlockType, typename TActorType, typename TOperator> static void updateActor(PvdDataStream& inStream, TActorType** actorGroup, PxU32 numActors, TOperator sleepingOp, PvdMetaDataBindingData& bindingData) { TBlockType theBlock; if(numActors == 0) return; for(PxU32 idx = 0; idx < numActors; ++idx) { TActorType* theActor(actorGroup[idx]); bool sleeping = sleepingOp(theActor, theBlock); bool wasSleeping = bindingData.mSleepingActors.contains(theActor); if(sleeping == false || sleeping != wasSleeping) { theBlock.GlobalPose = theActor->getGlobalPose(); theBlock.AngularVelocity = theActor->getAngularVelocity(); theBlock.LinearVelocity = theActor->getLinearVelocity(); inStream.sendPropertyMessageFromGroup(theActor, theBlock); if(sleeping != wasSleeping) { if(sleeping) bindingData.mSleepingActors.insert(theActor); else bindingData.mSleepingActors.erase(theActor); } } } } struct RigidDynamicUpdateOp { bool operator()(PxRigidDynamic* actor, PxRigidDynamicUpdateBlock& block) { bool sleeping = actor->isSleeping(); block.IsSleeping = sleeping; return sleeping; } }; struct ArticulationLinkUpdateOp { bool sleeping; ArticulationLinkUpdateOp(bool s) : sleeping(s) { } bool operator()(PxArticulationLink*, PxArticulationLinkUpdateBlock&) { return sleeping; } }; void PvdMetaDataBinding::updateDynamicActorsAndArticulations(PvdDataStream& inStream, const PxScene* inScene, PvdVisualizer* linkJointViz) { PX_COMPILE_TIME_ASSERT(sizeof(PxRigidDynamicUpdateBlock) == 14 * 4); { PxU32 actorCount = inScene->getNbActors(PxActorTypeFlag::eRIGID_DYNAMIC); if(actorCount) { inStream.beginPropertyMessageGroup<PxRigidDynamicUpdateBlock>(); mBindingData->mActors.resize(actorCount); PxActor** theActors = mBindingData->mActors.begin(); inScene->getActors(PxActorTypeFlag::eRIGID_DYNAMIC, theActors, actorCount); updateActor<PxRigidDynamicUpdateBlock>(inStream, reinterpret_cast<PxRigidDynamic**>(theActors), actorCount, RigidDynamicUpdateOp(), *mBindingData); inStream.endPropertyMessageGroup(); } } { PxU32 articulationCount = inScene->getNbArticulations(); if(articulationCount) { mBindingData->mArticulations.resize(articulationCount); PxArticulationReducedCoordinate** firstArticulation = mBindingData->mArticulations.begin(); PxArticulationReducedCoordinate** lastArticulation = firstArticulation + articulationCount; inScene->getArticulations(firstArticulation, articulationCount); inStream.beginPropertyMessageGroup<PxArticulationLinkUpdateBlock>(); for(; firstArticulation < lastArticulation; ++firstArticulation) { PxU32 linkCount = (*firstArticulation)->getNbLinks(); bool sleeping = (*firstArticulation)->isSleeping(); if(linkCount) { mBindingData->mArticulationLinks.resize(linkCount); PxArticulationLink** theLink = mBindingData->mArticulationLinks.begin(); (*firstArticulation)->getLinks(theLink, linkCount); updateActor<PxArticulationLinkUpdateBlock>(inStream, theLink, linkCount, ArticulationLinkUpdateOp(sleeping), *mBindingData); if(linkJointViz) { for(PxU32 idx = 0; idx < linkCount; ++idx) linkJointViz->visualize(*theLink[idx]); } } } inStream.endPropertyMessageGroup(); firstArticulation = mBindingData->mArticulations.begin(); for (; firstArticulation < lastArticulation; ++firstArticulation) { inStream.setPropertyValue(*firstArticulation, "IsSleeping", (*firstArticulation)->isSleeping()); inStream.setPropertyValue(*firstArticulation, "RootGlobalPose", (*firstArticulation)->getRootGlobalPose()); inStream.setPropertyValue(*firstArticulation, "RootLinearVelocity", (*firstArticulation)->getRootLinearVelocity()); inStream.setPropertyValue(*firstArticulation, "RootAngularVelocity", (*firstArticulation)->getRootAngularVelocity()); } inStream.beginPropertyMessageGroup<PxArticulationJointUpdateBlock>(); firstArticulation = mBindingData->mArticulations.begin(); for (; firstArticulation < lastArticulation; ++firstArticulation) { PxU32 linkCount = (*firstArticulation)->getNbLinks(); bool sleeping = (*firstArticulation)->isSleeping(); if (!sleeping) { for (PxU32 idx = 1; idx < linkCount; ++idx) { mBindingData->mArticulationLinks.resize(linkCount); PxArticulationLink** theLink = mBindingData->mArticulationLinks.begin(); (*firstArticulation)->getLinks(theLink, linkCount); PxArticulationJointUpdateBlock jointBlock; PxArticulationJointReducedCoordinate* joint = theLink[idx]->getInboundJoint(); jointBlock.JointPosition_eX = joint->getJointPosition(PxArticulationAxis::eX); jointBlock.JointPosition_eY = joint->getJointPosition(PxArticulationAxis::eY); jointBlock.JointPosition_eZ = joint->getJointPosition(PxArticulationAxis::eZ); jointBlock.JointPosition_eTwist = joint->getJointPosition(PxArticulationAxis::eTWIST); jointBlock.JointPosition_eSwing1 = joint->getJointPosition(PxArticulationAxis::eSWING1); jointBlock.JointPosition_eSwing2 = joint->getJointPosition(PxArticulationAxis::eSWING2); jointBlock.JointVelocity_eX = joint->getJointVelocity(PxArticulationAxis::eX); jointBlock.JointVelocity_eY = joint->getJointVelocity(PxArticulationAxis::eY); jointBlock.JointVelocity_eZ = joint->getJointVelocity(PxArticulationAxis::eZ); jointBlock.JointVelocity_eTwist = joint->getJointVelocity(PxArticulationAxis::eTWIST); jointBlock.JointVelocity_eSwing1 = joint->getJointVelocity(PxArticulationAxis::eSWING1); jointBlock.JointVelocity_eSwing2 = joint->getJointVelocity(PxArticulationAxis::eSWING2); inStream.sendPropertyMessageFromGroup(joint, jointBlock); } } } inStream.endPropertyMessageGroup(); } } } template <typename TObjType> struct CollectionOperator { PxArray<PxU8>& mTempArray; const TObjType& mObject; PvdDataStream& mStream; CollectionOperator(PxArray<PxU8>& ary, const TObjType& obj, PvdDataStream& stream) : mTempArray(ary), mObject(obj), mStream(stream) { } void pushName(const char*) { } void popName() { } template <typename TAccessor> void simpleProperty(PxU32 /*key*/, const TAccessor&) { } template <typename TAccessor> void flagsProperty(PxU32 /*key*/, const TAccessor&, const PxU32ToName*) { } template <typename TColType, typename TDataType, typename TCollectionProp> void handleCollection(const TCollectionProp& prop, NamespacedName dtype, PxU32 countMultiplier = 1) { PxU32 count = prop.size(&mObject); mTempArray.resize(count * sizeof(TDataType)); TColType* start = reinterpret_cast<TColType*>(mTempArray.begin()); prop.get(&mObject, start, count * countMultiplier); mStream.setPropertyValue(&mObject, prop.mName, DataRef<const PxU8>(mTempArray.begin(), mTempArray.size()), dtype); } template <PxU32 TKey, typename TObject, typename TColType> void handleCollection(const PxReadOnlyCollectionPropertyInfo<TKey, TObject, TColType>& prop) { handleCollection<TColType, TColType>(prop, getPvdNamespacedNameForType<TColType>()); } // Enumerations or bitflags. template <PxU32 TKey, typename TObject, typename TColType> void handleCollection(const PxReadOnlyCollectionPropertyInfo<TKey, TObject, TColType>& prop, const PxU32ToName*) { PX_COMPILE_TIME_ASSERT(sizeof(TColType) == sizeof(PxU32)); handleCollection<TColType, PxU32>(prop, getPvdNamespacedNameForType<PxU32>()); } private: CollectionOperator& operator=(const CollectionOperator&); }; // per frame update #define ENABLE_AGGREGATE_PVD_SUPPORT 1 #ifdef ENABLE_AGGREGATE_PVD_SUPPORT void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxAggregate& inObj, const PxScene& ownerScene) { addSceneGroupProperty(inStream, "Aggregates", inObj, ownerScene); sendAllProperties(inStream, inObj); } void PvdMetaDataBinding::sendAllProperties(PvdDataStream& inStream, const PxAggregate& inObj) { PxAggregateGeneratedValues values(&inObj); inStream.setPropertyMessage(&inObj, values); } void PvdMetaDataBinding::destroyInstance(PvdDataStream& inStream, const PxAggregate& inObj, const PxScene& ownerScene) { removeSceneGroupProperty(inStream, "Aggregates", inObj, ownerScene); } class ChangeOjectRefCmd : public PvdDataStream::PvdCommand { ChangeOjectRefCmd& operator=(const ChangeOjectRefCmd&) { PX_ASSERT(0); return *this; } // PX_NOCOPY doesn't work for local classes public: const void* mInstance; String mPropName; const void* mPropObj; const bool mPushBack; ChangeOjectRefCmd(const void* inInst, String inName, const void* inObj, bool pushBack) : mInstance(inInst), mPropName(inName), mPropObj(inObj), mPushBack(pushBack) { } // Assigned is needed for copying ChangeOjectRefCmd(const ChangeOjectRefCmd& other) : PvdDataStream::PvdCommand(other), mInstance(other.mInstance), mPropName(other.mPropName), mPropObj(other.mPropObj), mPushBack(other.mPushBack) { } virtual bool canRun(PvdInstanceDataStream& inStream) { PX_ASSERT(inStream.isInstanceValid(mInstance)); return inStream.isInstanceValid(mPropObj); } virtual void run(PvdInstanceDataStream& inStream) { if(!inStream.isInstanceValid(mInstance)) return; if(mPushBack) { if(inStream.isInstanceValid(mPropObj)) inStream.pushBackObjectRef(mInstance, mPropName, mPropObj); } else { // the called function will assert if propobj is already removed inStream.removeObjectRef(mInstance, mPropName, mPropObj); } } }; static void changeAggregateSubActors(PvdDataStream& inStream, const PxAggregate& inObj, const PxActor& inActor, bool pushBack) { const PxArticulationLink* link = inActor.is<PxArticulationLink>(); String propName = NULL; const void* object = NULL; if(link == NULL) { propName = "Actors"; object = &inActor; } else if(link->getInboundJoint() == NULL) { propName = "Articulations"; object = &link->getArticulation(); } else return; ChangeOjectRefCmd* cmd = PX_PLACEMENT_NEW(inStream.allocateMemForCmd(sizeof(ChangeOjectRefCmd)), ChangeOjectRefCmd)(&inObj, propName, object, pushBack); if(cmd->canRun(inStream)) cmd->run(inStream); else inStream.pushPvdCommand(*cmd); } void PvdMetaDataBinding::detachAggregateActor(PvdDataStream& inStream, const PxAggregate& inObj, const PxActor& inActor) { changeAggregateSubActors(inStream, inObj, inActor, false); } void PvdMetaDataBinding::attachAggregateActor(PvdDataStream& inStream, const PxAggregate& inObj, const PxActor& inActor) { changeAggregateSubActors(inStream, inObj, inActor, true); } #else void PvdMetaDataBinding::createInstance(PvdDataStream&, const PxAggregate&, const PxScene&, ObjectRegistrar&) { } void PvdMetaDataBinding::sendAllProperties(PvdDataStream&, const PxAggregate&) { } void PvdMetaDataBinding::destroyInstance(PvdDataStream&, const PxAggregate&, const PxScene&) { } void PvdMetaDataBinding::detachAggregateActor(PvdDataStream&, const PxAggregate&, const PxActor&) { } void PvdMetaDataBinding::attachAggregateActor(PvdDataStream&, const PxAggregate&, const PxActor&) { } #endif template <typename TDataType> static void sendSceneArray(PvdDataStream& inStream, const PxScene& inScene, const PxArray<TDataType>& inArray, const char* propName) { if(0 == inArray.size()) inStream.setPropertyValue(&inScene, propName, DataRef<const PxU8>(), getPvdNamespacedNameForType<TDataType>()); else { ScopedPropertyValueSender<TDataType, 32> sender(inStream, &inScene, propName); for(PxU32 i = 0; i < inArray.size(); ++i) sender.append(inArray[i]); } } static void sendSceneArray(PvdDataStream& inStream, const PxScene& inScene, const PxArray<PvdSqHit>& inArray, const char* propName) { if(0 == inArray.size()) inStream.setPropertyValue(&inScene, propName, DataRef<const PxU8>(), getPvdNamespacedNameForType<PvdSqHit>()); else { ScopedPropertyValueSender<PvdSqHit, 32> sender(inStream, &inScene, propName); for(PxU32 i = 0; i < inArray.size(); ++i) { if(!inStream.isInstanceValid(inArray[i].mShape) || !inStream.isInstanceValid(inArray[i].mActor)) { PvdSqHit hit = inArray[i]; hit.mShape = NULL; hit.mActor = NULL; sender.append(hit); } else sender.append(inArray[i]); } } } void PvdMetaDataBinding::sendSceneQueries(PvdDataStream& inStream, const PxScene& inScene, PsPvd* pvd) { if(!inStream.isConnected()) return; const physx::NpScene& scene = static_cast<const NpScene&>(inScene); { PvdSceneQueryCollector& collector = scene.getNpSQ().getSingleSqCollector(); PxMutex::ScopedLock lock(collector.getLock()); String propName = collector.getArrayName(collector.mPvdSqHits); sendSceneArray(inStream, inScene, collector.mPvdSqHits, propName); propName = collector.getArrayName(collector.mPoses); sendSceneArray(inStream, inScene, collector.mPoses, propName); propName = collector.getArrayName(collector.mFilterData); sendSceneArray(inStream, inScene, collector.mFilterData, propName); const NamedArray<PxGeometryHolder>& geometriesToDestroy = collector.getPrevFrameGeometries(); propName = collector.getArrayName(geometriesToDestroy); for(PxU32 k = 0; k < geometriesToDestroy.size(); ++k) { const PxGeometryHolder& inObj = geometriesToDestroy[k]; inStream.removeObjectRef(&inScene, propName, &inObj); inStream.destroyInstance(&inObj); } const PxArray<PxGeometryHolder>& geometriesToCreate = collector.getCurrentFrameGeometries(); for(PxU32 k = 0; k < geometriesToCreate.size(); ++k) { const PxGeometry& geometry = geometriesToCreate[k].any(); switch(geometry.getType()) { #define SEND_PVD_GEOM_TYPE(enumType, TGeomType, TValueType) \ case enumType: \ { \ const TGeomType& inObj = static_cast<const TGeomType&>(geometry); \ inStream.createInstance(getPvdNamespacedNameForType<TGeomType>(), &inObj); \ registrarPhysicsObject<TGeomType>(inStream, inObj, pvd); \ TValueType values(&inObj); \ inStream.setPropertyMessage(&inObj, values); \ inStream.pushBackObjectRef(&inScene, propName, &inObj); \ } \ break; SEND_PVD_GEOM_TYPE(PxGeometryType::eBOX, PxBoxGeometry, PxBoxGeometryGeneratedValues) SEND_PVD_GEOM_TYPE(PxGeometryType::eSPHERE, PxSphereGeometry, PxSphereGeometryGeneratedValues) SEND_PVD_GEOM_TYPE(PxGeometryType::eCAPSULE, PxCapsuleGeometry, PxCapsuleGeometryGeneratedValues) SEND_PVD_GEOM_TYPE(PxGeometryType::eCONVEXMESH, PxConvexMeshGeometry, PxConvexMeshGeometryGeneratedValues) #undef SEND_PVD_GEOM_TYPE case PxGeometryType::ePLANE: case PxGeometryType::eTRIANGLEMESH: case PxGeometryType::eHEIGHTFIELD: case PxGeometryType::eTETRAHEDRONMESH: case PxGeometryType::ePARTICLESYSTEM: case PxGeometryType::eHAIRSYSTEM: case PxGeometryType::eCUSTOM: case PxGeometryType::eGEOMETRY_COUNT: case PxGeometryType::eINVALID: PX_ALWAYS_ASSERT_MESSAGE("unsupported scene query geometry type"); break; } } collector.prepareNextFrameGeometries(); propName = collector.getArrayName(collector.mAccumulatedRaycastQueries); sendSceneArray(inStream, inScene, collector.mAccumulatedRaycastQueries, propName); propName = collector.getArrayName(collector.mAccumulatedOverlapQueries); sendSceneArray(inStream, inScene, collector.mAccumulatedOverlapQueries, propName); propName = collector.getArrayName(collector.mAccumulatedSweepQueries); sendSceneArray(inStream, inScene, collector.mAccumulatedSweepQueries, propName); } } } } #endif
81,227
C++
39.573427
180
0.77553
NVIDIA-Omniverse/PhysX/physx/source/physx/src/NpFLIPMaterial.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef NP_FLIP_MATERIAL_H #define NP_FLIP_MATERIAL_H #include "common/PxSerialFramework.h" #include "foundation/PxUserAllocated.h" #include "foundation/PxUtilities.h" #include "CmRefCountable.h" #include "PxsFLIPMaterialCore.h" #include "PxFLIPMaterial.h" namespace physx { #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION // Compared to other objects, materials are special since they belong to the SDK and not to scenes // (similar to meshes). That's why the NpFLIPMaterial does have direct access to the core material instead // of having a buffered interface for it. Scenes will have copies of the SDK material table and there // the materials will be buffered. class NpFLIPMaterial : public PxFLIPMaterial, public PxUserAllocated { public: // PX_SERIALIZATION NpFLIPMaterial(PxBaseFlags baseFlags) : PxFLIPMaterial(baseFlags), mMaterial(PxEmpty) {} virtual void resolveReferences(PxDeserializationContext& context); static NpFLIPMaterial* createObject(PxU8*& address, PxDeserializationContext& context); static void getBinaryMetaData(PxOutputStream& stream); void preExportDataReset() { Cm::RefCountable_preExportDataReset(*this); } void exportExtraData(PxSerializationContext&) {} void importExtraData(PxDeserializationContext&) {} virtual void requiresObjects(PxProcessPxBaseCallback&) {} //~PX_SERIALIZATION NpFLIPMaterial(const PxsFLIPMaterialCore& desc); virtual ~NpFLIPMaterial(); // PxBase virtual void release() PX_OVERRIDE; //~PxBase // PxRefCounted virtual void acquireReference() PX_OVERRIDE; virtual PxU32 getReferenceCount() const PX_OVERRIDE; virtual void onRefCountZero() PX_OVERRIDE; //~PxRefCounted // PxParticleMaterial virtual void setFriction(PxReal friction) PX_OVERRIDE; virtual PxReal getFriction() const PX_OVERRIDE; virtual void setDamping(PxReal damping) PX_OVERRIDE; virtual PxReal getDamping() const PX_OVERRIDE; virtual void setAdhesion(PxReal adhesion) PX_OVERRIDE; virtual PxReal getAdhesion() const PX_OVERRIDE; virtual void setGravityScale(PxReal scale) PX_OVERRIDE; virtual PxReal getGravityScale() const PX_OVERRIDE; virtual void setAdhesionRadiusScale(PxReal scale) PX_OVERRIDE; virtual PxReal getAdhesionRadiusScale() const PX_OVERRIDE; //~PxParticleMaterial // PxFLIPMaterial virtual void setViscosity(PxReal viscosity) PX_OVERRIDE; virtual PxReal getViscosity() const PX_OVERRIDE; //~PxFLIPMaterial PX_FORCE_INLINE static void getMaterialIndices(NpFLIPMaterial*const* materials, PxU16* materialIndices, PxU32 materialCount); private: PX_INLINE void updateMaterial(); // PX_SERIALIZATION public: //~PX_SERIALIZATION PxsFLIPMaterialCore mMaterial; }; PX_FORCE_INLINE void NpFLIPMaterial::getMaterialIndices(NpFLIPMaterial*const* materials, PxU16* materialIndices, PxU32 materialCount) { for (PxU32 i = 0; i < materialCount; i++) materialIndices[i] = static_cast<NpFLIPMaterial*>(materials[i])->mMaterial.mMaterialIndex; } #endif } #endif
4,826
C
42.098214
134
0.75259
NVIDIA-Omniverse/PhysX/physx/source/physx/src/NpSoftBody.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #include "foundation/PxPreprocessor.h" #if PX_SUPPORT_GPU_PHYSX #include "NpSoftBody.h" #include "NpParticleSystem.h" #include "NpCheck.h" #include "NpScene.h" #include "NpShape.h" #include "geometry/PxTetrahedronMesh.h" #include "geometry/PxTetrahedronMeshGeometry.h" #include "PxPhysXGpu.h" #include "PxvGlobals.h" #include "GuTetrahedronMesh.h" #include "NpRigidDynamic.h" #include "NpRigidStatic.h" #include "NpArticulationLink.h" #include "ScSoftBodySim.h" #include "NpFEMSoftBodyMaterial.h" #include "cudamanager/PxCudaContext.h" using namespace physx; namespace physx { NpSoftBody::NpSoftBody(PxCudaContextManager& cudaContextManager) : NpActorTemplate (PxConcreteType::eSOFT_BODY, PxBaseFlag::eOWNS_MEMORY | PxBaseFlag::eIS_RELEASABLE, NpType::eSOFTBODY), mShape (NULL), mCudaContextManager(&cudaContextManager) { } NpSoftBody::NpSoftBody(PxBaseFlags baseFlags, PxCudaContextManager& cudaContextManager) : NpActorTemplate (baseFlags), mShape (NULL), mCudaContextManager(&cudaContextManager) { } PxBounds3 NpSoftBody::getWorldBounds(float inflation) const { NP_READ_CHECK(getNpScene()); if (!getNpScene()) { PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "Querying bounds of a PxSoftBody which is not part of a PxScene is not supported."); return PxBounds3::empty(); } const Sc::SoftBodySim* sim = mCore.getSim(); PX_ASSERT(sim); PX_SIMD_GUARD; PxBounds3 bounds = sim->getBounds(); PX_ASSERT(bounds.isValid()); // PT: unfortunately we can't just scale the min/max vectors, we need to go through center/extents. const PxVec3 center = bounds.getCenter(); const PxVec3 inflatedExtents = bounds.getExtents() * inflation; return PxBounds3::centerExtents(center, inflatedExtents); } PxU32 NpSoftBody::getGpuSoftBodyIndex() { NP_READ_CHECK(getNpScene()); PX_CHECK_AND_RETURN_VAL(getNpScene(), "PxSoftBody::getGpuSoftBodyIndex: Soft body must be in a scene.", 0xffffffff); return mCore.getGpuSoftBodyIndex(); } void NpSoftBody::setSoftBodyFlag(PxSoftBodyFlag::Enum flag, bool val) { PxSoftBodyFlags flags = mCore.getFlags(); if (val) flags.raise(flag); else flags.clear(flag); mCore.setFlags(flags); } void NpSoftBody::setSoftBodyFlags(PxSoftBodyFlags flags) { mCore.setFlags(flags); } PxSoftBodyFlags NpSoftBody::getSoftBodyFlag() const { return mCore.getFlags(); } void NpSoftBody::setParameter(PxFEMParameters paramters) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxSoftBody::setInternalIterationCount() not allowed while simulation is running. Call will be ignored.") mCore.setParameter(paramters); UPDATE_PVD_PROPERTY } PxFEMParameters NpSoftBody::getParameter() const { NP_READ_CHECK(getNpScene()); return mCore.getParameter(); } PxVec4* NpSoftBody::getPositionInvMassBufferD() { PX_CHECK_AND_RETURN_NULL(mShape != NULL, "NpSoftBody::getPositionInvMassBufferD: Softbody does not have a shape, attach shape first."); Dy::SoftBodyCore& core = mCore.getCore(); return core.mPositionInvMass; } PxVec4* NpSoftBody::getRestPositionBufferD() { PX_CHECK_AND_RETURN_NULL(mShape != NULL, "NpSoftBody::getRestPositionBufferD: Softbody does not have a shape, attach shape first."); Dy::SoftBodyCore& core = mCore.getCore(); return core.mRestPosition; } PxVec4* NpSoftBody::getSimPositionInvMassBufferD() { PX_CHECK_AND_RETURN_NULL(mSimulationMesh != NULL, "NpSoftBody::getSimPositionInvMassBufferD: Softbody does not have a simulation mesh, attach simulation mesh first."); Dy::SoftBodyCore& core = mCore.getCore(); return core.mSimPositionInvMass; } PxVec4* NpSoftBody::getSimVelocityBufferD() { PX_CHECK_AND_RETURN_NULL(mSimulationMesh != NULL, "NpSoftBody::getSimVelocityBufferD: Softbody does not have a simulation mesh, attach simulation mesh first."); Dy::SoftBodyCore& core = mCore.getCore(); return core.mSimVelocity; } void NpSoftBody::markDirty(PxSoftBodyDataFlags flags) { NP_WRITE_CHECK(getNpScene()); Dy::SoftBodyCore& core = mCore.getCore(); core.mDirtyFlags |= flags; } void NpSoftBody::setKinematicTargetBufferD(const PxVec4* positions, PxSoftBodyFlags flags) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(!(positions == NULL && flags != PxSoftBodyFlags(0)), "NpSoftBody::setKinematicTargetBufferD: targets cannot be null if flags are set to be kinematic."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "PxSoftBody::setKinematicTargetBufferD() not allowed while simulation is running. Call will be ignored.") mCore.setKinematicTargets(positions, flags); } PxCudaContextManager* NpSoftBody::getCudaContextManager() const { return mCudaContextManager; } void NpSoftBody::setWakeCounter(PxReal wakeCounterValue) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxSoftBody::setWakeCounter() not allowed while simulation is running. Call will be ignored.") mCore.setWakeCounter(wakeCounterValue); //UPDATE_PVD_PROPERTIES_OBJECT() } PxReal NpSoftBody::getWakeCounter() const { NP_READ_CHECK(getNpScene()); return mCore.getWakeCounter(); } bool NpSoftBody::isSleeping() const { NP_READ_CHECK(getNpScene()); return mCore.isSleeping(); } void NpSoftBody::setSolverIterationCounts(PxU32 positionIters, PxU32 velocityIters) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_AND_RETURN(positionIters > 0, "NpSoftBody::setSolverIterationCounts: positionIters must be more than zero!"); PX_CHECK_AND_RETURN(positionIters <= 255, "NpSoftBody::setSolverIterationCounts: positionIters must be no greater than 255!"); PX_CHECK_AND_RETURN(velocityIters <= 255, "NpSoftBody::setSolverIterationCounts: velocityIters must be no greater than 255!"); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxSoftBody::setSolverIterationCounts() not allowed while simulation is running. Call will be ignored.") mCore.setSolverIterationCounts((velocityIters & 0xff) << 8 | (positionIters & 0xff)); } void NpSoftBody::getSolverIterationCounts(PxU32& positionIters, PxU32& velocityIters) const { NP_READ_CHECK(getNpScene()); PxU16 x = mCore.getSolverIterationCounts(); velocityIters = PxU32(x >> 8); positionIters = PxU32(x & 0xff); } PxShape* NpSoftBody::getShape() { return mShape; } PxTetrahedronMesh* NpSoftBody::getCollisionMesh() { const PxTetrahedronMeshGeometry& tetMeshGeom = static_cast<const PxTetrahedronMeshGeometry&>(mShape->getGeometry()); return tetMeshGeom.tetrahedronMesh; } const PxTetrahedronMesh* NpSoftBody::getCollisionMesh() const { const PxTetrahedronMeshGeometry& tetMeshGeom = static_cast<const PxTetrahedronMeshGeometry&>(mShape->getGeometry()); return tetMeshGeom.tetrahedronMesh; } bool NpSoftBody::attachSimulationMesh(PxTetrahedronMesh& simulationMesh, PxSoftBodyAuxData& softBodyAuxData) { Dy::SoftBodyCore& core = mCore.getCore(); PX_CHECK_AND_RETURN_NULL(core.mSimPositionInvMass == NULL, "NpSoftBody::attachSimulationMesh: mSimPositionInvMass already exists, overwrite not allowed, call detachSimulationMesh first"); PX_CHECK_AND_RETURN_NULL(core.mSimVelocity == NULL, "NpSoftBody::attachSimulationMesh: mSimVelocity already exists, overwrite not allowed, call detachSimulationMesh first"); mSimulationMesh = static_cast<Gu::TetrahedronMesh*>(&simulationMesh); mSoftBodyAuxData = static_cast<Gu::SoftBodyAuxData*>(&softBodyAuxData); Gu::TetrahedronMesh* tetMesh = static_cast<Gu::TetrahedronMesh*>(&simulationMesh); const PxU32 numVertsGM = tetMesh->getNbVerticesFast(); core.mSimPositionInvMass = PX_DEVICE_ALLOC_T(PxVec4, mCudaContextManager, numVertsGM); core.mSimVelocity = PX_DEVICE_ALLOC_T(PxVec4, mCudaContextManager, numVertsGM); return true; } void NpSoftBody::updateMaterials() { Dy::SoftBodyCore& core = mCore.getCore(); core.clearMaterials(); for (PxU32 i = 0; i < mShape->getNbMaterials(); ++i) { PxFEMSoftBodyMaterial* material; mShape->getSoftBodyMaterials(&material, 1, i); core.setMaterial(static_cast<NpFEMSoftBodyMaterial*>(material)->mMaterial.mMaterialIndex); } } bool NpSoftBody::attachShape(PxShape& shape) { NpShape* npShape = static_cast<NpShape*>(&shape); PX_CHECK_AND_RETURN_NULL(npShape->getGeometryTypeFast() == PxGeometryType::eTETRAHEDRONMESH, "NpSoftBody::attachShape: Geometry type must be tetrahedron mesh geometry"); PX_CHECK_AND_RETURN_NULL(mShape == NULL, "NpSoftBody::attachShape: soft body can just have one shape"); PX_CHECK_AND_RETURN_NULL(shape.isExclusive(), "NpSoftBody::attachShape: shape must be exclusive"); PX_CHECK_AND_RETURN_NULL(npShape->getCore().getCore().mShapeCoreFlags & PxShapeCoreFlag::eSOFT_BODY_SHAPE, "NpSoftBody::attachShape: shape must be a soft body shape!"); Dy::SoftBodyCore& core = mCore.getCore(); PX_CHECK_AND_RETURN_NULL(core.mPositionInvMass == NULL, "NpSoftBody::attachShape: mPositionInvMass already exists, overwrite not allowed, call detachShape first"); mShape = npShape; PX_ASSERT(shape.getActor() == NULL); npShape->onActorAttach(*this); const PxGeometryHolder gh(mShape->getGeometry()); // PT: TODO: avoid that copy const PxTetrahedronMeshGeometry& tetGeometry = gh.tetMesh(); Gu::BVTetrahedronMesh* tetMesh = static_cast<Gu::BVTetrahedronMesh*>(tetGeometry.tetrahedronMesh); const PxU32 numVerts = tetMesh->getNbVerticesFast(); core.mPositionInvMass = PX_DEVICE_ALLOC_T(PxVec4, mCudaContextManager, numVerts); core.mRestPosition = PX_DEVICE_ALLOC_T(PxVec4, mCudaContextManager, numVerts); updateMaterials(); return true; } void NpSoftBody::detachShape() { PX_CHECK_MSG(getNpSceneFromActor(*this) == NULL, "Detaching a shape from a softbody is currenly only allowed as long as it is not part of a scene. Please remove the softbody from its scene first."); Dy::SoftBodyCore& core = mCore.getCore(); if (core.mRestPosition) { PX_DEVICE_FREE(mCudaContextManager, core.mRestPosition); core.mRestPosition = NULL; } if (core.mPositionInvMass) { PX_DEVICE_FREE(mCudaContextManager, core.mPositionInvMass); core.mPositionInvMass = NULL; } if (mShape) mShape->onActorDetach(); mShape = NULL; } void NpSoftBody::detachSimulationMesh() { Dy::SoftBodyCore& core = mCore.getCore(); if (core.mSimPositionInvMass) { PX_DEVICE_FREE(mCudaContextManager, core.mSimPositionInvMass); core.mSimPositionInvMass = NULL; } if (core.mSimVelocity) { PX_DEVICE_FREE(mCudaContextManager, core.mSimVelocity); core.mSimVelocity = NULL; } mSimulationMesh = NULL; mSoftBodyAuxData = NULL; } void NpSoftBody::release() { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); // AD why is this commented out? // NpPhysics::getInstance().notifyDeletionListenersUserRelease(this, PxArticulationBase::userData); if (npScene) { npScene->scRemoveSoftBody(*this); npScene->removeFromSoftBodyList(*this); } detachSimulationMesh(); detachShape(); PX_ASSERT(!isAPIWriteForbidden()); NpDestroySoftBody(this); } void NpSoftBody::setName(const char* debugName) { NP_WRITE_CHECK(getNpScene()); mName = debugName; } const char* NpSoftBody::getName() const { NP_READ_CHECK(getNpScene()); return mName; } void NpSoftBody::addParticleFilter(PxPBDParticleSystem* particlesystem, const PxParticleBuffer* buffer, PxU32 particleId, PxU32 tetId) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(getNpScene() != NULL, "NpSoftBody::addParticleFilter: Soft body must be inserted into the scene."); PX_CHECK_AND_RETURN((particlesystem == NULL || particlesystem->getScene() != NULL), "NpSoftBody::addParticleFilter: actor must be inserted into the scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "NpSoftBody::addParticleFilter: Illegal to call while simulation is running."); NpPBDParticleSystem* npParticleSystem = static_cast<NpPBDParticleSystem*>(particlesystem); Sc::ParticleSystemCore& core = npParticleSystem->getCore(); mCore.addParticleFilter(&core, particleId, buffer ? buffer->bufferUniqueId : 0, tetId); } void NpSoftBody::removeParticleFilter(PxPBDParticleSystem* particlesystem, const PxParticleBuffer* buffer, PxU32 particleId, PxU32 tetId) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(getNpScene() != NULL, "NpSoftBody::removeParticleFilter: Soft body must be inserted into the scene."); PX_CHECK_AND_RETURN((particlesystem == NULL || particlesystem->getScene() != NULL), "NpSoftBody::removeParticleFilter: actor must be inserted into the scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "NpSoftBody::removeParticleFilter: Illegal to call while simulation is running."); NpPBDParticleSystem* npParticleSystem = static_cast<NpPBDParticleSystem*>(particlesystem); Sc::ParticleSystemCore& core = npParticleSystem->getCore(); mCore.removeParticleFilter(&core, particleId, buffer ? buffer->bufferUniqueId : 0, tetId); } PxU32 NpSoftBody::addParticleAttachment(PxPBDParticleSystem* particlesystem, const PxParticleBuffer* buffer, PxU32 particleId, PxU32 tetId, const PxVec4& barycentric) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN_VAL(getNpScene() != NULL, "NpSoftBody::addParticleAttachment: Soft body must be inserted into the scene.", 0xFFFFFFFF); PX_CHECK_AND_RETURN_VAL((particlesystem == NULL || particlesystem->getScene() != NULL), "NpSoftBody::addParticleAttachment: actor must be inserted into the scene.", 0xFFFFFFFF); PX_CHECK_SCENE_API_WRITE_FORBIDDEN_AND_RETURN_VAL(getNpScene(), "NpSoftBody::addParticleAttachment: Illegal to call while simulation is running.", 0xFFFFFFFF); NpPBDParticleSystem* npParticleSystem = static_cast<NpPBDParticleSystem*>(particlesystem); Sc::ParticleSystemCore& core = npParticleSystem->getCore(); return mCore.addParticleAttachment(&core, particleId, buffer ? buffer->bufferUniqueId : 0, tetId, barycentric); } void NpSoftBody::removeParticleAttachment(PxPBDParticleSystem* particlesystem, PxU32 handle) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(getNpScene() != NULL, "NpSoftBody::addParticleAttachment: Soft body must be inserted into the scene."); PX_CHECK_AND_RETURN((particlesystem == NULL || particlesystem->getScene() != NULL), "NpSoftBody::addParticleAttachment: actor must be inserted into the scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "NpSoftBody::addParticleAttachment: Illegal to call while simulation is running."); NpPBDParticleSystem* npParticleSystem = static_cast<NpPBDParticleSystem*>(particlesystem); Sc::ParticleSystemCore& core = npParticleSystem->getCore(); mCore.removeParticleAttachment(&core, handle); } void NpSoftBody::addRigidFilter(PxRigidActor* actor, PxU32 vertId) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(getNpScene() != NULL, "NpSoftBody::addRigidFilter: Soft body must be inserted into the scene."); PX_CHECK_AND_RETURN((actor == NULL || actor->getScene() != NULL), "NpSoftBody::addRigidFilter: actor must be inserted into the scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "NpSoftBody::addRigidFilter: Illegal to call while simulation is running."); Sc::BodyCore* core = getBodyCore(actor); mCore.addRigidFilter(core, vertId); } void NpSoftBody::removeRigidFilter(PxRigidActor* actor, PxU32 vertId) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(getNpScene() != NULL, "NpSoftBody::removeRigidFilter: soft body must be inserted into the scene."); PX_CHECK_AND_RETURN((actor == NULL || actor->getScene() != NULL), "NpSoftBody::removeRigidFilter: actor must be inserted into the scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "NpSoftBody::removeRigidFilter: Illegal to call while simulation is running."); Sc::BodyCore* core = getBodyCore(actor); mCore.removeRigidFilter(core, vertId); } PxU32 NpSoftBody::addRigidAttachment(PxRigidActor* actor, PxU32 vertId, const PxVec3& actorSpacePose, PxConeLimitedConstraint* constraint) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN_VAL(getNpScene() != NULL, "NpSoftBody::addRigidAttachment: Soft body must be inserted into the scene.", 0xFFFFFFFF); PX_CHECK_AND_RETURN_VAL((actor == NULL || actor->getScene() != NULL), "NpSoftBody::addRigidAttachment: actor must be inserted into the scene.", 0xFFFFFFFF); PX_CHECK_AND_RETURN_VAL(constraint == NULL || constraint->isValid(), "NpSoftBody::addRigidAttachment: PxConeLimitedConstraint needs to be valid if specified.", 0xFFFFFFFF); PX_CHECK_SCENE_API_WRITE_FORBIDDEN_AND_RETURN_VAL(getNpScene(), "NpSoftBody::addRigidAttachment: Illegal to call while simulation is running.", 0xFFFFFFFF); Sc::BodyCore* core = getBodyCore(actor); PxVec3 aPose = actorSpacePose; if (actor && actor->getConcreteType()==PxConcreteType::eRIGID_STATIC) { NpRigidStatic* stat = static_cast<NpRigidStatic*>(actor); aPose = stat->getGlobalPose().transform(aPose); } return mCore.addRigidAttachment(core, vertId, aPose, constraint); } void NpSoftBody::removeRigidAttachment(PxRigidActor* actor, PxU32 handle) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(getNpScene() != NULL, "NpSoftBody::removeRigidAttachment: soft body must be inserted into the scene."); PX_CHECK_AND_RETURN((actor == NULL || actor->getScene() != NULL), "NpSoftBody::removeRigidAttachment: actor must be inserted into the scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "NpSoftBody::removeRigidAttachment: Illegal to call while simulation is running."); Sc::BodyCore* core = getBodyCore(actor); mCore.removeRigidAttachment(core, handle); } void NpSoftBody::addTetRigidFilter(PxRigidActor* actor, PxU32 tetIdx) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(getNpScene() != NULL, "NpSoftBody::addTetRigidFilter: Soft body must be inserted into the scene."); PX_CHECK_AND_RETURN((actor == NULL || actor->getScene() != NULL), "NpSoftBody::addTetRigidFilter: actor must be inserted into the scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "NpSoftBody::addTetRigidFilter: Illegal to call while simulation is running."); Sc::BodyCore* core = getBodyCore(actor); return mCore.addTetRigidFilter(core, tetIdx); } void NpSoftBody::removeTetRigidFilter(PxRigidActor* actor, PxU32 tetIdx) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(getNpScene() != NULL, "NpSoftBody::removeTetRigidFilter: soft body must be inserted into the scene."); PX_CHECK_AND_RETURN((actor == NULL || actor->getScene() != NULL), "NpSoftBody::removeTetRigidFilter: actor must be inserted into the scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "NpSoftBody::removeTetRigidFilter: Illegal to call while simulation is running."); Sc::BodyCore* core = getBodyCore(actor); mCore.removeTetRigidFilter(core, tetIdx); } PxU32 NpSoftBody::addTetRigidAttachment(PxRigidActor* actor, PxU32 tetIdx, const PxVec4& barycentric, const PxVec3& actorSpacePose, PxConeLimitedConstraint* constraint) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN_VAL(getNpScene() != NULL, "NpSoftBody::addTetRigidAttachment: Soft body must be inserted into the scene.", 0xFFFFFFFF); PX_CHECK_AND_RETURN_VAL((actor == NULL || actor->getScene() != NULL), "NpSoftBody::addTetRigidAttachment: actor must be inserted into the scene.", 0xFFFFFFFF); PX_CHECK_AND_RETURN_VAL(constraint == NULL || constraint->isValid(), "NpSoftBody::addTetRigidAttachment: PxConeLimitedConstraint needs to be valid if specified.", 0xFFFFFFFF); PX_CHECK_SCENE_API_WRITE_FORBIDDEN_AND_RETURN_VAL(getNpScene(), "NpSoftBody::addTetRigidAttachment: Illegal to call while simulation is running.", 0xFFFFFFFF); Sc::BodyCore* core = getBodyCore(actor); PxVec3 aPose = actorSpacePose; if (actor && actor->getConcreteType()==PxConcreteType::eRIGID_STATIC) { NpRigidStatic* stat = static_cast<NpRigidStatic*>(actor); aPose = stat->getGlobalPose().transform(aPose); } return mCore.addTetRigidAttachment(core, tetIdx, barycentric, aPose, constraint); } void NpSoftBody::addSoftBodyFilter(PxSoftBody* softbody0, PxU32 tetIdx0, PxU32 tetIdx1) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(softbody0 != NULL, "NpSoftBody::addSoftBodyFilter: soft body must not be null"); PX_CHECK_AND_RETURN(getNpScene() != NULL, "NpSoftBody::addSoftBodyFilter: soft body must be inserted into the scene."); PX_CHECK_AND_RETURN(softbody0->getScene() != NULL, "NpSoftBody::addSoftBodyFilter: soft body must be inserted into the scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "NpSoftBody::addSoftBodyFilter: Illegal to call while simulation is running."); NpSoftBody* dyn = static_cast<NpSoftBody*>(softbody0); Sc::SoftBodyCore* core = &dyn->getCore(); mCore.addSoftBodyFilter(*core, tetIdx0, tetIdx1); } void NpSoftBody::removeSoftBodyFilter(PxSoftBody* softbody0, PxU32 tetIdx0, PxU32 tetIdx1) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(softbody0 != NULL, "NpSoftBody::removeSoftBodyFilter: soft body must not be null"); PX_CHECK_AND_RETURN(getNpScene() != NULL, "NpSoftBody::removeSoftBodyFilter: soft body must be inserted into the scene."); PX_CHECK_AND_RETURN(softbody0->getScene() != NULL, "NpSoftBody::removeSoftBodyFilter: soft body must be inserted into the scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "NpSoftBody::removeSoftBodyFilter: Illegal to call while simulation is running."); NpSoftBody* dyn = static_cast<NpSoftBody*>(softbody0); Sc::SoftBodyCore* core = &dyn->getCore(); mCore.removeSoftBodyFilter(*core, tetIdx0, tetIdx1); } void NpSoftBody::addSoftBodyFilters(PxSoftBody* softbody0, PxU32* tetIndices0, PxU32* tetIndices1, PxU32 tetIndicesSize) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(softbody0 != NULL, "NpSoftBody::addSoftBodyFilter: soft body must not be null"); PX_CHECK_AND_RETURN(getNpScene() != NULL, "NpSoftBody::addSoftBodyFilter: soft body must be inserted into the scene."); PX_CHECK_AND_RETURN(softbody0->getScene() != NULL, "NpSoftBody::addSoftBodyFilter: soft body must be inserted into the scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "NpSoftBody::addSoftBodyFilter: Illegal to call while simulation is running."); NpSoftBody* dyn = static_cast<NpSoftBody*>(softbody0); Sc::SoftBodyCore* core = &dyn->getCore(); mCore.addSoftBodyFilters(*core, tetIndices0, tetIndices1, tetIndicesSize); } void NpSoftBody::removeSoftBodyFilters(PxSoftBody* softbody0, PxU32* tetIndices0, PxU32* tetIndices1, PxU32 tetIndicesSize) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(softbody0 != NULL, "NpSoftBody::removeSoftBodyFilter: soft body must not be null"); PX_CHECK_AND_RETURN(getNpScene() != NULL, "NpSoftBody::removeSoftBodyFilter: soft body must be inserted into the scene."); PX_CHECK_AND_RETURN(softbody0->getScene() != NULL, "NpSoftBody::removeSoftBodyFilter: soft body must be inserted into the scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "NpSoftBody::removeSoftBodyFilter: Illegal to call while simulation is running."); NpSoftBody* dyn = static_cast<NpSoftBody*>(softbody0); Sc::SoftBodyCore* core = &dyn->getCore(); mCore.removeSoftBodyFilters(*core, tetIndices0, tetIndices1, tetIndicesSize); } PxU32 NpSoftBody::addSoftBodyAttachment(PxSoftBody* softbody0, PxU32 tetIdx0, const PxVec4& tetBarycentric0, PxU32 tetIdx1, const PxVec4& tetBarycentric1, PxConeLimitedConstraint* constraint, PxReal constraintOffset) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN_VAL(softbody0 != NULL, "NpSoftBody::addSoftBodyAttachment: soft body must not be null", 0xFFFFFFFF); PX_CHECK_AND_RETURN_VAL(getNpScene() != NULL, "NpSoftBody::addSoftBodyAttachment: soft body must be inserted into the scene.", 0xFFFFFFFF); PX_CHECK_AND_RETURN_VAL(softbody0->getScene() != NULL, "NpSoftBody::addSoftBodyAttachment: soft body must be inserted into the scene.", 0xFFFFFFFF); PX_CHECK_AND_RETURN_VAL(constraint == NULL || constraint->isValid(), "NpSoftBody::addSoftBodyAttachment: PxConeLimitedConstraint needs to be valid if specified.", 0xFFFFFFFF); PX_CHECK_SCENE_API_WRITE_FORBIDDEN_AND_RETURN_VAL(getNpScene(), "NpSoftBody::addSoftBodyAttachment: Illegal to call while simulation is running.", 0xFFFFFFFF); NpSoftBody* dyn = static_cast<NpSoftBody*>(softbody0); Sc::SoftBodyCore* core = &dyn->getCore(); return mCore.addSoftBodyAttachment(*core, tetIdx0, tetBarycentric0, tetIdx1, tetBarycentric1, constraint, constraintOffset); } void NpSoftBody::removeSoftBodyAttachment(PxSoftBody* softbody0, PxU32 handle) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(softbody0 != NULL, "NpSoftBody::removeSoftBodyAttachment: soft body must not be null"); PX_CHECK_AND_RETURN(getNpScene() != NULL, "NpSoftBody::removeSoftBodyAttachment: soft body must be inserted into the scene."); PX_CHECK_AND_RETURN(softbody0->getScene() != NULL, "NpSoftBody::removeSoftBodyAttachment: soft body must be inserted into the scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "NpSoftBody::removeSoftBodyAttachment: Illegal to call while simulation is running."); NpSoftBody* dyn = static_cast<NpSoftBody*>(softbody0); Sc::SoftBodyCore* core = &dyn->getCore(); mCore.removeSoftBodyAttachment(*core, handle); } #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION void NpSoftBody::addClothFilter(PxFEMCloth* cloth, PxU32 triIdx, PxU32 tetIdx) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(cloth != NULL, "NpSoftBody::addClothFilter: actor must not be null"); PX_CHECK_AND_RETURN(getNpScene() != NULL, "NpSoftBody::addClothFilter: Soft body must be inserted into the scene."); PX_CHECK_AND_RETURN(cloth->getScene() != NULL, "NpSoftBody::addClothFilter: actor must be inserted into the scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "NpSoftBody::addClothFilter: Illegal to call while simulation is running."); NpFEMCloth* dyn = static_cast<NpFEMCloth*>(cloth); Sc::FEMClothCore* core = &dyn->getCore(); return mCore.addClothFilter(*core, triIdx, tetIdx); } #else void NpSoftBody::addClothFilter(PxFEMCloth*, PxU32, PxU32) {} #endif #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION void NpSoftBody::removeClothFilter(PxFEMCloth* cloth, PxU32 triIdx, PxU32 tetIdx) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(cloth != NULL, "NpSoftBody::removeClothFilter: actor must not be null"); PX_CHECK_AND_RETURN(getNpScene() != NULL, "NpSoftBody::removeClothFilter: soft body must be inserted into the scene."); PX_CHECK_AND_RETURN(cloth->getScene() != NULL, "NpSoftBody::removeClothFilter: actor must be inserted into the scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "NpSoftBody::removeClothFilter: Illegal to call while simulation is running."); NpFEMCloth* dyn = static_cast<NpFEMCloth*>(cloth); Sc::FEMClothCore* core = &dyn->getCore(); mCore.removeClothFilter(*core, triIdx, tetIdx); } #else void NpSoftBody::removeClothFilter(PxFEMCloth*, PxU32, PxU32) {} #endif #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION void NpSoftBody::addVertClothFilter(PxFEMCloth* cloth, PxU32 vertIdx, PxU32 tetIdx) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(cloth != NULL, "NpSoftBody::addClothFilter: actor must not be null"); PX_CHECK_AND_RETURN(getNpScene() != NULL, "NpSoftBody::addClothFilter: Soft body must be inserted into the scene."); PX_CHECK_AND_RETURN(cloth->getScene() != NULL, "NpSoftBody::addClothFilter: actor must be inserted into the scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "NpSoftBody::addClothFilter: Illegal to call while simulation is running."); NpFEMCloth* dyn = static_cast<NpFEMCloth*>(cloth); Sc::FEMClothCore* core = &dyn->getCore(); return mCore.addVertClothFilter(*core, vertIdx, tetIdx); } #else void NpSoftBody::addVertClothFilter(PxFEMCloth*, PxU32, PxU32) {} #endif #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION void NpSoftBody::removeVertClothFilter(PxFEMCloth* cloth, PxU32 vertIdx, PxU32 tetIdx) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(cloth != NULL, "NpSoftBody::removeClothFilter: actor must not be null"); PX_CHECK_AND_RETURN(getNpScene() != NULL, "NpSoftBody::removeClothFilter: soft body must be inserted into the scene."); PX_CHECK_AND_RETURN(cloth->getScene() != NULL, "NpSoftBody::removeClothFilter: actor must be inserted into the scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "NpSoftBody::removeClothFilter: Illegal to call while simulation is running."); NpFEMCloth* dyn = static_cast<NpFEMCloth*>(cloth); Sc::FEMClothCore* core = &dyn->getCore(); mCore.removeVertClothFilter(*core, vertIdx, tetIdx); } #else void NpSoftBody::removeVertClothFilter(PxFEMCloth*, PxU32, PxU32) {} #endif #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION PxU32 NpSoftBody::addClothAttachment(PxFEMCloth* cloth, PxU32 triIdx, const PxVec4& triBarycentric, PxU32 tetIdx, const PxVec4& tetBarycentric, PxConeLimitedConstraint* constraint, PxReal constraintOffset) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN_VAL(cloth != NULL, "NpSoftBody::addClothAttachment: actor must not be null", 0xFFFFFFFF); PX_CHECK_AND_RETURN_VAL(getNpScene() != NULL, "NpSoftBody::addClothAttachment: Soft body must be inserted into the scene.", 0xFFFFFFFF); PX_CHECK_AND_RETURN_VAL(cloth->getScene() != NULL, "NpSoftBody::addClothAttachment: actor must be inserted into the scene.", 0xFFFFFFFF); PX_CHECK_AND_RETURN_VAL(constraint == NULL || constraint->isValid(), "NpSoftBody::addClothAttachment: PxConeLimitedConstraint needs to be valid if specified.", 0xFFFFFFFF); PX_CHECK_SCENE_API_WRITE_FORBIDDEN_AND_RETURN_VAL(getNpScene(), "NpSoftBody::addClothAttachment: Illegal to call while simulation is running.", 0xFFFFFFFF); NpFEMCloth* dyn = static_cast<NpFEMCloth*>(cloth); Sc::FEMClothCore* core = &dyn->getCore(); return mCore.addClothAttachment(*core, triIdx, triBarycentric, tetIdx, tetBarycentric, constraint, constraintOffset); } #else PxU32 NpSoftBody::addClothAttachment(PxFEMCloth*, PxU32, const PxVec4&, PxU32, const PxVec4&, PxConeLimitedConstraint*, PxReal) { return 0; } #endif #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION void NpSoftBody::removeClothAttachment(PxFEMCloth* cloth, PxU32 handle) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(cloth != NULL, "NpSoftBody::releaseClothAttachment: actor must not be null"); PX_CHECK_AND_RETURN(getNpScene() != NULL, "NpSoftBody::releaseClothAttachment: soft body must be inserted into the scene."); PX_CHECK_AND_RETURN(cloth->getScene() != NULL, "NpSoftBody::releaseClothAttachment: actor must be inserted into the scene."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(getNpScene(), "NpSoftBody::releaseClothAttachment: Illegal to call while simulation is running."); NpFEMCloth* dyn = static_cast<NpFEMCloth*>(cloth); Sc::FEMClothCore* core = &dyn->getCore(); mCore.removeClothAttachment(*core, handle); } #else void NpSoftBody::removeClothAttachment(PxFEMCloth*, PxU32) {} #endif } #endif //PX_SUPPORT_GPU_PHYSX
32,822
C++
42.53183
200
0.754768
NVIDIA-Omniverse/PhysX/physx/source/physx/src/NpFEMClothMaterial.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef NP_FEM_CLOTH_MATERIAL_H #define NP_FEM_CLOTH_MATERIAL_H #include "common/PxSerialFramework.h" #include "foundation/PxUserAllocated.h" #include "foundation/PxUtilities.h" #include "CmRefCountable.h" #include "PxsFEMClothMaterialCore.h" namespace physx { #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION // Compared to other objects, materials are special since they belong to the SDK and not to scenes // (similar to meshes). That's why the NpFEMClothMaterial does have direct access to the core material instead // of having a buffered interface for it. Scenes will have copies of the SDK material table and there // the materials will be buffered. class NpFEMClothMaterial : public PxFEMClothMaterial, public PxUserAllocated { public: // PX_SERIALIZATION NpFEMClothMaterial(PxBaseFlags baseFlags) : PxFEMClothMaterial(baseFlags), mMaterial(PxEmpty) {} virtual void resolveReferences(PxDeserializationContext& context); static NpFEMClothMaterial* createObject(PxU8*& address, PxDeserializationContext& context); static void getBinaryMetaData(PxOutputStream& stream); void preExportDataReset() { Cm::RefCountable_preExportDataReset(*this); } void exportExtraData(PxSerializationContext&) {} void importExtraData(PxDeserializationContext&) {} virtual void requiresObjects(PxProcessPxBaseCallback&) {} //~PX_SERIALIZATION NpFEMClothMaterial(const PxsFEMClothMaterialCore& desc); virtual ~NpFEMClothMaterial(); // PxBase virtual void release() PX_OVERRIDE; //~PxBase // PxRefCounted virtual void acquireReference() PX_OVERRIDE; virtual PxU32 getReferenceCount() const PX_OVERRIDE; virtual void onRefCountZero() PX_OVERRIDE; //~PxRefCounted // PxFEMMaterial virtual void setYoungsModulus(PxReal young) PX_OVERRIDE; virtual PxReal getYoungsModulus() const PX_OVERRIDE; virtual void setPoissons(PxReal poisson) PX_OVERRIDE; virtual PxReal getPoissons() const PX_OVERRIDE; virtual void setDynamicFriction(PxReal threshold) PX_OVERRIDE; virtual PxReal getDynamicFriction() const PX_OVERRIDE; //~PxFEMMaterial // PxFEMClothMaterial virtual void setThickness(PxReal thickness) PX_OVERRIDE; virtual PxReal getThickness() const PX_OVERRIDE; //~PxFEMClothMaterial PX_FORCE_INLINE static void getMaterialIndices(PxFEMClothMaterial*const* materials, PxU16* materialIndices, PxU32 materialCount); private: PX_INLINE void updateMaterial(); // PX_SERIALIZATION public: //~PX_SERIALIZATION PxsFEMClothMaterialCore mMaterial; }; PX_FORCE_INLINE void NpFEMClothMaterial::getMaterialIndices(PxFEMClothMaterial*const* materials, PxU16* materialIndices, PxU32 materialCount) { for (PxU32 i = 0; i < materialCount; i++) materialIndices[i] = static_cast<NpFEMClothMaterial*>(materials[i])->mMaterial.mMaterialIndex; } #endif } #endif
4,630
C
42.280373
142
0.757235
NVIDIA-Omniverse/PhysX/physx/source/physx/src/NpBase.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef NP_BASE_H #define NP_BASE_H #include "foundation/PxUserAllocated.h" #include "NpScene.h" #if PX_SUPPORT_PVD // PT: updatePvdProperties() is overloaded and the compiler needs to know 'this' type to do the right thing. // Thus we can't just move this as an inlined Base function. #define UPDATE_PVD_PROPERTY \ { \ NpScene* scene = getNpScene(); /* shared shapes also return zero here */ \ if(scene) \ scene->getScenePvdClientInternal().updatePvdProperties(this); \ } #else #define UPDATE_PVD_PROPERTY #endif /////////////////////////////////////////////////////////////////////////////// // PT: technically the following macros should all be "NP" macros (they're not exposed to the public API) // but I only renamed the local ones (used in NpBase.h) as "NP", while the other "PX" are used by clients // of these macros in other Np files. The PX_CHECK names are very misleading, since these checks seem to // stay in all builds, contrary to other macros like PX_CHECK_AND_RETURN. /////////////////////////////////////////////////////////////////////////////// #define NP_API_READ_WRITE_ERROR_MSG(text) PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, text) // some API read calls are not allowed while the simulation is running since the properties might get // written to during simulation. Some of those are allowed while collision is running though or in callbacks // like contact modification, contact reports etc. Furthermore, it is ok to read all of them between fetchCollide // and advance. #define NP_API_READ_FORBIDDEN(npScene) (npScene && npScene->isAPIReadForbidden()) #define NP_API_READ_FORBIDDEN_EXCEPT_COLLIDE(npScene) (npScene && npScene->isAPIReadForbidden() && (!npScene->isCollisionPhaseActive())) /////////////////////////////////////////////////////////////////////////////// #define PX_CHECK_SCENE_API_READ_FORBIDDEN(npScene, text) \ if(NP_API_READ_FORBIDDEN(npScene)) \ { \ NP_API_READ_WRITE_ERROR_MSG(text); \ return; \ } #define PX_CHECK_SCENE_API_READ_FORBIDDEN_AND_RETURN_VAL(npScene, text, retValue) \ if(NP_API_READ_FORBIDDEN(npScene)) \ { \ NP_API_READ_WRITE_ERROR_MSG(text); \ return retValue; \ } #define PX_CHECK_SCENE_API_READ_FORBIDDEN_EXCEPT_COLLIDE(npScene, text) \ if(NP_API_READ_FORBIDDEN_EXCEPT_COLLIDE(npScene)) \ { \ NP_API_READ_WRITE_ERROR_MSG(text); \ return; \ } #define PX_CHECK_SCENE_API_READ_FORBIDDEN_EXCEPT_COLLIDE_AND_RETURN_VAL(npScene, text, retValue) \ if(NP_API_READ_FORBIDDEN_EXCEPT_COLLIDE(npScene)) \ { \ NP_API_READ_WRITE_ERROR_MSG(text); \ return retValue; \ } /////////////////////////////////////////////////////////////////////////////// #define NP_API_WRITE_FORBIDDEN(npScene) (npScene && npScene->isAPIWriteForbidden()) // some API write calls are allowed between fetchCollide and advance #define NP_API_WRITE_FORBIDDEN_EXCEPT_SPLIT_SIM(npScene) (npScene && npScene->isAPIWriteForbidden() && (npScene->getSimulationStage() != Sc::SimulationStage::eFETCHCOLLIDE)) /////////////////////////////////////////////////////////////////////////////// #define PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, text) \ if(NP_API_WRITE_FORBIDDEN(npScene)) \ { \ NP_API_READ_WRITE_ERROR_MSG(text); \ return; \ } #define PX_CHECK_SCENE_API_WRITE_FORBIDDEN_AND_RETURN_VAL(npScene, text, retValue) \ if(NP_API_WRITE_FORBIDDEN(npScene)) \ { \ NP_API_READ_WRITE_ERROR_MSG(text); \ return retValue; \ } #define PX_CHECK_SCENE_API_WRITE_FORBIDDEN_EXCEPT_SPLIT_SIM(npScene, text) \ if(NP_API_WRITE_FORBIDDEN_EXCEPT_SPLIT_SIM(npScene)) \ { \ NP_API_READ_WRITE_ERROR_MSG(text); \ return; \ } /////////////////////////////////////////////////////////////////////////////// #define NP_UNUSED_BASE_INDEX 0x07ffffff #define NP_BASE_INDEX_MASK 0x07ffffff #define NP_BASE_INDEX_SHIFT 27 namespace physx { struct NpType { enum Enum { eUNDEFINED, eSHAPE, eBODY, eBODY_FROM_ARTICULATION_LINK, eRIGID_STATIC, eCONSTRAINT, eARTICULATION, eARTICULATION_JOINT, eARTICULATION_SENSOR, eARTICULATION_SPATIAL_TENDON, eARTICULATION_ATTACHMENT, eARTICULATION_FIXED_TENDON, eARTICULATION_TENDON_JOINT, eAGGREGATE, eSOFTBODY, eFEMCLOTH, ePBD_PARTICLESYSTEM, eFLIP_PARTICLESYSTEM, eMPM_PARTICLESYSTEM, eHAIRSYSTEM, eTYPE_COUNT, eFORCE_DWORD = 0x7fffffff }; }; // PT: we're going to store that type on 5 bits, leaving 27 bits for the base index. PX_COMPILE_TIME_ASSERT(NpType::eTYPE_COUNT<32); class NpBase : public PxUserAllocated { PX_NOCOPY(NpBase) public: // PX_SERIALIZATION NpBase(const PxEMPTY) : mScene (NULL), mFreeSlot (0) { // PT: preserve type, reset base index setBaseIndex(NP_UNUSED_BASE_INDEX); } static void getBinaryMetaData(PxOutputStream& stream); //~PX_SERIALIZATION NpBase(NpType::Enum type) : mScene (NULL), mFreeSlot (0) { mBaseIndexAndType = (PxU32(type)<<NP_BASE_INDEX_SHIFT)|NP_UNUSED_BASE_INDEX; } PX_INLINE bool isAPIWriteForbidden() const { return NP_API_WRITE_FORBIDDEN(mScene); } PX_INLINE bool isAPIWriteForbiddenExceptSplitSim() const { return NP_API_WRITE_FORBIDDEN_EXCEPT_SPLIT_SIM(mScene); } PX_FORCE_INLINE NpType::Enum getNpType() const { return NpType::Enum(mBaseIndexAndType>>NP_BASE_INDEX_SHIFT); } PX_FORCE_INLINE void setNpScene(NpScene* scene) { mScene = scene; } PX_FORCE_INLINE NpScene* getNpScene() const { return mScene; } PX_FORCE_INLINE PxU32 getBaseIndex() const { return mBaseIndexAndType & NP_BASE_INDEX_MASK; } PX_FORCE_INLINE void setBaseIndex(PxU32 index) { PX_ASSERT(!(index & ~NP_BASE_INDEX_MASK)); const PxU32 type = mBaseIndexAndType & ~NP_BASE_INDEX_MASK; mBaseIndexAndType = index|type; } protected: ~NpBase(){} private: NpScene* mScene; PxU32 mBaseIndexAndType; protected: PxU32 mFreeSlot; }; } #endif
8,183
C
37.78673
173
0.633264
NVIDIA-Omniverse/PhysX/physx/source/physx/src/NpRigidStatic.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #include "NpRigidStatic.h" #include "NpRigidActorTemplateInternal.h" #include "omnipvd/NpOmniPvdSetData.h" using namespace physx; NpRigidStatic::NpRigidStatic(const PxTransform& pose) : NpRigidStaticT (PxConcreteType::eRIGID_STATIC, PxBaseFlag::eOWNS_MEMORY | PxBaseFlag::eIS_RELEASABLE, NpType::eRIGID_STATIC), mCore (pose) { } NpRigidStatic::~NpRigidStatic() { } // PX_SERIALIZATION void NpRigidStatic::requiresObjects(PxProcessPxBaseCallback& c) { NpRigidStaticT::requiresObjects(c); } NpRigidStatic* NpRigidStatic::createObject(PxU8*& address, PxDeserializationContext& context) { NpRigidStatic* obj = PX_PLACEMENT_NEW(address, NpRigidStatic(PxBaseFlag::eIS_RELEASABLE)); address += sizeof(NpRigidStatic); obj->importExtraData(context); obj->resolveReferences(context); return obj; } //~PX_SERIALIZATION void NpRigidStatic::release() { if(releaseRigidActorT<PxRigidStatic>(*this)) { PX_ASSERT(!isAPIWriteForbidden()); // the code above should return false in that case NpDestroyRigidActor(this); } } void NpRigidStatic::setGlobalPose(const PxTransform& pose, bool /*wake*/) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_AND_RETURN(pose.isSane(), "PxRigidStatic::setGlobalPose: pose is not valid."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxRigidStatic::setGlobalPose() not allowed while simulation is running. Call will be ignored.") #if PX_CHECKED if(npScene) npScene->checkPositionSanity(*this, pose, "PxRigidStatic::setGlobalPose"); #endif const PxTransform newPose = pose.getNormalized(); //AM: added to fix 1461 where users read and write orientations for no reason. mCore.setActor2World(newPose); UPDATE_PVD_PROPERTY OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxRigidActor, translation, *static_cast<PxRigidActor*>(this), newPose.p); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxRigidActor, rotation, *static_cast<PxRigidActor*>(this), newPose.q); OMNI_PVD_WRITE_SCOPE_END if(npScene) mShapeManager.markActorForSQUpdate(npScene->getSQAPI(), *this); // invalidate the pruning structure if the actor bounds changed if(mShapeManager.getPruningStructure()) { PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "PxRigidStatic::setGlobalPose: Actor is part of a pruning structure, pruning structure is now invalid!"); mShapeManager.getPruningStructure()->invalidate(this); } updateShaderComs(); } PxTransform NpRigidStatic::getGlobalPose() const { NP_READ_CHECK(getNpScene()); return mCore.getActor2World(); } PxU32 physx::NpRigidStaticGetShapes(NpRigidStatic& rigid, NpShape* const *&shapes) { NpShapeManager& sm = rigid.getShapeManager(); shapes = sm.getShapes(); return sm.getNbShapes(); } void NpRigidStatic::switchToNoSim() { NpActor::scSwitchToNoSim(); } void NpRigidStatic::switchFromNoSim() { NpActor::scSwitchFromNoSim(); } #if PX_CHECKED bool NpRigidStatic::checkConstraintValidity() const { // Perhaps NpConnectorConstIterator would be worth it... NpConnectorIterator iter = (const_cast<NpRigidStatic*>(this))->getConnectorIterator(NpConnectorType::eConstraint); while (PxBase* ser = iter.getNext()) { NpConstraint* c = static_cast<NpConstraint*>(ser); if(!c->NpConstraint::isValid()) return false; } return true; } #endif
5,070
C++
34.215278
171
0.765286
NVIDIA-Omniverse/PhysX/physx/source/physx/src/NpRigidDynamic.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef NP_RIGID_DYNAMIC_H #define NP_RIGID_DYNAMIC_H #include "common/PxMetaData.h" #include "PxRigidDynamic.h" #include "NpRigidBodyTemplate.h" namespace physx { typedef NpRigidBodyTemplate<PxRigidDynamic> NpRigidDynamicT; class NpRigidDynamic : public NpRigidDynamicT { public: // PX_SERIALIZATION NpRigidDynamic(PxBaseFlags baseFlags) : NpRigidDynamicT(baseFlags) {} void preExportDataReset(); virtual void requiresObjects(PxProcessPxBaseCallback& c); static NpRigidDynamic* createObject(PxU8*& address, PxDeserializationContext& context); static void getBinaryMetaData(PxOutputStream& stream); //~PX_SERIALIZATION virtual ~NpRigidDynamic(); //--------------------------------------------------------------------------------- // PxActor implementation //--------------------------------------------------------------------------------- virtual void release() PX_OVERRIDE; //--------------------------------------------------------------------------------- // PxRigidDynamic implementation //--------------------------------------------------------------------------------- virtual PxActorType::Enum getType() const PX_OVERRIDE { return PxActorType::eRIGID_DYNAMIC; } // Pose virtual void setGlobalPose(const PxTransform& pose, bool autowake) PX_OVERRIDE; PX_FORCE_INLINE PxTransform getGlobalPoseFast() const { const Sc::BodyCore& body = getCore(); // PT:: tag: scalar transform*transform return body.getBody2World() * body.getBody2Actor().getInverse(); } virtual PxTransform getGlobalPose() const PX_OVERRIDE { NP_READ_CHECK(getNpScene()); PX_CHECK_SCENE_API_READ_FORBIDDEN_EXCEPT_COLLIDE_AND_RETURN_VAL(getNpScene(), "PxRigidDynamic::getGlobalPose() not allowed while simulation is running (except during PxScene::collide()).", PxTransform(PxIdentity)); return getGlobalPoseFast(); } virtual void setKinematicTarget(const PxTransform& destination) PX_OVERRIDE; virtual bool getKinematicTarget(PxTransform& target) const PX_OVERRIDE; // Center of mass pose virtual void setCMassLocalPose(const PxTransform&) PX_OVERRIDE; // Velocity virtual void setLinearVelocity(const PxVec3&, bool autowake) PX_OVERRIDE; virtual void setAngularVelocity(const PxVec3&, bool autowake) PX_OVERRIDE; // Force/Torque modifiers virtual void addForce(const PxVec3&, PxForceMode::Enum mode, bool autowake) PX_OVERRIDE; virtual void clearForce(PxForceMode::Enum mode) PX_OVERRIDE; virtual void addTorque(const PxVec3&, PxForceMode::Enum mode, bool autowake) PX_OVERRIDE; virtual void clearTorque(PxForceMode::Enum mode) PX_OVERRIDE; virtual void setForceAndTorque(const PxVec3& force, const PxVec3& torque, PxForceMode::Enum mode = PxForceMode::eFORCE) PX_OVERRIDE; // Sleeping virtual bool isSleeping() const PX_OVERRIDE; virtual PxReal getSleepThreshold() const PX_OVERRIDE; virtual void setSleepThreshold(PxReal threshold) PX_OVERRIDE; virtual PxReal getStabilizationThreshold() const PX_OVERRIDE; virtual void setStabilizationThreshold(PxReal threshold) PX_OVERRIDE; virtual void setWakeCounter(PxReal wakeCounterValue) PX_OVERRIDE; virtual PxReal getWakeCounter() const PX_OVERRIDE; virtual void wakeUp() PX_OVERRIDE; virtual void putToSleep() PX_OVERRIDE; virtual void setSolverIterationCounts(PxU32 positionIters, PxU32 velocityIters) PX_OVERRIDE; virtual void getSolverIterationCounts(PxU32 & positionIters, PxU32 & velocityIters) const PX_OVERRIDE; virtual void setContactReportThreshold(PxReal threshold) PX_OVERRIDE; virtual PxReal getContactReportThreshold() const PX_OVERRIDE; virtual PxRigidDynamicLockFlags getRigidDynamicLockFlags() const PX_OVERRIDE; virtual void setRigidDynamicLockFlags(PxRigidDynamicLockFlags flags) PX_OVERRIDE; virtual void setRigidDynamicLockFlag(PxRigidDynamicLockFlag::Enum flag, bool value) PX_OVERRIDE; //--------------------------------------------------------------------------------- // Miscellaneous //--------------------------------------------------------------------------------- NpRigidDynamic(const PxTransform& bodyPose); virtual void switchToNoSim() PX_OVERRIDE; virtual void switchFromNoSim() PX_OVERRIDE; PX_FORCE_INLINE void wakeUpInternal(); void wakeUpInternalNoKinematicTest(bool forceWakeUp, bool autowake); static PX_FORCE_INLINE size_t getCoreOffset() { return PX_OFFSET_OF_RT(NpRigidDynamic, mCore); } static PX_FORCE_INLINE size_t getNpShapeManagerOffset() { return PX_OFFSET_OF_RT(NpRigidDynamic, mShapeManager); } #if PX_CHECKED PX_FORCE_INLINE bool checkConstraintValidity() const { return true; } #endif private: PX_FORCE_INLINE void setKinematicTargetInternal(const PxTransform& destination); #if PX_ENABLE_DEBUG_VISUALIZATION public: void visualize(PxRenderOutput& out, NpScene& scene, float scale) const; #else PX_CATCH_UNDEFINED_ENABLE_DEBUG_VISUALIZATION #endif }; PX_FORCE_INLINE void NpRigidDynamic::wakeUpInternal() { PX_ASSERT(getNpScene()); const Sc::BodyCore& body = getCore(); const PxRigidBodyFlags currentFlags = body.getFlags(); if (!(currentFlags & PxRigidBodyFlag::eKINEMATIC)) // kinematics are only awake when a target is set, else they are asleep wakeUpInternalNoKinematicTest(false, true); } } #endif
7,078
C
41.90303
216
0.709381
NVIDIA-Omniverse/PhysX/physx/source/physx/src/NpParticleSystem.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef NP_PARTICLE_SYSTEM_H #define NP_PARTICLE_SYSTEM_H #include "foundation/PxBounds3.h" #include "foundation/PxErrors.h" #include "foundation/PxSimpleTypes.h" #include "foundation/PxUserAllocated.h" #include "foundation/PxVec3.h" #include "common/PxBase.h" #include "common/PxRenderOutput.h" #include "PxActor.h" #include "PxFiltering.h" #include "PxParticleBuffer.h" //#include "PxParticlePhase.h" #include "PxParticleSolverType.h" #include "PxParticleSystem.h" #include "PxPBDParticleSystem.h" #include "PxPBDMaterial.h" #include "PxSceneDesc.h" #include "PxSparseGridParams.h" #include "DyParticleSystem.h" #include "NpActor.h" #include "NpActorTemplate.h" #include "NpBase.h" #include "NpMaterialManager.h" #include "NpPhysics.h" #include "ScParticleSystemSim.h" #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION #include "PxFLIPParticleSystem.h" #include "PxFLIPMaterial.h" #include "PxMPMParticleSystem.h" #include "PxMPMMaterial.h" #endif namespace physx { class NpScene; class PxCudaContextManager; class PxParticleMaterial; class PxRigidActor; class PxSerializationContext; namespace Sc { class ParticleSystemSim; } template<class APIClass> class NpParticleSystem : public NpActorTemplate<APIClass> { public: NpParticleSystem(PxCudaContextManager& contextManager, PxType concreteType, NpType::Enum npType, PxActorType::Enum actorType) : NpActorTemplate<APIClass>(concreteType, PxBaseFlag::eOWNS_MEMORY | PxBaseFlag::eIS_RELEASABLE, npType), mCore(actorType), mCudaContextManager(&contextManager), mNextPhaseGroupID(0) { } NpParticleSystem(PxBaseFlags baseFlags) : NpActorTemplate<APIClass>(baseFlags) {} virtual ~NpParticleSystem() { //TODO!!!!! Do this correctly //sParticleSystemIdPool.tryRemoveID(mID); } virtual void exportData(PxSerializationContext& /*context*/) const {} //external API virtual PxBounds3 getWorldBounds(float inflation = 1.01f) const { NP_READ_CHECK(NpBase::getNpScene()); if (!NpBase::getNpScene()) { PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "Querying bounds of a PxParticleSystem which is not part of a PxScene is not supported."); return PxBounds3::empty(); } const Sc::ParticleSystemSim* sim = mCore.getSim(); PX_ASSERT(sim); PX_SIMD_GUARD; PxBounds3 bounds = sim->getBounds(); PX_ASSERT(bounds.isValid()); // PT: unfortunately we can't just scale the min/max vectors, we need to go through center/extents. const PxVec3 center = bounds.getCenter(); const PxVec3 inflatedExtents = bounds.getExtents() * inflation; return PxBounds3::centerExtents(center, inflatedExtents); } virtual void setSolverIterationCounts(PxU32 minPositionIters, PxU32 minVelocityIters = 1) { NpScene* npScene = NpBase::getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_AND_RETURN(minPositionIters > 0, "NpParticleSystem::setSolverIterationCounts: positionIters must be more than zero!"); PX_CHECK_AND_RETURN(minPositionIters <= 255, "NpParticleSystem::setSolverIterationCounts: positionIters must be no greater than 255!"); PX_CHECK_AND_RETURN(minVelocityIters <= 255, "NpParticleSystem::setSolverIterationCounts: velocityIters must be no greater than 255!"); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxParticleSystem::setSolverIterationCounts() not allowed while simulation is running. Call will be ignored.") mCore.setSolverIterationCounts((minVelocityIters & 0xff) << 8 | (minPositionIters & 0xff)); //UPDATE_PVD_PROPERTY } virtual void getSolverIterationCounts(PxU32& minPositionIters, PxU32& minVelocityIters) const { NP_READ_CHECK(NpBase::getNpScene()); PxU16 x = mCore.getSolverIterationCounts(); minVelocityIters = PxU32(x >> 8); minPositionIters = PxU32(x & 0xff); } virtual PxCudaContextManager* getCudaContextManager() const { return mCudaContextManager; } virtual void setRestOffset(PxReal restOffset) { scSetRestOffset(restOffset); } virtual PxReal getRestOffset() const { return mCore.getRestOffset(); } virtual void setContactOffset(PxReal contactOffset) { scSetContactOffset(contactOffset); } virtual PxReal getContactOffset() const { return mCore.getContactOffset(); } virtual void setParticleContactOffset(PxReal particleContactOffset) { scSetParticleContactOffset(particleContactOffset); } virtual PxReal getParticleContactOffset() const { return mCore.getParticleContactOffset(); } virtual void setSolidRestOffset(PxReal solidRestOffset) { scSetSolidRestOffset(solidRestOffset); } virtual PxReal getSolidRestOffset() const { return mCore.getSolidRestOffset(); } virtual void setMaxDepenetrationVelocity(PxReal v) {scSetMaxDepenetrationVelocity(v); } virtual PxReal getMaxDepenetrationVelocity(){ return mCore.getMaxDepenetrationVelocity(); } virtual void setMaxVelocity(PxReal v) { scSetMaxVelocity(v); } virtual PxReal getMaxVelocity() { return mCore.getMaxVelocity(); } virtual void setParticleSystemCallback(PxParticleSystemCallback* callback) { mCore.setParticleSystemCallback(callback); } virtual PxParticleSystemCallback* getParticleSystemCallback() const { return mCore.getParticleSystemCallback(); } // TOFIX virtual void enableCCD(bool enable) { scSnableCCD(enable); } virtual PxU32 createPhase(PxParticleMaterial* material, PxParticlePhaseFlags flags) = 0; virtual PxFilterData getSimulationFilterData() const { return mCore.getShapeCore().getSimulationFilterData(); } virtual void setSimulationFilterData(const PxFilterData& data) { mCore.getShapeCore().setSimulationFilterData(data); } virtual void setParticleFlag(PxParticleFlag::Enum flag, bool val) { PxParticleFlags flags = mCore.getFlags(); if (val) flags.raise(flag); else flags.clear(flag); mCore.setFlags(flags); scSetDirtyFlag(); } virtual void setParticleFlags(PxParticleFlags flags) { mCore.setFlags(flags); scSetDirtyFlag(); } virtual PxParticleFlags getParticleFlags() const { return mCore.getFlags(); } void setSolverType(const PxParticleSolverType::Enum solverType) { scSetSolverType(solverType); } virtual PxParticleSolverType::Enum getSolverType() const { return mCore.getSolverType(); } virtual PxU32 getNbParticleMaterials() const { const Sc::ParticleSystemShapeCore& shapeCore = mCore.getShapeCore(); const Dy::ParticleSystemCore& core = shapeCore.getLLCore(); return core.mUniqueMaterialHandles.size(); } virtual PxU32 getParticleMaterials(PxParticleMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex = 0) const = 0; virtual void addParticleBuffer(PxParticleBuffer* userBuffer) = 0; virtual void removeParticleBuffer(PxParticleBuffer* userBuffer) = 0; virtual PxU32 getGpuParticleSystemIndex() { NP_READ_CHECK(NpBase::getNpScene()); PX_CHECK_AND_RETURN_VAL(NpBase::getNpScene(), "NpParticleSystem::getGpuParticleSystemIndex: particle system must be in a scene.", 0xffffffff); if (NpBase::getNpScene()->getFlags() & PxSceneFlag::eENABLE_DIRECT_GPU_API) return mCore.getSim()->getLowLevelParticleSystem()->getGpuRemapId(); return 0xffffffff; } PX_FORCE_INLINE const Sc::ParticleSystemCore& getCore() const { return mCore; } PX_FORCE_INLINE Sc::ParticleSystemCore& getCore() { return mCore; } static PX_FORCE_INLINE size_t getCoreOffset() { return PX_OFFSET_OF_RT(NpParticleSystem, mCore); } PX_INLINE void scSetDirtyFlag() { NP_READ_CHECK(NpBase::getNpScene()); NpScene* scene = NpBase::getNpScene(); if (scene) { mCore.getSim()->getLowLevelParticleSystem()->mFlag |= Dy::ParticleSystemFlag::eUPDATE_PARAMS; } } PX_INLINE void scSetSleepThreshold(const PxReal v) { PX_ASSERT(!NpBase::isAPIWriteForbidden()); mCore.setSleepThreshold(v); //UPDATE_PVD_PROPERTY } PX_INLINE void scSetRestOffset(const PxReal v) { PX_ASSERT(!NpBase::isAPIWriteForbidden()); mCore.setRestOffset(v); scSetDirtyFlag(); //UPDATE_PVD_PROPERTY } PX_INLINE void scSetContactOffset(const PxReal v) { PX_ASSERT(!NpBase::isAPIWriteForbidden()); mCore.setContactOffset(v); scSetDirtyFlag(); //UPDATE_PVD_PROPERTY } PX_INLINE void scSetParticleContactOffset(const PxReal v) { PX_ASSERT(!NpBase::isAPIWriteForbidden()); mCore.setParticleContactOffset(v); scSetDirtyFlag(); //UPDATE_PVD_PROPERTY } PX_INLINE void scSetSolidRestOffset(const PxReal v) { PX_ASSERT(!NpBase::isAPIWriteForbidden()); mCore.setSolidRestOffset(v); scSetDirtyFlag(); //UPDATE_PVD_PROPERTY } PX_INLINE void scSetFluidRestOffset(const PxReal v) { PX_ASSERT(!NpBase::isAPIWriteForbidden()); mCore.setFluidRestOffset(v); scSetDirtyFlag(); //UPDATE_PVD_PROPERTY } PX_INLINE void scSetGridSizeX(const PxU32 v) { PX_ASSERT(!NpBase::isAPIWriteForbidden()); mCore.setGridSizeX(v); //UPDATE_PVD_PROPERTY } PX_INLINE void scSetGridSizeY(const PxU32 v) { PX_ASSERT(!NpBase::isAPIWriteForbidden()); mCore.setGridSizeY(v); //UPDATE_PVD_PROPERTY } PX_INLINE void scSetGridSizeZ(const PxU32 v) { PX_ASSERT(!NpBase::isAPIWriteForbidden()); mCore.setGridSizeZ(v); //UPDATE_PVD_PROPERTY } PX_INLINE void scSnableCCD(const bool enable) { PX_ASSERT(!NpBase::isAPIWriteForbidden()); mCore.enableCCD(enable); scSetDirtyFlag(); //UPDATE_PVD_PROPERTY } PX_INLINE void scSetWind(const PxVec3& v) { PX_ASSERT(!NpBase::isAPIWriteForbidden()); mCore.setWind(v); scSetDirtyFlag(); //UPDATE_PVD_PROPERTY } PX_INLINE void scSetMaxDepenetrationVelocity(const PxReal v) { PX_CHECK_AND_RETURN(v > 0.f, "PxParticleSystem::setMaxDepenetrationVelocity: Max Depenetration Velocity must be > 0!"); PX_ASSERT(!NpBase::isAPIWriteForbidden()); mCore.setMaxDepenetrationVelocity(v); scSetDirtyFlag(); //UPDATE_PVD_PROPERTY } PX_INLINE void scSetMaxVelocity(const PxReal v) { PX_CHECK_AND_RETURN(v > 0.f, "PxParticleSystem::setMaxVelocity: Max Velocity must be > 0!"); PX_ASSERT(!NpBase::isAPIWriteForbidden()); mCore.setMaxVelocity(v); scSetDirtyFlag(); //UPDATE_PVD_PROPERTY } PX_INLINE void scSetSolverType(const PxParticleSolverType::Enum solverType) { PX_ASSERT(!NpBase::isAPIWriteForbidden()); mCore.setSolverType(solverType); //UPDATE_PVD_PROPERTY } #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION PX_INLINE void scSetSparseGridParams(const PxSparseGridParams& params) { PX_CHECK_AND_RETURN(params.subgridSizeX > 1 && params.subgridSizeX % 2 == 0, "PxParticleSystem::setSparseGridParams: Sparse grid subgridSizeX must be > 1 and even number!"); PX_CHECK_AND_RETURN(params.subgridSizeY > 1 && params.subgridSizeY % 2 == 0, "PxParticleSystem::setSparseGridParams: Sparse grid subgridSizeY must be > 1 and even number!"); PX_CHECK_AND_RETURN(params.subgridSizeZ > 1 && params.subgridSizeZ % 2 == 0, "PxParticleSystem::setSparseGridParams: Sparse grid subgridSizeZ must be > 1 and even number!"); PX_ASSERT(!NpBase::isAPIWriteForbidden()); mCore.setSparseGridParams(params); //UPDATE_PVD_PROPERTY } #endif #if PX_ENABLE_DEBUG_VISUALIZATION virtual void visualize(PxRenderOutput& out, NpScene& npScene) const = 0; #else PX_CATCH_UNDEFINED_ENABLE_DEBUG_VISUALIZATION #endif // Debug name void setName(const char* debugName) { NP_WRITE_CHECK(NpBase::getNpScene()); NpActor::mName = debugName; } const char* getName() const { NP_READ_CHECK(NpBase::getNpScene()); return NpActor::mName; } virtual void setGridSizeX(PxU32 gridSizeX) { scSetGridSizeX(gridSizeX); } virtual void setGridSizeY(PxU32 gridSizeY) { scSetGridSizeY(gridSizeY); } virtual void setGridSizeZ(PxU32 gridSizeZ) { scSetGridSizeZ(gridSizeZ); } template<typename ParticleMaterialType> PxU32 getParticleMaterialsInternal(PxParticleMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex = 0) const { const Sc::ParticleSystemShapeCore& shapeCore = mCore.getShapeCore(); const Dy::ParticleSystemCore& core = shapeCore.getLLCore(); NpMaterialManager<ParticleMaterialType>& matManager = NpMaterialAccessor<ParticleMaterialType>::getMaterialManager(NpPhysics::getInstance()); PxU32 size = core.mUniqueMaterialHandles.size(); const PxU32 remainder = PxU32(PxMax<PxI32>(PxI32(size - startIndex), 0)); const PxU32 writeCount = PxMin(remainder, bufferSize); for(PxU32 i = 0; i < writeCount; i++) { userBuffer[i] = matManager.getMaterial(core.mUniqueMaterialHandles[startIndex + i]); } return writeCount; } protected: Sc::ParticleSystemCore mCore; PxCudaContextManager* mCudaContextManager; PxU32 mNextPhaseGroupID; }; class NpParticleClothPreProcessor : public PxParticleClothPreProcessor, public PxUserAllocated { public: NpParticleClothPreProcessor(PxCudaContextManager* cudaContextManager) : mCudaContextManager(cudaContextManager), mNbPartitions(0){} virtual ~NpParticleClothPreProcessor() {} virtual void release(); virtual void partitionSprings(const PxParticleClothDesc& clothDesc, PxPartitionedParticleCloth& output) PX_OVERRIDE; private: PxU32 computeSpringPartition(const PxParticleSpring& springs, const PxU32 partitionStartIndex, PxU32* partitionProgresses); PxU32* partitions(const PxParticleSpring* springs, PxU32* orderedSpringIndices); PxU32 combinePartitions(const PxParticleSpring* springs, const PxU32* orderedSpringIndices, const PxU32* accumulatedSpringsPerPartition, PxU32* accumulatedSpringsPerCombinedPartitions, PxParticleSpring* orderedSprings, PxU32* accumulatedCopiesPerParticles, PxU32* remapOutput); void classifySprings(const PxParticleSpring* springs, PxU32* partitionProgresses, PxU32* tempSprings, physx::PxArray<PxU32>& springsPerPartition); void writeSprings(const PxParticleSpring* springs, PxU32* partitionProgresses, PxU32* tempSprings, PxU32* orderedSprings, PxU32* accumulatedSpringsPerPartition); PxCudaContextManager* mCudaContextManager; PxU32 mNumSprings; PxU32 mNbPartitions; PxU32 mNumParticles; PxU32 mMaxSpringsPerPartition; }; class NpPBDParticleSystem : public NpParticleSystem<PxPBDParticleSystem> { public: NpPBDParticleSystem(PxU32 maxNeighborhood, PxCudaContextManager& contextManager); virtual ~NpPBDParticleSystem(){} virtual PxU32 createPhase(PxParticleMaterial* material, PxParticlePhaseFlags flags) PX_OVERRIDE; virtual void release(); virtual void setWind(const PxVec3& wind) { scSetWind(wind); } virtual PxVec3 getWind() const { return mCore.getWind(); } virtual void setFluidBoundaryDensityScale(PxReal fluidBoundaryDensityScale) { scSetFluidBoundaryDensityScale(fluidBoundaryDensityScale); } virtual PxReal getFluidBoundaryDensityScale() const { return mCore.getFluidBoundaryDensityScale(); } virtual void setFluidRestOffset(PxReal fluidRestOffset) { scSetFluidRestOffset(fluidRestOffset); } virtual PxReal getFluidRestOffset() const { return mCore.getFluidRestOffset(); } #if PX_ENABLE_DEBUG_VISUALIZATION virtual void visualize(PxRenderOutput& out, NpScene& npScene) const; #else PX_CATCH_UNDEFINED_ENABLE_DEBUG_VISUALIZATION #endif //external API virtual PxActorType::Enum getType() const { return PxActorType::ePBD_PARTICLESYSTEM; } virtual PxU32 getParticleMaterials(PxParticleMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex) const PX_OVERRIDE; virtual void addParticleBuffer(PxParticleBuffer* particleBuffer); virtual void removeParticleBuffer(PxParticleBuffer* particleBuffer); virtual void addRigidAttachment(PxRigidActor* actor); virtual void removeRigidAttachment(PxRigidActor* actor); private: PX_FORCE_INLINE void scSetFluidBoundaryDensityScale(const PxReal v) { PX_ASSERT(!NpBase::isAPIWriteForbidden()); mCore.setFluidBoundaryDensityScale(v); scSetDirtyFlag(); //UPDATE_PVD_PROPERTY } }; #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION class NpFLIPParticleSystem : public NpParticleSystem<PxFLIPParticleSystem> { public: NpFLIPParticleSystem(PxCudaContextManager& contextManager); virtual ~NpFLIPParticleSystem() {} virtual PxU32 createPhase(PxParticleMaterial* material, PxParticlePhaseFlags flags) PX_OVERRIDE; virtual void release(); virtual void setSparseGridParams(const PxSparseGridParams& params) { scSetSparseGridParams(params); } virtual PxSparseGridParams getSparseGridParams() const { return mCore.getSparseGridParams(); } virtual void* getSparseGridDataPointer(PxSparseGridDataFlag::Enum flags); virtual void getSparseGridCoord(PxI32& x, PxI32& y, PxI32& z, PxU32 id); virtual void setFLIPParams(const PxFLIPParams& params) { scSetFLIPParams(params); } virtual PxFLIPParams getFLIPParams() const { return mCore.getFLIPParams(); } #if PX_ENABLE_DEBUG_VISUALIZATION virtual void visualize(PxRenderOutput& out, NpScene& npScene) const; #else PX_CATCH_UNDEFINED_ENABLE_DEBUG_VISUALIZATION #endif virtual PxU32 getParticleMaterials(PxParticleMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex) const PX_OVERRIDE; virtual void addParticleBuffer(PxParticleBuffer* particleBuffer); virtual void removeParticleBuffer(PxParticleBuffer* particleBuffer); virtual void addRigidAttachment(PxRigidActor* /*actor*/) {} virtual void removeRigidAttachment(PxRigidActor* /*actor*/) {} //external API virtual PxActorType::Enum getType() const { return PxActorType::eFLIP_PARTICLESYSTEM; } private: PX_FORCE_INLINE void scSetFLIPParams(const PxFLIPParams& params) { PX_CHECK_AND_RETURN(params.blendingFactor >= 0.f && params.blendingFactor <= 1.f, "PxParticleSystem::setFLIPParams: FLIP blending factor must be >= 0 and <= 1!"); PX_ASSERT(!isAPIWriteForbidden()); mCore.setFLIPParams(params); //UPDATE_PVD_PROPERTY } }; class NpMPMParticleSystem :public NpParticleSystem<PxMPMParticleSystem> { public: NpMPMParticleSystem(PxCudaContextManager& contextManager); virtual ~NpMPMParticleSystem() {} virtual PxU32 createPhase(PxParticleMaterial* material, PxParticlePhaseFlags flags) PX_OVERRIDE; virtual void release(); virtual void setSparseGridParams(const PxSparseGridParams& params) { scSetSparseGridParams(params); } virtual PxSparseGridParams getSparseGridParams() const { return mCore.getSparseGridParams(); } virtual void* getSparseGridDataPointer(PxSparseGridDataFlag::Enum flags); virtual void getSparseGridCoord(PxI32& x, PxI32& y, PxI32& z, PxU32 id); virtual void setMPMParams(const PxMPMParams& params) { scSetMPMParams(params); } virtual PxMPMParams getMPMParams() const { return mCore.getMPMParams(); } virtual void* getMPMDataPointer(PxMPMParticleDataFlag::Enum flags); #if PX_ENABLE_DEBUG_VISUALIZATION virtual void visualize(PxRenderOutput& out, NpScene& npScene) const; #else PX_CATCH_UNDEFINED_ENABLE_DEBUG_VISUALIZATION #endif virtual PxU32 getParticleMaterials(PxParticleMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex) const PX_OVERRIDE; virtual void addParticleBuffer(PxParticleBuffer* particleBuffer); virtual void removeParticleBuffer(PxParticleBuffer* particleBuffer); virtual void addRigidAttachment(PxRigidActor* actor); virtual void removeRigidAttachment(PxRigidActor* actor); //external API virtual PxActorType::Enum getType() const { return PxActorType::eMPM_PARTICLESYSTEM; } private: PX_INLINE void scSetMPMParams(const PxMPMParams& params) { mCore.setMPMParams(params); //UPDATE_PVD_PROPERTY } }; #endif } #endif
21,537
C
34.19281
176
0.750569
NVIDIA-Omniverse/PhysX/physx/source/physx/src/NpShape.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #include "NpShape.h" #include "NpCheck.h" #include "NpRigidStatic.h" #include "NpRigidDynamic.h" #include "NpArticulationLink.h" #include "GuConvexMesh.h" #include "GuTriangleMesh.h" #include "GuTetrahedronMesh.h" #include "GuBounds.h" #include "NpFEMCloth.h" #include "NpSoftBody.h" #include "omnipvd/NpOmniPvdSetData.h" using namespace physx; using namespace Sq; using namespace Cm; /////////////////////////////////////////////////////////////////////////////// PX_IMPLEMENT_OUTPUT_ERROR /////////////////////////////////////////////////////////////////////////////// // PT: we're using mFreeSlot as a replacement for previous mExclusiveAndActorCount static PX_FORCE_INLINE void increaseActorCount(PxU32* count) { volatile PxI32* val = reinterpret_cast<volatile PxI32*>(count); PxAtomicIncrement(val); } static PX_FORCE_INLINE void decreaseActorCount(PxU32* count) { volatile PxI32* val = reinterpret_cast<volatile PxI32*>(count); PxAtomicDecrement(val); } NpShape::NpShape(const PxGeometry& geometry, PxShapeFlags shapeFlags, const PxU16* materialIndices, PxU16 materialCount, bool isExclusive, PxShapeCoreFlag::Enum flag) : PxShape (PxConcreteType::eSHAPE, PxBaseFlag::eOWNS_MEMORY | PxBaseFlag::eIS_RELEASABLE), NpBase (NpType::eSHAPE), mExclusiveShapeActor (NULL), mCore (geometry, shapeFlags, materialIndices, materialCount, isExclusive, flag) { //actor count mFreeSlot = 0; PX_ASSERT(mCore.getPxShape() == static_cast<PxShape*>(this)); PX_ASSERT(!PxShape::userData); mCore.mName = NULL; incMeshRefCount(); } NpShape::~NpShape() { decMeshRefCount(); const PxU32 nbMaterials = scGetNbMaterials(); PxShapeCoreFlags flags = mCore.getCore().mShapeCoreFlags; if (flags & PxShapeCoreFlag::eCLOTH_SHAPE) { #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION && PX_SUPPORT_GPU_PHYSX for (PxU32 i = 0; i < nbMaterials; i++) RefCountable_decRefCount(*scGetMaterial<NpFEMClothMaterial>(i)); #endif } else if(flags & PxShapeCoreFlag::eSOFT_BODY_SHAPE) { #if PX_SUPPORT_GPU_PHYSX for (PxU32 i = 0; i < nbMaterials; i++) RefCountable_decRefCount(*scGetMaterial<NpFEMSoftBodyMaterial>(i)); #endif } else { for (PxU32 i = 0; i < nbMaterials; i++) RefCountable_decRefCount(*scGetMaterial<NpMaterial>(i)); } } void NpShape::onRefCountZero() { NpFactory::getInstance().onShapeRelease(this); // see NpShape.h for ref counting semantics for shapes NpDestroyShape(this); } // PX_SERIALIZATION NpShape::NpShape(PxBaseFlags baseFlags) : PxShape(baseFlags), NpBase(PxEmpty), mCore(PxEmpty), mQueryFilterData(PxEmpty) { } void NpShape::preExportDataReset() { RefCountable_preExportDataReset(*this); mExclusiveShapeActor = NULL; mFreeSlot = 0; } void NpShape::exportExtraData(PxSerializationContext& context) { mCore.exportExtraData(context); context.writeName(mCore.mName); } void NpShape::importExtraData(PxDeserializationContext& context) { mCore.importExtraData(context); context.readName(mCore.mName); } void NpShape::requiresObjects(PxProcessPxBaseCallback& c) { //meshes PxBase* mesh = NULL; const PxGeometry& geometry = mCore.getGeometry(); switch(PxU32(mCore.getGeometryType())) { case PxGeometryType::eCONVEXMESH: mesh = static_cast<const PxConvexMeshGeometry&>(geometry).convexMesh; break; case PxGeometryType::eHEIGHTFIELD: mesh = static_cast<const PxHeightFieldGeometry&>(geometry).heightField; break; case PxGeometryType::eTRIANGLEMESH: mesh = static_cast<const PxTriangleMeshGeometry&>(geometry).triangleMesh; break; case PxGeometryType::eTETRAHEDRONMESH: mesh = static_cast<const PxTetrahedronMeshGeometry&>(geometry).tetrahedronMesh; break; } if(mesh) c.process(*mesh); //material const PxU32 nbMaterials = scGetNbMaterials(); for (PxU32 i=0; i < nbMaterials; i++) { NpMaterial* mat = scGetMaterial<NpMaterial>(i); c.process(*mat); } } void NpShape::resolveReferences(PxDeserializationContext& context) { // getMaterials() only works after material indices have been patched. // in order to get to the new material indices, we need access to the new materials. // this only leaves us with the option of acquiring the material through the context given an old material index (we do have the mapping) { PxU32 nbIndices = mCore.getNbMaterialIndices(); const PxU16* indices = mCore.getMaterialIndices(); for (PxU32 i=0; i < nbIndices; i++) { PxBase* base = context.resolveReference(PX_SERIAL_REF_KIND_MATERIAL_IDX, size_t(indices[i])); PX_ASSERT(base && base->is<PxMaterial>()); NpMaterial& material = *static_cast<NpMaterial*>(base); mCore.resolveMaterialReference(i, material.mMaterial.mMaterialIndex); } } //we don't resolve mExclusiveShapeActor because it's set to NULL on export. //it's recovered when the actors resolveReferences attaches to the shape mCore.resolveReferences(context); incMeshRefCount(); // Increment materials' refcounts in a second pass. Works better in case of failure above. const PxU32 nbMaterials = scGetNbMaterials(); for (PxU32 i=0; i < nbMaterials; i++) RefCountable_incRefCount(*scGetMaterial<NpMaterial>(i)); } NpShape* NpShape::createObject(PxU8*& address, PxDeserializationContext& context) { NpShape* obj = PX_PLACEMENT_NEW(address, NpShape(PxBaseFlag::eIS_RELEASABLE)); address += sizeof(NpShape); obj->importExtraData(context); obj->resolveReferences(context); return obj; } //~PX_SERIALIZATION PxU32 NpShape::getReferenceCount() const { return RefCountable_getRefCount(*this); } void NpShape::acquireReference() { RefCountable_incRefCount(*this); } void NpShape::release() { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(RefCountable_getRefCount(*this) > 1 || getActorCount() == 0, "PxShape::release: last reference to a shape released while still attached to an actor!"); releaseInternal(); } void NpShape::releaseInternal() { RefCountable_decRefCount(*this); } Sc::RigidCore& NpShape::getScRigidObjectExclusive() const { const PxType actorType = mExclusiveShapeActor->getConcreteType(); if (actorType == PxConcreteType::eRIGID_DYNAMIC) return static_cast<NpRigidDynamic&>(*mExclusiveShapeActor).getCore(); else if (actorType == PxConcreteType::eARTICULATION_LINK) return static_cast<NpArticulationLink&>(*mExclusiveShapeActor).getCore(); else return static_cast<NpRigidStatic&>(*mExclusiveShapeActor).getCore(); } void NpShape::updateSQ(const char* errorMessage) { PxRigidActor* actor = getActor(); if(actor && (mCore.getFlags() & PxShapeFlag::eSCENE_QUERY_SHAPE)) { NpScene* scene = NpActor::getNpSceneFromActor(*actor); NpShapeManager* shapeManager = NpActor::getShapeManager_(*actor); if(scene) shapeManager->markShapeForSQUpdate(scene->getSQAPI(), *this, static_cast<const PxRigidActor&>(*actor)); // invalidate the pruning structure if the actor bounds changed if(shapeManager->getPruningStructure()) { outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, errorMessage); shapeManager->getPruningStructure()->invalidate(mExclusiveShapeActor); } } } #if PX_CHECKED bool checkShape(const PxGeometry& g, const char* errorMsg); #endif void NpShape::setGeometry(const PxGeometry& g) { NpScene* ownerScene = getNpScene(); NP_WRITE_CHECK(ownerScene); PX_CHECK_AND_RETURN(isWritable(), "PxShape::setGeometry: shared shapes attached to actors are not writable."); #if PX_CHECKED if(!checkShape(g, "PxShape::setGeometry(): Invalid geometry!")) return; #endif PX_CHECK_SCENE_API_WRITE_FORBIDDEN(ownerScene, "PxShape::setGeometry() not allowed while simulation is running. Call will be ignored.") // PT: fixes US2117 if(g.getType() != getGeometryTypeFast()) { outputError<PxErrorCode::eINVALID_PARAMETER>(__LINE__, "PxShape::setGeometry(): Invalid geometry type. Changing the type of the shape is not supported."); return; } PX_SIMD_GUARD; //Do not decrement ref count here, but instead cache the refcountable mesh pointer if we had one. //We instead decrement the ref counter after incrementing the ref counter on the new geometry. //This resolves a case where the user changed a property of a mesh geometry and set the same mesh geometry. If the user had //called release() on the mesh, the ref count could hit 0 and be destroyed and then crash when we call incMeshRefCount(). PxRefCounted* mesh = getMeshRefCountable(); { Sc::RigidCore* rigidCore = getScRigidObjectSLOW(); if(rigidCore) rigidCore->unregisterShapeFromNphase(mCore); mCore.setGeometry(g); if (rigidCore) { rigidCore->registerShapeInNphase(mCore); rigidCore->onShapeChange(mCore, Sc::ShapeChangeNotifyFlag::eGEOMETRY); } #if PX_SUPPORT_PVD NpScene* npScene = getNpScene(); if(npScene) npScene->getScenePvdClientInternal().releaseAndRecreateGeometry(this); #endif } incMeshRefCount(); if(mesh) RefCountable_decRefCount(*mesh); updateSQ("PxShape::setGeometry: Shape is a part of pruning structure, pruning structure is now invalid!"); } const PxGeometry& NpShape::getGeometry() const { NP_READ_CHECK(getNpScene()); return mCore.getGeometry(); } PxRigidActor* NpShape::getActor() const { NP_READ_CHECK(getNpScene()); return mExclusiveShapeActor ? mExclusiveShapeActor->is<PxRigidActor>() : NULL; } void NpShape::setLocalPose(const PxTransform& newShape2Actor) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_AND_RETURN(newShape2Actor.isSane(), "PxShape::setLocalPose: pose is not valid."); PX_CHECK_AND_RETURN(isWritable(), "PxShape::setLocalPose: shared shapes attached to actors are not writable."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxShape::setLocalPose() not allowed while simulation is running. Call will be ignored."); PxTransform normalizedTransform = newShape2Actor.getNormalized(); mCore.setShape2Actor(normalizedTransform); notifyActorAndUpdatePVD(Sc::ShapeChangeNotifyFlag::eSHAPE2BODY); OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxShape, translation, static_cast<PxShape &>(*this), normalizedTransform.p) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxShape, rotation, static_cast<PxShape &>(*this), normalizedTransform.q) OMNI_PVD_WRITE_SCOPE_END updateSQ("PxShape::setLocalPose: Shape is a part of pruning structure, pruning structure is now invalid!"); } PxTransform NpShape::getLocalPose() const { NP_READ_CHECK(getNpScene()); return mCore.getShape2Actor(); } /////////////////////////////////////////////////////////////////////////////// void NpShape::setSimulationFilterData(const PxFilterData& data) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_AND_RETURN(isWritable(), "PxShape::setSimulationFilterData: shared shapes attached to actors are not writable."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxShape::setSimulationFilterData() not allowed while simulation is running. Call will be ignored.") mCore.setSimulationFilterData(data); notifyActorAndUpdatePVD(Sc::ShapeChangeNotifyFlag::eFILTERDATA); OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxShape, simulationFilterData, static_cast<PxShape&>(*this), data); } PxFilterData NpShape::getSimulationFilterData() const { NP_READ_CHECK(getNpScene()); return mCore.getSimulationFilterData(); } void NpShape::setQueryFilterData(const PxFilterData& data) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_AND_RETURN(isWritable(), "PxShape::setQueryFilterData: shared shapes attached to actors are not writable."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxShape::setQueryFilterData() not allowed while simulation is running. Call will be ignored.") OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxShape, queryFilterData, static_cast<PxShape&>(*this), data); mQueryFilterData = data; UPDATE_PVD_PROPERTY } PxFilterData NpShape::getQueryFilterData() const { NP_READ_CHECK(getNpScene()); return getQueryFilterDataFast(); } /////////////////////////////////////////////////////////////////////////////// template<typename PxMaterialType, typename NpMaterialType> void NpShape::setMaterialsInternal(PxMaterialType* const * materials, PxU16 materialCount) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_AND_RETURN(isWritable(), "PxShape::setMaterials: shared shapes attached to actors are not writable."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxShape::setMaterials() not allowed while simulation is running. Call will be ignored.") #if PX_CHECKED if (!NpShape::checkMaterialSetup(mCore.getGeometry(), "PxShape::setMaterials()", materials, materialCount)) return; #endif const PxU32 oldMaterialCount = scGetNbMaterials(); PX_ALLOCA(oldMaterials, PxMaterialType*, oldMaterialCount); PxU32 tmp = scGetMaterials<PxMaterialType, NpMaterialType>(oldMaterials, oldMaterialCount); PX_ASSERT(tmp == oldMaterialCount); PX_UNUSED(tmp); const bool ret = setMaterialsHelper<PxMaterialType, NpMaterialType>(materials, materialCount); #if PX_SUPPORT_PVD if (npScene) npScene->getScenePvdClientInternal().updateMaterials(this); #endif #if PX_SUPPORT_OMNI_PVD streamShapeMaterials(static_cast<PxShape&>(*this), materials, materialCount); #endif if (ret) { for (PxU32 i = 0; i < materialCount; i++) RefCountable_incRefCount(*materials[i]); for (PxU32 i = 0; i < oldMaterialCount; i++) RefCountable_decRefCount(*oldMaterials[i]); } } void NpShape::setMaterials(PxMaterial*const* materials, PxU16 materialCount) { PX_CHECK_AND_RETURN(!(mCore.getCore().mShapeCoreFlags & PxShapeCoreFlag::eSOFT_BODY_SHAPE), "NpShape::setMaterials: cannot set rigid body materials to a soft body shape!"); PX_CHECK_AND_RETURN(!(mCore.getCore().mShapeCoreFlags & PxShapeCoreFlag::eCLOTH_SHAPE), "NpShape::setMaterials: cannot set rigid body materials to a cloth shape!"); setMaterialsInternal<PxMaterial, NpMaterial>(materials, materialCount); } void NpShape::setSoftBodyMaterials(PxFEMSoftBodyMaterial*const* materials, PxU16 materialCount) { #if PX_SUPPORT_GPU_PHYSX PX_CHECK_AND_RETURN((mCore.getCore().mShapeCoreFlags & PxShapeCoreFlag::eSOFT_BODY_SHAPE), "NpShape::setMaterials: can only apply soft body materials to a soft body shape!"); setMaterialsInternal<PxFEMSoftBodyMaterial, NpFEMSoftBodyMaterial>(materials, materialCount); if (this->mExclusiveShapeActor) { static_cast<NpSoftBody*>(mExclusiveShapeActor)->updateMaterials(); } #else PX_UNUSED(materials); PX_UNUSED(materialCount); #endif } void NpShape::setClothMaterials(PxFEMClothMaterial*const* materials, PxU16 materialCount) { #if PX_SUPPORT_GPU_PHYSX && PX_ENABLE_FEATURES_UNDER_CONSTRUCTION PX_CHECK_AND_RETURN((mCore.getCore().mShapeCoreFlags & PxShapeCoreFlag::eCLOTH_SHAPE), "NpShape::setMaterials: can only apply cloth materials to a cloth shape!"); setMaterialsInternal<PxFEMClothMaterial, NpFEMClothMaterial>(materials, materialCount); #else PX_UNUSED(materials); PX_UNUSED(materialCount); #endif } PxU16 NpShape::getNbMaterials() const { NP_READ_CHECK(getNpScene()); return scGetNbMaterials(); } PxU32 NpShape::getMaterials(PxMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex) const { NP_READ_CHECK(getNpScene()); return scGetMaterials<PxMaterial, NpMaterial>(userBuffer, bufferSize, startIndex); } #if PX_SUPPORT_GPU_PHYSX PxU32 NpShape::getSoftBodyMaterials(PxFEMSoftBodyMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex) const { NP_READ_CHECK(getNpScene()); return scGetMaterials<PxFEMSoftBodyMaterial, NpFEMSoftBodyMaterial>(userBuffer, bufferSize, startIndex); } #else PxU32 NpShape::getSoftBodyMaterials(PxFEMSoftBodyMaterial**, PxU32, PxU32) const { return 0; } #endif #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION && PX_SUPPORT_GPU_PHYSX PxU32 NpShape::getClothMaterials(PxFEMClothMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex) const { NP_READ_CHECK(getNpScene()); return scGetMaterials<PxFEMClothMaterial, NpFEMClothMaterial>(userBuffer, bufferSize, startIndex); } #else PxU32 NpShape::getClothMaterials(PxFEMClothMaterial**, PxU32, PxU32) const { return 0; } #endif PxBaseMaterial* NpShape::getMaterialFromInternalFaceIndex(PxU32 faceIndex) const { NP_READ_CHECK(getNpScene()); const PxGeometry& geom = mCore.getGeometry(); const PxGeometryType::Enum geomType = geom.getType(); bool isHf = (geomType == PxGeometryType::eHEIGHTFIELD); bool isMesh = (geomType == PxGeometryType::eTRIANGLEMESH); // if SDF tri-mesh, where no multi-material setup is allowed, return zero-index material if (isMesh) { const PxTriangleMeshGeometry& triGeo = static_cast<const PxTriangleMeshGeometry&>(geom); if (triGeo.triangleMesh->getSDF()) { return getMaterial<PxMaterial, NpMaterial>(0); } } if( faceIndex == 0xFFFFffff && (isHf || isMesh) ) { outputError<PxErrorCode::eDEBUG_WARNING>(__LINE__, "PxShape::getMaterialFromInternalFaceIndex received 0xFFFFffff as input - returning NULL."); return NULL; } PxMaterialTableIndex hitMatTableId = 0; if(isHf) { const PxHeightFieldGeometry& hfGeom = static_cast<const PxHeightFieldGeometry&>(geom); hitMatTableId = hfGeom.heightField->getTriangleMaterialIndex(faceIndex); } else if(isMesh) { const PxTriangleMeshGeometry& triGeo = static_cast<const PxTriangleMeshGeometry&>(geom); Gu::TriangleMesh* tm = static_cast<Gu::TriangleMesh*>(triGeo.triangleMesh); if(tm->hasPerTriangleMaterials()) hitMatTableId = triGeo.triangleMesh->getTriangleMaterialIndex(faceIndex); } // PT: TODO: what's going on here? return getMaterial<PxMaterial, NpMaterial>(hitMatTableId); } void NpShape::setContactOffset(PxReal contactOffset) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_AND_RETURN(PxIsFinite(contactOffset), "PxShape::setContactOffset: invalid float"); PX_CHECK_AND_RETURN((contactOffset >= 0.0f && contactOffset > mCore.getRestOffset()), "PxShape::setContactOffset: contactOffset should be positive, and greater than restOffset!"); PX_CHECK_AND_RETURN(isWritable(), "PxShape::setContactOffset: shared shapes attached to actors are not writable."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxShape::setContactOffset() not allowed while simulation is running. Call will be ignored.") mCore.setContactOffset(contactOffset); notifyActorAndUpdatePVD(Sc::ShapeChangeNotifyFlag::eCONTACTOFFSET); OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxShape, contactOffset, static_cast<PxShape&>(*this), contactOffset) } PxReal NpShape::getContactOffset() const { NP_READ_CHECK(getNpScene()); return mCore.getContactOffset(); } void NpShape::setRestOffset(PxReal restOffset) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_AND_RETURN(PxIsFinite(restOffset), "PxShape::setRestOffset: invalid float"); PX_CHECK_AND_RETURN((restOffset < mCore.getContactOffset()), "PxShape::setRestOffset: restOffset should be less than contactOffset!"); PX_CHECK_AND_RETURN(isWritable(), "PxShape::setRestOffset: shared shapes attached to actors are not writable."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxShape::setRestOffset() not allowed while simulation is running. Call will be ignored.") mCore.setRestOffset(restOffset); notifyActorAndUpdatePVD(Sc::ShapeChangeNotifyFlag::eRESTOFFSET); OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxShape, restOffset, static_cast<PxShape&>(*this), restOffset) } PxReal NpShape::getRestOffset() const { NP_READ_CHECK(getNpScene()); return mCore.getRestOffset(); } void NpShape::setDensityForFluid(PxReal densityForFluid) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_AND_RETURN(PxIsFinite(densityForFluid), "PxShape::setDensityForFluid: invalid float"); PX_CHECK_AND_RETURN(isWritable(), "PxShape::setDensityForFluid: shared shapes attached to actors are not writable."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxShape::setDensityForFluid() not allowed while simulation is running. Call will be ignored.") mCore.setDensityForFluid(densityForFluid); ///notifyActorAndUpdatePVD(Sc::ShapeChangeNotifyFlag::eRESTOFFSET); OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxShape, densityForFluid, static_cast<PxShape &>(*this), densityForFluid); } PxReal NpShape::getDensityForFluid() const { NP_READ_CHECK(getNpScene()); return mCore.getDensityForFluid(); } void NpShape::setTorsionalPatchRadius(PxReal radius) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_AND_RETURN(PxIsFinite(radius), "PxShape::setTorsionalPatchRadius: invalid float"); PX_CHECK_AND_RETURN((radius >= 0.f), "PxShape::setTorsionalPatchRadius: must be >= 0.f"); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxShape::setTorsionalPatchRadius() not allowed while simulation is running. Call will be ignored.") // const PxShapeFlags oldShapeFlags = mShape.getFlags(); mCore.setTorsionalPatchRadius(radius); OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxShape, torsionalPatchRadius, static_cast<PxShape &>(*this), radius); // shared shapes return NULL. But shared shapes aren't mutable when attached to an actor, so no notification needed. // Sc::RigidCore* rigidCore = NpShapeGetScRigidObjectFromScSLOW(); // if(rigidCore) // rigidCore->onShapeChange(mShape, Sc::ShapeChangeNotifyFlag::eFLAGS, oldShapeFlags); UPDATE_PVD_PROPERTY } PxReal NpShape::getTorsionalPatchRadius() const { NP_READ_CHECK(getNpScene()); return mCore.getTorsionalPatchRadius(); } void NpShape::setMinTorsionalPatchRadius(PxReal radius) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_AND_RETURN(PxIsFinite(radius), "PxShape::setMinTorsionalPatchRadius: invalid float"); PX_CHECK_AND_RETURN((radius >= 0.f), "PxShape::setMinTorsionalPatchRadius: must be >= 0.f"); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxShape::setMinTorsionalPatchRadius() not allowed while simulation is running. Call will be ignored.") // const PxShapeFlags oldShapeFlags = mShape.getFlags(); mCore.setMinTorsionalPatchRadius(radius); OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxShape, minTorsionalPatchRadius, static_cast<PxShape &>(*this), radius); // Sc::RigidCore* rigidCore = NpShapeGetScRigidObjectFromSbSLOW(); // if(rigidCore) // rigidCore->onShapeChange(mShape, Sc::ShapeChangeNotifyFlag::eFLAGS, oldShapeFlags); UPDATE_PVD_PROPERTY } PxReal NpShape::getMinTorsionalPatchRadius() const { NP_READ_CHECK(getNpScene()); return mCore.getMinTorsionalPatchRadius(); } PxU32 NpShape::getInternalShapeIndex() const { NP_READ_CHECK(getNpScene()); if (getNpScene()) { PxsSimulationController* simulationController = getNpScene()->getSimulationController(); if (simulationController) return mCore.getInternalShapeIndex(*simulationController); } return PX_INVALID_NODE; } void NpShape::setFlagsInternal(PxShapeFlags inFlags) { const bool hasMeshTypeGeom = mCore.getGeometryType() == PxGeometryType::eTRIANGLEMESH || mCore.getGeometryType() == PxGeometryType::eHEIGHTFIELD; if(hasMeshTypeGeom && (inFlags & PxShapeFlag::eTRIGGER_SHAPE)) { outputError<PxErrorCode::eINVALID_PARAMETER>(__LINE__, "PxShape::setFlag(s): triangle mesh and heightfield triggers are not supported!"); return; } if((inFlags & PxShapeFlag::eSIMULATION_SHAPE) && (inFlags & PxShapeFlag::eTRIGGER_SHAPE)) { outputError<PxErrorCode::eINVALID_PARAMETER>(__LINE__, "PxShape::setFlag(s): shapes cannot simultaneously be trigger shapes and simulation shapes."); return; } const PxShapeFlags oldFlags = mCore.getFlags(); const bool oldIsSimShape = oldFlags & PxShapeFlag::eSIMULATION_SHAPE; const bool isSimShape = inFlags & PxShapeFlag::eSIMULATION_SHAPE; if(mExclusiveShapeActor) { const PxType type = mExclusiveShapeActor->getConcreteType(); // PT: US5732 - support kinematic meshes bool isKinematic = false; if(type==PxConcreteType::eRIGID_DYNAMIC) { PxRigidDynamic* rigidDynamic = static_cast<PxRigidDynamic*>(mExclusiveShapeActor); isKinematic = rigidDynamic->getRigidBodyFlags() & PxRigidBodyFlag::eKINEMATIC; } if((type != PxConcreteType::eRIGID_STATIC) && !isKinematic && isSimShape && !oldIsSimShape && (hasMeshTypeGeom || mCore.getGeometryType() == PxGeometryType::ePLANE)) { outputError<PxErrorCode::eINVALID_PARAMETER>(__LINE__, "PxShape::setFlag(s): triangle mesh, heightfield and plane shapes can only be simulation shapes if part of a PxRigidStatic!"); return; } } const bool oldHasSceneQuery = oldFlags & PxShapeFlag::eSCENE_QUERY_SHAPE; const bool hasSceneQuery = inFlags & PxShapeFlag::eSCENE_QUERY_SHAPE; { PX_ASSERT(!isAPIWriteForbidden()); const PxShapeFlags oldShapeFlags = mCore.getFlags(); mCore.setFlags(inFlags); notifyActorAndUpdatePVD(oldShapeFlags); } PxRigidActor* actor = getActor(); if(oldHasSceneQuery != hasSceneQuery && actor) { NpScene* npScene = getNpScene(); NpShapeManager* shapeManager = NpActor::getShapeManager_(*actor); if(npScene) { if(hasSceneQuery) { // PT: SQ_CODEPATH3 shapeManager->setupSceneQuery(npScene->getSQAPI(), NpActor::getFromPxActor(*actor), *actor, *this); } else { shapeManager->teardownSceneQuery(npScene->getSQAPI(), *actor, *this); } } // invalidate the pruning structure if the actor bounds changed if(shapeManager->getPruningStructure()) { outputError<PxErrorCode::eINVALID_OPERATION>(__LINE__, "PxShape::setFlag: Shape is a part of pruning structure, pruning structure is now invalid!"); shapeManager->getPruningStructure()->invalidate(mExclusiveShapeActor); } } } void NpShape::setFlag(PxShapeFlag::Enum flag, bool value) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_AND_RETURN(isWritable(), "PxShape::setFlag: shared shapes attached to actors are not writable."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxShape::setFlag() not allowed while simulation is running. Call will be ignored.") PX_SIMD_GUARD; PxShapeFlags shapeFlags = mCore.getFlags(); shapeFlags = value ? shapeFlags | flag : shapeFlags & ~flag; setFlagsInternal(shapeFlags); OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxShape, shapeFlags, static_cast<PxShape&>(*this), shapeFlags); } void NpShape::setFlags(PxShapeFlags inFlags) { NpScene* npScene = getNpScene(); NP_WRITE_CHECK(npScene); PX_CHECK_AND_RETURN(isWritable(), "PxShape::setFlags: shared shapes attached to actors are not writable."); PX_CHECK_SCENE_API_WRITE_FORBIDDEN(npScene, "PxShape::setFlags() not allowed while simulation is running. Call will be ignored.") PX_SIMD_GUARD; setFlagsInternal(inFlags); OMNI_PVD_SET(OMNI_PVD_CONTEXT_HANDLE, PxShape, shapeFlags, static_cast<PxShape&>(*this), inFlags); } PxShapeFlags NpShape::getFlags() const { NP_READ_CHECK(getNpScene()); return mCore.getFlags(); } bool NpShape::isExclusive() const { NP_READ_CHECK(getNpScene()); return isExclusiveFast(); } void NpShape::onActorAttach(PxActor& actor) { RefCountable_incRefCount(*this); if(isExclusiveFast()) mExclusiveShapeActor = &actor; increaseActorCount(&mFreeSlot); } void NpShape::onActorDetach() { PX_ASSERT(getActorCount() > 0); decreaseActorCount(&mFreeSlot); if(isExclusiveFast()) mExclusiveShapeActor = NULL; RefCountable_decRefCount(*this); } void NpShape::incActorCount() { RefCountable_incRefCount(*this); increaseActorCount(&mFreeSlot); } void NpShape::decActorCount() { PX_ASSERT(getActorCount() > 0); decreaseActorCount(&mFreeSlot); RefCountable_decRefCount(*this); } void NpShape::setName(const char* debugName) { NP_WRITE_CHECK(getNpScene()); PX_CHECK_AND_RETURN(isWritable(), "PxShape::setName: shared shapes attached to actors are not writable."); mCore.mName = debugName; UPDATE_PVD_PROPERTY } const char* NpShape::getName() const { NP_READ_CHECK(getNpScene()); return mCore.mName; } /////////////////////////////////////////////////////////////////////////////// // see NpConvexMesh.h, NpHeightField.h, NpTriangleMesh.h for details on how ref counting works for meshes PxRefCounted* NpShape::getMeshRefCountable() { const PxGeometry& geometry = mCore.getGeometry(); switch(PxU32(mCore.getGeometryType())) { case PxGeometryType::eCONVEXMESH: return static_cast<const PxConvexMeshGeometry&>(geometry).convexMesh; case PxGeometryType::eHEIGHTFIELD: return static_cast<const PxHeightFieldGeometry&>(geometry).heightField; case PxGeometryType::eTRIANGLEMESH: return static_cast<const PxTriangleMeshGeometry&>(geometry).triangleMesh; case PxGeometryType::eTETRAHEDRONMESH: return static_cast<const PxTetrahedronMeshGeometry&>(geometry).tetrahedronMesh; default: break; } return NULL; } bool NpShape::isWritable() { // a shape is writable if it's exclusive, or it's not connected to any actors (which is true if the ref count is 1 and the user ref is not released.) return isExclusiveFast() || (RefCountable_getRefCount(*this)==1 && (mBaseFlags & PxBaseFlag::eIS_RELEASABLE)); } void NpShape::incMeshRefCount() { PxRefCounted* mesh = getMeshRefCountable(); if(mesh) RefCountable_incRefCount(*mesh); } void NpShape::decMeshRefCount() { PxRefCounted* mesh = getMeshRefCountable(); if(mesh) RefCountable_decRefCount(*mesh); } /////////////////////////////////////////////////////////////////////////////// template <typename PxMaterialType, typename NpMaterialType> bool NpShape::setMaterialsHelper(PxMaterialType* const* materials, PxU16 materialCount) { PX_ASSERT(!isAPIWriteForbidden()); if(materialCount == 1) { const PxU16 materialIndex = static_cast<NpMaterialType*>(materials[0])->mMaterial.mMaterialIndex; mCore.setMaterialIndices(&materialIndex, 1); } else { PX_ASSERT(materialCount > 1); PX_ALLOCA(materialIndices, PxU16, materialCount); if(materialIndices) { NpMaterialType::getMaterialIndices(materials, materialIndices, materialCount); mCore.setMaterialIndices(materialIndices, materialCount); } else return outputError<PxErrorCode::eOUT_OF_MEMORY>(__LINE__, "PxShape::setMaterials() failed. Out of memory. Call will be ignored."); } NpScene* npScene = getNpScene(); if(npScene) npScene->getScScene().notifyNphaseOnUpdateShapeMaterial(mCore); return true; } void NpShape::notifyActorAndUpdatePVD(Sc::ShapeChangeNotifyFlags notifyFlags) { // shared shapes return NULL. But shared shapes aren't mutable when attached to an actor, so no notification needed. if(mExclusiveShapeActor) { Sc::RigidCore* rigidCore = getScRigidObjectSLOW(); if(rigidCore) rigidCore->onShapeChange(mCore, notifyFlags); #if PX_SUPPORT_GPU_PHYSX const PxType type = mExclusiveShapeActor->getConcreteType(); #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION if(type==PxConcreteType::eFEM_CLOTH) static_cast<NpFEMCloth*>(mExclusiveShapeActor)->getCore().onShapeChange(mCore, notifyFlags); #endif if(type==PxConcreteType::eSOFT_BODY) static_cast<NpSoftBody*>(mExclusiveShapeActor)->getCore().onShapeChange(mCore, notifyFlags); #endif } UPDATE_PVD_PROPERTY } void NpShape::notifyActorAndUpdatePVD(const PxShapeFlags oldShapeFlags) { // shared shapes return NULL. But shared shapes aren't mutable when attached to an actor, so no notification needed. Sc::RigidCore* rigidCore = getScRigidObjectSLOW(); if(rigidCore) rigidCore->onShapeFlagsChange(mCore, oldShapeFlags); UPDATE_PVD_PROPERTY }
32,794
C++
32.567042
184
0.751296
NVIDIA-Omniverse/PhysX/physx/source/physx/src/NpFEMSoftBodyMaterial.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef NP_FEM_MATERIAL_H #define NP_FEM_MATERIAL_H #include "common/PxSerialFramework.h" #include "foundation/PxUserAllocated.h" #include "foundation/PxUtilities.h" #include "CmRefCountable.h" #include "PxsFEMSoftBodyMaterialCore.h" namespace physx { // Compared to other objects, materials are special since they belong to the SDK and not to scenes // (similar to meshes). That's why the NpFEMMaterial does have direct access to the core material instead // of having a buffered interface for it. Scenes will have copies of the SDK material table and there // the materials will be buffered. class NpFEMSoftBodyMaterial : public PxFEMSoftBodyMaterial, public PxUserAllocated { public: // PX_SERIALIZATION NpFEMSoftBodyMaterial(PxBaseFlags baseFlags) : PxFEMSoftBodyMaterial(baseFlags), mMaterial(PxEmpty) {} virtual void resolveReferences(PxDeserializationContext& context); static NpFEMSoftBodyMaterial* createObject(PxU8*& address, PxDeserializationContext& context); static void getBinaryMetaData(PxOutputStream& stream); void preExportDataReset() { Cm::RefCountable_preExportDataReset(*this); } void exportExtraData(PxSerializationContext&) {} void importExtraData(PxDeserializationContext&) {} virtual void requiresObjects(PxProcessPxBaseCallback&) {} //~PX_SERIALIZATION NpFEMSoftBodyMaterial(const PxsFEMSoftBodyMaterialCore& desc); virtual ~NpFEMSoftBodyMaterial(); // PxBase virtual void onRefCountZero(); //~PxBase virtual void release(); // PxRefCounted virtual void acquireReference(); virtual PxU32 getReferenceCount() const; //~PxRefCounted // PxFEMMaterial virtual void setYoungsModulus(PxReal young) PX_OVERRIDE; virtual PxReal getYoungsModulus() const PX_OVERRIDE; virtual void setPoissons(PxReal poisson) PX_OVERRIDE; virtual PxReal getPoissons() const PX_OVERRIDE; virtual void setDynamicFriction(PxReal threshold) PX_OVERRIDE; virtual PxReal getDynamicFriction() const PX_OVERRIDE; //~PxFEMMaterial // PxFEMSoftBodyMaterial virtual void setDamping(PxReal damping) PX_OVERRIDE; virtual PxReal getDamping() const PX_OVERRIDE; virtual void setDampingScale(PxReal scale); virtual PxReal getDampingScale() const; virtual void setMaterialModel(PxFEMSoftBodyMaterialModel::Enum model); virtual PxFEMSoftBodyMaterialModel::Enum getMaterialModel() const; virtual void setDeformThreshold(PxReal threshold); virtual PxReal getDeformThreshold() const; virtual void setDeformLowLimitRatio(PxReal threshold); virtual PxReal getDeformLowLimitRatio() const; virtual void setDeformHighLimitRatio(PxReal threshold); virtual PxReal getDeformHighLimitRatio() const; //~PxFEMSoftBodyMaterial PX_FORCE_INLINE static void getMaterialIndices(PxFEMSoftBodyMaterial*const* materials, PxU16* materialIndices, PxU32 materialCount); private: PX_INLINE void updateMaterial(); // PX_SERIALIZATION public: //~PX_SERIALIZATION PxsFEMSoftBodyMaterialCore mMaterial; }; PX_FORCE_INLINE void NpFEMSoftBodyMaterial::getMaterialIndices(PxFEMSoftBodyMaterial*const* materials, PxU16* materialIndices, PxU32 materialCount) { for (PxU32 i = 0; i < materialCount; i++) materialIndices[i] = static_cast<NpFEMSoftBodyMaterial*>(materials[i])->mMaterial.mMaterialIndex; } } #endif
5,136
C
43.284482
148
0.75954
NVIDIA-Omniverse/PhysX/physx/source/physx/src/NpSceneQueries.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef NP_SCENE_QUERIES_H #define NP_SCENE_QUERIES_H #include "PxSceneQueryDesc.h" #include "SqQuery.h" #include "ScSqBoundsSync.h" #if PX_SUPPORT_PVD #include "NpPvdSceneQueryCollector.h" #include "NpPvdSceneClient.h" #endif #include "PxSceneQuerySystem.h" #include "NpBounds.h" // PT: for SQ_PRUNER_EPSILON namespace physx { class PxScene; class PxSceneDesc; namespace Vd { class PvdSceneClient; } class NpSceneQueries : public Sc::SqBoundsSync #if PX_SUPPORT_PVD , public Sq::PVDCapture #endif { PX_NOCOPY(NpSceneQueries) public: // PT: TODO: use PxSceneQueryDesc here, but we need some SQ-specific "scene limits" NpSceneQueries(const PxSceneDesc& desc, Vd::PvdSceneClient* pvd, PxU64 contextID); ~NpSceneQueries(); PX_FORCE_INLINE PxSceneQuerySystem& getSQAPI() { PX_ASSERT(mSQ); return *mSQ; } PX_FORCE_INLINE const PxSceneQuerySystem& getSQAPI() const { PX_ASSERT(mSQ); return *mSQ; } protected: // SqBoundsSync virtual void sync(PxU32 prunerIndex, const ScPrunerHandle* handles, const PxU32* boundsIndices, const PxBounds3* bounds, const PxTransform32* transforms, PxU32 count, const PxBitMap& ignoredIndices) PX_OVERRIDE; //~SqBoundsSync public: PxSceneQuerySystem* mSQ; #if PX_SUPPORT_PVD Vd::PvdSceneClient* mPVDClient; //Scene query and hits for pvd, collected in current frame mutable Vd::PvdSceneQueryCollector mSingleSqCollector; PX_FORCE_INLINE Vd::PvdSceneQueryCollector& getSingleSqCollector() const { return mSingleSqCollector; } // PVDCapture virtual bool transmitSceneQueries(); virtual void raycast(const PxVec3& origin, const PxVec3& unitDir, PxReal distance, const PxRaycastHit* hit, PxU32 hitsNum, const PxQueryFilterData& filterData, bool multipleHits); virtual void sweep(const PxGeometry& geometry, const PxTransform& pose, const PxVec3& unitDir, PxReal distance, const PxSweepHit* hit, PxU32 hitsNum, const PxQueryFilterData& filterData, bool multipleHits); virtual void overlap(const PxGeometry& geometry, const PxTransform& pose, const PxOverlapHit* hit, PxU32 hitsNum, const PxQueryFilterData& filterData); //~PVDCapture #endif // PX_SUPPORT_PVD }; } // namespace physx, sq #endif
3,958
C
39.814433
214
0.751642
NVIDIA-Omniverse/PhysX/physx/source/physx/src/NpConnector.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef NP_CONNECTOR_H #define NP_CONNECTOR_H #include "common/PxSerialFramework.h" #include "foundation/PxInlineArray.h" #include "foundation/PxUtilities.h" #include "CmUtils.h" namespace physx { struct NpConnectorType { enum Enum { eConstraint, eAggregate, eObserver, eBvh, eInvalid }; }; class NpConnector { public: NpConnector() : mType(NpConnectorType::eInvalid), mObject(NULL) {} NpConnector(NpConnectorType::Enum type, PxBase* object) : mType(PxTo8(type)), mObject(object) {} // PX_SERIALIZATION NpConnector(const NpConnector& c) { //special copy constructor that initializes padding bytes for meta data verification (PX_CHECKED only) PxMarkSerializedMemory(this, sizeof(NpConnector)); mType = c.mType; mObject = c.mObject; } static void getBinaryMetaData(PxOutputStream& stream); //~PX_SERIALIZATION PxU8 mType; // Revisit whether the type is really necessary or whether the serializable type is enough. // Since joints might gonna inherit from observers to register for constraint release events, the type // is necessary because a joint has its own serializable type and could not be detected as observer anymore. PxU8 mPadding[3]; // PT: padding from prev byte PxBase* mObject; // So far the serialization framework only supports ptr resolve for PxBase objects. // However, so far the observers all are PxBase, hence this choice of type. }; class NpConnectorIterator { public: PX_FORCE_INLINE NpConnectorIterator(NpConnector* c, PxU32 size, NpConnectorType::Enum type) : mConnectors(c), mSize(size), mIndex(0), mType(type) {} PX_FORCE_INLINE PxBase* getNext() { PxBase* s = NULL; while(mIndex < mSize) { NpConnector& c = mConnectors[mIndex]; mIndex++; if (c.mType == mType) return c.mObject; } return s; } private: NpConnector* mConnectors; PxU32 mSize; PxU32 mIndex; NpConnectorType::Enum mType; }; class NpConnectorArray: public PxInlineArray<NpConnector, 4> { public: // PX_SERIALIZATION NpConnectorArray(const PxEMPTY) : PxInlineArray<NpConnector, 4> (PxEmpty) {} static void getBinaryMetaData(PxOutputStream& stream); //~PX_SERIALIZATION NpConnectorArray() : PxInlineArray<NpConnector, 4>("connectorArray") { //special default constructor that initializes padding bytes for meta data verification (PX_CHECKED only) PxMarkSerializedMemory(this->mData, 4*sizeof(NpConnector)); } }; } #endif
4,136
C
33.475
149
0.746857
NVIDIA-Omniverse/PhysX/physx/source/physx/src/NpBounds.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #include "foundation/PxTransform.h" #include "NpBounds.h" #include "CmTransformUtils.h" #include "NpRigidStatic.h" #include "NpRigidDynamic.h" #include "NpArticulationLink.h" #include "GuBounds.h" using namespace physx; using namespace Sq; static void computeStaticWorldAABB(PxBounds3& bounds, const NpShape& npShape, const NpActor& npActor) { const PxTransform& shape2Actor = npShape.getCore().getShape2Actor(); PX_ALIGN(16, PxTransform) globalPose; Cm::getStaticGlobalPoseAligned(static_cast<const NpRigidStatic&>(npActor).getCore().getActor2World(), shape2Actor, globalPose); Gu::computeBounds(bounds, npShape.getCore().getGeometry(), globalPose, 0.0f, SQ_PRUNER_INFLATION); } static void computeDynamicWorldAABB(PxBounds3& bounds, const NpShape& npShape, const NpActor& npActor) { const PxTransform& shape2Actor = npShape.getCore().getShape2Actor(); PX_ALIGN(16, PxTransform) globalPose; { PX_ALIGN(16, PxTransform) kinematicTarget; const PxU16 sqktFlags = PxRigidBodyFlag::eKINEMATIC | PxRigidBodyFlag::eUSE_KINEMATIC_TARGET_FOR_SCENE_QUERIES; // PT: TODO: revisit this once the dust has settled PX_ASSERT(npActor.getNpType()==NpType::eBODY_FROM_ARTICULATION_LINK || npActor.getNpType()==NpType::eBODY); const Sc::BodyCore& core = npActor.getNpType()==NpType::eBODY_FROM_ARTICULATION_LINK ? static_cast<const NpArticulationLink&>(npActor).getCore() : static_cast<const NpRigidDynamic&>(npActor).getCore(); const bool useTarget = (PxU16(core.getFlags()) & sqktFlags) == sqktFlags; const PxTransform& body2World = (useTarget && core.getKinematicTarget(kinematicTarget)) ? kinematicTarget : core.getBody2World(); Cm::getDynamicGlobalPoseAligned(body2World, shape2Actor, core.getBody2Actor(), globalPose); } Gu::computeBounds(bounds, npShape.getCore().getGeometry(), globalPose, 0.0f, SQ_PRUNER_INFLATION); } const ComputeBoundsFunc Sq::gComputeBoundsTable[2] = { computeStaticWorldAABB, computeDynamicWorldAABB };
3,653
C++
47.719999
203
0.7706
NVIDIA-Omniverse/PhysX/physx/source/physx/src/NpPhysics.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #include "NpPhysics.h" // PX_SERIALIZATION #include "foundation/PxProfiler.h" #include "foundation/PxIO.h" #include "foundation/PxErrorCallback.h" #include "foundation/PxString.h" #include "foundation/PxPhysicsVersion.h" #include "common/PxTolerancesScale.h" #include "CmCollection.h" #include "CmUtils.h" #include "NpRigidStatic.h" #include "NpRigidDynamic.h" #if PX_SUPPORT_GPU_PHYSX #include "NpSoftBody.h" #include "NpParticleSystem.h" #include "NpHairSystem.h" #endif #include "NpArticulationReducedCoordinate.h" #include "NpArticulationLink.h" #include "NpMaterial.h" #include "GuHeightFieldData.h" #include "GuHeightField.h" #include "GuConvexMesh.h" #include "GuTriangleMesh.h" #include "foundation/PxIntrinsics.h" #include "PxvGlobals.h" // dynamic registration of HFs & articulations in LL #include "GuOverlapTests.h" // dynamic registration of HFs in Gu #include "PxDeletionListener.h" #include "PxPhysicsSerialization.h" #include "PvdPhysicsClient.h" #include "omnipvd/NpOmniPvdSetData.h" #if PX_SUPPORT_OMNI_PVD #include "omnipvd/NpOmniPvd.h" #include "OmniPvdWriter.h" #endif #if PX_SUPPORT_GPU_PHYSX #include "PxPhysXGpu.h" #endif //~PX_SERIALIZATION #include "NpFactory.h" #if PX_SWITCH #include "switch/NpMiddlewareInfo.h" #endif #if PX_SUPPORT_OMNI_PVD # define OMNI_PVD_NOTIFY_ADD(OBJECT) mOmniPvdListener.onObjectAdd(OBJECT) # define OMNI_PVD_NOTIFY_REMOVE(OBJECT) mOmniPvdListener.onObjectRemove(OBJECT) #else # define OMNI_PVD_NOTIFY_ADD(OBJECT) # define OMNI_PVD_NOTIFY_REMOVE(OBJECT) #endif using namespace physx; using namespace Cm; bool NpPhysics::apiReentryLock = false; NpPhysics* NpPhysics::mInstance = NULL; PxU32 NpPhysics::mRefCount = 0; NpPhysics::NpPhysics(const PxTolerancesScale& scale, const PxvOffsetTable& pxvOffsetTable, bool trackOutstandingAllocations, pvdsdk::PsPvd* pvd, PxFoundation& foundation, PxOmniPvd* omniPvd) : mSceneArray ("physicsSceneArray"), mPhysics (scale, pxvOffsetTable), mDeletionListenersExist (false), mFoundation (foundation) #if PX_SUPPORT_GPU_PHYSX , mNbRegisteredGpuClients (0) #endif { PX_UNUSED(trackOutstandingAllocations); //mMasterMaterialTable.reserve(10); #if PX_SUPPORT_PVD mPvd = pvd; if(pvd) { mPvdPhysicsClient = PX_NEW(Vd::PvdPhysicsClient)(mPvd); foundation.registerErrorCallback(*mPvdPhysicsClient); foundation.registerAllocationListener(*mPvd); } else { mPvdPhysicsClient = NULL; } #else PX_UNUSED(pvd); #endif // PT: please leave this commented-out block here. /* printf("sizeof(NpScene) = %d\n", sizeof(NpScene)); printf("sizeof(NpShape) = %d\n", sizeof(NpShape)); printf("sizeof(NpActor) = %d\n", sizeof(NpActor)); printf("sizeof(NpRigidStatic) = %d\n", sizeof(NpRigidStatic)); printf("sizeof(NpRigidDynamic) = %d\n", sizeof(NpRigidDynamic)); printf("sizeof(NpMaterial) = %d\n", sizeof(NpMaterial)); printf("sizeof(NpConstraint) = %d\n", sizeof(NpConstraint)); printf("sizeof(NpAggregate) = %d\n", sizeof(NpAggregate)); printf("sizeof(NpArticulationRC) = %d\n", sizeof(NpArticulationReducedCoordinate)); printf("sizeof(GeometryUnion) = %d\n", sizeof(GeometryUnion)); printf("sizeof(PxGeometry) = %d\n", sizeof(PxGeometry)); printf("sizeof(PxPlaneGeometry) = %d\n", sizeof(PxPlaneGeometry)); printf("sizeof(PxSphereGeometry) = %d\n", sizeof(PxSphereGeometry)); printf("sizeof(PxCapsuleGeometry) = %d\n", sizeof(PxCapsuleGeometry)); printf("sizeof(PxBoxGeometry) = %d\n", sizeof(PxBoxGeometry)); printf("sizeof(PxConvexMeshGeometry) = %d\n", sizeof(PxConvexMeshGeometry)); printf("sizeof(PxConvexMeshGeometryLL) = %d\n", sizeof(PxConvexMeshGeometryLL)); printf("sizeof(PxTriangleMeshGeometry) = %d\n", sizeof(PxTriangleMeshGeometry)); printf("sizeof(PxTriangleMeshGeometryLL) = %d\n", sizeof(PxTriangleMeshGeometryLL)); printf("sizeof(PxsShapeCore) = %d\n", sizeof(PxsShapeCore)); */ #if PX_SUPPORT_OMNI_PVD mOmniPvdSampler = NULL; mOmniPvd = NULL; if (omniPvd) { OmniPvdWriter* omniWriter = omniPvd->getWriter(); if (omniWriter && omniWriter->getWriteStream()) { mOmniPvdSampler = PX_NEW(::OmniPvdPxSampler)(); mOmniPvd = omniPvd; NpOmniPvd* npOmniPvd = static_cast<NpOmniPvd*>(mOmniPvd); NpOmniPvd::incRefCount(); npOmniPvd->mPhysXSampler = mOmniPvdSampler; // Dirty hack to do startSampling from PxOmniPvd mOmniPvdSampler->setOmniPvdInstance(npOmniPvd); } } #else PX_UNUSED(omniPvd); #endif } NpPhysics::~NpPhysics() { // Release all scenes in case the user didn't do it PxU32 nbScenes = mSceneArray.size(); NpScene** scenes = mSceneArray.begin(); for(PxU32 i=0;i<nbScenes;i++) PX_DELETE(scenes[i]); mSceneArray.clear(); //PxU32 matCount = mMasterMaterialTable.size(); //while (mMasterMaterialTable.size() > 0) //{ // // It's done this way since the material destructor removes the material from the table and adjusts indices // PX_ASSERT(mMasterMaterialTable[0]->getRefCount() == 1); // mMasterMaterialTable[0]->decRefCount(); //} //mMasterMaterialTable.clear(); mMasterMaterialManager.releaseMaterials(); #if PX_SUPPORT_GPU_PHYSX mMasterFEMSoftBodyMaterialManager.releaseMaterials(); mMasterPBDMaterialManager.releaseMaterials(); #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION mMasterFEMClothMaterialManager.releaseMaterials(); mMasterFLIPMaterialManager.releaseMaterials(); mMasterMPMMaterialManager.releaseMaterials(); #endif #endif #if PX_SUPPORT_PVD if(mPvd) { mPvdPhysicsClient->destroyPvdInstance(this); mPvd->removeClient(mPvdPhysicsClient); mFoundation.deregisterErrorCallback(*mPvdPhysicsClient); PX_DELETE(mPvdPhysicsClient); mFoundation.deregisterAllocationListener(*mPvd); } #endif const DeletionListenerMap::Entry* delListenerEntries = mDeletionListenerMap.getEntries(); const PxU32 delListenerEntryCount = mDeletionListenerMap.size(); for(PxU32 i=0; i < delListenerEntryCount; i++) { NpDelListenerEntry* listener = delListenerEntries[i].second; PX_DELETE(listener); } mDeletionListenerMap.clear(); #if PX_SUPPORT_OMNI_PVD OMNI_PVD_DESTROY(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, static_cast<PxPhysics&>(*this)) PX_DELETE(mOmniPvdSampler); if (mOmniPvd) { NpOmniPvd::decRefCount(); } #endif #if PX_SUPPORT_GPU_PHYSX PxPhysXGpu* gpu = PxvGetPhysXGpu(false); if (gpu) PxvReleasePhysXGpu(gpu); #endif } PxOmniPvd* NpPhysics::getOmniPvd() { #if PX_SUPPORT_OMNI_PVD return mOmniPvd; #else return NULL; #endif } void NpPhysics::initOffsetTables(PxvOffsetTable& pxvOffsetTable) { // init offset tables for Pxs/Sc/Px conversions { Sc::OffsetTable& offsetTable = Sc::gOffsetTable; offsetTable.scRigidStatic2PxActor = -ptrdiff_t(NpRigidStatic::getCoreOffset()); offsetTable.scRigidDynamic2PxActor = -ptrdiff_t(NpRigidDynamic::getCoreOffset()); offsetTable.scArticulationLink2PxActor = -ptrdiff_t(NpArticulationLink::getCoreOffset()); #if PX_SUPPORT_GPU_PHYSX offsetTable.scSoftBody2PxActor = -ptrdiff_t(NpSoftBody::getCoreOffset()); offsetTable.scPBDParticleSystem2PxActor = -ptrdiff_t(NpPBDParticleSystem::getCoreOffset()); #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION offsetTable.scFLIPParticleSystem2PxActor = -ptrdiff_t(NpFLIPParticleSystem::getCoreOffset()); offsetTable.scMPMParticleSystem2PxActor = -ptrdiff_t(NpMPMParticleSystem::getCoreOffset()); offsetTable.scHairSystem2PxActor = -ptrdiff_t(NpHairSystem::getCoreOffset()); #endif #endif offsetTable.scArticulationRC2Px = -ptrdiff_t(NpArticulationReducedCoordinate::getCoreOffset()); offsetTable.scArticulationJointRC2Px = -ptrdiff_t(NpArticulationJointReducedCoordinate::getCoreOffset()); offsetTable.scConstraint2Px = -ptrdiff_t(NpConstraint::getCoreOffset()); offsetTable.scShape2Px = -ptrdiff_t(NpShape::getCoreOffset()); for(PxU32 i=0;i<PxActorType::eACTOR_COUNT;i++) offsetTable.scCore2PxActor[i] = 0; offsetTable.scCore2PxActor[PxActorType::eRIGID_STATIC] = offsetTable.scRigidStatic2PxActor; offsetTable.scCore2PxActor[PxActorType::eRIGID_DYNAMIC] = offsetTable.scRigidDynamic2PxActor; offsetTable.scCore2PxActor[PxActorType::eARTICULATION_LINK] = offsetTable.scArticulationLink2PxActor; offsetTable.scCore2PxActor[PxActorType::eSOFTBODY] = offsetTable.scSoftBody2PxActor; offsetTable.scCore2PxActor[PxActorType::ePBD_PARTICLESYSTEM] = offsetTable.scPBDParticleSystem2PxActor; offsetTable.scCore2PxActor[PxActorType::eFLIP_PARTICLESYSTEM] = offsetTable.scFLIPParticleSystem2PxActor; offsetTable.scCore2PxActor[PxActorType::eMPM_PARTICLESYSTEM] = offsetTable.scMPMParticleSystem2PxActor; offsetTable.scCore2PxActor[PxActorType::eHAIRSYSTEM] = offsetTable.scHairSystem2PxActor; } { Sc::OffsetTable& scOffsetTable = Sc::gOffsetTable; pxvOffsetTable.pxsShapeCore2PxShape = scOffsetTable.scShape2Px - ptrdiff_t(Sc::ShapeCore::getCoreOffset()); pxvOffsetTable.pxsRigidCore2PxRigidBody = scOffsetTable.scRigidDynamic2PxActor - ptrdiff_t(Sc::BodyCore::getCoreOffset()); pxvOffsetTable.pxsRigidCore2PxRigidStatic = scOffsetTable.scRigidStatic2PxActor - ptrdiff_t(Sc::StaticCore::getCoreOffset()); } } NpPhysics* NpPhysics::createInstance(PxU32 version, PxFoundation& foundation, const PxTolerancesScale& scale, bool trackOutstandingAllocations, pvdsdk::PsPvd* pvd, PxOmniPvd* omniPvd) { #if PX_SWITCH NpSetMiddlewareInfo(); // register middleware info such that PhysX usage can be tracked #endif if (version!=PX_PHYSICS_VERSION) { char buffer[256]; Pxsnprintf(buffer, 256, "Wrong version: PhysX version is 0x%08x, tried to create 0x%08x", PX_PHYSICS_VERSION, version); foundation.getErrorCallback().reportError(PxErrorCode::eINVALID_PARAMETER, buffer, PX_FL); return NULL; } if (!scale.isValid()) { foundation.getErrorCallback().reportError(PxErrorCode::eINVALID_PARAMETER, "Scale invalid.\n", PX_FL); return NULL; } if(0 == mRefCount) { PX_ASSERT(&foundation == &PxGetFoundation()); PxIncFoundationRefCount(); // init offset tables for Pxs/Sc/Px conversions PxvOffsetTable pxvOffsetTable; initOffsetTables(pxvOffsetTable); //SerialFactory::createInstance(); mInstance = PX_NEW (NpPhysics)(scale, pxvOffsetTable, trackOutstandingAllocations, pvd, foundation, omniPvd); NpFactory::createInstance(); #if PX_SUPPORT_OMNI_PVD if (omniPvd) NpFactory::getInstance().addFactoryListener(mInstance->mOmniPvdListener); #endif #if PX_SUPPORT_PVD if(pvd) { NpFactory::getInstance().setNpFactoryListener( *mInstance->mPvdPhysicsClient ); pvd->addClient(mInstance->mPvdPhysicsClient); } #endif NpFactory::getInstance().addFactoryListener(mInstance->mDeletionMeshListener); } ++mRefCount; return mInstance; } PxU32 NpPhysics::releaseInstance() { PX_ASSERT(mRefCount > 0); if (--mRefCount) return mRefCount; #if PX_SUPPORT_PVD if(mInstance->mPvd) { NpFactory::getInstance().removeFactoryListener( *mInstance->mPvdPhysicsClient ); } #endif NpFactory::destroyInstance(); PX_ASSERT(mInstance); PX_DELETE(mInstance); PxDecFoundationRefCount(); return mRefCount; } void NpPhysics::release() { NpPhysics::releaseInstance(); } PxScene* NpPhysics::createScene(const PxSceneDesc& desc) { PX_CHECK_AND_RETURN_NULL(desc.isValid(), "Physics::createScene: desc.isValid() is false!"); const PxTolerancesScale& scale = mPhysics.getTolerancesScale(); const PxTolerancesScale& descScale = desc.getTolerancesScale(); PX_UNUSED(scale); PX_UNUSED(descScale); PX_CHECK_AND_RETURN_NULL((descScale.length == scale.length) && (descScale.speed == scale.speed), "Physics::createScene: PxTolerancesScale must be the same as used for creation of PxPhysics!"); PxMutex::ScopedLock lock(mSceneAndMaterialMutex); // done here because scene constructor accesses profiling manager of the SDK NpScene* npScene = PX_NEW (NpScene)(desc, *this); if(!npScene) { mFoundation.error(PxErrorCode::eINTERNAL_ERROR, PX_FL, "Unable to create scene."); return NULL; } if(!npScene->getTaskManagerFast()) { mFoundation.error(PxErrorCode::eINTERNAL_ERROR, PX_FL, "Unable to create scene. Task manager creation failed."); return NULL; } npScene->loadFromDesc(desc); OMNI_PVD_ADD(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, scenes, static_cast<PxPhysics&>(*this), static_cast<PxScene&>(*npScene)) #if PX_SUPPORT_PVD if(mPvd) { npScene->getScenePvdClientInternal().setPsPvd(mPvd); mPvd->addClient(&npScene->getScenePvdClientInternal()); } #endif if (!sendMaterialTable(*npScene) || !npScene->getScScene().isValid()) { PX_DELETE(npScene); mFoundation.error(PxErrorCode::eOUT_OF_MEMORY, PX_FL, "Unable to create scene."); return NULL; } mSceneArray.pushBack(npScene); return npScene; } void NpPhysics::releaseSceneInternal(PxScene& scene) { NpScene* pScene = static_cast<NpScene*>(&scene); OMNI_PVD_REMOVE(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, scenes, static_cast<PxPhysics&>(*this), scene) PxMutex::ScopedLock lock(mSceneAndMaterialMutex); for(PxU32 i=0;i<mSceneArray.size();i++) { if(mSceneArray[i]==pScene) { mSceneArray.replaceWithLast(i); PX_DELETE(pScene); return; } } } PxU32 NpPhysics::getNbScenes() const { PxMutex::ScopedLock lock(const_cast<PxMutex&>(mSceneAndMaterialMutex)); return mSceneArray.size(); } PxU32 NpPhysics::getScenes(PxScene** userBuffer, PxU32 bufferSize, PxU32 startIndex) const { PxMutex::ScopedLock lock(const_cast<PxMutex&>(mSceneAndMaterialMutex)); return Cm::getArrayOfPointers(userBuffer, bufferSize, startIndex, mSceneArray.begin(), mSceneArray.size()); } PxRigidStatic* NpPhysics::createRigidStatic(const PxTransform& globalPose) { PX_CHECK_AND_RETURN_NULL(globalPose.isSane(), "PxPhysics::createRigidStatic: invalid transform"); return NpFactory::getInstance().createRigidStatic(globalPose.getNormalized()); } PxShape* NpPhysics::createShape(const PxGeometry& geometry, PxMaterial*const * materials, PxU16 materialCount, bool isExclusive, PxShapeFlags shapeFlags) { PX_CHECK_AND_RETURN_NULL(materials, "createShape: material pointer is NULL"); PX_CHECK_AND_RETURN_NULL(materialCount>0, "createShape: material count is zero"); #if PX_CHECKED const bool isHeightfield = geometry.getType() == PxGeometryType::eHEIGHTFIELD; const bool hasMeshTypeGeom = isHeightfield || (geometry.getType() == PxGeometryType::eTRIANGLEMESH) || (geometry.getType() == PxGeometryType::eTETRAHEDRONMESH); PX_CHECK_AND_RETURN_NULL(!(hasMeshTypeGeom && (shapeFlags & PxShapeFlag::eTRIGGER_SHAPE)), "NpPhysics::createShape: triangle mesh/heightfield/tetrahedron mesh triggers are not supported!"); PX_CHECK_AND_RETURN_NULL(!((shapeFlags & PxShapeFlag::eSIMULATION_SHAPE) && (shapeFlags & PxShapeFlag::eTRIGGER_SHAPE)), "NpPhysics::createShape: shapes cannot simultaneously be trigger shapes and simulation shapes."); #endif return NpFactory::getInstance().createShape(geometry, shapeFlags, materials, materialCount, isExclusive); } PxShape* NpPhysics::createShape(const PxGeometry& geometry, PxFEMSoftBodyMaterial*const * materials, PxU16 materialCount, bool isExclusive, PxShapeFlags shapeFlags) { PX_CHECK_AND_RETURN_NULL(materials, "createShape: material pointer is NULL"); PX_CHECK_AND_RETURN_NULL(materialCount > 0, "createShape: material count is zero"); PX_CHECK_AND_RETURN_NULL(geometry.getType() == PxGeometryType::eTETRAHEDRONMESH, "createShape: soft bodies only accept PxTetrahedronMeshGeometry"); PX_CHECK_AND_RETURN_NULL(shapeFlags & PxShapeFlag::eSIMULATION_SHAPE, "createShape: soft body shapes must be simulation shapes"); return NpFactory::getInstance().createShape(geometry, shapeFlags, materials, materialCount, isExclusive); } #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION && PX_SUPPORT_GPU_PHYSX PxShape* NpPhysics::createShape(const PxGeometry& geometry, PxFEMClothMaterial*const * materials, PxU16 materialCount, bool isExclusive, PxShapeFlags shapeFlags) { PX_CHECK_AND_RETURN_NULL(materials, "createShape: material pointer is NULL"); PX_CHECK_AND_RETURN_NULL(materialCount > 0, "createShape: material count is zero"); PX_CHECK_AND_RETURN_NULL(geometry.getType() == PxGeometryType::eTRIANGLEMESH, "createShape: cloth only accept PxTriangleMeshGeometry"); PX_CHECK_AND_RETURN_NULL(shapeFlags & PxShapeFlag::eSIMULATION_SHAPE, "createShape: cloth shapes must be simulation shapes"); return NpFactory::getInstance().createShape(geometry, shapeFlags, materials, materialCount, isExclusive); } #else PxShape* NpPhysics::createShape(const PxGeometry&, PxFEMClothMaterial*const *, PxU16, bool, PxShapeFlags) { return NULL; } #endif PxU32 NpPhysics::getNbShapes() const { return NpFactory::getInstance().getNbShapes(); } PxU32 NpPhysics::getShapes(PxShape** userBuffer, PxU32 bufferSize, PxU32 startIndex) const { return NpFactory::getInstance().getShapes(userBuffer, bufferSize, startIndex); } PxRigidDynamic* NpPhysics::createRigidDynamic(const PxTransform& globalPose) { PX_CHECK_AND_RETURN_NULL(globalPose.isSane(), "PxPhysics::createRigidDynamic: invalid transform"); return NpFactory::getInstance().createRigidDynamic(globalPose.getNormalized()); } PxConstraint* NpPhysics::createConstraint(PxRigidActor* actor0, PxRigidActor* actor1, PxConstraintConnector& connector, const PxConstraintShaderTable& shaders, PxU32 dataSize) { return NpFactory::getInstance().createConstraint(actor0, actor1, connector, shaders, dataSize); } PxArticulationReducedCoordinate* NpPhysics::createArticulationReducedCoordinate() { return NpFactory::getInstance().createArticulationRC(); } PxSoftBody* NpPhysics::createSoftBody(PxCudaContextManager& cudaContextManager) { #if PX_SUPPORT_GPU_PHYSX return NpFactory::getInstance().createSoftBody(cudaContextManager); #else PX_UNUSED(cudaContextManager); return NULL; #endif } PxPBDParticleSystem* NpPhysics::createPBDParticleSystem(PxCudaContextManager& cudaContextManager, PxU32 maxNeighborhood) { #if PX_SUPPORT_GPU_PHYSX return NpFactory::getInstance().createPBDParticleSystem(maxNeighborhood, cudaContextManager); #else PX_UNUSED(cudaContextManager); PX_UNUSED(maxNeighborhood); return NULL; #endif } #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION && PX_SUPPORT_GPU_PHYSX PxFLIPParticleSystem* NpPhysics::createFLIPParticleSystem(PxCudaContextManager& cudaContextManager) { return NpFactory::getInstance().createFLIPParticleSystem(cudaContextManager); } PxMPMParticleSystem* NpPhysics::createMPMParticleSystem(PxCudaContextManager& cudaContextManager) { return NpFactory::getInstance().createMPMParticleSystem( cudaContextManager); } PxFEMCloth* NpPhysics::createFEMCloth(PxCudaContextManager& cudaContextManager) { return NpFactory::getInstance().createFEMCloth(cudaContextManager); } PxHairSystem* NpPhysics::createHairSystem(PxCudaContextManager& cudaContextManager) { return NpFactory::getInstance().createHairSystem(cudaContextManager); } #else PxFLIPParticleSystem* NpPhysics::createFLIPParticleSystem(PxCudaContextManager&) { return NULL; } PxMPMParticleSystem* NpPhysics::createMPMParticleSystem(PxCudaContextManager&) { return NULL; } PxFEMCloth* NpPhysics::createFEMCloth(PxCudaContextManager&) { return NULL; } PxHairSystem* NpPhysics::createHairSystem(PxCudaContextManager&) { return NULL; } #endif PxAggregate* NpPhysics::createAggregate(PxU32 maxActors, PxU32 maxShapes, PxAggregateFilterHint filterHint) { PX_CHECK_AND_RETURN_VAL(!(PxGetAggregateSelfCollisionBit(filterHint) && PxGetAggregateType(filterHint)==PxAggregateType::eSTATIC), "PxPhysics::createAggregate: static aggregates with self-collisions are not allowed.", NULL); return NpFactory::getInstance().createAggregate(maxActors, maxShapes, filterHint); } /////////////////////////////////////////////////////////////////////////////// template<class NpMaterialT> static NpMaterialT* addMaterial( #if PX_SUPPORT_OMNI_PVD NpPhysics::OmniPvdListener& mOmniPvdListener, #endif NpMaterialT* m, NpMaterialManager<NpMaterialT>& materialManager, PxMutex& mutex, PxArray<NpScene*>& sceneArray, const char* error) { if(!m) return NULL; OMNI_PVD_NOTIFY_ADD(m); PxMutex::ScopedLock lock(mutex); //the handle is set inside the setMaterial method if(materialManager.setMaterial(*m)) { // Let all scenes know of the new material const PxU32 nbScenes = sceneArray.size(); for(PxU32 i=0; i<nbScenes; i++) sceneArray[i]->addMaterial(*m); return m; } else { PxGetFoundation().error(PxErrorCode::eINVALID_PARAMETER, PX_FL, error); m->release(); return NULL; } } template<class NpMaterialT, class PxMaterialT> static PxU32 getMaterials(const NpMaterialManager<NpMaterialT>& materialManager, const PxMutex& mutex, PxMaterialT** userBuffer, PxU32 bufferSize, PxU32 startIndex) { PxMutex::ScopedLock lock(const_cast<PxMutex&>(mutex)); NpMaterialManagerIterator<NpMaterialT> iter(materialManager); PxU32 writeCount =0; PxU32 index = 0; NpMaterialT* mat; while(iter.getNextMaterial(mat)) { if(index++ < startIndex) continue; if(writeCount == bufferSize) break; userBuffer[writeCount++] = mat; } return writeCount; } template<class NpMaterialT> static void removeMaterialFromTable( #if PX_SUPPORT_OMNI_PVD NpPhysics::OmniPvdListener& mOmniPvdListener, #endif NpMaterialT& m, NpMaterialManager<NpMaterialT>& materialManager, PxMutex& mutex, PxArray<NpScene*>& sceneArray) { OMNI_PVD_NOTIFY_REMOVE(&m); PxMutex::ScopedLock lock(mutex); // Let all scenes know of the deleted material const PxU32 nbScenes = sceneArray.size(); for(PxU32 i=0; i<nbScenes; i++) sceneArray[i]->removeMaterial(m); materialManager.removeMaterial(m); } template<class NpMaterialT> static void updateMaterial(NpMaterialT& m, NpMaterialManager<NpMaterialT>& materialManager, PxMutex& mutex, PxArray<NpScene*>& sceneArray) { PxMutex::ScopedLock lock(mutex); // Let all scenes know of the updated material const PxU32 nbScenes = sceneArray.size(); for(PxU32 i=0; i<nbScenes; i++) sceneArray[i]->updateMaterial(m); materialManager.updateMaterial(m); } #if PX_SUPPORT_OMNI_PVD #define _addMaterial(p0, p1, p2, p3, p4) ::addMaterial(mOmniPvdListener, p0, p1, p2, p3, p4) #define _removeMaterialFromTable(p0, p1, p2, p3) ::removeMaterialFromTable(mOmniPvdListener, p0, p1, p2, p3) #else #define _addMaterial(p0, p1, p2, p3, p4) ::addMaterial(p0, p1, p2, p3, p4) #define _removeMaterialFromTable(p0, p1, p2, p3) ::removeMaterialFromTable(p0, p1, p2, p3) #endif #define IMPLEMENT_INTERNAL_MATERIAL_FUNCTIONS(NpMaterialT, manager, errorMsg) \ NpMaterialT* NpPhysics::addMaterial(NpMaterialT* m) \ { \ return _addMaterial(m, manager, mSceneAndMaterialMutex, mSceneArray, errorMsg); \ } \ void NpPhysics::removeMaterialFromTable(NpMaterialT& m) \ { \ _removeMaterialFromTable(m, manager, mSceneAndMaterialMutex, mSceneArray); \ } \ void NpPhysics::updateMaterial(NpMaterialT& m) \ { \ ::updateMaterial(m, manager, mSceneAndMaterialMutex, mSceneArray); \ } /////////////////////////////////////////////////////////////////////////////// template<class NpMaterialT> static void sendMaterialTable(NpScene& scene, const NpMaterialManager<NpMaterialT>& materialManager) { NpMaterialManagerIterator<NpMaterialT> iter(materialManager); NpMaterialT* mat; while(iter.getNextMaterial(mat)) scene.addMaterial(*mat); } bool NpPhysics::sendMaterialTable(NpScene& scene) { // note: no lock here because this method gets only called at scene creation and there we do lock ::sendMaterialTable(scene, mMasterMaterialManager); #if PX_SUPPORT_GPU_PHYSX ::sendMaterialTable(scene, mMasterFEMSoftBodyMaterialManager); ::sendMaterialTable(scene, mMasterPBDMaterialManager); #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION ::sendMaterialTable(scene, mMasterFEMClothMaterialManager); ::sendMaterialTable(scene, mMasterFLIPMaterialManager); ::sendMaterialTable(scene, mMasterMPMMaterialManager); #endif #endif return true; } /////////////////////////////////////////////////////////////////////////////// PxMaterial* NpPhysics::createMaterial(PxReal staticFriction, PxReal dynamicFriction, PxReal restitution) { PxMaterial* m = NpFactory::getInstance().createMaterial(staticFriction, dynamicFriction, restitution); return addMaterial(static_cast<NpMaterial*>(m)); } PxU32 NpPhysics::getNbMaterials() const { PxMutex::ScopedLock lock(const_cast<PxMutex&>(mSceneAndMaterialMutex)); return mMasterMaterialManager.getNumMaterials(); } PxU32 NpPhysics::getMaterials(PxMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex) const { return ::getMaterials(mMasterMaterialManager, mSceneAndMaterialMutex, userBuffer, bufferSize, startIndex); } IMPLEMENT_INTERNAL_MATERIAL_FUNCTIONS(NpMaterial, mMasterMaterialManager, "PxPhysics::createMaterial: limit of 64K materials reached.") /////////////////////////////////////////////////////////////////////////////// // PT: all the virtual functions that are unconditionally defined in the API / virtual interface cannot be compiled away entirely. // But the internal functions like addXXXX() can. #if PX_SUPPORT_GPU_PHYSX PxFEMSoftBodyMaterial* NpPhysics::createFEMSoftBodyMaterial(PxReal youngs, PxReal poissons, PxReal dynamicFriction) { PxFEMSoftBodyMaterial* m = NpFactory::getInstance().createFEMSoftBodyMaterial(youngs, poissons, dynamicFriction); return addMaterial(static_cast<NpFEMSoftBodyMaterial*>(m)); } PxU32 NpPhysics::getNbFEMSoftBodyMaterials() const { PxMutex::ScopedLock lock(const_cast<PxMutex&>(mSceneAndMaterialMutex)); return mMasterFEMSoftBodyMaterialManager.getNumMaterials(); } PxU32 NpPhysics::getFEMSoftBodyMaterials(PxFEMSoftBodyMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex) const { return ::getMaterials(mMasterFEMSoftBodyMaterialManager, mSceneAndMaterialMutex, userBuffer, bufferSize, startIndex); } IMPLEMENT_INTERNAL_MATERIAL_FUNCTIONS(NpFEMSoftBodyMaterial, mMasterFEMSoftBodyMaterialManager, "PxPhysics::createFEMSoftBodyMaterial: limit of 64K materials reached.") #else PxFEMSoftBodyMaterial* NpPhysics::createFEMSoftBodyMaterial(PxReal, PxReal, PxReal) { return NULL; } PxU32 NpPhysics::getNbFEMSoftBodyMaterials() const { return 0; } PxU32 NpPhysics::getFEMSoftBodyMaterials(PxFEMSoftBodyMaterial**, PxU32, PxU32) const { return 0; } #endif /////////////////////////////////////////////////////////////////////////////// #if PX_SUPPORT_GPU_PHYSX PxPBDMaterial* NpPhysics::createPBDMaterial(PxReal friction, PxReal damping, PxReal adhesion, PxReal viscosity, PxReal vorticityConfinement, PxReal surfaceTension, PxReal cohesion, PxReal lift, PxReal drag, PxReal cflCoefficient, PxReal gravityScale) { PxPBDMaterial* m = NpFactory::getInstance().createPBDMaterial(friction, damping, adhesion, viscosity, vorticityConfinement, surfaceTension, cohesion, lift, drag, cflCoefficient, gravityScale); return addMaterial(static_cast<NpPBDMaterial*>(m)); } PxU32 NpPhysics::getNbPBDMaterials() const { PxMutex::ScopedLock lock(const_cast<PxMutex&>(mSceneAndMaterialMutex)); return mMasterPBDMaterialManager.getNumMaterials(); } PxU32 NpPhysics::getPBDMaterials(PxPBDMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex) const { return ::getMaterials(mMasterPBDMaterialManager, mSceneAndMaterialMutex, userBuffer, bufferSize, startIndex); } IMPLEMENT_INTERNAL_MATERIAL_FUNCTIONS(NpPBDMaterial, mMasterPBDMaterialManager, "PxPhysics::createPBDMaterial: limit of 64K materials reached.") #else PxPBDMaterial* NpPhysics::createPBDMaterial(PxReal, PxReal, PxReal, PxReal, PxReal, PxReal, PxReal, PxReal, PxReal, PxReal, PxReal) { return NULL; } PxU32 NpPhysics::getNbPBDMaterials() const { return 0; } PxU32 NpPhysics::getPBDMaterials(PxPBDMaterial**, PxU32, PxU32) const { return 0; } #endif /////////////////////////////////////////////////////////////////////////////// #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION && PX_SUPPORT_GPU_PHYSX PxFEMClothMaterial* NpPhysics::createFEMClothMaterial(PxReal youngs, PxReal poissons, PxReal dynamicFriction, PxReal thickness) { PxFEMClothMaterial* m = NpFactory::getInstance().createFEMClothMaterial(youngs, poissons, dynamicFriction, thickness); return addMaterial(static_cast<NpFEMClothMaterial*>(m)); } PxU32 NpPhysics::getNbFEMClothMaterials() const { PxMutex::ScopedLock lock(const_cast<PxMutex&>(mSceneAndMaterialMutex)); return mMasterFEMClothMaterialManager.getNumMaterials(); } PxU32 NpPhysics::getFEMClothMaterials(PxFEMClothMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex) const { return ::getMaterials(mMasterFEMClothMaterialManager, mSceneAndMaterialMutex, userBuffer, bufferSize, startIndex); } IMPLEMENT_INTERNAL_MATERIAL_FUNCTIONS(NpFEMClothMaterial, mMasterFEMClothMaterialManager, "PxPhysics::createFEMClothMaterial: limit of 64K materials reached.") #else PxFEMClothMaterial* NpPhysics::createFEMClothMaterial(PxReal, PxReal, PxReal, PxReal) { return NULL; } PxU32 NpPhysics::getNbFEMClothMaterials() const { return 0; } PxU32 NpPhysics::getFEMClothMaterials(PxFEMClothMaterial**, PxU32, PxU32) const { return 0; } #endif /////////////////////////////////////////////////////////////////////////////// #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION && PX_SUPPORT_GPU_PHYSX PxFLIPMaterial* NpPhysics::createFLIPMaterial(PxReal friction, PxReal damping, PxReal maxVelocity, PxReal viscosity, PxReal gravityScale) { PxFLIPMaterial* m = NpFactory::getInstance().createFLIPMaterial(friction, damping, maxVelocity, viscosity, gravityScale); return addMaterial(static_cast<NpFLIPMaterial*>(m)); } PxU32 NpPhysics::getNbFLIPMaterials() const { PxMutex::ScopedLock lock(const_cast<PxMutex&>(mSceneAndMaterialMutex)); return mMasterFLIPMaterialManager.getNumMaterials(); } PxU32 NpPhysics::getFLIPMaterials(PxFLIPMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex) const { return ::getMaterials(mMasterFLIPMaterialManager, mSceneAndMaterialMutex, userBuffer, bufferSize, startIndex); } IMPLEMENT_INTERNAL_MATERIAL_FUNCTIONS(NpFLIPMaterial, mMasterFLIPMaterialManager, "PxPhysics::createFLIPMaterial: limit of 64K materials reached.") #else PxFLIPMaterial* NpPhysics::createFLIPMaterial(PxReal, PxReal, PxReal, PxReal, PxReal) { return NULL; } PxU32 NpPhysics::getNbFLIPMaterials() const { return 0; } PxU32 NpPhysics::getFLIPMaterials(PxFLIPMaterial**, PxU32, PxU32) const { return 0; } #endif /////////////////////////////////////////////////////////////////////////////// #if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION && PX_SUPPORT_GPU_PHYSX PxMPMMaterial* NpPhysics::createMPMMaterial(PxReal friction, PxReal damping, PxReal maxVelocity, bool isPlastic, PxReal youngsModulus, PxReal poissons, PxReal hardening, PxReal criticalCompression, PxReal criticalStretch, PxReal tensileDamageSensitivity, PxReal compressiveDamageSensitivity, PxReal attractiveForceResidual, PxReal gravityScale) { PxMPMMaterial* m = NpFactory::getInstance().createMPMMaterial(friction, damping, maxVelocity, isPlastic, youngsModulus, poissons, hardening, criticalCompression, criticalStretch, tensileDamageSensitivity, compressiveDamageSensitivity, attractiveForceResidual, gravityScale); return addMaterial(static_cast<NpMPMMaterial*>(m)); } PxU32 NpPhysics::getNbMPMMaterials() const { PxMutex::ScopedLock lock(const_cast<PxMutex&>(mSceneAndMaterialMutex)); return mMasterMPMMaterialManager.getNumMaterials(); } PxU32 NpPhysics::getMPMMaterials(PxMPMMaterial** userBuffer, PxU32 bufferSize, PxU32 startIndex) const { return ::getMaterials(mMasterMPMMaterialManager, mSceneAndMaterialMutex, userBuffer, bufferSize, startIndex); } IMPLEMENT_INTERNAL_MATERIAL_FUNCTIONS(NpMPMMaterial, mMasterMPMMaterialManager, "PxPhysics::createMPMMaterial: limit of 64K materials reached.") #else PxMPMMaterial* NpPhysics::createMPMMaterial(PxReal, PxReal, PxReal, bool, PxReal, PxReal, PxReal, PxReal, PxReal, PxReal, PxReal, PxReal, PxReal) { return NULL; } PxU32 NpPhysics::getNbMPMMaterials() const { return 0; } PxU32 NpPhysics::getMPMMaterials(PxMPMMaterial**, PxU32, PxU32) const { return 0; } #endif /////////////////////////////////////////////////////////////////////////////// PxTriangleMesh* NpPhysics::createTriangleMesh(PxInputStream& stream) { return NpFactory::getInstance().createTriangleMesh(stream); } PxU32 NpPhysics::getNbTriangleMeshes() const { return NpFactory::getInstance().getNbTriangleMeshes(); } PxU32 NpPhysics::getTriangleMeshes(PxTriangleMesh** userBuffer, PxU32 bufferSize, PxU32 startIndex) const { return NpFactory::getInstance().getTriangleMeshes(userBuffer, bufferSize, startIndex); } /////////////////////////////////////////////////////////////////////////////// PxTetrahedronMesh* NpPhysics::createTetrahedronMesh(PxInputStream& stream) { return NpFactory::getInstance().createTetrahedronMesh(stream); } PxU32 NpPhysics::getNbTetrahedronMeshes() const { return NpFactory::getInstance().getNbTetrahedronMeshes(); } PxU32 NpPhysics::getTetrahedronMeshes(PxTetrahedronMesh** userBuffer, PxU32 bufferSize, PxU32 startIndex) const { return NpFactory::getInstance().getTetrahedronMeshes(userBuffer, bufferSize, startIndex); } PxSoftBodyMesh* NpPhysics::createSoftBodyMesh(PxInputStream& stream) { return NpFactory::getInstance().createSoftBodyMesh(stream); } /////////////////////////////////////////////////////////////////////////////// PxHeightField* NpPhysics::createHeightField(PxInputStream& stream) { return NpFactory::getInstance().createHeightField(stream); } PxU32 NpPhysics::getNbHeightFields() const { return NpFactory::getInstance().getNbHeightFields(); } PxU32 NpPhysics::getHeightFields(PxHeightField** userBuffer, PxU32 bufferSize, PxU32 startIndex) const { return NpFactory::getInstance().getHeightFields(userBuffer, bufferSize, startIndex); } /////////////////////////////////////////////////////////////////////////////// PxConvexMesh* NpPhysics::createConvexMesh(PxInputStream& stream) { return NpFactory::getInstance().createConvexMesh(stream); } PxU32 NpPhysics::getNbConvexMeshes() const { return NpFactory::getInstance().getNbConvexMeshes(); } PxU32 NpPhysics::getConvexMeshes(PxConvexMesh** userBuffer, PxU32 bufferSize, PxU32 startIndex) const { return NpFactory::getInstance().getConvexMeshes(userBuffer, bufferSize, startIndex); } /////////////////////////////////////////////////////////////////////////////// PxBVH* NpPhysics::createBVH(PxInputStream& stream) { return NpFactory::getInstance().createBVH(stream); } PxU32 NpPhysics::getNbBVHs() const { return NpFactory::getInstance().getNbBVHs(); } PxU32 NpPhysics::getBVHs(PxBVH** userBuffer, PxU32 bufferSize, PxU32 startIndex) const { return NpFactory::getInstance().getBVHs(userBuffer, bufferSize, startIndex); } /////////////////////////////////////////////////////////////////////////////// #if PX_SUPPORT_GPU_PHYSX PxParticleBuffer* NpPhysics::createParticleBuffer(PxU32 maxParticles, PxU32 maxVolumes, PxCudaContextManager* cudaContextManager) { return NpFactory::getInstance().createParticleBuffer(maxParticles, maxVolumes, cudaContextManager); } PxParticleAndDiffuseBuffer* NpPhysics::createParticleAndDiffuseBuffer(PxU32 maxParticles, PxU32 maxVolumes, PxU32 maxDiffuseParticles, PxCudaContextManager* cudaContextManager) { return NpFactory::getInstance().createParticleAndDiffuseBuffer(maxParticles, maxVolumes, maxDiffuseParticles, cudaContextManager); } PxParticleClothBuffer* NpPhysics::createParticleClothBuffer(PxU32 maxParticles, PxU32 maxNumVolumes, PxU32 maxNumCloths, PxU32 maxNumTriangles, PxU32 maxNumSprings, PxCudaContextManager* cudaContextManager) { return NpFactory::getInstance().createParticleClothBuffer(maxParticles, maxNumVolumes, maxNumCloths, maxNumTriangles, maxNumSprings, cudaContextManager); } PxParticleRigidBuffer* NpPhysics::createParticleRigidBuffer(PxU32 maxParticles, PxU32 maxNumVolumes, PxU32 maxNumRigids, PxCudaContextManager* cudaContextManager) { return NpFactory::getInstance().createParticleRigidBuffer(maxParticles, maxNumVolumes, maxNumRigids, cudaContextManager); } #else PxParticleBuffer* NpPhysics::createParticleBuffer(PxU32, PxU32, PxCudaContextManager*) { return NULL; } PxParticleAndDiffuseBuffer* NpPhysics::createParticleAndDiffuseBuffer(PxU32, PxU32, PxU32, PxCudaContextManager*) { return NULL; } PxParticleClothBuffer* NpPhysics::createParticleClothBuffer(PxU32, PxU32, PxU32, PxU32, PxU32, PxCudaContextManager*) { return NULL; } PxParticleRigidBuffer* NpPhysics::createParticleRigidBuffer(PxU32, PxU32, PxU32, PxCudaContextManager*) { return NULL; } #endif /////////////////////////////////////////////////////////////////////////////// PxPruningStructure* NpPhysics::createPruningStructure(PxRigidActor*const* actors, PxU32 nbActors) { PX_SIMD_GUARD; PX_ASSERT(actors); PX_ASSERT(nbActors > 0); Sq::PruningStructure* ps = PX_NEW(Sq::PruningStructure)(); if(!ps->build(actors, nbActors)) { PX_DELETE(ps); } return ps; } /////////////////////////////////////////////////////////////////////////////// #if PX_SUPPORT_GPU_PHYSX void NpPhysics::registerPhysXIndicatorGpuClient() { PxMutex::ScopedLock lock(mPhysXIndicatorMutex); ++mNbRegisteredGpuClients; mPhysXIndicator.setIsGpu(mNbRegisteredGpuClients>0); } void NpPhysics::unregisterPhysXIndicatorGpuClient() { PxMutex::ScopedLock lock(mPhysXIndicatorMutex); if (mNbRegisteredGpuClients) --mNbRegisteredGpuClients; mPhysXIndicator.setIsGpu(mNbRegisteredGpuClients>0); } #endif /////////////////////////////////////////////////////////////////////////////// void NpPhysics::registerDeletionListener(PxDeletionListener& observer, const PxDeletionEventFlags& deletionEvents, bool restrictedObjectSet) { PxMutex::ScopedLock lock(mDeletionListenerMutex); const DeletionListenerMap::Entry* entry = mDeletionListenerMap.find(&observer); if(!entry) { NpDelListenerEntry* e = PX_NEW(NpDelListenerEntry)(deletionEvents, restrictedObjectSet); if (e) { if (mDeletionListenerMap.insert(&observer, e)) mDeletionListenersExist = true; else { PX_DELETE(e); PX_ALWAYS_ASSERT(); } } } else PX_ASSERT(mDeletionListenersExist); } void NpPhysics::unregisterDeletionListener(PxDeletionListener& observer) { PxMutex::ScopedLock lock(mDeletionListenerMutex); const DeletionListenerMap::Entry* entry = mDeletionListenerMap.find(&observer); if(entry) { NpDelListenerEntry* e = entry->second; mDeletionListenerMap.erase(&observer); PX_DELETE(e); } mDeletionListenersExist = mDeletionListenerMap.size()>0; } void NpPhysics::registerDeletionListenerObjects(PxDeletionListener& observer, const PxBase* const* observables, PxU32 observableCount) { PxMutex::ScopedLock lock(mDeletionListenerMutex); const DeletionListenerMap::Entry* entry = mDeletionListenerMap.find(&observer); if(entry) { NpDelListenerEntry* e = entry->second; PX_CHECK_AND_RETURN(e->restrictedObjectSet, "PxPhysics::registerDeletionListenerObjects: deletion listener is not configured to receive events from specific objects."); e->registeredObjects.reserve(e->registeredObjects.size() + observableCount); for(PxU32 i=0; i < observableCount; i++) e->registeredObjects.insert(observables[i]); } else { PX_CHECK_AND_RETURN(false, "PxPhysics::registerDeletionListenerObjects: deletion listener has to be registered in PxPhysics first."); } } void NpPhysics::unregisterDeletionListenerObjects(PxDeletionListener& observer, const PxBase* const* observables, PxU32 observableCount) { PxMutex::ScopedLock lock(mDeletionListenerMutex); const DeletionListenerMap::Entry* entry = mDeletionListenerMap.find(&observer); if(entry) { NpDelListenerEntry* e = entry->second; if (e->restrictedObjectSet) { for(PxU32 i=0; i < observableCount; i++) e->registeredObjects.erase(observables[i]); } else { PX_CHECK_AND_RETURN(false, "PxPhysics::unregisterDeletionListenerObjects: deletion listener is not configured to receive events from specific objects."); } } else { PX_CHECK_AND_RETURN(false, "PxPhysics::unregisterDeletionListenerObjects: deletion listener has to be registered in PxPhysics first."); } } void NpPhysics::notifyDeletionListeners(const PxBase* base, void* userData, PxDeletionEventFlag::Enum deletionEvent) { // we don't protect the check for whether there are any listeners, because we don't want to take a hit in the // common case where there are no listeners. Note the API comments here, that users should not register or // unregister deletion listeners while deletions are occurring if(mDeletionListenersExist) { PxMutex::ScopedLock lock(mDeletionListenerMutex); const DeletionListenerMap::Entry* delListenerEntries = mDeletionListenerMap.getEntries(); const PxU32 delListenerEntryCount = mDeletionListenerMap.size(); for(PxU32 i=0; i < delListenerEntryCount; i++) { const NpDelListenerEntry* entry = delListenerEntries[i].second; if (entry->flags & deletionEvent) { if (entry->restrictedObjectSet) { if (entry->registeredObjects.contains(base)) delListenerEntries[i].first->onRelease(base, userData, deletionEvent); } else delListenerEntries[i].first->onRelease(base, userData, deletionEvent); } } } } #if PX_SUPPORT_OMNI_PVD void NpPhysics::OmniPvdListener::onObjectAdd(const PxBase* object) { ::OmniPvdPxSampler::getInstance()->onObjectAdd(*object); } void NpPhysics::OmniPvdListener::onObjectRemove(const PxBase* object) { ::OmniPvdPxSampler::getInstance()->onObjectRemove(*object); } #endif /////////////////////////////////////////////////////////////////////////////// const PxTolerancesScale& NpPhysics::getTolerancesScale() const { return mPhysics.getTolerancesScale(); } PxFoundation& NpPhysics::getFoundation() { return mFoundation; } PxPhysics& PxGetPhysics() { return NpPhysics::getInstance(); } PxPhysics* PxCreatePhysics(PxU32 version, PxFoundation& foundation, const physx::PxTolerancesScale& scale, bool trackOutstandingAllocations, PxPvd* pvd, PxOmniPvd* omniPvd) { return NpPhysics::createInstance(version, foundation, scale, trackOutstandingAllocations, static_cast<pvdsdk::PsPvd*>(pvd), omniPvd); } void PxAddCollectionToPhysics(const PxCollection& collection) { NpFactory& factory = NpFactory::getInstance(); const Cm::Collection& c = static_cast<const Cm::Collection&>(collection); factory.addCollection(c); }
44,227
C++
35.918197
345
0.749384
NVIDIA-Omniverse/PhysX/physx/source/physx/src/NpCheck.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #include "NpCheck.h" #include "NpScene.h" using namespace physx; NpReadCheck::NpReadCheck(const NpScene* scene, const char* functionName) : mScene(scene), mName(functionName), mErrorCount(0) { if(mScene) { if(!mScene->startRead()) { if(mScene->getScScene().getFlags() & PxSceneFlag::eREQUIRE_RW_LOCK) { PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "An API read call (%s) was made from thread %d but PxScene::lockRead() was not called first, note that " "when PxSceneFlag::eREQUIRE_RW_LOCK is enabled all API reads and writes must be " "wrapped in the appropriate locks.", mName, PxU32(PxThread::getId())); } else { PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "Overlapping API read and write call detected during %s from thread %d! Note that read operations to " "the SDK must not be overlapped with write calls, else the resulting behavior is undefined.", mName, PxU32(PxThread::getId())); } } // Record the NpScene read/write error counter which is // incremented any time a NpScene::startWrite/startRead fails // (see destructor for additional error checking based on this count) mErrorCount = mScene->getReadWriteErrorCount(); } } NpReadCheck::~NpReadCheck() { if(mScene) { // By checking if the NpScene::mConcurrentErrorCount has been incremented // we can detect if an erroneous read/write was performed during // this objects lifetime. In this case we also print this function's // details so that the user can see which two API calls overlapped if(mScene->getReadWriteErrorCount() != mErrorCount && !(mScene->getScScene().getFlags() & PxSceneFlag::eREQUIRE_RW_LOCK)) { PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "Leaving %s on thread %d, an API overlapping write on another thread was detected.", mName, PxU32(PxThread::getId())); } mScene->stopRead(); } } NpWriteCheck::NpWriteCheck(NpScene* scene, const char* functionName, bool allowReentry) : mScene(scene), mName(functionName), mAllowReentry(allowReentry), mErrorCount(0) { if(mScene) { switch(mScene->startWrite(mAllowReentry)) { case NpScene::StartWriteResult::eOK: break; case NpScene::StartWriteResult::eNO_LOCK: PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "An API write call (%s) was made from thread %d but PxScene::lockWrite() was not called first, note that " "when PxSceneFlag::eREQUIRE_RW_LOCK is enabled all API reads and writes must be " "wrapped in the appropriate locks.", mName, PxU32(PxThread::getId())); break; case NpScene::StartWriteResult::eRACE_DETECTED: PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "Concurrent API write call or overlapping API read and write call detected during %s from thread %d! " "Note that write operations to the SDK must be sequential, i.e., no overlap with " "other write or read calls, else the resulting behavior is undefined. " "Also note that API writes during a callback function are not permitted.", mName, PxU32(PxThread::getId())); break; case NpScene::StartWriteResult::eIN_FETCHRESULTS: PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "Illegal write call detected in %s from thread %d during split fetchResults! " "Note that write operations to the SDK are not permitted between the start of fetchResultsStart() and end of fetchResultsFinish(). " "Behavior will be undefined. ", mName, PxU32(PxThread::getId())); break; } // Record the NpScene read/write error counter which is // incremented any time a NpScene::startWrite/startRead fails // (see destructor for additional error checking based on this count) mErrorCount = mScene->getReadWriteErrorCount(); } } NpWriteCheck::~NpWriteCheck() { if(mScene) { // By checking if the NpScene::mConcurrentErrorCount has been incremented // we can detect if an erroneous read/write was performed during // this objects lifetime. In this case we also print this function's // details so that the user can see which two API calls overlapped if(mScene->getReadWriteErrorCount() != mErrorCount && !(mScene->getScScene().getFlags() & PxSceneFlag::eREQUIRE_RW_LOCK)) { PxGetFoundation().error(PxErrorCode::eINVALID_OPERATION, PX_FL, "Leaving %s on thread %d, an overlapping API read or write by another thread was detected.", mName, PxU32(PxThread::getId())); } mScene->stopWrite(mAllowReentry); } }
6,191
C++
45.208955
169
0.737684
NVIDIA-Omniverse/PhysX/physx/source/physx/src/windows/NpWindowsDelayLoadHook.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #include "common/windows/PxWindowsDelayLoadHook.h" #include "foundation/windows/PxWindowsInclude.h" #include "windows/CmWindowsLoadLibrary.h" namespace physx { static const PxDelayLoadHook* gPhysXDelayLoadHook = NULL; void PxSetPhysXDelayLoadHook(const PxDelayLoadHook* hook) { gPhysXDelayLoadHook = hook; } } // delay loading is enabled only for non static configuration #if !defined PX_PHYSX_STATIC_LIB // Prior to Visual Studio 2015 Update 3, these hooks were non-const. #define DELAYIMP_INSECURE_WRITABLE_HOOKS #include <delayimp.h> using namespace physx; #pragma comment(lib, "delayimp") FARPROC WINAPI physxDelayHook(unsigned dliNotify, PDelayLoadInfo pdli) { switch (dliNotify) { case dliStartProcessing : break; case dliNotePreLoadLibrary : { return Cm::physXCommonDliNotePreLoadLibrary(pdli->szDll,gPhysXDelayLoadHook); } break; case dliNotePreGetProcAddress : break; case dliFailLoadLib : break; case dliFailGetProc : break; case dliNoteEndProcessing : break; default : return NULL; } return NULL; } PfnDliHook __pfnDliNotifyHook2 = physxDelayHook; #endif
2,821
C++
30.355555
80
0.76604
NVIDIA-Omniverse/PhysX/physx/source/physx/src/omnipvd/NpOmniPvd.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #include "NpOmniPvd.h" #if PX_SUPPORT_OMNI_PVD #include "OmniPvdPxSampler.h" #include "OmniPvdLoader.h" #include "OmniPvdFileWriteStream.h" #endif #include "foundation/PxUserAllocated.h" physx::PxU32 physx::NpOmniPvd::mRefCount = 0; physx::NpOmniPvd* physx::NpOmniPvd::mInstance = NULL; namespace physx { NpOmniPvd::NpOmniPvd() : mLoader (NULL), mFileWriteStream(NULL), mWriter (NULL), mPhysXSampler (NULL) { } NpOmniPvd::~NpOmniPvd() { #if PX_SUPPORT_OMNI_PVD if (mFileWriteStream) { mFileWriteStream->closeStream(); mLoader->mDestroyOmniPvdFileWriteStream(*mFileWriteStream); mFileWriteStream = NULL; } if (mWriter) { mLoader->mDestroyOmniPvdWriter(*mWriter); mWriter = NULL; } if (mLoader) { mLoader->~OmniPvdLoader(); PX_FREE(mLoader); mLoader = NULL; } #endif } void NpOmniPvd::destroyInstance() { PX_ASSERT(mInstance != NULL); if (mInstance->mRefCount == 1) { mInstance->~NpOmniPvd(); PX_FREE(mInstance); mInstance = NULL; } } // Called once by physx::PxOmniPvd* PxCreateOmniPvd(...) // Called once by NpPhysics::NpPhysics(...) void NpOmniPvd::incRefCount() { PX_ASSERT(mInstance != NULL); NpOmniPvd::mRefCount++; } // Called once by the Physics destructor in NpPhysics::~NpPhysics(...) void NpOmniPvd::decRefCount() { PX_ASSERT(mInstance != NULL); if (NpOmniPvd::mRefCount > 0) { NpOmniPvd::mRefCount--; } } void NpOmniPvd::release() { NpOmniPvd::destroyInstance(); } bool NpOmniPvd::initOmniPvd() { #if PX_SUPPORT_OMNI_PVD if (mLoader) { return true; } mLoader = PX_PLACEMENT_NEW(PX_ALLOC(sizeof(OmniPvdLoader), "OmniPvdLoader"), OmniPvdLoader)(); if (!mLoader) { return false; } bool success; #if PX_WIN64 success = mLoader->loadOmniPvd("PVDRuntime_64.dll"); #else success = mLoader->loadOmniPvd("libPVDRuntime_64.so"); #endif return success; #else return true; #endif } OmniPvdWriter* NpOmniPvd::getWriter() { return blockingWriterLoad(); } OmniPvdWriter* NpOmniPvd::blockingWriterLoad() { #if PX_SUPPORT_OMNI_PVD PxMutex::ScopedLock lock(mWriterLoadMutex); if (mWriter) { return mWriter; } if (mLoader == NULL) { return NULL; } mWriter = mLoader->mCreateOmniPvdWriter(); return mWriter; #else return NULL; #endif } OmniPvdWriter* NpOmniPvd::acquireExclusiveWriterAccess() { #if PX_SUPPORT_OMNI_PVD mMutex.lock(); return blockingWriterLoad(); #else return NULL; #endif } void NpOmniPvd::releaseExclusiveWriterAccess() { #if PX_SUPPORT_OMNI_PVD mMutex.unlock(); #endif } OmniPvdFileWriteStream* NpOmniPvd::getFileWriteStream() { #if PX_SUPPORT_OMNI_PVD if (mFileWriteStream) { return mFileWriteStream; } if (mLoader == NULL) { return NULL; } mFileWriteStream = mLoader->mCreateOmniPvdFileWriteStream(); return mFileWriteStream; #else return NULL; #endif } bool NpOmniPvd::startSampling() { #if PX_SUPPORT_OMNI_PVD if (mPhysXSampler) { mPhysXSampler->startSampling(); return true; } return false; #else return false; #endif } } physx::PxOmniPvd* PxCreateOmniPvd(physx::PxFoundation& foundation) { PX_UNUSED(foundation); #if PX_SUPPORT_OMNI_PVD if (physx::NpOmniPvd::mInstance) { // No need to call this function again //foundation.getErrorCallback() return physx::NpOmniPvd::mInstance; } physx::NpOmniPvd::mInstance = PX_PLACEMENT_NEW(PX_ALLOC(sizeof(physx::NpOmniPvd), "NpOmniPvd"), physx::NpOmniPvd)(); if (physx::NpOmniPvd::mInstance) { if (physx::NpOmniPvd::mInstance->initOmniPvd()) { physx::NpOmniPvd::mRefCount = 1; // Sets the reference counter to exactly 1 return physx::NpOmniPvd::mInstance; } else { physx::NpOmniPvd::mInstance->~NpOmniPvd(); PX_FREE(physx::NpOmniPvd::mInstance); physx::NpOmniPvd::mInstance = NULL; physx::NpOmniPvd::mRefCount = 0; return NULL; } } else { return NULL; } #else return NULL; #endif }
5,663
C++
21.83871
117
0.708105
NVIDIA-Omniverse/PhysX/physx/source/physx/src/omnipvd/NpOmniPvdRegistrationData.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef NP_OMNI_PVD_REGISTRATION_DATA_H #define NP_OMNI_PVD_REGISTRATION_DATA_H #if PX_SUPPORT_OMNI_PVD #include "OmniPvdWriter.h" #include "foundation/PxSimpleTypes.h" #include "foundation/PxVec3.h" #include "foundation/PxTransform.h" #include "foundation/PxBounds3.h" #include "PxSceneDesc.h" // for PxgDynamicsMemoryConfig #include "PxActor.h"// for PxDominanceGroup #include "PxClient.h" // for PxClientID #include "PxMaterial.h" // for PxMaterialFlags, PxCombineMode #include "PxRigidBody.h" // for PxRigidBodyFlags #include "PxRigidDynamic.h" // for PxRigidDynamicLockFlags #include "PxShape.h" // for PxShapeFlags #include "solver/PxSolverDefs.h" // for PxArticulationMotion #include "geometry/PxCustomGeometry.h" // for PxCustomGeometry::Callbacks namespace physx { class PxAggregate; class PxArticulationJointReducedCoordinate; class PxArticulationReducedCoordinate; class PxBaseMaterial; class PxBoxGeometry; class PxBVH; class PxCapsuleGeometry; class PxConvexMesh; class PxConvexMeshGeometry; class PxFEMClothMaterial; class PxFEMSoftBodyMaterial; class PxFLIPMaterial; class PxGeometry; class PxHeightField; class PxHeightFieldGeometry; class PxMPMMaterial; class PxPBDMaterial; class PxPhysics; class PxPlaneGeometry; class PxRigidActor; class PxRigidStatic; class PxScene; class PxSoftBodyMesh; class PxSphereGeometry; class PxTetrahedronMesh; class PxTetrahedronMeshGeometry; class PxTolerancesScale; class PxTriangleMesh; class PxTriangleMeshGeometry; struct OmniPvdPxCoreRegistrationData { void registerData(OmniPvdWriter&); // auto-generate members and setter methods from object definition file #include "omnipvd/CmOmniPvdAutoGenCreateRegistrationStruct.h" #include "OmniPvdTypes.h" #include "omnipvd/CmOmniPvdAutoGenClearDefines.h" }; } #endif // PX_SUPPORT_OMNI_PVD #endif // NP_OMNI_PVD_REGISTRATION_DATA_H
3,554
C
33.852941
74
0.791221
NVIDIA-Omniverse/PhysX/physx/source/physx/src/omnipvd/OmniPvdChunkAlloc.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #include "OmniPvdChunkAlloc.h" #include <string.h> // memcpy #include "foundation/PxAllocator.h" OmniPvdChunkElement::OmniPvdChunkElement() { } OmniPvdChunkElement::~OmniPvdChunkElement() { } OmniPvdChunk::OmniPvdChunk() : mData (NULL), mNbrBytesAllocated (0), mNbrBytesFree (0), mBytePtr (NULL), mNextChunk (NULL) { } OmniPvdChunk::~OmniPvdChunk() { PX_FREE(mData); } void OmniPvdChunk::resetChunk(int nbrBytes) { if (nbrBytes>mNbrBytesAllocated) { PX_FREE(mData); mData = static_cast<unsigned char*>(PX_ALLOC(sizeof(unsigned char)*(nbrBytes), "m_data")); mNbrBytesAllocated=nbrBytes; } mNbrBytesFree=mNbrBytesAllocated; mBytePtr=mData; } int OmniPvdChunk::nbrBytesUSed() { return mNbrBytesAllocated-mNbrBytesFree; } OmniPvdChunkList::OmniPvdChunkList() { resetList(); } OmniPvdChunkList::~OmniPvdChunkList() { } void OmniPvdChunkList::resetList() { mFirstChunk=0; mLastChunk=0; mNbrChunks=0; } OmniPvdChunk* OmniPvdChunkList::removeFirst() { if (mFirstChunk) { OmniPvdChunk* chunk=mFirstChunk; mFirstChunk=mFirstChunk->mNextChunk; if (!mFirstChunk) { // Did we remove the last one? mLastChunk=NULL; } chunk->mNextChunk=NULL; mNbrChunks--; return chunk; } else { return 0; } } void OmniPvdChunkList::appendList(OmniPvdChunkList* list) { if (!list) return; if (list->mNbrChunks==0) return; if (list->mFirstChunk==NULL) return; if (mFirstChunk) { mLastChunk->mNextChunk=list->mFirstChunk; mLastChunk=list->mLastChunk; } else { mFirstChunk=list->mFirstChunk; mLastChunk=list->mLastChunk; } mNbrChunks+=list->mNbrChunks; list->resetList(); } void OmniPvdChunkList::appendChunk(OmniPvdChunk* chunk) { if (!chunk) return; if (mFirstChunk) { mLastChunk->mNextChunk=chunk; mLastChunk=chunk; } else { mFirstChunk=chunk; mLastChunk=chunk; } chunk->mNextChunk=NULL; mNbrChunks++; } OmniPvdChunkPool::OmniPvdChunkPool() { mNbrAllocatedChunks = 0; mChunkSize = 65536; // random default value :-) } OmniPvdChunkPool::~OmniPvdChunkPool() { OmniPvdChunk* chunk=mFreeChunks.mFirstChunk; while (chunk) { OmniPvdChunk* nextChunk=chunk->mNextChunk; PX_DELETE(chunk); chunk=nextChunk; } mNbrAllocatedChunks = 0; } void OmniPvdChunkPool::setChunkSize(int chunkSize) { if (mNbrAllocatedChunks > 0) return; // makes it impossible to re-set the size of a chunk once a chunk was already allocated mChunkSize = chunkSize; } OmniPvdChunk* OmniPvdChunkPool::getChunk() { OmniPvdChunk* chunk=mFreeChunks.removeFirst(); if (!chunk) { chunk= PX_NEW(OmniPvdChunk); mNbrAllocatedChunks++; } chunk->resetChunk(mChunkSize); return chunk; } OmniPvdChunkByteAllocator::OmniPvdChunkByteAllocator() { mPool = NULL; } OmniPvdChunkByteAllocator::~OmniPvdChunkByteAllocator() { freeChunks(); } OmniPvdChunkElement* OmniPvdChunkByteAllocator::allocChunkElement(int totalStructSize) { return reinterpret_cast<OmniPvdChunkElement*>(allocBytes(totalStructSize)); } void OmniPvdChunkByteAllocator::setPool(OmniPvdChunkPool* pool) { mPool = pool; } unsigned char* OmniPvdChunkByteAllocator::allocBytes(int nbrBytes) { if (!mPool) return 0; if (mPool->mChunkSize < nbrBytes) { return 0; // impossible request! } if (mUsedChunks.mLastChunk) { // If a chunk is free if (mUsedChunks.mLastChunk->mNbrBytesFree< nbrBytes) { // The last chunk has not enough space, so get a fresh one from the pool mUsedChunks.appendChunk(mPool->getChunk()); } } else { // No last chunk is available, allocate a fresh one mUsedChunks.appendChunk(mPool->getChunk()); } // Use the last chunk to allocate the data necessary unsigned char* pSubChunk=mUsedChunks.mLastChunk->mBytePtr; mUsedChunks.mLastChunk->mNbrBytesFree-= nbrBytes; mUsedChunks.mLastChunk->mBytePtr+= nbrBytes; return pSubChunk; } void OmniPvdChunkByteAllocator::freeChunks() { if (!mPool) return; mPool->mFreeChunks.appendList(&mUsedChunks); }
5,619
C++
23.541485
125
0.745862
NVIDIA-Omniverse/PhysX/physx/source/physx/src/omnipvd/NpOmniPvdRegistrationData.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #include "NpOmniPvdRegistrationData.h" #if PX_SUPPORT_OMNI_PVD namespace physx { void OmniPvdPxCoreRegistrationData::registerData(OmniPvdWriter& writer) { // auto-generate class/attribute registration code from object definition file #define OMNI_PVD_WRITER_VAR writer #include "omnipvd/CmOmniPvdAutoGenRegisterData.h" #include "OmniPvdTypes.h" #include "omnipvd/CmOmniPvdAutoGenClearDefines.h" #undef OMNI_PVD_WRITER_VAR } } #endif
2,139
C++
40.960784
79
0.774194
NVIDIA-Omniverse/PhysX/physx/source/physx/src/omnipvd/OmniPvdPxSampler.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #if PX_SUPPORT_OMNI_PVD #include <stdio.h> #include "foundation/PxPreprocessor.h" #include "foundation/PxAllocator.h" #include "ScIterators.h" #include "omnipvd/NpOmniPvd.h" #include "OmniPvdPxSampler.h" #include "OmniPvdWriteStream.h" #include "NpOmniPvdSetData.h" #include "NpPhysics.h" #include "NpScene.h" #include "NpAggregate.h" #include "NpRigidStatic.h" #include "NpArticulationJointReducedCoordinate.h" #include "NpArticulationLink.h" using namespace physx; class OmniPvdStreamContainer { public: OmniPvdStreamContainer(); ~OmniPvdStreamContainer(); bool initOmniPvd(); void registerClasses(); void setOmniPvdInstance(NpOmniPvd* omniPvdInstance); NpOmniPvd* mOmniPvdInstance; physx::PxMutex mMutex; OmniPvdPxCoreRegistrationData mRegistrationData; bool mClassesRegistered; }; class OmniPvdSamplerInternals : public physx::PxUserAllocated { public: OmniPvdStreamContainer mPvdStream; bool addSharedMeshIfNotSeen(const void* geom, OmniPvdSharedMeshEnum geomEnum); // Returns true if the Geom was not yet seen and added physx::PxMutex mSampleMutex; bool mIsSampling; physx::PxMutex mSampledScenesMutex; physx::PxHashMap<physx::NpScene*, OmniPvdPxScene*> mSampledScenes; physx::PxMutex mSharedGeomsMutex; physx::PxHashMap<const void*, OmniPvdSharedMeshEnum> mSharedMeshesMap; }; OmniPvdSamplerInternals * samplerInternals = NULL; class OmniPvdPxScene : public physx::PxUserAllocated { public: OmniPvdPxScene() : mFrameId(0) {} ~OmniPvdPxScene() {} void sampleScene() { mFrameId++; samplerInternals->mPvdStream.mOmniPvdInstance->getWriter()->startFrame(OMNI_PVD_CONTEXT_HANDLE, mFrameId); } physx::PxU64 mFrameId; }; OmniPvdStreamContainer::OmniPvdStreamContainer() { physx::PxMutex::ScopedLock myLock(mMutex); mClassesRegistered = false; mOmniPvdInstance = NULL; } OmniPvdStreamContainer::~OmniPvdStreamContainer() { } void OmniPvdStreamContainer::setOmniPvdInstance(NpOmniPvd* omniPvdInstance) { mOmniPvdInstance = omniPvdInstance; } bool OmniPvdStreamContainer::initOmniPvd() { physx::PxMutex::ScopedLock myLock(mMutex); registerClasses(); PxPhysics& physicsRef = static_cast<PxPhysics&>(NpPhysics::getInstance()); OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) OMNI_PVD_CREATE_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxPhysics, physicsRef); const physx::PxTolerancesScale& tolScale = physicsRef.getTolerancesScale(); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxPhysics, tolerancesScale, physicsRef, tolScale); OMNI_PVD_WRITE_SCOPE_END return true; } void OmniPvdStreamContainer::registerClasses() { if (mClassesRegistered) return; OmniPvdWriter* writer = mOmniPvdInstance->acquireExclusiveWriterAccess(); if (writer) { mRegistrationData.registerData(*writer); mClassesRegistered = true; } mOmniPvdInstance->releaseExclusiveWriterAccess(); } int streamStringLength(const char* name) { #if PX_SUPPORT_OMNI_PVD if (NpPhysics::getInstance().mOmniPvdSampler == NULL) { return 0; } if (name == NULL) { return 0; } int len = static_cast<int>(strlen(name)); if (len > 0) { return len; } else { return 0; } #else return 0; #endif } void streamActorName(const physx::PxActor & a, const char* name) { #if PX_SUPPORT_OMNI_PVD int strLen = streamStringLength(name); if (strLen) { OMNI_PVD_SET_ARRAY(OMNI_PVD_CONTEXT_HANDLE, PxActor, name, a, name, strLen + 1); // copies over the trailing zero too } #endif } void streamSceneName(const physx::PxScene & s, const char* name) { #if PX_SUPPORT_OMNI_PVD int strLen = streamStringLength(name); if (strLen) { OMNI_PVD_SET_ARRAY(OMNI_PVD_CONTEXT_HANDLE, PxScene, name, s, name, strLen + 1); // copies over the trailing zero too } #endif } void streamSphereGeometry(const physx::PxSphereGeometry& g) { OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) OMNI_PVD_CREATE_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxSphereGeometry, g); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxSphereGeometry, radius, g, g.radius); OMNI_PVD_WRITE_SCOPE_END } void streamCapsuleGeometry(const physx::PxCapsuleGeometry& g) { OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) OMNI_PVD_CREATE_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxCapsuleGeometry, g); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxCapsuleGeometry, halfHeight, g, g.halfHeight); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxCapsuleGeometry, radius, g, g.radius); OMNI_PVD_WRITE_SCOPE_END } void streamBoxGeometry(const physx::PxBoxGeometry& g) { OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) OMNI_PVD_CREATE_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxBoxGeometry, g); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxBoxGeometry, halfExtents, g, g.halfExtents); OMNI_PVD_WRITE_SCOPE_END } void streamPlaneGeometry(const physx::PxPlaneGeometry& g) { OMNI_PVD_CREATE(OMNI_PVD_CONTEXT_HANDLE, PxPlaneGeometry, g); } void streamCustomGeometry(const physx::PxCustomGeometry& g) { OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) OMNI_PVD_CREATE_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxCustomGeometry, g); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxCustomGeometry, callbacks, g, g.callbacks); OMNI_PVD_WRITE_SCOPE_END } void streamConvexMesh(const physx::PxConvexMesh& mesh) { if (samplerInternals->addSharedMeshIfNotSeen(&mesh, OmniPvdSharedMeshEnum::eOmniPvdConvexMesh)) { OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) OMNI_PVD_CREATE_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxConvexMesh, mesh); const PxU32 nbPolys = mesh.getNbPolygons(); const PxU8* polygons = mesh.getIndexBuffer(); const PxVec3* verts = mesh.getVertices(); const PxU32 nbrVerts = mesh.getNbVertices(); PxU32 totalTris = 0; for (PxU32 i = 0; i < nbPolys; i++) { physx::PxHullPolygon data; mesh.getPolygonData(i, data); totalTris += data.mNbVerts - 2; } float* tmpVerts = (float*)PX_ALLOC(sizeof(float)*(nbrVerts * 3), "tmpVerts"); PxU32* tmpIndices = (PxU32*)PX_ALLOC(sizeof(PxU32)*(totalTris * 3), "tmpIndices"); //TODO: this copy is useless PxU32 vertIndex = 0; for (PxU32 v = 0; v < nbrVerts; v++) { tmpVerts[vertIndex + 0] = verts[v].x; tmpVerts[vertIndex + 1] = verts[v].y; tmpVerts[vertIndex + 2] = verts[v].z; vertIndex += 3; } PxU32 triIndex = 0; for (PxU32 p = 0; p < nbPolys; p++) { physx::PxHullPolygon data; mesh.getPolygonData(p, data); PxU32 nbTris = data.mNbVerts - 2; const PxU32 vref0 = polygons[data.mIndexBase + 0 + 0]; for (PxU32 t = 0; t < nbTris; t++) { const PxU32 vref1 = polygons[data.mIndexBase + t + 1]; const PxU32 vref2 = polygons[data.mIndexBase + t + 2]; tmpIndices[triIndex + 0] = vref0; tmpIndices[triIndex + 1] = vref1; tmpIndices[triIndex + 2] = vref2; triIndex += 3; } } OMNI_PVD_SET_ARRAY_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxConvexMesh, verts, mesh, tmpVerts, 3 * nbrVerts); OMNI_PVD_SET_ARRAY_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxConvexMesh, tris, mesh, tmpIndices, 3 * totalTris); PX_FREE(tmpVerts); PX_FREE(tmpIndices); OMNI_PVD_WRITE_SCOPE_END } } void streamConvexMeshGeometry(const physx::PxConvexMeshGeometry& g) { OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) OMNI_PVD_CREATE_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxConvexMeshGeometry, g); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxConvexMeshGeometry, scale, g, g.scale.scale); streamConvexMesh(*g.convexMesh); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxConvexMeshGeometry, convexMesh, g, g.convexMesh); OMNI_PVD_WRITE_SCOPE_END } void streamHeightField(const physx::PxHeightField& hf) { if (samplerInternals->addSharedMeshIfNotSeen(&hf, OmniPvdSharedMeshEnum::eOmniPvdHeightField)) { OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) OMNI_PVD_CREATE_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxHeightField, hf); const PxU32 nbCols = hf.getNbColumns(); const PxU32 nbRows = hf.getNbRows(); const PxU32 nbVerts = nbRows * nbCols; const PxU32 nbFaces = (nbCols - 1) * (nbRows - 1) * 2; physx::PxHeightFieldSample* sampleBuffer = (physx::PxHeightFieldSample*)PX_ALLOC(sizeof(physx::PxHeightFieldSample)*(nbVerts), "sampleBuffer"); hf.saveCells(sampleBuffer, nbVerts * sizeof(physx::PxHeightFieldSample)); //TODO: are the copies necessary? float* tmpVerts = (float*)PX_ALLOC(sizeof(float)*(nbVerts * 3), "tmpVerts"); PxU32* tmpIndices = (PxU32*)PX_ALLOC(sizeof(PxU32)*(nbFaces * 3), "tmpIndices"); for (PxU32 i = 0; i < nbRows; i++) { for (PxU32 j = 0; j < nbCols; j++) { const float x = PxReal(i);// *rs; const float y = PxReal(sampleBuffer[j + (i*nbCols)].height);// *hs; const float z = PxReal(j);// *cs; const PxU32 vertexIndex = 3 * (i * nbCols + j); float* vert = &tmpVerts[vertexIndex]; vert[0] = x; vert[1] = y; vert[2] = z; } } for (PxU32 i = 0; i < (nbCols - 1); ++i) { for (PxU32 j = 0; j < (nbRows - 1); ++j) { PxU8 tessFlag = sampleBuffer[i + j * nbCols].tessFlag(); PxU32 i0 = j * nbCols + i; PxU32 i1 = j * nbCols + i + 1; PxU32 i2 = (j + 1) * nbCols + i; PxU32 i3 = (j + 1) * nbCols + i + 1; // i2---i3 // | | // | | // i0---i1 // this is really a corner vertex index, not triangle index PxU32 mat0 = hf.getTriangleMaterialIndex((j*nbCols + i) * 2); PxU32 mat1 = hf.getTriangleMaterialIndex((j*nbCols + i) * 2 + 1); bool hole0 = (mat0 == PxHeightFieldMaterial::eHOLE); bool hole1 = (mat1 == PxHeightFieldMaterial::eHOLE); // first triangle tmpIndices[6 * (i * (nbRows - 1) + j) + 0] = hole0 ? i0 : i2; // duplicate i0 to make a hole tmpIndices[6 * (i * (nbRows - 1) + j) + 1] = i0; tmpIndices[6 * (i * (nbRows - 1) + j) + 2] = tessFlag ? i3 : i1; // second triangle tmpIndices[6 * (i * (nbRows - 1) + j) + 3] = hole1 ? i1 : i3; // duplicate i1 to make a hole tmpIndices[6 * (i * (nbRows - 1) + j) + 4] = tessFlag ? i0 : i2; tmpIndices[6 * (i * (nbRows - 1) + j) + 5] = i1; } } PX_FREE(sampleBuffer); OMNI_PVD_SET_ARRAY_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxHeightField, verts, hf, tmpVerts, 3 * nbVerts); OMNI_PVD_SET_ARRAY_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxHeightField, tris, hf, tmpIndices, 3 * nbFaces); PX_FREE(tmpVerts); PX_FREE(tmpIndices); OMNI_PVD_WRITE_SCOPE_END } } void streamHeightFieldGeometry(const physx::PxHeightFieldGeometry& g) { OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) OMNI_PVD_CREATE_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxHeightFieldGeometry, g); PxVec3 vertScale(g.rowScale, g.heightScale, g.columnScale); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxHeightFieldGeometry, scale, g, vertScale); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxHeightFieldGeometry, heightField, g, g.heightField); OMNI_PVD_WRITE_SCOPE_END } void streamActorAttributes(const physx::PxActor& actor) { OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxActor, flags, actor, actor.getActorFlags()); streamActorName(actor, actor.getName()); // Should we stream the worldBounds if the actor is not part of a Scene yet? OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxActor, worldBounds, actor, actor.getWorldBounds()) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxActor, dominance, actor, actor.getDominanceGroup()) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxActor, ownerClient, actor, actor.getOwnerClient()) OMNI_PVD_WRITE_SCOPE_END } void streamRigidActorAttributes(const PxRigidActor &ra) { OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) if (ra.is<PxArticulationLink>()) { const PxArticulationLink& link = static_cast<const PxArticulationLink&>(ra); PxTransform TArtLinkLocal; PxArticulationJointReducedCoordinate* joint = link.getInboundJoint(); if (joint) { PxArticulationLink& parentLink = joint->getParentArticulationLink(); // TGlobal = TFatherGlobal * TLocal // Inv(TFatherGlobal)* TGlobal = Inv(TFatherGlobal)*TFatherGlobal * TLocal // Inv(TFatherGlobal)* TGlobal = TLocal // TLocal = Inv(TFatherGlobal) * TGlobal //physx::PxTransform TParentGlobal = pxArticulationParentLink->getGlobalPose(); PxTransform TParentGlobalInv = parentLink.getGlobalPose().getInverse(); PxTransform TArtLinkGlobal = link.getGlobalPose(); // PT:: tag: scalar transform*transform TArtLinkLocal = TParentGlobalInv * TArtLinkGlobal; } else { TArtLinkLocal = link.getGlobalPose(); } OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxRigidActor, translation, ra, TArtLinkLocal.p) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxRigidActor, rotation, ra, TArtLinkLocal.q) } else { PxTransform t = ra.getGlobalPose(); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxRigidActor, translation, ra, t.p); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxRigidActor, rotation, ra, t.q); } // Stream shapes too const int nbrShapes = ra.getNbShapes(); for (int s = 0; s < nbrShapes; s++) { PxShape* shape[1]; ra.getShapes(shape, 1, s); OMNI_PVD_ADD_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxRigidActor, shapes, ra, *shape[0]) } OMNI_PVD_WRITE_SCOPE_END } void streamRigidBodyAttributes(const physx::PxRigidBody& rigidBody) { OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxRigidBody, cMassLocalPose, rigidBody, rigidBody.getCMassLocalPose()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxRigidBody, mass, rigidBody, rigidBody.getMass()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxRigidBody, massSpaceInertiaTensor, rigidBody, rigidBody.getMassSpaceInertiaTensor()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxRigidBody, linearDamping, rigidBody, rigidBody.getLinearDamping()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxRigidBody, angularDamping, rigidBody, rigidBody.getAngularDamping()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxRigidBody, linearVelocity, rigidBody, rigidBody.getLinearVelocity()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxRigidBody, angularVelocity, rigidBody, rigidBody.getAngularVelocity()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxRigidBody, maxLinearVelocity, rigidBody, rigidBody.getMaxLinearVelocity()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxRigidBody, maxAngularVelocity, rigidBody, rigidBody.getMaxAngularVelocity()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxRigidBody, rigidBodyFlags, rigidBody, rigidBody.getRigidBodyFlags()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxRigidBody, minAdvancedCCDCoefficient, rigidBody, rigidBody.getMinCCDAdvanceCoefficient()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxRigidBody, maxDepenetrationVelocity, rigidBody, rigidBody.getMaxDepenetrationVelocity()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxRigidBody, maxContactImpulse, rigidBody, rigidBody.getMaxContactImpulse()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxRigidBody, contactSlopCoefficient, rigidBody, rigidBody.getContactSlopCoefficient()); OMNI_PVD_WRITE_SCOPE_END } void streamRigidDynamicAttributes(const physx::PxRigidDynamic& rd) { OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) if (rd.getScene()) { OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxRigidDynamic, isSleeping, rd, rd.isSleeping()); } OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxRigidDynamic, sleepThreshold, rd, rd.getSleepThreshold()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxRigidDynamic, stabilizationThreshold, rd, rd.getStabilizationThreshold()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxRigidDynamic, rigidDynamicLockFlags, rd, rd.getRigidDynamicLockFlags()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxRigidDynamic, wakeCounter, rd, rd.getWakeCounter()); PxU32 positionIters, velocityIters; rd.getSolverIterationCounts(positionIters, velocityIters); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxRigidDynamic, positionIterations, rd, positionIters); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxRigidDynamic, velocityIterations, rd, velocityIters); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxRigidDynamic, contactReportThreshold, rd, rd.getContactReportThreshold()); OMNI_PVD_WRITE_SCOPE_END } void streamRigidDynamic(const physx::PxRigidDynamic& rd) { OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) const PxActor& a = rd; PX_ASSERT(&a == &rd); // if this changes, we would have to cast in a way such that the addresses are the same OMNI_PVD_CREATE_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxRigidDynamic, rd); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxActor, type, a, PxActorType::eRIGID_DYNAMIC); OMNI_PVD_WRITE_SCOPE_END streamActorAttributes(rd); streamRigidActorAttributes(rd); streamRigidBodyAttributes(rd); streamRigidDynamicAttributes(rd); } void streamRigidStatic(const physx::PxRigidStatic& rs) { OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) const PxActor& a = rs; PX_ASSERT(&a == &rs); // if this changes, we would have to cast in a way such that the addresses are the same OMNI_PVD_CREATE_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxRigidStatic, rs); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxActor, type, a, PxActorType::eRIGID_STATIC); OMNI_PVD_WRITE_SCOPE_END streamActorAttributes(rs); streamRigidActorAttributes(rs); } void streamArticulationJoint(const physx::PxArticulationJointReducedCoordinate& jointRef) { const PxU32 degreesOfFreedom = PxArticulationAxis::eCOUNT; // make sure size matches the size used in the PVD description PX_ASSERT(sizeof(PxArticulationMotion::Enum) == getOmniPvdDataTypeSize<OmniPvdDataType::eUINT32>()); PX_ASSERT(sizeof(PxArticulationDriveType::Enum) == getOmniPvdDataTypeSize<OmniPvdDataType::eUINT32>()); PxArticulationJointType::Enum jointType = jointRef.getJointType(); const PxArticulationLink* parentPxLinkPtr = &jointRef.getParentArticulationLink(); const PxArticulationLink* childPxLinkPtr = &jointRef.getChildArticulationLink(); PxArticulationMotion::Enum motions[degreesOfFreedom]; for (PxU32 ax = 0; ax < degreesOfFreedom; ++ax) motions[ax] = jointRef.getMotion(static_cast<PxArticulationAxis::Enum>(ax)); PxReal armatures[degreesOfFreedom]; for (PxU32 ax = 0; ax < degreesOfFreedom; ++ax) armatures[ax] = jointRef.getArmature(static_cast<PxArticulationAxis::Enum>(ax)); PxReal coefficient = jointRef.getFrictionCoefficient(); PxReal maxJointV = jointRef.getMaxJointVelocity(); PxReal positions[degreesOfFreedom]; for (PxU32 ax = 0; ax < degreesOfFreedom; ++ax) positions[ax] = jointRef.getJointPosition(static_cast<PxArticulationAxis::Enum>(ax)); PxReal velocitys[degreesOfFreedom]; for (PxU32 ax = 0; ax < degreesOfFreedom; ++ax) velocitys[ax] = jointRef.getJointVelocity(static_cast<PxArticulationAxis::Enum>(ax)); const char* concreteTypeName = jointRef.getConcreteTypeName(); PxU32 concreteTypeNameLen = PxU32(strlen(concreteTypeName)) + 1; PxReal lowlimits[degreesOfFreedom]; for (PxU32 ax = 0; ax < degreesOfFreedom; ++ax) lowlimits[ax] = jointRef.getLimitParams(static_cast<PxArticulationAxis::Enum>(ax)).low; PxReal highlimits[degreesOfFreedom]; for (PxU32 ax = 0; ax < degreesOfFreedom; ++ax) highlimits[ax] = jointRef.getLimitParams(static_cast<PxArticulationAxis::Enum>(ax)).high; PxReal stiffnesss[degreesOfFreedom]; for (PxU32 ax = 0; ax < degreesOfFreedom; ++ax) stiffnesss[ax] = jointRef.getDriveParams(static_cast<PxArticulationAxis::Enum>(ax)).stiffness; PxReal dampings[degreesOfFreedom]; for (PxU32 ax = 0; ax < degreesOfFreedom; ++ax) dampings[ax] = jointRef.getDriveParams(static_cast<PxArticulationAxis::Enum>(ax)).damping; PxReal maxforces[degreesOfFreedom]; for (PxU32 ax = 0; ax < degreesOfFreedom; ++ax) maxforces[ax] = jointRef.getDriveParams(static_cast<PxArticulationAxis::Enum>(ax)).maxForce; PxArticulationDriveType::Enum drivetypes[degreesOfFreedom]; for (PxU32 ax = 0; ax < degreesOfFreedom; ++ax) drivetypes[ax] = jointRef.getDriveParams(static_cast<PxArticulationAxis::Enum>(ax)).driveType; PxReal drivetargets[degreesOfFreedom]; for (PxU32 ax = 0; ax < degreesOfFreedom; ++ax) drivetargets[ax] = jointRef.getDriveTarget(static_cast<PxArticulationAxis::Enum>(ax)); PxReal drivevelocitys[degreesOfFreedom]; for (PxU32 ax = 0; ax < degreesOfFreedom; ++ax) drivevelocitys[ax] = jointRef.getDriveVelocity(static_cast<PxArticulationAxis::Enum>(ax)); OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) OMNI_PVD_CREATE_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, jointRef); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, type, jointRef, jointType); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, parentLink, jointRef, parentPxLinkPtr); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, childLink, jointRef, childPxLinkPtr); OMNI_PVD_SET_ARRAY_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, motion, jointRef, motions, degreesOfFreedom); OMNI_PVD_SET_ARRAY_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, armature, jointRef, armatures, degreesOfFreedom); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, frictionCoefficient, jointRef, coefficient); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, maxJointVelocity, jointRef, maxJointV); OMNI_PVD_SET_ARRAY_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, jointPosition, jointRef, positions, degreesOfFreedom); OMNI_PVD_SET_ARRAY_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, jointVelocity, jointRef, velocitys, degreesOfFreedom); OMNI_PVD_SET_ARRAY_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, concreteTypeName, jointRef, concreteTypeName, concreteTypeNameLen); OMNI_PVD_SET_ARRAY_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, limitLow, jointRef, lowlimits, degreesOfFreedom); OMNI_PVD_SET_ARRAY_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, limitHigh, jointRef, highlimits, degreesOfFreedom); OMNI_PVD_SET_ARRAY_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, driveStiffness, jointRef, stiffnesss, degreesOfFreedom); OMNI_PVD_SET_ARRAY_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, driveDamping, jointRef, dampings, degreesOfFreedom); OMNI_PVD_SET_ARRAY_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, driveMaxForce, jointRef, maxforces, degreesOfFreedom); OMNI_PVD_SET_ARRAY_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, driveType, jointRef, drivetypes, degreesOfFreedom); OMNI_PVD_SET_ARRAY_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, driveTarget, jointRef, drivetargets, degreesOfFreedom); OMNI_PVD_SET_ARRAY_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, driveVelocity, jointRef, drivevelocitys, degreesOfFreedom); OMNI_PVD_WRITE_SCOPE_END } void streamArticulationLink(const physx::PxArticulationLink& al) { OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) const PxActor& a = al; PX_ASSERT(&a == &al); // if this changes, we would have to cast in a way such that the addresses are the same OMNI_PVD_CREATE_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationLink, al); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxActor, type, a, PxActorType::eARTICULATION_LINK); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationLink, articulation, al, &al.getArticulation()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationLink, CFMScale, al, al.getCfmScale()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationLink, inboundJointDOF, al, al.getInboundJointDof()); OMNI_PVD_WRITE_SCOPE_END streamActorAttributes(al); streamRigidActorAttributes(al); streamRigidBodyAttributes(al); } void streamArticulation(const physx::PxArticulationReducedCoordinate& art) { OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) OMNI_PVD_CREATE_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationReducedCoordinate, art); PxU32 solverIterations[2]; art.getSolverIterationCounts(solverIterations[0], solverIterations[1]); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationReducedCoordinate, positionIterations, art, solverIterations[0]); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationReducedCoordinate, velocityIterations, art, solverIterations[1]); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationReducedCoordinate, isSleeping, art, false); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationReducedCoordinate, sleepThreshold, art, art.getSleepThreshold()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationReducedCoordinate, stabilizationThreshold, art, art.getStabilizationThreshold()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationReducedCoordinate, wakeCounter, art, art.getWakeCounter()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationReducedCoordinate, maxLinearVelocity, art, art.getMaxCOMLinearVelocity()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationReducedCoordinate, maxAngularVelocity, art, art.getMaxCOMAngularVelocity()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationReducedCoordinate, worldBounds, art, art.getWorldBounds()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationReducedCoordinate, articulationFlags, art, art.getArticulationFlags()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxArticulationReducedCoordinate, dofs, art, art.getDofs()); OMNI_PVD_WRITE_SCOPE_END } void streamAggregate(const physx::PxAggregate& agg) { OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) OMNI_PVD_CREATE_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxAggregate, agg); PxU32 actorCount = agg.getNbActors(); for (PxU32 i = 0; i < actorCount; ++i) { PxActor* a; agg.getActors(&a, 1, i); OMNI_PVD_ADD_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxAggregate, actors, agg, *a); } OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxAggregate, selfCollision, agg, agg.getSelfCollision()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxAggregate, maxNbShapes, agg, agg.getMaxNbShapes()); PxScene* scene = static_cast<const NpAggregate&>(agg).getNpScene(); // because PxAggregate::getScene() is not marked const OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxAggregate, scene, agg, scene); OMNI_PVD_WRITE_SCOPE_END } void streamMPMMaterial(const physx::PxMPMMaterial& m) { OMNI_PVD_CREATE(OMNI_PVD_CONTEXT_HANDLE, PxMPMMaterial, m); } void streamFLIPMaterial(const physx::PxFLIPMaterial& m) { OMNI_PVD_CREATE(OMNI_PVD_CONTEXT_HANDLE, PxFLIPMaterial, m); } void streamPBDMaterial(const physx::PxPBDMaterial& m) { OMNI_PVD_CREATE(OMNI_PVD_CONTEXT_HANDLE, PxPBDMaterial, m); } void streamFEMClothMaterial(const physx::PxFEMClothMaterial& m) { OMNI_PVD_CREATE(OMNI_PVD_CONTEXT_HANDLE, PxFEMClothMaterial, m); } void streamFEMSoBoMaterial(const physx::PxFEMSoftBodyMaterial& m) { OMNI_PVD_CREATE(OMNI_PVD_CONTEXT_HANDLE, PxFEMSoftBodyMaterial, m); } void streamMaterial(const physx::PxMaterial& m) { OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) OMNI_PVD_CREATE_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxMaterial, m); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxMaterial, flags, m, m.getFlags()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxMaterial, frictionCombineMode, m, m.getFrictionCombineMode()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxMaterial, restitutionCombineMode, m, m.getRestitutionCombineMode()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxMaterial, staticFriction, m, m.getStaticFriction()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxMaterial, dynamicFriction, m, m.getDynamicFriction()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxMaterial, restitution, m, m.getRestitution()); OMNI_PVD_WRITE_SCOPE_END } void streamShapeMaterials(const physx::PxShape& shape, physx::PxMaterial* const * mats, physx::PxU32 nbrMaterials) { OMNI_PVD_SET_ARRAY(OMNI_PVD_CONTEXT_HANDLE, PxShape, materials, shape, mats, nbrMaterials); } void streamShapeMaterials(const physx::PxShape& shape, physx::PxFEMClothMaterial* const * mats, physx::PxU32 nbrMaterials) { PX_UNUSED(shape); PX_UNUSED(mats); PX_UNUSED(nbrMaterials); } void streamShapeMaterials(const physx::PxShape& shape, physx::PxFEMMaterial* const * mats, physx::PxU32 nbrMaterials) { PX_UNUSED(shape); PX_UNUSED(mats); PX_UNUSED(nbrMaterials); } void streamShapeMaterials(const physx::PxShape& shape, physx::PxFEMSoftBodyMaterial* const * mats, physx::PxU32 nbrMaterials) { PX_UNUSED(shape); PX_UNUSED(mats); PX_UNUSED(nbrMaterials); } void streamShapeMaterials(const physx::PxShape& shape, physx::PxFLIPMaterial* const * mats, physx::PxU32 nbrMaterials) { PX_UNUSED(shape); PX_UNUSED(mats); PX_UNUSED(nbrMaterials); } void streamShapeMaterials(const physx::PxShape& shape, physx::PxMPMMaterial* const * mats, physx::PxU32 nbrMaterials) { PX_UNUSED(shape); PX_UNUSED(mats); PX_UNUSED(nbrMaterials); } void streamShapeMaterials(const physx::PxShape& shape, physx::PxParticleMaterial* const * mats, physx::PxU32 nbrMaterials) { PX_UNUSED(shape); PX_UNUSED(mats); PX_UNUSED(nbrMaterials); } void streamShapeMaterials(const physx::PxShape& shape, physx::PxPBDMaterial* const * mats, physx::PxU32 nbrMaterials) { PX_UNUSED(shape); PX_UNUSED(mats); PX_UNUSED(nbrMaterials); } void streamShape(const physx::PxShape& shape) { OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) OMNI_PVD_CREATE_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxShape, shape); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxShape, isExclusive, shape, shape.isExclusive()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxShape, geom, shape, &shape.getGeometry()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxShape, contactOffset, shape, shape.getContactOffset()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxShape, restOffset, shape, shape.getRestOffset()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxShape, densityForFluid, shape, shape.getDensityForFluid()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxShape, torsionalPatchRadius, shape, shape.getTorsionalPatchRadius()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxShape, minTorsionalPatchRadius, shape, shape.getMinTorsionalPatchRadius()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxShape, shapeFlags, shape, shape.getFlags()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxShape, simulationFilterData, shape, shape.getSimulationFilterData()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxShape, queryFilterData, shape, shape.getQueryFilterData()); const int nbrMaterials = shape.getNbMaterials(); PxMaterial** tmpMaterials = (PxMaterial**)PX_ALLOC(sizeof(PxMaterial*) * nbrMaterials, "tmpMaterials"); physx::PxU32 nbrMats = shape.getMaterials(tmpMaterials, nbrMaterials); streamShapeMaterials(shape, tmpMaterials, nbrMats); PX_FREE(tmpMaterials); OMNI_PVD_WRITE_SCOPE_END } void streamBVH(const physx::PxBVH& bvh) { OMNI_PVD_CREATE(OMNI_PVD_CONTEXT_HANDLE, PxBVH, bvh); } void streamSoBoMesh(const physx::PxSoftBodyMesh& mesh) { OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) OMNI_PVD_CREATE_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxSoftBodyMesh, mesh); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxSoftBodyMesh, collisionMesh, mesh, mesh.getCollisionMesh()); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxSoftBodyMesh, simulationMesh, mesh, mesh.getSimulationMesh()); OMNI_PVD_WRITE_SCOPE_END } void streamTetMesh(const physx::PxTetrahedronMesh& mesh) { OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) OMNI_PVD_CREATE_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxTetrahedronMesh, mesh); //this gets done at the bottom now const PxU32 tetrahedronCount = mesh.getNbTetrahedrons(); const PxU32 has16BitIndices = mesh.getTetrahedronMeshFlags() & physx::PxTetrahedronMeshFlag::e16_BIT_INDICES; const void* indexBuffer = mesh.getTetrahedrons(); const PxVec3* vertexBuffer = mesh.getVertices(); const PxU32* intIndices = reinterpret_cast<const PxU32*>(indexBuffer); const PxU16* shortIndices = reinterpret_cast<const PxU16*>(indexBuffer); //TODO: not needed to copy this const PxU32 nbrVerts = mesh.getNbVertices(); const PxU32 nbrTets = mesh.getNbTetrahedrons(); float* tmpVerts = (float*)PX_ALLOC(sizeof(float)*(nbrVerts * 3), "tmpVerts"); PxU32 vertIndex = 0; for (PxU32 v = 0; v < nbrVerts; v++) { tmpVerts[vertIndex + 0] = vertexBuffer[v].x; tmpVerts[vertIndex + 1] = vertexBuffer[v].y; tmpVerts[vertIndex + 2] = vertexBuffer[v].z; vertIndex += 3; } PxU32* tmpIndices = (PxU32*)PX_ALLOC(sizeof(PxU32)*(nbrTets * 4), "tmpIndices"); const PxU32 totalIndexCount = tetrahedronCount * 4; if (has16BitIndices) { for (PxU32 i = 0; i < totalIndexCount; ++i) { tmpIndices[i] = shortIndices[i]; } } else { for (PxU32 i = 0; i < totalIndexCount; ++i) { tmpIndices[i] = intIndices[i]; } } OMNI_PVD_SET_ARRAY_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxTetrahedronMesh, verts, mesh, tmpVerts, 3 * nbrVerts); OMNI_PVD_SET_ARRAY_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxTetrahedronMesh, tets, mesh, tmpIndices, 4 * nbrTets); PX_FREE(tmpVerts); PX_FREE(tmpIndices); OMNI_PVD_WRITE_SCOPE_END } void streamTriMesh(const physx::PxTriangleMesh& mesh) { if (samplerInternals->addSharedMeshIfNotSeen(&mesh, OmniPvdSharedMeshEnum::eOmniPvdTriMesh)) { OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) OMNI_PVD_CREATE_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxTriangleMesh, mesh); //this gets done at the bottom now const PxU32 triangleCount = mesh.getNbTriangles(); const PxU32 has16BitIndices = mesh.getTriangleMeshFlags() & physx::PxTriangleMeshFlag::e16_BIT_INDICES; const void* indexBuffer = mesh.getTriangles(); const PxVec3* vertexBuffer = mesh.getVertices(); const PxU32* intIndices = reinterpret_cast<const PxU32*>(indexBuffer); const PxU16* shortIndices = reinterpret_cast<const PxU16*>(indexBuffer); //TODO: not needed to copy this const PxU32 nbrVerts = mesh.getNbVertices(); const PxU32 nbrTris = mesh.getNbTriangles(); float* tmpVerts = (float*)PX_ALLOC(sizeof(float)*(nbrVerts * 3), "tmpVerts"); PxU32 vertIndex = 0; for (PxU32 v = 0; v < nbrVerts; v++) { tmpVerts[vertIndex + 0] = vertexBuffer[v].x; tmpVerts[vertIndex + 1] = vertexBuffer[v].y; tmpVerts[vertIndex + 2] = vertexBuffer[v].z; vertIndex += 3; } PxU32* tmpIndices = (PxU32*)PX_ALLOC(sizeof(PxU32)*(nbrTris * 3), "tmpIndices"); const PxU32 totalIndexCount = triangleCount * 3; if (has16BitIndices) { for (PxU32 i = 0; i < totalIndexCount; ++i) { tmpIndices[i] = shortIndices[i]; } } else { for (PxU32 i = 0; i < totalIndexCount; ++i) { tmpIndices[i] = intIndices[i]; } } OMNI_PVD_SET_ARRAY_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxTriangleMesh, verts, mesh, tmpVerts, 3 * nbrVerts); OMNI_PVD_SET_ARRAY_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxTriangleMesh, tris, mesh, tmpIndices, 3 * nbrTris); PX_FREE(tmpVerts); PX_FREE(tmpIndices); OMNI_PVD_WRITE_SCOPE_END } } void streamTriMeshGeometry(const physx::PxTriangleMeshGeometry& g) { OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) OMNI_PVD_CREATE_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxTriangleMeshGeometry, g); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxTriangleMeshGeometry, scale, g, g.scale.scale); streamTriMesh(*g.triangleMesh); OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxTriangleMeshGeometry, triangleMesh, g, g.triangleMesh); OMNI_PVD_WRITE_SCOPE_END } void OmniPvdPxSampler::streamSceneContacts(physx::NpScene& scene) { if (!isSampling()) return; PxsContactManagerOutputIterator outputIter; Sc::ContactIterator contactIter; scene.getScScene().initContactsIterator(contactIter, outputIter); Sc::ContactIterator::Pair* pair; PxU32 pairCount = 0; PxArray<PxActor*> pairsActors; PxArray<PxU32> pairsContactCounts; PxArray<PxVec3> pairsContactPoints; PxArray<PxVec3> pairsContactNormals; PxArray<PxReal> pairsContactSeparations; PxArray<PxShape*> pairsContactShapes; PxArray<PxU32> pairsContactFacesIndices; while ((pair = contactIter.getNextPair()) != NULL) { PxU32 pairContactCount = 0; Sc::Contact* contact = NULL; bool firstContact = true; while ((contact = pair->getNextContact()) != NULL) { if (firstContact) { pairsActors.pushBack(pair->getActor0()); pairsActors.pushBack(pair->getActor1()); ++pairCount; firstContact = false; } ++pairContactCount; pairsContactPoints.pushBack(contact->point); pairsContactNormals.pushBack(contact->normal); pairsContactSeparations.pushBack(contact->separation); pairsContactShapes.pushBack(contact->shape0); pairsContactShapes.pushBack(contact->shape1); pairsContactFacesIndices.pushBack(contact->faceIndex0); pairsContactFacesIndices.pushBack(contact->faceIndex1); } if (pairContactCount) { pairsContactCounts.pushBack(pairContactCount); } } if (pairCount == 0) return; OMNI_PVD_WRITE_SCOPE_BEGIN(pvdWriter, pvdRegData) OMNI_PVD_SET_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, pairCount, scene, pairCount); const PxU32 actorCount = pairsActors.size(); const PxActor** actors = actorCount ? const_cast<const PxActor**>(pairsActors.begin()) : NULL; OMNI_PVD_SET_ARRAY_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, pairsActors, scene, actors, actorCount); PxU32 nbContactCount = pairsContactCounts.size(); PxU32* contactCounts = nbContactCount ? pairsContactCounts.begin() : NULL; OMNI_PVD_SET_ARRAY_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, pairsContactCounts, scene, contactCounts, nbContactCount); PxU32 contactPointFloatCount = pairsContactPoints.size() * 3; PxReal* contactPoints = contactPointFloatCount ? &pairsContactPoints[0].x : NULL; OMNI_PVD_SET_ARRAY_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, pairsContactPoints, scene, contactPoints, contactPointFloatCount); PxU32 contactNormalFloatCount = pairsContactNormals.size() * 3; PxReal* contactNormals = contactNormalFloatCount ? &pairsContactNormals[0].x : NULL; OMNI_PVD_SET_ARRAY_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, pairsContactNormals, scene, contactNormals, contactNormalFloatCount); PxU32 contactSeparationCount = pairsContactSeparations.size(); PxReal* contactSeparations = contactSeparationCount ? pairsContactSeparations.begin() : NULL; OMNI_PVD_SET_ARRAY_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, pairsContactSeparations, scene, contactSeparations, contactSeparationCount); PxU32 contactShapeCount = pairsContactShapes.size(); const PxShape** contactShapes = contactShapeCount ? const_cast<const PxShape**>(pairsContactShapes.begin()) : NULL; OMNI_PVD_SET_ARRAY_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, pairsContactShapes, scene, contactShapes, contactShapeCount); PxU32 contactFacesIndexCount = pairsContactFacesIndices.size(); PxU32* contactFacesIndices = contactFacesIndexCount ? pairsContactFacesIndices.begin() : NULL; OMNI_PVD_SET_ARRAY_EXPLICIT(pvdWriter, pvdRegData, OMNI_PVD_CONTEXT_HANDLE, PxScene, pairsContactFacesIndices, scene, contactFacesIndices, contactFacesIndexCount); OMNI_PVD_WRITE_SCOPE_END } OmniPvdPxSampler::OmniPvdPxSampler() { samplerInternals = PX_NEW(OmniPvdSamplerInternals)(); physx::PxMutex::ScopedLock myLock(samplerInternals->mSampleMutex); samplerInternals->mIsSampling = false; } OmniPvdPxSampler::~OmniPvdPxSampler() { physx::PxHashMap<physx::NpScene*, OmniPvdPxScene*>::Iterator iterScenes = samplerInternals->mSampledScenes.getIterator(); while (!iterScenes.done()) { OmniPvdPxScene* scene = iterScenes->second; PX_DELETE(scene); iterScenes++; } PX_DELETE(samplerInternals); } void OmniPvdPxSampler::startSampling() { physx::PxMutex::ScopedLock myLock(samplerInternals->mSampleMutex); if (samplerInternals->mIsSampling) { return; } if (samplerInternals->mPvdStream.initOmniPvd()) { samplerInternals->mIsSampling = true; } } bool OmniPvdPxSampler::isSampling() { if (!samplerInternals) return false; physx::PxMutex::ScopedLock myLock(samplerInternals->mSampleMutex); return samplerInternals->mIsSampling; } void OmniPvdPxSampler::setOmniPvdInstance(physx::NpOmniPvd* omniPvdInstance) { samplerInternals->mPvdStream.setOmniPvdInstance(omniPvdInstance); } void createGeometry(const physx::PxGeometry & pxGeom) { switch (pxGeom.getType()) { case physx::PxGeometryType::eSPHERE: { streamSphereGeometry((const physx::PxSphereGeometry &)pxGeom); } break; case physx::PxGeometryType::eCAPSULE: { streamCapsuleGeometry((const physx::PxCapsuleGeometry &)pxGeom); } break; case physx::PxGeometryType::eBOX: { streamBoxGeometry((const physx::PxBoxGeometry &)pxGeom); } break; case physx::PxGeometryType::eTRIANGLEMESH: { streamTriMeshGeometry((const physx::PxTriangleMeshGeometry &)pxGeom); } break; case physx::PxGeometryType::eCONVEXMESH: { streamConvexMeshGeometry((const physx::PxConvexMeshGeometry &)pxGeom); } break; case physx::PxGeometryType::eHEIGHTFIELD: { streamHeightFieldGeometry((const physx::PxHeightFieldGeometry &)pxGeom); } break; case physx::PxGeometryType::ePLANE: { streamPlaneGeometry((const physx::PxPlaneGeometry &)pxGeom); } break; case physx::PxGeometryType::eCUSTOM: { streamCustomGeometry((const physx::PxCustomGeometry &)pxGeom); } break; default: break; } } void destroyGeometry(const physx::PxGeometry& pxGeom) { switch (pxGeom.getType()) { case physx::PxGeometryType::eSPHERE: { OMNI_PVD_DESTROY(OMNI_PVD_CONTEXT_HANDLE, PxSphereGeometry, static_cast<const PxSphereGeometry&>(pxGeom)); } break; case physx::PxGeometryType::eCAPSULE: { OMNI_PVD_DESTROY(OMNI_PVD_CONTEXT_HANDLE, PxCapsuleGeometry, static_cast<const PxCapsuleGeometry&>(pxGeom)); } break; case physx::PxGeometryType::eBOX: { OMNI_PVD_DESTROY(OMNI_PVD_CONTEXT_HANDLE, PxBoxGeometry, static_cast<const PxBoxGeometry&>(pxGeom)); } break; case physx::PxGeometryType::eTRIANGLEMESH: { OMNI_PVD_DESTROY(OMNI_PVD_CONTEXT_HANDLE, PxTriangleMeshGeometry, static_cast<const PxTriangleMeshGeometry&>(pxGeom)); } break; case physx::PxGeometryType::eCONVEXMESH: { OMNI_PVD_DESTROY(OMNI_PVD_CONTEXT_HANDLE, PxConvexMeshGeometry, static_cast<const PxConvexMeshGeometry&>(pxGeom)); } break; case physx::PxGeometryType::eHEIGHTFIELD: { OMNI_PVD_DESTROY(OMNI_PVD_CONTEXT_HANDLE, PxHeightFieldGeometry, static_cast<const PxHeightFieldGeometry&>(pxGeom)); } break; case physx::PxGeometryType::ePLANE: { OMNI_PVD_DESTROY(OMNI_PVD_CONTEXT_HANDLE, PxPlaneGeometry, static_cast<const PxPlaneGeometry&>(pxGeom)); } break; case physx::PxGeometryType::eCUSTOM: { OMNI_PVD_DESTROY(OMNI_PVD_CONTEXT_HANDLE, PxCustomGeometry, static_cast<const PxCustomGeometry&>(pxGeom)); } break; default: break; } } void OmniPvdPxSampler::sampleScene(physx::NpScene* scene) { { physx::PxMutex::ScopedLock myLock(samplerInternals->mSampleMutex); if (!samplerInternals->mIsSampling) return; } OmniPvdPxScene* ovdScene = getSampledScene(scene); ovdScene->sampleScene(); } void OmniPvdPxSampler::onObjectAdd(const physx::PxBase& object) { if (!isSampling()) return; const PxPhysics& physics = static_cast<PxPhysics&>(NpPhysics::getInstance()); switch (object.getConcreteType()) { case physx::PxConcreteType::eHEIGHTFIELD: { const PxHeightField& hf = static_cast<const PxHeightField&>(object); streamHeightField(hf); OMNI_PVD_ADD(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, heightFields, physics, hf); } break; case physx::PxConcreteType::eCONVEX_MESH: { const PxConvexMesh& cm = static_cast<const PxConvexMesh&>(object); streamConvexMesh(cm); OMNI_PVD_ADD(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, convexMeshes, physics, cm); } break; case physx::PxConcreteType::eTRIANGLE_MESH_BVH33: case physx::PxConcreteType::eTRIANGLE_MESH_BVH34: { const PxTriangleMesh& m = static_cast<const PxTriangleMesh&>(object); streamTriMesh(m); OMNI_PVD_ADD(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, triangleMeshes, physics, m); } break; case physx::PxConcreteType::eTETRAHEDRON_MESH: { const PxTetrahedronMesh& tm = static_cast<const PxTetrahedronMesh&>(object); streamTetMesh(tm); OMNI_PVD_ADD(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, tetrahedronMeshes, physics, tm); } break; case physx::PxConcreteType::eSOFTBODY_MESH: { const PxSoftBodyMesh& sm = static_cast<const PxSoftBodyMesh&>(object); streamSoBoMesh(sm); OMNI_PVD_ADD(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, softBodyMeshes, physics, sm); } break; case physx::PxConcreteType::eBVH: { const PxBVH& bvh = static_cast<const PxBVH&>(object); streamBVH(bvh); OMNI_PVD_ADD(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, bvhs, physics, bvh); } break; case physx::PxConcreteType::eSHAPE: { const PxShape& shape = static_cast<const physx::PxShape&>(object); createGeometry(shape.getGeometry()); streamShape(shape); OMNI_PVD_ADD(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, shapes, physics, shape); } break; case physx::PxConcreteType::eMATERIAL: { const PxMaterial& mat = static_cast<const PxMaterial&>(object); streamMaterial(mat); OMNI_PVD_ADD(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, materials, physics, mat); } break; case physx::PxConcreteType::eSOFTBODY_MATERIAL: { const PxFEMSoftBodyMaterial& sbMat = static_cast<const PxFEMSoftBodyMaterial&>(object); streamFEMSoBoMaterial(sbMat); OMNI_PVD_ADD(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, FEMSoftBodyMaterials, physics, sbMat); } break; case physx::PxConcreteType::eCLOTH_MATERIAL: { const PxFEMClothMaterial& clothMat = static_cast<const PxFEMClothMaterial&>(object); streamFEMClothMaterial(clothMat); OMNI_PVD_ADD(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, FEMClothMaterials, physics, clothMat); } break; case physx::PxConcreteType::ePBD_MATERIAL: { const PxPBDMaterial& pbdhMat = static_cast<const PxPBDMaterial&>(object); streamPBDMaterial(pbdhMat); OMNI_PVD_ADD(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, PBDMaterials, physics, pbdhMat); } break; case physx::PxConcreteType::eFLIP_MATERIAL: { const PxFLIPMaterial& flipMat = static_cast<const PxFLIPMaterial&>(object); streamFLIPMaterial(flipMat); OMNI_PVD_ADD(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, FLIPMaterials, physics, flipMat); } break; case physx::PxConcreteType::eMPM_MATERIAL: { const PxMPMMaterial& mpmMat = static_cast<const PxMPMMaterial&>(object); streamMPMMaterial(mpmMat); OMNI_PVD_ADD(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, MPMMaterials, physics, mpmMat); } break; case physx::PxConcreteType::eAGGREGATE: { const PxAggregate& agg = static_cast<const PxAggregate&>(object); streamAggregate(agg); OMNI_PVD_ADD(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, aggregates, physics, agg); } break; case physx::PxConcreteType::eARTICULATION_REDUCED_COORDINATE: { const PxArticulationReducedCoordinate& art = static_cast<const PxArticulationReducedCoordinate&>(object); streamArticulation(art); OMNI_PVD_ADD(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, articulations, physics, art); } break; case physx::PxConcreteType::eARTICULATION_LINK: { const PxArticulationLink& artLink = static_cast<const PxArticulationLink&>(object); streamArticulationLink(artLink); OMNI_PVD_ADD(OMNI_PVD_CONTEXT_HANDLE, PxArticulationReducedCoordinate, links, artLink.getArticulation(), artLink); } break; case physx::PxConcreteType::eARTICULATION_JOINT_REDUCED_COORDINATE: { const PxArticulationJointReducedCoordinate& artJoint = static_cast<const PxArticulationJointReducedCoordinate&>(object); streamArticulationJoint(artJoint); break; } case physx::PxConcreteType::eRIGID_DYNAMIC: { const PxRigidDynamic& rd = static_cast<const PxRigidDynamic&>(object); streamRigidDynamic(rd); OMNI_PVD_ADD(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, rigidDynamics, physics, rd); } break; case physx::PxConcreteType::eRIGID_STATIC: { const PxRigidStatic& rs = static_cast<const PxRigidStatic&>(object); streamRigidStatic(rs); OMNI_PVD_ADD(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, rigidStatics, physics, rs); } break; } } void OmniPvdPxSampler::onObjectRemove(const physx::PxBase& object) { if (!isSampling()) return; const PxPhysics& physics = static_cast<PxPhysics&>(NpPhysics::getInstance()); switch (object.getConcreteType()) { case physx::PxConcreteType::eHEIGHTFIELD: { const PxHeightField& hf = static_cast<const PxHeightField&>(object); OMNI_PVD_REMOVE(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, heightFields, physics, hf); OMNI_PVD_DESTROY(OMNI_PVD_CONTEXT_HANDLE, PxHeightField, hf); } break; case physx::PxConcreteType::eCONVEX_MESH: { const PxConvexMesh& cm = static_cast<const PxConvexMesh&>(object); OMNI_PVD_REMOVE(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, convexMeshes, physics, cm); OMNI_PVD_DESTROY(OMNI_PVD_CONTEXT_HANDLE, PxConvexMesh, cm); } break; case physx::PxConcreteType::eTRIANGLE_MESH_BVH33: case physx::PxConcreteType::eTRIANGLE_MESH_BVH34: { const PxTriangleMesh& m = static_cast<const PxTriangleMesh&>(object); OMNI_PVD_REMOVE(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, triangleMeshes, physics, m); OMNI_PVD_DESTROY(OMNI_PVD_CONTEXT_HANDLE, PxTriangleMesh, m); } break; case physx::PxConcreteType::eTETRAHEDRON_MESH: { const PxTetrahedronMesh& tm = static_cast<const PxTetrahedronMesh&>(object); OMNI_PVD_REMOVE(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, tetrahedronMeshes, physics, tm); OMNI_PVD_DESTROY(OMNI_PVD_CONTEXT_HANDLE, PxTetrahedronMesh, tm); } break; case physx::PxConcreteType::eSOFTBODY_MESH: { const PxSoftBodyMesh& sm = static_cast<const PxSoftBodyMesh&>(object); OMNI_PVD_REMOVE(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, softBodyMeshes, physics, sm); OMNI_PVD_DESTROY(OMNI_PVD_CONTEXT_HANDLE, PxSoftBodyMesh, sm); } break; case physx::PxConcreteType::eBVH: { const PxBVH& bvh = static_cast<const PxBVH&>(object); OMNI_PVD_REMOVE(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, bvhs, physics, bvh); OMNI_PVD_DESTROY(OMNI_PVD_CONTEXT_HANDLE, PxBVH, bvh); } break; case physx::PxConcreteType::eSHAPE: { const PxShape& shape = static_cast<const physx::PxShape&>(object); OMNI_PVD_REMOVE(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, shapes, physics, shape); OMNI_PVD_DESTROY(OMNI_PVD_CONTEXT_HANDLE, PxShape, shape); destroyGeometry(shape.getGeometry()); } break; case physx::PxConcreteType::eMATERIAL: { const PxMaterial& mat = static_cast<const PxMaterial&>(object); OMNI_PVD_REMOVE(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, materials, physics, mat); OMNI_PVD_DESTROY(OMNI_PVD_CONTEXT_HANDLE, PxMaterial, mat); } break; case physx::PxConcreteType::eSOFTBODY_MATERIAL: { const PxFEMSoftBodyMaterial& sbMat = static_cast<const PxFEMSoftBodyMaterial&>(object); OMNI_PVD_REMOVE(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, FEMSoftBodyMaterials, physics, sbMat); OMNI_PVD_DESTROY(OMNI_PVD_CONTEXT_HANDLE, PxFEMSoftBodyMaterial, sbMat); } break; case physx::PxConcreteType::eCLOTH_MATERIAL: { const PxFEMClothMaterial& clothMat = static_cast<const PxFEMClothMaterial&>(object); OMNI_PVD_REMOVE(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, FEMClothMaterials, physics, clothMat); OMNI_PVD_DESTROY(OMNI_PVD_CONTEXT_HANDLE, PxFEMClothMaterial, clothMat); } break; case physx::PxConcreteType::ePBD_MATERIAL: { const PxPBDMaterial& pbdhMat = static_cast<const PxPBDMaterial&>(object); OMNI_PVD_REMOVE(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, PBDMaterials, physics, pbdhMat); OMNI_PVD_DESTROY(OMNI_PVD_CONTEXT_HANDLE, PxPBDMaterial, pbdhMat); } break; case physx::PxConcreteType::eFLIP_MATERIAL: { const PxFLIPMaterial& flipMat = static_cast<const PxFLIPMaterial&>(object); OMNI_PVD_REMOVE(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, FLIPMaterials, physics, flipMat); OMNI_PVD_DESTROY(OMNI_PVD_CONTEXT_HANDLE, PxFLIPMaterial, flipMat); } break; case physx::PxConcreteType::eMPM_MATERIAL: { const PxMPMMaterial& mpmMat = static_cast<const PxMPMMaterial&>(object); OMNI_PVD_REMOVE(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, MPMMaterials, physics, mpmMat); OMNI_PVD_DESTROY(OMNI_PVD_CONTEXT_HANDLE, PxMPMMaterial, mpmMat); } break; case physx::PxConcreteType::eAGGREGATE: { const PxAggregate& agg = static_cast<const PxAggregate&>(object); OMNI_PVD_REMOVE(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, aggregates, physics, agg); OMNI_PVD_DESTROY(OMNI_PVD_CONTEXT_HANDLE, PxAggregate, agg); } break; case physx::PxConcreteType::eARTICULATION_REDUCED_COORDINATE: { const PxArticulationReducedCoordinate& art = static_cast<const PxArticulationReducedCoordinate&>(object); OMNI_PVD_REMOVE(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, articulations, physics, art); OMNI_PVD_DESTROY(OMNI_PVD_CONTEXT_HANDLE, PxArticulationReducedCoordinate, art); } break; case physx::PxConcreteType::eARTICULATION_LINK: { const PxArticulationLink& artLink = static_cast<const PxArticulationLink&>(object); OMNI_PVD_DESTROY(OMNI_PVD_CONTEXT_HANDLE, PxActor, artLink); } break; case physx::PxConcreteType::eARTICULATION_JOINT_REDUCED_COORDINATE: { const PxArticulationJointReducedCoordinate& artJoint = static_cast<const PxArticulationJointReducedCoordinate&>(object); OMNI_PVD_DESTROY(OMNI_PVD_CONTEXT_HANDLE, PxArticulationJointReducedCoordinate, artJoint); } break; case physx::PxConcreteType::eRIGID_DYNAMIC: { const PxRigidDynamic& rd = static_cast<const PxRigidDynamic&>(object); OMNI_PVD_REMOVE(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, rigidDynamics, physics, rd); OMNI_PVD_DESTROY(OMNI_PVD_CONTEXT_HANDLE, PxActor, rd); } break; case physx::PxConcreteType::eRIGID_STATIC: { const PxRigidStatic& rs = static_cast<const PxRigidStatic&>(object); OMNI_PVD_REMOVE(OMNI_PVD_CONTEXT_HANDLE, PxPhysics, rigidStatics, physics, rs); OMNI_PVD_DESTROY(OMNI_PVD_CONTEXT_HANDLE, PxActor, rs); } break; } } OmniPvdPxScene* OmniPvdPxSampler::getSampledScene(physx::NpScene* scene) { physx::PxMutex::ScopedLock myLock(samplerInternals->mSampledScenesMutex); const physx::PxHashMap<physx::NpScene*, OmniPvdPxScene*>::Entry* entry = samplerInternals->mSampledScenes.find(scene); if (entry) { return entry->second; } else { OmniPvdPxScene* ovdScene = PX_NEW(OmniPvdPxScene)(); samplerInternals->mSampledScenes[scene] = ovdScene; return ovdScene; } } // Returns true if the Geom was not yet seen and added bool OmniPvdSamplerInternals::addSharedMeshIfNotSeen(const void* geom, OmniPvdSharedMeshEnum geomEnum) { physx::PxMutex::ScopedLock myLock(samplerInternals->mSharedGeomsMutex); const physx::PxHashMap<const void*, OmniPvdSharedMeshEnum>::Entry* entry = samplerInternals->mSharedMeshesMap.find(geom); if (entry) { return false; } else { samplerInternals->mSharedMeshesMap[geom] = geomEnum; return true; } } /////////////////////////////////////////////////////////////////////////////// OmniPvdPxSampler* OmniPvdPxSampler::getInstance() { PX_ASSERT(&physx::NpPhysics::getInstance() != NULL); return &physx::NpPhysics::getInstance() ? physx::NpPhysics::getInstance().mOmniPvdSampler : NULL; } namespace physx { const OmniPvdPxCoreRegistrationData* NpOmniPvdGetPxCoreRegistrationData() { if (samplerInternals) { return &samplerInternals->mPvdStream.mRegistrationData; } else { return NULL; } } physx::NpOmniPvd* NpOmniPvdGetInstance() { if (samplerInternals) { return samplerInternals->mPvdStream.mOmniPvdInstance; } else { return NULL; } } } #endif
60,308
C++
39.448692
182
0.7598
NVIDIA-Omniverse/PhysX/physx/source/physx/src/omnipvd/OmniPvdPxSampler.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef OMNI_PVD_PX_SAMPLER_H #define OMNI_PVD_PX_SAMPLER_H #if PX_SUPPORT_OMNI_PVD #include "foundation/PxSimpleTypes.h" #include "foundation/PxHashMap.h" #include "foundation/PxMutex.h" #include "foundation/PxUserAllocated.h" #include "OmniPvdChunkAlloc.h" namespace physx { class PxScene; class PxBase; class NpScene; class PxActor; class PxShape; class PxMaterial; class PxFEMClothMaterial; class PxFEMMaterial; class PxFEMSoftBodyMaterial; class PxFLIPMaterial; class PxMPMMaterial; class PxParticleMaterial; class PxPBDMaterial; struct OmniPvdPxCoreRegistrationData; class NpOmniPvd; } void streamActorName(const physx::PxActor & a, const char* name); void streamSceneName(const physx::PxScene & s, const char* name); void streamShapeMaterials(const physx::PxShape&, physx::PxMaterial* const * mats, physx::PxU32 nbrMaterials); void streamShapeMaterials(const physx::PxShape&, physx::PxFEMClothMaterial* const * mats, physx::PxU32 nbrMaterials); void streamShapeMaterials(const physx::PxShape&, physx::PxFEMMaterial* const * mats, physx::PxU32 nbrMaterials); void streamShapeMaterials(const physx::PxShape&, physx::PxFEMSoftBodyMaterial* const * mats, physx::PxU32 nbrMaterials); void streamShapeMaterials(const physx::PxShape&, physx::PxFLIPMaterial* const * mats, physx::PxU32 nbrMaterials); void streamShapeMaterials(const physx::PxShape&, physx::PxMPMMaterial* const * mats, physx::PxU32 nbrMaterials); void streamShapeMaterials(const physx::PxShape&, physx::PxParticleMaterial* const * mats, physx::PxU32 nbrMaterials); void streamShapeMaterials(const physx::PxShape&, physx::PxPBDMaterial* const * mats, physx::PxU32 nbrMaterials); enum OmniPvdSharedMeshEnum { eOmniPvdTriMesh = 0, eOmniPvdConvexMesh = 1, eOmniPvdHeightField = 2, }; class OmniPvdWriter; class OmniPvdPxScene; class OmniPvdPxSampler : public physx::PxUserAllocated { public: OmniPvdPxSampler(); ~OmniPvdPxSampler(); void startSampling(); bool isSampling(); void setOmniPvdInstance(physx::NpOmniPvd* omniPvdIntance); // writes all contacts to the stream void streamSceneContacts(physx::NpScene& scene); // call at the end of a simulation step: void sampleScene(physx::NpScene* scene); static OmniPvdPxSampler* getInstance(); void onObjectAdd(const physx::PxBase& object); void onObjectRemove(const physx::PxBase& object); private: OmniPvdPxScene* getSampledScene(physx::NpScene* scene); }; namespace physx { const OmniPvdPxCoreRegistrationData* NpOmniPvdGetPxCoreRegistrationData(); NpOmniPvd* NpOmniPvdGetInstance(); } #endif #endif
4,271
C
34.305785
120
0.777336
NVIDIA-Omniverse/PhysX/physx/source/physx/src/omnipvd/OmniPvdTypes.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. // Declare OMNI_PVD Types and Attributes here! // The last two attribute parameters could now be derived from the other data, so could be removed in a refactor, // though explicit control may be better. // Note that HANDLE attributes have to use (Type const *) style, otherwise it won't compile! //////////////////////////////////////////////////////////////////////////////// // Bitfields //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_ENUM_BEGIN (PxSceneFlag) OMNI_PVD_ENUM_VALUE (PxSceneFlag, eENABLE_ACTIVE_ACTORS) OMNI_PVD_ENUM_VALUE (PxSceneFlag, eENABLE_CCD) OMNI_PVD_ENUM_VALUE (PxSceneFlag, eDISABLE_CCD_RESWEEP) OMNI_PVD_ENUM_VALUE (PxSceneFlag, eENABLE_PCM) OMNI_PVD_ENUM_VALUE (PxSceneFlag, eDISABLE_CONTACT_REPORT_BUFFER_RESIZE) OMNI_PVD_ENUM_VALUE (PxSceneFlag, eDISABLE_CONTACT_CACHE) OMNI_PVD_ENUM_VALUE (PxSceneFlag, eREQUIRE_RW_LOCK) OMNI_PVD_ENUM_VALUE (PxSceneFlag, eENABLE_STABILIZATION) OMNI_PVD_ENUM_VALUE (PxSceneFlag, eENABLE_AVERAGE_POINT) OMNI_PVD_ENUM_VALUE (PxSceneFlag, eEXCLUDE_KINEMATICS_FROM_ACTIVE_ACTORS) OMNI_PVD_ENUM_VALUE (PxSceneFlag, eENABLE_GPU_DYNAMICS) OMNI_PVD_ENUM_VALUE (PxSceneFlag, eENABLE_ENHANCED_DETERMINISM) OMNI_PVD_ENUM_VALUE (PxSceneFlag, eENABLE_FRICTION_EVERY_ITERATION) OMNI_PVD_ENUM_VALUE (PxSceneFlag, eENABLE_DIRECT_GPU_API) OMNI_PVD_ENUM_END (PxSceneFlag) OMNI_PVD_ENUM_BEGIN (PxMaterialFlag) OMNI_PVD_ENUM_VALUE (PxMaterialFlag, eDISABLE_FRICTION) OMNI_PVD_ENUM_VALUE (PxMaterialFlag, eDISABLE_STRONG_FRICTION) OMNI_PVD_ENUM_VALUE (PxMaterialFlag, eIMPROVED_PATCH_FRICTION) OMNI_PVD_ENUM_END (PxMaterialFlag) OMNI_PVD_ENUM_BEGIN (PxActorFlag) OMNI_PVD_ENUM_VALUE (PxActorFlag, eVISUALIZATION) OMNI_PVD_ENUM_VALUE (PxActorFlag, eDISABLE_GRAVITY) OMNI_PVD_ENUM_VALUE (PxActorFlag, eSEND_SLEEP_NOTIFIES) OMNI_PVD_ENUM_VALUE (PxActorFlag, eDISABLE_SIMULATION) OMNI_PVD_ENUM_END (PxActorFlag) OMNI_PVD_ENUM_BEGIN (PxRigidBodyFlag) OMNI_PVD_ENUM_VALUE (PxRigidBodyFlag, eKINEMATIC) OMNI_PVD_ENUM_VALUE (PxRigidBodyFlag, eUSE_KINEMATIC_TARGET_FOR_SCENE_QUERIES) OMNI_PVD_ENUM_VALUE (PxRigidBodyFlag, eENABLE_CCD) OMNI_PVD_ENUM_VALUE (PxRigidBodyFlag, eENABLE_CCD_FRICTION) OMNI_PVD_ENUM_VALUE (PxRigidBodyFlag, eENABLE_POSE_INTEGRATION_PREVIEW) OMNI_PVD_ENUM_VALUE (PxRigidBodyFlag, eENABLE_SPECULATIVE_CCD) OMNI_PVD_ENUM_VALUE (PxRigidBodyFlag, eENABLE_CCD_MAX_CONTACT_IMPULSE) OMNI_PVD_ENUM_VALUE (PxRigidBodyFlag, eRETAIN_ACCELERATIONS) OMNI_PVD_ENUM_VALUE (PxRigidBodyFlag, eFORCE_KINE_KINE_NOTIFICATIONS) OMNI_PVD_ENUM_VALUE (PxRigidBodyFlag, eFORCE_STATIC_KINE_NOTIFICATIONS) OMNI_PVD_ENUM_VALUE (PxRigidBodyFlag, eENABLE_GYROSCOPIC_FORCES) OMNI_PVD_ENUM_VALUE (PxRigidBodyFlag, eRESERVED) OMNI_PVD_ENUM_END (PxRigidBodyFlag) OMNI_PVD_ENUM_BEGIN (PxArticulationFlag) OMNI_PVD_ENUM_VALUE (PxArticulationFlag, eFIX_BASE) OMNI_PVD_ENUM_VALUE (PxArticulationFlag, eDRIVE_LIMITS_ARE_FORCES) OMNI_PVD_ENUM_VALUE (PxArticulationFlag, eDISABLE_SELF_COLLISION) OMNI_PVD_ENUM_VALUE (PxArticulationFlag, eCOMPUTE_JOINT_FORCES) OMNI_PVD_ENUM_END (PxArticulationFlag) OMNI_PVD_ENUM_BEGIN (PxRigidDynamicLockFlag) OMNI_PVD_ENUM_VALUE (PxRigidDynamicLockFlag, eLOCK_LINEAR_X) OMNI_PVD_ENUM_VALUE (PxRigidDynamicLockFlag, eLOCK_LINEAR_Y) OMNI_PVD_ENUM_VALUE (PxRigidDynamicLockFlag, eLOCK_LINEAR_Z) OMNI_PVD_ENUM_VALUE (PxRigidDynamicLockFlag, eLOCK_ANGULAR_X) OMNI_PVD_ENUM_VALUE (PxRigidDynamicLockFlag, eLOCK_ANGULAR_Y) OMNI_PVD_ENUM_VALUE (PxRigidDynamicLockFlag, eLOCK_ANGULAR_Z) OMNI_PVD_ENUM_END (PxRigidDynamicLockFlag) OMNI_PVD_ENUM_BEGIN (PxShapeFlag) OMNI_PVD_ENUM_VALUE (PxShapeFlag, eSIMULATION_SHAPE) OMNI_PVD_ENUM_VALUE (PxShapeFlag, eSCENE_QUERY_SHAPE) OMNI_PVD_ENUM_VALUE (PxShapeFlag, eTRIGGER_SHAPE) OMNI_PVD_ENUM_VALUE (PxShapeFlag, eVISUALIZATION) OMNI_PVD_ENUM_END (PxShapeFlag) //////////////////////////////////////////////////////////////////////////////// // Single value enums //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_ENUM_BEGIN (PxFrictionType) OMNI_PVD_ENUM_VALUE (PxFrictionType, ePATCH) OMNI_PVD_ENUM_VALUE (PxFrictionType, eONE_DIRECTIONAL) OMNI_PVD_ENUM_VALUE (PxFrictionType, eTWO_DIRECTIONAL) OMNI_PVD_ENUM_END (PxFrictionType) OMNI_PVD_ENUM_BEGIN (PxBroadPhaseType) OMNI_PVD_ENUM_VALUE (PxBroadPhaseType, eSAP) OMNI_PVD_ENUM_VALUE (PxBroadPhaseType, eMBP) OMNI_PVD_ENUM_VALUE (PxBroadPhaseType, eABP) OMNI_PVD_ENUM_VALUE (PxBroadPhaseType, eGPU) OMNI_PVD_ENUM_END (PxBroadPhaseType) OMNI_PVD_ENUM_BEGIN (PxSolverType) OMNI_PVD_ENUM_VALUE (PxSolverType, ePGS) OMNI_PVD_ENUM_VALUE (PxSolverType, eTGS) OMNI_PVD_ENUM_END (PxSolverType) OMNI_PVD_ENUM_BEGIN (PxPairFilteringMode) OMNI_PVD_ENUM_VALUE (PxPairFilteringMode, eKEEP) OMNI_PVD_ENUM_VALUE (PxPairFilteringMode, eSUPPRESS) OMNI_PVD_ENUM_VALUE (PxPairFilteringMode, eKILL) OMNI_PVD_ENUM_END (PxPairFilteringMode) OMNI_PVD_ENUM_BEGIN (PxCombineMode) OMNI_PVD_ENUM_VALUE (PxCombineMode, eAVERAGE) OMNI_PVD_ENUM_VALUE (PxCombineMode, eMIN) OMNI_PVD_ENUM_VALUE (PxCombineMode, eMULTIPLY) OMNI_PVD_ENUM_VALUE (PxCombineMode, eMAX) OMNI_PVD_ENUM_END (PxCombineMode) OMNI_PVD_ENUM_BEGIN (PxActorType) OMNI_PVD_ENUM_VALUE (PxActorType, eRIGID_STATIC) OMNI_PVD_ENUM_VALUE (PxActorType, eRIGID_DYNAMIC) OMNI_PVD_ENUM_VALUE (PxActorType, eARTICULATION_LINK) OMNI_PVD_ENUM_VALUE (PxActorType, eSOFTBODY) OMNI_PVD_ENUM_VALUE (PxActorType, eFEMCLOTH) OMNI_PVD_ENUM_VALUE (PxActorType, ePBD_PARTICLESYSTEM) OMNI_PVD_ENUM_VALUE (PxActorType, eFLIP_PARTICLESYSTEM) OMNI_PVD_ENUM_VALUE (PxActorType, eMPM_PARTICLESYSTEM) OMNI_PVD_ENUM_VALUE (PxActorType, eHAIRSYSTEM) OMNI_PVD_ENUM_END (PxActorType) OMNI_PVD_ENUM_BEGIN (PxArticulationJointType) OMNI_PVD_ENUM_VALUE (PxArticulationJointType, eFIX) OMNI_PVD_ENUM_VALUE (PxArticulationJointType, ePRISMATIC) OMNI_PVD_ENUM_VALUE (PxArticulationJointType, eREVOLUTE) OMNI_PVD_ENUM_VALUE (PxArticulationJointType, eREVOLUTE_UNWRAPPED) OMNI_PVD_ENUM_VALUE (PxArticulationJointType, eSPHERICAL) OMNI_PVD_ENUM_VALUE (PxArticulationJointType, eUNDEFINED) OMNI_PVD_ENUM_END (PxArticulationJointType) OMNI_PVD_ENUM_BEGIN (PxArticulationMotion) OMNI_PVD_ENUM_VALUE (PxArticulationMotion, eLOCKED) OMNI_PVD_ENUM_VALUE (PxArticulationMotion, eLIMITED) OMNI_PVD_ENUM_VALUE (PxArticulationMotion, eFREE) OMNI_PVD_ENUM_END (PxArticulationMotion) OMNI_PVD_ENUM_BEGIN (PxArticulationDriveType) OMNI_PVD_ENUM_VALUE (PxArticulationDriveType, eFORCE) OMNI_PVD_ENUM_VALUE (PxArticulationDriveType, eACCELERATION) OMNI_PVD_ENUM_VALUE (PxArticulationDriveType, eTARGET) OMNI_PVD_ENUM_VALUE (PxArticulationDriveType, eVELOCITY) OMNI_PVD_ENUM_VALUE (PxArticulationDriveType, eNONE) OMNI_PVD_ENUM_END (PxArticulationDriveType) //////////////////////////////////////////////////////////////////////////////// // Classes //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// // PxPhysics //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_BEGIN (PxPhysics) OMNI_PVD_ATTRIBUTE_UNIQUE_LIST (PxPhysics, scenes, PxScene) OMNI_PVD_ATTRIBUTE_UNIQUE_LIST (PxPhysics, heightFields, PxHeightField) OMNI_PVD_ATTRIBUTE_UNIQUE_LIST (PxPhysics, convexMeshes, PxConvexMesh) OMNI_PVD_ATTRIBUTE_UNIQUE_LIST (PxPhysics, triangleMeshes, PxTriangleMesh) OMNI_PVD_ATTRIBUTE_UNIQUE_LIST (PxPhysics, tetrahedronMeshes, PxTetrahedronMesh) OMNI_PVD_ATTRIBUTE_UNIQUE_LIST (PxPhysics, softBodyMeshes, PxSoftBodyMesh) OMNI_PVD_ATTRIBUTE_UNIQUE_LIST (PxPhysics, shapes, PxShape) OMNI_PVD_ATTRIBUTE_UNIQUE_LIST (PxPhysics, bvhs, PxBVH) OMNI_PVD_ATTRIBUTE_UNIQUE_LIST (PxPhysics, materials, PxMaterial) OMNI_PVD_ATTRIBUTE_UNIQUE_LIST (PxPhysics, FEMSoftBodyMaterials, PxFEMSoftBodyMaterial) OMNI_PVD_ATTRIBUTE_UNIQUE_LIST (PxPhysics, FEMClothMaterials, PxFEMClothMaterial) OMNI_PVD_ATTRIBUTE_UNIQUE_LIST (PxPhysics, PBDMaterials, PxPBDMaterial) OMNI_PVD_ATTRIBUTE_UNIQUE_LIST (PxPhysics, FLIPMaterials, PxFLIPMaterial) OMNI_PVD_ATTRIBUTE_UNIQUE_LIST (PxPhysics, MPMMaterials, PxMPMMaterial) OMNI_PVD_ATTRIBUTE_UNIQUE_LIST (PxPhysics, rigidDynamics, PxActor) OMNI_PVD_ATTRIBUTE_UNIQUE_LIST (PxPhysics, rigidStatics, PxActor) OMNI_PVD_ATTRIBUTE_UNIQUE_LIST (PxPhysics, aggregates, PxAggregate) OMNI_PVD_ATTRIBUTE_UNIQUE_LIST (PxPhysics, articulations, PxArticulationReducedCoordinate) OMNI_PVD_ATTRIBUTE_ARRAY_FIXED_SIZE (PxPhysics, tolerancesScale, PxTolerancesScale, OmniPvdDataType::eFLOAT32, 2) OMNI_PVD_CLASS_END (PxPhysics) //////////////////////////////////////////////////////////////////////////////// // PxScene //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_BEGIN (PxScene) OMNI_PVD_ATTRIBUTE_UNIQUE_LIST (PxScene, actors, PxActor) OMNI_PVD_ATTRIBUTE_UNIQUE_LIST (PxScene, articulations, PxArticulationReducedCoordinate) OMNI_PVD_ATTRIBUTE_UNIQUE_LIST (PxScene, aggregates, PxAggregate) OMNI_PVD_ATTRIBUTE_FLAG (PxScene, flags, PxSceneFlags, PxSceneFlag) OMNI_PVD_ATTRIBUTE_FLAG (PxScene, frictionType, PxFrictionType::Enum, PxFrictionType) OMNI_PVD_ATTRIBUTE_FLAG (PxScene, broadPhaseType, PxBroadPhaseType::Enum, PxBroadPhaseType) OMNI_PVD_ATTRIBUTE_FLAG (PxScene, kineKineFilteringMode, PxPairFilteringMode::Enum, PxPairFilteringMode) OMNI_PVD_ATTRIBUTE_FLAG (PxScene, staticKineFilteringMode,PxPairFilteringMode::Enum, PxPairFilteringMode) OMNI_PVD_ATTRIBUTE_FLAG (PxScene, solverType, PxSolverType::Enum, PxSolverType) OMNI_PVD_ATTRIBUTE_STRING (PxScene, name) OMNI_PVD_ATTRIBUTE_ARRAY_FIXED_SIZE (PxScene, gravity, PxVec3, OmniPvdDataType::eFLOAT32, 3) OMNI_PVD_ATTRIBUTE (PxScene, bounceThresholdVelocity,PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE (PxScene, frictionOffsetThreshold,PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE (PxScene, frictionCorrelationDistance, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE (PxScene, solverOffsetSlop, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE (PxScene, solverBatchSize, PxU32, OmniPvdDataType::eUINT32) OMNI_PVD_ATTRIBUTE (PxScene, solverArticulationBatchSize, PxU32, OmniPvdDataType::eUINT32) OMNI_PVD_ATTRIBUTE (PxScene, nbContactDataBlocks, PxU32, OmniPvdDataType::eUINT32) OMNI_PVD_ATTRIBUTE (PxScene, maxNbContactDataBlocks, PxU32, OmniPvdDataType::eUINT32) OMNI_PVD_ATTRIBUTE (PxScene, maxBiasCoefficient, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE (PxScene, contactReportStreamBufferSize, PxU32, OmniPvdDataType::eUINT32) OMNI_PVD_ATTRIBUTE (PxScene, ccdMaxPasses, PxU32, OmniPvdDataType::eUINT32) OMNI_PVD_ATTRIBUTE (PxScene, ccdThreshold, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE (PxScene, ccdMaxSeparation, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE (PxScene, wakeCounterResetValue, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE (PxScene, hasCPUDispatcher, bool, OmniPvdDataType::eUINT8) OMNI_PVD_ATTRIBUTE (PxScene, hasCUDAContextManager, bool, OmniPvdDataType::eUINT8) OMNI_PVD_ATTRIBUTE (PxScene, hasSimulationEventCallback, bool, OmniPvdDataType::eUINT8) OMNI_PVD_ATTRIBUTE (PxScene, hasContactModifyCallback, bool, OmniPvdDataType::eUINT8) OMNI_PVD_ATTRIBUTE (PxScene, hasCCDContactModifyCallback, bool, OmniPvdDataType::eUINT8) OMNI_PVD_ATTRIBUTE (PxScene, hasBroadPhaseCallback, bool, OmniPvdDataType::eUINT8) OMNI_PVD_ATTRIBUTE (PxScene, hasFilterCallback, bool, OmniPvdDataType::eUINT8) OMNI_PVD_ATTRIBUTE (PxScene, limitsMaxNbActors, PxU32, OmniPvdDataType::eUINT32) OMNI_PVD_ATTRIBUTE (PxScene, limitsMaxNbBodies, PxU32, OmniPvdDataType::eUINT32) OMNI_PVD_ATTRIBUTE (PxScene, limitsMaxNbStaticShapes,PxU32, OmniPvdDataType::eUINT32) OMNI_PVD_ATTRIBUTE (PxScene, limitsMaxNbDynamicShapes, PxU32, OmniPvdDataType::eUINT32) OMNI_PVD_ATTRIBUTE (PxScene, limitsMaxNbAggregates, PxU32, OmniPvdDataType::eUINT32) OMNI_PVD_ATTRIBUTE (PxScene, limitsMaxNbConstraints, PxU32, OmniPvdDataType::eUINT32) OMNI_PVD_ATTRIBUTE (PxScene, limitsMaxNbRegions, PxU32, OmniPvdDataType::eUINT32) OMNI_PVD_ATTRIBUTE (PxScene, limitsMaxNbBroadPhaseOverlaps, PxU32, OmniPvdDataType::eUINT32) OMNI_PVD_ATTRIBUTE_ARRAY_FIXED_SIZE (PxScene, sanityBounds, PxBounds3, OmniPvdDataType::eFLOAT32, 6) OMNI_PVD_ATTRIBUTE_ARRAY_FIXED_SIZE (PxScene, gpuDynamicsConfig, PxgDynamicsMemoryConfig, OmniPvdDataType::eUINT32, 12) OMNI_PVD_ATTRIBUTE (PxScene, gpuMaxNumPartitions, PxU32, OmniPvdDataType::eUINT32) OMNI_PVD_ATTRIBUTE (PxScene, gpuMaxNumStaticPartitions, PxU32, OmniPvdDataType::eUINT32) OMNI_PVD_ATTRIBUTE (PxScene, gpuComputeVersion, PxU32, OmniPvdDataType::eUINT32) OMNI_PVD_ATTRIBUTE (PxScene, contactPairSlabSize, PxU32, OmniPvdDataType::eUINT32) OMNI_PVD_ATTRIBUTE_ARRAY_FIXED_SIZE (PxScene, tolerancesScale, PxTolerancesScale, OmniPvdDataType::eFLOAT32, 2) OMNI_PVD_ATTRIBUTE (PxScene, pairCount, PxU32, OmniPvdDataType::eUINT32) OMNI_PVD_ATTRIBUTE_ARRAY_VARIABLE_SIZE (PxScene, pairsActors, PxActor*, OmniPvdDataType::eOBJECT_HANDLE) // 2 for each pair OMNI_PVD_ATTRIBUTE_ARRAY_VARIABLE_SIZE (PxScene, pairsContactCounts, PxU32, OmniPvdDataType::eUINT32) // 1 for each pair OMNI_PVD_ATTRIBUTE_ARRAY_VARIABLE_SIZE (PxScene, pairsContactPoints, PxReal, OmniPvdDataType::eFLOAT32) // 3 for each contact OMNI_PVD_ATTRIBUTE_ARRAY_VARIABLE_SIZE (PxScene, pairsContactNormals, PxReal, OmniPvdDataType::eFLOAT32) // 3 for each contact OMNI_PVD_ATTRIBUTE_ARRAY_VARIABLE_SIZE (PxScene, pairsContactSeparations, PxReal, OmniPvdDataType::eFLOAT32) // 1 for each contact OMNI_PVD_ATTRIBUTE_ARRAY_VARIABLE_SIZE (PxScene, pairsContactShapes, PxShape*, OmniPvdDataType::eOBJECT_HANDLE) // 2 for each contact OMNI_PVD_ATTRIBUTE_ARRAY_VARIABLE_SIZE (PxScene, pairsContactFacesIndices, PxU32, OmniPvdDataType::eUINT32) // 2 for each contact OMNI_PVD_CLASS_END (PxScene) //////////////////////////////////////////////////////////////////////////////// // PxBaseMaterial //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_BEGIN (PxBaseMaterial) OMNI_PVD_CLASS_END (PxBaseMaterial) //////////////////////////////////////////////////////////////////////////////// // PxMaterial //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_DERIVED_BEGIN (PxMaterial, PxBaseMaterial) OMNI_PVD_ATTRIBUTE_FLAG (PxMaterial, flags, PxMaterialFlags, PxMaterialFlag) OMNI_PVD_ATTRIBUTE_FLAG (PxMaterial, frictionCombineMode, PxCombineMode::Enum, PxCombineMode) OMNI_PVD_ATTRIBUTE_FLAG (PxMaterial, restitutionCombineMode,PxCombineMode::Enum, PxCombineMode) OMNI_PVD_ATTRIBUTE (PxMaterial, staticFriction, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE (PxMaterial, dynamicFriction, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE (PxMaterial, restitution, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE (PxMaterial, damping, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_CLASS_END (PxMaterial) //////////////////////////////////////////////////////////////////////////////// // PxFEMSoftBodyMaterial //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_DERIVED_BEGIN (PxFEMSoftBodyMaterial, PxBaseMaterial) OMNI_PVD_CLASS_END (PxFEMSoftBodyMaterial) //////////////////////////////////////////////////////////////////////////////// // PxFEMClothMaterial //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_DERIVED_BEGIN (PxFEMClothMaterial, PxBaseMaterial) OMNI_PVD_CLASS_END (PxFEMClothMaterial) //////////////////////////////////////////////////////////////////////////////// // PxPBDMaterial //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_DERIVED_BEGIN (PxPBDMaterial, PxBaseMaterial) OMNI_PVD_CLASS_END (PxPBDMaterial) //////////////////////////////////////////////////////////////////////////////// // PxFLIPMaterial //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_DERIVED_BEGIN (PxFLIPMaterial, PxBaseMaterial) OMNI_PVD_CLASS_END (PxFLIPMaterial) //////////////////////////////////////////////////////////////////////////////// // PxMPMMaterial //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_DERIVED_BEGIN (PxMPMMaterial, PxBaseMaterial) OMNI_PVD_CLASS_END (PxMPMMaterial) //////////////////////////////////////////////////////////////////////////////// // PxAggregate //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_BEGIN (PxAggregate) OMNI_PVD_ATTRIBUTE_UNIQUE_LIST (PxAggregate, actors, PxActor) OMNI_PVD_ATTRIBUTE (PxAggregate, selfCollision, bool, OmniPvdDataType::eUINT8) OMNI_PVD_ATTRIBUTE (PxAggregate, maxNbShapes, PxU32, OmniPvdDataType::eUINT32) OMNI_PVD_ATTRIBUTE (PxAggregate, scene, PxScene* const, OmniPvdDataType::eOBJECT_HANDLE) OMNI_PVD_CLASS_END (PxAggregate) //////////////////////////////////////////////////////////////////////////////// // PxActor // Missing // aggregate? // scene? //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_BEGIN (PxActor) OMNI_PVD_ATTRIBUTE_FLAG (PxActor, type, PxActorType::Enum, PxActorType) OMNI_PVD_ATTRIBUTE_FLAG (PxActor, flags, PxActorFlags, PxActorFlag) OMNI_PVD_ATTRIBUTE_STRING (PxActor, name) OMNI_PVD_ATTRIBUTE_ARRAY_FIXED_SIZE (PxActor, worldBounds, PxBounds3, OmniPvdDataType::eFLOAT32, 6) OMNI_PVD_ATTRIBUTE (PxActor, dominance, PxDominanceGroup, OmniPvdDataType::eUINT8) OMNI_PVD_ATTRIBUTE (PxActor, ownerClient, PxClientID, OmniPvdDataType::eUINT8) OMNI_PVD_CLASS_END (PxActor) //////////////////////////////////////////////////////////////////////////////// // PxRigidActor // Missing // internalActorIndex? // constraints? // Remap // translation + rotation -> globalPose? //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_DERIVED_BEGIN (PxRigidActor, PxActor) OMNI_PVD_ATTRIBUTE_ARRAY_FIXED_SIZE (PxRigidActor, translation, PxVec3, OmniPvdDataType::eFLOAT32, 3) OMNI_PVD_ATTRIBUTE_ARRAY_FIXED_SIZE (PxRigidActor, rotation, PxQuat, OmniPvdDataType::eFLOAT32, 4) OMNI_PVD_ATTRIBUTE_UNIQUE_LIST (PxRigidActor, shapes, PxShape) OMNI_PVD_CLASS_END (PxRigidActor) //////////////////////////////////////////////////////////////////////////////// // PxRigidStatic //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_DERIVED_BEGIN (PxRigidStatic, PxRigidActor) OMNI_PVD_CLASS_END (PxRigidStatic) //////////////////////////////////////////////////////////////////////////////// // PxRigidBody // Missing // islandNodeIndex? // force? // torque? //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_DERIVED_BEGIN (PxRigidBody, PxRigidActor) OMNI_PVD_ATTRIBUTE_ARRAY_FIXED_SIZE (PxRigidBody, cMassLocalPose, PxTransform, OmniPvdDataType::eFLOAT32, 7) OMNI_PVD_ATTRIBUTE (PxRigidBody, mass, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE_ARRAY_FIXED_SIZE (PxRigidBody, massSpaceInertiaTensor, PxVec3, OmniPvdDataType::eFLOAT32, 3) OMNI_PVD_ATTRIBUTE (PxRigidBody, linearDamping, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE (PxRigidBody, angularDamping, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE_ARRAY_FIXED_SIZE (PxRigidBody, linearVelocity, PxVec3, OmniPvdDataType::eFLOAT32, 3) OMNI_PVD_ATTRIBUTE_ARRAY_FIXED_SIZE (PxRigidBody, angularVelocity, PxVec3, OmniPvdDataType::eFLOAT32, 3) OMNI_PVD_ATTRIBUTE (PxRigidBody, maxLinearVelocity, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE (PxRigidBody, maxAngularVelocity, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE_FLAG (PxRigidBody, rigidBodyFlags, PxRigidBodyFlags, PxRigidBodyFlag) OMNI_PVD_ATTRIBUTE (PxRigidBody, minAdvancedCCDCoefficient, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE (PxRigidBody, maxDepenetrationVelocity, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE (PxRigidBody, maxContactImpulse, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE (PxRigidBody, contactSlopCoefficient, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_CLASS_END (PxRigidBody) //////////////////////////////////////////////////////////////////////////////// // PxRigidDynamic // Missing // kinematicTarget? //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_DERIVED_BEGIN (PxRigidDynamic, PxRigidBody) OMNI_PVD_ATTRIBUTE (PxRigidDynamic, isSleeping, bool, OmniPvdDataType::eUINT8) OMNI_PVD_ATTRIBUTE (PxRigidDynamic, sleepThreshold, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE (PxRigidDynamic, stabilizationThreshold, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE_FLAG (PxRigidDynamic, rigidDynamicLockFlags, PxRigidDynamicLockFlags, PxRigidDynamicLockFlag) OMNI_PVD_ATTRIBUTE (PxRigidDynamic, wakeCounter, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE (PxRigidDynamic, positionIterations, PxU32, OmniPvdDataType::eUINT32) OMNI_PVD_ATTRIBUTE (PxRigidDynamic, velocityIterations, PxU32, OmniPvdDataType::eUINT32) OMNI_PVD_ATTRIBUTE (PxRigidDynamic, contactReportThreshold, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_CLASS_END (PxRigidDynamic) //////////////////////////////////////////////////////////////////////////////// // PxArticulationLink // Missing // inboundJoint? // children? // linkIndex? //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_DERIVED_BEGIN (PxArticulationLink, PxRigidBody) OMNI_PVD_ATTRIBUTE (PxArticulationLink, articulation, PxArticulationReducedCoordinate* const, OmniPvdDataType::eOBJECT_HANDLE) OMNI_PVD_ATTRIBUTE (PxArticulationLink, inboundJointDOF, PxU32, OmniPvdDataType::eUINT32) OMNI_PVD_ATTRIBUTE (PxArticulationLink, CFMScale, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_CLASS_END (PxArticulationLink) //////////////////////////////////////////////////////////////////////////////// // PxArticulationReducedCoordinate //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_BEGIN (PxArticulationReducedCoordinate) OMNI_PVD_ATTRIBUTE (PxArticulationReducedCoordinate, positionIterations, PxU32, OmniPvdDataType::eUINT32) OMNI_PVD_ATTRIBUTE (PxArticulationReducedCoordinate, velocityIterations, PxU32, OmniPvdDataType::eUINT32) OMNI_PVD_ATTRIBUTE (PxArticulationReducedCoordinate, isSleeping, bool, OmniPvdDataType::eUINT8) OMNI_PVD_ATTRIBUTE (PxArticulationReducedCoordinate, sleepThreshold, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE (PxArticulationReducedCoordinate, stabilizationThreshold, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE (PxArticulationReducedCoordinate, wakeCounter, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE (PxArticulationReducedCoordinate, maxLinearVelocity, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE (PxArticulationReducedCoordinate, maxAngularVelocity, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE_UNIQUE_LIST (PxArticulationReducedCoordinate, links, PxArticulationLink) OMNI_PVD_ATTRIBUTE_ARRAY_FIXED_SIZE (PxArticulationReducedCoordinate, worldBounds, PxBounds3, OmniPvdDataType::eFLOAT32, 6) OMNI_PVD_ATTRIBUTE_FLAG (PxArticulationReducedCoordinate, articulationFlags, PxArticulationFlags, PxArticulationFlag) OMNI_PVD_ATTRIBUTE (PxArticulationReducedCoordinate, dofs, PxU32, OmniPvdDataType::eUINT32) OMNI_PVD_CLASS_END (PxArticulationReducedCoordinate) //////////////////////////////////////////////////////////////////////////////// // PxArticulationJointReducedCoordinate //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_BEGIN (PxArticulationJointReducedCoordinate) OMNI_PVD_ATTRIBUTE (PxArticulationJointReducedCoordinate, parentLink, PxArticulationLink* const, OmniPvdDataType::eOBJECT_HANDLE) OMNI_PVD_ATTRIBUTE (PxArticulationJointReducedCoordinate, childLink, PxArticulationLink* const, OmniPvdDataType::eOBJECT_HANDLE) OMNI_PVD_ATTRIBUTE_ARRAY_FIXED_SIZE (PxArticulationJointReducedCoordinate, parentTranslation, PxVec3, OmniPvdDataType::eFLOAT32, 3) OMNI_PVD_ATTRIBUTE_ARRAY_FIXED_SIZE (PxArticulationJointReducedCoordinate, parentRotation, PxQuat, OmniPvdDataType::eFLOAT32, 4) OMNI_PVD_ATTRIBUTE_ARRAY_FIXED_SIZE (PxArticulationJointReducedCoordinate, childTranslation, PxVec3, OmniPvdDataType::eFLOAT32, 3) OMNI_PVD_ATTRIBUTE_ARRAY_FIXED_SIZE (PxArticulationJointReducedCoordinate, childRotation, PxQuat, OmniPvdDataType::eFLOAT32, 4) OMNI_PVD_ATTRIBUTE_FLAG (PxArticulationJointReducedCoordinate, type, PxArticulationJointType::Enum, PxArticulationJointType) OMNI_PVD_ATTRIBUTE_ARRAY_VARIABLE_SIZE (PxArticulationJointReducedCoordinate, motion, PxArticulationMotion::Enum, OmniPvdDataType::eUINT32) OMNI_PVD_ATTRIBUTE_ARRAY_VARIABLE_SIZE (PxArticulationJointReducedCoordinate, armature, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE (PxArticulationJointReducedCoordinate, frictionCoefficient, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE (PxArticulationJointReducedCoordinate, maxJointVelocity, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE_ARRAY_VARIABLE_SIZE (PxArticulationJointReducedCoordinate, jointPosition, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE_ARRAY_VARIABLE_SIZE (PxArticulationJointReducedCoordinate, jointVelocity, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE_STRING (PxArticulationJointReducedCoordinate, concreteTypeName) OMNI_PVD_ATTRIBUTE_ARRAY_VARIABLE_SIZE (PxArticulationJointReducedCoordinate, limitLow, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE_ARRAY_VARIABLE_SIZE (PxArticulationJointReducedCoordinate, limitHigh, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE_ARRAY_VARIABLE_SIZE (PxArticulationJointReducedCoordinate, driveStiffness, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE_ARRAY_VARIABLE_SIZE (PxArticulationJointReducedCoordinate, driveDamping, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE_ARRAY_VARIABLE_SIZE (PxArticulationJointReducedCoordinate, driveMaxForce, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE_ARRAY_VARIABLE_SIZE (PxArticulationJointReducedCoordinate, driveType, PxArticulationDriveType::Enum, OmniPvdDataType::eUINT32) OMNI_PVD_ATTRIBUTE_ARRAY_VARIABLE_SIZE (PxArticulationJointReducedCoordinate, driveTarget, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE_ARRAY_VARIABLE_SIZE (PxArticulationJointReducedCoordinate, driveVelocity, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_CLASS_END (PxArticulationJointReducedCoordinate) //////////////////////////////////////////////////////////////////////////////// // PxShape //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_BEGIN (PxShape) OMNI_PVD_ATTRIBUTE_ARRAY_FIXED_SIZE (PxShape, translation, PxVec3, OmniPvdDataType::eFLOAT32, 3) OMNI_PVD_ATTRIBUTE_ARRAY_FIXED_SIZE (PxShape, rotation, PxQuat, OmniPvdDataType::eFLOAT32, 4) OMNI_PVD_ATTRIBUTE (PxShape, isExclusive, bool, OmniPvdDataType::eUINT8) OMNI_PVD_ATTRIBUTE (PxShape, geom, PxGeometry* const, OmniPvdDataType::eOBJECT_HANDLE) OMNI_PVD_ATTRIBUTE (PxShape, contactOffset, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE (PxShape, restOffset, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE (PxShape, densityForFluid, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE (PxShape, torsionalPatchRadius, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE (PxShape, minTorsionalPatchRadius, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE_FLAG (PxShape, shapeFlags, PxShapeFlags, PxShapeFlag) OMNI_PVD_ATTRIBUTE_ARRAY_FIXED_SIZE (PxShape, simulationFilterData, PxFilterData, OmniPvdDataType::eUINT32, 4) OMNI_PVD_ATTRIBUTE_ARRAY_FIXED_SIZE (PxShape, queryFilterData, PxFilterData, OmniPvdDataType::eUINT32, 4) OMNI_PVD_ATTRIBUTE_ARRAY_VARIABLE_SIZE (PxShape, materials, PxMaterial* const, OmniPvdDataType::eOBJECT_HANDLE) OMNI_PVD_CLASS_END (PxShape) //////////////////////////////////////////////////////////////////////////////// // PxGeometry //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_BEGIN (PxGeometry) OMNI_PVD_CLASS_END (PxGeometry) //////////////////////////////////////////////////////////////////////////////// // PxSphereGeometry //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_DERIVED_BEGIN (PxSphereGeometry, PxGeometry) OMNI_PVD_ATTRIBUTE (PxSphereGeometry, radius, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_CLASS_END (PxSphereGeometry) //////////////////////////////////////////////////////////////////////////////// // PxCapsuleGeometry //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_DERIVED_BEGIN (PxCapsuleGeometry, PxGeometry) OMNI_PVD_ATTRIBUTE (PxCapsuleGeometry, halfHeight, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE (PxCapsuleGeometry, radius, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_CLASS_END (PxCapsuleGeometry) //////////////////////////////////////////////////////////////////////////////// // PxBoxGeometry //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_DERIVED_BEGIN (PxBoxGeometry, PxGeometry) OMNI_PVD_ATTRIBUTE_ARRAY_FIXED_SIZE (PxBoxGeometry, halfExtents, PxVec3, OmniPvdDataType::eFLOAT32, 3) OMNI_PVD_CLASS_END (PxBoxGeometry) //////////////////////////////////////////////////////////////////////////////// // PxPlaneGeometry //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_DERIVED_BEGIN (PxPlaneGeometry, PxGeometry) OMNI_PVD_CLASS_END (PxPlaneGeometry) //////////////////////////////////////////////////////////////////////////////// // PxConvexMeshGeometry //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_DERIVED_BEGIN (PxConvexMeshGeometry, PxGeometry) OMNI_PVD_ATTRIBUTE_ARRAY_FIXED_SIZE (PxConvexMeshGeometry, scale, PxVec3, OmniPvdDataType::eFLOAT32, 3) OMNI_PVD_ATTRIBUTE (PxConvexMeshGeometry, convexMesh, PxConvexMesh* const, OmniPvdDataType::eOBJECT_HANDLE) OMNI_PVD_CLASS_END (PxConvexMeshGeometry) //////////////////////////////////////////////////////////////////////////////// // PxConvexMesh //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_BEGIN (PxConvexMesh) OMNI_PVD_ATTRIBUTE_ARRAY_VARIABLE_SIZE (PxConvexMesh, verts, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE_ARRAY_VARIABLE_SIZE (PxConvexMesh, tris, PxU32, OmniPvdDataType::eUINT32) OMNI_PVD_CLASS_END (PxConvexMesh) //////////////////////////////////////////////////////////////////////////////// // PxHeightFieldGeometry //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_DERIVED_BEGIN (PxHeightFieldGeometry, PxGeometry) OMNI_PVD_ATTRIBUTE_ARRAY_FIXED_SIZE (PxHeightFieldGeometry, scale, PxVec3, OmniPvdDataType::eFLOAT32, 3) OMNI_PVD_ATTRIBUTE (PxHeightFieldGeometry, heightField, PxHeightField* const, OmniPvdDataType::eOBJECT_HANDLE) OMNI_PVD_CLASS_END (PxHeightFieldGeometry) //////////////////////////////////////////////////////////////////////////////// // PxHeightField //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_BEGIN (PxHeightField) OMNI_PVD_ATTRIBUTE_ARRAY_VARIABLE_SIZE (PxHeightField, verts, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE_ARRAY_VARIABLE_SIZE (PxHeightField, tris, PxU32, OmniPvdDataType::eUINT32) OMNI_PVD_CLASS_END (PxHeightField) //////////////////////////////////////////////////////////////////////////////// // PxTriangleMeshGeometry //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_DERIVED_BEGIN (PxTriangleMeshGeometry, PxGeometry) OMNI_PVD_ATTRIBUTE_ARRAY_FIXED_SIZE (PxTriangleMeshGeometry, scale, PxVec3, OmniPvdDataType::eFLOAT32, 3) OMNI_PVD_ATTRIBUTE (PxTriangleMeshGeometry, triangleMesh, PxTriangleMesh* const, OmniPvdDataType::eOBJECT_HANDLE) OMNI_PVD_CLASS_END (PxTriangleMeshGeometry) //////////////////////////////////////////////////////////////////////////////// // PxTriangleMesh //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_BEGIN (PxTriangleMesh) OMNI_PVD_ATTRIBUTE_ARRAY_VARIABLE_SIZE (PxTriangleMesh, verts, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE_ARRAY_VARIABLE_SIZE (PxTriangleMesh, tris, PxU32, OmniPvdDataType::eUINT32) OMNI_PVD_CLASS_END (PxTriangleMesh) //////////////////////////////////////////////////////////////////////////////// // PxTetrahedronMeshGeometry //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_DERIVED_BEGIN (PxTetrahedronMeshGeometry, PxGeometry) OMNI_PVD_ATTRIBUTE (PxTetrahedronMeshGeometry, tetrahedronMesh, PxTetrahedronMesh* const, OmniPvdDataType::eOBJECT_HANDLE) OMNI_PVD_CLASS_END (PxTetrahedronMeshGeometry) //////////////////////////////////////////////////////////////////////////////// // PxTetrahedronMesh //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_BEGIN (PxTetrahedronMesh) OMNI_PVD_ATTRIBUTE_ARRAY_VARIABLE_SIZE (PxTetrahedronMesh, verts, PxReal, OmniPvdDataType::eFLOAT32) OMNI_PVD_ATTRIBUTE_ARRAY_VARIABLE_SIZE (PxTetrahedronMesh, tets, PxU32, OmniPvdDataType::eUINT32) OMNI_PVD_CLASS_END (PxTetrahedronMesh) //////////////////////////////////////////////////////////////////////////////// // PxCustomGeometry //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_DERIVED_BEGIN (PxCustomGeometry, PxGeometry) OMNI_PVD_ATTRIBUTE (PxCustomGeometry, callbacks, PxCustomGeometry::Callbacks* const, OmniPvdDataType::eOBJECT_HANDLE) OMNI_PVD_CLASS_END (PxCustomGeometry) //////////////////////////////////////////////////////////////////////////////// // PxSoftBodyMesh //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_BEGIN (PxSoftBodyMesh) OMNI_PVD_ATTRIBUTE (PxSoftBodyMesh, collisionMesh, PxTetrahedronMesh* const, OmniPvdDataType::eOBJECT_HANDLE) OMNI_PVD_ATTRIBUTE (PxSoftBodyMesh, simulationMesh,PxTetrahedronMesh* const, OmniPvdDataType::eOBJECT_HANDLE) OMNI_PVD_CLASS_END (PxSoftBodyMesh) //////////////////////////////////////////////////////////////////////////////// // PxBVH //////////////////////////////////////////////////////////////////////////////// OMNI_PVD_CLASS_BEGIN (PxBVH) OMNI_PVD_CLASS_END (PxBVH)
37,269
C
61.428811
148
0.6602
NVIDIA-Omniverse/PhysX/physx/source/physx/src/omnipvd/NpOmniPvdSetData.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef NP_OMNI_PVD_SET_DATA_H #define NP_OMNI_PVD_SET_DATA_H // // This header has to be included to use macros like OMNI_PVD_SET() (set attribute values, // object instance registration etc.) // #define OMNI_PVD_CONTEXT_HANDLE 1 #if PX_SUPPORT_OMNI_PVD #include "NpOmniPvdRegistrationData.h" #include "OmniPvdPxSampler.h" #include "NpOmniPvd.h" #define OMNI_PVD_ACTIVE (::OmniPvdPxSampler::getInstance() != NULL) // // Define the macros needed in CmOmniPvdAutoGenSetData.h // #undef OMNI_PVD_GET_WRITER #define OMNI_PVD_GET_WRITER(writer) \ physx::PxOmniPvd::ScopedExclusiveWriter writeLock(NpOmniPvdGetInstance()); \ OmniPvdWriter* writer = writeLock.getWriter(); #undef OMNI_PVD_GET_REGISTRATION_DATA #define OMNI_PVD_GET_REGISTRATION_DATA(registrationData) \ const OmniPvdPxCoreRegistrationData* registrationData = NpOmniPvdGetPxCoreRegistrationData(); #else // PX_SUPPORT_OMNI_PVD #define OMNI_PVD_ACTIVE (false) #endif // PX_SUPPORT_OMNI_PVD #include "omnipvd/CmOmniPvdAutoGenSetData.h" // note: included in all cases since it will provide empty definitions of the helper macros such // that not all of them have to be guarded by PX_SUPPORT_OMNI_PVD #endif // NP_OMNI_PVD_SET_DATA_H
2,920
C
35.061728
96
0.761644
NVIDIA-Omniverse/PhysX/physx/source/physx/src/omnipvd/OmniPvdChunkAlloc.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef OMNI_PVD_CHUNK_ALLOC_H #define OMNI_PVD_CHUNK_ALLOC_H #include "foundation/PxUserAllocated.h" //////////////////////////////////////////////////////////////////////////////// // The usage reason for splitting the Chunk allocator into a ChunkPool and a // ByteAllocator is so that similarly accessed objects get allocated next to each // other within the same Chunk, which is managed by the ByteAllocator. The // ChunkPool is basically just a resource pool. Not thread safe anything :-) // Locking is bad mkkk... //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// // Usage example of setting up a ChunkPool, a ByteAllocator and allocating some // bytes, for the lulz. //////////////////////////////////////////////////////////////////////////////// /* OmniPvdChunkPool pool; // set the individual Chunks to a size of 100k bytes pool.setChunkSize(100000); // all allocations must go through a ByteAllocator, so create one OmniPvdChunkByteAllocator allocator; // connect the ByteAllocator to the pool allocator.setPool(&pool); // we allocate 100 bytes through the ByteAllocator unsigned char *someBytes=allocator.allocBytes(100); */ //////////////////////////////////////////////////////////////////////////////// // Once we want to cleanup the allocations, return the Chunks to the ChunkPool, // which is also done silently in the destructor of the ByteAllocator. //////////////////////////////////////////////////////////////////////////////// /* allocator.freeChunks(); */ //////////////////////////////////////////////////////////////////////////////// // Memory management warning! The ByteAllocator does not deallocate the Chunks, // but must return the Chunks to the ChunkPool before going out of scope. The // ChunkPool can only deallocate the Chunks that is has in its free Chunks list, // so all ByteAllocators must either all go out of scope before the ChunkPool // goes out of scope or the ByteAllocators must all call the function freeChunks // before the ChunkPool goes out of scope. //////////////////////////////////////////////////////////////////////////////// class OmniPvdChunkElement { public: OmniPvdChunkElement(); ~OmniPvdChunkElement(); OmniPvdChunkElement* mNextElement; }; class OmniPvdChunk : public physx::PxUserAllocated { public: OmniPvdChunk(); ~OmniPvdChunk(); void resetChunk(int nbrBytes); int nbrBytesUSed(); unsigned char* mData; int mNbrBytesAllocated; int mNbrBytesFree; unsigned char* mBytePtr; OmniPvdChunk* mNextChunk; }; class OmniPvdChunkList { public: OmniPvdChunkList(); ~OmniPvdChunkList(); void resetList(); void appendList(OmniPvdChunkList* list); void appendChunk(OmniPvdChunk* chunk); OmniPvdChunk* removeFirst(); OmniPvdChunk* mFirstChunk; OmniPvdChunk* mLastChunk; int mNbrChunks; }; class OmniPvdChunkPool { public: OmniPvdChunkPool(); ~OmniPvdChunkPool(); void setChunkSize(int chunkSize); OmniPvdChunk* getChunk(); OmniPvdChunkList mFreeChunks; int mChunkSize; int mNbrAllocatedChunks; }; class OmniPvdChunkByteAllocator { public: OmniPvdChunkByteAllocator(); ~OmniPvdChunkByteAllocator(); OmniPvdChunkElement* allocChunkElement(int totalStructSize); void setPool(OmniPvdChunkPool* pool); unsigned char* allocBytes(int nbrBytes); void freeChunks(); OmniPvdChunkList mUsedChunks; OmniPvdChunkPool* mPool; }; #endif
5,205
C
33.25
81
0.667819
NVIDIA-Omniverse/PhysX/physx/source/physx/src/omnipvd/NpOmniPvd.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef NP_OMNI_PVD_H #define NP_OMNI_PVD_H #include "omnipvd/PxOmniPvd.h" #include "foundation/PxMutex.h" class OmniPvdReader; class OmniPvdWriter; class OmniPvdLoader; class OmniPvdFileWriteStream; class OmniPvdPxSampler; namespace physx { class NpOmniPvd : public PxOmniPvd { public: NpOmniPvd(); ~NpOmniPvd(); static void destroyInstance(); static void incRefCount(); static void decRefCount(); void release(); bool initOmniPvd(); OmniPvdWriter* getWriter(); OmniPvdWriter* blockingWriterLoad(); OmniPvdWriter* acquireExclusiveWriterAccess(); void releaseExclusiveWriterAccess(); OmniPvdFileWriteStream* getFileWriteStream(); bool startSampling(); OmniPvdLoader* mLoader; OmniPvdFileWriteStream* mFileWriteStream; OmniPvdWriter* mWriter; OmniPvdPxSampler* mPhysXSampler; static PxU32 mRefCount; static NpOmniPvd* mInstance; PxMutex mMutex; PxMutex mWriterLoadMutex; }; } #endif
2,617
C
32.13924
74
0.771494
NVIDIA-Omniverse/PhysX/physx/source/physx/src/device/PhysXIndicator.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef __PHYSXINDICATOR_H__ #define __PHYSXINDICATOR_H__ #include "foundation/PxPreprocessor.h" namespace physx { struct NvPhysXToDrv_Data_V1_; class PhysXIndicator { public: PhysXIndicator(bool isGpu = false); ~PhysXIndicator(); void setIsGpu(bool isGpu); private: void updateCounter(int delta); NvPhysXToDrv_Data_V1_* mPhysXDataPtr; void* mFileHandle; bool mIsGpu; }; } #endif // __PHYSXINDICATOR_H__
2,129
C
37.035714
74
0.755754
NVIDIA-Omniverse/PhysX/physx/source/physx/src/device/nvPhysXtoDrv.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef __NVPHYSXTODRV_H__ #define __NVPHYSXTODRV_H__ // The puprose of this interface is to provide graphics drivers with information // about PhysX state to draw PhysX visual indicator // We share information between modules using a memory section object. PhysX creates // such object, graphics drivers try to open it. The name of the object has // fixed part (NvPhysXToDrv_SectionName) followed by the process id. This allows // each process to have its own communication channel. namespace physx { #define NvPhysXToDrv_SectionName "PH71828182845_" // Vista apps cannot create stuff in Global\\ namespace when NOT elevated, so use local scope #define NvPhysXToDrv_Build_SectionName(PID, buf) sprintf(buf, NvPhysXToDrv_SectionName "%x", static_cast<unsigned int>(PID)) #define NvPhysXToDrv_Build_SectionNameXP(PID, buf) sprintf(buf, "Global\\" NvPhysXToDrv_SectionName "%x", static_cast<unsigned int>(PID)) typedef struct NvPhysXToDrv_Header_ { int signature; // header interface signature int version; // version of the interface int size; // size of the structure int reserved; // reserved, must be zero } NvPhysXToDrv_Header; // this structure describes layout of data in the shared memory section typedef struct NvPhysXToDrv_Data_V1_ { NvPhysXToDrv_Header header; // keep this member first in all versions of the interface. int bCpuPhysicsPresent; // nonzero if cpu physics is initialized int bGpuPhysicsPresent; // nonzero if gpu physics is initialized } NvPhysXToDrv_Data_V1; // some random magic number as our interface signature #define NvPhysXToDrv_Header_Signature 0xA7AB // use the macro to setup the header to the latest version of the interface // update the macro when a new verson of the interface is added #define NvPhysXToDrv_Header_Init(header) \ { \ header.signature = NvPhysXToDrv_Header_Signature; \ header.version = 1; \ header.size = sizeof(NvPhysXToDrv_Data_V1); \ header.reserved = 0; \ } // validate the header against all known interface versions // add validation checks when new interfaces are added #define NvPhysXToDrv_Header_Validate(header, curVersion) \ ( \ (header.signature == NvPhysXToDrv_Header_Signature) && \ (header.version == curVersion) && \ (curVersion == 1) && \ (header.size == sizeof(NvPhysXToDrv_Data_V1)) \ ) } #endif // __NVPHYSXTODRV_H__
4,354
C
45.827956
138
0.703721
NVIDIA-Omniverse/PhysX/physx/source/physx/src/device/windows/PhysXIndicatorWindows.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #include "PhysXIndicator.h" #include "nvPhysXtoDrv.h" #include "foundation/windows/PxWindowsInclude.h" #include <stdio.h> #if _MSC_VER >= 1800 #include <VersionHelpers.h> #endif // Scope-based to indicate to NV driver that CPU PhysX is happening physx::PhysXIndicator::PhysXIndicator(bool isGpu) : mPhysXDataPtr(0), mFileHandle(0), mIsGpu(isGpu) { // Get the windows version (we can only create Global\\ namespace objects in XP) /** Operating system Version number ---------------- -------------- Windows 7 6.1 Windows Server 2008 R2 6.1 Windows Server 2008 6.0 Windows Vista 6.0 Windows Server 2003 R2 5.2 Windows Server 2003 5.2 Windows XP 5.1 Windows 2000 5.0 **/ char configName[128]; #if _MSC_VER >= 1800 if (!IsWindowsVistaOrGreater()) #else OSVERSIONINFOEX windowsVersionInfo; windowsVersionInfo.dwOSVersionInfoSize = sizeof (windowsVersionInfo); GetVersionEx((LPOSVERSIONINFO)&windowsVersionInfo); if (windowsVersionInfo.dwMajorVersion < 6) #endif NvPhysXToDrv_Build_SectionNameXP(GetCurrentProcessId(), configName); else NvPhysXToDrv_Build_SectionName(GetCurrentProcessId(), configName); mFileHandle = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(NvPhysXToDrv_Data_V1), configName); if (!mFileHandle || mFileHandle == INVALID_HANDLE_VALUE) return; bool alreadyExists = ERROR_ALREADY_EXISTS == GetLastError(); mPhysXDataPtr = (physx::NvPhysXToDrv_Data_V1*)MapViewOfFile(mFileHandle, FILE_MAP_READ|FILE_MAP_WRITE, 0, 0, sizeof(NvPhysXToDrv_Data_V1)); if(!mPhysXDataPtr) return; if (!alreadyExists) { mPhysXDataPtr->bCpuPhysicsPresent = 0; mPhysXDataPtr->bGpuPhysicsPresent = 0; } updateCounter(1); // init header last to prevent race conditions // this must be done because the driver may have already created the shared memory block, // thus alreadyExists may be true, even if PhysX hasn't been initialized NvPhysXToDrv_Header_Init(mPhysXDataPtr->header); } physx::PhysXIndicator::~PhysXIndicator() { if(mPhysXDataPtr) { updateCounter(-1); UnmapViewOfFile(mPhysXDataPtr); } if(mFileHandle && mFileHandle != INVALID_HANDLE_VALUE) CloseHandle(mFileHandle); } void physx::PhysXIndicator::setIsGpu(bool isGpu) { if(!mPhysXDataPtr) return; updateCounter(-1); mIsGpu = isGpu; updateCounter(1); } PX_INLINE void physx::PhysXIndicator::updateCounter(int delta) { (mIsGpu ? mPhysXDataPtr->bGpuPhysicsPresent : mPhysXDataPtr->bCpuPhysicsPresent) += delta; }
4,203
C++
31.84375
90
0.748037
NVIDIA-Omniverse/PhysX/physx/source/physx/src/device/linux/PhysXIndicatorLinux.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #include "PhysXIndicator.h" #include "nvPhysXtoDrv.h" physx::PhysXIndicator::PhysXIndicator(bool isGpu) : mPhysXDataPtr(0), mFileHandle(0), mIsGpu(isGpu) { } physx::PhysXIndicator::~PhysXIndicator() { } void physx::PhysXIndicator::setIsGpu(bool isGpu) { PX_UNUSED(isGpu); } PX_INLINE void physx::PhysXIndicator::updateCounter(int delta) { PX_UNUSED(delta); }
2,069
C++
39.588235
74
0.760271
NVIDIA-Omniverse/PhysX/physx/source/physx/src/gpu/PxPhysXGpuModuleLoader.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. #include "PxPhysXConfig.h" #if PX_SUPPORT_GPU_PHYSX #include "foundation/Px.h" #include "gpu/PxGpu.h" #include "cudamanager/PxCudaContextManager.h" #include "PxPhysics.h" #if PX_WINDOWS #include "common/windows/PxWindowsDelayLoadHook.h" #include "foundation/windows/PxWindowsInclude.h" #include "windows/CmWindowsModuleUpdateLoader.h" #elif PX_LINUX #include <dlfcn.h> #endif // ~PX_LINUX #include "stdio.h" #if PX_CLANG #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wundefined-reinterpret-cast" #endif #define STRINGIFY(x) #x #define GETSTRING(x) STRINGIFY(x) #define PHYSX_GPU_SHARED_LIB_NAME GETSTRING(PX_PHYSX_GPU_SHARED_LIB_NAME) static const char* gPhysXGpuLibraryName = PHYSX_GPU_SHARED_LIB_NAME; #undef GETSTRING #undef STRINGIFY // Use reportError to handle cases where PxFoundation has not been created yet static void reportError(const char* file, int line, const char* format, ...) { va_list args; va_start(args, format); physx::PxFoundation* foundation = PxIsFoundationValid(); if(foundation) { foundation->error(physx::PxErrorCode::eINTERNAL_ERROR, file, line, format, args); } else { fprintf(stderr, "Error in %s:%i: ", file, line); vfprintf(stderr, format, args); } va_end(args); } void PxSetPhysXGpuLoadHook(const PxGpuLoadHook* hook) { gPhysXGpuLibraryName = hook->getPhysXGpuDllName(); } namespace physx { #if PX_VC #pragma warning(disable: 4191) //'operator/operation' : unsafe conversion from 'type of expression' to 'type required' #endif class PxFoundation; class PxPhysXGpu; class PxPhysicsGpu; typedef physx::PxPhysXGpu* (PxCreatePhysXGpu_FUNC)(); typedef physx::PxCudaContextManager* (PxCreateCudaContextManager_FUNC)(physx::PxFoundation& foundation, const physx::PxCudaContextManagerDesc& desc, physx::PxProfilerCallback* profilerCallback, bool launchSynchronous); typedef int (PxGetSuggestedCudaDeviceOrdinal_FUNC)(physx::PxErrorCallback& errc); typedef void (PxSetPhysXGpuProfilerCallback_FUNC)(physx::PxProfilerCallback* cbk); typedef void (PxCudaRegisterFunction_FUNC)(int, const char*); typedef void** (PxCudaRegisterFatBinary_FUNC)(void*); typedef physx::PxKernelIndex* (PxGetCudaFunctionTable_FUNC)(); typedef PxU32 (PxGetCudaFunctionTableSize_FUNC)(); typedef void** PxGetCudaModuleTable_FUNC(); typedef PxPhysicsGpu* PxCreatePhysicsGpu_FUNC(); PxCreatePhysXGpu_FUNC* g_PxCreatePhysXGpu_Func = NULL; PxCreateCudaContextManager_FUNC* g_PxCreateCudaContextManager_Func = NULL; PxGetSuggestedCudaDeviceOrdinal_FUNC* g_PxGetSuggestedCudaDeviceOrdinal_Func = NULL; PxSetPhysXGpuProfilerCallback_FUNC* g_PxSetPhysXGpuProfilerCallback_Func = NULL; PxCudaRegisterFunction_FUNC* g_PxCudaRegisterFunction_Func = NULL; PxCudaRegisterFatBinary_FUNC* g_PxCudaRegisterFatBinary_Func = NULL; PxGetCudaFunctionTable_FUNC* g_PxGetCudaFunctionTable_Func = NULL; PxGetCudaFunctionTableSize_FUNC* g_PxGetCudaFunctionTableSize_Func = NULL; PxGetCudaFunctionTableSize_FUNC* g_PxGetCudaModuleTableSize_Func = NULL; PxGetCudaModuleTable_FUNC* g_PxGetCudaModuleTable_Func = NULL; PxCreatePhysicsGpu_FUNC* g_PxCreatePhysicsGpu_Func = NULL; void PxUnloadPhysxGPUModule() { g_PxCreatePhysXGpu_Func = NULL; g_PxCreateCudaContextManager_Func = NULL; g_PxGetSuggestedCudaDeviceOrdinal_Func = NULL; g_PxSetPhysXGpuProfilerCallback_Func = NULL; g_PxCudaRegisterFunction_Func = NULL; g_PxCudaRegisterFatBinary_Func = NULL; g_PxGetCudaFunctionTable_Func = NULL; g_PxGetCudaFunctionTableSize_Func = NULL; g_PxGetCudaModuleTableSize_Func = NULL; g_PxGetCudaModuleTable_Func = NULL; g_PxCreatePhysicsGpu_Func = NULL; } #if PX_WINDOWS typedef void (PxSetPhysXGpuDelayLoadHook_FUNC)(const PxDelayLoadHook* delayLoadHook); #define DEFAULT_PHYSX_GPU_GUID "D79FA4BF-177C-4841-8091-4375D311D6A3" void PxLoadPhysxGPUModule(const char* appGUID) { HMODULE s_library = GetModuleHandle(gPhysXGpuLibraryName); bool freshlyLoaded = false; if (s_library == NULL) { Cm::CmModuleUpdateLoader moduleLoader(UPDATE_LOADER_DLL_NAME); s_library = moduleLoader.LoadModule(gPhysXGpuLibraryName, appGUID == NULL ? DEFAULT_PHYSX_GPU_GUID : appGUID); freshlyLoaded = true; } if (s_library && (freshlyLoaded || g_PxCreatePhysXGpu_Func == NULL)) { g_PxCreatePhysXGpu_Func = (PxCreatePhysXGpu_FUNC*)GetProcAddress(s_library, "PxCreatePhysXGpu"); g_PxCreateCudaContextManager_Func = (PxCreateCudaContextManager_FUNC*)GetProcAddress(s_library, "PxCreateCudaContextManager"); g_PxGetSuggestedCudaDeviceOrdinal_Func = (PxGetSuggestedCudaDeviceOrdinal_FUNC*)GetProcAddress(s_library, "PxGetSuggestedCudaDeviceOrdinal"); g_PxSetPhysXGpuProfilerCallback_Func = (PxSetPhysXGpuProfilerCallback_FUNC*)GetProcAddress(s_library, "PxSetPhysXGpuProfilerCallback"); g_PxCudaRegisterFunction_Func = (PxCudaRegisterFunction_FUNC*)GetProcAddress(s_library, "PxGpuCudaRegisterFunction"); g_PxCudaRegisterFatBinary_Func = (PxCudaRegisterFatBinary_FUNC*)GetProcAddress(s_library, "PxGpuCudaRegisterFatBinary"); g_PxGetCudaFunctionTable_Func = (PxGetCudaFunctionTable_FUNC*)GetProcAddress(s_library, "PxGpuGetCudaFunctionTable"); g_PxGetCudaFunctionTableSize_Func = (PxGetCudaFunctionTableSize_FUNC*)GetProcAddress(s_library, "PxGpuGetCudaFunctionTableSize"); g_PxGetCudaModuleTableSize_Func = (PxGetCudaFunctionTableSize_FUNC*)GetProcAddress(s_library, "PxGpuGetCudaModuleTableSize"); g_PxGetCudaModuleTable_Func = (PxGetCudaModuleTable_FUNC*)GetProcAddress(s_library, "PxGpuGetCudaModuleTable"); g_PxCreatePhysicsGpu_Func = (PxCreatePhysicsGpu_FUNC*)GetProcAddress(s_library, "PxGpuCreatePhysicsGpu"); } // Check for errors if (s_library == NULL) { reportError(PX_FL, "Failed to load %s!\n", gPhysXGpuLibraryName); return; } if (g_PxCreatePhysXGpu_Func == NULL || g_PxCreateCudaContextManager_Func == NULL || g_PxGetSuggestedCudaDeviceOrdinal_Func == NULL || g_PxSetPhysXGpuProfilerCallback_Func == NULL) { reportError(PX_FL, "PhysXGpu dll is incompatible with this version of PhysX!\n"); return; } } #elif PX_LINUX void PxLoadPhysxGPUModule(const char*) { static void* s_library = NULL; if (s_library == NULL) { // load libcuda.so here since gcc configured with --as-needed won't link to it // if there is no call from the binary to it. void* hLibCuda = dlopen("libcuda.so", RTLD_NOW | RTLD_GLOBAL); if (hLibCuda) { s_library = dlopen(gPhysXGpuLibraryName, RTLD_NOW); } else { char* error = dlerror(); reportError(PX_FL, "Could not load libcuda.so: %s\n", error); return; } } // no UpdateLoader if (s_library) { *reinterpret_cast<void**>(&g_PxCreatePhysXGpu_Func) = dlsym(s_library, "PxCreatePhysXGpu"); *reinterpret_cast<void**>(&g_PxCreateCudaContextManager_Func) = dlsym(s_library, "PxCreateCudaContextManager"); *reinterpret_cast<void**>(&g_PxGetSuggestedCudaDeviceOrdinal_Func) = dlsym(s_library, "PxGetSuggestedCudaDeviceOrdinal"); *reinterpret_cast<void**>(&g_PxSetPhysXGpuProfilerCallback_Func) = dlsym(s_library, "PxSetPhysXGpuProfilerCallback"); *reinterpret_cast<void**>(&g_PxCudaRegisterFunction_Func) = dlsym(s_library, "PxGpuCudaRegisterFunction"); *reinterpret_cast<void**>(&g_PxCudaRegisterFatBinary_Func) = dlsym(s_library, "PxGpuCudaRegisterFatBinary"); *reinterpret_cast<void**>(&g_PxGetCudaFunctionTable_Func) = dlsym(s_library, "PxGpuGetCudaFunctionTable"); *reinterpret_cast<void**>(&g_PxGetCudaFunctionTableSize_Func) = dlsym(s_library, "PxGpuGetCudaFunctionTableSize"); *reinterpret_cast<void**>(&g_PxGetCudaModuleTableSize_Func) = dlsym(s_library, "PxGpuGetCudaModuleTableSize"); *reinterpret_cast<void**>(&g_PxGetCudaModuleTable_Func) = dlsym(s_library, "PxGpuGetCudaModuleTable"); *reinterpret_cast<void**>(&g_PxCreatePhysicsGpu_Func) = dlsym(s_library, "PxGpuCreatePhysicsGpu"); } // Check for errors if (s_library == NULL) { char* error = dlerror(); reportError(PX_FL, "Failed to load %s!: %s\n", gPhysXGpuLibraryName, error); return; } if (g_PxCreatePhysXGpu_Func == NULL || g_PxCreateCudaContextManager_Func == NULL || g_PxGetSuggestedCudaDeviceOrdinal_Func == NULL) { reportError(PX_FL, "%s is incompatible with this version of PhysX!\n", gPhysXGpuLibraryName); return; } } #endif // PX_LINUX } // end physx namespace #if PX_CLANG #pragma clang diagnostic pop #endif #endif // PX_SUPPORT_GPU_PHYSX
9,989
C++
39.942623
219
0.76404
NVIDIA-Omniverse/PhysX/physx/source/physx/src/gpu/PxGpu.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. #include "PxPhysXConfig.h" #if PX_SUPPORT_GPU_PHYSX #include "gpu/PxGpu.h" #ifndef PX_PHYSX_GPU_STATIC namespace physx { //forward declare stuff from PxPhysXGpuModuleLoader.cpp void PxLoadPhysxGPUModule(const char* appGUID); typedef physx::PxCudaContextManager* (PxCreateCudaContextManager_FUNC)(physx::PxFoundation& foundation, const physx::PxCudaContextManagerDesc& desc, physx::PxProfilerCallback* profilerCallback, bool launchSynchronous); typedef int (PxGetSuggestedCudaDeviceOrdinal_FUNC)(physx::PxErrorCallback& errc); typedef void (PxSetPhysXGpuProfilerCallback_FUNC)(physx::PxProfilerCallback* cbk); typedef void (PxCudaRegisterFunction_FUNC)(int, const char*); typedef void** (PxCudaRegisterFatBinary_FUNC)(void*); typedef physx::PxKernelIndex* (PxGetCudaFunctionTable_FUNC)(); typedef PxU32 (PxGetCudaFunctionTableSize_FUNC)(); typedef void** PxGetCudaModuleTable_FUNC(); typedef PxPhysicsGpu* PxCreatePhysicsGpu_FUNC(); extern PxCreateCudaContextManager_FUNC* g_PxCreateCudaContextManager_Func; extern PxGetSuggestedCudaDeviceOrdinal_FUNC* g_PxGetSuggestedCudaDeviceOrdinal_Func; extern PxSetPhysXGpuProfilerCallback_FUNC* g_PxSetPhysXGpuProfilerCallback_Func; extern PxCudaRegisterFunction_FUNC* g_PxCudaRegisterFunction_Func; extern PxCudaRegisterFatBinary_FUNC* g_PxCudaRegisterFatBinary_Func; extern PxGetCudaFunctionTable_FUNC* g_PxGetCudaFunctionTable_Func; extern PxGetCudaFunctionTableSize_FUNC* g_PxGetCudaFunctionTableSize_Func; extern PxGetCudaFunctionTableSize_FUNC* g_PxGetCudaModuleTableSize_Func; extern PxGetCudaModuleTable_FUNC* g_PxGetCudaModuleTable_Func; extern PxCreatePhysicsGpu_FUNC* g_PxCreatePhysicsGpu_Func; } // end of physx namespace physx::PxCudaContextManager* PxCreateCudaContextManager(physx::PxFoundation& foundation, const physx::PxCudaContextManagerDesc& desc, physx::PxProfilerCallback* profilerCallback, bool launchSynchronous) { physx::PxLoadPhysxGPUModule(desc.appGUID); if (physx::g_PxCreateCudaContextManager_Func) return physx::g_PxCreateCudaContextManager_Func(foundation, desc, profilerCallback, launchSynchronous); else return NULL; } int PxGetSuggestedCudaDeviceOrdinal(physx::PxErrorCallback& errc) { physx::PxLoadPhysxGPUModule(NULL); if (physx::g_PxGetSuggestedCudaDeviceOrdinal_Func) return physx::g_PxGetSuggestedCudaDeviceOrdinal_Func(errc); else return -1; } void PxSetPhysXGpuProfilerCallback(physx::PxProfilerCallback* profilerCallback) { physx::PxLoadPhysxGPUModule(NULL); if (physx::g_PxSetPhysXGpuProfilerCallback_Func) physx::g_PxSetPhysXGpuProfilerCallback_Func(profilerCallback); } void PxCudaRegisterFunction(int moduleIndex, const char* functionName) { physx::PxLoadPhysxGPUModule(NULL); if (physx::g_PxCudaRegisterFunction_Func) physx::g_PxCudaRegisterFunction_Func(moduleIndex, functionName); } void** PxCudaRegisterFatBinary(void* fatBin) { physx::PxLoadPhysxGPUModule(NULL); if (physx::g_PxCudaRegisterFatBinary_Func) return physx::g_PxCudaRegisterFatBinary_Func(fatBin); return NULL; } physx::PxKernelIndex* PxGetCudaFunctionTable() { physx::PxLoadPhysxGPUModule(NULL); if(physx::g_PxGetCudaFunctionTable_Func) return physx::g_PxGetCudaFunctionTable_Func(); return NULL; } physx::PxU32 PxGetCudaFunctionTableSize() { physx::PxLoadPhysxGPUModule(NULL); if(physx::g_PxGetCudaFunctionTableSize_Func) return physx::g_PxGetCudaFunctionTableSize_Func(); return 0; } void** PxGetCudaModuleTable() { physx::PxLoadPhysxGPUModule(NULL); if(physx::g_PxGetCudaModuleTable_Func) return physx::g_PxGetCudaModuleTable_Func(); return NULL; } physx::PxU32 PxGetCudaModuleTableSize() { physx::PxLoadPhysxGPUModule(NULL); if(physx::g_PxGetCudaModuleTableSize_Func) return physx::g_PxGetCudaModuleTableSize_Func(); return 0; } physx::PxPhysicsGpu* PxGetPhysicsGpu() { physx::PxLoadPhysxGPUModule(NULL); if (physx::g_PxCreatePhysicsGpu_Func) return physx::g_PxCreatePhysicsGpu_Func(); return NULL; } #endif // PX_PHYSX_GPU_STATIC #endif // PX_SUPPORT_GPU_PHYSX
5,599
C++
32.333333
219
0.795856
NVIDIA-Omniverse/PhysX/physx/source/physxmetadata/extensions/src/PxExtensionAutoGeneratedMetaDataObjects.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. // This code is auto-generated by the PhysX Clang metadata generator. Do not edit or be // prepared for your edits to be quietly ignored next time the clang metadata generator is // run. You can find the most recent version of clang metadata generator by contacting // Chris Nuernberger <[email protected]> or Dilip or Adam. // The source code for the generate was at one time checked into: // physx/PhysXMetaDataGenerator/llvm/tools/clang/lib/Frontend/PhysXMetaDataAction.cpp #include "foundation/PxPreprocessor.h" #if PX_LINUX && PX_CLANG #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wreserved-identifier" #endif #include "PxExtensionMetaDataObjects.h" #if PX_LINUX && PX_CLANG #pragma clang diagnostic pop #endif #include "PxMetaDataCppPrefix.h" #include "extensions/PxExtensionsAPI.h" using namespace physx; void setPxJoint_Actors( PxJoint* inObj, PxRigidActor * inArg0, PxRigidActor * inArg1 ) { inObj->setActors( inArg0, inArg1 ); } void getPxJoint_Actors( const PxJoint* inObj, PxRigidActor *& inArg0, PxRigidActor *& inArg1 ) { inObj->getActors( inArg0, inArg1 ); } void setPxJoint_LocalPose( PxJoint* inObj, PxJointActorIndex::Enum inIndex, PxTransform inArg ){ inObj->setLocalPose( inIndex, inArg ); } PxTransform getPxJoint_LocalPose( const PxJoint* inObj, PxJointActorIndex::Enum inIndex ) { return inObj->getLocalPose( inIndex ); } PxTransform getPxJoint_RelativeTransform( const PxJoint* inObj ) { return inObj->getRelativeTransform(); } PxVec3 getPxJoint_RelativeLinearVelocity( const PxJoint* inObj ) { return inObj->getRelativeLinearVelocity(); } PxVec3 getPxJoint_RelativeAngularVelocity( const PxJoint* inObj ) { return inObj->getRelativeAngularVelocity(); } void setPxJoint_BreakForce( PxJoint* inObj, PxReal inArg0, PxReal inArg1 ) { inObj->setBreakForce( inArg0, inArg1 ); } void getPxJoint_BreakForce( const PxJoint* inObj, PxReal& inArg0, PxReal& inArg1 ) { inObj->getBreakForce( inArg0, inArg1 ); } void setPxJoint_ConstraintFlags( PxJoint* inObj, PxConstraintFlags inArg){ inObj->setConstraintFlags( inArg ); } PxConstraintFlags getPxJoint_ConstraintFlags( const PxJoint* inObj ) { return inObj->getConstraintFlags(); } void setPxJoint_InvMassScale0( PxJoint* inObj, PxReal inArg){ inObj->setInvMassScale0( inArg ); } PxReal getPxJoint_InvMassScale0( const PxJoint* inObj ) { return inObj->getInvMassScale0(); } void setPxJoint_InvInertiaScale0( PxJoint* inObj, PxReal inArg){ inObj->setInvInertiaScale0( inArg ); } PxReal getPxJoint_InvInertiaScale0( const PxJoint* inObj ) { return inObj->getInvInertiaScale0(); } void setPxJoint_InvMassScale1( PxJoint* inObj, PxReal inArg){ inObj->setInvMassScale1( inArg ); } PxReal getPxJoint_InvMassScale1( const PxJoint* inObj ) { return inObj->getInvMassScale1(); } void setPxJoint_InvInertiaScale1( PxJoint* inObj, PxReal inArg){ inObj->setInvInertiaScale1( inArg ); } PxReal getPxJoint_InvInertiaScale1( const PxJoint* inObj ) { return inObj->getInvInertiaScale1(); } PxConstraint * getPxJoint_Constraint( const PxJoint* inObj ) { return inObj->getConstraint(); } void setPxJoint_Name( PxJoint* inObj, const char * inArg){ inObj->setName( inArg ); } const char * getPxJoint_Name( const PxJoint* inObj ) { return inObj->getName(); } PxScene * getPxJoint_Scene( const PxJoint* inObj ) { return inObj->getScene(); } inline void * getPxJointUserData( const PxJoint* inOwner ) { return inOwner->userData; } inline void setPxJointUserData( PxJoint* inOwner, void * inData) { inOwner->userData = inData; } PxJointGeneratedInfo::PxJointGeneratedInfo() : Actors( "Actors", "actor0", "actor1", setPxJoint_Actors, getPxJoint_Actors) , LocalPose( "LocalPose", setPxJoint_LocalPose, getPxJoint_LocalPose) , RelativeTransform( "RelativeTransform", getPxJoint_RelativeTransform) , RelativeLinearVelocity( "RelativeLinearVelocity", getPxJoint_RelativeLinearVelocity) , RelativeAngularVelocity( "RelativeAngularVelocity", getPxJoint_RelativeAngularVelocity) , BreakForce( "BreakForce", "force", "torque", setPxJoint_BreakForce, getPxJoint_BreakForce) , ConstraintFlags( "ConstraintFlags", setPxJoint_ConstraintFlags, getPxJoint_ConstraintFlags) , InvMassScale0( "InvMassScale0", setPxJoint_InvMassScale0, getPxJoint_InvMassScale0) , InvInertiaScale0( "InvInertiaScale0", setPxJoint_InvInertiaScale0, getPxJoint_InvInertiaScale0) , InvMassScale1( "InvMassScale1", setPxJoint_InvMassScale1, getPxJoint_InvMassScale1) , InvInertiaScale1( "InvInertiaScale1", setPxJoint_InvInertiaScale1, getPxJoint_InvInertiaScale1) , Constraint( "Constraint", getPxJoint_Constraint) , Name( "Name", setPxJoint_Name, getPxJoint_Name) , Scene( "Scene", getPxJoint_Scene) , UserData( "UserData", setPxJointUserData, getPxJointUserData ) {} PxJointGeneratedValues::PxJointGeneratedValues( const PxJoint* inSource ) :RelativeTransform( getPxJoint_RelativeTransform( inSource ) ) ,RelativeLinearVelocity( getPxJoint_RelativeLinearVelocity( inSource ) ) ,RelativeAngularVelocity( getPxJoint_RelativeAngularVelocity( inSource ) ) ,ConstraintFlags( getPxJoint_ConstraintFlags( inSource ) ) ,InvMassScale0( getPxJoint_InvMassScale0( inSource ) ) ,InvInertiaScale0( getPxJoint_InvInertiaScale0( inSource ) ) ,InvMassScale1( getPxJoint_InvMassScale1( inSource ) ) ,InvInertiaScale1( getPxJoint_InvInertiaScale1( inSource ) ) ,Constraint( getPxJoint_Constraint( inSource ) ) ,Name( getPxJoint_Name( inSource ) ) ,Scene( getPxJoint_Scene( inSource ) ) ,UserData( inSource->userData ) { PX_UNUSED(inSource); getPxJoint_Actors( inSource, Actors[0], Actors[1] ); for ( PxU32 idx = 0; idx < static_cast<PxU32>( physx::PxJointActorIndex::COUNT ); ++idx ) LocalPose[idx] = getPxJoint_LocalPose( inSource, static_cast< PxJointActorIndex::Enum >( idx ) ); getPxJoint_BreakForce( inSource, BreakForce[0], BreakForce[1] ); } void setPxRackAndPinionJoint_Ratio( PxRackAndPinionJoint* inObj, float inArg){ inObj->setRatio( inArg ); } float getPxRackAndPinionJoint_Ratio( const PxRackAndPinionJoint* inObj ) { return inObj->getRatio(); } const char * getPxRackAndPinionJoint_ConcreteTypeName( const PxRackAndPinionJoint* inObj ) { return inObj->getConcreteTypeName(); } PxRackAndPinionJointGeneratedInfo::PxRackAndPinionJointGeneratedInfo() : Ratio( "Ratio", setPxRackAndPinionJoint_Ratio, getPxRackAndPinionJoint_Ratio) , ConcreteTypeName( "ConcreteTypeName", getPxRackAndPinionJoint_ConcreteTypeName) {} PxRackAndPinionJointGeneratedValues::PxRackAndPinionJointGeneratedValues( const PxRackAndPinionJoint* inSource ) :PxJointGeneratedValues( inSource ) ,Ratio( getPxRackAndPinionJoint_Ratio( inSource ) ) ,ConcreteTypeName( getPxRackAndPinionJoint_ConcreteTypeName( inSource ) ) { PX_UNUSED(inSource); } void setPxGearJoint_GearRatio( PxGearJoint* inObj, float inArg){ inObj->setGearRatio( inArg ); } float getPxGearJoint_GearRatio( const PxGearJoint* inObj ) { return inObj->getGearRatio(); } const char * getPxGearJoint_ConcreteTypeName( const PxGearJoint* inObj ) { return inObj->getConcreteTypeName(); } PxGearJointGeneratedInfo::PxGearJointGeneratedInfo() : GearRatio( "GearRatio", setPxGearJoint_GearRatio, getPxGearJoint_GearRatio) , ConcreteTypeName( "ConcreteTypeName", getPxGearJoint_ConcreteTypeName) {} PxGearJointGeneratedValues::PxGearJointGeneratedValues( const PxGearJoint* inSource ) :PxJointGeneratedValues( inSource ) ,GearRatio( getPxGearJoint_GearRatio( inSource ) ) ,ConcreteTypeName( getPxGearJoint_ConcreteTypeName( inSource ) ) { PX_UNUSED(inSource); } void setPxD6Joint_Motion( PxD6Joint* inObj, PxD6Axis::Enum inIndex, PxD6Motion::Enum inArg ){ inObj->setMotion( inIndex, inArg ); } PxD6Motion::Enum getPxD6Joint_Motion( const PxD6Joint* inObj, PxD6Axis::Enum inIndex ) { return inObj->getMotion( inIndex ); } PxReal getPxD6Joint_TwistAngle( const PxD6Joint* inObj ) { return inObj->getTwistAngle(); } PxReal getPxD6Joint_Twist( const PxD6Joint* inObj ) { return inObj->getTwist(); } PxReal getPxD6Joint_SwingYAngle( const PxD6Joint* inObj ) { return inObj->getSwingYAngle(); } PxReal getPxD6Joint_SwingZAngle( const PxD6Joint* inObj ) { return inObj->getSwingZAngle(); } void setPxD6Joint_DistanceLimit( PxD6Joint* inObj, const PxJointLinearLimit & inArg){ inObj->setDistanceLimit( inArg ); } PxJointLinearLimit getPxD6Joint_DistanceLimit( const PxD6Joint* inObj ) { return inObj->getDistanceLimit(); } void setPxD6Joint_LinearLimit( PxD6Joint* inObj, const PxJointLinearLimit & inArg){ inObj->setLinearLimit( inArg ); } PxJointLinearLimit getPxD6Joint_LinearLimit( const PxD6Joint* inObj ) { return inObj->getLinearLimit(); } void setPxD6Joint_TwistLimit( PxD6Joint* inObj, const PxJointAngularLimitPair & inArg){ inObj->setTwistLimit( inArg ); } PxJointAngularLimitPair getPxD6Joint_TwistLimit( const PxD6Joint* inObj ) { return inObj->getTwistLimit(); } void setPxD6Joint_SwingLimit( PxD6Joint* inObj, const PxJointLimitCone & inArg){ inObj->setSwingLimit( inArg ); } PxJointLimitCone getPxD6Joint_SwingLimit( const PxD6Joint* inObj ) { return inObj->getSwingLimit(); } void setPxD6Joint_PyramidSwingLimit( PxD6Joint* inObj, const PxJointLimitPyramid & inArg){ inObj->setPyramidSwingLimit( inArg ); } PxJointLimitPyramid getPxD6Joint_PyramidSwingLimit( const PxD6Joint* inObj ) { return inObj->getPyramidSwingLimit(); } void setPxD6Joint_Drive( PxD6Joint* inObj, PxD6Drive::Enum inIndex, PxD6JointDrive inArg ){ inObj->setDrive( inIndex, inArg ); } PxD6JointDrive getPxD6Joint_Drive( const PxD6Joint* inObj, PxD6Drive::Enum inIndex ) { return inObj->getDrive( inIndex ); } void setPxD6Joint_DrivePosition( PxD6Joint* inObj, const PxTransform & inArg){ inObj->setDrivePosition( inArg ); } PxTransform getPxD6Joint_DrivePosition( const PxD6Joint* inObj ) { return inObj->getDrivePosition(); } const char * getPxD6Joint_ConcreteTypeName( const PxD6Joint* inObj ) { return inObj->getConcreteTypeName(); } PxD6JointGeneratedInfo::PxD6JointGeneratedInfo() : Motion( "Motion", setPxD6Joint_Motion, getPxD6Joint_Motion) , TwistAngle( "TwistAngle", getPxD6Joint_TwistAngle) , Twist( "Twist", getPxD6Joint_Twist) , SwingYAngle( "SwingYAngle", getPxD6Joint_SwingYAngle) , SwingZAngle( "SwingZAngle", getPxD6Joint_SwingZAngle) , DistanceLimit( "DistanceLimit", setPxD6Joint_DistanceLimit, getPxD6Joint_DistanceLimit) , LinearLimit( "LinearLimit", setPxD6Joint_LinearLimit, getPxD6Joint_LinearLimit) , TwistLimit( "TwistLimit", setPxD6Joint_TwistLimit, getPxD6Joint_TwistLimit) , SwingLimit( "SwingLimit", setPxD6Joint_SwingLimit, getPxD6Joint_SwingLimit) , PyramidSwingLimit( "PyramidSwingLimit", setPxD6Joint_PyramidSwingLimit, getPxD6Joint_PyramidSwingLimit) , Drive( "Drive", setPxD6Joint_Drive, getPxD6Joint_Drive) , DrivePosition( "DrivePosition", setPxD6Joint_DrivePosition, getPxD6Joint_DrivePosition) , ConcreteTypeName( "ConcreteTypeName", getPxD6Joint_ConcreteTypeName) {} PxD6JointGeneratedValues::PxD6JointGeneratedValues( const PxD6Joint* inSource ) :PxJointGeneratedValues( inSource ) ,TwistAngle( getPxD6Joint_TwistAngle( inSource ) ) ,Twist( getPxD6Joint_Twist( inSource ) ) ,SwingYAngle( getPxD6Joint_SwingYAngle( inSource ) ) ,SwingZAngle( getPxD6Joint_SwingZAngle( inSource ) ) ,DistanceLimit( getPxD6Joint_DistanceLimit( inSource ) ) ,LinearLimit( getPxD6Joint_LinearLimit( inSource ) ) ,TwistLimit( getPxD6Joint_TwistLimit( inSource ) ) ,SwingLimit( getPxD6Joint_SwingLimit( inSource ) ) ,PyramidSwingLimit( getPxD6Joint_PyramidSwingLimit( inSource ) ) ,DrivePosition( getPxD6Joint_DrivePosition( inSource ) ) ,ConcreteTypeName( getPxD6Joint_ConcreteTypeName( inSource ) ) { PX_UNUSED(inSource); for ( PxU32 idx = 0; idx < static_cast<PxU32>( physx::PxD6Axis::eCOUNT ); ++idx ) Motion[idx] = getPxD6Joint_Motion( inSource, static_cast< PxD6Axis::Enum >( idx ) ); for ( PxU32 idx = 0; idx < static_cast<PxU32>( physx::PxD6Drive::eCOUNT ); ++idx ) Drive[idx] = getPxD6Joint_Drive( inSource, static_cast< PxD6Drive::Enum >( idx ) ); } PxReal getPxDistanceJoint_Distance( const PxDistanceJoint* inObj ) { return inObj->getDistance(); } void setPxDistanceJoint_MinDistance( PxDistanceJoint* inObj, PxReal inArg){ inObj->setMinDistance( inArg ); } PxReal getPxDistanceJoint_MinDistance( const PxDistanceJoint* inObj ) { return inObj->getMinDistance(); } void setPxDistanceJoint_MaxDistance( PxDistanceJoint* inObj, PxReal inArg){ inObj->setMaxDistance( inArg ); } PxReal getPxDistanceJoint_MaxDistance( const PxDistanceJoint* inObj ) { return inObj->getMaxDistance(); } void setPxDistanceJoint_Tolerance( PxDistanceJoint* inObj, PxReal inArg){ inObj->setTolerance( inArg ); } PxReal getPxDistanceJoint_Tolerance( const PxDistanceJoint* inObj ) { return inObj->getTolerance(); } void setPxDistanceJoint_Stiffness( PxDistanceJoint* inObj, PxReal inArg){ inObj->setStiffness( inArg ); } PxReal getPxDistanceJoint_Stiffness( const PxDistanceJoint* inObj ) { return inObj->getStiffness(); } void setPxDistanceJoint_Damping( PxDistanceJoint* inObj, PxReal inArg){ inObj->setDamping( inArg ); } PxReal getPxDistanceJoint_Damping( const PxDistanceJoint* inObj ) { return inObj->getDamping(); } void setPxDistanceJoint_DistanceJointFlags( PxDistanceJoint* inObj, PxDistanceJointFlags inArg){ inObj->setDistanceJointFlags( inArg ); } PxDistanceJointFlags getPxDistanceJoint_DistanceJointFlags( const PxDistanceJoint* inObj ) { return inObj->getDistanceJointFlags(); } const char * getPxDistanceJoint_ConcreteTypeName( const PxDistanceJoint* inObj ) { return inObj->getConcreteTypeName(); } PxDistanceJointGeneratedInfo::PxDistanceJointGeneratedInfo() : Distance( "Distance", getPxDistanceJoint_Distance) , MinDistance( "MinDistance", setPxDistanceJoint_MinDistance, getPxDistanceJoint_MinDistance) , MaxDistance( "MaxDistance", setPxDistanceJoint_MaxDistance, getPxDistanceJoint_MaxDistance) , Tolerance( "Tolerance", setPxDistanceJoint_Tolerance, getPxDistanceJoint_Tolerance) , Stiffness( "Stiffness", setPxDistanceJoint_Stiffness, getPxDistanceJoint_Stiffness) , Damping( "Damping", setPxDistanceJoint_Damping, getPxDistanceJoint_Damping) , DistanceJointFlags( "DistanceJointFlags", setPxDistanceJoint_DistanceJointFlags, getPxDistanceJoint_DistanceJointFlags) , ConcreteTypeName( "ConcreteTypeName", getPxDistanceJoint_ConcreteTypeName) {} PxDistanceJointGeneratedValues::PxDistanceJointGeneratedValues( const PxDistanceJoint* inSource ) :PxJointGeneratedValues( inSource ) ,Distance( getPxDistanceJoint_Distance( inSource ) ) ,MinDistance( getPxDistanceJoint_MinDistance( inSource ) ) ,MaxDistance( getPxDistanceJoint_MaxDistance( inSource ) ) ,Tolerance( getPxDistanceJoint_Tolerance( inSource ) ) ,Stiffness( getPxDistanceJoint_Stiffness( inSource ) ) ,Damping( getPxDistanceJoint_Damping( inSource ) ) ,DistanceJointFlags( getPxDistanceJoint_DistanceJointFlags( inSource ) ) ,ConcreteTypeName( getPxDistanceJoint_ConcreteTypeName( inSource ) ) { PX_UNUSED(inSource); } void setPxContactJoint_Contact( PxContactJoint* inObj, const PxVec3 & inArg){ inObj->setContact( inArg ); } PxVec3 getPxContactJoint_Contact( const PxContactJoint* inObj ) { return inObj->getContact(); } void setPxContactJoint_ContactNormal( PxContactJoint* inObj, const PxVec3 & inArg){ inObj->setContactNormal( inArg ); } PxVec3 getPxContactJoint_ContactNormal( const PxContactJoint* inObj ) { return inObj->getContactNormal(); } void setPxContactJoint_Penetration( PxContactJoint* inObj, const PxReal inArg){ inObj->setPenetration( inArg ); } PxReal getPxContactJoint_Penetration( const PxContactJoint* inObj ) { return inObj->getPenetration(); } void setPxContactJoint_Restitution( PxContactJoint* inObj, const PxReal inArg){ inObj->setRestitution( inArg ); } PxReal getPxContactJoint_Restitution( const PxContactJoint* inObj ) { return inObj->getRestitution(); } void setPxContactJoint_BounceThreshold( PxContactJoint* inObj, const PxReal inArg){ inObj->setBounceThreshold( inArg ); } PxReal getPxContactJoint_BounceThreshold( const PxContactJoint* inObj ) { return inObj->getBounceThreshold(); } const char * getPxContactJoint_ConcreteTypeName( const PxContactJoint* inObj ) { return inObj->getConcreteTypeName(); } PxContactJointGeneratedInfo::PxContactJointGeneratedInfo() : Contact( "Contact", setPxContactJoint_Contact, getPxContactJoint_Contact) , ContactNormal( "ContactNormal", setPxContactJoint_ContactNormal, getPxContactJoint_ContactNormal) , Penetration( "Penetration", setPxContactJoint_Penetration, getPxContactJoint_Penetration) , Restitution( "Restitution", setPxContactJoint_Restitution, getPxContactJoint_Restitution) , BounceThreshold( "BounceThreshold", setPxContactJoint_BounceThreshold, getPxContactJoint_BounceThreshold) , ConcreteTypeName( "ConcreteTypeName", getPxContactJoint_ConcreteTypeName) {} PxContactJointGeneratedValues::PxContactJointGeneratedValues( const PxContactJoint* inSource ) :PxJointGeneratedValues( inSource ) ,Contact( getPxContactJoint_Contact( inSource ) ) ,ContactNormal( getPxContactJoint_ContactNormal( inSource ) ) ,Penetration( getPxContactJoint_Penetration( inSource ) ) ,Restitution( getPxContactJoint_Restitution( inSource ) ) ,BounceThreshold( getPxContactJoint_BounceThreshold( inSource ) ) ,ConcreteTypeName( getPxContactJoint_ConcreteTypeName( inSource ) ) { PX_UNUSED(inSource); } const char * getPxFixedJoint_ConcreteTypeName( const PxFixedJoint* inObj ) { return inObj->getConcreteTypeName(); } PxFixedJointGeneratedInfo::PxFixedJointGeneratedInfo() : ConcreteTypeName( "ConcreteTypeName", getPxFixedJoint_ConcreteTypeName) {} PxFixedJointGeneratedValues::PxFixedJointGeneratedValues( const PxFixedJoint* inSource ) :PxJointGeneratedValues( inSource ) ,ConcreteTypeName( getPxFixedJoint_ConcreteTypeName( inSource ) ) { PX_UNUSED(inSource); } PxReal getPxPrismaticJoint_Position( const PxPrismaticJoint* inObj ) { return inObj->getPosition(); } PxReal getPxPrismaticJoint_Velocity( const PxPrismaticJoint* inObj ) { return inObj->getVelocity(); } void setPxPrismaticJoint_Limit( PxPrismaticJoint* inObj, const PxJointLinearLimitPair & inArg){ inObj->setLimit( inArg ); } PxJointLinearLimitPair getPxPrismaticJoint_Limit( const PxPrismaticJoint* inObj ) { return inObj->getLimit(); } void setPxPrismaticJoint_PrismaticJointFlags( PxPrismaticJoint* inObj, PxPrismaticJointFlags inArg){ inObj->setPrismaticJointFlags( inArg ); } PxPrismaticJointFlags getPxPrismaticJoint_PrismaticJointFlags( const PxPrismaticJoint* inObj ) { return inObj->getPrismaticJointFlags(); } const char * getPxPrismaticJoint_ConcreteTypeName( const PxPrismaticJoint* inObj ) { return inObj->getConcreteTypeName(); } PxPrismaticJointGeneratedInfo::PxPrismaticJointGeneratedInfo() : Position( "Position", getPxPrismaticJoint_Position) , Velocity( "Velocity", getPxPrismaticJoint_Velocity) , Limit( "Limit", setPxPrismaticJoint_Limit, getPxPrismaticJoint_Limit) , PrismaticJointFlags( "PrismaticJointFlags", setPxPrismaticJoint_PrismaticJointFlags, getPxPrismaticJoint_PrismaticJointFlags) , ConcreteTypeName( "ConcreteTypeName", getPxPrismaticJoint_ConcreteTypeName) {} PxPrismaticJointGeneratedValues::PxPrismaticJointGeneratedValues( const PxPrismaticJoint* inSource ) :PxJointGeneratedValues( inSource ) ,Position( getPxPrismaticJoint_Position( inSource ) ) ,Velocity( getPxPrismaticJoint_Velocity( inSource ) ) ,Limit( getPxPrismaticJoint_Limit( inSource ) ) ,PrismaticJointFlags( getPxPrismaticJoint_PrismaticJointFlags( inSource ) ) ,ConcreteTypeName( getPxPrismaticJoint_ConcreteTypeName( inSource ) ) { PX_UNUSED(inSource); } PxReal getPxRevoluteJoint_Angle( const PxRevoluteJoint* inObj ) { return inObj->getAngle(); } PxReal getPxRevoluteJoint_Velocity( const PxRevoluteJoint* inObj ) { return inObj->getVelocity(); } void setPxRevoluteJoint_Limit( PxRevoluteJoint* inObj, const PxJointAngularLimitPair & inArg){ inObj->setLimit( inArg ); } PxJointAngularLimitPair getPxRevoluteJoint_Limit( const PxRevoluteJoint* inObj ) { return inObj->getLimit(); } void setPxRevoluteJoint_DriveVelocity( PxRevoluteJoint* inObj, PxReal inArg){ inObj->setDriveVelocity( inArg ); } PxReal getPxRevoluteJoint_DriveVelocity( const PxRevoluteJoint* inObj ) { return inObj->getDriveVelocity(); } void setPxRevoluteJoint_DriveForceLimit( PxRevoluteJoint* inObj, PxReal inArg){ inObj->setDriveForceLimit( inArg ); } PxReal getPxRevoluteJoint_DriveForceLimit( const PxRevoluteJoint* inObj ) { return inObj->getDriveForceLimit(); } void setPxRevoluteJoint_DriveGearRatio( PxRevoluteJoint* inObj, PxReal inArg){ inObj->setDriveGearRatio( inArg ); } PxReal getPxRevoluteJoint_DriveGearRatio( const PxRevoluteJoint* inObj ) { return inObj->getDriveGearRatio(); } void setPxRevoluteJoint_RevoluteJointFlags( PxRevoluteJoint* inObj, PxRevoluteJointFlags inArg){ inObj->setRevoluteJointFlags( inArg ); } PxRevoluteJointFlags getPxRevoluteJoint_RevoluteJointFlags( const PxRevoluteJoint* inObj ) { return inObj->getRevoluteJointFlags(); } const char * getPxRevoluteJoint_ConcreteTypeName( const PxRevoluteJoint* inObj ) { return inObj->getConcreteTypeName(); } PxRevoluteJointGeneratedInfo::PxRevoluteJointGeneratedInfo() : Angle( "Angle", getPxRevoluteJoint_Angle) , Velocity( "Velocity", getPxRevoluteJoint_Velocity) , Limit( "Limit", setPxRevoluteJoint_Limit, getPxRevoluteJoint_Limit) , DriveVelocity( "DriveVelocity", setPxRevoluteJoint_DriveVelocity, getPxRevoluteJoint_DriveVelocity) , DriveForceLimit( "DriveForceLimit", setPxRevoluteJoint_DriveForceLimit, getPxRevoluteJoint_DriveForceLimit) , DriveGearRatio( "DriveGearRatio", setPxRevoluteJoint_DriveGearRatio, getPxRevoluteJoint_DriveGearRatio) , RevoluteJointFlags( "RevoluteJointFlags", setPxRevoluteJoint_RevoluteJointFlags, getPxRevoluteJoint_RevoluteJointFlags) , ConcreteTypeName( "ConcreteTypeName", getPxRevoluteJoint_ConcreteTypeName) {} PxRevoluteJointGeneratedValues::PxRevoluteJointGeneratedValues( const PxRevoluteJoint* inSource ) :PxJointGeneratedValues( inSource ) ,Angle( getPxRevoluteJoint_Angle( inSource ) ) ,Velocity( getPxRevoluteJoint_Velocity( inSource ) ) ,Limit( getPxRevoluteJoint_Limit( inSource ) ) ,DriveVelocity( getPxRevoluteJoint_DriveVelocity( inSource ) ) ,DriveForceLimit( getPxRevoluteJoint_DriveForceLimit( inSource ) ) ,DriveGearRatio( getPxRevoluteJoint_DriveGearRatio( inSource ) ) ,RevoluteJointFlags( getPxRevoluteJoint_RevoluteJointFlags( inSource ) ) ,ConcreteTypeName( getPxRevoluteJoint_ConcreteTypeName( inSource ) ) { PX_UNUSED(inSource); } void setPxSphericalJoint_LimitCone( PxSphericalJoint* inObj, const PxJointLimitCone & inArg){ inObj->setLimitCone( inArg ); } PxJointLimitCone getPxSphericalJoint_LimitCone( const PxSphericalJoint* inObj ) { return inObj->getLimitCone(); } PxReal getPxSphericalJoint_SwingYAngle( const PxSphericalJoint* inObj ) { return inObj->getSwingYAngle(); } PxReal getPxSphericalJoint_SwingZAngle( const PxSphericalJoint* inObj ) { return inObj->getSwingZAngle(); } void setPxSphericalJoint_SphericalJointFlags( PxSphericalJoint* inObj, PxSphericalJointFlags inArg){ inObj->setSphericalJointFlags( inArg ); } PxSphericalJointFlags getPxSphericalJoint_SphericalJointFlags( const PxSphericalJoint* inObj ) { return inObj->getSphericalJointFlags(); } const char * getPxSphericalJoint_ConcreteTypeName( const PxSphericalJoint* inObj ) { return inObj->getConcreteTypeName(); } PxSphericalJointGeneratedInfo::PxSphericalJointGeneratedInfo() : LimitCone( "LimitCone", setPxSphericalJoint_LimitCone, getPxSphericalJoint_LimitCone) , SwingYAngle( "SwingYAngle", getPxSphericalJoint_SwingYAngle) , SwingZAngle( "SwingZAngle", getPxSphericalJoint_SwingZAngle) , SphericalJointFlags( "SphericalJointFlags", setPxSphericalJoint_SphericalJointFlags, getPxSphericalJoint_SphericalJointFlags) , ConcreteTypeName( "ConcreteTypeName", getPxSphericalJoint_ConcreteTypeName) {} PxSphericalJointGeneratedValues::PxSphericalJointGeneratedValues( const PxSphericalJoint* inSource ) :PxJointGeneratedValues( inSource ) ,LimitCone( getPxSphericalJoint_LimitCone( inSource ) ) ,SwingYAngle( getPxSphericalJoint_SwingYAngle( inSource ) ) ,SwingZAngle( getPxSphericalJoint_SwingZAngle( inSource ) ) ,SphericalJointFlags( getPxSphericalJoint_SphericalJointFlags( inSource ) ) ,ConcreteTypeName( getPxSphericalJoint_ConcreteTypeName( inSource ) ) { PX_UNUSED(inSource); } inline PxReal getPxJointLimitParametersRestitution( const PxJointLimitParameters* inOwner ) { return inOwner->restitution; } inline void setPxJointLimitParametersRestitution( PxJointLimitParameters* inOwner, PxReal inData) { inOwner->restitution = inData; } inline PxReal getPxJointLimitParametersBounceThreshold( const PxJointLimitParameters* inOwner ) { return inOwner->bounceThreshold; } inline void setPxJointLimitParametersBounceThreshold( PxJointLimitParameters* inOwner, PxReal inData) { inOwner->bounceThreshold = inData; } inline PxReal getPxJointLimitParametersStiffness( const PxJointLimitParameters* inOwner ) { return inOwner->stiffness; } inline void setPxJointLimitParametersStiffness( PxJointLimitParameters* inOwner, PxReal inData) { inOwner->stiffness = inData; } inline PxReal getPxJointLimitParametersDamping( const PxJointLimitParameters* inOwner ) { return inOwner->damping; } inline void setPxJointLimitParametersDamping( PxJointLimitParameters* inOwner, PxReal inData) { inOwner->damping = inData; } PxJointLimitParametersGeneratedInfo::PxJointLimitParametersGeneratedInfo() : Restitution( "Restitution", setPxJointLimitParametersRestitution, getPxJointLimitParametersRestitution ) , BounceThreshold( "BounceThreshold", setPxJointLimitParametersBounceThreshold, getPxJointLimitParametersBounceThreshold ) , Stiffness( "Stiffness", setPxJointLimitParametersStiffness, getPxJointLimitParametersStiffness ) , Damping( "Damping", setPxJointLimitParametersDamping, getPxJointLimitParametersDamping ) {} PxJointLimitParametersGeneratedValues::PxJointLimitParametersGeneratedValues( const PxJointLimitParameters* inSource ) :Restitution( inSource->restitution ) ,BounceThreshold( inSource->bounceThreshold ) ,Stiffness( inSource->stiffness ) ,Damping( inSource->damping ) { PX_UNUSED(inSource); } inline PxReal getPxJointLinearLimitValue( const PxJointLinearLimit* inOwner ) { return inOwner->value; } inline void setPxJointLinearLimitValue( PxJointLinearLimit* inOwner, PxReal inData) { inOwner->value = inData; } PxJointLinearLimitGeneratedInfo::PxJointLinearLimitGeneratedInfo() : Value( "Value", setPxJointLinearLimitValue, getPxJointLinearLimitValue ) {} PxJointLinearLimitGeneratedValues::PxJointLinearLimitGeneratedValues( const PxJointLinearLimit* inSource ) :PxJointLimitParametersGeneratedValues( inSource ) ,Value( inSource->value ) { PX_UNUSED(inSource); } inline PxReal getPxJointLinearLimitPairUpper( const PxJointLinearLimitPair* inOwner ) { return inOwner->upper; } inline void setPxJointLinearLimitPairUpper( PxJointLinearLimitPair* inOwner, PxReal inData) { inOwner->upper = inData; } inline PxReal getPxJointLinearLimitPairLower( const PxJointLinearLimitPair* inOwner ) { return inOwner->lower; } inline void setPxJointLinearLimitPairLower( PxJointLinearLimitPair* inOwner, PxReal inData) { inOwner->lower = inData; } PxJointLinearLimitPairGeneratedInfo::PxJointLinearLimitPairGeneratedInfo() : Upper( "Upper", setPxJointLinearLimitPairUpper, getPxJointLinearLimitPairUpper ) , Lower( "Lower", setPxJointLinearLimitPairLower, getPxJointLinearLimitPairLower ) {} PxJointLinearLimitPairGeneratedValues::PxJointLinearLimitPairGeneratedValues( const PxJointLinearLimitPair* inSource ) :PxJointLimitParametersGeneratedValues( inSource ) ,Upper( inSource->upper ) ,Lower( inSource->lower ) { PX_UNUSED(inSource); } inline PxReal getPxJointAngularLimitPairUpper( const PxJointAngularLimitPair* inOwner ) { return inOwner->upper; } inline void setPxJointAngularLimitPairUpper( PxJointAngularLimitPair* inOwner, PxReal inData) { inOwner->upper = inData; } inline PxReal getPxJointAngularLimitPairLower( const PxJointAngularLimitPair* inOwner ) { return inOwner->lower; } inline void setPxJointAngularLimitPairLower( PxJointAngularLimitPair* inOwner, PxReal inData) { inOwner->lower = inData; } PxJointAngularLimitPairGeneratedInfo::PxJointAngularLimitPairGeneratedInfo() : Upper( "Upper", setPxJointAngularLimitPairUpper, getPxJointAngularLimitPairUpper ) , Lower( "Lower", setPxJointAngularLimitPairLower, getPxJointAngularLimitPairLower ) {} PxJointAngularLimitPairGeneratedValues::PxJointAngularLimitPairGeneratedValues( const PxJointAngularLimitPair* inSource ) :PxJointLimitParametersGeneratedValues( inSource ) ,Upper( inSource->upper ) ,Lower( inSource->lower ) { PX_UNUSED(inSource); } inline PxReal getPxJointLimitConeYAngle( const PxJointLimitCone* inOwner ) { return inOwner->yAngle; } inline void setPxJointLimitConeYAngle( PxJointLimitCone* inOwner, PxReal inData) { inOwner->yAngle = inData; } inline PxReal getPxJointLimitConeZAngle( const PxJointLimitCone* inOwner ) { return inOwner->zAngle; } inline void setPxJointLimitConeZAngle( PxJointLimitCone* inOwner, PxReal inData) { inOwner->zAngle = inData; } PxJointLimitConeGeneratedInfo::PxJointLimitConeGeneratedInfo() : YAngle( "YAngle", setPxJointLimitConeYAngle, getPxJointLimitConeYAngle ) , ZAngle( "ZAngle", setPxJointLimitConeZAngle, getPxJointLimitConeZAngle ) {} PxJointLimitConeGeneratedValues::PxJointLimitConeGeneratedValues( const PxJointLimitCone* inSource ) :PxJointLimitParametersGeneratedValues( inSource ) ,YAngle( inSource->yAngle ) ,ZAngle( inSource->zAngle ) { PX_UNUSED(inSource); } inline PxReal getPxJointLimitPyramidYAngleMin( const PxJointLimitPyramid* inOwner ) { return inOwner->yAngleMin; } inline void setPxJointLimitPyramidYAngleMin( PxJointLimitPyramid* inOwner, PxReal inData) { inOwner->yAngleMin = inData; } inline PxReal getPxJointLimitPyramidYAngleMax( const PxJointLimitPyramid* inOwner ) { return inOwner->yAngleMax; } inline void setPxJointLimitPyramidYAngleMax( PxJointLimitPyramid* inOwner, PxReal inData) { inOwner->yAngleMax = inData; } inline PxReal getPxJointLimitPyramidZAngleMin( const PxJointLimitPyramid* inOwner ) { return inOwner->zAngleMin; } inline void setPxJointLimitPyramidZAngleMin( PxJointLimitPyramid* inOwner, PxReal inData) { inOwner->zAngleMin = inData; } inline PxReal getPxJointLimitPyramidZAngleMax( const PxJointLimitPyramid* inOwner ) { return inOwner->zAngleMax; } inline void setPxJointLimitPyramidZAngleMax( PxJointLimitPyramid* inOwner, PxReal inData) { inOwner->zAngleMax = inData; } PxJointLimitPyramidGeneratedInfo::PxJointLimitPyramidGeneratedInfo() : YAngleMin( "YAngleMin", setPxJointLimitPyramidYAngleMin, getPxJointLimitPyramidYAngleMin ) , YAngleMax( "YAngleMax", setPxJointLimitPyramidYAngleMax, getPxJointLimitPyramidYAngleMax ) , ZAngleMin( "ZAngleMin", setPxJointLimitPyramidZAngleMin, getPxJointLimitPyramidZAngleMin ) , ZAngleMax( "ZAngleMax", setPxJointLimitPyramidZAngleMax, getPxJointLimitPyramidZAngleMax ) {} PxJointLimitPyramidGeneratedValues::PxJointLimitPyramidGeneratedValues( const PxJointLimitPyramid* inSource ) :PxJointLimitParametersGeneratedValues( inSource ) ,YAngleMin( inSource->yAngleMin ) ,YAngleMax( inSource->yAngleMax ) ,ZAngleMin( inSource->zAngleMin ) ,ZAngleMax( inSource->zAngleMax ) { PX_UNUSED(inSource); } inline PxReal getPxSpringStiffness( const PxSpring* inOwner ) { return inOwner->stiffness; } inline void setPxSpringStiffness( PxSpring* inOwner, PxReal inData) { inOwner->stiffness = inData; } inline PxReal getPxSpringDamping( const PxSpring* inOwner ) { return inOwner->damping; } inline void setPxSpringDamping( PxSpring* inOwner, PxReal inData) { inOwner->damping = inData; } PxSpringGeneratedInfo::PxSpringGeneratedInfo() : Stiffness( "Stiffness", setPxSpringStiffness, getPxSpringStiffness ) , Damping( "Damping", setPxSpringDamping, getPxSpringDamping ) {} PxSpringGeneratedValues::PxSpringGeneratedValues( const PxSpring* inSource ) :Stiffness( inSource->stiffness ) ,Damping( inSource->damping ) { PX_UNUSED(inSource); } inline PxReal getPxD6JointDriveForceLimit( const PxD6JointDrive* inOwner ) { return inOwner->forceLimit; } inline void setPxD6JointDriveForceLimit( PxD6JointDrive* inOwner, PxReal inData) { inOwner->forceLimit = inData; } inline PxD6JointDriveFlags getPxD6JointDriveFlags( const PxD6JointDrive* inOwner ) { return inOwner->flags; } inline void setPxD6JointDriveFlags( PxD6JointDrive* inOwner, PxD6JointDriveFlags inData) { inOwner->flags = inData; } PxD6JointDriveGeneratedInfo::PxD6JointDriveGeneratedInfo() : ForceLimit( "ForceLimit", setPxD6JointDriveForceLimit, getPxD6JointDriveForceLimit ) , Flags( "Flags", setPxD6JointDriveFlags, getPxD6JointDriveFlags ) {} PxD6JointDriveGeneratedValues::PxD6JointDriveGeneratedValues( const PxD6JointDrive* inSource ) :PxSpringGeneratedValues( inSource ) ,ForceLimit( inSource->forceLimit ) ,Flags( inSource->flags ) { PX_UNUSED(inSource); }
34,601
C++
70.34433
142
0.80411
NVIDIA-Omniverse/PhysX/physx/source/physxmetadata/extensions/include/PxExtensionAutoGeneratedMetaDataObjects.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. // This code is auto-generated by the PhysX Clang metadata generator. Do not edit or be // prepared for your edits to be quietly ignored next time the clang metadata generator is // run. You can find the most recent version of clang metadata generator by contacting // Chris Nuernberger <[email protected]> or Dilip or Adam. // The source code for the generate was at one time checked into: // physx/PhysXMetaDataGenerator/llvm/tools/clang/lib/Frontend/PhysXMetaDataAction.cpp #define THERE_IS_NO_INCLUDE_GUARD_HERE_FOR_A_REASON #define PX_PROPERTY_INFO_NAME PxExtensionsPropertyInfoName static PxU32ToName g_physx__PxJointActorIndex__EnumConversion[] = { { "eACTOR0", static_cast<PxU32>( physx::PxJointActorIndex::eACTOR0 ) }, { "eACTOR1", static_cast<PxU32>( physx::PxJointActorIndex::eACTOR1 ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxJointActorIndex::Enum > { PxEnumTraits() : NameConversion( g_physx__PxJointActorIndex__EnumConversion ) {} const PxU32ToName* NameConversion; }; class PxJoint; struct PxJointGeneratedValues { PxRigidActor * Actors[2]; PxTransform LocalPose[physx::PxJointActorIndex::COUNT]; PxTransform RelativeTransform; PxVec3 RelativeLinearVelocity; PxVec3 RelativeAngularVelocity; PxReal BreakForce[2]; PxConstraintFlags ConstraintFlags; PxReal InvMassScale0; PxReal InvInertiaScale0; PxReal InvMassScale1; PxReal InvInertiaScale1; PxConstraint * Constraint; const char * Name; PxScene * Scene; void * UserData; PxJointGeneratedValues( const PxJoint* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJoint, Actors, PxJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJoint, LocalPose, PxJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJoint, RelativeTransform, PxJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJoint, RelativeLinearVelocity, PxJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJoint, RelativeAngularVelocity, PxJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJoint, BreakForce, PxJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJoint, ConstraintFlags, PxJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJoint, InvMassScale0, PxJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJoint, InvInertiaScale0, PxJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJoint, InvMassScale1, PxJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJoint, InvInertiaScale1, PxJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJoint, Constraint, PxJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJoint, Name, PxJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJoint, Scene, PxJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJoint, UserData, PxJointGeneratedValues) struct PxJointGeneratedInfo { static const char* getClassName() { return "PxJoint"; } PxRangePropertyInfo<PX_PROPERTY_INFO_NAME::PxJoint_Actors, PxJoint, PxRigidActor * > Actors; PxIndexedPropertyInfo<PX_PROPERTY_INFO_NAME::PxJoint_LocalPose, PxJoint, PxJointActorIndex::Enum, PxTransform > LocalPose; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxJoint_RelativeTransform, PxJoint, PxTransform > RelativeTransform; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxJoint_RelativeLinearVelocity, PxJoint, PxVec3 > RelativeLinearVelocity; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxJoint_RelativeAngularVelocity, PxJoint, PxVec3 > RelativeAngularVelocity; PxRangePropertyInfo<PX_PROPERTY_INFO_NAME::PxJoint_BreakForce, PxJoint, PxReal > BreakForce; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJoint_ConstraintFlags, PxJoint, PxConstraintFlags, PxConstraintFlags > ConstraintFlags; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJoint_InvMassScale0, PxJoint, PxReal, PxReal > InvMassScale0; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJoint_InvInertiaScale0, PxJoint, PxReal, PxReal > InvInertiaScale0; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJoint_InvMassScale1, PxJoint, PxReal, PxReal > InvMassScale1; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJoint_InvInertiaScale1, PxJoint, PxReal, PxReal > InvInertiaScale1; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxJoint_Constraint, PxJoint, PxConstraint * > Constraint; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJoint_Name, PxJoint, const char *, const char * > Name; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxJoint_Scene, PxJoint, PxScene * > Scene; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJoint_UserData, PxJoint, void *, void * > UserData; PxJointGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxJoint*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); return inStartIndex; } static PxU32 instancePropertyCount() { return 15; } static PxU32 totalPropertyCount() { return instancePropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( Actors, inStartIndex + 0 );; inOperator( LocalPose, inStartIndex + 1 );; inOperator( RelativeTransform, inStartIndex + 2 );; inOperator( RelativeLinearVelocity, inStartIndex + 3 );; inOperator( RelativeAngularVelocity, inStartIndex + 4 );; inOperator( BreakForce, inStartIndex + 5 );; inOperator( ConstraintFlags, inStartIndex + 6 );; inOperator( InvMassScale0, inStartIndex + 7 );; inOperator( InvInertiaScale0, inStartIndex + 8 );; inOperator( InvMassScale1, inStartIndex + 9 );; inOperator( InvInertiaScale1, inStartIndex + 10 );; inOperator( Constraint, inStartIndex + 11 );; inOperator( Name, inStartIndex + 12 );; inOperator( Scene, inStartIndex + 13 );; inOperator( UserData, inStartIndex + 14 );; return 15 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxJoint> { PxJointGeneratedInfo Info; const PxJointGeneratedInfo* getInfo() { return &Info; } }; class PxRackAndPinionJoint; struct PxRackAndPinionJointGeneratedValues : PxJointGeneratedValues { float Ratio; const char * ConcreteTypeName; PxRackAndPinionJointGeneratedValues( const PxRackAndPinionJoint* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRackAndPinionJoint, Ratio, PxRackAndPinionJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRackAndPinionJoint, ConcreteTypeName, PxRackAndPinionJointGeneratedValues) struct PxRackAndPinionJointGeneratedInfo : PxJointGeneratedInfo { static const char* getClassName() { return "PxRackAndPinionJoint"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRackAndPinionJoint_Ratio, PxRackAndPinionJoint, float, float > Ratio; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxRackAndPinionJoint_ConcreteTypeName, PxRackAndPinionJoint, const char * > ConcreteTypeName; PxRackAndPinionJointGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxRackAndPinionJoint*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxJointGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxJointGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxJointGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 2; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxJointGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( Ratio, inStartIndex + 0 );; inOperator( ConcreteTypeName, inStartIndex + 1 );; return 2 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxRackAndPinionJoint> { PxRackAndPinionJointGeneratedInfo Info; const PxRackAndPinionJointGeneratedInfo* getInfo() { return &Info; } }; class PxGearJoint; struct PxGearJointGeneratedValues : PxJointGeneratedValues { float GearRatio; const char * ConcreteTypeName; PxGearJointGeneratedValues( const PxGearJoint* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxGearJoint, GearRatio, PxGearJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxGearJoint, ConcreteTypeName, PxGearJointGeneratedValues) struct PxGearJointGeneratedInfo : PxJointGeneratedInfo { static const char* getClassName() { return "PxGearJoint"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxGearJoint_GearRatio, PxGearJoint, float, float > GearRatio; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxGearJoint_ConcreteTypeName, PxGearJoint, const char * > ConcreteTypeName; PxGearJointGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxGearJoint*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxJointGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxJointGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxJointGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 2; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxJointGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( GearRatio, inStartIndex + 0 );; inOperator( ConcreteTypeName, inStartIndex + 1 );; return 2 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxGearJoint> { PxGearJointGeneratedInfo Info; const PxGearJointGeneratedInfo* getInfo() { return &Info; } }; static PxU32ToName g_physx__PxD6Axis__EnumConversion[] = { { "eX", static_cast<PxU32>( physx::PxD6Axis::eX ) }, { "eY", static_cast<PxU32>( physx::PxD6Axis::eY ) }, { "eZ", static_cast<PxU32>( physx::PxD6Axis::eZ ) }, { "eTWIST", static_cast<PxU32>( physx::PxD6Axis::eTWIST ) }, { "eSWING1", static_cast<PxU32>( physx::PxD6Axis::eSWING1 ) }, { "eSWING2", static_cast<PxU32>( physx::PxD6Axis::eSWING2 ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxD6Axis::Enum > { PxEnumTraits() : NameConversion( g_physx__PxD6Axis__EnumConversion ) {} const PxU32ToName* NameConversion; }; static PxU32ToName g_physx__PxD6Motion__EnumConversion[] = { { "eLOCKED", static_cast<PxU32>( physx::PxD6Motion::eLOCKED ) }, { "eLIMITED", static_cast<PxU32>( physx::PxD6Motion::eLIMITED ) }, { "eFREE", static_cast<PxU32>( physx::PxD6Motion::eFREE ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxD6Motion::Enum > { PxEnumTraits() : NameConversion( g_physx__PxD6Motion__EnumConversion ) {} const PxU32ToName* NameConversion; }; static PxU32ToName g_physx__PxD6Drive__EnumConversion[] = { { "eX", static_cast<PxU32>( physx::PxD6Drive::eX ) }, { "eY", static_cast<PxU32>( physx::PxD6Drive::eY ) }, { "eZ", static_cast<PxU32>( physx::PxD6Drive::eZ ) }, { "eSWING", static_cast<PxU32>( physx::PxD6Drive::eSWING ) }, { "eTWIST", static_cast<PxU32>( physx::PxD6Drive::eTWIST ) }, { "eSLERP", static_cast<PxU32>( physx::PxD6Drive::eSLERP ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxD6Drive::Enum > { PxEnumTraits() : NameConversion( g_physx__PxD6Drive__EnumConversion ) {} const PxU32ToName* NameConversion; }; class PxD6Joint; struct PxD6JointGeneratedValues : PxJointGeneratedValues { PxD6Motion::Enum Motion[physx::PxD6Axis::eCOUNT]; PxReal TwistAngle; PxReal Twist; PxReal SwingYAngle; PxReal SwingZAngle; PxJointLinearLimit DistanceLimit; PxJointLinearLimit LinearLimit; PxJointAngularLimitPair TwistLimit; PxJointLimitCone SwingLimit; PxJointLimitPyramid PyramidSwingLimit; PxD6JointDrive Drive[physx::PxD6Drive::eCOUNT]; PxTransform DrivePosition; const char * ConcreteTypeName; PxD6JointGeneratedValues( const PxD6Joint* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxD6Joint, Motion, PxD6JointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxD6Joint, TwistAngle, PxD6JointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxD6Joint, Twist, PxD6JointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxD6Joint, SwingYAngle, PxD6JointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxD6Joint, SwingZAngle, PxD6JointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxD6Joint, DistanceLimit, PxD6JointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxD6Joint, LinearLimit, PxD6JointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxD6Joint, TwistLimit, PxD6JointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxD6Joint, SwingLimit, PxD6JointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxD6Joint, PyramidSwingLimit, PxD6JointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxD6Joint, Drive, PxD6JointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxD6Joint, DrivePosition, PxD6JointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxD6Joint, ConcreteTypeName, PxD6JointGeneratedValues) struct PxD6JointGeneratedInfo : PxJointGeneratedInfo { static const char* getClassName() { return "PxD6Joint"; } PxIndexedPropertyInfo<PX_PROPERTY_INFO_NAME::PxD6Joint_Motion, PxD6Joint, PxD6Axis::Enum, PxD6Motion::Enum > Motion; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxD6Joint_TwistAngle, PxD6Joint, PxReal > TwistAngle; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxD6Joint_Twist, PxD6Joint, PxReal > Twist; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxD6Joint_SwingYAngle, PxD6Joint, PxReal > SwingYAngle; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxD6Joint_SwingZAngle, PxD6Joint, PxReal > SwingZAngle; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxD6Joint_DistanceLimit, PxD6Joint, const PxJointLinearLimit &, PxJointLinearLimit > DistanceLimit; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxD6Joint_LinearLimit, PxD6Joint, const PxJointLinearLimit &, PxJointLinearLimit > LinearLimit; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxD6Joint_TwistLimit, PxD6Joint, const PxJointAngularLimitPair &, PxJointAngularLimitPair > TwistLimit; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxD6Joint_SwingLimit, PxD6Joint, const PxJointLimitCone &, PxJointLimitCone > SwingLimit; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxD6Joint_PyramidSwingLimit, PxD6Joint, const PxJointLimitPyramid &, PxJointLimitPyramid > PyramidSwingLimit; PxIndexedPropertyInfo<PX_PROPERTY_INFO_NAME::PxD6Joint_Drive, PxD6Joint, PxD6Drive::Enum, PxD6JointDrive > Drive; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxD6Joint_DrivePosition, PxD6Joint, const PxTransform &, PxTransform > DrivePosition; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxD6Joint_ConcreteTypeName, PxD6Joint, const char * > ConcreteTypeName; PxD6JointGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxD6Joint*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxJointGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxJointGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxJointGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 13; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxJointGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( Motion, inStartIndex + 0 );; inOperator( TwistAngle, inStartIndex + 1 );; inOperator( Twist, inStartIndex + 2 );; inOperator( SwingYAngle, inStartIndex + 3 );; inOperator( SwingZAngle, inStartIndex + 4 );; inOperator( DistanceLimit, inStartIndex + 5 );; inOperator( LinearLimit, inStartIndex + 6 );; inOperator( TwistLimit, inStartIndex + 7 );; inOperator( SwingLimit, inStartIndex + 8 );; inOperator( PyramidSwingLimit, inStartIndex + 9 );; inOperator( Drive, inStartIndex + 10 );; inOperator( DrivePosition, inStartIndex + 11 );; inOperator( ConcreteTypeName, inStartIndex + 12 );; return 13 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxD6Joint> { PxD6JointGeneratedInfo Info; const PxD6JointGeneratedInfo* getInfo() { return &Info; } }; static PxU32ToName g_physx__PxDistanceJointFlag__EnumConversion[] = { { "eMAX_DISTANCE_ENABLED", static_cast<PxU32>( physx::PxDistanceJointFlag::eMAX_DISTANCE_ENABLED ) }, { "eMIN_DISTANCE_ENABLED", static_cast<PxU32>( physx::PxDistanceJointFlag::eMIN_DISTANCE_ENABLED ) }, { "eSPRING_ENABLED", static_cast<PxU32>( physx::PxDistanceJointFlag::eSPRING_ENABLED ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxDistanceJointFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxDistanceJointFlag__EnumConversion ) {} const PxU32ToName* NameConversion; }; class PxDistanceJoint; struct PxDistanceJointGeneratedValues : PxJointGeneratedValues { PxReal Distance; PxReal MinDistance; PxReal MaxDistance; PxReal Tolerance; PxReal Stiffness; PxReal Damping; PxDistanceJointFlags DistanceJointFlags; const char * ConcreteTypeName; PxDistanceJointGeneratedValues( const PxDistanceJoint* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxDistanceJoint, Distance, PxDistanceJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxDistanceJoint, MinDistance, PxDistanceJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxDistanceJoint, MaxDistance, PxDistanceJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxDistanceJoint, Tolerance, PxDistanceJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxDistanceJoint, Stiffness, PxDistanceJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxDistanceJoint, Damping, PxDistanceJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxDistanceJoint, DistanceJointFlags, PxDistanceJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxDistanceJoint, ConcreteTypeName, PxDistanceJointGeneratedValues) struct PxDistanceJointGeneratedInfo : PxJointGeneratedInfo { static const char* getClassName() { return "PxDistanceJoint"; } PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxDistanceJoint_Distance, PxDistanceJoint, PxReal > Distance; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxDistanceJoint_MinDistance, PxDistanceJoint, PxReal, PxReal > MinDistance; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxDistanceJoint_MaxDistance, PxDistanceJoint, PxReal, PxReal > MaxDistance; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxDistanceJoint_Tolerance, PxDistanceJoint, PxReal, PxReal > Tolerance; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxDistanceJoint_Stiffness, PxDistanceJoint, PxReal, PxReal > Stiffness; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxDistanceJoint_Damping, PxDistanceJoint, PxReal, PxReal > Damping; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxDistanceJoint_DistanceJointFlags, PxDistanceJoint, PxDistanceJointFlags, PxDistanceJointFlags > DistanceJointFlags; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxDistanceJoint_ConcreteTypeName, PxDistanceJoint, const char * > ConcreteTypeName; PxDistanceJointGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxDistanceJoint*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxJointGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxJointGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxJointGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 8; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxJointGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( Distance, inStartIndex + 0 );; inOperator( MinDistance, inStartIndex + 1 );; inOperator( MaxDistance, inStartIndex + 2 );; inOperator( Tolerance, inStartIndex + 3 );; inOperator( Stiffness, inStartIndex + 4 );; inOperator( Damping, inStartIndex + 5 );; inOperator( DistanceJointFlags, inStartIndex + 6 );; inOperator( ConcreteTypeName, inStartIndex + 7 );; return 8 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxDistanceJoint> { PxDistanceJointGeneratedInfo Info; const PxDistanceJointGeneratedInfo* getInfo() { return &Info; } }; class PxContactJoint; struct PxContactJointGeneratedValues : PxJointGeneratedValues { PxVec3 Contact; PxVec3 ContactNormal; PxReal Penetration; PxReal Restitution; PxReal BounceThreshold; const char * ConcreteTypeName; PxContactJointGeneratedValues( const PxContactJoint* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxContactJoint, Contact, PxContactJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxContactJoint, ContactNormal, PxContactJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxContactJoint, Penetration, PxContactJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxContactJoint, Restitution, PxContactJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxContactJoint, BounceThreshold, PxContactJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxContactJoint, ConcreteTypeName, PxContactJointGeneratedValues) struct PxContactJointGeneratedInfo : PxJointGeneratedInfo { static const char* getClassName() { return "PxContactJoint"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxContactJoint_Contact, PxContactJoint, const PxVec3 &, PxVec3 > Contact; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxContactJoint_ContactNormal, PxContactJoint, const PxVec3 &, PxVec3 > ContactNormal; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxContactJoint_Penetration, PxContactJoint, const PxReal, PxReal > Penetration; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxContactJoint_Restitution, PxContactJoint, const PxReal, PxReal > Restitution; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxContactJoint_BounceThreshold, PxContactJoint, const PxReal, PxReal > BounceThreshold; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxContactJoint_ConcreteTypeName, PxContactJoint, const char * > ConcreteTypeName; PxContactJointGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxContactJoint*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxJointGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxJointGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxJointGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 6; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxJointGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( Contact, inStartIndex + 0 );; inOperator( ContactNormal, inStartIndex + 1 );; inOperator( Penetration, inStartIndex + 2 );; inOperator( Restitution, inStartIndex + 3 );; inOperator( BounceThreshold, inStartIndex + 4 );; inOperator( ConcreteTypeName, inStartIndex + 5 );; return 6 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxContactJoint> { PxContactJointGeneratedInfo Info; const PxContactJointGeneratedInfo* getInfo() { return &Info; } }; class PxFixedJoint; struct PxFixedJointGeneratedValues : PxJointGeneratedValues { const char * ConcreteTypeName; PxFixedJointGeneratedValues( const PxFixedJoint* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxFixedJoint, ConcreteTypeName, PxFixedJointGeneratedValues) struct PxFixedJointGeneratedInfo : PxJointGeneratedInfo { static const char* getClassName() { return "PxFixedJoint"; } PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxFixedJoint_ConcreteTypeName, PxFixedJoint, const char * > ConcreteTypeName; PxFixedJointGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxFixedJoint*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxJointGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxJointGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxJointGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 1; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxJointGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( ConcreteTypeName, inStartIndex + 0 );; return 1 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxFixedJoint> { PxFixedJointGeneratedInfo Info; const PxFixedJointGeneratedInfo* getInfo() { return &Info; } }; static PxU32ToName g_physx__PxPrismaticJointFlag__EnumConversion[] = { { "eLIMIT_ENABLED", static_cast<PxU32>( physx::PxPrismaticJointFlag::eLIMIT_ENABLED ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxPrismaticJointFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxPrismaticJointFlag__EnumConversion ) {} const PxU32ToName* NameConversion; }; class PxPrismaticJoint; struct PxPrismaticJointGeneratedValues : PxJointGeneratedValues { PxReal Position; PxReal Velocity; PxJointLinearLimitPair Limit; PxPrismaticJointFlags PrismaticJointFlags; const char * ConcreteTypeName; PxPrismaticJointGeneratedValues( const PxPrismaticJoint* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPrismaticJoint, Position, PxPrismaticJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPrismaticJoint, Velocity, PxPrismaticJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPrismaticJoint, Limit, PxPrismaticJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPrismaticJoint, PrismaticJointFlags, PxPrismaticJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPrismaticJoint, ConcreteTypeName, PxPrismaticJointGeneratedValues) struct PxPrismaticJointGeneratedInfo : PxJointGeneratedInfo { static const char* getClassName() { return "PxPrismaticJoint"; } PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxPrismaticJoint_Position, PxPrismaticJoint, PxReal > Position; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxPrismaticJoint_Velocity, PxPrismaticJoint, PxReal > Velocity; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxPrismaticJoint_Limit, PxPrismaticJoint, const PxJointLinearLimitPair &, PxJointLinearLimitPair > Limit; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxPrismaticJoint_PrismaticJointFlags, PxPrismaticJoint, PxPrismaticJointFlags, PxPrismaticJointFlags > PrismaticJointFlags; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxPrismaticJoint_ConcreteTypeName, PxPrismaticJoint, const char * > ConcreteTypeName; PxPrismaticJointGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxPrismaticJoint*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxJointGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxJointGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxJointGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 5; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxJointGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( Position, inStartIndex + 0 );; inOperator( Velocity, inStartIndex + 1 );; inOperator( Limit, inStartIndex + 2 );; inOperator( PrismaticJointFlags, inStartIndex + 3 );; inOperator( ConcreteTypeName, inStartIndex + 4 );; return 5 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxPrismaticJoint> { PxPrismaticJointGeneratedInfo Info; const PxPrismaticJointGeneratedInfo* getInfo() { return &Info; } }; static PxU32ToName g_physx__PxRevoluteJointFlag__EnumConversion[] = { { "eLIMIT_ENABLED", static_cast<PxU32>( physx::PxRevoluteJointFlag::eLIMIT_ENABLED ) }, { "eDRIVE_ENABLED", static_cast<PxU32>( physx::PxRevoluteJointFlag::eDRIVE_ENABLED ) }, { "eDRIVE_FREESPIN", static_cast<PxU32>( physx::PxRevoluteJointFlag::eDRIVE_FREESPIN ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxRevoluteJointFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxRevoluteJointFlag__EnumConversion ) {} const PxU32ToName* NameConversion; }; class PxRevoluteJoint; struct PxRevoluteJointGeneratedValues : PxJointGeneratedValues { PxReal Angle; PxReal Velocity; PxJointAngularLimitPair Limit; PxReal DriveVelocity; PxReal DriveForceLimit; PxReal DriveGearRatio; PxRevoluteJointFlags RevoluteJointFlags; const char * ConcreteTypeName; PxRevoluteJointGeneratedValues( const PxRevoluteJoint* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRevoluteJoint, Angle, PxRevoluteJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRevoluteJoint, Velocity, PxRevoluteJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRevoluteJoint, Limit, PxRevoluteJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRevoluteJoint, DriveVelocity, PxRevoluteJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRevoluteJoint, DriveForceLimit, PxRevoluteJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRevoluteJoint, DriveGearRatio, PxRevoluteJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRevoluteJoint, RevoluteJointFlags, PxRevoluteJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRevoluteJoint, ConcreteTypeName, PxRevoluteJointGeneratedValues) struct PxRevoluteJointGeneratedInfo : PxJointGeneratedInfo { static const char* getClassName() { return "PxRevoluteJoint"; } PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxRevoluteJoint_Angle, PxRevoluteJoint, PxReal > Angle; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxRevoluteJoint_Velocity, PxRevoluteJoint, PxReal > Velocity; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRevoluteJoint_Limit, PxRevoluteJoint, const PxJointAngularLimitPair &, PxJointAngularLimitPair > Limit; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRevoluteJoint_DriveVelocity, PxRevoluteJoint, PxReal, PxReal > DriveVelocity; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRevoluteJoint_DriveForceLimit, PxRevoluteJoint, PxReal, PxReal > DriveForceLimit; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRevoluteJoint_DriveGearRatio, PxRevoluteJoint, PxReal, PxReal > DriveGearRatio; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRevoluteJoint_RevoluteJointFlags, PxRevoluteJoint, PxRevoluteJointFlags, PxRevoluteJointFlags > RevoluteJointFlags; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxRevoluteJoint_ConcreteTypeName, PxRevoluteJoint, const char * > ConcreteTypeName; PxRevoluteJointGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxRevoluteJoint*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxJointGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxJointGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxJointGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 8; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxJointGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( Angle, inStartIndex + 0 );; inOperator( Velocity, inStartIndex + 1 );; inOperator( Limit, inStartIndex + 2 );; inOperator( DriveVelocity, inStartIndex + 3 );; inOperator( DriveForceLimit, inStartIndex + 4 );; inOperator( DriveGearRatio, inStartIndex + 5 );; inOperator( RevoluteJointFlags, inStartIndex + 6 );; inOperator( ConcreteTypeName, inStartIndex + 7 );; return 8 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxRevoluteJoint> { PxRevoluteJointGeneratedInfo Info; const PxRevoluteJointGeneratedInfo* getInfo() { return &Info; } }; static PxU32ToName g_physx__PxSphericalJointFlag__EnumConversion[] = { { "eLIMIT_ENABLED", static_cast<PxU32>( physx::PxSphericalJointFlag::eLIMIT_ENABLED ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxSphericalJointFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxSphericalJointFlag__EnumConversion ) {} const PxU32ToName* NameConversion; }; class PxSphericalJoint; struct PxSphericalJointGeneratedValues : PxJointGeneratedValues { PxJointLimitCone LimitCone; PxReal SwingYAngle; PxReal SwingZAngle; PxSphericalJointFlags SphericalJointFlags; const char * ConcreteTypeName; PxSphericalJointGeneratedValues( const PxSphericalJoint* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSphericalJoint, LimitCone, PxSphericalJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSphericalJoint, SwingYAngle, PxSphericalJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSphericalJoint, SwingZAngle, PxSphericalJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSphericalJoint, SphericalJointFlags, PxSphericalJointGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSphericalJoint, ConcreteTypeName, PxSphericalJointGeneratedValues) struct PxSphericalJointGeneratedInfo : PxJointGeneratedInfo { static const char* getClassName() { return "PxSphericalJoint"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSphericalJoint_LimitCone, PxSphericalJoint, const PxJointLimitCone &, PxJointLimitCone > LimitCone; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxSphericalJoint_SwingYAngle, PxSphericalJoint, PxReal > SwingYAngle; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxSphericalJoint_SwingZAngle, PxSphericalJoint, PxReal > SwingZAngle; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSphericalJoint_SphericalJointFlags, PxSphericalJoint, PxSphericalJointFlags, PxSphericalJointFlags > SphericalJointFlags; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxSphericalJoint_ConcreteTypeName, PxSphericalJoint, const char * > ConcreteTypeName; PxSphericalJointGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxSphericalJoint*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxJointGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxJointGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxJointGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 5; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxJointGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( LimitCone, inStartIndex + 0 );; inOperator( SwingYAngle, inStartIndex + 1 );; inOperator( SwingZAngle, inStartIndex + 2 );; inOperator( SphericalJointFlags, inStartIndex + 3 );; inOperator( ConcreteTypeName, inStartIndex + 4 );; return 5 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxSphericalJoint> { PxSphericalJointGeneratedInfo Info; const PxSphericalJointGeneratedInfo* getInfo() { return &Info; } }; class PxJointLimitParameters; struct PxJointLimitParametersGeneratedValues { PxReal Restitution; PxReal BounceThreshold; PxReal Stiffness; PxReal Damping; PxJointLimitParametersGeneratedValues( const PxJointLimitParameters* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJointLimitParameters, Restitution, PxJointLimitParametersGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJointLimitParameters, BounceThreshold, PxJointLimitParametersGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJointLimitParameters, Stiffness, PxJointLimitParametersGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJointLimitParameters, Damping, PxJointLimitParametersGeneratedValues) struct PxJointLimitParametersGeneratedInfo { static const char* getClassName() { return "PxJointLimitParameters"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJointLimitParameters_Restitution, PxJointLimitParameters, PxReal, PxReal > Restitution; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJointLimitParameters_BounceThreshold, PxJointLimitParameters, PxReal, PxReal > BounceThreshold; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJointLimitParameters_Stiffness, PxJointLimitParameters, PxReal, PxReal > Stiffness; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJointLimitParameters_Damping, PxJointLimitParameters, PxReal, PxReal > Damping; PxJointLimitParametersGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxJointLimitParameters*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); return inStartIndex; } static PxU32 instancePropertyCount() { return 4; } static PxU32 totalPropertyCount() { return instancePropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( Restitution, inStartIndex + 0 );; inOperator( BounceThreshold, inStartIndex + 1 );; inOperator( Stiffness, inStartIndex + 2 );; inOperator( Damping, inStartIndex + 3 );; return 4 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxJointLimitParameters> { PxJointLimitParametersGeneratedInfo Info; const PxJointLimitParametersGeneratedInfo* getInfo() { return &Info; } }; class PxJointLinearLimit; struct PxJointLinearLimitGeneratedValues : PxJointLimitParametersGeneratedValues { PxReal Value; PxJointLinearLimitGeneratedValues( const PxJointLinearLimit* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJointLinearLimit, Value, PxJointLinearLimitGeneratedValues) struct PxJointLinearLimitGeneratedInfo : PxJointLimitParametersGeneratedInfo { static const char* getClassName() { return "PxJointLinearLimit"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJointLinearLimit_Value, PxJointLinearLimit, PxReal, PxReal > Value; PxJointLinearLimitGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxJointLinearLimit*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxJointLimitParametersGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxJointLimitParametersGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxJointLimitParametersGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 1; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxJointLimitParametersGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( Value, inStartIndex + 0 );; return 1 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxJointLinearLimit> { PxJointLinearLimitGeneratedInfo Info; const PxJointLinearLimitGeneratedInfo* getInfo() { return &Info; } }; class PxJointLinearLimitPair; struct PxJointLinearLimitPairGeneratedValues : PxJointLimitParametersGeneratedValues { PxReal Upper; PxReal Lower; PxJointLinearLimitPairGeneratedValues( const PxJointLinearLimitPair* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJointLinearLimitPair, Upper, PxJointLinearLimitPairGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJointLinearLimitPair, Lower, PxJointLinearLimitPairGeneratedValues) struct PxJointLinearLimitPairGeneratedInfo : PxJointLimitParametersGeneratedInfo { static const char* getClassName() { return "PxJointLinearLimitPair"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJointLinearLimitPair_Upper, PxJointLinearLimitPair, PxReal, PxReal > Upper; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJointLinearLimitPair_Lower, PxJointLinearLimitPair, PxReal, PxReal > Lower; PxJointLinearLimitPairGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxJointLinearLimitPair*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxJointLimitParametersGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxJointLimitParametersGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxJointLimitParametersGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 2; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxJointLimitParametersGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( Upper, inStartIndex + 0 );; inOperator( Lower, inStartIndex + 1 );; return 2 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxJointLinearLimitPair> { PxJointLinearLimitPairGeneratedInfo Info; const PxJointLinearLimitPairGeneratedInfo* getInfo() { return &Info; } }; class PxJointAngularLimitPair; struct PxJointAngularLimitPairGeneratedValues : PxJointLimitParametersGeneratedValues { PxReal Upper; PxReal Lower; PxJointAngularLimitPairGeneratedValues( const PxJointAngularLimitPair* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJointAngularLimitPair, Upper, PxJointAngularLimitPairGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJointAngularLimitPair, Lower, PxJointAngularLimitPairGeneratedValues) struct PxJointAngularLimitPairGeneratedInfo : PxJointLimitParametersGeneratedInfo { static const char* getClassName() { return "PxJointAngularLimitPair"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJointAngularLimitPair_Upper, PxJointAngularLimitPair, PxReal, PxReal > Upper; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJointAngularLimitPair_Lower, PxJointAngularLimitPair, PxReal, PxReal > Lower; PxJointAngularLimitPairGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxJointAngularLimitPair*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxJointLimitParametersGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxJointLimitParametersGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxJointLimitParametersGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 2; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxJointLimitParametersGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( Upper, inStartIndex + 0 );; inOperator( Lower, inStartIndex + 1 );; return 2 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxJointAngularLimitPair> { PxJointAngularLimitPairGeneratedInfo Info; const PxJointAngularLimitPairGeneratedInfo* getInfo() { return &Info; } }; class PxJointLimitCone; struct PxJointLimitConeGeneratedValues : PxJointLimitParametersGeneratedValues { PxReal YAngle; PxReal ZAngle; PxJointLimitConeGeneratedValues( const PxJointLimitCone* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJointLimitCone, YAngle, PxJointLimitConeGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJointLimitCone, ZAngle, PxJointLimitConeGeneratedValues) struct PxJointLimitConeGeneratedInfo : PxJointLimitParametersGeneratedInfo { static const char* getClassName() { return "PxJointLimitCone"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJointLimitCone_YAngle, PxJointLimitCone, PxReal, PxReal > YAngle; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJointLimitCone_ZAngle, PxJointLimitCone, PxReal, PxReal > ZAngle; PxJointLimitConeGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxJointLimitCone*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxJointLimitParametersGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxJointLimitParametersGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxJointLimitParametersGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 2; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxJointLimitParametersGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( YAngle, inStartIndex + 0 );; inOperator( ZAngle, inStartIndex + 1 );; return 2 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxJointLimitCone> { PxJointLimitConeGeneratedInfo Info; const PxJointLimitConeGeneratedInfo* getInfo() { return &Info; } }; class PxJointLimitPyramid; struct PxJointLimitPyramidGeneratedValues : PxJointLimitParametersGeneratedValues { PxReal YAngleMin; PxReal YAngleMax; PxReal ZAngleMin; PxReal ZAngleMax; PxJointLimitPyramidGeneratedValues( const PxJointLimitPyramid* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJointLimitPyramid, YAngleMin, PxJointLimitPyramidGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJointLimitPyramid, YAngleMax, PxJointLimitPyramidGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJointLimitPyramid, ZAngleMin, PxJointLimitPyramidGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxJointLimitPyramid, ZAngleMax, PxJointLimitPyramidGeneratedValues) struct PxJointLimitPyramidGeneratedInfo : PxJointLimitParametersGeneratedInfo { static const char* getClassName() { return "PxJointLimitPyramid"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJointLimitPyramid_YAngleMin, PxJointLimitPyramid, PxReal, PxReal > YAngleMin; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJointLimitPyramid_YAngleMax, PxJointLimitPyramid, PxReal, PxReal > YAngleMax; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJointLimitPyramid_ZAngleMin, PxJointLimitPyramid, PxReal, PxReal > ZAngleMin; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxJointLimitPyramid_ZAngleMax, PxJointLimitPyramid, PxReal, PxReal > ZAngleMax; PxJointLimitPyramidGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxJointLimitPyramid*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxJointLimitParametersGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxJointLimitParametersGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxJointLimitParametersGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 4; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxJointLimitParametersGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( YAngleMin, inStartIndex + 0 );; inOperator( YAngleMax, inStartIndex + 1 );; inOperator( ZAngleMin, inStartIndex + 2 );; inOperator( ZAngleMax, inStartIndex + 3 );; return 4 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxJointLimitPyramid> { PxJointLimitPyramidGeneratedInfo Info; const PxJointLimitPyramidGeneratedInfo* getInfo() { return &Info; } }; class PxSpring; struct PxSpringGeneratedValues { PxReal Stiffness; PxReal Damping; PxSpringGeneratedValues( const PxSpring* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSpring, Stiffness, PxSpringGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSpring, Damping, PxSpringGeneratedValues) struct PxSpringGeneratedInfo { static const char* getClassName() { return "PxSpring"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSpring_Stiffness, PxSpring, PxReal, PxReal > Stiffness; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSpring_Damping, PxSpring, PxReal, PxReal > Damping; PxSpringGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxSpring*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); return inStartIndex; } static PxU32 instancePropertyCount() { return 2; } static PxU32 totalPropertyCount() { return instancePropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( Stiffness, inStartIndex + 0 );; inOperator( Damping, inStartIndex + 1 );; return 2 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxSpring> { PxSpringGeneratedInfo Info; const PxSpringGeneratedInfo* getInfo() { return &Info; } }; static PxU32ToName g_physx__PxD6JointDriveFlag__EnumConversion[] = { { "eACCELERATION", static_cast<PxU32>( physx::PxD6JointDriveFlag::eACCELERATION ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxD6JointDriveFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxD6JointDriveFlag__EnumConversion ) {} const PxU32ToName* NameConversion; }; class PxD6JointDrive; struct PxD6JointDriveGeneratedValues : PxSpringGeneratedValues { PxReal ForceLimit; PxD6JointDriveFlags Flags; PxD6JointDriveGeneratedValues( const PxD6JointDrive* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxD6JointDrive, ForceLimit, PxD6JointDriveGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxD6JointDrive, Flags, PxD6JointDriveGeneratedValues) struct PxD6JointDriveGeneratedInfo : PxSpringGeneratedInfo { static const char* getClassName() { return "PxD6JointDrive"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxD6JointDrive_ForceLimit, PxD6JointDrive, PxReal, PxReal > ForceLimit; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxD6JointDrive_Flags, PxD6JointDrive, PxD6JointDriveFlags, PxD6JointDriveFlags > Flags; PxD6JointDriveGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxD6JointDrive*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxSpringGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxSpringGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxSpringGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 2; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxSpringGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( ForceLimit, inStartIndex + 0 );; inOperator( Flags, inStartIndex + 1 );; return 2 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxD6JointDrive> { PxD6JointDriveGeneratedInfo Info; const PxD6JointDriveGeneratedInfo* getInfo() { return &Info; } }; #undef THERE_IS_NO_INCLUDE_GUARD_HERE_FOR_A_REASON #undef PX_PROPERTY_INFO_NAME
59,955
C
45.08455
192
0.780252
NVIDIA-Omniverse/PhysX/physx/source/physxmetadata/extensions/include/PxExtensionMetaDataObjects.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_EXTENSION_METADATAOBJECTS_H #define PX_EXTENSION_METADATAOBJECTS_H #include "PxPhysicsAPI.h" #include "extensions/PxExtensionsAPI.h" #include "PxMetaDataObjects.h" /** \addtogroup physics @{ */ namespace physx { class PxD6Joint; class PxJointLimitCone; struct PxExtensionsPropertyInfoName { enum Enum { Unnamed = PxPropertyInfoName::LastPxPropertyInfoName, #include "PxExtensionAutoGeneratedMetaDataObjectNames.h" LastPxPropertyInfoName }; }; #define DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( type, prop, valueStruct ) \ template<> struct PxPropertyToValueStructMemberMap< PxExtensionsPropertyInfoName::type##_##prop > \ { \ PxU32 Offset; \ PxPropertyToValueStructMemberMap< PxExtensionsPropertyInfoName::type##_##prop >() : Offset( PX_OFFSET_OF_RT( valueStruct, prop ) ) {} \ template<typename TOperator> void visitProp( TOperator inOperator, valueStruct& inStruct ) { inOperator( inStruct.prop ); } \ }; #if PX_LINUX && PX_CLANG #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wreserved-identifier" #endif #include "PxExtensionAutoGeneratedMetaDataObjects.h" #if PX_LINUX && PX_CLANG #pragma clang diagnostic pop #endif #undef DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP } /** @} */ #endif
3,022
C
37.75641
137
0.742886
NVIDIA-Omniverse/PhysX/physx/source/physxmetadata/extensions/include/PxExtensionAutoGeneratedMetaDataObjectNames.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. // This code is auto-generated by the PhysX Clang metadata generator. Do not edit or be // prepared for your edits to be quietly ignored next time the clang metadata generator is // run. You can find the most recent version of clang metadata generator by contacting // Chris Nuernberger <[email protected]> or Dilip or Adam. // The source code for the generate was at one time checked into: // physx/PhysXMetaDataGenerator/llvm/tools/clang/lib/Frontend/PhysXMetaDataAction.cpp #define THERE_IS_NO_INCLUDE_GUARD_HERE_FOR_A_REASON PxJoint_PropertiesStart, PxJoint_Actors, PxJoint_LocalPose, PxJoint_RelativeTransform, PxJoint_RelativeLinearVelocity, PxJoint_RelativeAngularVelocity, PxJoint_BreakForce, PxJoint_ConstraintFlags, PxJoint_InvMassScale0, PxJoint_InvInertiaScale0, PxJoint_InvMassScale1, PxJoint_InvInertiaScale1, PxJoint_Constraint, PxJoint_Name, PxJoint_Scene, PxJoint_UserData, PxJoint_PropertiesStop, PxRackAndPinionJoint_PropertiesStart, PxRackAndPinionJoint_Ratio, PxRackAndPinionJoint_ConcreteTypeName, PxRackAndPinionJoint_PropertiesStop, PxGearJoint_PropertiesStart, PxGearJoint_GearRatio, PxGearJoint_ConcreteTypeName, PxGearJoint_PropertiesStop, PxD6Joint_PropertiesStart, PxD6Joint_Motion, PxD6Joint_TwistAngle, PxD6Joint_Twist, PxD6Joint_SwingYAngle, PxD6Joint_SwingZAngle, PxD6Joint_DistanceLimit, PxD6Joint_LinearLimit, PxD6Joint_TwistLimit, PxD6Joint_SwingLimit, PxD6Joint_PyramidSwingLimit, PxD6Joint_Drive, PxD6Joint_DrivePosition, PxD6Joint_ConcreteTypeName, PxD6Joint_PropertiesStop, PxDistanceJoint_PropertiesStart, PxDistanceJoint_Distance, PxDistanceJoint_MinDistance, PxDistanceJoint_MaxDistance, PxDistanceJoint_Tolerance, PxDistanceJoint_Stiffness, PxDistanceJoint_Damping, PxDistanceJoint_DistanceJointFlags, PxDistanceJoint_ConcreteTypeName, PxDistanceJoint_PropertiesStop, PxContactJoint_PropertiesStart, PxContactJoint_Contact, PxContactJoint_ContactNormal, PxContactJoint_Penetration, PxContactJoint_Restitution, PxContactJoint_BounceThreshold, PxContactJoint_ConcreteTypeName, PxContactJoint_PropertiesStop, PxFixedJoint_PropertiesStart, PxFixedJoint_ConcreteTypeName, PxFixedJoint_PropertiesStop, PxPrismaticJoint_PropertiesStart, PxPrismaticJoint_Position, PxPrismaticJoint_Velocity, PxPrismaticJoint_Limit, PxPrismaticJoint_PrismaticJointFlags, PxPrismaticJoint_ConcreteTypeName, PxPrismaticJoint_PropertiesStop, PxRevoluteJoint_PropertiesStart, PxRevoluteJoint_Angle, PxRevoluteJoint_Velocity, PxRevoluteJoint_Limit, PxRevoluteJoint_DriveVelocity, PxRevoluteJoint_DriveForceLimit, PxRevoluteJoint_DriveGearRatio, PxRevoluteJoint_RevoluteJointFlags, PxRevoluteJoint_ConcreteTypeName, PxRevoluteJoint_PropertiesStop, PxSphericalJoint_PropertiesStart, PxSphericalJoint_LimitCone, PxSphericalJoint_SwingYAngle, PxSphericalJoint_SwingZAngle, PxSphericalJoint_SphericalJointFlags, PxSphericalJoint_ConcreteTypeName, PxSphericalJoint_PropertiesStop, PxJointLimitParameters_PropertiesStart, PxJointLimitParameters_Restitution, PxJointLimitParameters_BounceThreshold, PxJointLimitParameters_Stiffness, PxJointLimitParameters_Damping, PxJointLimitParameters_PropertiesStop, PxJointLinearLimit_PropertiesStart, PxJointLinearLimit_Value, PxJointLinearLimit_PropertiesStop, PxJointLinearLimitPair_PropertiesStart, PxJointLinearLimitPair_Upper, PxJointLinearLimitPair_Lower, PxJointLinearLimitPair_PropertiesStop, PxJointAngularLimitPair_PropertiesStart, PxJointAngularLimitPair_Upper, PxJointAngularLimitPair_Lower, PxJointAngularLimitPair_PropertiesStop, PxJointLimitCone_PropertiesStart, PxJointLimitCone_YAngle, PxJointLimitCone_ZAngle, PxJointLimitCone_PropertiesStop, PxJointLimitPyramid_PropertiesStart, PxJointLimitPyramid_YAngleMin, PxJointLimitPyramid_YAngleMax, PxJointLimitPyramid_ZAngleMin, PxJointLimitPyramid_ZAngleMax, PxJointLimitPyramid_PropertiesStop, PxSpring_PropertiesStart, PxSpring_Stiffness, PxSpring_Damping, PxSpring_PropertiesStop, PxD6JointDrive_PropertiesStart, PxD6JointDrive_ForceLimit, PxD6JointDrive_Flags, PxD6JointDrive_PropertiesStop, #undef THERE_IS_NO_INCLUDE_GUARD_HERE_FOR_A_REASON
5,756
C
34.98125
90
0.846942
NVIDIA-Omniverse/PhysX/physx/source/physxmetadata/core/src/PxMetaDataObjects.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #include "foundation/PxUtilities.h" #include "foundation/PxFoundation.h" #include "foundation/PxErrors.h" #include "PxMetaDataObjects.h" using namespace physx; namespace { template<class T> PX_FORCE_INLINE bool getGeometryT(PxGeometryType::Enum type, const PxShape* inShape, T& geom) { const PxGeometry& inGeometry = inShape->getGeometry(); if(inShape == NULL || inGeometry.getType() != type) return false; geom = static_cast<const T&>(inGeometry); return true; } } PX_PHYSX_CORE_API PxGeometryType::Enum PxShapeGeomPropertyHelper::getGeometryType(const PxShape* inShape) const { return inShape->getGeometry().getType(); } PX_PHYSX_CORE_API bool PxShapeGeomPropertyHelper::getGeometry(const PxShape* inShape, PxBoxGeometry& geometry) const { return getGeometryT(PxGeometryType::eBOX, inShape, geometry); } PX_PHYSX_CORE_API bool PxShapeGeomPropertyHelper::getGeometry(const PxShape* inShape, PxSphereGeometry& geometry) const { return getGeometryT(PxGeometryType::eSPHERE, inShape, geometry); } PX_PHYSX_CORE_API bool PxShapeGeomPropertyHelper::getGeometry(const PxShape* inShape, PxCapsuleGeometry& geometry) const { return getGeometryT(PxGeometryType::eCAPSULE, inShape, geometry); } PX_PHYSX_CORE_API bool PxShapeGeomPropertyHelper::getGeometry(const PxShape* inShape, PxPlaneGeometry& geometry) const { return getGeometryT(PxGeometryType::ePLANE, inShape, geometry); } PX_PHYSX_CORE_API bool PxShapeGeomPropertyHelper::getGeometry(const PxShape* inShape, PxConvexMeshGeometry& geometry) const { return getGeometryT(PxGeometryType::eCONVEXMESH, inShape, geometry); } PX_PHYSX_CORE_API bool PxShapeGeomPropertyHelper::getGeometry(const PxShape* inShape, PxTetrahedronMeshGeometry& geometry) const { return getGeometryT(PxGeometryType::eTETRAHEDRONMESH, inShape, geometry); } PX_PHYSX_CORE_API bool PxShapeGeomPropertyHelper::getGeometry(const PxShape* inShape, PxParticleSystemGeometry& geometry) const { return getGeometryT(PxGeometryType::ePARTICLESYSTEM, inShape, geometry); } PX_PHYSX_CORE_API bool PxShapeGeomPropertyHelper::getGeometry(const PxShape* inShape, PxTriangleMeshGeometry& geometry) const { return getGeometryT(PxGeometryType::eTRIANGLEMESH, inShape, geometry); } PX_PHYSX_CORE_API bool PxShapeGeomPropertyHelper::getGeometry(const PxShape* inShape, PxHeightFieldGeometry& geometry) const { return getGeometryT(PxGeometryType::eHEIGHTFIELD, inShape, geometry); } PX_PHYSX_CORE_API void PxShapeMaterialsPropertyHelper::setMaterials(PxShape* inShape, PxMaterial*const* materials, PxU16 materialCount) const { inShape->setMaterials( materials, materialCount ); } PX_PHYSX_CORE_API PxShape* PxRigidActorShapeCollectionHelper::createShape(PxRigidActor* inActor, const PxGeometry& geometry, PxMaterial& material, PxShapeFlags shapeFlags ) const { PxMaterial* materialPtr = const_cast<PxMaterial*>(&material); PxShape* shape = PxGetPhysics().createShape(geometry, &materialPtr, 1, true, shapeFlags); if (shape) { inActor->attachShape(*shape); // attach can fail, if e.g. we try and attach a trimesh simulation shape to a dynamic actor shape->release(); // if attach fails, we hold the only counted reference, and so this cleans up properly } return shape; } PX_PHYSX_CORE_API PxShape* PxRigidActorShapeCollectionHelper::createShape(PxRigidActor* inActor, const PxGeometry& geometry, PxMaterial *const* materials, PxU16 materialCount, PxShapeFlags shapeFlags ) const { PxShape* shape = PxGetPhysics().createShape(geometry, materials, materialCount, true, shapeFlags); if (shape) { inActor->attachShape(*shape); // attach can fail, if e.g. we try and attach a trimesh simulation shape to a dynamic actor shape->release(); // if attach fails, we hold the only counted reference, and so this cleans up properly } return shape; } PX_PHYSX_CORE_API PxArticulationLink* PxArticulationReducedCoordinateLinkCollectionPropHelper::createLink(PxArticulationReducedCoordinate* inArticulation, PxArticulationLink* parent, const PxTransform& pose) const { PX_CHECK_AND_RETURN_NULL(pose.isValid(), "PxArticulationReducedCoordinateLinkCollectionPropHelper::createLink pose is not valid."); return inArticulation->createLink(parent, pose ); } inline void SetNbShape( PxSimulationStatistics* inStats, PxGeometryType::Enum data, PxU32 val ) { inStats->nbShapes[data] = val; } inline PxU32 GetNbShape( const PxSimulationStatistics* inStats, PxGeometryType::Enum data) { return inStats->nbShapes[data]; } PX_PHYSX_CORE_API NbShapesProperty::NbShapesProperty() : PxIndexedPropertyInfo<PxPropertyInfoName::PxSimulationStatistics_NbShapes , PxSimulationStatistics , PxGeometryType::Enum , PxU32> ( "NbShapes", SetNbShape, GetNbShape ) { } inline void SetNbDiscreteContactPairs( PxSimulationStatistics* inStats, PxGeometryType::Enum idx1, PxGeometryType::Enum idx2, PxU32 val ) { inStats->nbDiscreteContactPairs[idx1][idx2] = val; } inline PxU32 GetNbDiscreteContactPairs( const PxSimulationStatistics* inStats, PxGeometryType::Enum idx1, PxGeometryType::Enum idx2 ) { return inStats->nbDiscreteContactPairs[idx1][idx2]; } PX_PHYSX_CORE_API NbDiscreteContactPairsProperty::NbDiscreteContactPairsProperty() : PxDualIndexedPropertyInfo<PxPropertyInfoName::PxSimulationStatistics_NbDiscreteContactPairs , PxSimulationStatistics , PxGeometryType::Enum , PxGeometryType::Enum , PxU32> ( "NbDiscreteContactPairs", SetNbDiscreteContactPairs, GetNbDiscreteContactPairs ) { } inline void SetNbModifiedContactPairs( PxSimulationStatistics* inStats, PxGeometryType::Enum idx1, PxGeometryType::Enum idx2, PxU32 val ) { inStats->nbModifiedContactPairs[idx1][idx2] = val; } inline PxU32 GetNbModifiedContactPairs( const PxSimulationStatistics* inStats, PxGeometryType::Enum idx1, PxGeometryType::Enum idx2 ) { return inStats->nbModifiedContactPairs[idx1][idx2]; } PX_PHYSX_CORE_API NbModifiedContactPairsProperty::NbModifiedContactPairsProperty() : PxDualIndexedPropertyInfo<PxPropertyInfoName::PxSimulationStatistics_NbModifiedContactPairs , PxSimulationStatistics , PxGeometryType::Enum , PxGeometryType::Enum , PxU32> ( "NbModifiedContactPairs", SetNbModifiedContactPairs, GetNbModifiedContactPairs ) { } inline void SetNbCCDPairs( PxSimulationStatistics* inStats, PxGeometryType::Enum idx1, PxGeometryType::Enum idx2, PxU32 val ) { inStats->nbCCDPairs[idx1][idx2] = val; } inline PxU32 GetNbCCDPairs( const PxSimulationStatistics* inStats, PxGeometryType::Enum idx1, PxGeometryType::Enum idx2 ) { return inStats->nbCCDPairs[idx1][idx2]; } PX_PHYSX_CORE_API NbCCDPairsProperty::NbCCDPairsProperty() : PxDualIndexedPropertyInfo<PxPropertyInfoName::PxSimulationStatistics_NbCCDPairs , PxSimulationStatistics , PxGeometryType::Enum , PxGeometryType::Enum , PxU32> ( "NbCCDPairs", SetNbCCDPairs, GetNbCCDPairs ) { } inline void SetNbTriggerPairs( PxSimulationStatistics* inStats, PxGeometryType::Enum idx1, PxGeometryType::Enum idx2, PxU32 val ) { inStats->nbTriggerPairs[idx1][idx2] = val; } inline PxU32 GetNbTriggerPairs( const PxSimulationStatistics* inStats, PxGeometryType::Enum idx1, PxGeometryType::Enum idx2 ) { return inStats->nbTriggerPairs[idx1][idx2]; } PX_PHYSX_CORE_API NbTriggerPairsProperty::NbTriggerPairsProperty() : PxDualIndexedPropertyInfo<PxPropertyInfoName::PxSimulationStatistics_NbTriggerPairs , PxSimulationStatistics , PxGeometryType::Enum , PxGeometryType::Enum , PxU32> ( "NbTriggerPairs", SetNbTriggerPairs, GetNbTriggerPairs ) { } inline PxSimulationStatistics GetStats( const PxScene* inScene ) { PxSimulationStatistics stats; inScene->getSimulationStatistics( stats ); return stats; } PX_PHYSX_CORE_API SimulationStatisticsProperty::SimulationStatisticsProperty() : PxReadOnlyPropertyInfo<PxPropertyInfoName::PxScene_SimulationStatistics, PxScene, PxSimulationStatistics >( "SimulationStatistics", GetStats ) { } inline PxU32 GetCustomType(const PxCustomGeometry* inGeom) { PxCustomGeometry::Type t = inGeom->callbacks->getCustomType(); return *reinterpret_cast<const PxU32*>(&t); } PX_PHYSX_CORE_API PxCustomGeometryCustomTypeProperty::PxCustomGeometryCustomTypeProperty() : PxReadOnlyPropertyInfo<PxPropertyInfoName::PxCustomGeometry_CustomType, PxCustomGeometry, PxU32 >("CustomType", GetCustomType) { }
10,195
C++
58.625731
206
0.777146
NVIDIA-Omniverse/PhysX/physx/source/physxmetadata/core/src/PxAutoGeneratedMetaDataObjects.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. // This code is auto-generated by the PhysX Clang metadata generator. Do not edit or be // prepared for your edits to be quietly ignored next time the clang metadata generator is // run. You can find the most recent version of clang metadata generator by contacting // Chris Nuernberger <[email protected]> or Dilip or Adam. // The source code for the generate was at one time checked into: // physx/PhysXMetaDataGenerator/llvm/tools/clang/lib/Frontend/PhysXMetaDataAction.cpp #include "foundation/PxPreprocessor.h" #if PX_LINUX && PX_CLANG #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wreserved-identifier" #endif #include "PxMetaDataObjects.h" #if PX_LINUX && PX_CLANG #pragma clang diagnostic pop #endif #include "PxMetaDataCppPrefix.h" using namespace physx; const PxTolerancesScale getPxPhysics_TolerancesScale( const PxPhysics* inObj ) { return inObj->getTolerancesScale(); } PxU32 getPxPhysics_TriangleMeshes( const PxPhysics* inObj, PxTriangleMesh ** outBuffer, PxU32 inBufSize ) { return inObj->getTriangleMeshes( outBuffer, inBufSize ); } PxU32 getNbPxPhysics_TriangleMeshes( const PxPhysics* inObj ) { return inObj->getNbTriangleMeshes( ); } PxTriangleMesh * createPxPhysics_TriangleMeshes( PxPhysics* inObj, PxInputStream & inCreateParam ){ return inObj->createTriangleMesh( inCreateParam ); } PxU32 getPxPhysics_TetrahedronMeshes( const PxPhysics* inObj, PxTetrahedronMesh ** outBuffer, PxU32 inBufSize ) { return inObj->getTetrahedronMeshes( outBuffer, inBufSize ); } PxU32 getNbPxPhysics_TetrahedronMeshes( const PxPhysics* inObj ) { return inObj->getNbTetrahedronMeshes( ); } PxTetrahedronMesh * createPxPhysics_TetrahedronMeshes( PxPhysics* inObj, PxInputStream & inCreateParam ){ return inObj->createTetrahedronMesh( inCreateParam ); } PxU32 getPxPhysics_HeightFields( const PxPhysics* inObj, PxHeightField ** outBuffer, PxU32 inBufSize ) { return inObj->getHeightFields( outBuffer, inBufSize ); } PxU32 getNbPxPhysics_HeightFields( const PxPhysics* inObj ) { return inObj->getNbHeightFields( ); } PxHeightField * createPxPhysics_HeightFields( PxPhysics* inObj, PxInputStream & inCreateParam ){ return inObj->createHeightField( inCreateParam ); } PxU32 getPxPhysics_ConvexMeshes( const PxPhysics* inObj, PxConvexMesh ** outBuffer, PxU32 inBufSize ) { return inObj->getConvexMeshes( outBuffer, inBufSize ); } PxU32 getNbPxPhysics_ConvexMeshes( const PxPhysics* inObj ) { return inObj->getNbConvexMeshes( ); } PxConvexMesh * createPxPhysics_ConvexMeshes( PxPhysics* inObj, PxInputStream & inCreateParam ){ return inObj->createConvexMesh( inCreateParam ); } PxU32 getPxPhysics_BVHs( const PxPhysics* inObj, PxBVH ** outBuffer, PxU32 inBufSize ) { return inObj->getBVHs( outBuffer, inBufSize ); } PxU32 getNbPxPhysics_BVHs( const PxPhysics* inObj ) { return inObj->getNbBVHs( ); } PxBVH * createPxPhysics_BVHs( PxPhysics* inObj, PxInputStream & inCreateParam ){ return inObj->createBVH( inCreateParam ); } PxU32 getPxPhysics_Scenes( const PxPhysics* inObj, PxScene ** outBuffer, PxU32 inBufSize ) { return inObj->getScenes( outBuffer, inBufSize ); } PxU32 getNbPxPhysics_Scenes( const PxPhysics* inObj ) { return inObj->getNbScenes( ); } PxScene * createPxPhysics_Scenes( PxPhysics* inObj, const PxSceneDesc & inCreateParam ){ return inObj->createScene( inCreateParam ); } PxU32 getPxPhysics_Shapes( const PxPhysics* inObj, PxShape ** outBuffer, PxU32 inBufSize ) { return inObj->getShapes( outBuffer, inBufSize ); } PxU32 getNbPxPhysics_Shapes( const PxPhysics* inObj ) { return inObj->getNbShapes( ); } PxU32 getPxPhysics_Materials( const PxPhysics* inObj, PxMaterial ** outBuffer, PxU32 inBufSize ) { return inObj->getMaterials( outBuffer, inBufSize ); } PxU32 getNbPxPhysics_Materials( const PxPhysics* inObj ) { return inObj->getNbMaterials( ); } PxU32 getPxPhysics_FEMSoftBodyMaterials( const PxPhysics* inObj, PxFEMSoftBodyMaterial ** outBuffer, PxU32 inBufSize ) { return inObj->getFEMSoftBodyMaterials( outBuffer, inBufSize ); } PxU32 getNbPxPhysics_FEMSoftBodyMaterials( const PxPhysics* inObj ) { return inObj->getNbFEMSoftBodyMaterials( ); } PxU32 getPxPhysics_FEMClothMaterials( const PxPhysics* inObj, PxFEMClothMaterial ** outBuffer, PxU32 inBufSize ) { return inObj->getFEMClothMaterials( outBuffer, inBufSize ); } PxU32 getNbPxPhysics_FEMClothMaterials( const PxPhysics* inObj ) { return inObj->getNbFEMClothMaterials( ); } PxU32 getPxPhysics_PBDMaterials( const PxPhysics* inObj, PxPBDMaterial ** outBuffer, PxU32 inBufSize ) { return inObj->getPBDMaterials( outBuffer, inBufSize ); } PxU32 getNbPxPhysics_PBDMaterials( const PxPhysics* inObj ) { return inObj->getNbPBDMaterials( ); } PX_PHYSX_CORE_API PxPhysicsGeneratedInfo::PxPhysicsGeneratedInfo() : TolerancesScale( "TolerancesScale", getPxPhysics_TolerancesScale) , TriangleMeshes( "TriangleMeshes", getPxPhysics_TriangleMeshes, getNbPxPhysics_TriangleMeshes, createPxPhysics_TriangleMeshes ) , TetrahedronMeshes( "TetrahedronMeshes", getPxPhysics_TetrahedronMeshes, getNbPxPhysics_TetrahedronMeshes, createPxPhysics_TetrahedronMeshes ) , HeightFields( "HeightFields", getPxPhysics_HeightFields, getNbPxPhysics_HeightFields, createPxPhysics_HeightFields ) , ConvexMeshes( "ConvexMeshes", getPxPhysics_ConvexMeshes, getNbPxPhysics_ConvexMeshes, createPxPhysics_ConvexMeshes ) , BVHs( "BVHs", getPxPhysics_BVHs, getNbPxPhysics_BVHs, createPxPhysics_BVHs ) , Scenes( "Scenes", getPxPhysics_Scenes, getNbPxPhysics_Scenes, createPxPhysics_Scenes ) , Shapes( "Shapes", getPxPhysics_Shapes, getNbPxPhysics_Shapes ) , Materials( "Materials", getPxPhysics_Materials, getNbPxPhysics_Materials ) , FEMSoftBodyMaterials( "FEMSoftBodyMaterials", getPxPhysics_FEMSoftBodyMaterials, getNbPxPhysics_FEMSoftBodyMaterials ) , FEMClothMaterials( "FEMClothMaterials", getPxPhysics_FEMClothMaterials, getNbPxPhysics_FEMClothMaterials ) , PBDMaterials( "PBDMaterials", getPxPhysics_PBDMaterials, getNbPxPhysics_PBDMaterials ) {} PX_PHYSX_CORE_API PxPhysicsGeneratedValues::PxPhysicsGeneratedValues( const PxPhysics* inSource ) :TolerancesScale( getPxPhysics_TolerancesScale( inSource ) ) { PX_UNUSED(inSource); } PxU32 getPxRefCounted_ReferenceCount( const PxRefCounted* inObj ) { return inObj->getReferenceCount(); } PX_PHYSX_CORE_API PxRefCountedGeneratedInfo::PxRefCountedGeneratedInfo() : ReferenceCount( "ReferenceCount", getPxRefCounted_ReferenceCount) {} PX_PHYSX_CORE_API PxRefCountedGeneratedValues::PxRefCountedGeneratedValues( const PxRefCounted* inSource ) :ReferenceCount( getPxRefCounted_ReferenceCount( inSource ) ) { PX_UNUSED(inSource); } inline void * getPxBaseMaterialUserData( const PxBaseMaterial* inOwner ) { return inOwner->userData; } inline void setPxBaseMaterialUserData( PxBaseMaterial* inOwner, void * inData) { inOwner->userData = inData; } PX_PHYSX_CORE_API PxBaseMaterialGeneratedInfo::PxBaseMaterialGeneratedInfo() : UserData( "UserData", setPxBaseMaterialUserData, getPxBaseMaterialUserData ) {} PX_PHYSX_CORE_API PxBaseMaterialGeneratedValues::PxBaseMaterialGeneratedValues( const PxBaseMaterial* inSource ) :PxRefCountedGeneratedValues( inSource ) ,UserData( inSource->userData ) { PX_UNUSED(inSource); } void setPxMaterial_DynamicFriction( PxMaterial* inObj, PxReal inArg){ inObj->setDynamicFriction( inArg ); } PxReal getPxMaterial_DynamicFriction( const PxMaterial* inObj ) { return inObj->getDynamicFriction(); } void setPxMaterial_StaticFriction( PxMaterial* inObj, PxReal inArg){ inObj->setStaticFriction( inArg ); } PxReal getPxMaterial_StaticFriction( const PxMaterial* inObj ) { return inObj->getStaticFriction(); } void setPxMaterial_Restitution( PxMaterial* inObj, PxReal inArg){ inObj->setRestitution( inArg ); } PxReal getPxMaterial_Restitution( const PxMaterial* inObj ) { return inObj->getRestitution(); } void setPxMaterial_Damping( PxMaterial* inObj, PxReal inArg){ inObj->setDamping( inArg ); } PxReal getPxMaterial_Damping( const PxMaterial* inObj ) { return inObj->getDamping(); } void setPxMaterial_Flags( PxMaterial* inObj, PxMaterialFlags inArg){ inObj->setFlags( inArg ); } PxMaterialFlags getPxMaterial_Flags( const PxMaterial* inObj ) { return inObj->getFlags(); } void setPxMaterial_FrictionCombineMode( PxMaterial* inObj, PxCombineMode::Enum inArg){ inObj->setFrictionCombineMode( inArg ); } PxCombineMode::Enum getPxMaterial_FrictionCombineMode( const PxMaterial* inObj ) { return inObj->getFrictionCombineMode(); } void setPxMaterial_RestitutionCombineMode( PxMaterial* inObj, PxCombineMode::Enum inArg){ inObj->setRestitutionCombineMode( inArg ); } PxCombineMode::Enum getPxMaterial_RestitutionCombineMode( const PxMaterial* inObj ) { return inObj->getRestitutionCombineMode(); } const char * getPxMaterial_ConcreteTypeName( const PxMaterial* inObj ) { return inObj->getConcreteTypeName(); } PX_PHYSX_CORE_API PxMaterialGeneratedInfo::PxMaterialGeneratedInfo() : DynamicFriction( "DynamicFriction", setPxMaterial_DynamicFriction, getPxMaterial_DynamicFriction) , StaticFriction( "StaticFriction", setPxMaterial_StaticFriction, getPxMaterial_StaticFriction) , Restitution( "Restitution", setPxMaterial_Restitution, getPxMaterial_Restitution) , Damping( "Damping", setPxMaterial_Damping, getPxMaterial_Damping) , Flags( "Flags", setPxMaterial_Flags, getPxMaterial_Flags) , FrictionCombineMode( "FrictionCombineMode", setPxMaterial_FrictionCombineMode, getPxMaterial_FrictionCombineMode) , RestitutionCombineMode( "RestitutionCombineMode", setPxMaterial_RestitutionCombineMode, getPxMaterial_RestitutionCombineMode) , ConcreteTypeName( "ConcreteTypeName", getPxMaterial_ConcreteTypeName) {} PX_PHYSX_CORE_API PxMaterialGeneratedValues::PxMaterialGeneratedValues( const PxMaterial* inSource ) :PxBaseMaterialGeneratedValues( inSource ) ,DynamicFriction( getPxMaterial_DynamicFriction( inSource ) ) ,StaticFriction( getPxMaterial_StaticFriction( inSource ) ) ,Restitution( getPxMaterial_Restitution( inSource ) ) ,Damping( getPxMaterial_Damping( inSource ) ) ,Flags( getPxMaterial_Flags( inSource ) ) ,FrictionCombineMode( getPxMaterial_FrictionCombineMode( inSource ) ) ,RestitutionCombineMode( getPxMaterial_RestitutionCombineMode( inSource ) ) ,ConcreteTypeName( getPxMaterial_ConcreteTypeName( inSource ) ) { PX_UNUSED(inSource); } void setPxFEMMaterial_YoungsModulus( PxFEMMaterial* inObj, PxReal inArg){ inObj->setYoungsModulus( inArg ); } PxReal getPxFEMMaterial_YoungsModulus( const PxFEMMaterial* inObj ) { return inObj->getYoungsModulus(); } void setPxFEMMaterial_Poissons( PxFEMMaterial* inObj, PxReal inArg){ inObj->setPoissons( inArg ); } PxReal getPxFEMMaterial_Poissons( const PxFEMMaterial* inObj ) { return inObj->getPoissons(); } void setPxFEMMaterial_DynamicFriction( PxFEMMaterial* inObj, PxReal inArg){ inObj->setDynamicFriction( inArg ); } PxReal getPxFEMMaterial_DynamicFriction( const PxFEMMaterial* inObj ) { return inObj->getDynamicFriction(); } PX_PHYSX_CORE_API PxFEMMaterialGeneratedInfo::PxFEMMaterialGeneratedInfo() : YoungsModulus( "YoungsModulus", setPxFEMMaterial_YoungsModulus, getPxFEMMaterial_YoungsModulus) , Poissons( "Poissons", setPxFEMMaterial_Poissons, getPxFEMMaterial_Poissons) , DynamicFriction( "DynamicFriction", setPxFEMMaterial_DynamicFriction, getPxFEMMaterial_DynamicFriction) {} PX_PHYSX_CORE_API PxFEMMaterialGeneratedValues::PxFEMMaterialGeneratedValues( const PxFEMMaterial* inSource ) :PxBaseMaterialGeneratedValues( inSource ) ,YoungsModulus( getPxFEMMaterial_YoungsModulus( inSource ) ) ,Poissons( getPxFEMMaterial_Poissons( inSource ) ) ,DynamicFriction( getPxFEMMaterial_DynamicFriction( inSource ) ) { PX_UNUSED(inSource); } void setPxFEMSoftBodyMaterial_Damping( PxFEMSoftBodyMaterial* inObj, PxReal inArg){ inObj->setDamping( inArg ); } PxReal getPxFEMSoftBodyMaterial_Damping( const PxFEMSoftBodyMaterial* inObj ) { return inObj->getDamping(); } void setPxFEMSoftBodyMaterial_DampingScale( PxFEMSoftBodyMaterial* inObj, PxReal inArg){ inObj->setDampingScale( inArg ); } PxReal getPxFEMSoftBodyMaterial_DampingScale( const PxFEMSoftBodyMaterial* inObj ) { return inObj->getDampingScale(); } void setPxFEMSoftBodyMaterial_MaterialModel( PxFEMSoftBodyMaterial* inObj, PxFEMSoftBodyMaterialModel::Enum inArg){ inObj->setMaterialModel( inArg ); } PxFEMSoftBodyMaterialModel::Enum getPxFEMSoftBodyMaterial_MaterialModel( const PxFEMSoftBodyMaterial* inObj ) { return inObj->getMaterialModel(); } const char * getPxFEMSoftBodyMaterial_ConcreteTypeName( const PxFEMSoftBodyMaterial* inObj ) { return inObj->getConcreteTypeName(); } PX_PHYSX_CORE_API PxFEMSoftBodyMaterialGeneratedInfo::PxFEMSoftBodyMaterialGeneratedInfo() : Damping( "Damping", setPxFEMSoftBodyMaterial_Damping, getPxFEMSoftBodyMaterial_Damping) , DampingScale( "DampingScale", setPxFEMSoftBodyMaterial_DampingScale, getPxFEMSoftBodyMaterial_DampingScale) , MaterialModel( "MaterialModel", setPxFEMSoftBodyMaterial_MaterialModel, getPxFEMSoftBodyMaterial_MaterialModel) , ConcreteTypeName( "ConcreteTypeName", getPxFEMSoftBodyMaterial_ConcreteTypeName) {} PX_PHYSX_CORE_API PxFEMSoftBodyMaterialGeneratedValues::PxFEMSoftBodyMaterialGeneratedValues( const PxFEMSoftBodyMaterial* inSource ) :PxFEMMaterialGeneratedValues( inSource ) ,Damping( getPxFEMSoftBodyMaterial_Damping( inSource ) ) ,DampingScale( getPxFEMSoftBodyMaterial_DampingScale( inSource ) ) ,MaterialModel( getPxFEMSoftBodyMaterial_MaterialModel( inSource ) ) ,ConcreteTypeName( getPxFEMSoftBodyMaterial_ConcreteTypeName( inSource ) ) { PX_UNUSED(inSource); } void setPxParticleMaterial_Friction( PxParticleMaterial* inObj, PxReal inArg){ inObj->setFriction( inArg ); } PxReal getPxParticleMaterial_Friction( const PxParticleMaterial* inObj ) { return inObj->getFriction(); } void setPxParticleMaterial_Damping( PxParticleMaterial* inObj, PxReal inArg){ inObj->setDamping( inArg ); } PxReal getPxParticleMaterial_Damping( const PxParticleMaterial* inObj ) { return inObj->getDamping(); } void setPxParticleMaterial_Adhesion( PxParticleMaterial* inObj, PxReal inArg){ inObj->setAdhesion( inArg ); } PxReal getPxParticleMaterial_Adhesion( const PxParticleMaterial* inObj ) { return inObj->getAdhesion(); } void setPxParticleMaterial_GravityScale( PxParticleMaterial* inObj, PxReal inArg){ inObj->setGravityScale( inArg ); } PxReal getPxParticleMaterial_GravityScale( const PxParticleMaterial* inObj ) { return inObj->getGravityScale(); } void setPxParticleMaterial_AdhesionRadiusScale( PxParticleMaterial* inObj, PxReal inArg){ inObj->setAdhesionRadiusScale( inArg ); } PxReal getPxParticleMaterial_AdhesionRadiusScale( const PxParticleMaterial* inObj ) { return inObj->getAdhesionRadiusScale(); } PX_PHYSX_CORE_API PxParticleMaterialGeneratedInfo::PxParticleMaterialGeneratedInfo() : Friction( "Friction", setPxParticleMaterial_Friction, getPxParticleMaterial_Friction) , Damping( "Damping", setPxParticleMaterial_Damping, getPxParticleMaterial_Damping) , Adhesion( "Adhesion", setPxParticleMaterial_Adhesion, getPxParticleMaterial_Adhesion) , GravityScale( "GravityScale", setPxParticleMaterial_GravityScale, getPxParticleMaterial_GravityScale) , AdhesionRadiusScale( "AdhesionRadiusScale", setPxParticleMaterial_AdhesionRadiusScale, getPxParticleMaterial_AdhesionRadiusScale) {} PX_PHYSX_CORE_API PxParticleMaterialGeneratedValues::PxParticleMaterialGeneratedValues( const PxParticleMaterial* inSource ) :PxBaseMaterialGeneratedValues( inSource ) ,Friction( getPxParticleMaterial_Friction( inSource ) ) ,Damping( getPxParticleMaterial_Damping( inSource ) ) ,Adhesion( getPxParticleMaterial_Adhesion( inSource ) ) ,GravityScale( getPxParticleMaterial_GravityScale( inSource ) ) ,AdhesionRadiusScale( getPxParticleMaterial_AdhesionRadiusScale( inSource ) ) { PX_UNUSED(inSource); } void setPxPBDMaterial_Viscosity( PxPBDMaterial* inObj, PxReal inArg){ inObj->setViscosity( inArg ); } PxReal getPxPBDMaterial_Viscosity( const PxPBDMaterial* inObj ) { return inObj->getViscosity(); } void setPxPBDMaterial_VorticityConfinement( PxPBDMaterial* inObj, PxReal inArg){ inObj->setVorticityConfinement( inArg ); } PxReal getPxPBDMaterial_VorticityConfinement( const PxPBDMaterial* inObj ) { return inObj->getVorticityConfinement(); } void setPxPBDMaterial_SurfaceTension( PxPBDMaterial* inObj, PxReal inArg){ inObj->setSurfaceTension( inArg ); } PxReal getPxPBDMaterial_SurfaceTension( const PxPBDMaterial* inObj ) { return inObj->getSurfaceTension(); } void setPxPBDMaterial_Cohesion( PxPBDMaterial* inObj, PxReal inArg){ inObj->setCohesion( inArg ); } PxReal getPxPBDMaterial_Cohesion( const PxPBDMaterial* inObj ) { return inObj->getCohesion(); } void setPxPBDMaterial_Lift( PxPBDMaterial* inObj, PxReal inArg){ inObj->setLift( inArg ); } PxReal getPxPBDMaterial_Lift( const PxPBDMaterial* inObj ) { return inObj->getLift(); } void setPxPBDMaterial_Drag( PxPBDMaterial* inObj, PxReal inArg){ inObj->setDrag( inArg ); } PxReal getPxPBDMaterial_Drag( const PxPBDMaterial* inObj ) { return inObj->getDrag(); } void setPxPBDMaterial_CFLCoefficient( PxPBDMaterial* inObj, PxReal inArg){ inObj->setCFLCoefficient( inArg ); } PxReal getPxPBDMaterial_CFLCoefficient( const PxPBDMaterial* inObj ) { return inObj->getCFLCoefficient(); } void setPxPBDMaterial_ParticleFrictionScale( PxPBDMaterial* inObj, PxReal inArg){ inObj->setParticleFrictionScale( inArg ); } PxReal getPxPBDMaterial_ParticleFrictionScale( const PxPBDMaterial* inObj ) { return inObj->getParticleFrictionScale(); } void setPxPBDMaterial_ParticleAdhesionScale( PxPBDMaterial* inObj, PxReal inArg){ inObj->setParticleAdhesionScale( inArg ); } PxReal getPxPBDMaterial_ParticleAdhesionScale( const PxPBDMaterial* inObj ) { return inObj->getParticleAdhesionScale(); } const char * getPxPBDMaterial_ConcreteTypeName( const PxPBDMaterial* inObj ) { return inObj->getConcreteTypeName(); } PX_PHYSX_CORE_API PxPBDMaterialGeneratedInfo::PxPBDMaterialGeneratedInfo() : Viscosity( "Viscosity", setPxPBDMaterial_Viscosity, getPxPBDMaterial_Viscosity) , VorticityConfinement( "VorticityConfinement", setPxPBDMaterial_VorticityConfinement, getPxPBDMaterial_VorticityConfinement) , SurfaceTension( "SurfaceTension", setPxPBDMaterial_SurfaceTension, getPxPBDMaterial_SurfaceTension) , Cohesion( "Cohesion", setPxPBDMaterial_Cohesion, getPxPBDMaterial_Cohesion) , Lift( "Lift", setPxPBDMaterial_Lift, getPxPBDMaterial_Lift) , Drag( "Drag", setPxPBDMaterial_Drag, getPxPBDMaterial_Drag) , CFLCoefficient( "CFLCoefficient", setPxPBDMaterial_CFLCoefficient, getPxPBDMaterial_CFLCoefficient) , ParticleFrictionScale( "ParticleFrictionScale", setPxPBDMaterial_ParticleFrictionScale, getPxPBDMaterial_ParticleFrictionScale) , ParticleAdhesionScale( "ParticleAdhesionScale", setPxPBDMaterial_ParticleAdhesionScale, getPxPBDMaterial_ParticleAdhesionScale) , ConcreteTypeName( "ConcreteTypeName", getPxPBDMaterial_ConcreteTypeName) {} PX_PHYSX_CORE_API PxPBDMaterialGeneratedValues::PxPBDMaterialGeneratedValues( const PxPBDMaterial* inSource ) :PxParticleMaterialGeneratedValues( inSource ) ,Viscosity( getPxPBDMaterial_Viscosity( inSource ) ) ,VorticityConfinement( getPxPBDMaterial_VorticityConfinement( inSource ) ) ,SurfaceTension( getPxPBDMaterial_SurfaceTension( inSource ) ) ,Cohesion( getPxPBDMaterial_Cohesion( inSource ) ) ,Lift( getPxPBDMaterial_Lift( inSource ) ) ,Drag( getPxPBDMaterial_Drag( inSource ) ) ,CFLCoefficient( getPxPBDMaterial_CFLCoefficient( inSource ) ) ,ParticleFrictionScale( getPxPBDMaterial_ParticleFrictionScale( inSource ) ) ,ParticleAdhesionScale( getPxPBDMaterial_ParticleAdhesionScale( inSource ) ) ,ConcreteTypeName( getPxPBDMaterial_ConcreteTypeName( inSource ) ) { PX_UNUSED(inSource); } PxScene * getPxActor_Scene( const PxActor* inObj ) { return inObj->getScene(); } void setPxActor_Name( PxActor* inObj, const char * inArg){ inObj->setName( inArg ); } const char * getPxActor_Name( const PxActor* inObj ) { return inObj->getName(); } void setPxActor_ActorFlags( PxActor* inObj, PxActorFlags inArg){ inObj->setActorFlags( inArg ); } PxActorFlags getPxActor_ActorFlags( const PxActor* inObj ) { return inObj->getActorFlags(); } void setPxActor_DominanceGroup( PxActor* inObj, PxDominanceGroup inArg){ inObj->setDominanceGroup( inArg ); } PxDominanceGroup getPxActor_DominanceGroup( const PxActor* inObj ) { return inObj->getDominanceGroup(); } void setPxActor_OwnerClient( PxActor* inObj, PxClientID inArg){ inObj->setOwnerClient( inArg ); } PxClientID getPxActor_OwnerClient( const PxActor* inObj ) { return inObj->getOwnerClient(); } PxAggregate * getPxActor_Aggregate( const PxActor* inObj ) { return inObj->getAggregate(); } inline void * getPxActorUserData( const PxActor* inOwner ) { return inOwner->userData; } inline void setPxActorUserData( PxActor* inOwner, void * inData) { inOwner->userData = inData; } PX_PHYSX_CORE_API PxActorGeneratedInfo::PxActorGeneratedInfo() : Scene( "Scene", getPxActor_Scene) , Name( "Name", setPxActor_Name, getPxActor_Name) , ActorFlags( "ActorFlags", setPxActor_ActorFlags, getPxActor_ActorFlags) , DominanceGroup( "DominanceGroup", setPxActor_DominanceGroup, getPxActor_DominanceGroup) , OwnerClient( "OwnerClient", setPxActor_OwnerClient, getPxActor_OwnerClient) , Aggregate( "Aggregate", getPxActor_Aggregate) , UserData( "UserData", setPxActorUserData, getPxActorUserData ) {} PX_PHYSX_CORE_API PxActorGeneratedValues::PxActorGeneratedValues( const PxActor* inSource ) :Scene( getPxActor_Scene( inSource ) ) ,Name( getPxActor_Name( inSource ) ) ,ActorFlags( getPxActor_ActorFlags( inSource ) ) ,DominanceGroup( getPxActor_DominanceGroup( inSource ) ) ,OwnerClient( getPxActor_OwnerClient( inSource ) ) ,Aggregate( getPxActor_Aggregate( inSource ) ) ,UserData( inSource->userData ) { PX_UNUSED(inSource); } void setPxRigidActor_GlobalPose( PxRigidActor* inObj, const PxTransform & inArg){ inObj->setGlobalPose( inArg ); } PxTransform getPxRigidActor_GlobalPose( const PxRigidActor* inObj ) { return inObj->getGlobalPose(); } PxU32 getPxRigidActor_Shapes( const PxRigidActor* inObj, PxShape ** outBuffer, PxU32 inBufSize ) { return inObj->getShapes( outBuffer, inBufSize ); } PxU32 getNbPxRigidActor_Shapes( const PxRigidActor* inObj ) { return inObj->getNbShapes( ); } PxU32 getPxRigidActor_Constraints( const PxRigidActor* inObj, PxConstraint ** outBuffer, PxU32 inBufSize ) { return inObj->getConstraints( outBuffer, inBufSize ); } PxU32 getNbPxRigidActor_Constraints( const PxRigidActor* inObj ) { return inObj->getNbConstraints( ); } PX_PHYSX_CORE_API PxRigidActorGeneratedInfo::PxRigidActorGeneratedInfo() : GlobalPose( "GlobalPose", setPxRigidActor_GlobalPose, getPxRigidActor_GlobalPose) , Shapes( "Shapes", getPxRigidActor_Shapes, getNbPxRigidActor_Shapes ) , Constraints( "Constraints", getPxRigidActor_Constraints, getNbPxRigidActor_Constraints ) {} PX_PHYSX_CORE_API PxRigidActorGeneratedValues::PxRigidActorGeneratedValues( const PxRigidActor* inSource ) :PxActorGeneratedValues( inSource ) ,GlobalPose( getPxRigidActor_GlobalPose( inSource ) ) { PX_UNUSED(inSource); } void setPxRigidBody_CMassLocalPose( PxRigidBody* inObj, const PxTransform & inArg){ inObj->setCMassLocalPose( inArg ); } PxTransform getPxRigidBody_CMassLocalPose( const PxRigidBody* inObj ) { return inObj->getCMassLocalPose(); } void setPxRigidBody_Mass( PxRigidBody* inObj, PxReal inArg){ inObj->setMass( inArg ); } PxReal getPxRigidBody_Mass( const PxRigidBody* inObj ) { return inObj->getMass(); } PxReal getPxRigidBody_InvMass( const PxRigidBody* inObj ) { return inObj->getInvMass(); } void setPxRigidBody_MassSpaceInertiaTensor( PxRigidBody* inObj, const PxVec3 & inArg){ inObj->setMassSpaceInertiaTensor( inArg ); } PxVec3 getPxRigidBody_MassSpaceInertiaTensor( const PxRigidBody* inObj ) { return inObj->getMassSpaceInertiaTensor(); } PxVec3 getPxRigidBody_MassSpaceInvInertiaTensor( const PxRigidBody* inObj ) { return inObj->getMassSpaceInvInertiaTensor(); } void setPxRigidBody_LinearDamping( PxRigidBody* inObj, PxReal inArg){ inObj->setLinearDamping( inArg ); } PxReal getPxRigidBody_LinearDamping( const PxRigidBody* inObj ) { return inObj->getLinearDamping(); } void setPxRigidBody_AngularDamping( PxRigidBody* inObj, PxReal inArg){ inObj->setAngularDamping( inArg ); } PxReal getPxRigidBody_AngularDamping( const PxRigidBody* inObj ) { return inObj->getAngularDamping(); } void setPxRigidBody_MaxLinearVelocity( PxRigidBody* inObj, PxReal inArg){ inObj->setMaxLinearVelocity( inArg ); } PxReal getPxRigidBody_MaxLinearVelocity( const PxRigidBody* inObj ) { return inObj->getMaxLinearVelocity(); } void setPxRigidBody_MaxAngularVelocity( PxRigidBody* inObj, PxReal inArg){ inObj->setMaxAngularVelocity( inArg ); } PxReal getPxRigidBody_MaxAngularVelocity( const PxRigidBody* inObj ) { return inObj->getMaxAngularVelocity(); } void setPxRigidBody_RigidBodyFlags( PxRigidBody* inObj, PxRigidBodyFlags inArg){ inObj->setRigidBodyFlags( inArg ); } PxRigidBodyFlags getPxRigidBody_RigidBodyFlags( const PxRigidBody* inObj ) { return inObj->getRigidBodyFlags(); } void setPxRigidBody_MinCCDAdvanceCoefficient( PxRigidBody* inObj, PxReal inArg){ inObj->setMinCCDAdvanceCoefficient( inArg ); } PxReal getPxRigidBody_MinCCDAdvanceCoefficient( const PxRigidBody* inObj ) { return inObj->getMinCCDAdvanceCoefficient(); } void setPxRigidBody_MaxDepenetrationVelocity( PxRigidBody* inObj, PxReal inArg){ inObj->setMaxDepenetrationVelocity( inArg ); } PxReal getPxRigidBody_MaxDepenetrationVelocity( const PxRigidBody* inObj ) { return inObj->getMaxDepenetrationVelocity(); } void setPxRigidBody_MaxContactImpulse( PxRigidBody* inObj, PxReal inArg){ inObj->setMaxContactImpulse( inArg ); } PxReal getPxRigidBody_MaxContactImpulse( const PxRigidBody* inObj ) { return inObj->getMaxContactImpulse(); } void setPxRigidBody_ContactSlopCoefficient( PxRigidBody* inObj, PxReal inArg){ inObj->setContactSlopCoefficient( inArg ); } PxReal getPxRigidBody_ContactSlopCoefficient( const PxRigidBody* inObj ) { return inObj->getContactSlopCoefficient(); } PX_PHYSX_CORE_API PxRigidBodyGeneratedInfo::PxRigidBodyGeneratedInfo() : CMassLocalPose( "CMassLocalPose", setPxRigidBody_CMassLocalPose, getPxRigidBody_CMassLocalPose) , Mass( "Mass", setPxRigidBody_Mass, getPxRigidBody_Mass) , InvMass( "InvMass", getPxRigidBody_InvMass) , MassSpaceInertiaTensor( "MassSpaceInertiaTensor", setPxRigidBody_MassSpaceInertiaTensor, getPxRigidBody_MassSpaceInertiaTensor) , MassSpaceInvInertiaTensor( "MassSpaceInvInertiaTensor", getPxRigidBody_MassSpaceInvInertiaTensor) , LinearDamping( "LinearDamping", setPxRigidBody_LinearDamping, getPxRigidBody_LinearDamping) , AngularDamping( "AngularDamping", setPxRigidBody_AngularDamping, getPxRigidBody_AngularDamping) , MaxLinearVelocity( "MaxLinearVelocity", setPxRigidBody_MaxLinearVelocity, getPxRigidBody_MaxLinearVelocity) , MaxAngularVelocity( "MaxAngularVelocity", setPxRigidBody_MaxAngularVelocity, getPxRigidBody_MaxAngularVelocity) , RigidBodyFlags( "RigidBodyFlags", setPxRigidBody_RigidBodyFlags, getPxRigidBody_RigidBodyFlags) , MinCCDAdvanceCoefficient( "MinCCDAdvanceCoefficient", setPxRigidBody_MinCCDAdvanceCoefficient, getPxRigidBody_MinCCDAdvanceCoefficient) , MaxDepenetrationVelocity( "MaxDepenetrationVelocity", setPxRigidBody_MaxDepenetrationVelocity, getPxRigidBody_MaxDepenetrationVelocity) , MaxContactImpulse( "MaxContactImpulse", setPxRigidBody_MaxContactImpulse, getPxRigidBody_MaxContactImpulse) , ContactSlopCoefficient( "ContactSlopCoefficient", setPxRigidBody_ContactSlopCoefficient, getPxRigidBody_ContactSlopCoefficient) {} PX_PHYSX_CORE_API PxRigidBodyGeneratedValues::PxRigidBodyGeneratedValues( const PxRigidBody* inSource ) :PxRigidActorGeneratedValues( inSource ) ,CMassLocalPose( getPxRigidBody_CMassLocalPose( inSource ) ) ,Mass( getPxRigidBody_Mass( inSource ) ) ,InvMass( getPxRigidBody_InvMass( inSource ) ) ,MassSpaceInertiaTensor( getPxRigidBody_MassSpaceInertiaTensor( inSource ) ) ,MassSpaceInvInertiaTensor( getPxRigidBody_MassSpaceInvInertiaTensor( inSource ) ) ,LinearDamping( getPxRigidBody_LinearDamping( inSource ) ) ,AngularDamping( getPxRigidBody_AngularDamping( inSource ) ) ,MaxLinearVelocity( getPxRigidBody_MaxLinearVelocity( inSource ) ) ,MaxAngularVelocity( getPxRigidBody_MaxAngularVelocity( inSource ) ) ,RigidBodyFlags( getPxRigidBody_RigidBodyFlags( inSource ) ) ,MinCCDAdvanceCoefficient( getPxRigidBody_MinCCDAdvanceCoefficient( inSource ) ) ,MaxDepenetrationVelocity( getPxRigidBody_MaxDepenetrationVelocity( inSource ) ) ,MaxContactImpulse( getPxRigidBody_MaxContactImpulse( inSource ) ) ,ContactSlopCoefficient( getPxRigidBody_ContactSlopCoefficient( inSource ) ) { PX_UNUSED(inSource); } _Bool getPxRigidDynamic_IsSleeping( const PxRigidDynamic* inObj ) { return inObj->isSleeping(); } void setPxRigidDynamic_SleepThreshold( PxRigidDynamic* inObj, PxReal inArg){ inObj->setSleepThreshold( inArg ); } PxReal getPxRigidDynamic_SleepThreshold( const PxRigidDynamic* inObj ) { return inObj->getSleepThreshold(); } void setPxRigidDynamic_StabilizationThreshold( PxRigidDynamic* inObj, PxReal inArg){ inObj->setStabilizationThreshold( inArg ); } PxReal getPxRigidDynamic_StabilizationThreshold( const PxRigidDynamic* inObj ) { return inObj->getStabilizationThreshold(); } void setPxRigidDynamic_RigidDynamicLockFlags( PxRigidDynamic* inObj, PxRigidDynamicLockFlags inArg){ inObj->setRigidDynamicLockFlags( inArg ); } PxRigidDynamicLockFlags getPxRigidDynamic_RigidDynamicLockFlags( const PxRigidDynamic* inObj ) { return inObj->getRigidDynamicLockFlags(); } void setPxRigidDynamic_LinearVelocity( PxRigidDynamic* inObj, const PxVec3 & inArg){ inObj->setLinearVelocity( inArg ); } PxVec3 getPxRigidDynamic_LinearVelocity( const PxRigidDynamic* inObj ) { return inObj->getLinearVelocity(); } void setPxRigidDynamic_AngularVelocity( PxRigidDynamic* inObj, const PxVec3 & inArg){ inObj->setAngularVelocity( inArg ); } PxVec3 getPxRigidDynamic_AngularVelocity( const PxRigidDynamic* inObj ) { return inObj->getAngularVelocity(); } void setPxRigidDynamic_WakeCounter( PxRigidDynamic* inObj, PxReal inArg){ inObj->setWakeCounter( inArg ); } PxReal getPxRigidDynamic_WakeCounter( const PxRigidDynamic* inObj ) { return inObj->getWakeCounter(); } void setPxRigidDynamic_SolverIterationCounts( PxRigidDynamic* inObj, PxU32 inArg0, PxU32 inArg1 ) { inObj->setSolverIterationCounts( inArg0, inArg1 ); } void getPxRigidDynamic_SolverIterationCounts( const PxRigidDynamic* inObj, PxU32& inArg0, PxU32& inArg1 ) { inObj->getSolverIterationCounts( inArg0, inArg1 ); } void setPxRigidDynamic_ContactReportThreshold( PxRigidDynamic* inObj, PxReal inArg){ inObj->setContactReportThreshold( inArg ); } PxReal getPxRigidDynamic_ContactReportThreshold( const PxRigidDynamic* inObj ) { return inObj->getContactReportThreshold(); } const char * getPxRigidDynamic_ConcreteTypeName( const PxRigidDynamic* inObj ) { return inObj->getConcreteTypeName(); } PX_PHYSX_CORE_API PxRigidDynamicGeneratedInfo::PxRigidDynamicGeneratedInfo() : IsSleeping( "IsSleeping", getPxRigidDynamic_IsSleeping) , SleepThreshold( "SleepThreshold", setPxRigidDynamic_SleepThreshold, getPxRigidDynamic_SleepThreshold) , StabilizationThreshold( "StabilizationThreshold", setPxRigidDynamic_StabilizationThreshold, getPxRigidDynamic_StabilizationThreshold) , RigidDynamicLockFlags( "RigidDynamicLockFlags", setPxRigidDynamic_RigidDynamicLockFlags, getPxRigidDynamic_RigidDynamicLockFlags) , LinearVelocity( "LinearVelocity", setPxRigidDynamic_LinearVelocity, getPxRigidDynamic_LinearVelocity) , AngularVelocity( "AngularVelocity", setPxRigidDynamic_AngularVelocity, getPxRigidDynamic_AngularVelocity) , WakeCounter( "WakeCounter", setPxRigidDynamic_WakeCounter, getPxRigidDynamic_WakeCounter) , SolverIterationCounts( "SolverIterationCounts", "minPositionIters", "minVelocityIters", setPxRigidDynamic_SolverIterationCounts, getPxRigidDynamic_SolverIterationCounts) , ContactReportThreshold( "ContactReportThreshold", setPxRigidDynamic_ContactReportThreshold, getPxRigidDynamic_ContactReportThreshold) , ConcreteTypeName( "ConcreteTypeName", getPxRigidDynamic_ConcreteTypeName) {} PX_PHYSX_CORE_API PxRigidDynamicGeneratedValues::PxRigidDynamicGeneratedValues( const PxRigidDynamic* inSource ) :PxRigidBodyGeneratedValues( inSource ) ,IsSleeping( getPxRigidDynamic_IsSleeping( inSource ) ) ,SleepThreshold( getPxRigidDynamic_SleepThreshold( inSource ) ) ,StabilizationThreshold( getPxRigidDynamic_StabilizationThreshold( inSource ) ) ,RigidDynamicLockFlags( getPxRigidDynamic_RigidDynamicLockFlags( inSource ) ) ,LinearVelocity( getPxRigidDynamic_LinearVelocity( inSource ) ) ,AngularVelocity( getPxRigidDynamic_AngularVelocity( inSource ) ) ,WakeCounter( getPxRigidDynamic_WakeCounter( inSource ) ) ,ContactReportThreshold( getPxRigidDynamic_ContactReportThreshold( inSource ) ) ,ConcreteTypeName( getPxRigidDynamic_ConcreteTypeName( inSource ) ) { PX_UNUSED(inSource); getPxRigidDynamic_SolverIterationCounts( inSource, SolverIterationCounts[0], SolverIterationCounts[1] ); } const char * getPxRigidStatic_ConcreteTypeName( const PxRigidStatic* inObj ) { return inObj->getConcreteTypeName(); } PX_PHYSX_CORE_API PxRigidStaticGeneratedInfo::PxRigidStaticGeneratedInfo() : ConcreteTypeName( "ConcreteTypeName", getPxRigidStatic_ConcreteTypeName) {} PX_PHYSX_CORE_API PxRigidStaticGeneratedValues::PxRigidStaticGeneratedValues( const PxRigidStatic* inSource ) :PxRigidActorGeneratedValues( inSource ) ,ConcreteTypeName( getPxRigidStatic_ConcreteTypeName( inSource ) ) { PX_UNUSED(inSource); } PxArticulationJointReducedCoordinate * getPxArticulationLink_InboundJoint( const PxArticulationLink* inObj ) { return inObj->getInboundJoint(); } PxU32 getPxArticulationLink_InboundJointDof( const PxArticulationLink* inObj ) { return inObj->getInboundJointDof(); } PxU32 getPxArticulationLink_LinkIndex( const PxArticulationLink* inObj ) { return inObj->getLinkIndex(); } PxU32 getPxArticulationLink_Children( const PxArticulationLink* inObj, PxArticulationLink ** outBuffer, PxU32 inBufSize ) { return inObj->getChildren( outBuffer, inBufSize ); } PxU32 getNbPxArticulationLink_Children( const PxArticulationLink* inObj ) { return inObj->getNbChildren( ); } void setPxArticulationLink_CfmScale( PxArticulationLink* inObj, const PxReal inArg){ inObj->setCfmScale( inArg ); } PxReal getPxArticulationLink_CfmScale( const PxArticulationLink* inObj ) { return inObj->getCfmScale(); } PxVec3 getPxArticulationLink_LinearVelocity( const PxArticulationLink* inObj ) { return inObj->getLinearVelocity(); } PxVec3 getPxArticulationLink_AngularVelocity( const PxArticulationLink* inObj ) { return inObj->getAngularVelocity(); } const char * getPxArticulationLink_ConcreteTypeName( const PxArticulationLink* inObj ) { return inObj->getConcreteTypeName(); } PX_PHYSX_CORE_API PxArticulationLinkGeneratedInfo::PxArticulationLinkGeneratedInfo() : InboundJoint( "InboundJoint", getPxArticulationLink_InboundJoint) , InboundJointDof( "InboundJointDof", getPxArticulationLink_InboundJointDof) , LinkIndex( "LinkIndex", getPxArticulationLink_LinkIndex) , Children( "Children", getPxArticulationLink_Children, getNbPxArticulationLink_Children ) , CfmScale( "CfmScale", setPxArticulationLink_CfmScale, getPxArticulationLink_CfmScale) , LinearVelocity( "LinearVelocity", getPxArticulationLink_LinearVelocity) , AngularVelocity( "AngularVelocity", getPxArticulationLink_AngularVelocity) , ConcreteTypeName( "ConcreteTypeName", getPxArticulationLink_ConcreteTypeName) {} PX_PHYSX_CORE_API PxArticulationLinkGeneratedValues::PxArticulationLinkGeneratedValues( const PxArticulationLink* inSource ) :PxRigidBodyGeneratedValues( inSource ) ,InboundJoint( getPxArticulationLink_InboundJoint( inSource ) ) ,InboundJointDof( getPxArticulationLink_InboundJointDof( inSource ) ) ,LinkIndex( getPxArticulationLink_LinkIndex( inSource ) ) ,CfmScale( getPxArticulationLink_CfmScale( inSource ) ) ,LinearVelocity( getPxArticulationLink_LinearVelocity( inSource ) ) ,AngularVelocity( getPxArticulationLink_AngularVelocity( inSource ) ) ,ConcreteTypeName( getPxArticulationLink_ConcreteTypeName( inSource ) ) { PX_UNUSED(inSource); } void setPxArticulationJointReducedCoordinate_ParentPose( PxArticulationJointReducedCoordinate* inObj, const PxTransform & inArg){ inObj->setParentPose( inArg ); } PxTransform getPxArticulationJointReducedCoordinate_ParentPose( const PxArticulationJointReducedCoordinate* inObj ) { return inObj->getParentPose(); } void setPxArticulationJointReducedCoordinate_ChildPose( PxArticulationJointReducedCoordinate* inObj, const PxTransform & inArg){ inObj->setChildPose( inArg ); } PxTransform getPxArticulationJointReducedCoordinate_ChildPose( const PxArticulationJointReducedCoordinate* inObj ) { return inObj->getChildPose(); } void setPxArticulationJointReducedCoordinate_JointType( PxArticulationJointReducedCoordinate* inObj, PxArticulationJointType::Enum inArg){ inObj->setJointType( inArg ); } PxArticulationJointType::Enum getPxArticulationJointReducedCoordinate_JointType( const PxArticulationJointReducedCoordinate* inObj ) { return inObj->getJointType(); } void setPxArticulationJointReducedCoordinate_Motion( PxArticulationJointReducedCoordinate* inObj, PxArticulationAxis::Enum inIndex, PxArticulationMotion::Enum inArg ){ inObj->setMotion( inIndex, inArg ); } PxArticulationMotion::Enum getPxArticulationJointReducedCoordinate_Motion( const PxArticulationJointReducedCoordinate* inObj, PxArticulationAxis::Enum inIndex ) { return inObj->getMotion( inIndex ); } void setPxArticulationJointReducedCoordinate_LimitParams( PxArticulationJointReducedCoordinate* inObj, PxArticulationAxis::Enum inIndex, PxArticulationLimit inArg ){ inObj->setLimitParams( inIndex, inArg ); } PxArticulationLimit getPxArticulationJointReducedCoordinate_LimitParams( const PxArticulationJointReducedCoordinate* inObj, PxArticulationAxis::Enum inIndex ) { return inObj->getLimitParams( inIndex ); } void setPxArticulationJointReducedCoordinate_DriveParams( PxArticulationJointReducedCoordinate* inObj, PxArticulationAxis::Enum inIndex, PxArticulationDrive inArg ){ inObj->setDriveParams( inIndex, inArg ); } PxArticulationDrive getPxArticulationJointReducedCoordinate_DriveParams( const PxArticulationJointReducedCoordinate* inObj, PxArticulationAxis::Enum inIndex ) { return inObj->getDriveParams( inIndex ); } void setPxArticulationJointReducedCoordinate_Armature( PxArticulationJointReducedCoordinate* inObj, PxArticulationAxis::Enum inIndex, PxReal inArg ){ inObj->setArmature( inIndex, inArg ); } PxReal getPxArticulationJointReducedCoordinate_Armature( const PxArticulationJointReducedCoordinate* inObj, PxArticulationAxis::Enum inIndex ) { return inObj->getArmature( inIndex ); } void setPxArticulationJointReducedCoordinate_FrictionCoefficient( PxArticulationJointReducedCoordinate* inObj, const PxReal inArg){ inObj->setFrictionCoefficient( inArg ); } PxReal getPxArticulationJointReducedCoordinate_FrictionCoefficient( const PxArticulationJointReducedCoordinate* inObj ) { return inObj->getFrictionCoefficient(); } void setPxArticulationJointReducedCoordinate_MaxJointVelocity( PxArticulationJointReducedCoordinate* inObj, const PxReal inArg){ inObj->setMaxJointVelocity( inArg ); } PxReal getPxArticulationJointReducedCoordinate_MaxJointVelocity( const PxArticulationJointReducedCoordinate* inObj ) { return inObj->getMaxJointVelocity(); } void setPxArticulationJointReducedCoordinate_JointPosition( PxArticulationJointReducedCoordinate* inObj, PxArticulationAxis::Enum inIndex, PxReal inArg ){ inObj->setJointPosition( inIndex, inArg ); } PxReal getPxArticulationJointReducedCoordinate_JointPosition( const PxArticulationJointReducedCoordinate* inObj, PxArticulationAxis::Enum inIndex ) { return inObj->getJointPosition( inIndex ); } void setPxArticulationJointReducedCoordinate_JointVelocity( PxArticulationJointReducedCoordinate* inObj, PxArticulationAxis::Enum inIndex, PxReal inArg ){ inObj->setJointVelocity( inIndex, inArg ); } PxReal getPxArticulationJointReducedCoordinate_JointVelocity( const PxArticulationJointReducedCoordinate* inObj, PxArticulationAxis::Enum inIndex ) { return inObj->getJointVelocity( inIndex ); } const char * getPxArticulationJointReducedCoordinate_ConcreteTypeName( const PxArticulationJointReducedCoordinate* inObj ) { return inObj->getConcreteTypeName(); } inline void * getPxArticulationJointReducedCoordinateUserData( const PxArticulationJointReducedCoordinate* inOwner ) { return inOwner->userData; } inline void setPxArticulationJointReducedCoordinateUserData( PxArticulationJointReducedCoordinate* inOwner, void * inData) { inOwner->userData = inData; } PX_PHYSX_CORE_API PxArticulationJointReducedCoordinateGeneratedInfo::PxArticulationJointReducedCoordinateGeneratedInfo() : ParentPose( "ParentPose", setPxArticulationJointReducedCoordinate_ParentPose, getPxArticulationJointReducedCoordinate_ParentPose) , ChildPose( "ChildPose", setPxArticulationJointReducedCoordinate_ChildPose, getPxArticulationJointReducedCoordinate_ChildPose) , JointType( "JointType", setPxArticulationJointReducedCoordinate_JointType, getPxArticulationJointReducedCoordinate_JointType) , Motion( "Motion", setPxArticulationJointReducedCoordinate_Motion, getPxArticulationJointReducedCoordinate_Motion) , LimitParams( "LimitParams", setPxArticulationJointReducedCoordinate_LimitParams, getPxArticulationJointReducedCoordinate_LimitParams) , DriveParams( "DriveParams", setPxArticulationJointReducedCoordinate_DriveParams, getPxArticulationJointReducedCoordinate_DriveParams) , Armature( "Armature", setPxArticulationJointReducedCoordinate_Armature, getPxArticulationJointReducedCoordinate_Armature) , FrictionCoefficient( "FrictionCoefficient", setPxArticulationJointReducedCoordinate_FrictionCoefficient, getPxArticulationJointReducedCoordinate_FrictionCoefficient) , MaxJointVelocity( "MaxJointVelocity", setPxArticulationJointReducedCoordinate_MaxJointVelocity, getPxArticulationJointReducedCoordinate_MaxJointVelocity) , JointPosition( "JointPosition", setPxArticulationJointReducedCoordinate_JointPosition, getPxArticulationJointReducedCoordinate_JointPosition) , JointVelocity( "JointVelocity", setPxArticulationJointReducedCoordinate_JointVelocity, getPxArticulationJointReducedCoordinate_JointVelocity) , ConcreteTypeName( "ConcreteTypeName", getPxArticulationJointReducedCoordinate_ConcreteTypeName) , UserData( "UserData", setPxArticulationJointReducedCoordinateUserData, getPxArticulationJointReducedCoordinateUserData ) {} PX_PHYSX_CORE_API PxArticulationJointReducedCoordinateGeneratedValues::PxArticulationJointReducedCoordinateGeneratedValues( const PxArticulationJointReducedCoordinate* inSource ) :ParentPose( getPxArticulationJointReducedCoordinate_ParentPose( inSource ) ) ,ChildPose( getPxArticulationJointReducedCoordinate_ChildPose( inSource ) ) ,JointType( getPxArticulationJointReducedCoordinate_JointType( inSource ) ) ,FrictionCoefficient( getPxArticulationJointReducedCoordinate_FrictionCoefficient( inSource ) ) ,MaxJointVelocity( getPxArticulationJointReducedCoordinate_MaxJointVelocity( inSource ) ) ,ConcreteTypeName( getPxArticulationJointReducedCoordinate_ConcreteTypeName( inSource ) ) ,UserData( inSource->userData ) { PX_UNUSED(inSource); for ( PxU32 idx = 0; idx < static_cast<PxU32>( physx::PxArticulationAxis::eCOUNT ); ++idx ) Motion[idx] = getPxArticulationJointReducedCoordinate_Motion( inSource, static_cast< PxArticulationAxis::Enum >( idx ) ); for ( PxU32 idx = 0; idx < static_cast<PxU32>( physx::PxArticulationAxis::eCOUNT ); ++idx ) LimitParams[idx] = getPxArticulationJointReducedCoordinate_LimitParams( inSource, static_cast< PxArticulationAxis::Enum >( idx ) ); for ( PxU32 idx = 0; idx < static_cast<PxU32>( physx::PxArticulationAxis::eCOUNT ); ++idx ) DriveParams[idx] = getPxArticulationJointReducedCoordinate_DriveParams( inSource, static_cast< PxArticulationAxis::Enum >( idx ) ); for ( PxU32 idx = 0; idx < static_cast<PxU32>( physx::PxArticulationAxis::eCOUNT ); ++idx ) Armature[idx] = getPxArticulationJointReducedCoordinate_Armature( inSource, static_cast< PxArticulationAxis::Enum >( idx ) ); for ( PxU32 idx = 0; idx < static_cast<PxU32>( physx::PxArticulationAxis::eCOUNT ); ++idx ) JointPosition[idx] = getPxArticulationJointReducedCoordinate_JointPosition( inSource, static_cast< PxArticulationAxis::Enum >( idx ) ); for ( PxU32 idx = 0; idx < static_cast<PxU32>( physx::PxArticulationAxis::eCOUNT ); ++idx ) JointVelocity[idx] = getPxArticulationJointReducedCoordinate_JointVelocity( inSource, static_cast< PxArticulationAxis::Enum >( idx ) ); } PxScene * getPxArticulationReducedCoordinate_Scene( const PxArticulationReducedCoordinate* inObj ) { return inObj->getScene(); } void setPxArticulationReducedCoordinate_SolverIterationCounts( PxArticulationReducedCoordinate* inObj, PxU32 inArg0, PxU32 inArg1 ) { inObj->setSolverIterationCounts( inArg0, inArg1 ); } void getPxArticulationReducedCoordinate_SolverIterationCounts( const PxArticulationReducedCoordinate* inObj, PxU32& inArg0, PxU32& inArg1 ) { inObj->getSolverIterationCounts( inArg0, inArg1 ); } _Bool getPxArticulationReducedCoordinate_IsSleeping( const PxArticulationReducedCoordinate* inObj ) { return inObj->isSleeping(); } void setPxArticulationReducedCoordinate_SleepThreshold( PxArticulationReducedCoordinate* inObj, PxReal inArg){ inObj->setSleepThreshold( inArg ); } PxReal getPxArticulationReducedCoordinate_SleepThreshold( const PxArticulationReducedCoordinate* inObj ) { return inObj->getSleepThreshold(); } void setPxArticulationReducedCoordinate_StabilizationThreshold( PxArticulationReducedCoordinate* inObj, PxReal inArg){ inObj->setStabilizationThreshold( inArg ); } PxReal getPxArticulationReducedCoordinate_StabilizationThreshold( const PxArticulationReducedCoordinate* inObj ) { return inObj->getStabilizationThreshold(); } void setPxArticulationReducedCoordinate_WakeCounter( PxArticulationReducedCoordinate* inObj, PxReal inArg){ inObj->setWakeCounter( inArg ); } PxReal getPxArticulationReducedCoordinate_WakeCounter( const PxArticulationReducedCoordinate* inObj ) { return inObj->getWakeCounter(); } void setPxArticulationReducedCoordinate_MaxCOMLinearVelocity( PxArticulationReducedCoordinate* inObj, const PxReal inArg){ inObj->setMaxCOMLinearVelocity( inArg ); } PxReal getPxArticulationReducedCoordinate_MaxCOMLinearVelocity( const PxArticulationReducedCoordinate* inObj ) { return inObj->getMaxCOMLinearVelocity(); } void setPxArticulationReducedCoordinate_MaxCOMAngularVelocity( PxArticulationReducedCoordinate* inObj, const PxReal inArg){ inObj->setMaxCOMAngularVelocity( inArg ); } PxReal getPxArticulationReducedCoordinate_MaxCOMAngularVelocity( const PxArticulationReducedCoordinate* inObj ) { return inObj->getMaxCOMAngularVelocity(); } PxU32 getPxArticulationReducedCoordinate_Links( const PxArticulationReducedCoordinate* inObj, PxArticulationLink ** outBuffer, PxU32 inBufSize ) { return inObj->getLinks( outBuffer, inBufSize ); } PxU32 getNbPxArticulationReducedCoordinate_Links( const PxArticulationReducedCoordinate* inObj ) { return inObj->getNbLinks( ); } void setPxArticulationReducedCoordinate_Name( PxArticulationReducedCoordinate* inObj, const char * inArg){ inObj->setName( inArg ); } const char * getPxArticulationReducedCoordinate_Name( const PxArticulationReducedCoordinate* inObj ) { return inObj->getName(); } PxAggregate * getPxArticulationReducedCoordinate_Aggregate( const PxArticulationReducedCoordinate* inObj ) { return inObj->getAggregate(); } void setPxArticulationReducedCoordinate_ArticulationFlags( PxArticulationReducedCoordinate* inObj, PxArticulationFlags inArg){ inObj->setArticulationFlags( inArg ); } PxArticulationFlags getPxArticulationReducedCoordinate_ArticulationFlags( const PxArticulationReducedCoordinate* inObj ) { return inObj->getArticulationFlags(); } void setPxArticulationReducedCoordinate_RootGlobalPose( PxArticulationReducedCoordinate* inObj, const PxTransform & inArg){ inObj->setRootGlobalPose( inArg ); } PxTransform getPxArticulationReducedCoordinate_RootGlobalPose( const PxArticulationReducedCoordinate* inObj ) { return inObj->getRootGlobalPose(); } void setPxArticulationReducedCoordinate_RootLinearVelocity( PxArticulationReducedCoordinate* inObj, const PxVec3 & inArg){ inObj->setRootLinearVelocity( inArg ); } PxVec3 getPxArticulationReducedCoordinate_RootLinearVelocity( const PxArticulationReducedCoordinate* inObj ) { return inObj->getRootLinearVelocity(); } void setPxArticulationReducedCoordinate_RootAngularVelocity( PxArticulationReducedCoordinate* inObj, const PxVec3 & inArg){ inObj->setRootAngularVelocity( inArg ); } PxVec3 getPxArticulationReducedCoordinate_RootAngularVelocity( const PxArticulationReducedCoordinate* inObj ) { return inObj->getRootAngularVelocity(); } inline void * getPxArticulationReducedCoordinateUserData( const PxArticulationReducedCoordinate* inOwner ) { return inOwner->userData; } inline void setPxArticulationReducedCoordinateUserData( PxArticulationReducedCoordinate* inOwner, void * inData) { inOwner->userData = inData; } PX_PHYSX_CORE_API PxArticulationReducedCoordinateGeneratedInfo::PxArticulationReducedCoordinateGeneratedInfo() : Scene( "Scene", getPxArticulationReducedCoordinate_Scene) , SolverIterationCounts( "SolverIterationCounts", "minPositionIters", "minVelocityIters", setPxArticulationReducedCoordinate_SolverIterationCounts, getPxArticulationReducedCoordinate_SolverIterationCounts) , IsSleeping( "IsSleeping", getPxArticulationReducedCoordinate_IsSleeping) , SleepThreshold( "SleepThreshold", setPxArticulationReducedCoordinate_SleepThreshold, getPxArticulationReducedCoordinate_SleepThreshold) , StabilizationThreshold( "StabilizationThreshold", setPxArticulationReducedCoordinate_StabilizationThreshold, getPxArticulationReducedCoordinate_StabilizationThreshold) , WakeCounter( "WakeCounter", setPxArticulationReducedCoordinate_WakeCounter, getPxArticulationReducedCoordinate_WakeCounter) , MaxCOMLinearVelocity( "MaxCOMLinearVelocity", setPxArticulationReducedCoordinate_MaxCOMLinearVelocity, getPxArticulationReducedCoordinate_MaxCOMLinearVelocity) , MaxCOMAngularVelocity( "MaxCOMAngularVelocity", setPxArticulationReducedCoordinate_MaxCOMAngularVelocity, getPxArticulationReducedCoordinate_MaxCOMAngularVelocity) , Links( "Links", getPxArticulationReducedCoordinate_Links, getNbPxArticulationReducedCoordinate_Links ) , Name( "Name", setPxArticulationReducedCoordinate_Name, getPxArticulationReducedCoordinate_Name) , Aggregate( "Aggregate", getPxArticulationReducedCoordinate_Aggregate) , ArticulationFlags( "ArticulationFlags", setPxArticulationReducedCoordinate_ArticulationFlags, getPxArticulationReducedCoordinate_ArticulationFlags) , RootGlobalPose( "RootGlobalPose", setPxArticulationReducedCoordinate_RootGlobalPose, getPxArticulationReducedCoordinate_RootGlobalPose) , RootLinearVelocity( "RootLinearVelocity", setPxArticulationReducedCoordinate_RootLinearVelocity, getPxArticulationReducedCoordinate_RootLinearVelocity) , RootAngularVelocity( "RootAngularVelocity", setPxArticulationReducedCoordinate_RootAngularVelocity, getPxArticulationReducedCoordinate_RootAngularVelocity) , UserData( "UserData", setPxArticulationReducedCoordinateUserData, getPxArticulationReducedCoordinateUserData ) {} PX_PHYSX_CORE_API PxArticulationReducedCoordinateGeneratedValues::PxArticulationReducedCoordinateGeneratedValues( const PxArticulationReducedCoordinate* inSource ) :Scene( getPxArticulationReducedCoordinate_Scene( inSource ) ) ,IsSleeping( getPxArticulationReducedCoordinate_IsSleeping( inSource ) ) ,SleepThreshold( getPxArticulationReducedCoordinate_SleepThreshold( inSource ) ) ,StabilizationThreshold( getPxArticulationReducedCoordinate_StabilizationThreshold( inSource ) ) ,WakeCounter( getPxArticulationReducedCoordinate_WakeCounter( inSource ) ) ,MaxCOMLinearVelocity( getPxArticulationReducedCoordinate_MaxCOMLinearVelocity( inSource ) ) ,MaxCOMAngularVelocity( getPxArticulationReducedCoordinate_MaxCOMAngularVelocity( inSource ) ) ,Name( getPxArticulationReducedCoordinate_Name( inSource ) ) ,Aggregate( getPxArticulationReducedCoordinate_Aggregate( inSource ) ) ,ArticulationFlags( getPxArticulationReducedCoordinate_ArticulationFlags( inSource ) ) ,RootGlobalPose( getPxArticulationReducedCoordinate_RootGlobalPose( inSource ) ) ,RootLinearVelocity( getPxArticulationReducedCoordinate_RootLinearVelocity( inSource ) ) ,RootAngularVelocity( getPxArticulationReducedCoordinate_RootAngularVelocity( inSource ) ) ,UserData( inSource->userData ) { PX_UNUSED(inSource); getPxArticulationReducedCoordinate_SolverIterationCounts( inSource, SolverIterationCounts[0], SolverIterationCounts[1] ); } PxU32 getPxAggregate_MaxNbActors( const PxAggregate* inObj ) { return inObj->getMaxNbActors(); } PxU32 getPxAggregate_MaxNbShapes( const PxAggregate* inObj ) { return inObj->getMaxNbShapes(); } PxU32 getPxAggregate_Actors( const PxAggregate* inObj, PxActor ** outBuffer, PxU32 inBufSize ) { return inObj->getActors( outBuffer, inBufSize ); } PxU32 getNbPxAggregate_Actors( const PxAggregate* inObj ) { return inObj->getNbActors( ); } _Bool getPxAggregate_SelfCollision( const PxAggregate* inObj ) { return inObj->getSelfCollision(); } const char * getPxAggregate_ConcreteTypeName( const PxAggregate* inObj ) { return inObj->getConcreteTypeName(); } inline void * getPxAggregateUserData( const PxAggregate* inOwner ) { return inOwner->userData; } inline void setPxAggregateUserData( PxAggregate* inOwner, void * inData) { inOwner->userData = inData; } PX_PHYSX_CORE_API PxAggregateGeneratedInfo::PxAggregateGeneratedInfo() : MaxNbActors( "MaxNbActors", getPxAggregate_MaxNbActors) , MaxNbShapes( "MaxNbShapes", getPxAggregate_MaxNbShapes) , Actors( "Actors", getPxAggregate_Actors, getNbPxAggregate_Actors ) , SelfCollision( "SelfCollision", getPxAggregate_SelfCollision) , ConcreteTypeName( "ConcreteTypeName", getPxAggregate_ConcreteTypeName) , UserData( "UserData", setPxAggregateUserData, getPxAggregateUserData ) {} PX_PHYSX_CORE_API PxAggregateGeneratedValues::PxAggregateGeneratedValues( const PxAggregate* inSource ) :MaxNbActors( getPxAggregate_MaxNbActors( inSource ) ) ,MaxNbShapes( getPxAggregate_MaxNbShapes( inSource ) ) ,SelfCollision( getPxAggregate_SelfCollision( inSource ) ) ,ConcreteTypeName( getPxAggregate_ConcreteTypeName( inSource ) ) ,UserData( inSource->userData ) { PX_UNUSED(inSource); } PxScene * getPxConstraint_Scene( const PxConstraint* inObj ) { return inObj->getScene(); } void setPxConstraint_Actors( PxConstraint* inObj, PxRigidActor * inArg0, PxRigidActor * inArg1 ) { inObj->setActors( inArg0, inArg1 ); } void getPxConstraint_Actors( const PxConstraint* inObj, PxRigidActor *& inArg0, PxRigidActor *& inArg1 ) { inObj->getActors( inArg0, inArg1 ); } void setPxConstraint_Flags( PxConstraint* inObj, PxConstraintFlags inArg){ inObj->setFlags( inArg ); } PxConstraintFlags getPxConstraint_Flags( const PxConstraint* inObj ) { return inObj->getFlags(); } _Bool getPxConstraint_IsValid( const PxConstraint* inObj ) { return inObj->isValid(); } void setPxConstraint_BreakForce( PxConstraint* inObj, PxReal inArg0, PxReal inArg1 ) { inObj->setBreakForce( inArg0, inArg1 ); } void getPxConstraint_BreakForce( const PxConstraint* inObj, PxReal& inArg0, PxReal& inArg1 ) { inObj->getBreakForce( inArg0, inArg1 ); } void setPxConstraint_MinResponseThreshold( PxConstraint* inObj, PxReal inArg){ inObj->setMinResponseThreshold( inArg ); } PxReal getPxConstraint_MinResponseThreshold( const PxConstraint* inObj ) { return inObj->getMinResponseThreshold(); } const char * getPxConstraint_ConcreteTypeName( const PxConstraint* inObj ) { return inObj->getConcreteTypeName(); } inline void * getPxConstraintUserData( const PxConstraint* inOwner ) { return inOwner->userData; } inline void setPxConstraintUserData( PxConstraint* inOwner, void * inData) { inOwner->userData = inData; } PX_PHYSX_CORE_API PxConstraintGeneratedInfo::PxConstraintGeneratedInfo() : Scene( "Scene", getPxConstraint_Scene) , Actors( "Actors", "actor0", "actor1", setPxConstraint_Actors, getPxConstraint_Actors) , Flags( "Flags", setPxConstraint_Flags, getPxConstraint_Flags) , IsValid( "IsValid", getPxConstraint_IsValid) , BreakForce( "BreakForce", "linear", "angular", setPxConstraint_BreakForce, getPxConstraint_BreakForce) , MinResponseThreshold( "MinResponseThreshold", setPxConstraint_MinResponseThreshold, getPxConstraint_MinResponseThreshold) , ConcreteTypeName( "ConcreteTypeName", getPxConstraint_ConcreteTypeName) , UserData( "UserData", setPxConstraintUserData, getPxConstraintUserData ) {} PX_PHYSX_CORE_API PxConstraintGeneratedValues::PxConstraintGeneratedValues( const PxConstraint* inSource ) :Scene( getPxConstraint_Scene( inSource ) ) ,Flags( getPxConstraint_Flags( inSource ) ) ,IsValid( getPxConstraint_IsValid( inSource ) ) ,MinResponseThreshold( getPxConstraint_MinResponseThreshold( inSource ) ) ,ConcreteTypeName( getPxConstraint_ConcreteTypeName( inSource ) ) ,UserData( inSource->userData ) { PX_UNUSED(inSource); getPxConstraint_Actors( inSource, Actors[0], Actors[1] ); getPxConstraint_BreakForce( inSource, BreakForce[0], BreakForce[1] ); } void setPxShape_LocalPose( PxShape* inObj, const PxTransform & inArg){ inObj->setLocalPose( inArg ); } PxTransform getPxShape_LocalPose( const PxShape* inObj ) { return inObj->getLocalPose(); } void setPxShape_SimulationFilterData( PxShape* inObj, const PxFilterData & inArg){ inObj->setSimulationFilterData( inArg ); } PxFilterData getPxShape_SimulationFilterData( const PxShape* inObj ) { return inObj->getSimulationFilterData(); } void setPxShape_QueryFilterData( PxShape* inObj, const PxFilterData & inArg){ inObj->setQueryFilterData( inArg ); } PxFilterData getPxShape_QueryFilterData( const PxShape* inObj ) { return inObj->getQueryFilterData(); } PxU32 getPxShape_Materials( const PxShape* inObj, PxMaterial ** outBuffer, PxU32 inBufSize ) { return inObj->getMaterials( outBuffer, inBufSize ); } PxU32 getNbPxShape_Materials( const PxShape* inObj ) { return inObj->getNbMaterials( ); } void setPxShape_ContactOffset( PxShape* inObj, PxReal inArg){ inObj->setContactOffset( inArg ); } PxReal getPxShape_ContactOffset( const PxShape* inObj ) { return inObj->getContactOffset(); } void setPxShape_RestOffset( PxShape* inObj, PxReal inArg){ inObj->setRestOffset( inArg ); } PxReal getPxShape_RestOffset( const PxShape* inObj ) { return inObj->getRestOffset(); } void setPxShape_DensityForFluid( PxShape* inObj, PxReal inArg){ inObj->setDensityForFluid( inArg ); } PxReal getPxShape_DensityForFluid( const PxShape* inObj ) { return inObj->getDensityForFluid(); } void setPxShape_TorsionalPatchRadius( PxShape* inObj, PxReal inArg){ inObj->setTorsionalPatchRadius( inArg ); } PxReal getPxShape_TorsionalPatchRadius( const PxShape* inObj ) { return inObj->getTorsionalPatchRadius(); } void setPxShape_MinTorsionalPatchRadius( PxShape* inObj, PxReal inArg){ inObj->setMinTorsionalPatchRadius( inArg ); } PxReal getPxShape_MinTorsionalPatchRadius( const PxShape* inObj ) { return inObj->getMinTorsionalPatchRadius(); } PxU32 getPxShape_InternalShapeIndex( const PxShape* inObj ) { return inObj->getInternalShapeIndex(); } void setPxShape_Flags( PxShape* inObj, PxShapeFlags inArg){ inObj->setFlags( inArg ); } PxShapeFlags getPxShape_Flags( const PxShape* inObj ) { return inObj->getFlags(); } _Bool getPxShape_IsExclusive( const PxShape* inObj ) { return inObj->isExclusive(); } void setPxShape_Name( PxShape* inObj, const char * inArg){ inObj->setName( inArg ); } const char * getPxShape_Name( const PxShape* inObj ) { return inObj->getName(); } const char * getPxShape_ConcreteTypeName( const PxShape* inObj ) { return inObj->getConcreteTypeName(); } inline void * getPxShapeUserData( const PxShape* inOwner ) { return inOwner->userData; } inline void setPxShapeUserData( PxShape* inOwner, void * inData) { inOwner->userData = inData; } PX_PHYSX_CORE_API PxShapeGeneratedInfo::PxShapeGeneratedInfo() : LocalPose( "LocalPose", setPxShape_LocalPose, getPxShape_LocalPose) , SimulationFilterData( "SimulationFilterData", setPxShape_SimulationFilterData, getPxShape_SimulationFilterData) , QueryFilterData( "QueryFilterData", setPxShape_QueryFilterData, getPxShape_QueryFilterData) , Materials( "Materials", getPxShape_Materials, getNbPxShape_Materials ) , ContactOffset( "ContactOffset", setPxShape_ContactOffset, getPxShape_ContactOffset) , RestOffset( "RestOffset", setPxShape_RestOffset, getPxShape_RestOffset) , DensityForFluid( "DensityForFluid", setPxShape_DensityForFluid, getPxShape_DensityForFluid) , TorsionalPatchRadius( "TorsionalPatchRadius", setPxShape_TorsionalPatchRadius, getPxShape_TorsionalPatchRadius) , MinTorsionalPatchRadius( "MinTorsionalPatchRadius", setPxShape_MinTorsionalPatchRadius, getPxShape_MinTorsionalPatchRadius) , InternalShapeIndex( "InternalShapeIndex", getPxShape_InternalShapeIndex) , Flags( "Flags", setPxShape_Flags, getPxShape_Flags) , IsExclusive( "IsExclusive", getPxShape_IsExclusive) , Name( "Name", setPxShape_Name, getPxShape_Name) , ConcreteTypeName( "ConcreteTypeName", getPxShape_ConcreteTypeName) , UserData( "UserData", setPxShapeUserData, getPxShapeUserData ) {} PX_PHYSX_CORE_API PxShapeGeneratedValues::PxShapeGeneratedValues( const PxShape* inSource ) :PxRefCountedGeneratedValues( inSource ) ,LocalPose( getPxShape_LocalPose( inSource ) ) ,SimulationFilterData( getPxShape_SimulationFilterData( inSource ) ) ,QueryFilterData( getPxShape_QueryFilterData( inSource ) ) ,ContactOffset( getPxShape_ContactOffset( inSource ) ) ,RestOffset( getPxShape_RestOffset( inSource ) ) ,DensityForFluid( getPxShape_DensityForFluid( inSource ) ) ,TorsionalPatchRadius( getPxShape_TorsionalPatchRadius( inSource ) ) ,MinTorsionalPatchRadius( getPxShape_MinTorsionalPatchRadius( inSource ) ) ,InternalShapeIndex( getPxShape_InternalShapeIndex( inSource ) ) ,Flags( getPxShape_Flags( inSource ) ) ,IsExclusive( getPxShape_IsExclusive( inSource ) ) ,Name( getPxShape_Name( inSource ) ) ,ConcreteTypeName( getPxShape_ConcreteTypeName( inSource ) ) ,UserData( inSource->userData ) { PX_UNUSED(inSource); Geom = PxGeometryHolder(inSource->getGeometry()); } PxU32 getPxPruningStructure_RigidActors( const PxPruningStructure* inObj, PxRigidActor ** outBuffer, PxU32 inBufSize ) { return inObj->getRigidActors( outBuffer, inBufSize ); } PxU32 getNbPxPruningStructure_RigidActors( const PxPruningStructure* inObj ) { return inObj->getNbRigidActors( ); } const void * getPxPruningStructure_StaticMergeData( const PxPruningStructure* inObj ) { return inObj->getStaticMergeData(); } const void * getPxPruningStructure_DynamicMergeData( const PxPruningStructure* inObj ) { return inObj->getDynamicMergeData(); } const char * getPxPruningStructure_ConcreteTypeName( const PxPruningStructure* inObj ) { return inObj->getConcreteTypeName(); } PX_PHYSX_CORE_API PxPruningStructureGeneratedInfo::PxPruningStructureGeneratedInfo() : RigidActors( "RigidActors", getPxPruningStructure_RigidActors, getNbPxPruningStructure_RigidActors ) , StaticMergeData( "StaticMergeData", getPxPruningStructure_StaticMergeData) , DynamicMergeData( "DynamicMergeData", getPxPruningStructure_DynamicMergeData) , ConcreteTypeName( "ConcreteTypeName", getPxPruningStructure_ConcreteTypeName) {} PX_PHYSX_CORE_API PxPruningStructureGeneratedValues::PxPruningStructureGeneratedValues( const PxPruningStructure* inSource ) :StaticMergeData( getPxPruningStructure_StaticMergeData( inSource ) ) ,DynamicMergeData( getPxPruningStructure_DynamicMergeData( inSource ) ) ,ConcreteTypeName( getPxPruningStructure_ConcreteTypeName( inSource ) ) { PX_UNUSED(inSource); } _Bool getPxTolerancesScale_IsValid( const PxTolerancesScale* inObj ) { return inObj->isValid(); } inline PxReal getPxTolerancesScaleLength( const PxTolerancesScale* inOwner ) { return inOwner->length; } inline void setPxTolerancesScaleLength( PxTolerancesScale* inOwner, PxReal inData) { inOwner->length = inData; } inline PxReal getPxTolerancesScaleSpeed( const PxTolerancesScale* inOwner ) { return inOwner->speed; } inline void setPxTolerancesScaleSpeed( PxTolerancesScale* inOwner, PxReal inData) { inOwner->speed = inData; } PX_PHYSX_CORE_API PxTolerancesScaleGeneratedInfo::PxTolerancesScaleGeneratedInfo() : IsValid( "IsValid", getPxTolerancesScale_IsValid) , Length( "Length", setPxTolerancesScaleLength, getPxTolerancesScaleLength ) , Speed( "Speed", setPxTolerancesScaleSpeed, getPxTolerancesScaleSpeed ) {} PX_PHYSX_CORE_API PxTolerancesScaleGeneratedValues::PxTolerancesScaleGeneratedValues( const PxTolerancesScale* inSource ) :IsValid( getPxTolerancesScale_IsValid( inSource ) ) ,Length( inSource->length ) ,Speed( inSource->speed ) { PX_UNUSED(inSource); } PX_PHYSX_CORE_API PxGeometryGeneratedInfo::PxGeometryGeneratedInfo() {} PX_PHYSX_CORE_API PxGeometryGeneratedValues::PxGeometryGeneratedValues( const PxGeometry* inSource ) { PX_UNUSED(inSource); } inline PxVec3 getPxBoxGeometryHalfExtents( const PxBoxGeometry* inOwner ) { return inOwner->halfExtents; } inline void setPxBoxGeometryHalfExtents( PxBoxGeometry* inOwner, PxVec3 inData) { inOwner->halfExtents = inData; } PX_PHYSX_CORE_API PxBoxGeometryGeneratedInfo::PxBoxGeometryGeneratedInfo() : HalfExtents( "HalfExtents", setPxBoxGeometryHalfExtents, getPxBoxGeometryHalfExtents ) {} PX_PHYSX_CORE_API PxBoxGeometryGeneratedValues::PxBoxGeometryGeneratedValues( const PxBoxGeometry* inSource ) :PxGeometryGeneratedValues( inSource ) ,HalfExtents( inSource->halfExtents ) { PX_UNUSED(inSource); } inline PxReal getPxCapsuleGeometryRadius( const PxCapsuleGeometry* inOwner ) { return inOwner->radius; } inline void setPxCapsuleGeometryRadius( PxCapsuleGeometry* inOwner, PxReal inData) { inOwner->radius = inData; } inline PxReal getPxCapsuleGeometryHalfHeight( const PxCapsuleGeometry* inOwner ) { return inOwner->halfHeight; } inline void setPxCapsuleGeometryHalfHeight( PxCapsuleGeometry* inOwner, PxReal inData) { inOwner->halfHeight = inData; } PX_PHYSX_CORE_API PxCapsuleGeometryGeneratedInfo::PxCapsuleGeometryGeneratedInfo() : Radius( "Radius", setPxCapsuleGeometryRadius, getPxCapsuleGeometryRadius ) , HalfHeight( "HalfHeight", setPxCapsuleGeometryHalfHeight, getPxCapsuleGeometryHalfHeight ) {} PX_PHYSX_CORE_API PxCapsuleGeometryGeneratedValues::PxCapsuleGeometryGeneratedValues( const PxCapsuleGeometry* inSource ) :PxGeometryGeneratedValues( inSource ) ,Radius( inSource->radius ) ,HalfHeight( inSource->halfHeight ) { PX_UNUSED(inSource); } inline PxVec3 getPxMeshScaleScale( const PxMeshScale* inOwner ) { return inOwner->scale; } inline void setPxMeshScaleScale( PxMeshScale* inOwner, PxVec3 inData) { inOwner->scale = inData; } inline PxQuat getPxMeshScaleRotation( const PxMeshScale* inOwner ) { return inOwner->rotation; } inline void setPxMeshScaleRotation( PxMeshScale* inOwner, PxQuat inData) { inOwner->rotation = inData; } PX_PHYSX_CORE_API PxMeshScaleGeneratedInfo::PxMeshScaleGeneratedInfo() : Scale( "Scale", setPxMeshScaleScale, getPxMeshScaleScale ) , Rotation( "Rotation", setPxMeshScaleRotation, getPxMeshScaleRotation ) {} PX_PHYSX_CORE_API PxMeshScaleGeneratedValues::PxMeshScaleGeneratedValues( const PxMeshScale* inSource ) :Scale( inSource->scale ) ,Rotation( inSource->rotation ) { PX_UNUSED(inSource); } inline PxMeshScale getPxConvexMeshGeometryScale( const PxConvexMeshGeometry* inOwner ) { return inOwner->scale; } inline void setPxConvexMeshGeometryScale( PxConvexMeshGeometry* inOwner, PxMeshScale inData) { inOwner->scale = inData; } inline PxConvexMesh * getPxConvexMeshGeometryConvexMesh( const PxConvexMeshGeometry* inOwner ) { return inOwner->convexMesh; } inline void setPxConvexMeshGeometryConvexMesh( PxConvexMeshGeometry* inOwner, PxConvexMesh * inData) { inOwner->convexMesh = inData; } inline PxConvexMeshGeometryFlags getPxConvexMeshGeometryMeshFlags( const PxConvexMeshGeometry* inOwner ) { return inOwner->meshFlags; } inline void setPxConvexMeshGeometryMeshFlags( PxConvexMeshGeometry* inOwner, PxConvexMeshGeometryFlags inData) { inOwner->meshFlags = inData; } PX_PHYSX_CORE_API PxConvexMeshGeometryGeneratedInfo::PxConvexMeshGeometryGeneratedInfo() : Scale( "Scale", setPxConvexMeshGeometryScale, getPxConvexMeshGeometryScale ) , ConvexMesh( "ConvexMesh", setPxConvexMeshGeometryConvexMesh, getPxConvexMeshGeometryConvexMesh ) , MeshFlags( "MeshFlags", setPxConvexMeshGeometryMeshFlags, getPxConvexMeshGeometryMeshFlags ) {} PX_PHYSX_CORE_API PxConvexMeshGeometryGeneratedValues::PxConvexMeshGeometryGeneratedValues( const PxConvexMeshGeometry* inSource ) :PxGeometryGeneratedValues( inSource ) ,Scale( inSource->scale ) ,ConvexMesh( inSource->convexMesh ) ,MeshFlags( inSource->meshFlags ) { PX_UNUSED(inSource); } inline PxReal getPxSphereGeometryRadius( const PxSphereGeometry* inOwner ) { return inOwner->radius; } inline void setPxSphereGeometryRadius( PxSphereGeometry* inOwner, PxReal inData) { inOwner->radius = inData; } PX_PHYSX_CORE_API PxSphereGeometryGeneratedInfo::PxSphereGeometryGeneratedInfo() : Radius( "Radius", setPxSphereGeometryRadius, getPxSphereGeometryRadius ) {} PX_PHYSX_CORE_API PxSphereGeometryGeneratedValues::PxSphereGeometryGeneratedValues( const PxSphereGeometry* inSource ) :PxGeometryGeneratedValues( inSource ) ,Radius( inSource->radius ) { PX_UNUSED(inSource); } PX_PHYSX_CORE_API PxPlaneGeometryGeneratedInfo::PxPlaneGeometryGeneratedInfo() {} PX_PHYSX_CORE_API PxPlaneGeometryGeneratedValues::PxPlaneGeometryGeneratedValues( const PxPlaneGeometry* inSource ) :PxGeometryGeneratedValues( inSource ) { PX_UNUSED(inSource); } inline PxMeshScale getPxTriangleMeshGeometryScale( const PxTriangleMeshGeometry* inOwner ) { return inOwner->scale; } inline void setPxTriangleMeshGeometryScale( PxTriangleMeshGeometry* inOwner, PxMeshScale inData) { inOwner->scale = inData; } inline PxMeshGeometryFlags getPxTriangleMeshGeometryMeshFlags( const PxTriangleMeshGeometry* inOwner ) { return inOwner->meshFlags; } inline void setPxTriangleMeshGeometryMeshFlags( PxTriangleMeshGeometry* inOwner, PxMeshGeometryFlags inData) { inOwner->meshFlags = inData; } inline PxTriangleMesh * getPxTriangleMeshGeometryTriangleMesh( const PxTriangleMeshGeometry* inOwner ) { return inOwner->triangleMesh; } inline void setPxTriangleMeshGeometryTriangleMesh( PxTriangleMeshGeometry* inOwner, PxTriangleMesh * inData) { inOwner->triangleMesh = inData; } PX_PHYSX_CORE_API PxTriangleMeshGeometryGeneratedInfo::PxTriangleMeshGeometryGeneratedInfo() : Scale( "Scale", setPxTriangleMeshGeometryScale, getPxTriangleMeshGeometryScale ) , MeshFlags( "MeshFlags", setPxTriangleMeshGeometryMeshFlags, getPxTriangleMeshGeometryMeshFlags ) , TriangleMesh( "TriangleMesh", setPxTriangleMeshGeometryTriangleMesh, getPxTriangleMeshGeometryTriangleMesh ) {} PX_PHYSX_CORE_API PxTriangleMeshGeometryGeneratedValues::PxTriangleMeshGeometryGeneratedValues( const PxTriangleMeshGeometry* inSource ) :PxGeometryGeneratedValues( inSource ) ,Scale( inSource->scale ) ,MeshFlags( inSource->meshFlags ) ,TriangleMesh( inSource->triangleMesh ) { PX_UNUSED(inSource); } inline PxHeightField * getPxHeightFieldGeometryHeightField( const PxHeightFieldGeometry* inOwner ) { return inOwner->heightField; } inline void setPxHeightFieldGeometryHeightField( PxHeightFieldGeometry* inOwner, PxHeightField * inData) { inOwner->heightField = inData; } inline PxReal getPxHeightFieldGeometryHeightScale( const PxHeightFieldGeometry* inOwner ) { return inOwner->heightScale; } inline void setPxHeightFieldGeometryHeightScale( PxHeightFieldGeometry* inOwner, PxReal inData) { inOwner->heightScale = inData; } inline PxReal getPxHeightFieldGeometryRowScale( const PxHeightFieldGeometry* inOwner ) { return inOwner->rowScale; } inline void setPxHeightFieldGeometryRowScale( PxHeightFieldGeometry* inOwner, PxReal inData) { inOwner->rowScale = inData; } inline PxReal getPxHeightFieldGeometryColumnScale( const PxHeightFieldGeometry* inOwner ) { return inOwner->columnScale; } inline void setPxHeightFieldGeometryColumnScale( PxHeightFieldGeometry* inOwner, PxReal inData) { inOwner->columnScale = inData; } inline PxMeshGeometryFlags getPxHeightFieldGeometryHeightFieldFlags( const PxHeightFieldGeometry* inOwner ) { return inOwner->heightFieldFlags; } inline void setPxHeightFieldGeometryHeightFieldFlags( PxHeightFieldGeometry* inOwner, PxMeshGeometryFlags inData) { inOwner->heightFieldFlags = inData; } PX_PHYSX_CORE_API PxHeightFieldGeometryGeneratedInfo::PxHeightFieldGeometryGeneratedInfo() : HeightField( "HeightField", setPxHeightFieldGeometryHeightField, getPxHeightFieldGeometryHeightField ) , HeightScale( "HeightScale", setPxHeightFieldGeometryHeightScale, getPxHeightFieldGeometryHeightScale ) , RowScale( "RowScale", setPxHeightFieldGeometryRowScale, getPxHeightFieldGeometryRowScale ) , ColumnScale( "ColumnScale", setPxHeightFieldGeometryColumnScale, getPxHeightFieldGeometryColumnScale ) , HeightFieldFlags( "HeightFieldFlags", setPxHeightFieldGeometryHeightFieldFlags, getPxHeightFieldGeometryHeightFieldFlags ) {} PX_PHYSX_CORE_API PxHeightFieldGeometryGeneratedValues::PxHeightFieldGeometryGeneratedValues( const PxHeightFieldGeometry* inSource ) :PxGeometryGeneratedValues( inSource ) ,HeightField( inSource->heightField ) ,HeightScale( inSource->heightScale ) ,RowScale( inSource->rowScale ) ,ColumnScale( inSource->columnScale ) ,HeightFieldFlags( inSource->heightFieldFlags ) { PX_UNUSED(inSource); } void setPxSceneQuerySystemBase_DynamicTreeRebuildRateHint( PxSceneQuerySystemBase* inObj, PxU32 inArg){ inObj->setDynamicTreeRebuildRateHint( inArg ); } PxU32 getPxSceneQuerySystemBase_DynamicTreeRebuildRateHint( const PxSceneQuerySystemBase* inObj ) { return inObj->getDynamicTreeRebuildRateHint(); } void setPxSceneQuerySystemBase_UpdateMode( PxSceneQuerySystemBase* inObj, PxSceneQueryUpdateMode::Enum inArg){ inObj->setUpdateMode( inArg ); } PxSceneQueryUpdateMode::Enum getPxSceneQuerySystemBase_UpdateMode( const PxSceneQuerySystemBase* inObj ) { return inObj->getUpdateMode(); } PxU32 getPxSceneQuerySystemBase_StaticTimestamp( const PxSceneQuerySystemBase* inObj ) { return inObj->getStaticTimestamp(); } PX_PHYSX_CORE_API PxSceneQuerySystemBaseGeneratedInfo::PxSceneQuerySystemBaseGeneratedInfo() : DynamicTreeRebuildRateHint( "DynamicTreeRebuildRateHint", setPxSceneQuerySystemBase_DynamicTreeRebuildRateHint, getPxSceneQuerySystemBase_DynamicTreeRebuildRateHint) , UpdateMode( "UpdateMode", setPxSceneQuerySystemBase_UpdateMode, getPxSceneQuerySystemBase_UpdateMode) , StaticTimestamp( "StaticTimestamp", getPxSceneQuerySystemBase_StaticTimestamp) {} PX_PHYSX_CORE_API PxSceneQuerySystemBaseGeneratedValues::PxSceneQuerySystemBaseGeneratedValues( const PxSceneQuerySystemBase* inSource ) :DynamicTreeRebuildRateHint( getPxSceneQuerySystemBase_DynamicTreeRebuildRateHint( inSource ) ) ,UpdateMode( getPxSceneQuerySystemBase_UpdateMode( inSource ) ) ,StaticTimestamp( getPxSceneQuerySystemBase_StaticTimestamp( inSource ) ) { PX_UNUSED(inSource); } void setPxSceneSQSystem_SceneQueryUpdateMode( PxSceneSQSystem* inObj, PxSceneQueryUpdateMode::Enum inArg){ inObj->setSceneQueryUpdateMode( inArg ); } PxSceneQueryUpdateMode::Enum getPxSceneSQSystem_SceneQueryUpdateMode( const PxSceneSQSystem* inObj ) { return inObj->getSceneQueryUpdateMode(); } PxU32 getPxSceneSQSystem_SceneQueryStaticTimestamp( const PxSceneSQSystem* inObj ) { return inObj->getSceneQueryStaticTimestamp(); } PxPruningStructureType::Enum getPxSceneSQSystem_StaticStructure( const PxSceneSQSystem* inObj ) { return inObj->getStaticStructure(); } PxPruningStructureType::Enum getPxSceneSQSystem_DynamicStructure( const PxSceneSQSystem* inObj ) { return inObj->getDynamicStructure(); } PX_PHYSX_CORE_API PxSceneSQSystemGeneratedInfo::PxSceneSQSystemGeneratedInfo() : SceneQueryUpdateMode( "SceneQueryUpdateMode", setPxSceneSQSystem_SceneQueryUpdateMode, getPxSceneSQSystem_SceneQueryUpdateMode) , SceneQueryStaticTimestamp( "SceneQueryStaticTimestamp", getPxSceneSQSystem_SceneQueryStaticTimestamp) , StaticStructure( "StaticStructure", getPxSceneSQSystem_StaticStructure) , DynamicStructure( "DynamicStructure", getPxSceneSQSystem_DynamicStructure) {} PX_PHYSX_CORE_API PxSceneSQSystemGeneratedValues::PxSceneSQSystemGeneratedValues( const PxSceneSQSystem* inSource ) :PxSceneQuerySystemBaseGeneratedValues( inSource ) ,SceneQueryUpdateMode( getPxSceneSQSystem_SceneQueryUpdateMode( inSource ) ) ,SceneQueryStaticTimestamp( getPxSceneSQSystem_SceneQueryStaticTimestamp( inSource ) ) ,StaticStructure( getPxSceneSQSystem_StaticStructure( inSource ) ) ,DynamicStructure( getPxSceneSQSystem_DynamicStructure( inSource ) ) { PX_UNUSED(inSource); } PxSceneFlags getPxScene_Flags( const PxScene* inObj ) { return inObj->getFlags(); } void setPxScene_Limits( PxScene* inObj, const PxSceneLimits & inArg){ inObj->setLimits( inArg ); } PxSceneLimits getPxScene_Limits( const PxScene* inObj ) { return inObj->getLimits(); } PxU32 getPxScene_Timestamp( const PxScene* inObj ) { return inObj->getTimestamp(); } void setPxScene_Name( PxScene* inObj, const char * inArg){ inObj->setName( inArg ); } const char * getPxScene_Name( const PxScene* inObj ) { return inObj->getName(); } PxU32 getPxScene_Actors( const PxScene* inObj, PxActorTypeFlags inFilter, PxActor ** outBuffer, PxU32 inBufSize ) { return inObj->getActors( inFilter, outBuffer, inBufSize ); } PxU32 getNbPxScene_Actors( const PxScene* inObj, PxActorTypeFlags inFilter ) { return inObj->getNbActors( inFilter ); } PxU32 getPxScene_SoftBodies( const PxScene* inObj, PxSoftBody ** outBuffer, PxU32 inBufSize ) { return inObj->getSoftBodies( outBuffer, inBufSize ); } PxU32 getNbPxScene_SoftBodies( const PxScene* inObj ) { return inObj->getNbSoftBodies( ); } PxU32 getPxScene_Articulations( const PxScene* inObj, PxArticulationReducedCoordinate ** outBuffer, PxU32 inBufSize ) { return inObj->getArticulations( outBuffer, inBufSize ); } PxU32 getNbPxScene_Articulations( const PxScene* inObj ) { return inObj->getNbArticulations( ); } PxU32 getPxScene_Constraints( const PxScene* inObj, PxConstraint ** outBuffer, PxU32 inBufSize ) { return inObj->getConstraints( outBuffer, inBufSize ); } PxU32 getNbPxScene_Constraints( const PxScene* inObj ) { return inObj->getNbConstraints( ); } PxU32 getPxScene_Aggregates( const PxScene* inObj, PxAggregate ** outBuffer, PxU32 inBufSize ) { return inObj->getAggregates( outBuffer, inBufSize ); } PxU32 getNbPxScene_Aggregates( const PxScene* inObj ) { return inObj->getNbAggregates( ); } PxCpuDispatcher * getPxScene_CpuDispatcher( const PxScene* inObj ) { return inObj->getCpuDispatcher(); } PxCudaContextManager * getPxScene_CudaContextManager( const PxScene* inObj ) { return inObj->getCudaContextManager(); } void setPxScene_SimulationEventCallback( PxScene* inObj, PxSimulationEventCallback * inArg){ inObj->setSimulationEventCallback( inArg ); } PxSimulationEventCallback * getPxScene_SimulationEventCallback( const PxScene* inObj ) { return inObj->getSimulationEventCallback(); } void setPxScene_ContactModifyCallback( PxScene* inObj, PxContactModifyCallback * inArg){ inObj->setContactModifyCallback( inArg ); } PxContactModifyCallback * getPxScene_ContactModifyCallback( const PxScene* inObj ) { return inObj->getContactModifyCallback(); } void setPxScene_CCDContactModifyCallback( PxScene* inObj, PxCCDContactModifyCallback * inArg){ inObj->setCCDContactModifyCallback( inArg ); } PxCCDContactModifyCallback * getPxScene_CCDContactModifyCallback( const PxScene* inObj ) { return inObj->getCCDContactModifyCallback(); } void setPxScene_BroadPhaseCallback( PxScene* inObj, PxBroadPhaseCallback * inArg){ inObj->setBroadPhaseCallback( inArg ); } PxBroadPhaseCallback * getPxScene_BroadPhaseCallback( const PxScene* inObj ) { return inObj->getBroadPhaseCallback(); } PxU32 getPxScene_FilterShaderDataSize( const PxScene* inObj ) { return inObj->getFilterShaderDataSize(); } PxSimulationFilterShader getPxScene_FilterShader( const PxScene* inObj ) { return inObj->getFilterShader(); } PxSimulationFilterCallback * getPxScene_FilterCallback( const PxScene* inObj ) { return inObj->getFilterCallback(); } PxPairFilteringMode::Enum getPxScene_KinematicKinematicFilteringMode( const PxScene* inObj ) { return inObj->getKinematicKinematicFilteringMode(); } PxPairFilteringMode::Enum getPxScene_StaticKinematicFilteringMode( const PxScene* inObj ) { return inObj->getStaticKinematicFilteringMode(); } void setPxScene_Gravity( PxScene* inObj, const PxVec3 & inArg){ inObj->setGravity( inArg ); } PxVec3 getPxScene_Gravity( const PxScene* inObj ) { return inObj->getGravity(); } void setPxScene_BounceThresholdVelocity( PxScene* inObj, const PxReal inArg){ inObj->setBounceThresholdVelocity( inArg ); } PxReal getPxScene_BounceThresholdVelocity( const PxScene* inObj ) { return inObj->getBounceThresholdVelocity(); } void setPxScene_CCDMaxPasses( PxScene* inObj, PxU32 inArg){ inObj->setCCDMaxPasses( inArg ); } PxU32 getPxScene_CCDMaxPasses( const PxScene* inObj ) { return inObj->getCCDMaxPasses(); } void setPxScene_CCDMaxSeparation( PxScene* inObj, const PxReal inArg){ inObj->setCCDMaxSeparation( inArg ); } PxReal getPxScene_CCDMaxSeparation( const PxScene* inObj ) { return inObj->getCCDMaxSeparation(); } void setPxScene_CCDThreshold( PxScene* inObj, const PxReal inArg){ inObj->setCCDThreshold( inArg ); } PxReal getPxScene_CCDThreshold( const PxScene* inObj ) { return inObj->getCCDThreshold(); } void setPxScene_MaxBiasCoefficient( PxScene* inObj, const PxReal inArg){ inObj->setMaxBiasCoefficient( inArg ); } PxReal getPxScene_MaxBiasCoefficient( const PxScene* inObj ) { return inObj->getMaxBiasCoefficient(); } void setPxScene_FrictionOffsetThreshold( PxScene* inObj, const PxReal inArg){ inObj->setFrictionOffsetThreshold( inArg ); } PxReal getPxScene_FrictionOffsetThreshold( const PxScene* inObj ) { return inObj->getFrictionOffsetThreshold(); } void setPxScene_FrictionCorrelationDistance( PxScene* inObj, const PxReal inArg){ inObj->setFrictionCorrelationDistance( inArg ); } PxReal getPxScene_FrictionCorrelationDistance( const PxScene* inObj ) { return inObj->getFrictionCorrelationDistance(); } PxFrictionType::Enum getPxScene_FrictionType( const PxScene* inObj ) { return inObj->getFrictionType(); } PxSolverType::Enum getPxScene_SolverType( const PxScene* inObj ) { return inObj->getSolverType(); } void setPxScene_VisualizationCullingBox( PxScene* inObj, const PxBounds3 & inArg){ inObj->setVisualizationCullingBox( inArg ); } PxBounds3 getPxScene_VisualizationCullingBox( const PxScene* inObj ) { return inObj->getVisualizationCullingBox(); } PxBroadPhaseType::Enum getPxScene_BroadPhaseType( const PxScene* inObj ) { return inObj->getBroadPhaseType(); } PxU32 getPxScene_BroadPhaseRegions( const PxScene* inObj, PxBroadPhaseRegionInfo* outBuffer, PxU32 inBufSize ) { return inObj->getBroadPhaseRegions( outBuffer, inBufSize ); } PxU32 getNbPxScene_BroadPhaseRegions( const PxScene* inObj ) { return inObj->getNbBroadPhaseRegions( ); } PxTaskManager * getPxScene_TaskManager( const PxScene* inObj ) { return inObj->getTaskManager(); } void setPxScene_NbContactDataBlocks( PxScene* inObj, PxU32 inArg){ inObj->setNbContactDataBlocks( inArg ); } PxU32 getPxScene_MaxNbContactDataBlocksUsed( const PxScene* inObj ) { return inObj->getMaxNbContactDataBlocksUsed(); } PxU32 getPxScene_ContactReportStreamBufferSize( const PxScene* inObj ) { return inObj->getContactReportStreamBufferSize(); } void setPxScene_SolverBatchSize( PxScene* inObj, PxU32 inArg){ inObj->setSolverBatchSize( inArg ); } PxU32 getPxScene_SolverBatchSize( const PxScene* inObj ) { return inObj->getSolverBatchSize(); } void setPxScene_SolverArticulationBatchSize( PxScene* inObj, PxU32 inArg){ inObj->setSolverArticulationBatchSize( inArg ); } PxU32 getPxScene_SolverArticulationBatchSize( const PxScene* inObj ) { return inObj->getSolverArticulationBatchSize(); } PxReal getPxScene_WakeCounterResetValue( const PxScene* inObj ) { return inObj->getWakeCounterResetValue(); } PxgDynamicsMemoryConfig getPxScene_GpuDynamicsConfig( const PxScene* inObj ) { return inObj->getGpuDynamicsConfig(); } inline void * getPxSceneUserData( const PxScene* inOwner ) { return inOwner->userData; } inline void setPxSceneUserData( PxScene* inOwner, void * inData) { inOwner->userData = inData; } PX_PHYSX_CORE_API PxSceneGeneratedInfo::PxSceneGeneratedInfo() : Flags( "Flags", getPxScene_Flags) , Limits( "Limits", setPxScene_Limits, getPxScene_Limits) , Timestamp( "Timestamp", getPxScene_Timestamp) , Name( "Name", setPxScene_Name, getPxScene_Name) , Actors( "Actors", getPxScene_Actors, getNbPxScene_Actors ) , SoftBodies( "SoftBodies", getPxScene_SoftBodies, getNbPxScene_SoftBodies ) , Articulations( "Articulations", getPxScene_Articulations, getNbPxScene_Articulations ) , Constraints( "Constraints", getPxScene_Constraints, getNbPxScene_Constraints ) , Aggregates( "Aggregates", getPxScene_Aggregates, getNbPxScene_Aggregates ) , CpuDispatcher( "CpuDispatcher", getPxScene_CpuDispatcher) , CudaContextManager( "CudaContextManager", getPxScene_CudaContextManager) , SimulationEventCallback( "SimulationEventCallback", setPxScene_SimulationEventCallback, getPxScene_SimulationEventCallback) , ContactModifyCallback( "ContactModifyCallback", setPxScene_ContactModifyCallback, getPxScene_ContactModifyCallback) , CCDContactModifyCallback( "CCDContactModifyCallback", setPxScene_CCDContactModifyCallback, getPxScene_CCDContactModifyCallback) , BroadPhaseCallback( "BroadPhaseCallback", setPxScene_BroadPhaseCallback, getPxScene_BroadPhaseCallback) , FilterShaderDataSize( "FilterShaderDataSize", getPxScene_FilterShaderDataSize) , FilterShader( "FilterShader", getPxScene_FilterShader) , FilterCallback( "FilterCallback", getPxScene_FilterCallback) , KinematicKinematicFilteringMode( "KinematicKinematicFilteringMode", getPxScene_KinematicKinematicFilteringMode) , StaticKinematicFilteringMode( "StaticKinematicFilteringMode", getPxScene_StaticKinematicFilteringMode) , Gravity( "Gravity", setPxScene_Gravity, getPxScene_Gravity) , BounceThresholdVelocity( "BounceThresholdVelocity", setPxScene_BounceThresholdVelocity, getPxScene_BounceThresholdVelocity) , CCDMaxPasses( "CCDMaxPasses", setPxScene_CCDMaxPasses, getPxScene_CCDMaxPasses) , CCDMaxSeparation( "CCDMaxSeparation", setPxScene_CCDMaxSeparation, getPxScene_CCDMaxSeparation) , CCDThreshold( "CCDThreshold", setPxScene_CCDThreshold, getPxScene_CCDThreshold) , MaxBiasCoefficient( "MaxBiasCoefficient", setPxScene_MaxBiasCoefficient, getPxScene_MaxBiasCoefficient) , FrictionOffsetThreshold( "FrictionOffsetThreshold", setPxScene_FrictionOffsetThreshold, getPxScene_FrictionOffsetThreshold) , FrictionCorrelationDistance( "FrictionCorrelationDistance", setPxScene_FrictionCorrelationDistance, getPxScene_FrictionCorrelationDistance) , FrictionType( "FrictionType", getPxScene_FrictionType) , SolverType( "SolverType", getPxScene_SolverType) , VisualizationCullingBox( "VisualizationCullingBox", setPxScene_VisualizationCullingBox, getPxScene_VisualizationCullingBox) , BroadPhaseType( "BroadPhaseType", getPxScene_BroadPhaseType) , BroadPhaseRegions( "BroadPhaseRegions", getPxScene_BroadPhaseRegions, getNbPxScene_BroadPhaseRegions ) , TaskManager( "TaskManager", getPxScene_TaskManager) , NbContactDataBlocks( "NbContactDataBlocks", setPxScene_NbContactDataBlocks) , MaxNbContactDataBlocksUsed( "MaxNbContactDataBlocksUsed", getPxScene_MaxNbContactDataBlocksUsed) , ContactReportStreamBufferSize( "ContactReportStreamBufferSize", getPxScene_ContactReportStreamBufferSize) , SolverBatchSize( "SolverBatchSize", setPxScene_SolverBatchSize, getPxScene_SolverBatchSize) , SolverArticulationBatchSize( "SolverArticulationBatchSize", setPxScene_SolverArticulationBatchSize, getPxScene_SolverArticulationBatchSize) , WakeCounterResetValue( "WakeCounterResetValue", getPxScene_WakeCounterResetValue) , GpuDynamicsConfig( "GpuDynamicsConfig", getPxScene_GpuDynamicsConfig) , UserData( "UserData", setPxSceneUserData, getPxSceneUserData ) {} PX_PHYSX_CORE_API PxSceneGeneratedValues::PxSceneGeneratedValues( const PxScene* inSource ) :PxSceneSQSystemGeneratedValues( inSource ) ,Flags( getPxScene_Flags( inSource ) ) ,Limits( getPxScene_Limits( inSource ) ) ,Timestamp( getPxScene_Timestamp( inSource ) ) ,Name( getPxScene_Name( inSource ) ) ,CpuDispatcher( getPxScene_CpuDispatcher( inSource ) ) ,CudaContextManager( getPxScene_CudaContextManager( inSource ) ) ,SimulationEventCallback( getPxScene_SimulationEventCallback( inSource ) ) ,ContactModifyCallback( getPxScene_ContactModifyCallback( inSource ) ) ,CCDContactModifyCallback( getPxScene_CCDContactModifyCallback( inSource ) ) ,BroadPhaseCallback( getPxScene_BroadPhaseCallback( inSource ) ) ,FilterShaderDataSize( getPxScene_FilterShaderDataSize( inSource ) ) ,FilterShader( getPxScene_FilterShader( inSource ) ) ,FilterCallback( getPxScene_FilterCallback( inSource ) ) ,KinematicKinematicFilteringMode( getPxScene_KinematicKinematicFilteringMode( inSource ) ) ,StaticKinematicFilteringMode( getPxScene_StaticKinematicFilteringMode( inSource ) ) ,Gravity( getPxScene_Gravity( inSource ) ) ,BounceThresholdVelocity( getPxScene_BounceThresholdVelocity( inSource ) ) ,CCDMaxPasses( getPxScene_CCDMaxPasses( inSource ) ) ,CCDMaxSeparation( getPxScene_CCDMaxSeparation( inSource ) ) ,CCDThreshold( getPxScene_CCDThreshold( inSource ) ) ,MaxBiasCoefficient( getPxScene_MaxBiasCoefficient( inSource ) ) ,FrictionOffsetThreshold( getPxScene_FrictionOffsetThreshold( inSource ) ) ,FrictionCorrelationDistance( getPxScene_FrictionCorrelationDistance( inSource ) ) ,FrictionType( getPxScene_FrictionType( inSource ) ) ,SolverType( getPxScene_SolverType( inSource ) ) ,VisualizationCullingBox( getPxScene_VisualizationCullingBox( inSource ) ) ,BroadPhaseType( getPxScene_BroadPhaseType( inSource ) ) ,TaskManager( getPxScene_TaskManager( inSource ) ) ,MaxNbContactDataBlocksUsed( getPxScene_MaxNbContactDataBlocksUsed( inSource ) ) ,ContactReportStreamBufferSize( getPxScene_ContactReportStreamBufferSize( inSource ) ) ,SolverBatchSize( getPxScene_SolverBatchSize( inSource ) ) ,SolverArticulationBatchSize( getPxScene_SolverArticulationBatchSize( inSource ) ) ,WakeCounterResetValue( getPxScene_WakeCounterResetValue( inSource ) ) ,GpuDynamicsConfig( getPxScene_GpuDynamicsConfig( inSource ) ) ,UserData( inSource->userData ) { PX_UNUSED(inSource); inSource->getSimulationStatistics(SimulationStatistics); } inline PxTetrahedronMesh * getPxTetrahedronMeshGeometryTetrahedronMesh( const PxTetrahedronMeshGeometry* inOwner ) { return inOwner->tetrahedronMesh; } inline void setPxTetrahedronMeshGeometryTetrahedronMesh( PxTetrahedronMeshGeometry* inOwner, PxTetrahedronMesh * inData) { inOwner->tetrahedronMesh = inData; } PX_PHYSX_CORE_API PxTetrahedronMeshGeometryGeneratedInfo::PxTetrahedronMeshGeometryGeneratedInfo() : TetrahedronMesh( "TetrahedronMesh", setPxTetrahedronMeshGeometryTetrahedronMesh, getPxTetrahedronMeshGeometryTetrahedronMesh ) {} PX_PHYSX_CORE_API PxTetrahedronMeshGeometryGeneratedValues::PxTetrahedronMeshGeometryGeneratedValues( const PxTetrahedronMeshGeometry* inSource ) :PxGeometryGeneratedValues( inSource ) ,TetrahedronMesh( inSource->tetrahedronMesh ) { PX_UNUSED(inSource); } PX_PHYSX_CORE_API PxCustomGeometryGeneratedInfo::PxCustomGeometryGeneratedInfo() {} PX_PHYSX_CORE_API PxCustomGeometryGeneratedValues::PxCustomGeometryGeneratedValues( const PxCustomGeometry* inSource ) :PxGeometryGeneratedValues( inSource ) { PX_UNUSED(inSource); PxCustomGeometry::Type t = inSource->callbacks->getCustomType(); CustomType = *reinterpret_cast<const PxU32*>(&t); } inline PxU32 getPxHeightFieldDescNbRows( const PxHeightFieldDesc* inOwner ) { return inOwner->nbRows; } inline void setPxHeightFieldDescNbRows( PxHeightFieldDesc* inOwner, PxU32 inData) { inOwner->nbRows = inData; } inline PxU32 getPxHeightFieldDescNbColumns( const PxHeightFieldDesc* inOwner ) { return inOwner->nbColumns; } inline void setPxHeightFieldDescNbColumns( PxHeightFieldDesc* inOwner, PxU32 inData) { inOwner->nbColumns = inData; } inline PxHeightFieldFormat::Enum getPxHeightFieldDescFormat( const PxHeightFieldDesc* inOwner ) { return inOwner->format; } inline void setPxHeightFieldDescFormat( PxHeightFieldDesc* inOwner, PxHeightFieldFormat::Enum inData) { inOwner->format = inData; } inline PxStridedData getPxHeightFieldDescSamples( const PxHeightFieldDesc* inOwner ) { return inOwner->samples; } inline void setPxHeightFieldDescSamples( PxHeightFieldDesc* inOwner, PxStridedData inData) { inOwner->samples = inData; } inline PxReal getPxHeightFieldDescConvexEdgeThreshold( const PxHeightFieldDesc* inOwner ) { return inOwner->convexEdgeThreshold; } inline void setPxHeightFieldDescConvexEdgeThreshold( PxHeightFieldDesc* inOwner, PxReal inData) { inOwner->convexEdgeThreshold = inData; } inline PxHeightFieldFlags getPxHeightFieldDescFlags( const PxHeightFieldDesc* inOwner ) { return inOwner->flags; } inline void setPxHeightFieldDescFlags( PxHeightFieldDesc* inOwner, PxHeightFieldFlags inData) { inOwner->flags = inData; } PX_PHYSX_CORE_API PxHeightFieldDescGeneratedInfo::PxHeightFieldDescGeneratedInfo() : NbRows( "NbRows", setPxHeightFieldDescNbRows, getPxHeightFieldDescNbRows ) , NbColumns( "NbColumns", setPxHeightFieldDescNbColumns, getPxHeightFieldDescNbColumns ) , Format( "Format", setPxHeightFieldDescFormat, getPxHeightFieldDescFormat ) , Samples( "Samples", setPxHeightFieldDescSamples, getPxHeightFieldDescSamples ) , ConvexEdgeThreshold( "ConvexEdgeThreshold", setPxHeightFieldDescConvexEdgeThreshold, getPxHeightFieldDescConvexEdgeThreshold ) , Flags( "Flags", setPxHeightFieldDescFlags, getPxHeightFieldDescFlags ) {} PX_PHYSX_CORE_API PxHeightFieldDescGeneratedValues::PxHeightFieldDescGeneratedValues( const PxHeightFieldDesc* inSource ) :NbRows( inSource->nbRows ) ,NbColumns( inSource->nbColumns ) ,Format( inSource->format ) ,Samples( inSource->samples ) ,ConvexEdgeThreshold( inSource->convexEdgeThreshold ) ,Flags( inSource->flags ) { PX_UNUSED(inSource); } inline PxReal getPxArticulationLimitLow( const PxArticulationLimit* inOwner ) { return inOwner->low; } inline void setPxArticulationLimitLow( PxArticulationLimit* inOwner, PxReal inData) { inOwner->low = inData; } inline PxReal getPxArticulationLimitHigh( const PxArticulationLimit* inOwner ) { return inOwner->high; } inline void setPxArticulationLimitHigh( PxArticulationLimit* inOwner, PxReal inData) { inOwner->high = inData; } PX_PHYSX_CORE_API PxArticulationLimitGeneratedInfo::PxArticulationLimitGeneratedInfo() : Low( "Low", setPxArticulationLimitLow, getPxArticulationLimitLow ) , High( "High", setPxArticulationLimitHigh, getPxArticulationLimitHigh ) {} PX_PHYSX_CORE_API PxArticulationLimitGeneratedValues::PxArticulationLimitGeneratedValues( const PxArticulationLimit* inSource ) :Low( inSource->low ) ,High( inSource->high ) { PX_UNUSED(inSource); } inline PxReal getPxArticulationDriveStiffness( const PxArticulationDrive* inOwner ) { return inOwner->stiffness; } inline void setPxArticulationDriveStiffness( PxArticulationDrive* inOwner, PxReal inData) { inOwner->stiffness = inData; } inline PxReal getPxArticulationDriveDamping( const PxArticulationDrive* inOwner ) { return inOwner->damping; } inline void setPxArticulationDriveDamping( PxArticulationDrive* inOwner, PxReal inData) { inOwner->damping = inData; } inline PxReal getPxArticulationDriveMaxForce( const PxArticulationDrive* inOwner ) { return inOwner->maxForce; } inline void setPxArticulationDriveMaxForce( PxArticulationDrive* inOwner, PxReal inData) { inOwner->maxForce = inData; } inline PxArticulationDriveType::Enum getPxArticulationDriveDriveType( const PxArticulationDrive* inOwner ) { return inOwner->driveType; } inline void setPxArticulationDriveDriveType( PxArticulationDrive* inOwner, PxArticulationDriveType::Enum inData) { inOwner->driveType = inData; } PX_PHYSX_CORE_API PxArticulationDriveGeneratedInfo::PxArticulationDriveGeneratedInfo() : Stiffness( "Stiffness", setPxArticulationDriveStiffness, getPxArticulationDriveStiffness ) , Damping( "Damping", setPxArticulationDriveDamping, getPxArticulationDriveDamping ) , MaxForce( "MaxForce", setPxArticulationDriveMaxForce, getPxArticulationDriveMaxForce ) , DriveType( "DriveType", setPxArticulationDriveDriveType, getPxArticulationDriveDriveType ) {} PX_PHYSX_CORE_API PxArticulationDriveGeneratedValues::PxArticulationDriveGeneratedValues( const PxArticulationDrive* inSource ) :Stiffness( inSource->stiffness ) ,Damping( inSource->damping ) ,MaxForce( inSource->maxForce ) ,DriveType( inSource->driveType ) { PX_UNUSED(inSource); } _Bool getPxSceneQueryDesc_IsValid( const PxSceneQueryDesc* inObj ) { return inObj->isValid(); } inline PxPruningStructureType::Enum getPxSceneQueryDescStaticStructure( const PxSceneQueryDesc* inOwner ) { return inOwner->staticStructure; } inline void setPxSceneQueryDescStaticStructure( PxSceneQueryDesc* inOwner, PxPruningStructureType::Enum inData) { inOwner->staticStructure = inData; } inline PxPruningStructureType::Enum getPxSceneQueryDescDynamicStructure( const PxSceneQueryDesc* inOwner ) { return inOwner->dynamicStructure; } inline void setPxSceneQueryDescDynamicStructure( PxSceneQueryDesc* inOwner, PxPruningStructureType::Enum inData) { inOwner->dynamicStructure = inData; } inline PxU32 getPxSceneQueryDescDynamicTreeRebuildRateHint( const PxSceneQueryDesc* inOwner ) { return inOwner->dynamicTreeRebuildRateHint; } inline void setPxSceneQueryDescDynamicTreeRebuildRateHint( PxSceneQueryDesc* inOwner, PxU32 inData) { inOwner->dynamicTreeRebuildRateHint = inData; } inline PxDynamicTreeSecondaryPruner::Enum getPxSceneQueryDescDynamicTreeSecondaryPruner( const PxSceneQueryDesc* inOwner ) { return inOwner->dynamicTreeSecondaryPruner; } inline void setPxSceneQueryDescDynamicTreeSecondaryPruner( PxSceneQueryDesc* inOwner, PxDynamicTreeSecondaryPruner::Enum inData) { inOwner->dynamicTreeSecondaryPruner = inData; } inline PxBVHBuildStrategy::Enum getPxSceneQueryDescStaticBVHBuildStrategy( const PxSceneQueryDesc* inOwner ) { return inOwner->staticBVHBuildStrategy; } inline void setPxSceneQueryDescStaticBVHBuildStrategy( PxSceneQueryDesc* inOwner, PxBVHBuildStrategy::Enum inData) { inOwner->staticBVHBuildStrategy = inData; } inline PxBVHBuildStrategy::Enum getPxSceneQueryDescDynamicBVHBuildStrategy( const PxSceneQueryDesc* inOwner ) { return inOwner->dynamicBVHBuildStrategy; } inline void setPxSceneQueryDescDynamicBVHBuildStrategy( PxSceneQueryDesc* inOwner, PxBVHBuildStrategy::Enum inData) { inOwner->dynamicBVHBuildStrategy = inData; } inline PxU32 getPxSceneQueryDescStaticNbObjectsPerNode( const PxSceneQueryDesc* inOwner ) { return inOwner->staticNbObjectsPerNode; } inline void setPxSceneQueryDescStaticNbObjectsPerNode( PxSceneQueryDesc* inOwner, PxU32 inData) { inOwner->staticNbObjectsPerNode = inData; } inline PxU32 getPxSceneQueryDescDynamicNbObjectsPerNode( const PxSceneQueryDesc* inOwner ) { return inOwner->dynamicNbObjectsPerNode; } inline void setPxSceneQueryDescDynamicNbObjectsPerNode( PxSceneQueryDesc* inOwner, PxU32 inData) { inOwner->dynamicNbObjectsPerNode = inData; } inline PxSceneQueryUpdateMode::Enum getPxSceneQueryDescSceneQueryUpdateMode( const PxSceneQueryDesc* inOwner ) { return inOwner->sceneQueryUpdateMode; } inline void setPxSceneQueryDescSceneQueryUpdateMode( PxSceneQueryDesc* inOwner, PxSceneQueryUpdateMode::Enum inData) { inOwner->sceneQueryUpdateMode = inData; } PX_PHYSX_CORE_API PxSceneQueryDescGeneratedInfo::PxSceneQueryDescGeneratedInfo() : IsValid( "IsValid", getPxSceneQueryDesc_IsValid) , StaticStructure( "StaticStructure", setPxSceneQueryDescStaticStructure, getPxSceneQueryDescStaticStructure ) , DynamicStructure( "DynamicStructure", setPxSceneQueryDescDynamicStructure, getPxSceneQueryDescDynamicStructure ) , DynamicTreeRebuildRateHint( "DynamicTreeRebuildRateHint", setPxSceneQueryDescDynamicTreeRebuildRateHint, getPxSceneQueryDescDynamicTreeRebuildRateHint ) , DynamicTreeSecondaryPruner( "DynamicTreeSecondaryPruner", setPxSceneQueryDescDynamicTreeSecondaryPruner, getPxSceneQueryDescDynamicTreeSecondaryPruner ) , StaticBVHBuildStrategy( "StaticBVHBuildStrategy", setPxSceneQueryDescStaticBVHBuildStrategy, getPxSceneQueryDescStaticBVHBuildStrategy ) , DynamicBVHBuildStrategy( "DynamicBVHBuildStrategy", setPxSceneQueryDescDynamicBVHBuildStrategy, getPxSceneQueryDescDynamicBVHBuildStrategy ) , StaticNbObjectsPerNode( "StaticNbObjectsPerNode", setPxSceneQueryDescStaticNbObjectsPerNode, getPxSceneQueryDescStaticNbObjectsPerNode ) , DynamicNbObjectsPerNode( "DynamicNbObjectsPerNode", setPxSceneQueryDescDynamicNbObjectsPerNode, getPxSceneQueryDescDynamicNbObjectsPerNode ) , SceneQueryUpdateMode( "SceneQueryUpdateMode", setPxSceneQueryDescSceneQueryUpdateMode, getPxSceneQueryDescSceneQueryUpdateMode ) {} PX_PHYSX_CORE_API PxSceneQueryDescGeneratedValues::PxSceneQueryDescGeneratedValues( const PxSceneQueryDesc* inSource ) :IsValid( getPxSceneQueryDesc_IsValid( inSource ) ) ,StaticStructure( inSource->staticStructure ) ,DynamicStructure( inSource->dynamicStructure ) ,DynamicTreeRebuildRateHint( inSource->dynamicTreeRebuildRateHint ) ,DynamicTreeSecondaryPruner( inSource->dynamicTreeSecondaryPruner ) ,StaticBVHBuildStrategy( inSource->staticBVHBuildStrategy ) ,DynamicBVHBuildStrategy( inSource->dynamicBVHBuildStrategy ) ,StaticNbObjectsPerNode( inSource->staticNbObjectsPerNode ) ,DynamicNbObjectsPerNode( inSource->dynamicNbObjectsPerNode ) ,SceneQueryUpdateMode( inSource->sceneQueryUpdateMode ) { PX_UNUSED(inSource); } void setPxSceneDesc_ToDefault( PxSceneDesc* inObj, const PxTolerancesScale & inArg){ inObj->setToDefault( inArg ); } inline PxVec3 getPxSceneDescGravity( const PxSceneDesc* inOwner ) { return inOwner->gravity; } inline void setPxSceneDescGravity( PxSceneDesc* inOwner, PxVec3 inData) { inOwner->gravity = inData; } inline PxSimulationEventCallback * getPxSceneDescSimulationEventCallback( const PxSceneDesc* inOwner ) { return inOwner->simulationEventCallback; } inline void setPxSceneDescSimulationEventCallback( PxSceneDesc* inOwner, PxSimulationEventCallback * inData) { inOwner->simulationEventCallback = inData; } inline PxContactModifyCallback * getPxSceneDescContactModifyCallback( const PxSceneDesc* inOwner ) { return inOwner->contactModifyCallback; } inline void setPxSceneDescContactModifyCallback( PxSceneDesc* inOwner, PxContactModifyCallback * inData) { inOwner->contactModifyCallback = inData; } inline PxCCDContactModifyCallback * getPxSceneDescCcdContactModifyCallback( const PxSceneDesc* inOwner ) { return inOwner->ccdContactModifyCallback; } inline void setPxSceneDescCcdContactModifyCallback( PxSceneDesc* inOwner, PxCCDContactModifyCallback * inData) { inOwner->ccdContactModifyCallback = inData; } inline const void * getPxSceneDescFilterShaderData( const PxSceneDesc* inOwner ) { return inOwner->filterShaderData; } inline void setPxSceneDescFilterShaderData( PxSceneDesc* inOwner, const void * inData) { inOwner->filterShaderData = inData; } inline PxU32 getPxSceneDescFilterShaderDataSize( const PxSceneDesc* inOwner ) { return inOwner->filterShaderDataSize; } inline void setPxSceneDescFilterShaderDataSize( PxSceneDesc* inOwner, PxU32 inData) { inOwner->filterShaderDataSize = inData; } inline PxSimulationFilterShader getPxSceneDescFilterShader( const PxSceneDesc* inOwner ) { return inOwner->filterShader; } inline void setPxSceneDescFilterShader( PxSceneDesc* inOwner, PxSimulationFilterShader inData) { inOwner->filterShader = inData; } inline PxSimulationFilterCallback * getPxSceneDescFilterCallback( const PxSceneDesc* inOwner ) { return inOwner->filterCallback; } inline void setPxSceneDescFilterCallback( PxSceneDesc* inOwner, PxSimulationFilterCallback * inData) { inOwner->filterCallback = inData; } inline PxPairFilteringMode::Enum getPxSceneDescKineKineFilteringMode( const PxSceneDesc* inOwner ) { return inOwner->kineKineFilteringMode; } inline void setPxSceneDescKineKineFilteringMode( PxSceneDesc* inOwner, PxPairFilteringMode::Enum inData) { inOwner->kineKineFilteringMode = inData; } inline PxPairFilteringMode::Enum getPxSceneDescStaticKineFilteringMode( const PxSceneDesc* inOwner ) { return inOwner->staticKineFilteringMode; } inline void setPxSceneDescStaticKineFilteringMode( PxSceneDesc* inOwner, PxPairFilteringMode::Enum inData) { inOwner->staticKineFilteringMode = inData; } inline PxBroadPhaseType::Enum getPxSceneDescBroadPhaseType( const PxSceneDesc* inOwner ) { return inOwner->broadPhaseType; } inline void setPxSceneDescBroadPhaseType( PxSceneDesc* inOwner, PxBroadPhaseType::Enum inData) { inOwner->broadPhaseType = inData; } inline PxBroadPhaseCallback * getPxSceneDescBroadPhaseCallback( const PxSceneDesc* inOwner ) { return inOwner->broadPhaseCallback; } inline void setPxSceneDescBroadPhaseCallback( PxSceneDesc* inOwner, PxBroadPhaseCallback * inData) { inOwner->broadPhaseCallback = inData; } inline PxSceneLimits getPxSceneDescLimits( const PxSceneDesc* inOwner ) { return inOwner->limits; } inline void setPxSceneDescLimits( PxSceneDesc* inOwner, PxSceneLimits inData) { inOwner->limits = inData; } inline PxFrictionType::Enum getPxSceneDescFrictionType( const PxSceneDesc* inOwner ) { return inOwner->frictionType; } inline void setPxSceneDescFrictionType( PxSceneDesc* inOwner, PxFrictionType::Enum inData) { inOwner->frictionType = inData; } inline PxSolverType::Enum getPxSceneDescSolverType( const PxSceneDesc* inOwner ) { return inOwner->solverType; } inline void setPxSceneDescSolverType( PxSceneDesc* inOwner, PxSolverType::Enum inData) { inOwner->solverType = inData; } inline PxReal getPxSceneDescBounceThresholdVelocity( const PxSceneDesc* inOwner ) { return inOwner->bounceThresholdVelocity; } inline void setPxSceneDescBounceThresholdVelocity( PxSceneDesc* inOwner, PxReal inData) { inOwner->bounceThresholdVelocity = inData; } inline PxReal getPxSceneDescFrictionOffsetThreshold( const PxSceneDesc* inOwner ) { return inOwner->frictionOffsetThreshold; } inline void setPxSceneDescFrictionOffsetThreshold( PxSceneDesc* inOwner, PxReal inData) { inOwner->frictionOffsetThreshold = inData; } inline PxReal getPxSceneDescFrictionCorrelationDistance( const PxSceneDesc* inOwner ) { return inOwner->frictionCorrelationDistance; } inline void setPxSceneDescFrictionCorrelationDistance( PxSceneDesc* inOwner, PxReal inData) { inOwner->frictionCorrelationDistance = inData; } inline PxSceneFlags getPxSceneDescFlags( const PxSceneDesc* inOwner ) { return inOwner->flags; } inline void setPxSceneDescFlags( PxSceneDesc* inOwner, PxSceneFlags inData) { inOwner->flags = inData; } inline PxCpuDispatcher * getPxSceneDescCpuDispatcher( const PxSceneDesc* inOwner ) { return inOwner->cpuDispatcher; } inline void setPxSceneDescCpuDispatcher( PxSceneDesc* inOwner, PxCpuDispatcher * inData) { inOwner->cpuDispatcher = inData; } inline PxCudaContextManager * getPxSceneDescCudaContextManager( const PxSceneDesc* inOwner ) { return inOwner->cudaContextManager; } inline void setPxSceneDescCudaContextManager( PxSceneDesc* inOwner, PxCudaContextManager * inData) { inOwner->cudaContextManager = inData; } inline void * getPxSceneDescUserData( const PxSceneDesc* inOwner ) { return inOwner->userData; } inline void setPxSceneDescUserData( PxSceneDesc* inOwner, void * inData) { inOwner->userData = inData; } inline PxU32 getPxSceneDescSolverBatchSize( const PxSceneDesc* inOwner ) { return inOwner->solverBatchSize; } inline void setPxSceneDescSolverBatchSize( PxSceneDesc* inOwner, PxU32 inData) { inOwner->solverBatchSize = inData; } inline PxU32 getPxSceneDescSolverArticulationBatchSize( const PxSceneDesc* inOwner ) { return inOwner->solverArticulationBatchSize; } inline void setPxSceneDescSolverArticulationBatchSize( PxSceneDesc* inOwner, PxU32 inData) { inOwner->solverArticulationBatchSize = inData; } inline PxU32 getPxSceneDescNbContactDataBlocks( const PxSceneDesc* inOwner ) { return inOwner->nbContactDataBlocks; } inline void setPxSceneDescNbContactDataBlocks( PxSceneDesc* inOwner, PxU32 inData) { inOwner->nbContactDataBlocks = inData; } inline PxU32 getPxSceneDescMaxNbContactDataBlocks( const PxSceneDesc* inOwner ) { return inOwner->maxNbContactDataBlocks; } inline void setPxSceneDescMaxNbContactDataBlocks( PxSceneDesc* inOwner, PxU32 inData) { inOwner->maxNbContactDataBlocks = inData; } inline PxReal getPxSceneDescMaxBiasCoefficient( const PxSceneDesc* inOwner ) { return inOwner->maxBiasCoefficient; } inline void setPxSceneDescMaxBiasCoefficient( PxSceneDesc* inOwner, PxReal inData) { inOwner->maxBiasCoefficient = inData; } inline PxU32 getPxSceneDescContactReportStreamBufferSize( const PxSceneDesc* inOwner ) { return inOwner->contactReportStreamBufferSize; } inline void setPxSceneDescContactReportStreamBufferSize( PxSceneDesc* inOwner, PxU32 inData) { inOwner->contactReportStreamBufferSize = inData; } inline PxU32 getPxSceneDescCcdMaxPasses( const PxSceneDesc* inOwner ) { return inOwner->ccdMaxPasses; } inline void setPxSceneDescCcdMaxPasses( PxSceneDesc* inOwner, PxU32 inData) { inOwner->ccdMaxPasses = inData; } inline PxReal getPxSceneDescCcdThreshold( const PxSceneDesc* inOwner ) { return inOwner->ccdThreshold; } inline void setPxSceneDescCcdThreshold( PxSceneDesc* inOwner, PxReal inData) { inOwner->ccdThreshold = inData; } inline PxReal getPxSceneDescCcdMaxSeparation( const PxSceneDesc* inOwner ) { return inOwner->ccdMaxSeparation; } inline void setPxSceneDescCcdMaxSeparation( PxSceneDesc* inOwner, PxReal inData) { inOwner->ccdMaxSeparation = inData; } inline PxReal getPxSceneDescWakeCounterResetValue( const PxSceneDesc* inOwner ) { return inOwner->wakeCounterResetValue; } inline void setPxSceneDescWakeCounterResetValue( PxSceneDesc* inOwner, PxReal inData) { inOwner->wakeCounterResetValue = inData; } inline PxBounds3 getPxSceneDescSanityBounds( const PxSceneDesc* inOwner ) { return inOwner->sanityBounds; } inline void setPxSceneDescSanityBounds( PxSceneDesc* inOwner, PxBounds3 inData) { inOwner->sanityBounds = inData; } inline PxgDynamicsMemoryConfig getPxSceneDescGpuDynamicsConfig( const PxSceneDesc* inOwner ) { return inOwner->gpuDynamicsConfig; } inline void setPxSceneDescGpuDynamicsConfig( PxSceneDesc* inOwner, PxgDynamicsMemoryConfig inData) { inOwner->gpuDynamicsConfig = inData; } inline PxU32 getPxSceneDescGpuMaxNumPartitions( const PxSceneDesc* inOwner ) { return inOwner->gpuMaxNumPartitions; } inline void setPxSceneDescGpuMaxNumPartitions( PxSceneDesc* inOwner, PxU32 inData) { inOwner->gpuMaxNumPartitions = inData; } inline PxU32 getPxSceneDescGpuMaxNumStaticPartitions( const PxSceneDesc* inOwner ) { return inOwner->gpuMaxNumStaticPartitions; } inline void setPxSceneDescGpuMaxNumStaticPartitions( PxSceneDesc* inOwner, PxU32 inData) { inOwner->gpuMaxNumStaticPartitions = inData; } inline PxU32 getPxSceneDescGpuComputeVersion( const PxSceneDesc* inOwner ) { return inOwner->gpuComputeVersion; } inline void setPxSceneDescGpuComputeVersion( PxSceneDesc* inOwner, PxU32 inData) { inOwner->gpuComputeVersion = inData; } inline PxU32 getPxSceneDescContactPairSlabSize( const PxSceneDesc* inOwner ) { return inOwner->contactPairSlabSize; } inline void setPxSceneDescContactPairSlabSize( PxSceneDesc* inOwner, PxU32 inData) { inOwner->contactPairSlabSize = inData; } PX_PHYSX_CORE_API PxSceneDescGeneratedInfo::PxSceneDescGeneratedInfo() : ToDefault( "ToDefault", setPxSceneDesc_ToDefault) , Gravity( "Gravity", setPxSceneDescGravity, getPxSceneDescGravity ) , SimulationEventCallback( "SimulationEventCallback", setPxSceneDescSimulationEventCallback, getPxSceneDescSimulationEventCallback ) , ContactModifyCallback( "ContactModifyCallback", setPxSceneDescContactModifyCallback, getPxSceneDescContactModifyCallback ) , CcdContactModifyCallback( "CcdContactModifyCallback", setPxSceneDescCcdContactModifyCallback, getPxSceneDescCcdContactModifyCallback ) , FilterShaderData( "FilterShaderData", setPxSceneDescFilterShaderData, getPxSceneDescFilterShaderData ) , FilterShaderDataSize( "FilterShaderDataSize", setPxSceneDescFilterShaderDataSize, getPxSceneDescFilterShaderDataSize ) , FilterShader( "FilterShader", setPxSceneDescFilterShader, getPxSceneDescFilterShader ) , FilterCallback( "FilterCallback", setPxSceneDescFilterCallback, getPxSceneDescFilterCallback ) , KineKineFilteringMode( "KineKineFilteringMode", setPxSceneDescKineKineFilteringMode, getPxSceneDescKineKineFilteringMode ) , StaticKineFilteringMode( "StaticKineFilteringMode", setPxSceneDescStaticKineFilteringMode, getPxSceneDescStaticKineFilteringMode ) , BroadPhaseType( "BroadPhaseType", setPxSceneDescBroadPhaseType, getPxSceneDescBroadPhaseType ) , BroadPhaseCallback( "BroadPhaseCallback", setPxSceneDescBroadPhaseCallback, getPxSceneDescBroadPhaseCallback ) , Limits( "Limits", setPxSceneDescLimits, getPxSceneDescLimits ) , FrictionType( "FrictionType", setPxSceneDescFrictionType, getPxSceneDescFrictionType ) , SolverType( "SolverType", setPxSceneDescSolverType, getPxSceneDescSolverType ) , BounceThresholdVelocity( "BounceThresholdVelocity", setPxSceneDescBounceThresholdVelocity, getPxSceneDescBounceThresholdVelocity ) , FrictionOffsetThreshold( "FrictionOffsetThreshold", setPxSceneDescFrictionOffsetThreshold, getPxSceneDescFrictionOffsetThreshold ) , FrictionCorrelationDistance( "FrictionCorrelationDistance", setPxSceneDescFrictionCorrelationDistance, getPxSceneDescFrictionCorrelationDistance ) , Flags( "Flags", setPxSceneDescFlags, getPxSceneDescFlags ) , CpuDispatcher( "CpuDispatcher", setPxSceneDescCpuDispatcher, getPxSceneDescCpuDispatcher ) , CudaContextManager( "CudaContextManager", setPxSceneDescCudaContextManager, getPxSceneDescCudaContextManager ) , UserData( "UserData", setPxSceneDescUserData, getPxSceneDescUserData ) , SolverBatchSize( "SolverBatchSize", setPxSceneDescSolverBatchSize, getPxSceneDescSolverBatchSize ) , SolverArticulationBatchSize( "SolverArticulationBatchSize", setPxSceneDescSolverArticulationBatchSize, getPxSceneDescSolverArticulationBatchSize ) , NbContactDataBlocks( "NbContactDataBlocks", setPxSceneDescNbContactDataBlocks, getPxSceneDescNbContactDataBlocks ) , MaxNbContactDataBlocks( "MaxNbContactDataBlocks", setPxSceneDescMaxNbContactDataBlocks, getPxSceneDescMaxNbContactDataBlocks ) , MaxBiasCoefficient( "MaxBiasCoefficient", setPxSceneDescMaxBiasCoefficient, getPxSceneDescMaxBiasCoefficient ) , ContactReportStreamBufferSize( "ContactReportStreamBufferSize", setPxSceneDescContactReportStreamBufferSize, getPxSceneDescContactReportStreamBufferSize ) , CcdMaxPasses( "CcdMaxPasses", setPxSceneDescCcdMaxPasses, getPxSceneDescCcdMaxPasses ) , CcdThreshold( "CcdThreshold", setPxSceneDescCcdThreshold, getPxSceneDescCcdThreshold ) , CcdMaxSeparation( "CcdMaxSeparation", setPxSceneDescCcdMaxSeparation, getPxSceneDescCcdMaxSeparation ) , WakeCounterResetValue( "WakeCounterResetValue", setPxSceneDescWakeCounterResetValue, getPxSceneDescWakeCounterResetValue ) , SanityBounds( "SanityBounds", setPxSceneDescSanityBounds, getPxSceneDescSanityBounds ) , GpuDynamicsConfig( "GpuDynamicsConfig", setPxSceneDescGpuDynamicsConfig, getPxSceneDescGpuDynamicsConfig ) , GpuMaxNumPartitions( "GpuMaxNumPartitions", setPxSceneDescGpuMaxNumPartitions, getPxSceneDescGpuMaxNumPartitions ) , GpuMaxNumStaticPartitions( "GpuMaxNumStaticPartitions", setPxSceneDescGpuMaxNumStaticPartitions, getPxSceneDescGpuMaxNumStaticPartitions ) , GpuComputeVersion( "GpuComputeVersion", setPxSceneDescGpuComputeVersion, getPxSceneDescGpuComputeVersion ) , ContactPairSlabSize( "ContactPairSlabSize", setPxSceneDescContactPairSlabSize, getPxSceneDescContactPairSlabSize ) {} PX_PHYSX_CORE_API PxSceneDescGeneratedValues::PxSceneDescGeneratedValues( const PxSceneDesc* inSource ) :PxSceneQueryDescGeneratedValues( inSource ) ,Gravity( inSource->gravity ) ,SimulationEventCallback( inSource->simulationEventCallback ) ,ContactModifyCallback( inSource->contactModifyCallback ) ,CcdContactModifyCallback( inSource->ccdContactModifyCallback ) ,FilterShaderData( inSource->filterShaderData ) ,FilterShaderDataSize( inSource->filterShaderDataSize ) ,FilterShader( inSource->filterShader ) ,FilterCallback( inSource->filterCallback ) ,KineKineFilteringMode( inSource->kineKineFilteringMode ) ,StaticKineFilteringMode( inSource->staticKineFilteringMode ) ,BroadPhaseType( inSource->broadPhaseType ) ,BroadPhaseCallback( inSource->broadPhaseCallback ) ,Limits( inSource->limits ) ,FrictionType( inSource->frictionType ) ,SolverType( inSource->solverType ) ,BounceThresholdVelocity( inSource->bounceThresholdVelocity ) ,FrictionOffsetThreshold( inSource->frictionOffsetThreshold ) ,FrictionCorrelationDistance( inSource->frictionCorrelationDistance ) ,Flags( inSource->flags ) ,CpuDispatcher( inSource->cpuDispatcher ) ,CudaContextManager( inSource->cudaContextManager ) ,UserData( inSource->userData ) ,SolverBatchSize( inSource->solverBatchSize ) ,SolverArticulationBatchSize( inSource->solverArticulationBatchSize ) ,NbContactDataBlocks( inSource->nbContactDataBlocks ) ,MaxNbContactDataBlocks( inSource->maxNbContactDataBlocks ) ,MaxBiasCoefficient( inSource->maxBiasCoefficient ) ,ContactReportStreamBufferSize( inSource->contactReportStreamBufferSize ) ,CcdMaxPasses( inSource->ccdMaxPasses ) ,CcdThreshold( inSource->ccdThreshold ) ,CcdMaxSeparation( inSource->ccdMaxSeparation ) ,WakeCounterResetValue( inSource->wakeCounterResetValue ) ,SanityBounds( inSource->sanityBounds ) ,GpuDynamicsConfig( inSource->gpuDynamicsConfig ) ,GpuMaxNumPartitions( inSource->gpuMaxNumPartitions ) ,GpuMaxNumStaticPartitions( inSource->gpuMaxNumStaticPartitions ) ,GpuComputeVersion( inSource->gpuComputeVersion ) ,ContactPairSlabSize( inSource->contactPairSlabSize ) { PX_UNUSED(inSource); } _Bool getPxBroadPhaseDesc_IsValid( const PxBroadPhaseDesc* inObj ) { return inObj->isValid(); } inline PxBroadPhaseType::Enum getPxBroadPhaseDescMType( const PxBroadPhaseDesc* inOwner ) { return inOwner->mType; } inline void setPxBroadPhaseDescMType( PxBroadPhaseDesc* inOwner, PxBroadPhaseType::Enum inData) { inOwner->mType = inData; } inline PxU64 getPxBroadPhaseDescMContextID( const PxBroadPhaseDesc* inOwner ) { return inOwner->mContextID; } inline void setPxBroadPhaseDescMContextID( PxBroadPhaseDesc* inOwner, PxU64 inData) { inOwner->mContextID = inData; } inline PxCudaContextManager * getPxBroadPhaseDescMContextManager( const PxBroadPhaseDesc* inOwner ) { return inOwner->mContextManager; } inline void setPxBroadPhaseDescMContextManager( PxBroadPhaseDesc* inOwner, PxCudaContextManager * inData) { inOwner->mContextManager = inData; } inline PxU32 getPxBroadPhaseDescMFoundLostPairsCapacity( const PxBroadPhaseDesc* inOwner ) { return inOwner->mFoundLostPairsCapacity; } inline void setPxBroadPhaseDescMFoundLostPairsCapacity( PxBroadPhaseDesc* inOwner, PxU32 inData) { inOwner->mFoundLostPairsCapacity = inData; } inline _Bool getPxBroadPhaseDescMDiscardStaticVsKinematic( const PxBroadPhaseDesc* inOwner ) { return inOwner->mDiscardStaticVsKinematic; } inline void setPxBroadPhaseDescMDiscardStaticVsKinematic( PxBroadPhaseDesc* inOwner, _Bool inData) { inOwner->mDiscardStaticVsKinematic = inData; } inline _Bool getPxBroadPhaseDescMDiscardKinematicVsKinematic( const PxBroadPhaseDesc* inOwner ) { return inOwner->mDiscardKinematicVsKinematic; } inline void setPxBroadPhaseDescMDiscardKinematicVsKinematic( PxBroadPhaseDesc* inOwner, _Bool inData) { inOwner->mDiscardKinematicVsKinematic = inData; } PX_PHYSX_CORE_API PxBroadPhaseDescGeneratedInfo::PxBroadPhaseDescGeneratedInfo() : IsValid( "IsValid", getPxBroadPhaseDesc_IsValid) , MType( "MType", setPxBroadPhaseDescMType, getPxBroadPhaseDescMType ) , MContextID( "MContextID", setPxBroadPhaseDescMContextID, getPxBroadPhaseDescMContextID ) , MContextManager( "MContextManager", setPxBroadPhaseDescMContextManager, getPxBroadPhaseDescMContextManager ) , MFoundLostPairsCapacity( "MFoundLostPairsCapacity", setPxBroadPhaseDescMFoundLostPairsCapacity, getPxBroadPhaseDescMFoundLostPairsCapacity ) , MDiscardStaticVsKinematic( "MDiscardStaticVsKinematic", setPxBroadPhaseDescMDiscardStaticVsKinematic, getPxBroadPhaseDescMDiscardStaticVsKinematic ) , MDiscardKinematicVsKinematic( "MDiscardKinematicVsKinematic", setPxBroadPhaseDescMDiscardKinematicVsKinematic, getPxBroadPhaseDescMDiscardKinematicVsKinematic ) {} PX_PHYSX_CORE_API PxBroadPhaseDescGeneratedValues::PxBroadPhaseDescGeneratedValues( const PxBroadPhaseDesc* inSource ) :IsValid( getPxBroadPhaseDesc_IsValid( inSource ) ) ,MType( inSource->mType ) ,MContextID( inSource->mContextID ) ,MContextManager( inSource->mContextManager ) ,MFoundLostPairsCapacity( inSource->mFoundLostPairsCapacity ) ,MDiscardStaticVsKinematic( inSource->mDiscardStaticVsKinematic ) ,MDiscardKinematicVsKinematic( inSource->mDiscardKinematicVsKinematic ) { PX_UNUSED(inSource); } inline PxU32 getPxSceneLimitsMaxNbActors( const PxSceneLimits* inOwner ) { return inOwner->maxNbActors; } inline void setPxSceneLimitsMaxNbActors( PxSceneLimits* inOwner, PxU32 inData) { inOwner->maxNbActors = inData; } inline PxU32 getPxSceneLimitsMaxNbBodies( const PxSceneLimits* inOwner ) { return inOwner->maxNbBodies; } inline void setPxSceneLimitsMaxNbBodies( PxSceneLimits* inOwner, PxU32 inData) { inOwner->maxNbBodies = inData; } inline PxU32 getPxSceneLimitsMaxNbStaticShapes( const PxSceneLimits* inOwner ) { return inOwner->maxNbStaticShapes; } inline void setPxSceneLimitsMaxNbStaticShapes( PxSceneLimits* inOwner, PxU32 inData) { inOwner->maxNbStaticShapes = inData; } inline PxU32 getPxSceneLimitsMaxNbDynamicShapes( const PxSceneLimits* inOwner ) { return inOwner->maxNbDynamicShapes; } inline void setPxSceneLimitsMaxNbDynamicShapes( PxSceneLimits* inOwner, PxU32 inData) { inOwner->maxNbDynamicShapes = inData; } inline PxU32 getPxSceneLimitsMaxNbAggregates( const PxSceneLimits* inOwner ) { return inOwner->maxNbAggregates; } inline void setPxSceneLimitsMaxNbAggregates( PxSceneLimits* inOwner, PxU32 inData) { inOwner->maxNbAggregates = inData; } inline PxU32 getPxSceneLimitsMaxNbConstraints( const PxSceneLimits* inOwner ) { return inOwner->maxNbConstraints; } inline void setPxSceneLimitsMaxNbConstraints( PxSceneLimits* inOwner, PxU32 inData) { inOwner->maxNbConstraints = inData; } inline PxU32 getPxSceneLimitsMaxNbRegions( const PxSceneLimits* inOwner ) { return inOwner->maxNbRegions; } inline void setPxSceneLimitsMaxNbRegions( PxSceneLimits* inOwner, PxU32 inData) { inOwner->maxNbRegions = inData; } inline PxU32 getPxSceneLimitsMaxNbBroadPhaseOverlaps( const PxSceneLimits* inOwner ) { return inOwner->maxNbBroadPhaseOverlaps; } inline void setPxSceneLimitsMaxNbBroadPhaseOverlaps( PxSceneLimits* inOwner, PxU32 inData) { inOwner->maxNbBroadPhaseOverlaps = inData; } PX_PHYSX_CORE_API PxSceneLimitsGeneratedInfo::PxSceneLimitsGeneratedInfo() : MaxNbActors( "MaxNbActors", setPxSceneLimitsMaxNbActors, getPxSceneLimitsMaxNbActors ) , MaxNbBodies( "MaxNbBodies", setPxSceneLimitsMaxNbBodies, getPxSceneLimitsMaxNbBodies ) , MaxNbStaticShapes( "MaxNbStaticShapes", setPxSceneLimitsMaxNbStaticShapes, getPxSceneLimitsMaxNbStaticShapes ) , MaxNbDynamicShapes( "MaxNbDynamicShapes", setPxSceneLimitsMaxNbDynamicShapes, getPxSceneLimitsMaxNbDynamicShapes ) , MaxNbAggregates( "MaxNbAggregates", setPxSceneLimitsMaxNbAggregates, getPxSceneLimitsMaxNbAggregates ) , MaxNbConstraints( "MaxNbConstraints", setPxSceneLimitsMaxNbConstraints, getPxSceneLimitsMaxNbConstraints ) , MaxNbRegions( "MaxNbRegions", setPxSceneLimitsMaxNbRegions, getPxSceneLimitsMaxNbRegions ) , MaxNbBroadPhaseOverlaps( "MaxNbBroadPhaseOverlaps", setPxSceneLimitsMaxNbBroadPhaseOverlaps, getPxSceneLimitsMaxNbBroadPhaseOverlaps ) {} PX_PHYSX_CORE_API PxSceneLimitsGeneratedValues::PxSceneLimitsGeneratedValues( const PxSceneLimits* inSource ) :MaxNbActors( inSource->maxNbActors ) ,MaxNbBodies( inSource->maxNbBodies ) ,MaxNbStaticShapes( inSource->maxNbStaticShapes ) ,MaxNbDynamicShapes( inSource->maxNbDynamicShapes ) ,MaxNbAggregates( inSource->maxNbAggregates ) ,MaxNbConstraints( inSource->maxNbConstraints ) ,MaxNbRegions( inSource->maxNbRegions ) ,MaxNbBroadPhaseOverlaps( inSource->maxNbBroadPhaseOverlaps ) { PX_UNUSED(inSource); } _Bool getPxgDynamicsMemoryConfig_IsValid( const PxgDynamicsMemoryConfig* inObj ) { return inObj->isValid(); } inline PxU32 getPxgDynamicsMemoryConfigTempBufferCapacity( const PxgDynamicsMemoryConfig* inOwner ) { return inOwner->tempBufferCapacity; } inline void setPxgDynamicsMemoryConfigTempBufferCapacity( PxgDynamicsMemoryConfig* inOwner, PxU32 inData) { inOwner->tempBufferCapacity = inData; } inline PxU32 getPxgDynamicsMemoryConfigMaxRigidContactCount( const PxgDynamicsMemoryConfig* inOwner ) { return inOwner->maxRigidContactCount; } inline void setPxgDynamicsMemoryConfigMaxRigidContactCount( PxgDynamicsMemoryConfig* inOwner, PxU32 inData) { inOwner->maxRigidContactCount = inData; } inline PxU32 getPxgDynamicsMemoryConfigMaxRigidPatchCount( const PxgDynamicsMemoryConfig* inOwner ) { return inOwner->maxRigidPatchCount; } inline void setPxgDynamicsMemoryConfigMaxRigidPatchCount( PxgDynamicsMemoryConfig* inOwner, PxU32 inData) { inOwner->maxRigidPatchCount = inData; } inline PxU32 getPxgDynamicsMemoryConfigHeapCapacity( const PxgDynamicsMemoryConfig* inOwner ) { return inOwner->heapCapacity; } inline void setPxgDynamicsMemoryConfigHeapCapacity( PxgDynamicsMemoryConfig* inOwner, PxU32 inData) { inOwner->heapCapacity = inData; } inline PxU32 getPxgDynamicsMemoryConfigFoundLostPairsCapacity( const PxgDynamicsMemoryConfig* inOwner ) { return inOwner->foundLostPairsCapacity; } inline void setPxgDynamicsMemoryConfigFoundLostPairsCapacity( PxgDynamicsMemoryConfig* inOwner, PxU32 inData) { inOwner->foundLostPairsCapacity = inData; } inline PxU32 getPxgDynamicsMemoryConfigFoundLostAggregatePairsCapacity( const PxgDynamicsMemoryConfig* inOwner ) { return inOwner->foundLostAggregatePairsCapacity; } inline void setPxgDynamicsMemoryConfigFoundLostAggregatePairsCapacity( PxgDynamicsMemoryConfig* inOwner, PxU32 inData) { inOwner->foundLostAggregatePairsCapacity = inData; } inline PxU32 getPxgDynamicsMemoryConfigTotalAggregatePairsCapacity( const PxgDynamicsMemoryConfig* inOwner ) { return inOwner->totalAggregatePairsCapacity; } inline void setPxgDynamicsMemoryConfigTotalAggregatePairsCapacity( PxgDynamicsMemoryConfig* inOwner, PxU32 inData) { inOwner->totalAggregatePairsCapacity = inData; } inline PxU32 getPxgDynamicsMemoryConfigMaxSoftBodyContacts( const PxgDynamicsMemoryConfig* inOwner ) { return inOwner->maxSoftBodyContacts; } inline void setPxgDynamicsMemoryConfigMaxSoftBodyContacts( PxgDynamicsMemoryConfig* inOwner, PxU32 inData) { inOwner->maxSoftBodyContacts = inData; } inline PxU32 getPxgDynamicsMemoryConfigMaxFemClothContacts( const PxgDynamicsMemoryConfig* inOwner ) { return inOwner->maxFemClothContacts; } inline void setPxgDynamicsMemoryConfigMaxFemClothContacts( PxgDynamicsMemoryConfig* inOwner, PxU32 inData) { inOwner->maxFemClothContacts = inData; } inline PxU32 getPxgDynamicsMemoryConfigMaxParticleContacts( const PxgDynamicsMemoryConfig* inOwner ) { return inOwner->maxParticleContacts; } inline void setPxgDynamicsMemoryConfigMaxParticleContacts( PxgDynamicsMemoryConfig* inOwner, PxU32 inData) { inOwner->maxParticleContacts = inData; } inline PxU32 getPxgDynamicsMemoryConfigCollisionStackSize( const PxgDynamicsMemoryConfig* inOwner ) { return inOwner->collisionStackSize; } inline void setPxgDynamicsMemoryConfigCollisionStackSize( PxgDynamicsMemoryConfig* inOwner, PxU32 inData) { inOwner->collisionStackSize = inData; } inline PxU32 getPxgDynamicsMemoryConfigMaxHairContacts( const PxgDynamicsMemoryConfig* inOwner ) { return inOwner->maxHairContacts; } inline void setPxgDynamicsMemoryConfigMaxHairContacts( PxgDynamicsMemoryConfig* inOwner, PxU32 inData) { inOwner->maxHairContacts = inData; } PX_PHYSX_CORE_API PxgDynamicsMemoryConfigGeneratedInfo::PxgDynamicsMemoryConfigGeneratedInfo() : IsValid( "IsValid", getPxgDynamicsMemoryConfig_IsValid) , TempBufferCapacity( "TempBufferCapacity", setPxgDynamicsMemoryConfigTempBufferCapacity, getPxgDynamicsMemoryConfigTempBufferCapacity ) , MaxRigidContactCount( "MaxRigidContactCount", setPxgDynamicsMemoryConfigMaxRigidContactCount, getPxgDynamicsMemoryConfigMaxRigidContactCount ) , MaxRigidPatchCount( "MaxRigidPatchCount", setPxgDynamicsMemoryConfigMaxRigidPatchCount, getPxgDynamicsMemoryConfigMaxRigidPatchCount ) , HeapCapacity( "HeapCapacity", setPxgDynamicsMemoryConfigHeapCapacity, getPxgDynamicsMemoryConfigHeapCapacity ) , FoundLostPairsCapacity( "FoundLostPairsCapacity", setPxgDynamicsMemoryConfigFoundLostPairsCapacity, getPxgDynamicsMemoryConfigFoundLostPairsCapacity ) , FoundLostAggregatePairsCapacity( "FoundLostAggregatePairsCapacity", setPxgDynamicsMemoryConfigFoundLostAggregatePairsCapacity, getPxgDynamicsMemoryConfigFoundLostAggregatePairsCapacity ) , TotalAggregatePairsCapacity( "TotalAggregatePairsCapacity", setPxgDynamicsMemoryConfigTotalAggregatePairsCapacity, getPxgDynamicsMemoryConfigTotalAggregatePairsCapacity ) , MaxSoftBodyContacts( "MaxSoftBodyContacts", setPxgDynamicsMemoryConfigMaxSoftBodyContacts, getPxgDynamicsMemoryConfigMaxSoftBodyContacts ) , MaxFemClothContacts( "MaxFemClothContacts", setPxgDynamicsMemoryConfigMaxFemClothContacts, getPxgDynamicsMemoryConfigMaxFemClothContacts ) , MaxParticleContacts( "MaxParticleContacts", setPxgDynamicsMemoryConfigMaxParticleContacts, getPxgDynamicsMemoryConfigMaxParticleContacts ) , CollisionStackSize( "CollisionStackSize", setPxgDynamicsMemoryConfigCollisionStackSize, getPxgDynamicsMemoryConfigCollisionStackSize ) , MaxHairContacts( "MaxHairContacts", setPxgDynamicsMemoryConfigMaxHairContacts, getPxgDynamicsMemoryConfigMaxHairContacts ) {} PX_PHYSX_CORE_API PxgDynamicsMemoryConfigGeneratedValues::PxgDynamicsMemoryConfigGeneratedValues( const PxgDynamicsMemoryConfig* inSource ) :IsValid( getPxgDynamicsMemoryConfig_IsValid( inSource ) ) ,TempBufferCapacity( inSource->tempBufferCapacity ) ,MaxRigidContactCount( inSource->maxRigidContactCount ) ,MaxRigidPatchCount( inSource->maxRigidPatchCount ) ,HeapCapacity( inSource->heapCapacity ) ,FoundLostPairsCapacity( inSource->foundLostPairsCapacity ) ,FoundLostAggregatePairsCapacity( inSource->foundLostAggregatePairsCapacity ) ,TotalAggregatePairsCapacity( inSource->totalAggregatePairsCapacity ) ,MaxSoftBodyContacts( inSource->maxSoftBodyContacts ) ,MaxFemClothContacts( inSource->maxFemClothContacts ) ,MaxParticleContacts( inSource->maxParticleContacts ) ,CollisionStackSize( inSource->collisionStackSize ) ,MaxHairContacts( inSource->maxHairContacts ) { PX_UNUSED(inSource); } inline PxU32 getPxSimulationStatisticsNbActiveConstraints( const PxSimulationStatistics* inOwner ) { return inOwner->nbActiveConstraints; } inline void setPxSimulationStatisticsNbActiveConstraints( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbActiveConstraints = inData; } inline PxU32 getPxSimulationStatisticsNbActiveDynamicBodies( const PxSimulationStatistics* inOwner ) { return inOwner->nbActiveDynamicBodies; } inline void setPxSimulationStatisticsNbActiveDynamicBodies( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbActiveDynamicBodies = inData; } inline PxU32 getPxSimulationStatisticsNbActiveKinematicBodies( const PxSimulationStatistics* inOwner ) { return inOwner->nbActiveKinematicBodies; } inline void setPxSimulationStatisticsNbActiveKinematicBodies( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbActiveKinematicBodies = inData; } inline PxU32 getPxSimulationStatisticsNbStaticBodies( const PxSimulationStatistics* inOwner ) { return inOwner->nbStaticBodies; } inline void setPxSimulationStatisticsNbStaticBodies( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbStaticBodies = inData; } inline PxU32 getPxSimulationStatisticsNbDynamicBodies( const PxSimulationStatistics* inOwner ) { return inOwner->nbDynamicBodies; } inline void setPxSimulationStatisticsNbDynamicBodies( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbDynamicBodies = inData; } inline PxU32 getPxSimulationStatisticsNbKinematicBodies( const PxSimulationStatistics* inOwner ) { return inOwner->nbKinematicBodies; } inline void setPxSimulationStatisticsNbKinematicBodies( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbKinematicBodies = inData; } inline PxU32 getPxSimulationStatisticsNbAggregates( const PxSimulationStatistics* inOwner ) { return inOwner->nbAggregates; } inline void setPxSimulationStatisticsNbAggregates( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbAggregates = inData; } inline PxU32 getPxSimulationStatisticsNbArticulations( const PxSimulationStatistics* inOwner ) { return inOwner->nbArticulations; } inline void setPxSimulationStatisticsNbArticulations( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbArticulations = inData; } inline PxU32 getPxSimulationStatisticsNbAxisSolverConstraints( const PxSimulationStatistics* inOwner ) { return inOwner->nbAxisSolverConstraints; } inline void setPxSimulationStatisticsNbAxisSolverConstraints( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbAxisSolverConstraints = inData; } inline PxU32 getPxSimulationStatisticsCompressedContactSize( const PxSimulationStatistics* inOwner ) { return inOwner->compressedContactSize; } inline void setPxSimulationStatisticsCompressedContactSize( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->compressedContactSize = inData; } inline PxU32 getPxSimulationStatisticsRequiredContactConstraintMemory( const PxSimulationStatistics* inOwner ) { return inOwner->requiredContactConstraintMemory; } inline void setPxSimulationStatisticsRequiredContactConstraintMemory( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->requiredContactConstraintMemory = inData; } inline PxU32 getPxSimulationStatisticsPeakConstraintMemory( const PxSimulationStatistics* inOwner ) { return inOwner->peakConstraintMemory; } inline void setPxSimulationStatisticsPeakConstraintMemory( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->peakConstraintMemory = inData; } inline PxU32 getPxSimulationStatisticsNbDiscreteContactPairsTotal( const PxSimulationStatistics* inOwner ) { return inOwner->nbDiscreteContactPairsTotal; } inline void setPxSimulationStatisticsNbDiscreteContactPairsTotal( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbDiscreteContactPairsTotal = inData; } inline PxU32 getPxSimulationStatisticsNbDiscreteContactPairsWithCacheHits( const PxSimulationStatistics* inOwner ) { return inOwner->nbDiscreteContactPairsWithCacheHits; } inline void setPxSimulationStatisticsNbDiscreteContactPairsWithCacheHits( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbDiscreteContactPairsWithCacheHits = inData; } inline PxU32 getPxSimulationStatisticsNbDiscreteContactPairsWithContacts( const PxSimulationStatistics* inOwner ) { return inOwner->nbDiscreteContactPairsWithContacts; } inline void setPxSimulationStatisticsNbDiscreteContactPairsWithContacts( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbDiscreteContactPairsWithContacts = inData; } inline PxU32 getPxSimulationStatisticsNbNewPairs( const PxSimulationStatistics* inOwner ) { return inOwner->nbNewPairs; } inline void setPxSimulationStatisticsNbNewPairs( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbNewPairs = inData; } inline PxU32 getPxSimulationStatisticsNbLostPairs( const PxSimulationStatistics* inOwner ) { return inOwner->nbLostPairs; } inline void setPxSimulationStatisticsNbLostPairs( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbLostPairs = inData; } inline PxU32 getPxSimulationStatisticsNbNewTouches( const PxSimulationStatistics* inOwner ) { return inOwner->nbNewTouches; } inline void setPxSimulationStatisticsNbNewTouches( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbNewTouches = inData; } inline PxU32 getPxSimulationStatisticsNbLostTouches( const PxSimulationStatistics* inOwner ) { return inOwner->nbLostTouches; } inline void setPxSimulationStatisticsNbLostTouches( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbLostTouches = inData; } inline PxU32 getPxSimulationStatisticsNbPartitions( const PxSimulationStatistics* inOwner ) { return inOwner->nbPartitions; } inline void setPxSimulationStatisticsNbPartitions( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbPartitions = inData; } inline PxU64 getPxSimulationStatisticsGpuMemParticles( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemParticles; } inline void setPxSimulationStatisticsGpuMemParticles( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemParticles = inData; } inline PxU64 getPxSimulationStatisticsGpuMemSoftBodies( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemSoftBodies; } inline void setPxSimulationStatisticsGpuMemSoftBodies( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemSoftBodies = inData; } inline PxU64 getPxSimulationStatisticsGpuMemFEMCloths( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemFEMCloths; } inline void setPxSimulationStatisticsGpuMemFEMCloths( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemFEMCloths = inData; } inline PxU64 getPxSimulationStatisticsGpuMemHairSystems( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemHairSystems; } inline void setPxSimulationStatisticsGpuMemHairSystems( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemHairSystems = inData; } inline PxU64 getPxSimulationStatisticsGpuMemHeap( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemHeap; } inline void setPxSimulationStatisticsGpuMemHeap( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemHeap = inData; } inline PxU64 getPxSimulationStatisticsGpuMemHeapBroadPhase( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemHeapBroadPhase; } inline void setPxSimulationStatisticsGpuMemHeapBroadPhase( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemHeapBroadPhase = inData; } inline PxU64 getPxSimulationStatisticsGpuMemHeapNarrowPhase( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemHeapNarrowPhase; } inline void setPxSimulationStatisticsGpuMemHeapNarrowPhase( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemHeapNarrowPhase = inData; } inline PxU64 getPxSimulationStatisticsGpuMemHeapSolver( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemHeapSolver; } inline void setPxSimulationStatisticsGpuMemHeapSolver( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemHeapSolver = inData; } inline PxU64 getPxSimulationStatisticsGpuMemHeapArticulation( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemHeapArticulation; } inline void setPxSimulationStatisticsGpuMemHeapArticulation( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemHeapArticulation = inData; } inline PxU64 getPxSimulationStatisticsGpuMemHeapSimulation( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemHeapSimulation; } inline void setPxSimulationStatisticsGpuMemHeapSimulation( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemHeapSimulation = inData; } inline PxU64 getPxSimulationStatisticsGpuMemHeapSimulationArticulation( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemHeapSimulationArticulation; } inline void setPxSimulationStatisticsGpuMemHeapSimulationArticulation( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemHeapSimulationArticulation = inData; } inline PxU64 getPxSimulationStatisticsGpuMemHeapSimulationParticles( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemHeapSimulationParticles; } inline void setPxSimulationStatisticsGpuMemHeapSimulationParticles( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemHeapSimulationParticles = inData; } inline PxU64 getPxSimulationStatisticsGpuMemHeapSimulationSoftBody( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemHeapSimulationSoftBody; } inline void setPxSimulationStatisticsGpuMemHeapSimulationSoftBody( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemHeapSimulationSoftBody = inData; } inline PxU64 getPxSimulationStatisticsGpuMemHeapSimulationFEMCloth( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemHeapSimulationFEMCloth; } inline void setPxSimulationStatisticsGpuMemHeapSimulationFEMCloth( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemHeapSimulationFEMCloth = inData; } inline PxU64 getPxSimulationStatisticsGpuMemHeapSimulationHairSystem( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemHeapSimulationHairSystem; } inline void setPxSimulationStatisticsGpuMemHeapSimulationHairSystem( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemHeapSimulationHairSystem = inData; } inline PxU64 getPxSimulationStatisticsGpuMemHeapParticles( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemHeapParticles; } inline void setPxSimulationStatisticsGpuMemHeapParticles( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemHeapParticles = inData; } inline PxU64 getPxSimulationStatisticsGpuMemHeapSoftBodies( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemHeapSoftBodies; } inline void setPxSimulationStatisticsGpuMemHeapSoftBodies( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemHeapSoftBodies = inData; } inline PxU64 getPxSimulationStatisticsGpuMemHeapFEMCloths( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemHeapFEMCloths; } inline void setPxSimulationStatisticsGpuMemHeapFEMCloths( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemHeapFEMCloths = inData; } inline PxU64 getPxSimulationStatisticsGpuMemHeapHairSystems( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemHeapHairSystems; } inline void setPxSimulationStatisticsGpuMemHeapHairSystems( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemHeapHairSystems = inData; } inline PxU64 getPxSimulationStatisticsGpuMemHeapOther( const PxSimulationStatistics* inOwner ) { return inOwner->gpuMemHeapOther; } inline void setPxSimulationStatisticsGpuMemHeapOther( PxSimulationStatistics* inOwner, PxU64 inData) { inOwner->gpuMemHeapOther = inData; } inline PxU32 getPxSimulationStatisticsNbBroadPhaseAdds( const PxSimulationStatistics* inOwner ) { return inOwner->nbBroadPhaseAdds; } inline void setPxSimulationStatisticsNbBroadPhaseAdds( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbBroadPhaseAdds = inData; } inline PxU32 getPxSimulationStatisticsNbBroadPhaseRemoves( const PxSimulationStatistics* inOwner ) { return inOwner->nbBroadPhaseRemoves; } inline void setPxSimulationStatisticsNbBroadPhaseRemoves( PxSimulationStatistics* inOwner, PxU32 inData) { inOwner->nbBroadPhaseRemoves = inData; } PX_PHYSX_CORE_API PxSimulationStatisticsGeneratedInfo::PxSimulationStatisticsGeneratedInfo() : NbActiveConstraints( "NbActiveConstraints", setPxSimulationStatisticsNbActiveConstraints, getPxSimulationStatisticsNbActiveConstraints ) , NbActiveDynamicBodies( "NbActiveDynamicBodies", setPxSimulationStatisticsNbActiveDynamicBodies, getPxSimulationStatisticsNbActiveDynamicBodies ) , NbActiveKinematicBodies( "NbActiveKinematicBodies", setPxSimulationStatisticsNbActiveKinematicBodies, getPxSimulationStatisticsNbActiveKinematicBodies ) , NbStaticBodies( "NbStaticBodies", setPxSimulationStatisticsNbStaticBodies, getPxSimulationStatisticsNbStaticBodies ) , NbDynamicBodies( "NbDynamicBodies", setPxSimulationStatisticsNbDynamicBodies, getPxSimulationStatisticsNbDynamicBodies ) , NbKinematicBodies( "NbKinematicBodies", setPxSimulationStatisticsNbKinematicBodies, getPxSimulationStatisticsNbKinematicBodies ) , NbAggregates( "NbAggregates", setPxSimulationStatisticsNbAggregates, getPxSimulationStatisticsNbAggregates ) , NbArticulations( "NbArticulations", setPxSimulationStatisticsNbArticulations, getPxSimulationStatisticsNbArticulations ) , NbAxisSolverConstraints( "NbAxisSolverConstraints", setPxSimulationStatisticsNbAxisSolverConstraints, getPxSimulationStatisticsNbAxisSolverConstraints ) , CompressedContactSize( "CompressedContactSize", setPxSimulationStatisticsCompressedContactSize, getPxSimulationStatisticsCompressedContactSize ) , RequiredContactConstraintMemory( "RequiredContactConstraintMemory", setPxSimulationStatisticsRequiredContactConstraintMemory, getPxSimulationStatisticsRequiredContactConstraintMemory ) , PeakConstraintMemory( "PeakConstraintMemory", setPxSimulationStatisticsPeakConstraintMemory, getPxSimulationStatisticsPeakConstraintMemory ) , NbDiscreteContactPairsTotal( "NbDiscreteContactPairsTotal", setPxSimulationStatisticsNbDiscreteContactPairsTotal, getPxSimulationStatisticsNbDiscreteContactPairsTotal ) , NbDiscreteContactPairsWithCacheHits( "NbDiscreteContactPairsWithCacheHits", setPxSimulationStatisticsNbDiscreteContactPairsWithCacheHits, getPxSimulationStatisticsNbDiscreteContactPairsWithCacheHits ) , NbDiscreteContactPairsWithContacts( "NbDiscreteContactPairsWithContacts", setPxSimulationStatisticsNbDiscreteContactPairsWithContacts, getPxSimulationStatisticsNbDiscreteContactPairsWithContacts ) , NbNewPairs( "NbNewPairs", setPxSimulationStatisticsNbNewPairs, getPxSimulationStatisticsNbNewPairs ) , NbLostPairs( "NbLostPairs", setPxSimulationStatisticsNbLostPairs, getPxSimulationStatisticsNbLostPairs ) , NbNewTouches( "NbNewTouches", setPxSimulationStatisticsNbNewTouches, getPxSimulationStatisticsNbNewTouches ) , NbLostTouches( "NbLostTouches", setPxSimulationStatisticsNbLostTouches, getPxSimulationStatisticsNbLostTouches ) , NbPartitions( "NbPartitions", setPxSimulationStatisticsNbPartitions, getPxSimulationStatisticsNbPartitions ) , GpuMemParticles( "GpuMemParticles", setPxSimulationStatisticsGpuMemParticles, getPxSimulationStatisticsGpuMemParticles ) , GpuMemSoftBodies( "GpuMemSoftBodies", setPxSimulationStatisticsGpuMemSoftBodies, getPxSimulationStatisticsGpuMemSoftBodies ) , GpuMemFEMCloths( "GpuMemFEMCloths", setPxSimulationStatisticsGpuMemFEMCloths, getPxSimulationStatisticsGpuMemFEMCloths ) , GpuMemHairSystems( "GpuMemHairSystems", setPxSimulationStatisticsGpuMemHairSystems, getPxSimulationStatisticsGpuMemHairSystems ) , GpuMemHeap( "GpuMemHeap", setPxSimulationStatisticsGpuMemHeap, getPxSimulationStatisticsGpuMemHeap ) , GpuMemHeapBroadPhase( "GpuMemHeapBroadPhase", setPxSimulationStatisticsGpuMemHeapBroadPhase, getPxSimulationStatisticsGpuMemHeapBroadPhase ) , GpuMemHeapNarrowPhase( "GpuMemHeapNarrowPhase", setPxSimulationStatisticsGpuMemHeapNarrowPhase, getPxSimulationStatisticsGpuMemHeapNarrowPhase ) , GpuMemHeapSolver( "GpuMemHeapSolver", setPxSimulationStatisticsGpuMemHeapSolver, getPxSimulationStatisticsGpuMemHeapSolver ) , GpuMemHeapArticulation( "GpuMemHeapArticulation", setPxSimulationStatisticsGpuMemHeapArticulation, getPxSimulationStatisticsGpuMemHeapArticulation ) , GpuMemHeapSimulation( "GpuMemHeapSimulation", setPxSimulationStatisticsGpuMemHeapSimulation, getPxSimulationStatisticsGpuMemHeapSimulation ) , GpuMemHeapSimulationArticulation( "GpuMemHeapSimulationArticulation", setPxSimulationStatisticsGpuMemHeapSimulationArticulation, getPxSimulationStatisticsGpuMemHeapSimulationArticulation ) , GpuMemHeapSimulationParticles( "GpuMemHeapSimulationParticles", setPxSimulationStatisticsGpuMemHeapSimulationParticles, getPxSimulationStatisticsGpuMemHeapSimulationParticles ) , GpuMemHeapSimulationSoftBody( "GpuMemHeapSimulationSoftBody", setPxSimulationStatisticsGpuMemHeapSimulationSoftBody, getPxSimulationStatisticsGpuMemHeapSimulationSoftBody ) , GpuMemHeapSimulationFEMCloth( "GpuMemHeapSimulationFEMCloth", setPxSimulationStatisticsGpuMemHeapSimulationFEMCloth, getPxSimulationStatisticsGpuMemHeapSimulationFEMCloth ) , GpuMemHeapSimulationHairSystem( "GpuMemHeapSimulationHairSystem", setPxSimulationStatisticsGpuMemHeapSimulationHairSystem, getPxSimulationStatisticsGpuMemHeapSimulationHairSystem ) , GpuMemHeapParticles( "GpuMemHeapParticles", setPxSimulationStatisticsGpuMemHeapParticles, getPxSimulationStatisticsGpuMemHeapParticles ) , GpuMemHeapSoftBodies( "GpuMemHeapSoftBodies", setPxSimulationStatisticsGpuMemHeapSoftBodies, getPxSimulationStatisticsGpuMemHeapSoftBodies ) , GpuMemHeapFEMCloths( "GpuMemHeapFEMCloths", setPxSimulationStatisticsGpuMemHeapFEMCloths, getPxSimulationStatisticsGpuMemHeapFEMCloths ) , GpuMemHeapHairSystems( "GpuMemHeapHairSystems", setPxSimulationStatisticsGpuMemHeapHairSystems, getPxSimulationStatisticsGpuMemHeapHairSystems ) , GpuMemHeapOther( "GpuMemHeapOther", setPxSimulationStatisticsGpuMemHeapOther, getPxSimulationStatisticsGpuMemHeapOther ) , NbBroadPhaseAdds( "NbBroadPhaseAdds", setPxSimulationStatisticsNbBroadPhaseAdds, getPxSimulationStatisticsNbBroadPhaseAdds ) , NbBroadPhaseRemoves( "NbBroadPhaseRemoves", setPxSimulationStatisticsNbBroadPhaseRemoves, getPxSimulationStatisticsNbBroadPhaseRemoves ) {} PX_PHYSX_CORE_API PxSimulationStatisticsGeneratedValues::PxSimulationStatisticsGeneratedValues( const PxSimulationStatistics* inSource ) :NbActiveConstraints( inSource->nbActiveConstraints ) ,NbActiveDynamicBodies( inSource->nbActiveDynamicBodies ) ,NbActiveKinematicBodies( inSource->nbActiveKinematicBodies ) ,NbStaticBodies( inSource->nbStaticBodies ) ,NbDynamicBodies( inSource->nbDynamicBodies ) ,NbKinematicBodies( inSource->nbKinematicBodies ) ,NbAggregates( inSource->nbAggregates ) ,NbArticulations( inSource->nbArticulations ) ,NbAxisSolverConstraints( inSource->nbAxisSolverConstraints ) ,CompressedContactSize( inSource->compressedContactSize ) ,RequiredContactConstraintMemory( inSource->requiredContactConstraintMemory ) ,PeakConstraintMemory( inSource->peakConstraintMemory ) ,NbDiscreteContactPairsTotal( inSource->nbDiscreteContactPairsTotal ) ,NbDiscreteContactPairsWithCacheHits( inSource->nbDiscreteContactPairsWithCacheHits ) ,NbDiscreteContactPairsWithContacts( inSource->nbDiscreteContactPairsWithContacts ) ,NbNewPairs( inSource->nbNewPairs ) ,NbLostPairs( inSource->nbLostPairs ) ,NbNewTouches( inSource->nbNewTouches ) ,NbLostTouches( inSource->nbLostTouches ) ,NbPartitions( inSource->nbPartitions ) ,GpuMemParticles( inSource->gpuMemParticles ) ,GpuMemSoftBodies( inSource->gpuMemSoftBodies ) ,GpuMemFEMCloths( inSource->gpuMemFEMCloths ) ,GpuMemHairSystems( inSource->gpuMemHairSystems ) ,GpuMemHeap( inSource->gpuMemHeap ) ,GpuMemHeapBroadPhase( inSource->gpuMemHeapBroadPhase ) ,GpuMemHeapNarrowPhase( inSource->gpuMemHeapNarrowPhase ) ,GpuMemHeapSolver( inSource->gpuMemHeapSolver ) ,GpuMemHeapArticulation( inSource->gpuMemHeapArticulation ) ,GpuMemHeapSimulation( inSource->gpuMemHeapSimulation ) ,GpuMemHeapSimulationArticulation( inSource->gpuMemHeapSimulationArticulation ) ,GpuMemHeapSimulationParticles( inSource->gpuMemHeapSimulationParticles ) ,GpuMemHeapSimulationSoftBody( inSource->gpuMemHeapSimulationSoftBody ) ,GpuMemHeapSimulationFEMCloth( inSource->gpuMemHeapSimulationFEMCloth ) ,GpuMemHeapSimulationHairSystem( inSource->gpuMemHeapSimulationHairSystem ) ,GpuMemHeapParticles( inSource->gpuMemHeapParticles ) ,GpuMemHeapSoftBodies( inSource->gpuMemHeapSoftBodies ) ,GpuMemHeapFEMCloths( inSource->gpuMemHeapFEMCloths ) ,GpuMemHeapHairSystems( inSource->gpuMemHeapHairSystems ) ,GpuMemHeapOther( inSource->gpuMemHeapOther ) ,NbBroadPhaseAdds( inSource->nbBroadPhaseAdds ) ,NbBroadPhaseRemoves( inSource->nbBroadPhaseRemoves ) { PX_UNUSED(inSource); PxMemCopy( NbDiscreteContactPairs, inSource->nbDiscreteContactPairs, sizeof( NbDiscreteContactPairs ) ); PxMemCopy( NbModifiedContactPairs, inSource->nbModifiedContactPairs, sizeof( NbModifiedContactPairs ) ); PxMemCopy( NbCCDPairs, inSource->nbCCDPairs, sizeof( NbCCDPairs ) ); PxMemCopy( NbTriggerPairs, inSource->nbTriggerPairs, sizeof( NbTriggerPairs ) ); PxMemCopy( NbShapes, inSource->nbShapes, sizeof( NbShapes ) ); }
154,103
C++
91.443911
208
0.831859
NVIDIA-Omniverse/PhysX/physx/source/physxmetadata/core/include/PvdMetaDataPropertyVisitor.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_META_DATA_PROPERTY_VISITOR_H #define PX_META_DATA_PROPERTY_VISITOR_H #include <stdio.h> #include "PvdMetaDataExtensions.h" namespace physx { namespace Vd { //PVD only deals with read-only properties, indexed, and properties like this by in large. //so we have a filter that expands properties to a level where we can get to them and expands them into //named functions that make more sense and are easier to read than operator() template<typename TOperatorType> struct PvdPropertyFilter { private: PvdPropertyFilter& operator=(const PvdPropertyFilter&); public: TOperatorType mOperator; PxU32* mKeyOverride; PxU32* mOffsetOverride; PvdPropertyFilter( TOperatorType& inOperator ) : mOperator( inOperator ) , mKeyOverride( 0 ) , mOffsetOverride( 0 ) {} PvdPropertyFilter( TOperatorType& inOperator, PxU32* inKeyOverride, PxU32* inOffsetOverride ) : mOperator( inOperator ) , mKeyOverride( inKeyOverride ) , mOffsetOverride( inOffsetOverride ) {} PvdPropertyFilter( const PvdPropertyFilter& inOther ) : mOperator( inOther.mOperator ), mKeyOverride( inOther.mKeyOverride ), mOffsetOverride( inOther.mOffsetOverride ) {} template<PxU32 TKey, typename TAccessorType> void dispatchAccessor( PxU32 inKey, const TAccessorType& inAccessor, bool, bool, bool) { mOperator.simpleProperty(inKey, inAccessor ); } template<PxU32 TKey, typename TAccessorType> void dispatchAccessor( PxU32 inKey, const TAccessorType& inAccessor, bool, bool, const PxU32ToName* inConversions ) { mOperator.flagsProperty(inKey, inAccessor, inConversions ); } template<PxU32 TKey, typename TAccessorType> void dispatchAccessor( PxU32 inKey, const TAccessorType& inAccessor, const PxU32ToName* inConversions, bool, bool ) { mOperator.enumProperty( inKey, inAccessor, inConversions ); } template<PxU32 TKey, typename TAccessorType, typename TInfoType> void dispatchAccessor(PxU32, const TAccessorType& inAccessor, bool, const TInfoType* inInfo, bool ) { PxU32 rangeStart = TKey; PxU32& propIdx = mKeyOverride == NULL ? rangeStart : *mKeyOverride; mOperator.complexProperty( &propIdx, inAccessor, *inInfo ); } PxU32 getKeyValue( PxU32 inPropertyKey ) { PxU32 retval = inPropertyKey; if ( mKeyOverride ) { retval = *mKeyOverride; (*mKeyOverride)++; } return retval; } void setupValueStructOffset( const ValueStructOffsetRecord&, bool, PxU32* ) {} void setupValueStructOffset( const ValueStructOffsetRecord& inAccessor, PxU32 inOffset, PxU32* inAdditionalOffset ) { //This allows us to nest properties correctly. if ( inAdditionalOffset ) inOffset += *inAdditionalOffset; inAccessor.setupValueStructOffset( inOffset ); } template<PxU32 TKey, typename TAccessorType> void handleAccessor( PxU32 inKey, const TAccessorType& inAccessor ) { typedef typename TAccessorType::prop_type TPropertyType; dispatchAccessor<TKey>( inKey , inAccessor , PxEnumTraits<TPropertyType>().NameConversion , PxClassInfoTraits<TPropertyType>().getInfo() , IsFlagsType<TPropertyType>().FlagData ); } template<PxU32 TKey, typename TAccessorType> void handleAccessor( const TAccessorType& inAccessor ) { setupValueStructOffset( inAccessor, PxPropertyToValueStructMemberMap<TKey>().Offset, mOffsetOverride ); handleAccessor<TKey>( getKeyValue( TKey ), inAccessor ); } template<PxU32 TKey, typename TObjType, typename TPropertyType> void operator()( const PxReadOnlyPropertyInfo<TKey,TObjType,TPropertyType>& inProperty, PxU32 ) { PxPvdReadOnlyPropertyAccessor< TKey, TObjType, TPropertyType > theAccessor( inProperty ); mOperator.pushName( inProperty.mName ); handleAccessor<TKey>( theAccessor ); mOperator.popName(); } //We don't handle unbounded indexed properties template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropertyType, typename TValueConversionType, typename TInfoType> void indexedProperty( PxU32, const PxIndexedPropertyInfo<TKey, TObjType, TIndexType, TPropertyType >&, bool, TValueConversionType, const TInfoType& ) {} template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropertyType> void indexedProperty( PxU32, const PxIndexedPropertyInfo<TKey, TObjType, TIndexType, TPropertyType >& inProp, const PxU32ToName* theConversions, const PxUnknownClassInfo& ) { mOperator.pushName( inProp.mName ); PxU32 rangeStart = TKey; PxU32& propIdx = mKeyOverride == NULL ? rangeStart : *mKeyOverride; PxU32 theOffset = 0; if ( mOffsetOverride ) theOffset = *mOffsetOverride; while( theConversions->mName != NULL ) { mOperator.pushBracketedName( theConversions->mName ); PxPvdIndexedPropertyAccessor<TKey, TObjType, TIndexType, TPropertyType> theAccessor( inProp, theConversions->mValue ); setupValueStructOffset( theAccessor, PxPropertyToValueStructMemberMap<TKey>().Offset, &theOffset ); handleAccessor<TKey>( propIdx, theAccessor ); mOperator.popName(); ++propIdx; ++theConversions; theOffset += sizeof( TPropertyType ); } mOperator.popName(); } template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropertyType, typename TInfoType> void indexedProperty( PxU32, const PxIndexedPropertyInfo<TKey, TObjType, TIndexType, TPropertyType >& inProp, const PxU32ToName* theConversions, const TInfoType& inInfo ) { //ouch, not nice. Indexed complex property. mOperator.pushName( inProp.mName ); PxU32 propIdx = TKey; PxU32 theOffset = 0; if ( mOffsetOverride ) theOffset = *mOffsetOverride; while( theConversions->mName != NULL ) { mOperator.pushBracketedName( theConversions->mName ); PxPvdIndexedPropertyAccessor<TKey, TObjType, TIndexType, TPropertyType> theAccessor( inProp, theConversions->mValue ); setupValueStructOffset( theAccessor, PxPropertyToValueStructMemberMap<TKey>().Offset, &theOffset ); PX_ASSERT( theAccessor.mHasValidOffset ); mOperator.complexProperty( &propIdx, theAccessor, inInfo ); mOperator.popName(); ++theConversions; theOffset += sizeof( TPropertyType ); } mOperator.popName(); } static char* myStrcat(const char* a,const char * b) { size_t len = strlen(a)+strlen(b); char* result = new char[len+1]; strcpy(result,a); strcat(result,b); result[len] = 0; return result; } template<PxU32 TKey, typename TObjType, typename TPropertyType, typename TInfoType> void handleBufferCollectionProperty(PxU32 , const PxBufferCollectionPropertyInfo<TKey, TObjType, TPropertyType >& inProp, const TInfoType& inInfo) { //append 'Collection' to buffer properties char* name = myStrcat(inProp.mName, "Collection"); mOperator.pushName(name); PxU32 propIdx = TKey; PxU32 theOffset = 0; PxBufferCollectionPropertyAccessor<TKey, TObjType, TPropertyType> theAccessor( inProp, inProp.mName ); setupValueStructOffset( theAccessor, PxPropertyToValueStructMemberMap<TKey>().Offset, &theOffset ); mOperator.bufferCollectionProperty( &propIdx, theAccessor, inInfo ); mOperator.popName(); delete []name; } template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropertyType> void operator()( const PxIndexedPropertyInfo<TKey, TObjType, TIndexType, TPropertyType >& inProp, PxU32 inIndex ) { indexedProperty( inIndex, inProp, IndexerToNameMap<TKey,TIndexType>().Converter.NameConversion , PxClassInfoTraits<TPropertyType>().Info ); } template<PxU32 TKey, typename TObjType, typename TPropertyType, typename TIndexType, typename TInfoType> void handleExtendedIndexProperty(PxU32 inIndex, const PxExtendedIndexedPropertyInfo<TKey, TObjType, TIndexType, TPropertyType >& inProp, const TInfoType& inInfo) { mOperator.pushName(inProp.mName); PxU32 propIdx = TKey; PxU32 theOffset = 0; PxPvdExtendedIndexedPropertyAccessor<TKey, TObjType, TIndexType, TPropertyType> theAccessor( inProp, inIndex ); setupValueStructOffset( theAccessor, PxPropertyToValueStructMemberMap<TKey>().Offset, &theOffset ); mOperator.extendedIndexedProperty( &propIdx, theAccessor, inInfo ); mOperator.popName(); } template<PxU32 TKey, typename TObjType, typename TPropertyType, typename TIndexType, typename TInfoType> void handlePxFixedSizeLookupTableProperty( const PxU32 inIndex, const PxFixedSizeLookupTablePropertyInfo<TKey, TObjType, TIndexType, TPropertyType >& inProp, const TInfoType& inInfo) { mOperator.pushName(inProp.mName); PxU32 propIdx = TKey; PxU32 theOffset = 0; PxPvdFixedSizeLookupTablePropertyAccessor<TKey, TObjType, TIndexType, TPropertyType> theAccessor( inProp, inIndex ); setupValueStructOffset( theAccessor, PxPropertyToValueStructMemberMap<TKey>().Offset, &theOffset ); mOperator.PxFixedSizeLookupTableProperty( &propIdx, theAccessor, inInfo ); mOperator.popName(); } template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropertyType> void operator()( const PxExtendedIndexedPropertyInfo<TKey, TObjType, TIndexType, TPropertyType >& inProp, PxU32 inIndex ) { handleExtendedIndexProperty( inIndex, inProp, PxClassInfoTraits<TPropertyType>().Info ); } template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropertyType> void operator()( const PxFixedSizeLookupTablePropertyInfo<TKey, TObjType, TIndexType, TPropertyType >& inProp, PxU32 inIndex) { handlePxFixedSizeLookupTableProperty(inIndex, inProp, PxClassInfoTraits<TPropertyType>().Info); } //We don't handle unbounded indexed properties template<PxU32 TKey, typename TObjType, typename TIndexType, typename TIndex2Type, typename TPropertyType, typename TNameConv, typename TNameConv2 > void dualIndexedProperty( PxU32 idx, const PxDualIndexedPropertyInfo<TKey, TObjType, TIndexType, TIndex2Type, TPropertyType >&, TNameConv, TNameConv2 ) { PX_UNUSED(idx); } template<PxU32 TKey, typename TObjType, typename TIndexType, typename TIndex2Type, typename TPropertyType> void dualIndexedProperty( PxU32 /*idx*/, const PxDualIndexedPropertyInfo<TKey, TObjType, TIndexType, TIndex2Type, TPropertyType >& inProp, const PxU32ToName* c1, const PxU32ToName* c2 ) { mOperator.pushName( inProp.mName ); PxU32 rangeStart = TKey; PxU32& propIdx = mKeyOverride == NULL ? rangeStart : *mKeyOverride; PxU32 theOffset = 0; if ( mOffsetOverride ) theOffset = *mOffsetOverride; while( c1->mName != NULL ) { mOperator.pushBracketedName( c1->mName ); const PxU32ToName* c2Idx = c2; while( c2Idx->mName != NULL ) { mOperator.pushBracketedName( c2Idx->mName ); PxPvdDualIndexedPropertyAccessor<TKey, TObjType, TIndexType, TIndex2Type, TPropertyType> theAccessor( inProp, c1->mValue, c2Idx->mValue ); setupValueStructOffset( theAccessor, PxPropertyToValueStructMemberMap<TKey>().Offset, &theOffset ); handleAccessor<TKey>( propIdx, theAccessor ); mOperator.popName(); ++propIdx; ++c2Idx; theOffset += sizeof( TPropertyType ); } mOperator.popName(); ++c1; } mOperator.popName(); } template<PxU32 TKey, typename TObjType, typename TIndexType, typename TIndex2Type, typename TPropertyType> void extendedDualIndexedProperty( PxU32 /*idx*/, const PxExtendedDualIndexedPropertyInfo<TKey, TObjType, TIndexType, TIndex2Type, TPropertyType >& inProp, PxU32 id0Count, PxU32 id1Count ) { mOperator.pushName( inProp.mName ); PxU32 rangeStart = TKey; PxU32& propIdx = mKeyOverride == NULL ? rangeStart : *mKeyOverride; PxU32 theOffset = 0; if ( mOffsetOverride ) theOffset = *mOffsetOverride; for(PxU32 i = 0; i < id0Count; ++i) { char buffer1[32] = { 0 }; sprintf( buffer1, "eId1_%u", i ); mOperator.pushBracketedName( buffer1 ); for(PxU32 j = 0; j < id1Count; ++j) { char buffer2[32] = { 0 }; sprintf( buffer2, "eId2_%u", j ); mOperator.pushBracketedName( buffer2 ); PxPvdExtendedDualIndexedPropertyAccessor<TKey, TObjType, TIndexType, TIndex2Type, TPropertyType> theAccessor( inProp, i, j ); setupValueStructOffset( theAccessor, PxPropertyToValueStructMemberMap<TKey>().Offset, &theOffset ); handleAccessor<TKey>( propIdx, theAccessor ); mOperator.popName(); ++propIdx; theOffset += sizeof( TPropertyType ); } mOperator.popName(); } mOperator.popName(); } template<PxU32 TKey, typename TObjType, typename TIndexType, typename TIndex2Type, typename TPropertyType> void operator()( const PxDualIndexedPropertyInfo<TKey, TObjType, TIndexType, TIndex2Type, TPropertyType >& inProp, PxU32 idx ) { dualIndexedProperty( idx, inProp , IndexerToNameMap<TKey,TIndexType>().Converter.NameConversion , IndexerToNameMap<TKey,TIndex2Type>().Converter.NameConversion ); } template<PxU32 TKey, typename TObjType, typename TIndexType, typename TIndex2Type, typename TPropertyType> void operator()( const PxExtendedDualIndexedPropertyInfo<TKey, TObjType, TIndexType, TIndex2Type, TPropertyType >& inProp, PxU32 idx ) { extendedDualIndexedProperty( idx, inProp, inProp.mId0Count, inProp.mId1Count ); } template<PxU32 TKey, typename TObjType, typename TPropertyType> void operator()( const PxRangePropertyInfo<TKey, TObjType, TPropertyType>& inProperty, PxU32 /*idx*/) { PxU32 rangeStart = TKey; PxU32& propIdx = mKeyOverride == NULL ? rangeStart : *mKeyOverride; PxU32 theOffset = 0; if ( mOffsetOverride ) theOffset = *mOffsetOverride; mOperator.pushName( inProperty.mName ); mOperator.pushName( inProperty.mArg0Name ); PxPvdRangePropertyAccessor<TKey, TObjType, TPropertyType> theAccessor( inProperty, true ); setupValueStructOffset( theAccessor, PxPropertyToValueStructMemberMap<TKey>().Offset, &theOffset ); handleAccessor<TKey>( propIdx, theAccessor ); ++propIdx; theOffset += sizeof( TPropertyType ); mOperator.popName(); mOperator.pushName( inProperty.mArg1Name ); theAccessor.mFirstValue = false; setupValueStructOffset( theAccessor, PxPropertyToValueStructMemberMap<TKey>().Offset, &theOffset ); handleAccessor<TKey>( propIdx, theAccessor ); mOperator.popName(); mOperator.popName(); } template<PxU32 TKey, typename TObjType, typename TPropertyType> void operator()( const PxBufferCollectionPropertyInfo<TKey, TObjType, TPropertyType>& inProp, PxU32 count ) { handleBufferCollectionProperty( count, inProp, PxClassInfoTraits<TPropertyType>().Info ); } template<PxU32 TKey, typename TObjectType, typename TPropertyType, PxU32 TEnableFlag> void handleBuffer( const PxBufferPropertyInfo<TKey, TObjectType, TPropertyType, TEnableFlag>& inProp ) { mOperator.handleBuffer( inProp ); } template<PxU32 TKey, typename TObjectType, typename TPropertyType, PxU32 TEnableFlag> void operator()( const PxBufferPropertyInfo<TKey, TObjectType, TPropertyType, TEnableFlag>& inProp, PxU32 ) { handleBuffer( inProp ); } template<PxU32 TKey, typename TObjType> void operator()( const PxReadOnlyCollectionPropertyInfo<TKey, TObjType, PxU32>& prop, PxU32 ) { mOperator.handleCollection( prop ); } template<PxU32 TKey, typename TObjType> void operator()( const PxReadOnlyCollectionPropertyInfo<TKey, TObjType, PxReal>& prop, PxU32 ) { mOperator.handleCollection( prop ); } template<PxU32 TKey, typename TObjType, typename TPropertyType> void operator()( const PxWriteOnlyPropertyInfo<TKey,TObjType,TPropertyType>&, PxU32 ) {} template<PxU32 TKey, typename TObjType, typename TCollectionType> void operator()( const PxReadOnlyCollectionPropertyInfo<TKey, TObjType, TCollectionType>&, PxU32 ) {} template<PxU32 TKey, typename TObjType, typename TCollectionType, typename TFilterType> void operator()( const PxReadOnlyFilteredCollectionPropertyInfo<TKey, TObjType, TCollectionType, TFilterType >&, PxU32 ) {} //We don't deal with these property datatypes. #define DEFINE_PVD_PROPERTY_NOP(datatype) \ template<PxU32 TKey, typename TObjType> \ void operator()( const PxReadOnlyPropertyInfo<TKey,TObjType,datatype>& inProperty, PxU32 ){PX_UNUSED(inProperty); } DEFINE_PVD_PROPERTY_NOP( const void* ) DEFINE_PVD_PROPERTY_NOP( void* ) DEFINE_PVD_PROPERTY_NOP( PxSimulationFilterCallback * ) DEFINE_PVD_PROPERTY_NOP( physx::PxTaskManager * ) DEFINE_PVD_PROPERTY_NOP( PxSimulationFilterShader * ) DEFINE_PVD_PROPERTY_NOP( PxSimulationFilterShader) DEFINE_PVD_PROPERTY_NOP( PxContactModifyCallback * ) DEFINE_PVD_PROPERTY_NOP( PxCCDContactModifyCallback * ) DEFINE_PVD_PROPERTY_NOP( PxSimulationEventCallback * ) DEFINE_PVD_PROPERTY_NOP( physx::PxCudaContextManager* ) DEFINE_PVD_PROPERTY_NOP( physx::PxCpuDispatcher * ) DEFINE_PVD_PROPERTY_NOP( PxRigidActor ) DEFINE_PVD_PROPERTY_NOP( const PxRigidActor ) DEFINE_PVD_PROPERTY_NOP( PxRigidActor& ) DEFINE_PVD_PROPERTY_NOP( const PxRigidActor& ) DEFINE_PVD_PROPERTY_NOP( PxScene* ) DEFINE_PVD_PROPERTY_NOP( PxConstraint ) DEFINE_PVD_PROPERTY_NOP( PxConstraint* ) DEFINE_PVD_PROPERTY_NOP( PxConstraint& ) DEFINE_PVD_PROPERTY_NOP( const PxConstraint& ) DEFINE_PVD_PROPERTY_NOP( PxAggregate * ) DEFINE_PVD_PROPERTY_NOP( PxArticulationReducedCoordinate&) DEFINE_PVD_PROPERTY_NOP( const PxArticulationLink * ) DEFINE_PVD_PROPERTY_NOP( const PxRigidDynamic * ) DEFINE_PVD_PROPERTY_NOP( const PxRigidStatic * ) DEFINE_PVD_PROPERTY_NOP( PxArticulationJointReducedCoordinate * ) DEFINE_PVD_PROPERTY_NOP( PxBroadPhaseCallback * ) DEFINE_PVD_PROPERTY_NOP( const PxBroadPhaseRegion * ) DEFINE_PVD_PROPERTY_NOP( PxU32 * ) }; template<typename TOperator> inline PvdPropertyFilter<TOperator> makePvdPropertyFilter( TOperator inOperator ) { return PvdPropertyFilter<TOperator>( inOperator ); } template<typename TOperator> inline PvdPropertyFilter<TOperator> makePvdPropertyFilter( TOperator inOperator, PxU32* inKey, PxU32* inOffset ) { return PvdPropertyFilter<TOperator>( inOperator, inKey, inOffset ); } template<typename TOperator, typename TFuncType> inline void visitWithPvdFilter( TOperator inOperator, TFuncType inFuncType ) { PX_UNUSED(inFuncType); TFuncType( makePvdPropertyFilter( inOperator ) ); } template<typename TObjType, typename TOperator> inline void visitInstancePvdProperties( TOperator inOperator ) { visitInstanceProperties<TObjType>( makePvdPropertyFilter( inOperator ) ); } template<typename TOperator> struct PvdAllPropertyVisitor { TOperator mOperator; PvdAllPropertyVisitor( TOperator op ) : mOperator( op ) {} template<typename TObjectType> bool operator()( const TObjectType* ) { visitInstancePvdProperties<TObjectType>( mOperator ); return false; } }; template<typename TOperator> struct PvdAllInfoVisitor { TOperator mOperator; PvdAllInfoVisitor( TOperator op ) : mOperator( op ) {} template<typename TInfoType> void operator()( TInfoType inInfo ) { inInfo.template visitType<bool>( PvdAllPropertyVisitor<TOperator>( mOperator ) ); inInfo.visitBases( *this ); } }; template<typename TObjType, typename TOperator> inline void visitAllPvdProperties( TOperator inOperator ) { visitAllProperties<TObjType>( makePvdPropertyFilter( inOperator ) ); } template<typename TOperator> inline void visitRigidDynamicPerFrameProperties( TOperator inOperator ) { PvdPropertyFilter<TOperator> theFilter( inOperator ); PxRigidDynamicGeneratedInfo theInfo; theFilter( theInfo.GlobalPose, 0 ); theFilter( theInfo.LinearVelocity, 1 ); theFilter( theInfo.AngularVelocity, 2 ); theFilter( theInfo.IsSleeping, 3 ); } template<typename TOperator> inline void visitArticulationLinkPerFrameProperties( TOperator inOperator ) { PvdPropertyFilter<TOperator> theFilter( inOperator ); PxArticulationLinkGeneratedInfo theInfo; theFilter( theInfo.GlobalPose, 0 ); } } } #endif
21,250
C
38.945489
188
0.766306
NVIDIA-Omniverse/PhysX/physx/source/physxmetadata/core/include/PxAutoGeneratedMetaDataObjectNames.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. // This code is auto-generated by the PhysX Clang metadata generator. Do not edit or be // prepared for your edits to be quietly ignored next time the clang metadata generator is // run. You can find the most recent version of clang metadata generator by contacting // Chris Nuernberger <[email protected]> or Dilip or Adam. // The source code for the generate was at one time checked into: // physx/PhysXMetaDataGenerator/llvm/tools/clang/lib/Frontend/PhysXMetaDataAction.cpp #define THERE_IS_NO_INCLUDE_GUARD_HERE_FOR_A_REASON PxPhysics_PropertiesStart, PxPhysics_TolerancesScale, PxPhysics_TriangleMeshes, PxPhysics_TetrahedronMeshes, PxPhysics_HeightFields, PxPhysics_ConvexMeshes, PxPhysics_BVHs, PxPhysics_Scenes, PxPhysics_Shapes, PxPhysics_Materials, PxPhysics_FEMSoftBodyMaterials, PxPhysics_FEMClothMaterials, PxPhysics_PBDMaterials, PxPhysics_PropertiesStop, PxRefCounted_PropertiesStart, PxRefCounted_ReferenceCount, PxRefCounted_PropertiesStop, PxBaseMaterial_PropertiesStart, PxBaseMaterial_UserData, PxBaseMaterial_PropertiesStop, PxMaterial_PropertiesStart, PxMaterial_DynamicFriction, PxMaterial_StaticFriction, PxMaterial_Restitution, PxMaterial_Damping, PxMaterial_Flags, PxMaterial_FrictionCombineMode, PxMaterial_RestitutionCombineMode, PxMaterial_ConcreteTypeName, PxMaterial_PropertiesStop, PxFEMMaterial_PropertiesStart, PxFEMMaterial_YoungsModulus, PxFEMMaterial_Poissons, PxFEMMaterial_DynamicFriction, PxFEMMaterial_PropertiesStop, PxFEMSoftBodyMaterial_PropertiesStart, PxFEMSoftBodyMaterial_Damping, PxFEMSoftBodyMaterial_DampingScale, PxFEMSoftBodyMaterial_MaterialModel, PxFEMSoftBodyMaterial_ConcreteTypeName, PxFEMSoftBodyMaterial_PropertiesStop, PxParticleMaterial_PropertiesStart, PxParticleMaterial_Friction, PxParticleMaterial_Damping, PxParticleMaterial_Adhesion, PxParticleMaterial_GravityScale, PxParticleMaterial_AdhesionRadiusScale, PxParticleMaterial_PropertiesStop, PxPBDMaterial_PropertiesStart, PxPBDMaterial_Viscosity, PxPBDMaterial_VorticityConfinement, PxPBDMaterial_SurfaceTension, PxPBDMaterial_Cohesion, PxPBDMaterial_Lift, PxPBDMaterial_Drag, PxPBDMaterial_CFLCoefficient, PxPBDMaterial_ParticleFrictionScale, PxPBDMaterial_ParticleAdhesionScale, PxPBDMaterial_ConcreteTypeName, PxPBDMaterial_PropertiesStop, PxActor_PropertiesStart, PxActor_Scene, PxActor_Name, PxActor_ActorFlags, PxActor_DominanceGroup, PxActor_OwnerClient, PxActor_Aggregate, PxActor_UserData, PxActor_PropertiesStop, PxRigidActor_PropertiesStart, PxRigidActor_GlobalPose, PxRigidActor_Shapes, PxRigidActor_Constraints, PxRigidActor_PropertiesStop, PxRigidBody_PropertiesStart, PxRigidBody_CMassLocalPose, PxRigidBody_Mass, PxRigidBody_InvMass, PxRigidBody_MassSpaceInertiaTensor, PxRigidBody_MassSpaceInvInertiaTensor, PxRigidBody_LinearDamping, PxRigidBody_AngularDamping, PxRigidBody_MaxLinearVelocity, PxRigidBody_MaxAngularVelocity, PxRigidBody_RigidBodyFlags, PxRigidBody_MinCCDAdvanceCoefficient, PxRigidBody_MaxDepenetrationVelocity, PxRigidBody_MaxContactImpulse, PxRigidBody_ContactSlopCoefficient, PxRigidBody_PropertiesStop, PxRigidDynamic_PropertiesStart, PxRigidDynamic_IsSleeping, PxRigidDynamic_SleepThreshold, PxRigidDynamic_StabilizationThreshold, PxRigidDynamic_RigidDynamicLockFlags, PxRigidDynamic_LinearVelocity, PxRigidDynamic_AngularVelocity, PxRigidDynamic_WakeCounter, PxRigidDynamic_SolverIterationCounts, PxRigidDynamic_ContactReportThreshold, PxRigidDynamic_ConcreteTypeName, PxRigidDynamic_PropertiesStop, PxRigidStatic_PropertiesStart, PxRigidStatic_ConcreteTypeName, PxRigidStatic_PropertiesStop, PxArticulationLink_PropertiesStart, PxArticulationLink_InboundJoint, PxArticulationLink_InboundJointDof, PxArticulationLink_LinkIndex, PxArticulationLink_Children, PxArticulationLink_CfmScale, PxArticulationLink_LinearVelocity, PxArticulationLink_AngularVelocity, PxArticulationLink_ConcreteTypeName, PxArticulationLink_PropertiesStop, PxArticulationJointReducedCoordinate_PropertiesStart, PxArticulationJointReducedCoordinate_ParentPose, PxArticulationJointReducedCoordinate_ChildPose, PxArticulationJointReducedCoordinate_JointType, PxArticulationJointReducedCoordinate_Motion, PxArticulationJointReducedCoordinate_LimitParams, PxArticulationJointReducedCoordinate_DriveParams, PxArticulationJointReducedCoordinate_Armature, PxArticulationJointReducedCoordinate_FrictionCoefficient, PxArticulationJointReducedCoordinate_MaxJointVelocity, PxArticulationJointReducedCoordinate_JointPosition, PxArticulationJointReducedCoordinate_JointVelocity, PxArticulationJointReducedCoordinate_ConcreteTypeName, PxArticulationJointReducedCoordinate_UserData, PxArticulationJointReducedCoordinate_PropertiesStop, PxArticulationReducedCoordinate_PropertiesStart, PxArticulationReducedCoordinate_Scene, PxArticulationReducedCoordinate_SolverIterationCounts, PxArticulationReducedCoordinate_IsSleeping, PxArticulationReducedCoordinate_SleepThreshold, PxArticulationReducedCoordinate_StabilizationThreshold, PxArticulationReducedCoordinate_WakeCounter, PxArticulationReducedCoordinate_MaxCOMLinearVelocity, PxArticulationReducedCoordinate_MaxCOMAngularVelocity, PxArticulationReducedCoordinate_Links, PxArticulationReducedCoordinate_Name, PxArticulationReducedCoordinate_Aggregate, PxArticulationReducedCoordinate_ArticulationFlags, PxArticulationReducedCoordinate_RootGlobalPose, PxArticulationReducedCoordinate_RootLinearVelocity, PxArticulationReducedCoordinate_RootAngularVelocity, PxArticulationReducedCoordinate_UserData, PxArticulationReducedCoordinate_PropertiesStop, PxAggregate_PropertiesStart, PxAggregate_MaxNbActors, PxAggregate_MaxNbShapes, PxAggregate_Actors, PxAggregate_SelfCollision, PxAggregate_ConcreteTypeName, PxAggregate_UserData, PxAggregate_PropertiesStop, PxConstraint_PropertiesStart, PxConstraint_Scene, PxConstraint_Actors, PxConstraint_Flags, PxConstraint_IsValid, PxConstraint_BreakForce, PxConstraint_MinResponseThreshold, PxConstraint_ConcreteTypeName, PxConstraint_UserData, PxConstraint_PropertiesStop, PxShape_PropertiesStart, PxShape_LocalPose, PxShape_SimulationFilterData, PxShape_QueryFilterData, PxShape_Materials, PxShape_ContactOffset, PxShape_RestOffset, PxShape_DensityForFluid, PxShape_TorsionalPatchRadius, PxShape_MinTorsionalPatchRadius, PxShape_InternalShapeIndex, PxShape_Flags, PxShape_IsExclusive, PxShape_Name, PxShape_ConcreteTypeName, PxShape_UserData, PxShape_Geom, PxShape_PropertiesStop, PxPruningStructure_PropertiesStart, PxPruningStructure_RigidActors, PxPruningStructure_StaticMergeData, PxPruningStructure_DynamicMergeData, PxPruningStructure_ConcreteTypeName, PxPruningStructure_PropertiesStop, PxTolerancesScale_PropertiesStart, PxTolerancesScale_IsValid, PxTolerancesScale_Length, PxTolerancesScale_Speed, PxTolerancesScale_PropertiesStop, PxGeometry_PropertiesStart, PxGeometry_PropertiesStop, PxBoxGeometry_PropertiesStart, PxBoxGeometry_HalfExtents, PxBoxGeometry_PropertiesStop, PxCapsuleGeometry_PropertiesStart, PxCapsuleGeometry_Radius, PxCapsuleGeometry_HalfHeight, PxCapsuleGeometry_PropertiesStop, PxMeshScale_PropertiesStart, PxMeshScale_Scale, PxMeshScale_Rotation, PxMeshScale_PropertiesStop, PxConvexMeshGeometry_PropertiesStart, PxConvexMeshGeometry_Scale, PxConvexMeshGeometry_ConvexMesh, PxConvexMeshGeometry_MeshFlags, PxConvexMeshGeometry_PropertiesStop, PxSphereGeometry_PropertiesStart, PxSphereGeometry_Radius, PxSphereGeometry_PropertiesStop, PxPlaneGeometry_PropertiesStart, PxPlaneGeometry_PropertiesStop, PxTriangleMeshGeometry_PropertiesStart, PxTriangleMeshGeometry_Scale, PxTriangleMeshGeometry_MeshFlags, PxTriangleMeshGeometry_TriangleMesh, PxTriangleMeshGeometry_PropertiesStop, PxHeightFieldGeometry_PropertiesStart, PxHeightFieldGeometry_HeightField, PxHeightFieldGeometry_HeightScale, PxHeightFieldGeometry_RowScale, PxHeightFieldGeometry_ColumnScale, PxHeightFieldGeometry_HeightFieldFlags, PxHeightFieldGeometry_PropertiesStop, PxSceneQuerySystemBase_PropertiesStart, PxSceneQuerySystemBase_DynamicTreeRebuildRateHint, PxSceneQuerySystemBase_UpdateMode, PxSceneQuerySystemBase_StaticTimestamp, PxSceneQuerySystemBase_PropertiesStop, PxSceneSQSystem_PropertiesStart, PxSceneSQSystem_SceneQueryUpdateMode, PxSceneSQSystem_SceneQueryStaticTimestamp, PxSceneSQSystem_StaticStructure, PxSceneSQSystem_DynamicStructure, PxSceneSQSystem_PropertiesStop, PxScene_PropertiesStart, PxScene_Flags, PxScene_Limits, PxScene_Timestamp, PxScene_Name, PxScene_Actors, PxScene_SoftBodies, PxScene_Articulations, PxScene_Constraints, PxScene_Aggregates, PxScene_CpuDispatcher, PxScene_CudaContextManager, PxScene_SimulationEventCallback, PxScene_ContactModifyCallback, PxScene_CCDContactModifyCallback, PxScene_BroadPhaseCallback, PxScene_FilterShaderDataSize, PxScene_FilterShader, PxScene_FilterCallback, PxScene_KinematicKinematicFilteringMode, PxScene_StaticKinematicFilteringMode, PxScene_Gravity, PxScene_BounceThresholdVelocity, PxScene_CCDMaxPasses, PxScene_CCDMaxSeparation, PxScene_CCDThreshold, PxScene_MaxBiasCoefficient, PxScene_FrictionOffsetThreshold, PxScene_FrictionCorrelationDistance, PxScene_FrictionType, PxScene_SolverType, PxScene_VisualizationCullingBox, PxScene_BroadPhaseType, PxScene_BroadPhaseRegions, PxScene_TaskManager, PxScene_NbContactDataBlocks, PxScene_MaxNbContactDataBlocksUsed, PxScene_ContactReportStreamBufferSize, PxScene_SolverBatchSize, PxScene_SolverArticulationBatchSize, PxScene_WakeCounterResetValue, PxScene_GpuDynamicsConfig, PxScene_UserData, PxScene_SimulationStatistics, PxScene_PropertiesStop, PxTetrahedronMeshGeometry_PropertiesStart, PxTetrahedronMeshGeometry_TetrahedronMesh, PxTetrahedronMeshGeometry_PropertiesStop, PxCustomGeometry_PropertiesStart, PxCustomGeometry_CustomType, PxCustomGeometry_PropertiesStop, PxHeightFieldDesc_PropertiesStart, PxHeightFieldDesc_NbRows, PxHeightFieldDesc_NbColumns, PxHeightFieldDesc_Format, PxHeightFieldDesc_Samples, PxHeightFieldDesc_ConvexEdgeThreshold, PxHeightFieldDesc_Flags, PxHeightFieldDesc_PropertiesStop, PxArticulationLimit_PropertiesStart, PxArticulationLimit_Low, PxArticulationLimit_High, PxArticulationLimit_PropertiesStop, PxArticulationDrive_PropertiesStart, PxArticulationDrive_Stiffness, PxArticulationDrive_Damping, PxArticulationDrive_MaxForce, PxArticulationDrive_DriveType, PxArticulationDrive_PropertiesStop, PxSceneQueryDesc_PropertiesStart, PxSceneQueryDesc_IsValid, PxSceneQueryDesc_StaticStructure, PxSceneQueryDesc_DynamicStructure, PxSceneQueryDesc_DynamicTreeRebuildRateHint, PxSceneQueryDesc_DynamicTreeSecondaryPruner, PxSceneQueryDesc_StaticBVHBuildStrategy, PxSceneQueryDesc_DynamicBVHBuildStrategy, PxSceneQueryDesc_StaticNbObjectsPerNode, PxSceneQueryDesc_DynamicNbObjectsPerNode, PxSceneQueryDesc_SceneQueryUpdateMode, PxSceneQueryDesc_PropertiesStop, PxSceneDesc_PropertiesStart, PxSceneDesc_ToDefault, PxSceneDesc_Gravity, PxSceneDesc_SimulationEventCallback, PxSceneDesc_ContactModifyCallback, PxSceneDesc_CcdContactModifyCallback, PxSceneDesc_FilterShaderData, PxSceneDesc_FilterShaderDataSize, PxSceneDesc_FilterShader, PxSceneDesc_FilterCallback, PxSceneDesc_KineKineFilteringMode, PxSceneDesc_StaticKineFilteringMode, PxSceneDesc_BroadPhaseType, PxSceneDesc_BroadPhaseCallback, PxSceneDesc_Limits, PxSceneDesc_FrictionType, PxSceneDesc_SolverType, PxSceneDesc_BounceThresholdVelocity, PxSceneDesc_FrictionOffsetThreshold, PxSceneDesc_FrictionCorrelationDistance, PxSceneDesc_Flags, PxSceneDesc_CpuDispatcher, PxSceneDesc_CudaContextManager, PxSceneDesc_UserData, PxSceneDesc_SolverBatchSize, PxSceneDesc_SolverArticulationBatchSize, PxSceneDesc_NbContactDataBlocks, PxSceneDesc_MaxNbContactDataBlocks, PxSceneDesc_MaxBiasCoefficient, PxSceneDesc_ContactReportStreamBufferSize, PxSceneDesc_CcdMaxPasses, PxSceneDesc_CcdThreshold, PxSceneDesc_CcdMaxSeparation, PxSceneDesc_WakeCounterResetValue, PxSceneDesc_SanityBounds, PxSceneDesc_GpuDynamicsConfig, PxSceneDesc_GpuMaxNumPartitions, PxSceneDesc_GpuMaxNumStaticPartitions, PxSceneDesc_GpuComputeVersion, PxSceneDesc_ContactPairSlabSize, PxSceneDesc_PropertiesStop, PxBroadPhaseDesc_PropertiesStart, PxBroadPhaseDesc_IsValid, PxBroadPhaseDesc_MType, PxBroadPhaseDesc_MContextID, PxBroadPhaseDesc_MContextManager, PxBroadPhaseDesc_MFoundLostPairsCapacity, PxBroadPhaseDesc_MDiscardStaticVsKinematic, PxBroadPhaseDesc_MDiscardKinematicVsKinematic, PxBroadPhaseDesc_PropertiesStop, PxSceneLimits_PropertiesStart, PxSceneLimits_MaxNbActors, PxSceneLimits_MaxNbBodies, PxSceneLimits_MaxNbStaticShapes, PxSceneLimits_MaxNbDynamicShapes, PxSceneLimits_MaxNbAggregates, PxSceneLimits_MaxNbConstraints, PxSceneLimits_MaxNbRegions, PxSceneLimits_MaxNbBroadPhaseOverlaps, PxSceneLimits_PropertiesStop, PxgDynamicsMemoryConfig_PropertiesStart, PxgDynamicsMemoryConfig_IsValid, PxgDynamicsMemoryConfig_TempBufferCapacity, PxgDynamicsMemoryConfig_MaxRigidContactCount, PxgDynamicsMemoryConfig_MaxRigidPatchCount, PxgDynamicsMemoryConfig_HeapCapacity, PxgDynamicsMemoryConfig_FoundLostPairsCapacity, PxgDynamicsMemoryConfig_FoundLostAggregatePairsCapacity, PxgDynamicsMemoryConfig_TotalAggregatePairsCapacity, PxgDynamicsMemoryConfig_MaxSoftBodyContacts, PxgDynamicsMemoryConfig_MaxFemClothContacts, PxgDynamicsMemoryConfig_MaxParticleContacts, PxgDynamicsMemoryConfig_CollisionStackSize, PxgDynamicsMemoryConfig_MaxHairContacts, PxgDynamicsMemoryConfig_PropertiesStop, PxSimulationStatistics_PropertiesStart, PxSimulationStatistics_NbActiveConstraints, PxSimulationStatistics_NbActiveDynamicBodies, PxSimulationStatistics_NbActiveKinematicBodies, PxSimulationStatistics_NbStaticBodies, PxSimulationStatistics_NbDynamicBodies, PxSimulationStatistics_NbKinematicBodies, PxSimulationStatistics_NbAggregates, PxSimulationStatistics_NbArticulations, PxSimulationStatistics_NbAxisSolverConstraints, PxSimulationStatistics_CompressedContactSize, PxSimulationStatistics_RequiredContactConstraintMemory, PxSimulationStatistics_PeakConstraintMemory, PxSimulationStatistics_NbDiscreteContactPairsTotal, PxSimulationStatistics_NbDiscreteContactPairsWithCacheHits, PxSimulationStatistics_NbDiscreteContactPairsWithContacts, PxSimulationStatistics_NbNewPairs, PxSimulationStatistics_NbLostPairs, PxSimulationStatistics_NbNewTouches, PxSimulationStatistics_NbLostTouches, PxSimulationStatistics_NbPartitions, PxSimulationStatistics_GpuMemParticles, PxSimulationStatistics_GpuMemSoftBodies, PxSimulationStatistics_GpuMemFEMCloths, PxSimulationStatistics_GpuMemHairSystems, PxSimulationStatistics_GpuMemHeap, PxSimulationStatistics_GpuMemHeapBroadPhase, PxSimulationStatistics_GpuMemHeapNarrowPhase, PxSimulationStatistics_GpuMemHeapSolver, PxSimulationStatistics_GpuMemHeapArticulation, PxSimulationStatistics_GpuMemHeapSimulation, PxSimulationStatistics_GpuMemHeapSimulationArticulation, PxSimulationStatistics_GpuMemHeapSimulationParticles, PxSimulationStatistics_GpuMemHeapSimulationSoftBody, PxSimulationStatistics_GpuMemHeapSimulationFEMCloth, PxSimulationStatistics_GpuMemHeapSimulationHairSystem, PxSimulationStatistics_GpuMemHeapParticles, PxSimulationStatistics_GpuMemHeapSoftBodies, PxSimulationStatistics_GpuMemHeapFEMCloths, PxSimulationStatistics_GpuMemHeapHairSystems, PxSimulationStatistics_GpuMemHeapOther, PxSimulationStatistics_NbBroadPhaseAdds, PxSimulationStatistics_NbBroadPhaseRemoves, PxSimulationStatistics_NbDiscreteContactPairs, PxSimulationStatistics_NbModifiedContactPairs, PxSimulationStatistics_NbCCDPairs, PxSimulationStatistics_NbTriggerPairs, PxSimulationStatistics_NbShapes, PxSimulationStatistics_PropertiesStop, #undef THERE_IS_NO_INCLUDE_GUARD_HERE_FOR_A_REASON
17,181
C
34.353909
90
0.891799
NVIDIA-Omniverse/PhysX/physx/source/physxmetadata/core/include/PxAutoGeneratedMetaDataObjects.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. // This code is auto-generated by the PhysX Clang metadata generator. Do not edit or be // prepared for your edits to be quietly ignored next time the clang metadata generator is // run. You can find the most recent version of clang metadata generator by contacting // Chris Nuernberger <[email protected]> or Dilip or Adam. // The source code for the generate was at one time checked into: // physx/PhysXMetaDataGenerator/llvm/tools/clang/lib/Frontend/PhysXMetaDataAction.cpp #define THERE_IS_NO_INCLUDE_GUARD_HERE_FOR_A_REASON #define PX_PROPERTY_INFO_NAME PxPropertyInfoName static PxU32ToName g_physx__PxShapeFlag__EnumConversion[] = { { "eSIMULATION_SHAPE", static_cast<PxU32>( physx::PxShapeFlag::eSIMULATION_SHAPE ) }, { "eSCENE_QUERY_SHAPE", static_cast<PxU32>( physx::PxShapeFlag::eSCENE_QUERY_SHAPE ) }, { "eTRIGGER_SHAPE", static_cast<PxU32>( physx::PxShapeFlag::eTRIGGER_SHAPE ) }, { "eVISUALIZATION", static_cast<PxU32>( physx::PxShapeFlag::eVISUALIZATION ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxShapeFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxShapeFlag__EnumConversion ) {} const PxU32ToName* NameConversion; }; class PxPhysics; struct PxPhysicsGeneratedValues { PxTolerancesScale TolerancesScale; PX_PHYSX_CORE_API PxPhysicsGeneratedValues( const PxPhysics* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPhysics, TolerancesScale, PxPhysicsGeneratedValues) struct PxPhysicsGeneratedInfo { static const char* getClassName() { return "PxPhysics"; } PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxPhysics_TolerancesScale, PxPhysics, const PxTolerancesScale > TolerancesScale; PxFactoryCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxPhysics_TriangleMeshes, PxPhysics, PxTriangleMesh *, PxInputStream & > TriangleMeshes; PxFactoryCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxPhysics_TetrahedronMeshes, PxPhysics, PxTetrahedronMesh *, PxInputStream & > TetrahedronMeshes; PxFactoryCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxPhysics_HeightFields, PxPhysics, PxHeightField *, PxInputStream & > HeightFields; PxFactoryCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxPhysics_ConvexMeshes, PxPhysics, PxConvexMesh *, PxInputStream & > ConvexMeshes; PxFactoryCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxPhysics_BVHs, PxPhysics, PxBVH *, PxInputStream & > BVHs; PxFactoryCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxPhysics_Scenes, PxPhysics, PxScene *, const PxSceneDesc & > Scenes; PxReadOnlyCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxPhysics_Shapes, PxPhysics, PxShape * > Shapes; PxReadOnlyCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxPhysics_Materials, PxPhysics, PxMaterial * > Materials; PxReadOnlyCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxPhysics_FEMSoftBodyMaterials, PxPhysics, PxFEMSoftBodyMaterial * > FEMSoftBodyMaterials; PxReadOnlyCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxPhysics_FEMClothMaterials, PxPhysics, PxFEMClothMaterial * > FEMClothMaterials; PxReadOnlyCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxPhysics_PBDMaterials, PxPhysics, PxPBDMaterial * > PBDMaterials; PX_PHYSX_CORE_API PxPhysicsGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxPhysics*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); return inStartIndex; } static PxU32 instancePropertyCount() { return 12; } static PxU32 totalPropertyCount() { return instancePropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( TolerancesScale, inStartIndex + 0 );; inOperator( TriangleMeshes, inStartIndex + 1 );; inOperator( TetrahedronMeshes, inStartIndex + 2 );; inOperator( HeightFields, inStartIndex + 3 );; inOperator( ConvexMeshes, inStartIndex + 4 );; inOperator( BVHs, inStartIndex + 5 );; inOperator( Scenes, inStartIndex + 6 );; inOperator( Shapes, inStartIndex + 7 );; inOperator( Materials, inStartIndex + 8 );; inOperator( FEMSoftBodyMaterials, inStartIndex + 9 );; inOperator( FEMClothMaterials, inStartIndex + 10 );; inOperator( PBDMaterials, inStartIndex + 11 );; return 12 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxPhysics> { PxPhysicsGeneratedInfo Info; const PxPhysicsGeneratedInfo* getInfo() { return &Info; } }; class PxRefCounted; struct PxRefCountedGeneratedValues { PxU32 ReferenceCount; PX_PHYSX_CORE_API PxRefCountedGeneratedValues( const PxRefCounted* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRefCounted, ReferenceCount, PxRefCountedGeneratedValues) struct PxRefCountedGeneratedInfo { static const char* getClassName() { return "PxRefCounted"; } PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxRefCounted_ReferenceCount, PxRefCounted, PxU32 > ReferenceCount; PX_PHYSX_CORE_API PxRefCountedGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxRefCounted*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); return inStartIndex; } static PxU32 instancePropertyCount() { return 1; } static PxU32 totalPropertyCount() { return instancePropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( ReferenceCount, inStartIndex + 0 );; return 1 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxRefCounted> { PxRefCountedGeneratedInfo Info; const PxRefCountedGeneratedInfo* getInfo() { return &Info; } }; class PxBaseMaterial; struct PxBaseMaterialGeneratedValues : PxRefCountedGeneratedValues { void * UserData; PX_PHYSX_CORE_API PxBaseMaterialGeneratedValues( const PxBaseMaterial* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxBaseMaterial, UserData, PxBaseMaterialGeneratedValues) struct PxBaseMaterialGeneratedInfo : PxRefCountedGeneratedInfo { static const char* getClassName() { return "PxBaseMaterial"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxBaseMaterial_UserData, PxBaseMaterial, void *, void * > UserData; PX_PHYSX_CORE_API PxBaseMaterialGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxBaseMaterial*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxRefCountedGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxRefCountedGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxRefCountedGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 1; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxRefCountedGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( UserData, inStartIndex + 0 );; return 1 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxBaseMaterial> { PxBaseMaterialGeneratedInfo Info; const PxBaseMaterialGeneratedInfo* getInfo() { return &Info; } }; static PxU32ToName g_physx__PxMaterialFlag__EnumConversion[] = { { "eDISABLE_FRICTION", static_cast<PxU32>( physx::PxMaterialFlag::eDISABLE_FRICTION ) }, { "eDISABLE_STRONG_FRICTION", static_cast<PxU32>( physx::PxMaterialFlag::eDISABLE_STRONG_FRICTION ) }, { "eIMPROVED_PATCH_FRICTION", static_cast<PxU32>( physx::PxMaterialFlag::eIMPROVED_PATCH_FRICTION ) }, { "eCOMPLIANT_CONTACT", static_cast<PxU32>( physx::PxMaterialFlag::eCOMPLIANT_CONTACT ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxMaterialFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxMaterialFlag__EnumConversion ) {} const PxU32ToName* NameConversion; }; static PxU32ToName g_physx__PxCombineMode__EnumConversion[] = { { "eAVERAGE", static_cast<PxU32>( physx::PxCombineMode::eAVERAGE ) }, { "eMIN", static_cast<PxU32>( physx::PxCombineMode::eMIN ) }, { "eMULTIPLY", static_cast<PxU32>( physx::PxCombineMode::eMULTIPLY ) }, { "eMAX", static_cast<PxU32>( physx::PxCombineMode::eMAX ) }, { "eN_VALUES", static_cast<PxU32>( physx::PxCombineMode::eN_VALUES ) }, { "ePAD_32", static_cast<PxU32>( physx::PxCombineMode::ePAD_32 ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxCombineMode::Enum > { PxEnumTraits() : NameConversion( g_physx__PxCombineMode__EnumConversion ) {} const PxU32ToName* NameConversion; }; class PxMaterial; struct PxMaterialGeneratedValues : PxBaseMaterialGeneratedValues { PxReal DynamicFriction; PxReal StaticFriction; PxReal Restitution; PxReal Damping; PxMaterialFlags Flags; PxCombineMode::Enum FrictionCombineMode; PxCombineMode::Enum RestitutionCombineMode; const char * ConcreteTypeName; PX_PHYSX_CORE_API PxMaterialGeneratedValues( const PxMaterial* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxMaterial, DynamicFriction, PxMaterialGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxMaterial, StaticFriction, PxMaterialGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxMaterial, Restitution, PxMaterialGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxMaterial, Damping, PxMaterialGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxMaterial, Flags, PxMaterialGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxMaterial, FrictionCombineMode, PxMaterialGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxMaterial, RestitutionCombineMode, PxMaterialGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxMaterial, ConcreteTypeName, PxMaterialGeneratedValues) struct PxMaterialGeneratedInfo : PxBaseMaterialGeneratedInfo { static const char* getClassName() { return "PxMaterial"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxMaterial_DynamicFriction, PxMaterial, PxReal, PxReal > DynamicFriction; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxMaterial_StaticFriction, PxMaterial, PxReal, PxReal > StaticFriction; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxMaterial_Restitution, PxMaterial, PxReal, PxReal > Restitution; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxMaterial_Damping, PxMaterial, PxReal, PxReal > Damping; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxMaterial_Flags, PxMaterial, PxMaterialFlags, PxMaterialFlags > Flags; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxMaterial_FrictionCombineMode, PxMaterial, PxCombineMode::Enum, PxCombineMode::Enum > FrictionCombineMode; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxMaterial_RestitutionCombineMode, PxMaterial, PxCombineMode::Enum, PxCombineMode::Enum > RestitutionCombineMode; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxMaterial_ConcreteTypeName, PxMaterial, const char * > ConcreteTypeName; PX_PHYSX_CORE_API PxMaterialGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxMaterial*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxBaseMaterialGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxBaseMaterialGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxBaseMaterialGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 8; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxBaseMaterialGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( DynamicFriction, inStartIndex + 0 );; inOperator( StaticFriction, inStartIndex + 1 );; inOperator( Restitution, inStartIndex + 2 );; inOperator( Damping, inStartIndex + 3 );; inOperator( Flags, inStartIndex + 4 );; inOperator( FrictionCombineMode, inStartIndex + 5 );; inOperator( RestitutionCombineMode, inStartIndex + 6 );; inOperator( ConcreteTypeName, inStartIndex + 7 );; return 8 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxMaterial> { PxMaterialGeneratedInfo Info; const PxMaterialGeneratedInfo* getInfo() { return &Info; } }; class PxFEMMaterial; struct PxFEMMaterialGeneratedValues : PxBaseMaterialGeneratedValues { PxReal YoungsModulus; PxReal Poissons; PxReal DynamicFriction; PX_PHYSX_CORE_API PxFEMMaterialGeneratedValues( const PxFEMMaterial* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxFEMMaterial, YoungsModulus, PxFEMMaterialGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxFEMMaterial, Poissons, PxFEMMaterialGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxFEMMaterial, DynamicFriction, PxFEMMaterialGeneratedValues) struct PxFEMMaterialGeneratedInfo : PxBaseMaterialGeneratedInfo { static const char* getClassName() { return "PxFEMMaterial"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxFEMMaterial_YoungsModulus, PxFEMMaterial, PxReal, PxReal > YoungsModulus; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxFEMMaterial_Poissons, PxFEMMaterial, PxReal, PxReal > Poissons; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxFEMMaterial_DynamicFriction, PxFEMMaterial, PxReal, PxReal > DynamicFriction; PX_PHYSX_CORE_API PxFEMMaterialGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxFEMMaterial*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxBaseMaterialGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxBaseMaterialGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxBaseMaterialGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 3; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxBaseMaterialGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( YoungsModulus, inStartIndex + 0 );; inOperator( Poissons, inStartIndex + 1 );; inOperator( DynamicFriction, inStartIndex + 2 );; return 3 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxFEMMaterial> { PxFEMMaterialGeneratedInfo Info; const PxFEMMaterialGeneratedInfo* getInfo() { return &Info; } }; static PxU32ToName g_physx__PxFEMSoftBodyMaterialModel__EnumConversion[] = { { "eCO_ROTATIONAL", static_cast<PxU32>( physx::PxFEMSoftBodyMaterialModel::eCO_ROTATIONAL ) }, { "eNEO_HOOKEAN", static_cast<PxU32>( physx::PxFEMSoftBodyMaterialModel::eNEO_HOOKEAN ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxFEMSoftBodyMaterialModel::Enum > { PxEnumTraits() : NameConversion( g_physx__PxFEMSoftBodyMaterialModel__EnumConversion ) {} const PxU32ToName* NameConversion; }; class PxFEMSoftBodyMaterial; struct PxFEMSoftBodyMaterialGeneratedValues : PxFEMMaterialGeneratedValues { PxReal Damping; PxReal DampingScale; PxFEMSoftBodyMaterialModel::Enum MaterialModel; const char * ConcreteTypeName; PX_PHYSX_CORE_API PxFEMSoftBodyMaterialGeneratedValues( const PxFEMSoftBodyMaterial* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxFEMSoftBodyMaterial, Damping, PxFEMSoftBodyMaterialGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxFEMSoftBodyMaterial, DampingScale, PxFEMSoftBodyMaterialGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxFEMSoftBodyMaterial, MaterialModel, PxFEMSoftBodyMaterialGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxFEMSoftBodyMaterial, ConcreteTypeName, PxFEMSoftBodyMaterialGeneratedValues) struct PxFEMSoftBodyMaterialGeneratedInfo : PxFEMMaterialGeneratedInfo { static const char* getClassName() { return "PxFEMSoftBodyMaterial"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxFEMSoftBodyMaterial_Damping, PxFEMSoftBodyMaterial, PxReal, PxReal > Damping; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxFEMSoftBodyMaterial_DampingScale, PxFEMSoftBodyMaterial, PxReal, PxReal > DampingScale; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxFEMSoftBodyMaterial_MaterialModel, PxFEMSoftBodyMaterial, PxFEMSoftBodyMaterialModel::Enum, PxFEMSoftBodyMaterialModel::Enum > MaterialModel; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxFEMSoftBodyMaterial_ConcreteTypeName, PxFEMSoftBodyMaterial, const char * > ConcreteTypeName; PX_PHYSX_CORE_API PxFEMSoftBodyMaterialGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxFEMSoftBodyMaterial*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxFEMMaterialGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxFEMMaterialGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxFEMMaterialGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 4; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxFEMMaterialGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( Damping, inStartIndex + 0 );; inOperator( DampingScale, inStartIndex + 1 );; inOperator( MaterialModel, inStartIndex + 2 );; inOperator( ConcreteTypeName, inStartIndex + 3 );; return 4 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxFEMSoftBodyMaterial> { PxFEMSoftBodyMaterialGeneratedInfo Info; const PxFEMSoftBodyMaterialGeneratedInfo* getInfo() { return &Info; } }; class PxParticleMaterial; struct PxParticleMaterialGeneratedValues : PxBaseMaterialGeneratedValues { PxReal Friction; PxReal Damping; PxReal Adhesion; PxReal GravityScale; PxReal AdhesionRadiusScale; PX_PHYSX_CORE_API PxParticleMaterialGeneratedValues( const PxParticleMaterial* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxParticleMaterial, Friction, PxParticleMaterialGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxParticleMaterial, Damping, PxParticleMaterialGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxParticleMaterial, Adhesion, PxParticleMaterialGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxParticleMaterial, GravityScale, PxParticleMaterialGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxParticleMaterial, AdhesionRadiusScale, PxParticleMaterialGeneratedValues) struct PxParticleMaterialGeneratedInfo : PxBaseMaterialGeneratedInfo { static const char* getClassName() { return "PxParticleMaterial"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxParticleMaterial_Friction, PxParticleMaterial, PxReal, PxReal > Friction; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxParticleMaterial_Damping, PxParticleMaterial, PxReal, PxReal > Damping; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxParticleMaterial_Adhesion, PxParticleMaterial, PxReal, PxReal > Adhesion; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxParticleMaterial_GravityScale, PxParticleMaterial, PxReal, PxReal > GravityScale; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxParticleMaterial_AdhesionRadiusScale, PxParticleMaterial, PxReal, PxReal > AdhesionRadiusScale; PX_PHYSX_CORE_API PxParticleMaterialGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxParticleMaterial*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxBaseMaterialGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxBaseMaterialGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxBaseMaterialGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 5; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxBaseMaterialGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( Friction, inStartIndex + 0 );; inOperator( Damping, inStartIndex + 1 );; inOperator( Adhesion, inStartIndex + 2 );; inOperator( GravityScale, inStartIndex + 3 );; inOperator( AdhesionRadiusScale, inStartIndex + 4 );; return 5 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxParticleMaterial> { PxParticleMaterialGeneratedInfo Info; const PxParticleMaterialGeneratedInfo* getInfo() { return &Info; } }; class PxPBDMaterial; struct PxPBDMaterialGeneratedValues : PxParticleMaterialGeneratedValues { PxReal Viscosity; PxReal VorticityConfinement; PxReal SurfaceTension; PxReal Cohesion; PxReal Lift; PxReal Drag; PxReal CFLCoefficient; PxReal ParticleFrictionScale; PxReal ParticleAdhesionScale; const char * ConcreteTypeName; PX_PHYSX_CORE_API PxPBDMaterialGeneratedValues( const PxPBDMaterial* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPBDMaterial, Viscosity, PxPBDMaterialGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPBDMaterial, VorticityConfinement, PxPBDMaterialGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPBDMaterial, SurfaceTension, PxPBDMaterialGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPBDMaterial, Cohesion, PxPBDMaterialGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPBDMaterial, Lift, PxPBDMaterialGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPBDMaterial, Drag, PxPBDMaterialGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPBDMaterial, CFLCoefficient, PxPBDMaterialGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPBDMaterial, ParticleFrictionScale, PxPBDMaterialGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPBDMaterial, ParticleAdhesionScale, PxPBDMaterialGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPBDMaterial, ConcreteTypeName, PxPBDMaterialGeneratedValues) struct PxPBDMaterialGeneratedInfo : PxParticleMaterialGeneratedInfo { static const char* getClassName() { return "PxPBDMaterial"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxPBDMaterial_Viscosity, PxPBDMaterial, PxReal, PxReal > Viscosity; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxPBDMaterial_VorticityConfinement, PxPBDMaterial, PxReal, PxReal > VorticityConfinement; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxPBDMaterial_SurfaceTension, PxPBDMaterial, PxReal, PxReal > SurfaceTension; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxPBDMaterial_Cohesion, PxPBDMaterial, PxReal, PxReal > Cohesion; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxPBDMaterial_Lift, PxPBDMaterial, PxReal, PxReal > Lift; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxPBDMaterial_Drag, PxPBDMaterial, PxReal, PxReal > Drag; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxPBDMaterial_CFLCoefficient, PxPBDMaterial, PxReal, PxReal > CFLCoefficient; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxPBDMaterial_ParticleFrictionScale, PxPBDMaterial, PxReal, PxReal > ParticleFrictionScale; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxPBDMaterial_ParticleAdhesionScale, PxPBDMaterial, PxReal, PxReal > ParticleAdhesionScale; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxPBDMaterial_ConcreteTypeName, PxPBDMaterial, const char * > ConcreteTypeName; PX_PHYSX_CORE_API PxPBDMaterialGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxPBDMaterial*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxParticleMaterialGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxParticleMaterialGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxParticleMaterialGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 10; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxParticleMaterialGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( Viscosity, inStartIndex + 0 );; inOperator( VorticityConfinement, inStartIndex + 1 );; inOperator( SurfaceTension, inStartIndex + 2 );; inOperator( Cohesion, inStartIndex + 3 );; inOperator( Lift, inStartIndex + 4 );; inOperator( Drag, inStartIndex + 5 );; inOperator( CFLCoefficient, inStartIndex + 6 );; inOperator( ParticleFrictionScale, inStartIndex + 7 );; inOperator( ParticleAdhesionScale, inStartIndex + 8 );; inOperator( ConcreteTypeName, inStartIndex + 9 );; return 10 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxPBDMaterial> { PxPBDMaterialGeneratedInfo Info; const PxPBDMaterialGeneratedInfo* getInfo() { return &Info; } }; static PxU32ToName g_physx__PxActorType__EnumConversion[] = { { "eRIGID_STATIC", static_cast<PxU32>( physx::PxActorType::eRIGID_STATIC ) }, { "eRIGID_DYNAMIC", static_cast<PxU32>( physx::PxActorType::eRIGID_DYNAMIC ) }, { "eARTICULATION_LINK", static_cast<PxU32>( physx::PxActorType::eARTICULATION_LINK ) }, { "eSOFTBODY", static_cast<PxU32>( physx::PxActorType::eSOFTBODY ) }, { "eFEMCLOTH", static_cast<PxU32>( physx::PxActorType::eFEMCLOTH ) }, { "ePBD_PARTICLESYSTEM", static_cast<PxU32>( physx::PxActorType::ePBD_PARTICLESYSTEM ) }, { "eFLIP_PARTICLESYSTEM", static_cast<PxU32>( physx::PxActorType::eFLIP_PARTICLESYSTEM ) }, { "eMPM_PARTICLESYSTEM", static_cast<PxU32>( physx::PxActorType::eMPM_PARTICLESYSTEM ) }, { "eHAIRSYSTEM", static_cast<PxU32>( physx::PxActorType::eHAIRSYSTEM ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxActorType::Enum > { PxEnumTraits() : NameConversion( g_physx__PxActorType__EnumConversion ) {} const PxU32ToName* NameConversion; }; static PxU32ToName g_physx__PxActorFlag__EnumConversion[] = { { "eVISUALIZATION", static_cast<PxU32>( physx::PxActorFlag::eVISUALIZATION ) }, { "eDISABLE_GRAVITY", static_cast<PxU32>( physx::PxActorFlag::eDISABLE_GRAVITY ) }, { "eSEND_SLEEP_NOTIFIES", static_cast<PxU32>( physx::PxActorFlag::eSEND_SLEEP_NOTIFIES ) }, { "eDISABLE_SIMULATION", static_cast<PxU32>( physx::PxActorFlag::eDISABLE_SIMULATION ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxActorFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxActorFlag__EnumConversion ) {} const PxU32ToName* NameConversion; }; class PxActor; struct PxActorGeneratedValues { PxScene * Scene; const char * Name; PxActorFlags ActorFlags; PxDominanceGroup DominanceGroup; PxClientID OwnerClient; PxAggregate * Aggregate; void * UserData; PX_PHYSX_CORE_API PxActorGeneratedValues( const PxActor* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxActor, Scene, PxActorGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxActor, Name, PxActorGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxActor, ActorFlags, PxActorGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxActor, DominanceGroup, PxActorGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxActor, OwnerClient, PxActorGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxActor, Aggregate, PxActorGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxActor, UserData, PxActorGeneratedValues) struct PxActorGeneratedInfo { static const char* getClassName() { return "PxActor"; } PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxActor_Scene, PxActor, PxScene * > Scene; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxActor_Name, PxActor, const char *, const char * > Name; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxActor_ActorFlags, PxActor, PxActorFlags, PxActorFlags > ActorFlags; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxActor_DominanceGroup, PxActor, PxDominanceGroup, PxDominanceGroup > DominanceGroup; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxActor_OwnerClient, PxActor, PxClientID, PxClientID > OwnerClient; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxActor_Aggregate, PxActor, PxAggregate * > Aggregate; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxActor_UserData, PxActor, void *, void * > UserData; PX_PHYSX_CORE_API PxActorGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxActor*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); return inStartIndex; } static PxU32 instancePropertyCount() { return 7; } static PxU32 totalPropertyCount() { return instancePropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( Scene, inStartIndex + 0 );; inOperator( Name, inStartIndex + 1 );; inOperator( ActorFlags, inStartIndex + 2 );; inOperator( DominanceGroup, inStartIndex + 3 );; inOperator( OwnerClient, inStartIndex + 4 );; inOperator( Aggregate, inStartIndex + 5 );; inOperator( UserData, inStartIndex + 6 );; return 7 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxActor> { PxActorGeneratedInfo Info; const PxActorGeneratedInfo* getInfo() { return &Info; } }; class PxRigidActor; struct PxRigidActorGeneratedValues : PxActorGeneratedValues { PxTransform GlobalPose; PX_PHYSX_CORE_API PxRigidActorGeneratedValues( const PxRigidActor* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidActor, GlobalPose, PxRigidActorGeneratedValues) struct PxRigidActorGeneratedInfo : PxActorGeneratedInfo { static const char* getClassName() { return "PxRigidActor"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidActor_GlobalPose, PxRigidActor, const PxTransform &, PxTransform > GlobalPose; PxRigidActorShapeCollection Shapes; PxReadOnlyCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidActor_Constraints, PxRigidActor, PxConstraint * > Constraints; PX_PHYSX_CORE_API PxRigidActorGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxRigidActor*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxActorGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxActorGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxActorGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 3; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxActorGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( GlobalPose, inStartIndex + 0 );; inOperator( Shapes, inStartIndex + 1 );; inOperator( Constraints, inStartIndex + 2 );; return 3 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxRigidActor> { PxRigidActorGeneratedInfo Info; const PxRigidActorGeneratedInfo* getInfo() { return &Info; } }; static PxU32ToName g_physx__PxForceMode__EnumConversion[] = { { "eFORCE", static_cast<PxU32>( physx::PxForceMode::eFORCE ) }, { "eIMPULSE", static_cast<PxU32>( physx::PxForceMode::eIMPULSE ) }, { "eVELOCITY_CHANGE", static_cast<PxU32>( physx::PxForceMode::eVELOCITY_CHANGE ) }, { "eACCELERATION", static_cast<PxU32>( physx::PxForceMode::eACCELERATION ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxForceMode::Enum > { PxEnumTraits() : NameConversion( g_physx__PxForceMode__EnumConversion ) {} const PxU32ToName* NameConversion; }; static PxU32ToName g_physx__PxRigidBodyFlag__EnumConversion[] = { { "eKINEMATIC", static_cast<PxU32>( physx::PxRigidBodyFlag::eKINEMATIC ) }, { "eUSE_KINEMATIC_TARGET_FOR_SCENE_QUERIES", static_cast<PxU32>( physx::PxRigidBodyFlag::eUSE_KINEMATIC_TARGET_FOR_SCENE_QUERIES ) }, { "eENABLE_CCD", static_cast<PxU32>( physx::PxRigidBodyFlag::eENABLE_CCD ) }, { "eENABLE_CCD_FRICTION", static_cast<PxU32>( physx::PxRigidBodyFlag::eENABLE_CCD_FRICTION ) }, { "eENABLE_SPECULATIVE_CCD", static_cast<PxU32>( physx::PxRigidBodyFlag::eENABLE_SPECULATIVE_CCD ) }, { "eENABLE_POSE_INTEGRATION_PREVIEW", static_cast<PxU32>( physx::PxRigidBodyFlag::eENABLE_POSE_INTEGRATION_PREVIEW ) }, { "eENABLE_CCD_MAX_CONTACT_IMPULSE", static_cast<PxU32>( physx::PxRigidBodyFlag::eENABLE_CCD_MAX_CONTACT_IMPULSE ) }, { "eRETAIN_ACCELERATIONS", static_cast<PxU32>( physx::PxRigidBodyFlag::eRETAIN_ACCELERATIONS ) }, { "eFORCE_KINE_KINE_NOTIFICATIONS", static_cast<PxU32>( physx::PxRigidBodyFlag::eFORCE_KINE_KINE_NOTIFICATIONS ) }, { "eFORCE_STATIC_KINE_NOTIFICATIONS", static_cast<PxU32>( physx::PxRigidBodyFlag::eFORCE_STATIC_KINE_NOTIFICATIONS ) }, { "eENABLE_GYROSCOPIC_FORCES", static_cast<PxU32>( physx::PxRigidBodyFlag::eENABLE_GYROSCOPIC_FORCES ) }, { "eRESERVED", static_cast<PxU32>( physx::PxRigidBodyFlag::eRESERVED ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxRigidBodyFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxRigidBodyFlag__EnumConversion ) {} const PxU32ToName* NameConversion; }; class PxRigidBody; struct PxRigidBodyGeneratedValues : PxRigidActorGeneratedValues { PxTransform CMassLocalPose; PxReal Mass; PxReal InvMass; PxVec3 MassSpaceInertiaTensor; PxVec3 MassSpaceInvInertiaTensor; PxReal LinearDamping; PxReal AngularDamping; PxReal MaxLinearVelocity; PxReal MaxAngularVelocity; PxRigidBodyFlags RigidBodyFlags; PxReal MinCCDAdvanceCoefficient; PxReal MaxDepenetrationVelocity; PxReal MaxContactImpulse; PxReal ContactSlopCoefficient; PX_PHYSX_CORE_API PxRigidBodyGeneratedValues( const PxRigidBody* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidBody, CMassLocalPose, PxRigidBodyGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidBody, Mass, PxRigidBodyGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidBody, InvMass, PxRigidBodyGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidBody, MassSpaceInertiaTensor, PxRigidBodyGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidBody, MassSpaceInvInertiaTensor, PxRigidBodyGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidBody, LinearDamping, PxRigidBodyGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidBody, AngularDamping, PxRigidBodyGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidBody, MaxLinearVelocity, PxRigidBodyGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidBody, MaxAngularVelocity, PxRigidBodyGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidBody, RigidBodyFlags, PxRigidBodyGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidBody, MinCCDAdvanceCoefficient, PxRigidBodyGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidBody, MaxDepenetrationVelocity, PxRigidBodyGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidBody, MaxContactImpulse, PxRigidBodyGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidBody, ContactSlopCoefficient, PxRigidBodyGeneratedValues) struct PxRigidBodyGeneratedInfo : PxRigidActorGeneratedInfo { static const char* getClassName() { return "PxRigidBody"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidBody_CMassLocalPose, PxRigidBody, const PxTransform &, PxTransform > CMassLocalPose; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidBody_Mass, PxRigidBody, PxReal, PxReal > Mass; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidBody_InvMass, PxRigidBody, PxReal > InvMass; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidBody_MassSpaceInertiaTensor, PxRigidBody, const PxVec3 &, PxVec3 > MassSpaceInertiaTensor; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidBody_MassSpaceInvInertiaTensor, PxRigidBody, PxVec3 > MassSpaceInvInertiaTensor; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidBody_LinearDamping, PxRigidBody, PxReal, PxReal > LinearDamping; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidBody_AngularDamping, PxRigidBody, PxReal, PxReal > AngularDamping; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidBody_MaxLinearVelocity, PxRigidBody, PxReal, PxReal > MaxLinearVelocity; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidBody_MaxAngularVelocity, PxRigidBody, PxReal, PxReal > MaxAngularVelocity; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidBody_RigidBodyFlags, PxRigidBody, PxRigidBodyFlags, PxRigidBodyFlags > RigidBodyFlags; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidBody_MinCCDAdvanceCoefficient, PxRigidBody, PxReal, PxReal > MinCCDAdvanceCoefficient; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidBody_MaxDepenetrationVelocity, PxRigidBody, PxReal, PxReal > MaxDepenetrationVelocity; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidBody_MaxContactImpulse, PxRigidBody, PxReal, PxReal > MaxContactImpulse; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidBody_ContactSlopCoefficient, PxRigidBody, PxReal, PxReal > ContactSlopCoefficient; PX_PHYSX_CORE_API PxRigidBodyGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxRigidBody*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxRigidActorGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxRigidActorGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxRigidActorGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 14; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxRigidActorGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( CMassLocalPose, inStartIndex + 0 );; inOperator( Mass, inStartIndex + 1 );; inOperator( InvMass, inStartIndex + 2 );; inOperator( MassSpaceInertiaTensor, inStartIndex + 3 );; inOperator( MassSpaceInvInertiaTensor, inStartIndex + 4 );; inOperator( LinearDamping, inStartIndex + 5 );; inOperator( AngularDamping, inStartIndex + 6 );; inOperator( MaxLinearVelocity, inStartIndex + 7 );; inOperator( MaxAngularVelocity, inStartIndex + 8 );; inOperator( RigidBodyFlags, inStartIndex + 9 );; inOperator( MinCCDAdvanceCoefficient, inStartIndex + 10 );; inOperator( MaxDepenetrationVelocity, inStartIndex + 11 );; inOperator( MaxContactImpulse, inStartIndex + 12 );; inOperator( ContactSlopCoefficient, inStartIndex + 13 );; return 14 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxRigidBody> { PxRigidBodyGeneratedInfo Info; const PxRigidBodyGeneratedInfo* getInfo() { return &Info; } }; static PxU32ToName g_physx__PxRigidDynamicLockFlag__EnumConversion[] = { { "eLOCK_LINEAR_X", static_cast<PxU32>( physx::PxRigidDynamicLockFlag::eLOCK_LINEAR_X ) }, { "eLOCK_LINEAR_Y", static_cast<PxU32>( physx::PxRigidDynamicLockFlag::eLOCK_LINEAR_Y ) }, { "eLOCK_LINEAR_Z", static_cast<PxU32>( physx::PxRigidDynamicLockFlag::eLOCK_LINEAR_Z ) }, { "eLOCK_ANGULAR_X", static_cast<PxU32>( physx::PxRigidDynamicLockFlag::eLOCK_ANGULAR_X ) }, { "eLOCK_ANGULAR_Y", static_cast<PxU32>( physx::PxRigidDynamicLockFlag::eLOCK_ANGULAR_Y ) }, { "eLOCK_ANGULAR_Z", static_cast<PxU32>( physx::PxRigidDynamicLockFlag::eLOCK_ANGULAR_Z ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxRigidDynamicLockFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxRigidDynamicLockFlag__EnumConversion ) {} const PxU32ToName* NameConversion; }; class PxRigidDynamic; struct PxRigidDynamicGeneratedValues : PxRigidBodyGeneratedValues { _Bool IsSleeping; PxReal SleepThreshold; PxReal StabilizationThreshold; PxRigidDynamicLockFlags RigidDynamicLockFlags; PxVec3 LinearVelocity; PxVec3 AngularVelocity; PxReal WakeCounter; PxU32 SolverIterationCounts[2]; PxReal ContactReportThreshold; const char * ConcreteTypeName; PX_PHYSX_CORE_API PxRigidDynamicGeneratedValues( const PxRigidDynamic* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidDynamic, IsSleeping, PxRigidDynamicGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidDynamic, SleepThreshold, PxRigidDynamicGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidDynamic, StabilizationThreshold, PxRigidDynamicGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidDynamic, RigidDynamicLockFlags, PxRigidDynamicGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidDynamic, LinearVelocity, PxRigidDynamicGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidDynamic, AngularVelocity, PxRigidDynamicGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidDynamic, WakeCounter, PxRigidDynamicGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidDynamic, SolverIterationCounts, PxRigidDynamicGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidDynamic, ContactReportThreshold, PxRigidDynamicGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidDynamic, ConcreteTypeName, PxRigidDynamicGeneratedValues) struct PxRigidDynamicGeneratedInfo : PxRigidBodyGeneratedInfo { static const char* getClassName() { return "PxRigidDynamic"; } PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidDynamic_IsSleeping, PxRigidDynamic, _Bool > IsSleeping; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidDynamic_SleepThreshold, PxRigidDynamic, PxReal, PxReal > SleepThreshold; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidDynamic_StabilizationThreshold, PxRigidDynamic, PxReal, PxReal > StabilizationThreshold; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidDynamic_RigidDynamicLockFlags, PxRigidDynamic, PxRigidDynamicLockFlags, PxRigidDynamicLockFlags > RigidDynamicLockFlags; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidDynamic_LinearVelocity, PxRigidDynamic, const PxVec3 &, PxVec3 > LinearVelocity; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidDynamic_AngularVelocity, PxRigidDynamic, const PxVec3 &, PxVec3 > AngularVelocity; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidDynamic_WakeCounter, PxRigidDynamic, PxReal, PxReal > WakeCounter; PxRangePropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidDynamic_SolverIterationCounts, PxRigidDynamic, PxU32 > SolverIterationCounts; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidDynamic_ContactReportThreshold, PxRigidDynamic, PxReal, PxReal > ContactReportThreshold; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidDynamic_ConcreteTypeName, PxRigidDynamic, const char * > ConcreteTypeName; PX_PHYSX_CORE_API PxRigidDynamicGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxRigidDynamic*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxRigidBodyGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxRigidBodyGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxRigidBodyGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 10; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxRigidBodyGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( IsSleeping, inStartIndex + 0 );; inOperator( SleepThreshold, inStartIndex + 1 );; inOperator( StabilizationThreshold, inStartIndex + 2 );; inOperator( RigidDynamicLockFlags, inStartIndex + 3 );; inOperator( LinearVelocity, inStartIndex + 4 );; inOperator( AngularVelocity, inStartIndex + 5 );; inOperator( WakeCounter, inStartIndex + 6 );; inOperator( SolverIterationCounts, inStartIndex + 7 );; inOperator( ContactReportThreshold, inStartIndex + 8 );; inOperator( ConcreteTypeName, inStartIndex + 9 );; return 10 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxRigidDynamic> { PxRigidDynamicGeneratedInfo Info; const PxRigidDynamicGeneratedInfo* getInfo() { return &Info; } }; class PxRigidStatic; struct PxRigidStaticGeneratedValues : PxRigidActorGeneratedValues { const char * ConcreteTypeName; PX_PHYSX_CORE_API PxRigidStaticGeneratedValues( const PxRigidStatic* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxRigidStatic, ConcreteTypeName, PxRigidStaticGeneratedValues) struct PxRigidStaticGeneratedInfo : PxRigidActorGeneratedInfo { static const char* getClassName() { return "PxRigidStatic"; } PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxRigidStatic_ConcreteTypeName, PxRigidStatic, const char * > ConcreteTypeName; PX_PHYSX_CORE_API PxRigidStaticGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxRigidStatic*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxRigidActorGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxRigidActorGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxRigidActorGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 1; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxRigidActorGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( ConcreteTypeName, inStartIndex + 0 );; return 1 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxRigidStatic> { PxRigidStaticGeneratedInfo Info; const PxRigidStaticGeneratedInfo* getInfo() { return &Info; } }; class PxArticulationLink; struct PxArticulationLinkGeneratedValues : PxRigidBodyGeneratedValues { PxArticulationJointReducedCoordinate * InboundJoint; PxU32 InboundJointDof; PxU32 LinkIndex; PxReal CfmScale; PxVec3 LinearVelocity; PxVec3 AngularVelocity; const char * ConcreteTypeName; PX_PHYSX_CORE_API PxArticulationLinkGeneratedValues( const PxArticulationLink* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationLink, InboundJoint, PxArticulationLinkGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationLink, InboundJointDof, PxArticulationLinkGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationLink, LinkIndex, PxArticulationLinkGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationLink, CfmScale, PxArticulationLinkGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationLink, LinearVelocity, PxArticulationLinkGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationLink, AngularVelocity, PxArticulationLinkGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationLink, ConcreteTypeName, PxArticulationLinkGeneratedValues) struct PxArticulationLinkGeneratedInfo : PxRigidBodyGeneratedInfo { static const char* getClassName() { return "PxArticulationLink"; } PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationLink_InboundJoint, PxArticulationLink, PxArticulationJointReducedCoordinate * > InboundJoint; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationLink_InboundJointDof, PxArticulationLink, PxU32 > InboundJointDof; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationLink_LinkIndex, PxArticulationLink, PxU32 > LinkIndex; PxReadOnlyCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationLink_Children, PxArticulationLink, PxArticulationLink * > Children; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationLink_CfmScale, PxArticulationLink, const PxReal, PxReal > CfmScale; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationLink_LinearVelocity, PxArticulationLink, PxVec3 > LinearVelocity; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationLink_AngularVelocity, PxArticulationLink, PxVec3 > AngularVelocity; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationLink_ConcreteTypeName, PxArticulationLink, const char * > ConcreteTypeName; PX_PHYSX_CORE_API PxArticulationLinkGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxArticulationLink*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxRigidBodyGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxRigidBodyGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxRigidBodyGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 8; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxRigidBodyGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( InboundJoint, inStartIndex + 0 );; inOperator( InboundJointDof, inStartIndex + 1 );; inOperator( LinkIndex, inStartIndex + 2 );; inOperator( Children, inStartIndex + 3 );; inOperator( CfmScale, inStartIndex + 4 );; inOperator( LinearVelocity, inStartIndex + 5 );; inOperator( AngularVelocity, inStartIndex + 6 );; inOperator( ConcreteTypeName, inStartIndex + 7 );; return 8 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxArticulationLink> { PxArticulationLinkGeneratedInfo Info; const PxArticulationLinkGeneratedInfo* getInfo() { return &Info; } }; static PxU32ToName g_physx__PxArticulationJointType__EnumConversion[] = { { "eFIX", static_cast<PxU32>( physx::PxArticulationJointType::eFIX ) }, { "ePRISMATIC", static_cast<PxU32>( physx::PxArticulationJointType::ePRISMATIC ) }, { "eREVOLUTE", static_cast<PxU32>( physx::PxArticulationJointType::eREVOLUTE ) }, { "eREVOLUTE_UNWRAPPED", static_cast<PxU32>( physx::PxArticulationJointType::eREVOLUTE_UNWRAPPED ) }, { "eSPHERICAL", static_cast<PxU32>( physx::PxArticulationJointType::eSPHERICAL ) }, { "eUNDEFINED", static_cast<PxU32>( physx::PxArticulationJointType::eUNDEFINED ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxArticulationJointType::Enum > { PxEnumTraits() : NameConversion( g_physx__PxArticulationJointType__EnumConversion ) {} const PxU32ToName* NameConversion; }; static PxU32ToName g_physx__PxArticulationAxis__EnumConversion[] = { { "eTWIST", static_cast<PxU32>( physx::PxArticulationAxis::eTWIST ) }, { "eSWING1", static_cast<PxU32>( physx::PxArticulationAxis::eSWING1 ) }, { "eSWING2", static_cast<PxU32>( physx::PxArticulationAxis::eSWING2 ) }, { "eX", static_cast<PxU32>( physx::PxArticulationAxis::eX ) }, { "eY", static_cast<PxU32>( physx::PxArticulationAxis::eY ) }, { "eZ", static_cast<PxU32>( physx::PxArticulationAxis::eZ ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxArticulationAxis::Enum > { PxEnumTraits() : NameConversion( g_physx__PxArticulationAxis__EnumConversion ) {} const PxU32ToName* NameConversion; }; static PxU32ToName g_physx__PxArticulationMotion__EnumConversion[] = { { "eLOCKED", static_cast<PxU32>( physx::PxArticulationMotion::eLOCKED ) }, { "eLIMITED", static_cast<PxU32>( physx::PxArticulationMotion::eLIMITED ) }, { "eFREE", static_cast<PxU32>( physx::PxArticulationMotion::eFREE ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxArticulationMotion::Enum > { PxEnumTraits() : NameConversion( g_physx__PxArticulationMotion__EnumConversion ) {} const PxU32ToName* NameConversion; }; class PxArticulationJointReducedCoordinate; struct PxArticulationJointReducedCoordinateGeneratedValues { PxTransform ParentPose; PxTransform ChildPose; PxArticulationJointType::Enum JointType; PxArticulationMotion::Enum Motion[physx::PxArticulationAxis::eCOUNT]; PxArticulationLimit LimitParams[physx::PxArticulationAxis::eCOUNT]; PxArticulationDrive DriveParams[physx::PxArticulationAxis::eCOUNT]; PxReal Armature[physx::PxArticulationAxis::eCOUNT]; PxReal FrictionCoefficient; PxReal MaxJointVelocity; PxReal JointPosition[physx::PxArticulationAxis::eCOUNT]; PxReal JointVelocity[physx::PxArticulationAxis::eCOUNT]; const char * ConcreteTypeName; void * UserData; PX_PHYSX_CORE_API PxArticulationJointReducedCoordinateGeneratedValues( const PxArticulationJointReducedCoordinate* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationJointReducedCoordinate, ParentPose, PxArticulationJointReducedCoordinateGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationJointReducedCoordinate, ChildPose, PxArticulationJointReducedCoordinateGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationJointReducedCoordinate, JointType, PxArticulationJointReducedCoordinateGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationJointReducedCoordinate, Motion, PxArticulationJointReducedCoordinateGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationJointReducedCoordinate, LimitParams, PxArticulationJointReducedCoordinateGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationJointReducedCoordinate, DriveParams, PxArticulationJointReducedCoordinateGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationJointReducedCoordinate, Armature, PxArticulationJointReducedCoordinateGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationJointReducedCoordinate, FrictionCoefficient, PxArticulationJointReducedCoordinateGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationJointReducedCoordinate, MaxJointVelocity, PxArticulationJointReducedCoordinateGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationJointReducedCoordinate, JointPosition, PxArticulationJointReducedCoordinateGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationJointReducedCoordinate, JointVelocity, PxArticulationJointReducedCoordinateGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationJointReducedCoordinate, ConcreteTypeName, PxArticulationJointReducedCoordinateGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationJointReducedCoordinate, UserData, PxArticulationJointReducedCoordinateGeneratedValues) struct PxArticulationJointReducedCoordinateGeneratedInfo { static const char* getClassName() { return "PxArticulationJointReducedCoordinate"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationJointReducedCoordinate_ParentPose, PxArticulationJointReducedCoordinate, const PxTransform &, PxTransform > ParentPose; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationJointReducedCoordinate_ChildPose, PxArticulationJointReducedCoordinate, const PxTransform &, PxTransform > ChildPose; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationJointReducedCoordinate_JointType, PxArticulationJointReducedCoordinate, PxArticulationJointType::Enum, PxArticulationJointType::Enum > JointType; PxIndexedPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationJointReducedCoordinate_Motion, PxArticulationJointReducedCoordinate, PxArticulationAxis::Enum, PxArticulationMotion::Enum > Motion; PxIndexedPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationJointReducedCoordinate_LimitParams, PxArticulationJointReducedCoordinate, PxArticulationAxis::Enum, PxArticulationLimit > LimitParams; PxIndexedPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationJointReducedCoordinate_DriveParams, PxArticulationJointReducedCoordinate, PxArticulationAxis::Enum, PxArticulationDrive > DriveParams; PxIndexedPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationJointReducedCoordinate_Armature, PxArticulationJointReducedCoordinate, PxArticulationAxis::Enum, PxReal > Armature; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationJointReducedCoordinate_FrictionCoefficient, PxArticulationJointReducedCoordinate, const PxReal, PxReal > FrictionCoefficient; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationJointReducedCoordinate_MaxJointVelocity, PxArticulationJointReducedCoordinate, const PxReal, PxReal > MaxJointVelocity; PxIndexedPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationJointReducedCoordinate_JointPosition, PxArticulationJointReducedCoordinate, PxArticulationAxis::Enum, PxReal > JointPosition; PxIndexedPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationJointReducedCoordinate_JointVelocity, PxArticulationJointReducedCoordinate, PxArticulationAxis::Enum, PxReal > JointVelocity; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationJointReducedCoordinate_ConcreteTypeName, PxArticulationJointReducedCoordinate, const char * > ConcreteTypeName; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationJointReducedCoordinate_UserData, PxArticulationJointReducedCoordinate, void *, void * > UserData; PX_PHYSX_CORE_API PxArticulationJointReducedCoordinateGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxArticulationJointReducedCoordinate*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); return inStartIndex; } static PxU32 instancePropertyCount() { return 13; } static PxU32 totalPropertyCount() { return instancePropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( ParentPose, inStartIndex + 0 );; inOperator( ChildPose, inStartIndex + 1 );; inOperator( JointType, inStartIndex + 2 );; inOperator( Motion, inStartIndex + 3 );; inOperator( LimitParams, inStartIndex + 4 );; inOperator( DriveParams, inStartIndex + 5 );; inOperator( Armature, inStartIndex + 6 );; inOperator( FrictionCoefficient, inStartIndex + 7 );; inOperator( MaxJointVelocity, inStartIndex + 8 );; inOperator( JointPosition, inStartIndex + 9 );; inOperator( JointVelocity, inStartIndex + 10 );; inOperator( ConcreteTypeName, inStartIndex + 11 );; inOperator( UserData, inStartIndex + 12 );; return 13 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxArticulationJointReducedCoordinate> { PxArticulationJointReducedCoordinateGeneratedInfo Info; const PxArticulationJointReducedCoordinateGeneratedInfo* getInfo() { return &Info; } }; static PxU32ToName g_physx__PxArticulationFlag__EnumConversion[] = { { "eFIX_BASE", static_cast<PxU32>( physx::PxArticulationFlag::eFIX_BASE ) }, { "eDRIVE_LIMITS_ARE_FORCES", static_cast<PxU32>( physx::PxArticulationFlag::eDRIVE_LIMITS_ARE_FORCES ) }, { "eDISABLE_SELF_COLLISION", static_cast<PxU32>( physx::PxArticulationFlag::eDISABLE_SELF_COLLISION ) }, { "eCOMPUTE_JOINT_FORCES", static_cast<PxU32>( physx::PxArticulationFlag::eCOMPUTE_JOINT_FORCES ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxArticulationFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxArticulationFlag__EnumConversion ) {} const PxU32ToName* NameConversion; }; static PxU32ToName g_physx__PxArticulationCacheFlag__EnumConversion[] = { { "eVELOCITY", static_cast<PxU32>( physx::PxArticulationCacheFlag::eVELOCITY ) }, { "eACCELERATION", static_cast<PxU32>( physx::PxArticulationCacheFlag::eACCELERATION ) }, { "ePOSITION", static_cast<PxU32>( physx::PxArticulationCacheFlag::ePOSITION ) }, { "eFORCE", static_cast<PxU32>( physx::PxArticulationCacheFlag::eFORCE ) }, { "eLINK_VELOCITY", static_cast<PxU32>( physx::PxArticulationCacheFlag::eLINK_VELOCITY ) }, { "eLINK_ACCELERATION", static_cast<PxU32>( physx::PxArticulationCacheFlag::eLINK_ACCELERATION ) }, { "eROOT_TRANSFORM", static_cast<PxU32>( physx::PxArticulationCacheFlag::eROOT_TRANSFORM ) }, { "eROOT_VELOCITIES", static_cast<PxU32>( physx::PxArticulationCacheFlag::eROOT_VELOCITIES ) }, { "eSENSOR_FORCES", static_cast<PxU32>( physx::PxArticulationCacheFlag::eSENSOR_FORCES ) }, { "eJOINT_SOLVER_FORCES", static_cast<PxU32>( physx::PxArticulationCacheFlag::eJOINT_SOLVER_FORCES ) }, { "eLINK_INCOMING_JOINT_FORCE", static_cast<PxU32>( physx::PxArticulationCacheFlag::eLINK_INCOMING_JOINT_FORCE ) }, { "eJOINT_TARGET_POSITIONS", static_cast<PxU32>( physx::PxArticulationCacheFlag::eJOINT_TARGET_POSITIONS ) }, { "eJOINT_TARGET_VELOCITIES", static_cast<PxU32>( physx::PxArticulationCacheFlag::eJOINT_TARGET_VELOCITIES ) }, { "eALL", static_cast<PxU32>( physx::PxArticulationCacheFlag::eALL ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxArticulationCacheFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxArticulationCacheFlag__EnumConversion ) {} const PxU32ToName* NameConversion; }; class PxArticulationReducedCoordinate; struct PxArticulationReducedCoordinateGeneratedValues { PxScene * Scene; PxU32 SolverIterationCounts[2]; _Bool IsSleeping; PxReal SleepThreshold; PxReal StabilizationThreshold; PxReal WakeCounter; PxReal MaxCOMLinearVelocity; PxReal MaxCOMAngularVelocity; const char * Name; PxAggregate * Aggregate; PxArticulationFlags ArticulationFlags; PxTransform RootGlobalPose; PxVec3 RootLinearVelocity; PxVec3 RootAngularVelocity; void * UserData; PX_PHYSX_CORE_API PxArticulationReducedCoordinateGeneratedValues( const PxArticulationReducedCoordinate* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationReducedCoordinate, Scene, PxArticulationReducedCoordinateGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationReducedCoordinate, SolverIterationCounts, PxArticulationReducedCoordinateGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationReducedCoordinate, IsSleeping, PxArticulationReducedCoordinateGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationReducedCoordinate, SleepThreshold, PxArticulationReducedCoordinateGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationReducedCoordinate, StabilizationThreshold, PxArticulationReducedCoordinateGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationReducedCoordinate, WakeCounter, PxArticulationReducedCoordinateGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationReducedCoordinate, MaxCOMLinearVelocity, PxArticulationReducedCoordinateGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationReducedCoordinate, MaxCOMAngularVelocity, PxArticulationReducedCoordinateGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationReducedCoordinate, Name, PxArticulationReducedCoordinateGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationReducedCoordinate, Aggregate, PxArticulationReducedCoordinateGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationReducedCoordinate, ArticulationFlags, PxArticulationReducedCoordinateGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationReducedCoordinate, RootGlobalPose, PxArticulationReducedCoordinateGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationReducedCoordinate, RootLinearVelocity, PxArticulationReducedCoordinateGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationReducedCoordinate, RootAngularVelocity, PxArticulationReducedCoordinateGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationReducedCoordinate, UserData, PxArticulationReducedCoordinateGeneratedValues) struct PxArticulationReducedCoordinateGeneratedInfo { static const char* getClassName() { return "PxArticulationReducedCoordinate"; } PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationReducedCoordinate_Scene, PxArticulationReducedCoordinate, PxScene * > Scene; PxRangePropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationReducedCoordinate_SolverIterationCounts, PxArticulationReducedCoordinate, PxU32 > SolverIterationCounts; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationReducedCoordinate_IsSleeping, PxArticulationReducedCoordinate, _Bool > IsSleeping; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationReducedCoordinate_SleepThreshold, PxArticulationReducedCoordinate, PxReal, PxReal > SleepThreshold; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationReducedCoordinate_StabilizationThreshold, PxArticulationReducedCoordinate, PxReal, PxReal > StabilizationThreshold; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationReducedCoordinate_WakeCounter, PxArticulationReducedCoordinate, PxReal, PxReal > WakeCounter; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationReducedCoordinate_MaxCOMLinearVelocity, PxArticulationReducedCoordinate, const PxReal, PxReal > MaxCOMLinearVelocity; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationReducedCoordinate_MaxCOMAngularVelocity, PxArticulationReducedCoordinate, const PxReal, PxReal > MaxCOMAngularVelocity; PxArticulationLinkCollectionProp Links; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationReducedCoordinate_Name, PxArticulationReducedCoordinate, const char *, const char * > Name; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationReducedCoordinate_Aggregate, PxArticulationReducedCoordinate, PxAggregate * > Aggregate; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationReducedCoordinate_ArticulationFlags, PxArticulationReducedCoordinate, PxArticulationFlags, PxArticulationFlags > ArticulationFlags; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationReducedCoordinate_RootGlobalPose, PxArticulationReducedCoordinate, const PxTransform &, PxTransform > RootGlobalPose; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationReducedCoordinate_RootLinearVelocity, PxArticulationReducedCoordinate, const PxVec3 &, PxVec3 > RootLinearVelocity; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationReducedCoordinate_RootAngularVelocity, PxArticulationReducedCoordinate, const PxVec3 &, PxVec3 > RootAngularVelocity; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationReducedCoordinate_UserData, PxArticulationReducedCoordinate, void *, void * > UserData; PX_PHYSX_CORE_API PxArticulationReducedCoordinateGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxArticulationReducedCoordinate*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); return inStartIndex; } static PxU32 instancePropertyCount() { return 16; } static PxU32 totalPropertyCount() { return instancePropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( Scene, inStartIndex + 0 );; inOperator( SolverIterationCounts, inStartIndex + 1 );; inOperator( IsSleeping, inStartIndex + 2 );; inOperator( SleepThreshold, inStartIndex + 3 );; inOperator( StabilizationThreshold, inStartIndex + 4 );; inOperator( WakeCounter, inStartIndex + 5 );; inOperator( MaxCOMLinearVelocity, inStartIndex + 6 );; inOperator( MaxCOMAngularVelocity, inStartIndex + 7 );; inOperator( Links, inStartIndex + 8 );; inOperator( Name, inStartIndex + 9 );; inOperator( Aggregate, inStartIndex + 10 );; inOperator( ArticulationFlags, inStartIndex + 11 );; inOperator( RootGlobalPose, inStartIndex + 12 );; inOperator( RootLinearVelocity, inStartIndex + 13 );; inOperator( RootAngularVelocity, inStartIndex + 14 );; inOperator( UserData, inStartIndex + 15 );; return 16 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxArticulationReducedCoordinate> { PxArticulationReducedCoordinateGeneratedInfo Info; const PxArticulationReducedCoordinateGeneratedInfo* getInfo() { return &Info; } }; class PxAggregate; struct PxAggregateGeneratedValues { PxU32 MaxNbActors; PxU32 MaxNbShapes; _Bool SelfCollision; const char * ConcreteTypeName; void * UserData; PX_PHYSX_CORE_API PxAggregateGeneratedValues( const PxAggregate* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxAggregate, MaxNbActors, PxAggregateGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxAggregate, MaxNbShapes, PxAggregateGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxAggregate, SelfCollision, PxAggregateGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxAggregate, ConcreteTypeName, PxAggregateGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxAggregate, UserData, PxAggregateGeneratedValues) struct PxAggregateGeneratedInfo { static const char* getClassName() { return "PxAggregate"; } PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxAggregate_MaxNbActors, PxAggregate, PxU32 > MaxNbActors; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxAggregate_MaxNbShapes, PxAggregate, PxU32 > MaxNbShapes; PxReadOnlyCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxAggregate_Actors, PxAggregate, PxActor * > Actors; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxAggregate_SelfCollision, PxAggregate, _Bool > SelfCollision; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxAggregate_ConcreteTypeName, PxAggregate, const char * > ConcreteTypeName; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxAggregate_UserData, PxAggregate, void *, void * > UserData; PX_PHYSX_CORE_API PxAggregateGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxAggregate*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); return inStartIndex; } static PxU32 instancePropertyCount() { return 6; } static PxU32 totalPropertyCount() { return instancePropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( MaxNbActors, inStartIndex + 0 );; inOperator( MaxNbShapes, inStartIndex + 1 );; inOperator( Actors, inStartIndex + 2 );; inOperator( SelfCollision, inStartIndex + 3 );; inOperator( ConcreteTypeName, inStartIndex + 4 );; inOperator( UserData, inStartIndex + 5 );; return 6 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxAggregate> { PxAggregateGeneratedInfo Info; const PxAggregateGeneratedInfo* getInfo() { return &Info; } }; static PxU32ToName g_physx__PxConstraintFlag__EnumConversion[] = { { "eBROKEN", static_cast<PxU32>( physx::PxConstraintFlag::eBROKEN ) }, { "eCOLLISION_ENABLED", static_cast<PxU32>( physx::PxConstraintFlag::eCOLLISION_ENABLED ) }, { "eVISUALIZATION", static_cast<PxU32>( physx::PxConstraintFlag::eVISUALIZATION ) }, { "eDRIVE_LIMITS_ARE_FORCES", static_cast<PxU32>( physx::PxConstraintFlag::eDRIVE_LIMITS_ARE_FORCES ) }, { "eIMPROVED_SLERP", static_cast<PxU32>( physx::PxConstraintFlag::eIMPROVED_SLERP ) }, { "eDISABLE_PREPROCESSING", static_cast<PxU32>( physx::PxConstraintFlag::eDISABLE_PREPROCESSING ) }, { "eENABLE_EXTENDED_LIMITS", static_cast<PxU32>( physx::PxConstraintFlag::eENABLE_EXTENDED_LIMITS ) }, { "eGPU_COMPATIBLE", static_cast<PxU32>( physx::PxConstraintFlag::eGPU_COMPATIBLE ) }, { "eALWAYS_UPDATE", static_cast<PxU32>( physx::PxConstraintFlag::eALWAYS_UPDATE ) }, { "eDISABLE_CONSTRAINT", static_cast<PxU32>( physx::PxConstraintFlag::eDISABLE_CONSTRAINT ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxConstraintFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxConstraintFlag__EnumConversion ) {} const PxU32ToName* NameConversion; }; class PxConstraint; struct PxConstraintGeneratedValues { PxScene * Scene; PxRigidActor * Actors[2]; PxConstraintFlags Flags; _Bool IsValid; PxReal BreakForce[2]; PxReal MinResponseThreshold; const char * ConcreteTypeName; void * UserData; PX_PHYSX_CORE_API PxConstraintGeneratedValues( const PxConstraint* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxConstraint, Scene, PxConstraintGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxConstraint, Actors, PxConstraintGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxConstraint, Flags, PxConstraintGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxConstraint, IsValid, PxConstraintGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxConstraint, BreakForce, PxConstraintGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxConstraint, MinResponseThreshold, PxConstraintGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxConstraint, ConcreteTypeName, PxConstraintGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxConstraint, UserData, PxConstraintGeneratedValues) struct PxConstraintGeneratedInfo { static const char* getClassName() { return "PxConstraint"; } PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxConstraint_Scene, PxConstraint, PxScene * > Scene; PxRangePropertyInfo<PX_PROPERTY_INFO_NAME::PxConstraint_Actors, PxConstraint, PxRigidActor * > Actors; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxConstraint_Flags, PxConstraint, PxConstraintFlags, PxConstraintFlags > Flags; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxConstraint_IsValid, PxConstraint, _Bool > IsValid; PxRangePropertyInfo<PX_PROPERTY_INFO_NAME::PxConstraint_BreakForce, PxConstraint, PxReal > BreakForce; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxConstraint_MinResponseThreshold, PxConstraint, PxReal, PxReal > MinResponseThreshold; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxConstraint_ConcreteTypeName, PxConstraint, const char * > ConcreteTypeName; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxConstraint_UserData, PxConstraint, void *, void * > UserData; PX_PHYSX_CORE_API PxConstraintGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxConstraint*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); return inStartIndex; } static PxU32 instancePropertyCount() { return 8; } static PxU32 totalPropertyCount() { return instancePropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( Scene, inStartIndex + 0 );; inOperator( Actors, inStartIndex + 1 );; inOperator( Flags, inStartIndex + 2 );; inOperator( IsValid, inStartIndex + 3 );; inOperator( BreakForce, inStartIndex + 4 );; inOperator( MinResponseThreshold, inStartIndex + 5 );; inOperator( ConcreteTypeName, inStartIndex + 6 );; inOperator( UserData, inStartIndex + 7 );; return 8 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxConstraint> { PxConstraintGeneratedInfo Info; const PxConstraintGeneratedInfo* getInfo() { return &Info; } }; class PxShape; struct PxShapeGeneratedValues : PxRefCountedGeneratedValues { PxTransform LocalPose; PxFilterData SimulationFilterData; PxFilterData QueryFilterData; PxReal ContactOffset; PxReal RestOffset; PxReal DensityForFluid; PxReal TorsionalPatchRadius; PxReal MinTorsionalPatchRadius; PxU32 InternalShapeIndex; PxShapeFlags Flags; _Bool IsExclusive; const char * Name; const char * ConcreteTypeName; void * UserData; PxGeometryHolder Geom; PX_PHYSX_CORE_API PxShapeGeneratedValues( const PxShape* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxShape, LocalPose, PxShapeGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxShape, SimulationFilterData, PxShapeGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxShape, QueryFilterData, PxShapeGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxShape, ContactOffset, PxShapeGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxShape, RestOffset, PxShapeGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxShape, DensityForFluid, PxShapeGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxShape, TorsionalPatchRadius, PxShapeGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxShape, MinTorsionalPatchRadius, PxShapeGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxShape, InternalShapeIndex, PxShapeGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxShape, Flags, PxShapeGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxShape, IsExclusive, PxShapeGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxShape, Name, PxShapeGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxShape, ConcreteTypeName, PxShapeGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxShape, UserData, PxShapeGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxShape, Geom, PxShapeGeneratedValues) struct PxShapeGeneratedInfo : PxRefCountedGeneratedInfo { static const char* getClassName() { return "PxShape"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxShape_LocalPose, PxShape, const PxTransform &, PxTransform > LocalPose; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxShape_SimulationFilterData, PxShape, const PxFilterData &, PxFilterData > SimulationFilterData; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxShape_QueryFilterData, PxShape, const PxFilterData &, PxFilterData > QueryFilterData; PxShapeMaterialsProperty Materials; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxShape_ContactOffset, PxShape, PxReal, PxReal > ContactOffset; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxShape_RestOffset, PxShape, PxReal, PxReal > RestOffset; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxShape_DensityForFluid, PxShape, PxReal, PxReal > DensityForFluid; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxShape_TorsionalPatchRadius, PxShape, PxReal, PxReal > TorsionalPatchRadius; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxShape_MinTorsionalPatchRadius, PxShape, PxReal, PxReal > MinTorsionalPatchRadius; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxShape_InternalShapeIndex, PxShape, PxU32 > InternalShapeIndex; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxShape_Flags, PxShape, PxShapeFlags, PxShapeFlags > Flags; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxShape_IsExclusive, PxShape, _Bool > IsExclusive; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxShape_Name, PxShape, const char *, const char * > Name; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxShape_ConcreteTypeName, PxShape, const char * > ConcreteTypeName; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxShape_UserData, PxShape, void *, void * > UserData; PxShapeGeomProperty Geom; PX_PHYSX_CORE_API PxShapeGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxShape*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxRefCountedGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxRefCountedGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxRefCountedGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 16; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxRefCountedGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( LocalPose, inStartIndex + 0 );; inOperator( SimulationFilterData, inStartIndex + 1 );; inOperator( QueryFilterData, inStartIndex + 2 );; inOperator( Materials, inStartIndex + 3 );; inOperator( ContactOffset, inStartIndex + 4 );; inOperator( RestOffset, inStartIndex + 5 );; inOperator( DensityForFluid, inStartIndex + 6 );; inOperator( TorsionalPatchRadius, inStartIndex + 7 );; inOperator( MinTorsionalPatchRadius, inStartIndex + 8 );; inOperator( InternalShapeIndex, inStartIndex + 9 );; inOperator( Flags, inStartIndex + 10 );; inOperator( IsExclusive, inStartIndex + 11 );; inOperator( Name, inStartIndex + 12 );; inOperator( ConcreteTypeName, inStartIndex + 13 );; inOperator( UserData, inStartIndex + 14 );; inOperator( Geom, inStartIndex + 15 );; return 16 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxShape> { PxShapeGeneratedInfo Info; const PxShapeGeneratedInfo* getInfo() { return &Info; } }; class PxPruningStructure; struct PxPruningStructureGeneratedValues { const void * StaticMergeData; const void * DynamicMergeData; const char * ConcreteTypeName; PX_PHYSX_CORE_API PxPruningStructureGeneratedValues( const PxPruningStructure* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPruningStructure, StaticMergeData, PxPruningStructureGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPruningStructure, DynamicMergeData, PxPruningStructureGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxPruningStructure, ConcreteTypeName, PxPruningStructureGeneratedValues) struct PxPruningStructureGeneratedInfo { static const char* getClassName() { return "PxPruningStructure"; } PxReadOnlyCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxPruningStructure_RigidActors, PxPruningStructure, PxRigidActor * > RigidActors; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxPruningStructure_StaticMergeData, PxPruningStructure, const void * > StaticMergeData; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxPruningStructure_DynamicMergeData, PxPruningStructure, const void * > DynamicMergeData; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxPruningStructure_ConcreteTypeName, PxPruningStructure, const char * > ConcreteTypeName; PX_PHYSX_CORE_API PxPruningStructureGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxPruningStructure*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); return inStartIndex; } static PxU32 instancePropertyCount() { return 4; } static PxU32 totalPropertyCount() { return instancePropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( RigidActors, inStartIndex + 0 );; inOperator( StaticMergeData, inStartIndex + 1 );; inOperator( DynamicMergeData, inStartIndex + 2 );; inOperator( ConcreteTypeName, inStartIndex + 3 );; return 4 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxPruningStructure> { PxPruningStructureGeneratedInfo Info; const PxPruningStructureGeneratedInfo* getInfo() { return &Info; } }; class PxTolerancesScale; struct PxTolerancesScaleGeneratedValues { _Bool IsValid; PxReal Length; PxReal Speed; PX_PHYSX_CORE_API PxTolerancesScaleGeneratedValues( const PxTolerancesScale* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxTolerancesScale, IsValid, PxTolerancesScaleGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxTolerancesScale, Length, PxTolerancesScaleGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxTolerancesScale, Speed, PxTolerancesScaleGeneratedValues) struct PxTolerancesScaleGeneratedInfo { static const char* getClassName() { return "PxTolerancesScale"; } PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxTolerancesScale_IsValid, PxTolerancesScale, _Bool > IsValid; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxTolerancesScale_Length, PxTolerancesScale, PxReal, PxReal > Length; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxTolerancesScale_Speed, PxTolerancesScale, PxReal, PxReal > Speed; PX_PHYSX_CORE_API PxTolerancesScaleGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxTolerancesScale*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); return inStartIndex; } static PxU32 instancePropertyCount() { return 3; } static PxU32 totalPropertyCount() { return instancePropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( IsValid, inStartIndex + 0 );; inOperator( Length, inStartIndex + 1 );; inOperator( Speed, inStartIndex + 2 );; return 3 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxTolerancesScale> { PxTolerancesScaleGeneratedInfo Info; const PxTolerancesScaleGeneratedInfo* getInfo() { return &Info; } }; static PxU32ToName g_physx__PxGeometryType__EnumConversion[] = { { "eSPHERE", static_cast<PxU32>( physx::PxGeometryType::eSPHERE ) }, { "ePLANE", static_cast<PxU32>( physx::PxGeometryType::ePLANE ) }, { "eCAPSULE", static_cast<PxU32>( physx::PxGeometryType::eCAPSULE ) }, { "eBOX", static_cast<PxU32>( physx::PxGeometryType::eBOX ) }, { "eCONVEXMESH", static_cast<PxU32>( physx::PxGeometryType::eCONVEXMESH ) }, { "ePARTICLESYSTEM", static_cast<PxU32>( physx::PxGeometryType::ePARTICLESYSTEM ) }, { "eTETRAHEDRONMESH", static_cast<PxU32>( physx::PxGeometryType::eTETRAHEDRONMESH ) }, { "eTRIANGLEMESH", static_cast<PxU32>( physx::PxGeometryType::eTRIANGLEMESH ) }, { "eHEIGHTFIELD", static_cast<PxU32>( physx::PxGeometryType::eHEIGHTFIELD ) }, { "eHAIRSYSTEM", static_cast<PxU32>( physx::PxGeometryType::eHAIRSYSTEM ) }, { "eCUSTOM", static_cast<PxU32>( physx::PxGeometryType::eCUSTOM ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxGeometryType::Enum > { PxEnumTraits() : NameConversion( g_physx__PxGeometryType__EnumConversion ) {} const PxU32ToName* NameConversion; }; class PxGeometry; struct PxGeometryGeneratedValues { PX_PHYSX_CORE_API PxGeometryGeneratedValues( const PxGeometry* inSource ); }; struct PxGeometryGeneratedInfo { static const char* getClassName() { return "PxGeometry"; } PX_PHYSX_CORE_API PxGeometryGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxGeometry*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); return inStartIndex; } static PxU32 instancePropertyCount() { return 0; } static PxU32 totalPropertyCount() { return instancePropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); return 0 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxGeometry> { PxGeometryGeneratedInfo Info; const PxGeometryGeneratedInfo* getInfo() { return &Info; } }; class PxBoxGeometry; struct PxBoxGeometryGeneratedValues : PxGeometryGeneratedValues { PxVec3 HalfExtents; PX_PHYSX_CORE_API PxBoxGeometryGeneratedValues( const PxBoxGeometry* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxBoxGeometry, HalfExtents, PxBoxGeometryGeneratedValues) struct PxBoxGeometryGeneratedInfo : PxGeometryGeneratedInfo { static const char* getClassName() { return "PxBoxGeometry"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxBoxGeometry_HalfExtents, PxBoxGeometry, PxVec3, PxVec3 > HalfExtents; PX_PHYSX_CORE_API PxBoxGeometryGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxBoxGeometry*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxGeometryGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxGeometryGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxGeometryGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 1; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxGeometryGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( HalfExtents, inStartIndex + 0 );; return 1 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxBoxGeometry> { PxBoxGeometryGeneratedInfo Info; const PxBoxGeometryGeneratedInfo* getInfo() { return &Info; } }; class PxCapsuleGeometry; struct PxCapsuleGeometryGeneratedValues : PxGeometryGeneratedValues { PxReal Radius; PxReal HalfHeight; PX_PHYSX_CORE_API PxCapsuleGeometryGeneratedValues( const PxCapsuleGeometry* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxCapsuleGeometry, Radius, PxCapsuleGeometryGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxCapsuleGeometry, HalfHeight, PxCapsuleGeometryGeneratedValues) struct PxCapsuleGeometryGeneratedInfo : PxGeometryGeneratedInfo { static const char* getClassName() { return "PxCapsuleGeometry"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxCapsuleGeometry_Radius, PxCapsuleGeometry, PxReal, PxReal > Radius; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxCapsuleGeometry_HalfHeight, PxCapsuleGeometry, PxReal, PxReal > HalfHeight; PX_PHYSX_CORE_API PxCapsuleGeometryGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxCapsuleGeometry*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxGeometryGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxGeometryGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxGeometryGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 2; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxGeometryGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( Radius, inStartIndex + 0 );; inOperator( HalfHeight, inStartIndex + 1 );; return 2 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxCapsuleGeometry> { PxCapsuleGeometryGeneratedInfo Info; const PxCapsuleGeometryGeneratedInfo* getInfo() { return &Info; } }; class PxMeshScale; struct PxMeshScaleGeneratedValues { PxVec3 Scale; PxQuat Rotation; PX_PHYSX_CORE_API PxMeshScaleGeneratedValues( const PxMeshScale* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxMeshScale, Scale, PxMeshScaleGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxMeshScale, Rotation, PxMeshScaleGeneratedValues) struct PxMeshScaleGeneratedInfo { static const char* getClassName() { return "PxMeshScale"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxMeshScale_Scale, PxMeshScale, PxVec3, PxVec3 > Scale; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxMeshScale_Rotation, PxMeshScale, PxQuat, PxQuat > Rotation; PX_PHYSX_CORE_API PxMeshScaleGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxMeshScale*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); return inStartIndex; } static PxU32 instancePropertyCount() { return 2; } static PxU32 totalPropertyCount() { return instancePropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( Scale, inStartIndex + 0 );; inOperator( Rotation, inStartIndex + 1 );; return 2 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxMeshScale> { PxMeshScaleGeneratedInfo Info; const PxMeshScaleGeneratedInfo* getInfo() { return &Info; } }; static PxU32ToName g_physx__PxConvexMeshGeometryFlag__EnumConversion[] = { { "eTIGHT_BOUNDS", static_cast<PxU32>( physx::PxConvexMeshGeometryFlag::eTIGHT_BOUNDS ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxConvexMeshGeometryFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxConvexMeshGeometryFlag__EnumConversion ) {} const PxU32ToName* NameConversion; }; class PxConvexMeshGeometry; struct PxConvexMeshGeometryGeneratedValues : PxGeometryGeneratedValues { PxMeshScale Scale; PxConvexMesh * ConvexMesh; PxConvexMeshGeometryFlags MeshFlags; PX_PHYSX_CORE_API PxConvexMeshGeometryGeneratedValues( const PxConvexMeshGeometry* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxConvexMeshGeometry, Scale, PxConvexMeshGeometryGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxConvexMeshGeometry, ConvexMesh, PxConvexMeshGeometryGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxConvexMeshGeometry, MeshFlags, PxConvexMeshGeometryGeneratedValues) struct PxConvexMeshGeometryGeneratedInfo : PxGeometryGeneratedInfo { static const char* getClassName() { return "PxConvexMeshGeometry"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxConvexMeshGeometry_Scale, PxConvexMeshGeometry, PxMeshScale, PxMeshScale > Scale; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxConvexMeshGeometry_ConvexMesh, PxConvexMeshGeometry, PxConvexMesh *, PxConvexMesh * > ConvexMesh; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxConvexMeshGeometry_MeshFlags, PxConvexMeshGeometry, PxConvexMeshGeometryFlags, PxConvexMeshGeometryFlags > MeshFlags; PX_PHYSX_CORE_API PxConvexMeshGeometryGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxConvexMeshGeometry*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxGeometryGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxGeometryGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxGeometryGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 3; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxGeometryGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( Scale, inStartIndex + 0 );; inOperator( ConvexMesh, inStartIndex + 1 );; inOperator( MeshFlags, inStartIndex + 2 );; return 3 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxConvexMeshGeometry> { PxConvexMeshGeometryGeneratedInfo Info; const PxConvexMeshGeometryGeneratedInfo* getInfo() { return &Info; } }; class PxSphereGeometry; struct PxSphereGeometryGeneratedValues : PxGeometryGeneratedValues { PxReal Radius; PX_PHYSX_CORE_API PxSphereGeometryGeneratedValues( const PxSphereGeometry* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSphereGeometry, Radius, PxSphereGeometryGeneratedValues) struct PxSphereGeometryGeneratedInfo : PxGeometryGeneratedInfo { static const char* getClassName() { return "PxSphereGeometry"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSphereGeometry_Radius, PxSphereGeometry, PxReal, PxReal > Radius; PX_PHYSX_CORE_API PxSphereGeometryGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxSphereGeometry*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxGeometryGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxGeometryGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxGeometryGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 1; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxGeometryGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( Radius, inStartIndex + 0 );; return 1 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxSphereGeometry> { PxSphereGeometryGeneratedInfo Info; const PxSphereGeometryGeneratedInfo* getInfo() { return &Info; } }; class PxPlaneGeometry; struct PxPlaneGeometryGeneratedValues : PxGeometryGeneratedValues { PX_PHYSX_CORE_API PxPlaneGeometryGeneratedValues( const PxPlaneGeometry* inSource ); }; struct PxPlaneGeometryGeneratedInfo : PxGeometryGeneratedInfo { static const char* getClassName() { return "PxPlaneGeometry"; } PX_PHYSX_CORE_API PxPlaneGeometryGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxPlaneGeometry*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxGeometryGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxGeometryGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxGeometryGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 0; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxGeometryGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); return 0 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxPlaneGeometry> { PxPlaneGeometryGeneratedInfo Info; const PxPlaneGeometryGeneratedInfo* getInfo() { return &Info; } }; static PxU32ToName g_physx__PxMeshGeometryFlag__EnumConversion[] = { { "eTIGHT_BOUNDS", static_cast<PxU32>( physx::PxMeshGeometryFlag::eTIGHT_BOUNDS ) }, { "eDOUBLE_SIDED", static_cast<PxU32>( physx::PxMeshGeometryFlag::eDOUBLE_SIDED ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxMeshGeometryFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxMeshGeometryFlag__EnumConversion ) {} const PxU32ToName* NameConversion; }; class PxTriangleMeshGeometry; struct PxTriangleMeshGeometryGeneratedValues : PxGeometryGeneratedValues { PxMeshScale Scale; PxMeshGeometryFlags MeshFlags; PxTriangleMesh * TriangleMesh; PX_PHYSX_CORE_API PxTriangleMeshGeometryGeneratedValues( const PxTriangleMeshGeometry* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxTriangleMeshGeometry, Scale, PxTriangleMeshGeometryGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxTriangleMeshGeometry, MeshFlags, PxTriangleMeshGeometryGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxTriangleMeshGeometry, TriangleMesh, PxTriangleMeshGeometryGeneratedValues) struct PxTriangleMeshGeometryGeneratedInfo : PxGeometryGeneratedInfo { static const char* getClassName() { return "PxTriangleMeshGeometry"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxTriangleMeshGeometry_Scale, PxTriangleMeshGeometry, PxMeshScale, PxMeshScale > Scale; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxTriangleMeshGeometry_MeshFlags, PxTriangleMeshGeometry, PxMeshGeometryFlags, PxMeshGeometryFlags > MeshFlags; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxTriangleMeshGeometry_TriangleMesh, PxTriangleMeshGeometry, PxTriangleMesh *, PxTriangleMesh * > TriangleMesh; PX_PHYSX_CORE_API PxTriangleMeshGeometryGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxTriangleMeshGeometry*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxGeometryGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxGeometryGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxGeometryGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 3; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxGeometryGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( Scale, inStartIndex + 0 );; inOperator( MeshFlags, inStartIndex + 1 );; inOperator( TriangleMesh, inStartIndex + 2 );; return 3 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxTriangleMeshGeometry> { PxTriangleMeshGeometryGeneratedInfo Info; const PxTriangleMeshGeometryGeneratedInfo* getInfo() { return &Info; } }; class PxHeightFieldGeometry; struct PxHeightFieldGeometryGeneratedValues : PxGeometryGeneratedValues { PxHeightField * HeightField; PxReal HeightScale; PxReal RowScale; PxReal ColumnScale; PxMeshGeometryFlags HeightFieldFlags; PX_PHYSX_CORE_API PxHeightFieldGeometryGeneratedValues( const PxHeightFieldGeometry* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxHeightFieldGeometry, HeightField, PxHeightFieldGeometryGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxHeightFieldGeometry, HeightScale, PxHeightFieldGeometryGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxHeightFieldGeometry, RowScale, PxHeightFieldGeometryGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxHeightFieldGeometry, ColumnScale, PxHeightFieldGeometryGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxHeightFieldGeometry, HeightFieldFlags, PxHeightFieldGeometryGeneratedValues) struct PxHeightFieldGeometryGeneratedInfo : PxGeometryGeneratedInfo { static const char* getClassName() { return "PxHeightFieldGeometry"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxHeightFieldGeometry_HeightField, PxHeightFieldGeometry, PxHeightField *, PxHeightField * > HeightField; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxHeightFieldGeometry_HeightScale, PxHeightFieldGeometry, PxReal, PxReal > HeightScale; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxHeightFieldGeometry_RowScale, PxHeightFieldGeometry, PxReal, PxReal > RowScale; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxHeightFieldGeometry_ColumnScale, PxHeightFieldGeometry, PxReal, PxReal > ColumnScale; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxHeightFieldGeometry_HeightFieldFlags, PxHeightFieldGeometry, PxMeshGeometryFlags, PxMeshGeometryFlags > HeightFieldFlags; PX_PHYSX_CORE_API PxHeightFieldGeometryGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxHeightFieldGeometry*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxGeometryGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxGeometryGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxGeometryGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 5; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxGeometryGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( HeightField, inStartIndex + 0 );; inOperator( HeightScale, inStartIndex + 1 );; inOperator( RowScale, inStartIndex + 2 );; inOperator( ColumnScale, inStartIndex + 3 );; inOperator( HeightFieldFlags, inStartIndex + 4 );; return 5 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxHeightFieldGeometry> { PxHeightFieldGeometryGeneratedInfo Info; const PxHeightFieldGeometryGeneratedInfo* getInfo() { return &Info; } }; static PxU32ToName g_physx__PxSceneQueryUpdateMode__EnumConversion[] = { { "eBUILD_ENABLED_COMMIT_ENABLED", static_cast<PxU32>( physx::PxSceneQueryUpdateMode::eBUILD_ENABLED_COMMIT_ENABLED ) }, { "eBUILD_ENABLED_COMMIT_DISABLED", static_cast<PxU32>( physx::PxSceneQueryUpdateMode::eBUILD_ENABLED_COMMIT_DISABLED ) }, { "eBUILD_DISABLED_COMMIT_DISABLED", static_cast<PxU32>( physx::PxSceneQueryUpdateMode::eBUILD_DISABLED_COMMIT_DISABLED ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxSceneQueryUpdateMode::Enum > { PxEnumTraits() : NameConversion( g_physx__PxSceneQueryUpdateMode__EnumConversion ) {} const PxU32ToName* NameConversion; }; static PxU32ToName g_physx__PxHitFlag__EnumConversion[] = { { "ePOSITION", static_cast<PxU32>( physx::PxHitFlag::ePOSITION ) }, { "eNORMAL", static_cast<PxU32>( physx::PxHitFlag::eNORMAL ) }, { "eUV", static_cast<PxU32>( physx::PxHitFlag::eUV ) }, { "eASSUME_NO_INITIAL_OVERLAP", static_cast<PxU32>( physx::PxHitFlag::eASSUME_NO_INITIAL_OVERLAP ) }, { "eANY_HIT", static_cast<PxU32>( physx::PxHitFlag::eANY_HIT ) }, { "eMESH_MULTIPLE", static_cast<PxU32>( physx::PxHitFlag::eMESH_MULTIPLE ) }, { "eMESH_ANY", static_cast<PxU32>( physx::PxHitFlag::eMESH_ANY ) }, { "eMESH_BOTH_SIDES", static_cast<PxU32>( physx::PxHitFlag::eMESH_BOTH_SIDES ) }, { "ePRECISE_SWEEP", static_cast<PxU32>( physx::PxHitFlag::ePRECISE_SWEEP ) }, { "eMTD", static_cast<PxU32>( physx::PxHitFlag::eMTD ) }, { "eFACE_INDEX", static_cast<PxU32>( physx::PxHitFlag::eFACE_INDEX ) }, { "eDEFAULT", static_cast<PxU32>( physx::PxHitFlag::eDEFAULT ) }, { "eMODIFIABLE_FLAGS", static_cast<PxU32>( physx::PxHitFlag::eMODIFIABLE_FLAGS ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxHitFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxHitFlag__EnumConversion ) {} const PxU32ToName* NameConversion; }; static PxU32ToName g_physx__PxGeometryQueryFlag__EnumConversion[] = { { "eSIMD_GUARD", static_cast<PxU32>( physx::PxGeometryQueryFlag::eSIMD_GUARD ) }, { "eDEFAULT", static_cast<PxU32>( physx::PxGeometryQueryFlag::eDEFAULT ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxGeometryQueryFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxGeometryQueryFlag__EnumConversion ) {} const PxU32ToName* NameConversion; }; class PxSceneQuerySystemBase; struct PxSceneQuerySystemBaseGeneratedValues { PxU32 DynamicTreeRebuildRateHint; PxSceneQueryUpdateMode::Enum UpdateMode; PxU32 StaticTimestamp; PX_PHYSX_CORE_API PxSceneQuerySystemBaseGeneratedValues( const PxSceneQuerySystemBase* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneQuerySystemBase, DynamicTreeRebuildRateHint, PxSceneQuerySystemBaseGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneQuerySystemBase, UpdateMode, PxSceneQuerySystemBaseGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneQuerySystemBase, StaticTimestamp, PxSceneQuerySystemBaseGeneratedValues) struct PxSceneQuerySystemBaseGeneratedInfo { static const char* getClassName() { return "PxSceneQuerySystemBase"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneQuerySystemBase_DynamicTreeRebuildRateHint, PxSceneQuerySystemBase, PxU32, PxU32 > DynamicTreeRebuildRateHint; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneQuerySystemBase_UpdateMode, PxSceneQuerySystemBase, PxSceneQueryUpdateMode::Enum, PxSceneQueryUpdateMode::Enum > UpdateMode; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneQuerySystemBase_StaticTimestamp, PxSceneQuerySystemBase, PxU32 > StaticTimestamp; PX_PHYSX_CORE_API PxSceneQuerySystemBaseGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxSceneQuerySystemBase*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); return inStartIndex; } static PxU32 instancePropertyCount() { return 3; } static PxU32 totalPropertyCount() { return instancePropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( DynamicTreeRebuildRateHint, inStartIndex + 0 );; inOperator( UpdateMode, inStartIndex + 1 );; inOperator( StaticTimestamp, inStartIndex + 2 );; return 3 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxSceneQuerySystemBase> { PxSceneQuerySystemBaseGeneratedInfo Info; const PxSceneQuerySystemBaseGeneratedInfo* getInfo() { return &Info; } }; static PxU32ToName g_physx__PxPruningStructureType__EnumConversion[] = { { "eNONE", static_cast<PxU32>( physx::PxPruningStructureType::eNONE ) }, { "eDYNAMIC_AABB_TREE", static_cast<PxU32>( physx::PxPruningStructureType::eDYNAMIC_AABB_TREE ) }, { "eSTATIC_AABB_TREE", static_cast<PxU32>( physx::PxPruningStructureType::eSTATIC_AABB_TREE ) }, { "eLAST", static_cast<PxU32>( physx::PxPruningStructureType::eLAST ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxPruningStructureType::Enum > { PxEnumTraits() : NameConversion( g_physx__PxPruningStructureType__EnumConversion ) {} const PxU32ToName* NameConversion; }; class PxSceneSQSystem; struct PxSceneSQSystemGeneratedValues : PxSceneQuerySystemBaseGeneratedValues { PxSceneQueryUpdateMode::Enum SceneQueryUpdateMode; PxU32 SceneQueryStaticTimestamp; PxPruningStructureType::Enum StaticStructure; PxPruningStructureType::Enum DynamicStructure; PX_PHYSX_CORE_API PxSceneSQSystemGeneratedValues( const PxSceneSQSystem* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneSQSystem, SceneQueryUpdateMode, PxSceneSQSystemGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneSQSystem, SceneQueryStaticTimestamp, PxSceneSQSystemGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneSQSystem, StaticStructure, PxSceneSQSystemGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneSQSystem, DynamicStructure, PxSceneSQSystemGeneratedValues) struct PxSceneSQSystemGeneratedInfo : PxSceneQuerySystemBaseGeneratedInfo { static const char* getClassName() { return "PxSceneSQSystem"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneSQSystem_SceneQueryUpdateMode, PxSceneSQSystem, PxSceneQueryUpdateMode::Enum, PxSceneQueryUpdateMode::Enum > SceneQueryUpdateMode; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneSQSystem_SceneQueryStaticTimestamp, PxSceneSQSystem, PxU32 > SceneQueryStaticTimestamp; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneSQSystem_StaticStructure, PxSceneSQSystem, PxPruningStructureType::Enum > StaticStructure; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneSQSystem_DynamicStructure, PxSceneSQSystem, PxPruningStructureType::Enum > DynamicStructure; PX_PHYSX_CORE_API PxSceneSQSystemGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxSceneSQSystem*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxSceneQuerySystemBaseGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxSceneQuerySystemBaseGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxSceneQuerySystemBaseGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 4; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxSceneQuerySystemBaseGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( SceneQueryUpdateMode, inStartIndex + 0 );; inOperator( SceneQueryStaticTimestamp, inStartIndex + 1 );; inOperator( StaticStructure, inStartIndex + 2 );; inOperator( DynamicStructure, inStartIndex + 3 );; return 4 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxSceneSQSystem> { PxSceneSQSystemGeneratedInfo Info; const PxSceneSQSystemGeneratedInfo* getInfo() { return &Info; } }; static PxU32ToName g_physx__PxSceneFlag__EnumConversion[] = { { "eENABLE_ACTIVE_ACTORS", static_cast<PxU32>( physx::PxSceneFlag::eENABLE_ACTIVE_ACTORS ) }, { "eENABLE_CCD", static_cast<PxU32>( physx::PxSceneFlag::eENABLE_CCD ) }, { "eDISABLE_CCD_RESWEEP", static_cast<PxU32>( physx::PxSceneFlag::eDISABLE_CCD_RESWEEP ) }, { "eENABLE_PCM", static_cast<PxU32>( physx::PxSceneFlag::eENABLE_PCM ) }, { "eDISABLE_CONTACT_REPORT_BUFFER_RESIZE", static_cast<PxU32>( physx::PxSceneFlag::eDISABLE_CONTACT_REPORT_BUFFER_RESIZE ) }, { "eDISABLE_CONTACT_CACHE", static_cast<PxU32>( physx::PxSceneFlag::eDISABLE_CONTACT_CACHE ) }, { "eREQUIRE_RW_LOCK", static_cast<PxU32>( physx::PxSceneFlag::eREQUIRE_RW_LOCK ) }, { "eENABLE_STABILIZATION", static_cast<PxU32>( physx::PxSceneFlag::eENABLE_STABILIZATION ) }, { "eENABLE_AVERAGE_POINT", static_cast<PxU32>( physx::PxSceneFlag::eENABLE_AVERAGE_POINT ) }, { "eEXCLUDE_KINEMATICS_FROM_ACTIVE_ACTORS", static_cast<PxU32>( physx::PxSceneFlag::eEXCLUDE_KINEMATICS_FROM_ACTIVE_ACTORS ) }, { "eENABLE_GPU_DYNAMICS", static_cast<PxU32>( physx::PxSceneFlag::eENABLE_GPU_DYNAMICS ) }, { "eENABLE_ENHANCED_DETERMINISM", static_cast<PxU32>( physx::PxSceneFlag::eENABLE_ENHANCED_DETERMINISM ) }, { "eENABLE_FRICTION_EVERY_ITERATION", static_cast<PxU32>( physx::PxSceneFlag::eENABLE_FRICTION_EVERY_ITERATION ) }, { "eENABLE_DIRECT_GPU_API", static_cast<PxU32>( physx::PxSceneFlag::eENABLE_DIRECT_GPU_API ) }, { "eMUTABLE_FLAGS", static_cast<PxU32>( physx::PxSceneFlag::eMUTABLE_FLAGS ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxSceneFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxSceneFlag__EnumConversion ) {} const PxU32ToName* NameConversion; }; static PxU32ToName g_physx__PxActorTypeFlag__EnumConversion[] = { { "eRIGID_STATIC", static_cast<PxU32>( physx::PxActorTypeFlag::eRIGID_STATIC ) }, { "eRIGID_DYNAMIC", static_cast<PxU32>( physx::PxActorTypeFlag::eRIGID_DYNAMIC ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxActorTypeFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxActorTypeFlag__EnumConversion ) {} const PxU32ToName* NameConversion; }; static PxU32ToName g_physx__PxParticleSolverType__EnumConversion[] = { { "ePBD", static_cast<PxU32>( physx::PxParticleSolverType::ePBD ) }, { "eFLIP", static_cast<PxU32>( physx::PxParticleSolverType::eFLIP ) }, { "eMPM", static_cast<PxU32>( physx::PxParticleSolverType::eMPM ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxParticleSolverType::Enum > { PxEnumTraits() : NameConversion( g_physx__PxParticleSolverType__EnumConversion ) {} const PxU32ToName* NameConversion; }; static PxU32ToName g_physx__PxPairFilteringMode__EnumConversion[] = { { "eKEEP", static_cast<PxU32>( physx::PxPairFilteringMode::eKEEP ) }, { "eSUPPRESS", static_cast<PxU32>( physx::PxPairFilteringMode::eSUPPRESS ) }, { "eKILL", static_cast<PxU32>( physx::PxPairFilteringMode::eKILL ) }, { "eDEFAULT", static_cast<PxU32>( physx::PxPairFilteringMode::eDEFAULT ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxPairFilteringMode::Enum > { PxEnumTraits() : NameConversion( g_physx__PxPairFilteringMode__EnumConversion ) {} const PxU32ToName* NameConversion; }; static PxU32ToName g_physx__PxFrictionType__EnumConversion[] = { { "ePATCH", static_cast<PxU32>( physx::PxFrictionType::ePATCH ) }, { "eONE_DIRECTIONAL", static_cast<PxU32>( physx::PxFrictionType::eONE_DIRECTIONAL ) }, { "eTWO_DIRECTIONAL", static_cast<PxU32>( physx::PxFrictionType::eTWO_DIRECTIONAL ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxFrictionType::Enum > { PxEnumTraits() : NameConversion( g_physx__PxFrictionType__EnumConversion ) {} const PxU32ToName* NameConversion; }; static PxU32ToName g_physx__PxSolverType__EnumConversion[] = { { "ePGS", static_cast<PxU32>( physx::PxSolverType::ePGS ) }, { "eTGS", static_cast<PxU32>( physx::PxSolverType::eTGS ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxSolverType::Enum > { PxEnumTraits() : NameConversion( g_physx__PxSolverType__EnumConversion ) {} const PxU32ToName* NameConversion; }; static PxU32ToName g_physx__PxVisualizationParameter__EnumConversion[] = { { "eSCALE", static_cast<PxU32>( physx::PxVisualizationParameter::eSCALE ) }, { "eWORLD_AXES", static_cast<PxU32>( physx::PxVisualizationParameter::eWORLD_AXES ) }, { "eBODY_AXES", static_cast<PxU32>( physx::PxVisualizationParameter::eBODY_AXES ) }, { "eBODY_MASS_AXES", static_cast<PxU32>( physx::PxVisualizationParameter::eBODY_MASS_AXES ) }, { "eBODY_LIN_VELOCITY", static_cast<PxU32>( physx::PxVisualizationParameter::eBODY_LIN_VELOCITY ) }, { "eBODY_ANG_VELOCITY", static_cast<PxU32>( physx::PxVisualizationParameter::eBODY_ANG_VELOCITY ) }, { "eCONTACT_POINT", static_cast<PxU32>( physx::PxVisualizationParameter::eCONTACT_POINT ) }, { "eCONTACT_NORMAL", static_cast<PxU32>( physx::PxVisualizationParameter::eCONTACT_NORMAL ) }, { "eCONTACT_ERROR", static_cast<PxU32>( physx::PxVisualizationParameter::eCONTACT_ERROR ) }, { "eCONTACT_FORCE", static_cast<PxU32>( physx::PxVisualizationParameter::eCONTACT_FORCE ) }, { "eACTOR_AXES", static_cast<PxU32>( physx::PxVisualizationParameter::eACTOR_AXES ) }, { "eCOLLISION_AABBS", static_cast<PxU32>( physx::PxVisualizationParameter::eCOLLISION_AABBS ) }, { "eCOLLISION_SHAPES", static_cast<PxU32>( physx::PxVisualizationParameter::eCOLLISION_SHAPES ) }, { "eCOLLISION_AXES", static_cast<PxU32>( physx::PxVisualizationParameter::eCOLLISION_AXES ) }, { "eCOLLISION_COMPOUNDS", static_cast<PxU32>( physx::PxVisualizationParameter::eCOLLISION_COMPOUNDS ) }, { "eCOLLISION_FNORMALS", static_cast<PxU32>( physx::PxVisualizationParameter::eCOLLISION_FNORMALS ) }, { "eCOLLISION_EDGES", static_cast<PxU32>( physx::PxVisualizationParameter::eCOLLISION_EDGES ) }, { "eCOLLISION_STATIC", static_cast<PxU32>( physx::PxVisualizationParameter::eCOLLISION_STATIC ) }, { "eCOLLISION_DYNAMIC", static_cast<PxU32>( physx::PxVisualizationParameter::eCOLLISION_DYNAMIC ) }, { "eJOINT_LOCAL_FRAMES", static_cast<PxU32>( physx::PxVisualizationParameter::eJOINT_LOCAL_FRAMES ) }, { "eJOINT_LIMITS", static_cast<PxU32>( physx::PxVisualizationParameter::eJOINT_LIMITS ) }, { "eCULL_BOX", static_cast<PxU32>( physx::PxVisualizationParameter::eCULL_BOX ) }, { "eMBP_REGIONS", static_cast<PxU32>( physx::PxVisualizationParameter::eMBP_REGIONS ) }, { "eSIMULATION_MESH", static_cast<PxU32>( physx::PxVisualizationParameter::eSIMULATION_MESH ) }, { "eSDF", static_cast<PxU32>( physx::PxVisualizationParameter::eSDF ) }, { "eNUM_VALUES", static_cast<PxU32>( physx::PxVisualizationParameter::eNUM_VALUES ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxVisualizationParameter::Enum > { PxEnumTraits() : NameConversion( g_physx__PxVisualizationParameter__EnumConversion ) {} const PxU32ToName* NameConversion; }; static PxU32ToName g_physx__PxBroadPhaseType__EnumConversion[] = { { "eSAP", static_cast<PxU32>( physx::PxBroadPhaseType::eSAP ) }, { "eMBP", static_cast<PxU32>( physx::PxBroadPhaseType::eMBP ) }, { "eABP", static_cast<PxU32>( physx::PxBroadPhaseType::eABP ) }, { "ePABP", static_cast<PxU32>( physx::PxBroadPhaseType::ePABP ) }, { "eGPU", static_cast<PxU32>( physx::PxBroadPhaseType::eGPU ) }, { "eLAST", static_cast<PxU32>( physx::PxBroadPhaseType::eLAST ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxBroadPhaseType::Enum > { PxEnumTraits() : NameConversion( g_physx__PxBroadPhaseType__EnumConversion ) {} const PxU32ToName* NameConversion; }; static PxU32ToName g_physx__PxArticulationGpuDataType__EnumConversion[] = { { "eJOINT_POSITION", static_cast<PxU32>( physx::PxArticulationGpuDataType::eJOINT_POSITION ) }, { "eJOINT_VELOCITY", static_cast<PxU32>( physx::PxArticulationGpuDataType::eJOINT_VELOCITY ) }, { "eJOINT_ACCELERATION", static_cast<PxU32>( physx::PxArticulationGpuDataType::eJOINT_ACCELERATION ) }, { "eJOINT_FORCE", static_cast<PxU32>( physx::PxArticulationGpuDataType::eJOINT_FORCE ) }, { "eJOINT_SOLVER_FORCE", static_cast<PxU32>( physx::PxArticulationGpuDataType::eJOINT_SOLVER_FORCE ) }, { "eJOINT_TARGET_VELOCITY", static_cast<PxU32>( physx::PxArticulationGpuDataType::eJOINT_TARGET_VELOCITY ) }, { "eJOINT_TARGET_POSITION", static_cast<PxU32>( physx::PxArticulationGpuDataType::eJOINT_TARGET_POSITION ) }, { "eSENSOR_FORCE", static_cast<PxU32>( physx::PxArticulationGpuDataType::eSENSOR_FORCE ) }, { "eROOT_TRANSFORM", static_cast<PxU32>( physx::PxArticulationGpuDataType::eROOT_TRANSFORM ) }, { "eROOT_VELOCITY", static_cast<PxU32>( physx::PxArticulationGpuDataType::eROOT_VELOCITY ) }, { "eLINK_TRANSFORM", static_cast<PxU32>( physx::PxArticulationGpuDataType::eLINK_TRANSFORM ) }, { "eLINK_VELOCITY", static_cast<PxU32>( physx::PxArticulationGpuDataType::eLINK_VELOCITY ) }, { "eLINK_ACCELERATION", static_cast<PxU32>( physx::PxArticulationGpuDataType::eLINK_ACCELERATION ) }, { "eLINK_INCOMING_JOINT_FORCE", static_cast<PxU32>( physx::PxArticulationGpuDataType::eLINK_INCOMING_JOINT_FORCE ) }, { "eLINK_FORCE", static_cast<PxU32>( physx::PxArticulationGpuDataType::eLINK_FORCE ) }, { "eLINK_TORQUE", static_cast<PxU32>( physx::PxArticulationGpuDataType::eLINK_TORQUE ) }, { "eFIXED_TENDON", static_cast<PxU32>( physx::PxArticulationGpuDataType::eFIXED_TENDON ) }, { "eFIXED_TENDON_JOINT", static_cast<PxU32>( physx::PxArticulationGpuDataType::eFIXED_TENDON_JOINT ) }, { "eSPATIAL_TENDON", static_cast<PxU32>( physx::PxArticulationGpuDataType::eSPATIAL_TENDON ) }, { "eSPATIAL_TENDON_ATTACHMENT", static_cast<PxU32>( physx::PxArticulationGpuDataType::eSPATIAL_TENDON_ATTACHMENT ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxArticulationGpuDataType::Enum > { PxEnumTraits() : NameConversion( g_physx__PxArticulationGpuDataType__EnumConversion ) {} const PxU32ToName* NameConversion; }; static PxU32ToName g_physx__PxSoftBodyGpuDataFlag__EnumConversion[] = { { "eTET_INDICES", static_cast<PxU32>( physx::PxSoftBodyGpuDataFlag::eTET_INDICES ) }, { "eTET_REST_POSES", static_cast<PxU32>( physx::PxSoftBodyGpuDataFlag::eTET_REST_POSES ) }, { "eTET_ROTATIONS", static_cast<PxU32>( physx::PxSoftBodyGpuDataFlag::eTET_ROTATIONS ) }, { "eTET_POSITION_INV_MASS", static_cast<PxU32>( physx::PxSoftBodyGpuDataFlag::eTET_POSITION_INV_MASS ) }, { "eSIM_TET_INDICES", static_cast<PxU32>( physx::PxSoftBodyGpuDataFlag::eSIM_TET_INDICES ) }, { "eSIM_TET_ROTATIONS", static_cast<PxU32>( physx::PxSoftBodyGpuDataFlag::eSIM_TET_ROTATIONS ) }, { "eSIM_VELOCITY_INV_MASS", static_cast<PxU32>( physx::PxSoftBodyGpuDataFlag::eSIM_VELOCITY_INV_MASS ) }, { "eSIM_POSITION_INV_MASS", static_cast<PxU32>( physx::PxSoftBodyGpuDataFlag::eSIM_POSITION_INV_MASS ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxSoftBodyGpuDataFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxSoftBodyGpuDataFlag__EnumConversion ) {} const PxU32ToName* NameConversion; }; static PxU32ToName g_physx__PxActorCacheFlag__EnumConversion[] = { { "eACTOR_DATA", static_cast<PxU32>( physx::PxActorCacheFlag::eACTOR_DATA ) }, { "eFORCE", static_cast<PxU32>( physx::PxActorCacheFlag::eFORCE ) }, { "eTORQUE", static_cast<PxU32>( physx::PxActorCacheFlag::eTORQUE ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxActorCacheFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxActorCacheFlag__EnumConversion ) {} const PxU32ToName* NameConversion; }; class PxScene; struct PxSceneGeneratedValues : PxSceneSQSystemGeneratedValues { PxSceneFlags Flags; PxSceneLimits Limits; PxU32 Timestamp; const char * Name; PxCpuDispatcher * CpuDispatcher; PxCudaContextManager * CudaContextManager; PxSimulationEventCallback * SimulationEventCallback; PxContactModifyCallback * ContactModifyCallback; PxCCDContactModifyCallback * CCDContactModifyCallback; PxBroadPhaseCallback * BroadPhaseCallback; PxU32 FilterShaderDataSize; PxSimulationFilterShader FilterShader; PxSimulationFilterCallback * FilterCallback; PxPairFilteringMode::Enum KinematicKinematicFilteringMode; PxPairFilteringMode::Enum StaticKinematicFilteringMode; PxVec3 Gravity; PxReal BounceThresholdVelocity; PxU32 CCDMaxPasses; PxReal CCDMaxSeparation; PxReal CCDThreshold; PxReal MaxBiasCoefficient; PxReal FrictionOffsetThreshold; PxReal FrictionCorrelationDistance; PxFrictionType::Enum FrictionType; PxSolverType::Enum SolverType; PxBounds3 VisualizationCullingBox; PxBroadPhaseType::Enum BroadPhaseType; PxTaskManager * TaskManager; PxU32 MaxNbContactDataBlocksUsed; PxU32 ContactReportStreamBufferSize; PxU32 SolverBatchSize; PxU32 SolverArticulationBatchSize; PxReal WakeCounterResetValue; PxgDynamicsMemoryConfig GpuDynamicsConfig; void * UserData; PxSimulationStatistics SimulationStatistics; PX_PHYSX_CORE_API PxSceneGeneratedValues( const PxScene* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, Flags, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, Limits, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, Timestamp, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, Name, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, CpuDispatcher, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, CudaContextManager, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, SimulationEventCallback, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, ContactModifyCallback, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, CCDContactModifyCallback, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, BroadPhaseCallback, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, FilterShaderDataSize, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, FilterShader, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, FilterCallback, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, KinematicKinematicFilteringMode, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, StaticKinematicFilteringMode, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, Gravity, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, BounceThresholdVelocity, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, CCDMaxPasses, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, CCDMaxSeparation, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, CCDThreshold, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, MaxBiasCoefficient, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, FrictionOffsetThreshold, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, FrictionCorrelationDistance, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, FrictionType, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, SolverType, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, VisualizationCullingBox, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, BroadPhaseType, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, TaskManager, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, MaxNbContactDataBlocksUsed, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, ContactReportStreamBufferSize, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, SolverBatchSize, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, SolverArticulationBatchSize, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, WakeCounterResetValue, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, GpuDynamicsConfig, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, UserData, PxSceneGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxScene, SimulationStatistics, PxSceneGeneratedValues) struct PxSceneGeneratedInfo : PxSceneSQSystemGeneratedInfo { static const char* getClassName() { return "PxScene"; } PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_Flags, PxScene, PxSceneFlags > Flags; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_Limits, PxScene, const PxSceneLimits &, PxSceneLimits > Limits; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_Timestamp, PxScene, PxU32 > Timestamp; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_Name, PxScene, const char *, const char * > Name; PxReadOnlyFilteredCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_Actors, PxScene, PxActor *, PxActorTypeFlags > Actors; PxReadOnlyCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_SoftBodies, PxScene, PxSoftBody * > SoftBodies; PxReadOnlyCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_Articulations, PxScene, PxArticulationReducedCoordinate * > Articulations; PxReadOnlyCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_Constraints, PxScene, PxConstraint * > Constraints; PxReadOnlyCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_Aggregates, PxScene, PxAggregate * > Aggregates; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_CpuDispatcher, PxScene, PxCpuDispatcher * > CpuDispatcher; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_CudaContextManager, PxScene, PxCudaContextManager * > CudaContextManager; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_SimulationEventCallback, PxScene, PxSimulationEventCallback *, PxSimulationEventCallback * > SimulationEventCallback; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_ContactModifyCallback, PxScene, PxContactModifyCallback *, PxContactModifyCallback * > ContactModifyCallback; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_CCDContactModifyCallback, PxScene, PxCCDContactModifyCallback *, PxCCDContactModifyCallback * > CCDContactModifyCallback; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_BroadPhaseCallback, PxScene, PxBroadPhaseCallback *, PxBroadPhaseCallback * > BroadPhaseCallback; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_FilterShaderDataSize, PxScene, PxU32 > FilterShaderDataSize; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_FilterShader, PxScene, PxSimulationFilterShader > FilterShader; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_FilterCallback, PxScene, PxSimulationFilterCallback * > FilterCallback; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_KinematicKinematicFilteringMode, PxScene, PxPairFilteringMode::Enum > KinematicKinematicFilteringMode; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_StaticKinematicFilteringMode, PxScene, PxPairFilteringMode::Enum > StaticKinematicFilteringMode; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_Gravity, PxScene, const PxVec3 &, PxVec3 > Gravity; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_BounceThresholdVelocity, PxScene, const PxReal, PxReal > BounceThresholdVelocity; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_CCDMaxPasses, PxScene, PxU32, PxU32 > CCDMaxPasses; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_CCDMaxSeparation, PxScene, const PxReal, PxReal > CCDMaxSeparation; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_CCDThreshold, PxScene, const PxReal, PxReal > CCDThreshold; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_MaxBiasCoefficient, PxScene, const PxReal, PxReal > MaxBiasCoefficient; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_FrictionOffsetThreshold, PxScene, const PxReal, PxReal > FrictionOffsetThreshold; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_FrictionCorrelationDistance, PxScene, const PxReal, PxReal > FrictionCorrelationDistance; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_FrictionType, PxScene, PxFrictionType::Enum > FrictionType; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_SolverType, PxScene, PxSolverType::Enum > SolverType; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_VisualizationCullingBox, PxScene, const PxBounds3 &, PxBounds3 > VisualizationCullingBox; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_BroadPhaseType, PxScene, PxBroadPhaseType::Enum > BroadPhaseType; PxReadOnlyCollectionPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_BroadPhaseRegions, PxScene, PxBroadPhaseRegionInfo > BroadPhaseRegions; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_TaskManager, PxScene, PxTaskManager * > TaskManager; PxWriteOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_NbContactDataBlocks, PxScene, PxU32 > NbContactDataBlocks; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_MaxNbContactDataBlocksUsed, PxScene, PxU32 > MaxNbContactDataBlocksUsed; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_ContactReportStreamBufferSize, PxScene, PxU32 > ContactReportStreamBufferSize; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_SolverBatchSize, PxScene, PxU32, PxU32 > SolverBatchSize; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_SolverArticulationBatchSize, PxScene, PxU32, PxU32 > SolverArticulationBatchSize; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_WakeCounterResetValue, PxScene, PxReal > WakeCounterResetValue; PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_GpuDynamicsConfig, PxScene, PxgDynamicsMemoryConfig > GpuDynamicsConfig; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxScene_UserData, PxScene, void *, void * > UserData; SimulationStatisticsProperty SimulationStatistics; PX_PHYSX_CORE_API PxSceneGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxScene*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxSceneSQSystemGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxSceneSQSystemGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxSceneSQSystemGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 43; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxSceneSQSystemGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( Flags, inStartIndex + 0 );; inOperator( Limits, inStartIndex + 1 );; inOperator( Timestamp, inStartIndex + 2 );; inOperator( Name, inStartIndex + 3 );; inOperator( Actors, inStartIndex + 4 );; inOperator( SoftBodies, inStartIndex + 5 );; inOperator( Articulations, inStartIndex + 6 );; inOperator( Constraints, inStartIndex + 7 );; inOperator( Aggregates, inStartIndex + 8 );; inOperator( CpuDispatcher, inStartIndex + 9 );; inOperator( CudaContextManager, inStartIndex + 10 );; inOperator( SimulationEventCallback, inStartIndex + 11 );; inOperator( ContactModifyCallback, inStartIndex + 12 );; inOperator( CCDContactModifyCallback, inStartIndex + 13 );; inOperator( BroadPhaseCallback, inStartIndex + 14 );; inOperator( FilterShaderDataSize, inStartIndex + 15 );; inOperator( FilterShader, inStartIndex + 16 );; inOperator( FilterCallback, inStartIndex + 17 );; inOperator( KinematicKinematicFilteringMode, inStartIndex + 18 );; inOperator( StaticKinematicFilteringMode, inStartIndex + 19 );; inOperator( Gravity, inStartIndex + 20 );; inOperator( BounceThresholdVelocity, inStartIndex + 21 );; inOperator( CCDMaxPasses, inStartIndex + 22 );; inOperator( CCDMaxSeparation, inStartIndex + 23 );; inOperator( CCDThreshold, inStartIndex + 24 );; inOperator( MaxBiasCoefficient, inStartIndex + 25 );; inOperator( FrictionOffsetThreshold, inStartIndex + 26 );; inOperator( FrictionCorrelationDistance, inStartIndex + 27 );; inOperator( FrictionType, inStartIndex + 28 );; inOperator( SolverType, inStartIndex + 29 );; inOperator( VisualizationCullingBox, inStartIndex + 30 );; inOperator( BroadPhaseType, inStartIndex + 31 );; inOperator( BroadPhaseRegions, inStartIndex + 32 );; inOperator( TaskManager, inStartIndex + 33 );; inOperator( NbContactDataBlocks, inStartIndex + 34 );; inOperator( MaxNbContactDataBlocksUsed, inStartIndex + 35 );; inOperator( ContactReportStreamBufferSize, inStartIndex + 36 );; inOperator( SolverBatchSize, inStartIndex + 37 );; inOperator( SolverArticulationBatchSize, inStartIndex + 38 );; inOperator( WakeCounterResetValue, inStartIndex + 39 );; inOperator( GpuDynamicsConfig, inStartIndex + 40 );; inOperator( UserData, inStartIndex + 41 );; inOperator( SimulationStatistics, inStartIndex + 42 );; return 43 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxScene> { PxSceneGeneratedInfo Info; const PxSceneGeneratedInfo* getInfo() { return &Info; } }; class PxTetrahedronMeshGeometry; struct PxTetrahedronMeshGeometryGeneratedValues : PxGeometryGeneratedValues { PxTetrahedronMesh * TetrahedronMesh; PX_PHYSX_CORE_API PxTetrahedronMeshGeometryGeneratedValues( const PxTetrahedronMeshGeometry* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxTetrahedronMeshGeometry, TetrahedronMesh, PxTetrahedronMeshGeometryGeneratedValues) struct PxTetrahedronMeshGeometryGeneratedInfo : PxGeometryGeneratedInfo { static const char* getClassName() { return "PxTetrahedronMeshGeometry"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxTetrahedronMeshGeometry_TetrahedronMesh, PxTetrahedronMeshGeometry, PxTetrahedronMesh *, PxTetrahedronMesh * > TetrahedronMesh; PX_PHYSX_CORE_API PxTetrahedronMeshGeometryGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxTetrahedronMeshGeometry*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxGeometryGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxGeometryGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxGeometryGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 1; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxGeometryGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( TetrahedronMesh, inStartIndex + 0 );; return 1 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxTetrahedronMeshGeometry> { PxTetrahedronMeshGeometryGeneratedInfo Info; const PxTetrahedronMeshGeometryGeneratedInfo* getInfo() { return &Info; } }; class PxCustomGeometry; struct PxCustomGeometryGeneratedValues : PxGeometryGeneratedValues { PxU32 CustomType; PX_PHYSX_CORE_API PxCustomGeometryGeneratedValues( const PxCustomGeometry* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxCustomGeometry, CustomType, PxCustomGeometryGeneratedValues) struct PxCustomGeometryGeneratedInfo : PxGeometryGeneratedInfo { static const char* getClassName() { return "PxCustomGeometry"; } PxCustomGeometryCustomTypeProperty CustomType; PX_PHYSX_CORE_API PxCustomGeometryGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxCustomGeometry*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxGeometryGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxGeometryGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxGeometryGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 1; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxGeometryGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( CustomType, inStartIndex + 0 );; return 1 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxCustomGeometry> { PxCustomGeometryGeneratedInfo Info; const PxCustomGeometryGeneratedInfo* getInfo() { return &Info; } }; static PxU32ToName g_physx__PxHeightFieldFormat__EnumConversion[] = { { "eS16_TM", static_cast<PxU32>( physx::PxHeightFieldFormat::eS16_TM ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxHeightFieldFormat::Enum > { PxEnumTraits() : NameConversion( g_physx__PxHeightFieldFormat__EnumConversion ) {} const PxU32ToName* NameConversion; }; static PxU32ToName g_physx__PxHeightFieldFlag__EnumConversion[] = { { "eNO_BOUNDARY_EDGES", static_cast<PxU32>( physx::PxHeightFieldFlag::eNO_BOUNDARY_EDGES ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxHeightFieldFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxHeightFieldFlag__EnumConversion ) {} const PxU32ToName* NameConversion; }; class PxHeightFieldDesc; struct PxHeightFieldDescGeneratedValues { PxU32 NbRows; PxU32 NbColumns; PxHeightFieldFormat::Enum Format; PxStridedData Samples; PxReal ConvexEdgeThreshold; PxHeightFieldFlags Flags; PX_PHYSX_CORE_API PxHeightFieldDescGeneratedValues( const PxHeightFieldDesc* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxHeightFieldDesc, NbRows, PxHeightFieldDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxHeightFieldDesc, NbColumns, PxHeightFieldDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxHeightFieldDesc, Format, PxHeightFieldDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxHeightFieldDesc, Samples, PxHeightFieldDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxHeightFieldDesc, ConvexEdgeThreshold, PxHeightFieldDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxHeightFieldDesc, Flags, PxHeightFieldDescGeneratedValues) struct PxHeightFieldDescGeneratedInfo { static const char* getClassName() { return "PxHeightFieldDesc"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxHeightFieldDesc_NbRows, PxHeightFieldDesc, PxU32, PxU32 > NbRows; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxHeightFieldDesc_NbColumns, PxHeightFieldDesc, PxU32, PxU32 > NbColumns; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxHeightFieldDesc_Format, PxHeightFieldDesc, PxHeightFieldFormat::Enum, PxHeightFieldFormat::Enum > Format; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxHeightFieldDesc_Samples, PxHeightFieldDesc, PxStridedData, PxStridedData > Samples; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxHeightFieldDesc_ConvexEdgeThreshold, PxHeightFieldDesc, PxReal, PxReal > ConvexEdgeThreshold; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxHeightFieldDesc_Flags, PxHeightFieldDesc, PxHeightFieldFlags, PxHeightFieldFlags > Flags; PX_PHYSX_CORE_API PxHeightFieldDescGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxHeightFieldDesc*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); return inStartIndex; } static PxU32 instancePropertyCount() { return 6; } static PxU32 totalPropertyCount() { return instancePropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( NbRows, inStartIndex + 0 );; inOperator( NbColumns, inStartIndex + 1 );; inOperator( Format, inStartIndex + 2 );; inOperator( Samples, inStartIndex + 3 );; inOperator( ConvexEdgeThreshold, inStartIndex + 4 );; inOperator( Flags, inStartIndex + 5 );; return 6 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxHeightFieldDesc> { PxHeightFieldDescGeneratedInfo Info; const PxHeightFieldDescGeneratedInfo* getInfo() { return &Info; } }; struct PxArticulationLimit; struct PxArticulationLimitGeneratedValues { PxReal Low; PxReal High; PX_PHYSX_CORE_API PxArticulationLimitGeneratedValues( const PxArticulationLimit* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationLimit, Low, PxArticulationLimitGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationLimit, High, PxArticulationLimitGeneratedValues) struct PxArticulationLimitGeneratedInfo { static const char* getClassName() { return "PxArticulationLimit"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationLimit_Low, PxArticulationLimit, PxReal, PxReal > Low; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationLimit_High, PxArticulationLimit, PxReal, PxReal > High; PX_PHYSX_CORE_API PxArticulationLimitGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxArticulationLimit*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); return inStartIndex; } static PxU32 instancePropertyCount() { return 2; } static PxU32 totalPropertyCount() { return instancePropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( Low, inStartIndex + 0 );; inOperator( High, inStartIndex + 1 );; return 2 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxArticulationLimit> { PxArticulationLimitGeneratedInfo Info; const PxArticulationLimitGeneratedInfo* getInfo() { return &Info; } }; static PxU32ToName g_physx__PxArticulationDriveType__EnumConversion[] = { { "eFORCE", static_cast<PxU32>( physx::PxArticulationDriveType::eFORCE ) }, { "eACCELERATION", static_cast<PxU32>( physx::PxArticulationDriveType::eACCELERATION ) }, { "eTARGET", static_cast<PxU32>( physx::PxArticulationDriveType::eTARGET ) }, { "eVELOCITY", static_cast<PxU32>( physx::PxArticulationDriveType::eVELOCITY ) }, { "eNONE", static_cast<PxU32>( physx::PxArticulationDriveType::eNONE ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxArticulationDriveType::Enum > { PxEnumTraits() : NameConversion( g_physx__PxArticulationDriveType__EnumConversion ) {} const PxU32ToName* NameConversion; }; struct PxArticulationDrive; struct PxArticulationDriveGeneratedValues { PxReal Stiffness; PxReal Damping; PxReal MaxForce; PxArticulationDriveType::Enum DriveType; PX_PHYSX_CORE_API PxArticulationDriveGeneratedValues( const PxArticulationDrive* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationDrive, Stiffness, PxArticulationDriveGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationDrive, Damping, PxArticulationDriveGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationDrive, MaxForce, PxArticulationDriveGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxArticulationDrive, DriveType, PxArticulationDriveGeneratedValues) struct PxArticulationDriveGeneratedInfo { static const char* getClassName() { return "PxArticulationDrive"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationDrive_Stiffness, PxArticulationDrive, PxReal, PxReal > Stiffness; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationDrive_Damping, PxArticulationDrive, PxReal, PxReal > Damping; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationDrive_MaxForce, PxArticulationDrive, PxReal, PxReal > MaxForce; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxArticulationDrive_DriveType, PxArticulationDrive, PxArticulationDriveType::Enum, PxArticulationDriveType::Enum > DriveType; PX_PHYSX_CORE_API PxArticulationDriveGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxArticulationDrive*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); return inStartIndex; } static PxU32 instancePropertyCount() { return 4; } static PxU32 totalPropertyCount() { return instancePropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( Stiffness, inStartIndex + 0 );; inOperator( Damping, inStartIndex + 1 );; inOperator( MaxForce, inStartIndex + 2 );; inOperator( DriveType, inStartIndex + 3 );; return 4 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxArticulationDrive> { PxArticulationDriveGeneratedInfo Info; const PxArticulationDriveGeneratedInfo* getInfo() { return &Info; } }; static PxU32ToName g_physx__PxDynamicTreeSecondaryPruner__EnumConversion[] = { { "eNONE", static_cast<PxU32>( physx::PxDynamicTreeSecondaryPruner::eNONE ) }, { "eBUCKET", static_cast<PxU32>( physx::PxDynamicTreeSecondaryPruner::eBUCKET ) }, { "eINCREMENTAL", static_cast<PxU32>( physx::PxDynamicTreeSecondaryPruner::eINCREMENTAL ) }, { "eBVH", static_cast<PxU32>( physx::PxDynamicTreeSecondaryPruner::eBVH ) }, { "eLAST", static_cast<PxU32>( physx::PxDynamicTreeSecondaryPruner::eLAST ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxDynamicTreeSecondaryPruner::Enum > { PxEnumTraits() : NameConversion( g_physx__PxDynamicTreeSecondaryPruner__EnumConversion ) {} const PxU32ToName* NameConversion; }; static PxU32ToName g_physx__PxBVHBuildStrategy__EnumConversion[] = { { "eFAST", static_cast<PxU32>( physx::PxBVHBuildStrategy::eFAST ) }, { "eDEFAULT", static_cast<PxU32>( physx::PxBVHBuildStrategy::eDEFAULT ) }, { "eSAH", static_cast<PxU32>( physx::PxBVHBuildStrategy::eSAH ) }, { "eLAST", static_cast<PxU32>( physx::PxBVHBuildStrategy::eLAST ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxBVHBuildStrategy::Enum > { PxEnumTraits() : NameConversion( g_physx__PxBVHBuildStrategy__EnumConversion ) {} const PxU32ToName* NameConversion; }; class PxSceneQueryDesc; struct PxSceneQueryDescGeneratedValues { _Bool IsValid; PxPruningStructureType::Enum StaticStructure; PxPruningStructureType::Enum DynamicStructure; PxU32 DynamicTreeRebuildRateHint; PxDynamicTreeSecondaryPruner::Enum DynamicTreeSecondaryPruner; PxBVHBuildStrategy::Enum StaticBVHBuildStrategy; PxBVHBuildStrategy::Enum DynamicBVHBuildStrategy; PxU32 StaticNbObjectsPerNode; PxU32 DynamicNbObjectsPerNode; PxSceneQueryUpdateMode::Enum SceneQueryUpdateMode; PX_PHYSX_CORE_API PxSceneQueryDescGeneratedValues( const PxSceneQueryDesc* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneQueryDesc, IsValid, PxSceneQueryDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneQueryDesc, StaticStructure, PxSceneQueryDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneQueryDesc, DynamicStructure, PxSceneQueryDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneQueryDesc, DynamicTreeRebuildRateHint, PxSceneQueryDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneQueryDesc, DynamicTreeSecondaryPruner, PxSceneQueryDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneQueryDesc, StaticBVHBuildStrategy, PxSceneQueryDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneQueryDesc, DynamicBVHBuildStrategy, PxSceneQueryDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneQueryDesc, StaticNbObjectsPerNode, PxSceneQueryDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneQueryDesc, DynamicNbObjectsPerNode, PxSceneQueryDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneQueryDesc, SceneQueryUpdateMode, PxSceneQueryDescGeneratedValues) struct PxSceneQueryDescGeneratedInfo { static const char* getClassName() { return "PxSceneQueryDesc"; } PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneQueryDesc_IsValid, PxSceneQueryDesc, _Bool > IsValid; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneQueryDesc_StaticStructure, PxSceneQueryDesc, PxPruningStructureType::Enum, PxPruningStructureType::Enum > StaticStructure; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneQueryDesc_DynamicStructure, PxSceneQueryDesc, PxPruningStructureType::Enum, PxPruningStructureType::Enum > DynamicStructure; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneQueryDesc_DynamicTreeRebuildRateHint, PxSceneQueryDesc, PxU32, PxU32 > DynamicTreeRebuildRateHint; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneQueryDesc_DynamicTreeSecondaryPruner, PxSceneQueryDesc, PxDynamicTreeSecondaryPruner::Enum, PxDynamicTreeSecondaryPruner::Enum > DynamicTreeSecondaryPruner; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneQueryDesc_StaticBVHBuildStrategy, PxSceneQueryDesc, PxBVHBuildStrategy::Enum, PxBVHBuildStrategy::Enum > StaticBVHBuildStrategy; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneQueryDesc_DynamicBVHBuildStrategy, PxSceneQueryDesc, PxBVHBuildStrategy::Enum, PxBVHBuildStrategy::Enum > DynamicBVHBuildStrategy; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneQueryDesc_StaticNbObjectsPerNode, PxSceneQueryDesc, PxU32, PxU32 > StaticNbObjectsPerNode; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneQueryDesc_DynamicNbObjectsPerNode, PxSceneQueryDesc, PxU32, PxU32 > DynamicNbObjectsPerNode; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneQueryDesc_SceneQueryUpdateMode, PxSceneQueryDesc, PxSceneQueryUpdateMode::Enum, PxSceneQueryUpdateMode::Enum > SceneQueryUpdateMode; PX_PHYSX_CORE_API PxSceneQueryDescGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxSceneQueryDesc*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); return inStartIndex; } static PxU32 instancePropertyCount() { return 10; } static PxU32 totalPropertyCount() { return instancePropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( IsValid, inStartIndex + 0 );; inOperator( StaticStructure, inStartIndex + 1 );; inOperator( DynamicStructure, inStartIndex + 2 );; inOperator( DynamicTreeRebuildRateHint, inStartIndex + 3 );; inOperator( DynamicTreeSecondaryPruner, inStartIndex + 4 );; inOperator( StaticBVHBuildStrategy, inStartIndex + 5 );; inOperator( DynamicBVHBuildStrategy, inStartIndex + 6 );; inOperator( StaticNbObjectsPerNode, inStartIndex + 7 );; inOperator( DynamicNbObjectsPerNode, inStartIndex + 8 );; inOperator( SceneQueryUpdateMode, inStartIndex + 9 );; return 10 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxSceneQueryDesc> { PxSceneQueryDescGeneratedInfo Info; const PxSceneQueryDescGeneratedInfo* getInfo() { return &Info; } }; class PxSceneDesc; struct PxSceneDescGeneratedValues : PxSceneQueryDescGeneratedValues { PxVec3 Gravity; PxSimulationEventCallback * SimulationEventCallback; PxContactModifyCallback * ContactModifyCallback; PxCCDContactModifyCallback * CcdContactModifyCallback; const void * FilterShaderData; PxU32 FilterShaderDataSize; PxSimulationFilterShader FilterShader; PxSimulationFilterCallback * FilterCallback; PxPairFilteringMode::Enum KineKineFilteringMode; PxPairFilteringMode::Enum StaticKineFilteringMode; PxBroadPhaseType::Enum BroadPhaseType; PxBroadPhaseCallback * BroadPhaseCallback; PxSceneLimits Limits; PxFrictionType::Enum FrictionType; PxSolverType::Enum SolverType; PxReal BounceThresholdVelocity; PxReal FrictionOffsetThreshold; PxReal FrictionCorrelationDistance; PxSceneFlags Flags; PxCpuDispatcher * CpuDispatcher; PxCudaContextManager * CudaContextManager; void * UserData; PxU32 SolverBatchSize; PxU32 SolverArticulationBatchSize; PxU32 NbContactDataBlocks; PxU32 MaxNbContactDataBlocks; PxReal MaxBiasCoefficient; PxU32 ContactReportStreamBufferSize; PxU32 CcdMaxPasses; PxReal CcdThreshold; PxReal CcdMaxSeparation; PxReal WakeCounterResetValue; PxBounds3 SanityBounds; PxgDynamicsMemoryConfig GpuDynamicsConfig; PxU32 GpuMaxNumPartitions; PxU32 GpuMaxNumStaticPartitions; PxU32 GpuComputeVersion; PxU32 ContactPairSlabSize; PX_PHYSX_CORE_API PxSceneDescGeneratedValues( const PxSceneDesc* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, Gravity, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, SimulationEventCallback, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, ContactModifyCallback, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, CcdContactModifyCallback, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, FilterShaderData, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, FilterShaderDataSize, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, FilterShader, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, FilterCallback, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, KineKineFilteringMode, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, StaticKineFilteringMode, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, BroadPhaseType, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, BroadPhaseCallback, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, Limits, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, FrictionType, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, SolverType, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, BounceThresholdVelocity, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, FrictionOffsetThreshold, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, FrictionCorrelationDistance, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, Flags, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, CpuDispatcher, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, CudaContextManager, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, UserData, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, SolverBatchSize, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, SolverArticulationBatchSize, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, NbContactDataBlocks, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, MaxNbContactDataBlocks, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, MaxBiasCoefficient, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, ContactReportStreamBufferSize, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, CcdMaxPasses, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, CcdThreshold, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, CcdMaxSeparation, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, WakeCounterResetValue, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, SanityBounds, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, GpuDynamicsConfig, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, GpuMaxNumPartitions, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, GpuMaxNumStaticPartitions, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, GpuComputeVersion, PxSceneDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneDesc, ContactPairSlabSize, PxSceneDescGeneratedValues) struct PxSceneDescGeneratedInfo : PxSceneQueryDescGeneratedInfo { static const char* getClassName() { return "PxSceneDesc"; } PxWriteOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_ToDefault, PxSceneDesc, const PxTolerancesScale & > ToDefault; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_Gravity, PxSceneDesc, PxVec3, PxVec3 > Gravity; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_SimulationEventCallback, PxSceneDesc, PxSimulationEventCallback *, PxSimulationEventCallback * > SimulationEventCallback; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_ContactModifyCallback, PxSceneDesc, PxContactModifyCallback *, PxContactModifyCallback * > ContactModifyCallback; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_CcdContactModifyCallback, PxSceneDesc, PxCCDContactModifyCallback *, PxCCDContactModifyCallback * > CcdContactModifyCallback; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_FilterShaderData, PxSceneDesc, const void *, const void * > FilterShaderData; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_FilterShaderDataSize, PxSceneDesc, PxU32, PxU32 > FilterShaderDataSize; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_FilterShader, PxSceneDesc, PxSimulationFilterShader, PxSimulationFilterShader > FilterShader; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_FilterCallback, PxSceneDesc, PxSimulationFilterCallback *, PxSimulationFilterCallback * > FilterCallback; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_KineKineFilteringMode, PxSceneDesc, PxPairFilteringMode::Enum, PxPairFilteringMode::Enum > KineKineFilteringMode; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_StaticKineFilteringMode, PxSceneDesc, PxPairFilteringMode::Enum, PxPairFilteringMode::Enum > StaticKineFilteringMode; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_BroadPhaseType, PxSceneDesc, PxBroadPhaseType::Enum, PxBroadPhaseType::Enum > BroadPhaseType; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_BroadPhaseCallback, PxSceneDesc, PxBroadPhaseCallback *, PxBroadPhaseCallback * > BroadPhaseCallback; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_Limits, PxSceneDesc, PxSceneLimits, PxSceneLimits > Limits; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_FrictionType, PxSceneDesc, PxFrictionType::Enum, PxFrictionType::Enum > FrictionType; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_SolverType, PxSceneDesc, PxSolverType::Enum, PxSolverType::Enum > SolverType; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_BounceThresholdVelocity, PxSceneDesc, PxReal, PxReal > BounceThresholdVelocity; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_FrictionOffsetThreshold, PxSceneDesc, PxReal, PxReal > FrictionOffsetThreshold; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_FrictionCorrelationDistance, PxSceneDesc, PxReal, PxReal > FrictionCorrelationDistance; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_Flags, PxSceneDesc, PxSceneFlags, PxSceneFlags > Flags; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_CpuDispatcher, PxSceneDesc, PxCpuDispatcher *, PxCpuDispatcher * > CpuDispatcher; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_CudaContextManager, PxSceneDesc, PxCudaContextManager *, PxCudaContextManager * > CudaContextManager; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_UserData, PxSceneDesc, void *, void * > UserData; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_SolverBatchSize, PxSceneDesc, PxU32, PxU32 > SolverBatchSize; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_SolverArticulationBatchSize, PxSceneDesc, PxU32, PxU32 > SolverArticulationBatchSize; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_NbContactDataBlocks, PxSceneDesc, PxU32, PxU32 > NbContactDataBlocks; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_MaxNbContactDataBlocks, PxSceneDesc, PxU32, PxU32 > MaxNbContactDataBlocks; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_MaxBiasCoefficient, PxSceneDesc, PxReal, PxReal > MaxBiasCoefficient; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_ContactReportStreamBufferSize, PxSceneDesc, PxU32, PxU32 > ContactReportStreamBufferSize; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_CcdMaxPasses, PxSceneDesc, PxU32, PxU32 > CcdMaxPasses; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_CcdThreshold, PxSceneDesc, PxReal, PxReal > CcdThreshold; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_CcdMaxSeparation, PxSceneDesc, PxReal, PxReal > CcdMaxSeparation; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_WakeCounterResetValue, PxSceneDesc, PxReal, PxReal > WakeCounterResetValue; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_SanityBounds, PxSceneDesc, PxBounds3, PxBounds3 > SanityBounds; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_GpuDynamicsConfig, PxSceneDesc, PxgDynamicsMemoryConfig, PxgDynamicsMemoryConfig > GpuDynamicsConfig; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_GpuMaxNumPartitions, PxSceneDesc, PxU32, PxU32 > GpuMaxNumPartitions; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_GpuMaxNumStaticPartitions, PxSceneDesc, PxU32, PxU32 > GpuMaxNumStaticPartitions; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_GpuComputeVersion, PxSceneDesc, PxU32, PxU32 > GpuComputeVersion; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneDesc_ContactPairSlabSize, PxSceneDesc, PxU32, PxU32 > ContactPairSlabSize; PX_PHYSX_CORE_API PxSceneDescGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxSceneDesc*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); inOperator( *static_cast<PxSceneQueryDescGeneratedInfo*>( this ) ); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inStartIndex = PxSceneQueryDescGeneratedInfo::visitBaseProperties( inOperator, inStartIndex ); inStartIndex = PxSceneQueryDescGeneratedInfo::visitInstanceProperties( inOperator, inStartIndex ); return inStartIndex; } static PxU32 instancePropertyCount() { return 39; } static PxU32 totalPropertyCount() { return instancePropertyCount() + PxSceneQueryDescGeneratedInfo::totalPropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( ToDefault, inStartIndex + 0 );; inOperator( Gravity, inStartIndex + 1 );; inOperator( SimulationEventCallback, inStartIndex + 2 );; inOperator( ContactModifyCallback, inStartIndex + 3 );; inOperator( CcdContactModifyCallback, inStartIndex + 4 );; inOperator( FilterShaderData, inStartIndex + 5 );; inOperator( FilterShaderDataSize, inStartIndex + 6 );; inOperator( FilterShader, inStartIndex + 7 );; inOperator( FilterCallback, inStartIndex + 8 );; inOperator( KineKineFilteringMode, inStartIndex + 9 );; inOperator( StaticKineFilteringMode, inStartIndex + 10 );; inOperator( BroadPhaseType, inStartIndex + 11 );; inOperator( BroadPhaseCallback, inStartIndex + 12 );; inOperator( Limits, inStartIndex + 13 );; inOperator( FrictionType, inStartIndex + 14 );; inOperator( SolverType, inStartIndex + 15 );; inOperator( BounceThresholdVelocity, inStartIndex + 16 );; inOperator( FrictionOffsetThreshold, inStartIndex + 17 );; inOperator( FrictionCorrelationDistance, inStartIndex + 18 );; inOperator( Flags, inStartIndex + 19 );; inOperator( CpuDispatcher, inStartIndex + 20 );; inOperator( CudaContextManager, inStartIndex + 21 );; inOperator( UserData, inStartIndex + 22 );; inOperator( SolverBatchSize, inStartIndex + 23 );; inOperator( SolverArticulationBatchSize, inStartIndex + 24 );; inOperator( NbContactDataBlocks, inStartIndex + 25 );; inOperator( MaxNbContactDataBlocks, inStartIndex + 26 );; inOperator( MaxBiasCoefficient, inStartIndex + 27 );; inOperator( ContactReportStreamBufferSize, inStartIndex + 28 );; inOperator( CcdMaxPasses, inStartIndex + 29 );; inOperator( CcdThreshold, inStartIndex + 30 );; inOperator( CcdMaxSeparation, inStartIndex + 31 );; inOperator( WakeCounterResetValue, inStartIndex + 32 );; inOperator( SanityBounds, inStartIndex + 33 );; inOperator( GpuDynamicsConfig, inStartIndex + 34 );; inOperator( GpuMaxNumPartitions, inStartIndex + 35 );; inOperator( GpuMaxNumStaticPartitions, inStartIndex + 36 );; inOperator( GpuComputeVersion, inStartIndex + 37 );; inOperator( ContactPairSlabSize, inStartIndex + 38 );; return 39 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxSceneDesc> { PxSceneDescGeneratedInfo Info; const PxSceneDescGeneratedInfo* getInfo() { return &Info; } }; class PxBroadPhaseDesc; struct PxBroadPhaseDescGeneratedValues { _Bool IsValid; PxBroadPhaseType::Enum MType; PxU64 MContextID; PxCudaContextManager * MContextManager; PxU32 MFoundLostPairsCapacity; _Bool MDiscardStaticVsKinematic; _Bool MDiscardKinematicVsKinematic; PX_PHYSX_CORE_API PxBroadPhaseDescGeneratedValues( const PxBroadPhaseDesc* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxBroadPhaseDesc, IsValid, PxBroadPhaseDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxBroadPhaseDesc, MType, PxBroadPhaseDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxBroadPhaseDesc, MContextID, PxBroadPhaseDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxBroadPhaseDesc, MContextManager, PxBroadPhaseDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxBroadPhaseDesc, MFoundLostPairsCapacity, PxBroadPhaseDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxBroadPhaseDesc, MDiscardStaticVsKinematic, PxBroadPhaseDescGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxBroadPhaseDesc, MDiscardKinematicVsKinematic, PxBroadPhaseDescGeneratedValues) struct PxBroadPhaseDescGeneratedInfo { static const char* getClassName() { return "PxBroadPhaseDesc"; } PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxBroadPhaseDesc_IsValid, PxBroadPhaseDesc, _Bool > IsValid; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxBroadPhaseDesc_MType, PxBroadPhaseDesc, PxBroadPhaseType::Enum, PxBroadPhaseType::Enum > MType; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxBroadPhaseDesc_MContextID, PxBroadPhaseDesc, PxU64, PxU64 > MContextID; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxBroadPhaseDesc_MContextManager, PxBroadPhaseDesc, PxCudaContextManager *, PxCudaContextManager * > MContextManager; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxBroadPhaseDesc_MFoundLostPairsCapacity, PxBroadPhaseDesc, PxU32, PxU32 > MFoundLostPairsCapacity; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxBroadPhaseDesc_MDiscardStaticVsKinematic, PxBroadPhaseDesc, _Bool, _Bool > MDiscardStaticVsKinematic; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxBroadPhaseDesc_MDiscardKinematicVsKinematic, PxBroadPhaseDesc, _Bool, _Bool > MDiscardKinematicVsKinematic; PX_PHYSX_CORE_API PxBroadPhaseDescGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxBroadPhaseDesc*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); return inStartIndex; } static PxU32 instancePropertyCount() { return 7; } static PxU32 totalPropertyCount() { return instancePropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( IsValid, inStartIndex + 0 );; inOperator( MType, inStartIndex + 1 );; inOperator( MContextID, inStartIndex + 2 );; inOperator( MContextManager, inStartIndex + 3 );; inOperator( MFoundLostPairsCapacity, inStartIndex + 4 );; inOperator( MDiscardStaticVsKinematic, inStartIndex + 5 );; inOperator( MDiscardKinematicVsKinematic, inStartIndex + 6 );; return 7 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxBroadPhaseDesc> { PxBroadPhaseDescGeneratedInfo Info; const PxBroadPhaseDescGeneratedInfo* getInfo() { return &Info; } }; class PxSceneLimits; struct PxSceneLimitsGeneratedValues { PxU32 MaxNbActors; PxU32 MaxNbBodies; PxU32 MaxNbStaticShapes; PxU32 MaxNbDynamicShapes; PxU32 MaxNbAggregates; PxU32 MaxNbConstraints; PxU32 MaxNbRegions; PxU32 MaxNbBroadPhaseOverlaps; PX_PHYSX_CORE_API PxSceneLimitsGeneratedValues( const PxSceneLimits* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneLimits, MaxNbActors, PxSceneLimitsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneLimits, MaxNbBodies, PxSceneLimitsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneLimits, MaxNbStaticShapes, PxSceneLimitsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneLimits, MaxNbDynamicShapes, PxSceneLimitsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneLimits, MaxNbAggregates, PxSceneLimitsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneLimits, MaxNbConstraints, PxSceneLimitsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneLimits, MaxNbRegions, PxSceneLimitsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSceneLimits, MaxNbBroadPhaseOverlaps, PxSceneLimitsGeneratedValues) struct PxSceneLimitsGeneratedInfo { static const char* getClassName() { return "PxSceneLimits"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneLimits_MaxNbActors, PxSceneLimits, PxU32, PxU32 > MaxNbActors; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneLimits_MaxNbBodies, PxSceneLimits, PxU32, PxU32 > MaxNbBodies; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneLimits_MaxNbStaticShapes, PxSceneLimits, PxU32, PxU32 > MaxNbStaticShapes; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneLimits_MaxNbDynamicShapes, PxSceneLimits, PxU32, PxU32 > MaxNbDynamicShapes; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneLimits_MaxNbAggregates, PxSceneLimits, PxU32, PxU32 > MaxNbAggregates; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneLimits_MaxNbConstraints, PxSceneLimits, PxU32, PxU32 > MaxNbConstraints; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneLimits_MaxNbRegions, PxSceneLimits, PxU32, PxU32 > MaxNbRegions; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSceneLimits_MaxNbBroadPhaseOverlaps, PxSceneLimits, PxU32, PxU32 > MaxNbBroadPhaseOverlaps; PX_PHYSX_CORE_API PxSceneLimitsGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxSceneLimits*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); return inStartIndex; } static PxU32 instancePropertyCount() { return 8; } static PxU32 totalPropertyCount() { return instancePropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( MaxNbActors, inStartIndex + 0 );; inOperator( MaxNbBodies, inStartIndex + 1 );; inOperator( MaxNbStaticShapes, inStartIndex + 2 );; inOperator( MaxNbDynamicShapes, inStartIndex + 3 );; inOperator( MaxNbAggregates, inStartIndex + 4 );; inOperator( MaxNbConstraints, inStartIndex + 5 );; inOperator( MaxNbRegions, inStartIndex + 6 );; inOperator( MaxNbBroadPhaseOverlaps, inStartIndex + 7 );; return 8 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxSceneLimits> { PxSceneLimitsGeneratedInfo Info; const PxSceneLimitsGeneratedInfo* getInfo() { return &Info; } }; struct PxgDynamicsMemoryConfig; struct PxgDynamicsMemoryConfigGeneratedValues { _Bool IsValid; PxU32 TempBufferCapacity; PxU32 MaxRigidContactCount; PxU32 MaxRigidPatchCount; PxU32 HeapCapacity; PxU32 FoundLostPairsCapacity; PxU32 FoundLostAggregatePairsCapacity; PxU32 TotalAggregatePairsCapacity; PxU32 MaxSoftBodyContacts; PxU32 MaxFemClothContacts; PxU32 MaxParticleContacts; PxU32 CollisionStackSize; PxU32 MaxHairContacts; PX_PHYSX_CORE_API PxgDynamicsMemoryConfigGeneratedValues( const PxgDynamicsMemoryConfig* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxgDynamicsMemoryConfig, IsValid, PxgDynamicsMemoryConfigGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxgDynamicsMemoryConfig, TempBufferCapacity, PxgDynamicsMemoryConfigGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxgDynamicsMemoryConfig, MaxRigidContactCount, PxgDynamicsMemoryConfigGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxgDynamicsMemoryConfig, MaxRigidPatchCount, PxgDynamicsMemoryConfigGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxgDynamicsMemoryConfig, HeapCapacity, PxgDynamicsMemoryConfigGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxgDynamicsMemoryConfig, FoundLostPairsCapacity, PxgDynamicsMemoryConfigGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxgDynamicsMemoryConfig, FoundLostAggregatePairsCapacity, PxgDynamicsMemoryConfigGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxgDynamicsMemoryConfig, TotalAggregatePairsCapacity, PxgDynamicsMemoryConfigGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxgDynamicsMemoryConfig, MaxSoftBodyContacts, PxgDynamicsMemoryConfigGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxgDynamicsMemoryConfig, MaxFemClothContacts, PxgDynamicsMemoryConfigGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxgDynamicsMemoryConfig, MaxParticleContacts, PxgDynamicsMemoryConfigGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxgDynamicsMemoryConfig, CollisionStackSize, PxgDynamicsMemoryConfigGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxgDynamicsMemoryConfig, MaxHairContacts, PxgDynamicsMemoryConfigGeneratedValues) struct PxgDynamicsMemoryConfigGeneratedInfo { static const char* getClassName() { return "PxgDynamicsMemoryConfig"; } PxReadOnlyPropertyInfo<PX_PROPERTY_INFO_NAME::PxgDynamicsMemoryConfig_IsValid, PxgDynamicsMemoryConfig, _Bool > IsValid; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxgDynamicsMemoryConfig_TempBufferCapacity, PxgDynamicsMemoryConfig, PxU32, PxU32 > TempBufferCapacity; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxgDynamicsMemoryConfig_MaxRigidContactCount, PxgDynamicsMemoryConfig, PxU32, PxU32 > MaxRigidContactCount; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxgDynamicsMemoryConfig_MaxRigidPatchCount, PxgDynamicsMemoryConfig, PxU32, PxU32 > MaxRigidPatchCount; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxgDynamicsMemoryConfig_HeapCapacity, PxgDynamicsMemoryConfig, PxU32, PxU32 > HeapCapacity; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxgDynamicsMemoryConfig_FoundLostPairsCapacity, PxgDynamicsMemoryConfig, PxU32, PxU32 > FoundLostPairsCapacity; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxgDynamicsMemoryConfig_FoundLostAggregatePairsCapacity, PxgDynamicsMemoryConfig, PxU32, PxU32 > FoundLostAggregatePairsCapacity; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxgDynamicsMemoryConfig_TotalAggregatePairsCapacity, PxgDynamicsMemoryConfig, PxU32, PxU32 > TotalAggregatePairsCapacity; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxgDynamicsMemoryConfig_MaxSoftBodyContacts, PxgDynamicsMemoryConfig, PxU32, PxU32 > MaxSoftBodyContacts; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxgDynamicsMemoryConfig_MaxFemClothContacts, PxgDynamicsMemoryConfig, PxU32, PxU32 > MaxFemClothContacts; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxgDynamicsMemoryConfig_MaxParticleContacts, PxgDynamicsMemoryConfig, PxU32, PxU32 > MaxParticleContacts; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxgDynamicsMemoryConfig_CollisionStackSize, PxgDynamicsMemoryConfig, PxU32, PxU32 > CollisionStackSize; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxgDynamicsMemoryConfig_MaxHairContacts, PxgDynamicsMemoryConfig, PxU32, PxU32 > MaxHairContacts; PX_PHYSX_CORE_API PxgDynamicsMemoryConfigGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxgDynamicsMemoryConfig*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); return inStartIndex; } static PxU32 instancePropertyCount() { return 13; } static PxU32 totalPropertyCount() { return instancePropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( IsValid, inStartIndex + 0 );; inOperator( TempBufferCapacity, inStartIndex + 1 );; inOperator( MaxRigidContactCount, inStartIndex + 2 );; inOperator( MaxRigidPatchCount, inStartIndex + 3 );; inOperator( HeapCapacity, inStartIndex + 4 );; inOperator( FoundLostPairsCapacity, inStartIndex + 5 );; inOperator( FoundLostAggregatePairsCapacity, inStartIndex + 6 );; inOperator( TotalAggregatePairsCapacity, inStartIndex + 7 );; inOperator( MaxSoftBodyContacts, inStartIndex + 8 );; inOperator( MaxFemClothContacts, inStartIndex + 9 );; inOperator( MaxParticleContacts, inStartIndex + 10 );; inOperator( CollisionStackSize, inStartIndex + 11 );; inOperator( MaxHairContacts, inStartIndex + 12 );; return 13 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxgDynamicsMemoryConfig> { PxgDynamicsMemoryConfigGeneratedInfo Info; const PxgDynamicsMemoryConfigGeneratedInfo* getInfo() { return &Info; } }; static PxU32ToName g_physx__PxSimulationStatistics__RbPairStatsTypeConversion[] = { { "eDISCRETE_CONTACT_PAIRS", static_cast<PxU32>( physx::PxSimulationStatistics::eDISCRETE_CONTACT_PAIRS ) }, { "eCCD_PAIRS", static_cast<PxU32>( physx::PxSimulationStatistics::eCCD_PAIRS ) }, { "eMODIFIED_CONTACT_PAIRS", static_cast<PxU32>( physx::PxSimulationStatistics::eMODIFIED_CONTACT_PAIRS ) }, { "eTRIGGER_PAIRS", static_cast<PxU32>( physx::PxSimulationStatistics::eTRIGGER_PAIRS ) }, { NULL, 0 } }; template<> struct PxEnumTraits< physx::PxSimulationStatistics::RbPairStatsType > { PxEnumTraits() : NameConversion( g_physx__PxSimulationStatistics__RbPairStatsTypeConversion ) {} const PxU32ToName* NameConversion; }; class PxSimulationStatistics; struct PxSimulationStatisticsGeneratedValues { PxU32 NbActiveConstraints; PxU32 NbActiveDynamicBodies; PxU32 NbActiveKinematicBodies; PxU32 NbStaticBodies; PxU32 NbDynamicBodies; PxU32 NbKinematicBodies; PxU32 NbAggregates; PxU32 NbArticulations; PxU32 NbAxisSolverConstraints; PxU32 CompressedContactSize; PxU32 RequiredContactConstraintMemory; PxU32 PeakConstraintMemory; PxU32 NbDiscreteContactPairsTotal; PxU32 NbDiscreteContactPairsWithCacheHits; PxU32 NbDiscreteContactPairsWithContacts; PxU32 NbNewPairs; PxU32 NbLostPairs; PxU32 NbNewTouches; PxU32 NbLostTouches; PxU32 NbPartitions; PxU64 GpuMemParticles; PxU64 GpuMemSoftBodies; PxU64 GpuMemFEMCloths; PxU64 GpuMemHairSystems; PxU64 GpuMemHeap; PxU64 GpuMemHeapBroadPhase; PxU64 GpuMemHeapNarrowPhase; PxU64 GpuMemHeapSolver; PxU64 GpuMemHeapArticulation; PxU64 GpuMemHeapSimulation; PxU64 GpuMemHeapSimulationArticulation; PxU64 GpuMemHeapSimulationParticles; PxU64 GpuMemHeapSimulationSoftBody; PxU64 GpuMemHeapSimulationFEMCloth; PxU64 GpuMemHeapSimulationHairSystem; PxU64 GpuMemHeapParticles; PxU64 GpuMemHeapSoftBodies; PxU64 GpuMemHeapFEMCloths; PxU64 GpuMemHeapHairSystems; PxU64 GpuMemHeapOther; PxU32 NbBroadPhaseAdds; PxU32 NbBroadPhaseRemoves; PxU32 NbDiscreteContactPairs[PxGeometryType::eGEOMETRY_COUNT][PxGeometryType::eGEOMETRY_COUNT]; PxU32 NbModifiedContactPairs[PxGeometryType::eGEOMETRY_COUNT][PxGeometryType::eGEOMETRY_COUNT]; PxU32 NbCCDPairs[PxGeometryType::eGEOMETRY_COUNT][PxGeometryType::eGEOMETRY_COUNT]; PxU32 NbTriggerPairs[PxGeometryType::eGEOMETRY_COUNT][PxGeometryType::eGEOMETRY_COUNT]; PxU32 NbShapes[PxGeometryType::eGEOMETRY_COUNT]; PX_PHYSX_CORE_API PxSimulationStatisticsGeneratedValues( const PxSimulationStatistics* inSource ); }; DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbActiveConstraints, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbActiveDynamicBodies, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbActiveKinematicBodies, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbStaticBodies, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbDynamicBodies, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbKinematicBodies, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbAggregates, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbArticulations, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbAxisSolverConstraints, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, CompressedContactSize, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, RequiredContactConstraintMemory, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, PeakConstraintMemory, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbDiscreteContactPairsTotal, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbDiscreteContactPairsWithCacheHits, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbDiscreteContactPairsWithContacts, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbNewPairs, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbLostPairs, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbNewTouches, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbLostTouches, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbPartitions, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemParticles, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemSoftBodies, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemFEMCloths, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemHairSystems, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemHeap, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemHeapBroadPhase, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemHeapNarrowPhase, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemHeapSolver, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemHeapArticulation, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemHeapSimulation, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemHeapSimulationArticulation, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemHeapSimulationParticles, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemHeapSimulationSoftBody, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemHeapSimulationFEMCloth, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemHeapSimulationHairSystem, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemHeapParticles, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemHeapSoftBodies, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemHeapFEMCloths, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemHeapHairSystems, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, GpuMemHeapOther, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbBroadPhaseAdds, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbBroadPhaseRemoves, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbDiscreteContactPairs, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbModifiedContactPairs, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbCCDPairs, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbTriggerPairs, PxSimulationStatisticsGeneratedValues) DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( PxSimulationStatistics, NbShapes, PxSimulationStatisticsGeneratedValues) struct PxSimulationStatisticsGeneratedInfo { static const char* getClassName() { return "PxSimulationStatistics"; } PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbActiveConstraints, PxSimulationStatistics, PxU32, PxU32 > NbActiveConstraints; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbActiveDynamicBodies, PxSimulationStatistics, PxU32, PxU32 > NbActiveDynamicBodies; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbActiveKinematicBodies, PxSimulationStatistics, PxU32, PxU32 > NbActiveKinematicBodies; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbStaticBodies, PxSimulationStatistics, PxU32, PxU32 > NbStaticBodies; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbDynamicBodies, PxSimulationStatistics, PxU32, PxU32 > NbDynamicBodies; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbKinematicBodies, PxSimulationStatistics, PxU32, PxU32 > NbKinematicBodies; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbAggregates, PxSimulationStatistics, PxU32, PxU32 > NbAggregates; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbArticulations, PxSimulationStatistics, PxU32, PxU32 > NbArticulations; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbAxisSolverConstraints, PxSimulationStatistics, PxU32, PxU32 > NbAxisSolverConstraints; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_CompressedContactSize, PxSimulationStatistics, PxU32, PxU32 > CompressedContactSize; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_RequiredContactConstraintMemory, PxSimulationStatistics, PxU32, PxU32 > RequiredContactConstraintMemory; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_PeakConstraintMemory, PxSimulationStatistics, PxU32, PxU32 > PeakConstraintMemory; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbDiscreteContactPairsTotal, PxSimulationStatistics, PxU32, PxU32 > NbDiscreteContactPairsTotal; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbDiscreteContactPairsWithCacheHits, PxSimulationStatistics, PxU32, PxU32 > NbDiscreteContactPairsWithCacheHits; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbDiscreteContactPairsWithContacts, PxSimulationStatistics, PxU32, PxU32 > NbDiscreteContactPairsWithContacts; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbNewPairs, PxSimulationStatistics, PxU32, PxU32 > NbNewPairs; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbLostPairs, PxSimulationStatistics, PxU32, PxU32 > NbLostPairs; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbNewTouches, PxSimulationStatistics, PxU32, PxU32 > NbNewTouches; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbLostTouches, PxSimulationStatistics, PxU32, PxU32 > NbLostTouches; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbPartitions, PxSimulationStatistics, PxU32, PxU32 > NbPartitions; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemParticles, PxSimulationStatistics, PxU64, PxU64 > GpuMemParticles; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemSoftBodies, PxSimulationStatistics, PxU64, PxU64 > GpuMemSoftBodies; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemFEMCloths, PxSimulationStatistics, PxU64, PxU64 > GpuMemFEMCloths; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemHairSystems, PxSimulationStatistics, PxU64, PxU64 > GpuMemHairSystems; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemHeap, PxSimulationStatistics, PxU64, PxU64 > GpuMemHeap; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemHeapBroadPhase, PxSimulationStatistics, PxU64, PxU64 > GpuMemHeapBroadPhase; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemHeapNarrowPhase, PxSimulationStatistics, PxU64, PxU64 > GpuMemHeapNarrowPhase; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemHeapSolver, PxSimulationStatistics, PxU64, PxU64 > GpuMemHeapSolver; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemHeapArticulation, PxSimulationStatistics, PxU64, PxU64 > GpuMemHeapArticulation; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemHeapSimulation, PxSimulationStatistics, PxU64, PxU64 > GpuMemHeapSimulation; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemHeapSimulationArticulation, PxSimulationStatistics, PxU64, PxU64 > GpuMemHeapSimulationArticulation; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemHeapSimulationParticles, PxSimulationStatistics, PxU64, PxU64 > GpuMemHeapSimulationParticles; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemHeapSimulationSoftBody, PxSimulationStatistics, PxU64, PxU64 > GpuMemHeapSimulationSoftBody; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemHeapSimulationFEMCloth, PxSimulationStatistics, PxU64, PxU64 > GpuMemHeapSimulationFEMCloth; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemHeapSimulationHairSystem, PxSimulationStatistics, PxU64, PxU64 > GpuMemHeapSimulationHairSystem; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemHeapParticles, PxSimulationStatistics, PxU64, PxU64 > GpuMemHeapParticles; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemHeapSoftBodies, PxSimulationStatistics, PxU64, PxU64 > GpuMemHeapSoftBodies; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemHeapFEMCloths, PxSimulationStatistics, PxU64, PxU64 > GpuMemHeapFEMCloths; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemHeapHairSystems, PxSimulationStatistics, PxU64, PxU64 > GpuMemHeapHairSystems; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_GpuMemHeapOther, PxSimulationStatistics, PxU64, PxU64 > GpuMemHeapOther; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbBroadPhaseAdds, PxSimulationStatistics, PxU32, PxU32 > NbBroadPhaseAdds; PxPropertyInfo<PX_PROPERTY_INFO_NAME::PxSimulationStatistics_NbBroadPhaseRemoves, PxSimulationStatistics, PxU32, PxU32 > NbBroadPhaseRemoves; NbDiscreteContactPairsProperty NbDiscreteContactPairs; NbModifiedContactPairsProperty NbModifiedContactPairs; NbCCDPairsProperty NbCCDPairs; NbTriggerPairsProperty NbTriggerPairs; NbShapesProperty NbShapes; PX_PHYSX_CORE_API PxSimulationStatisticsGeneratedInfo(); template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator inOperator ) const { return inOperator( reinterpret_cast<PxSimulationStatistics*>(NULL) ); } template<typename TOperator> void visitBases( TOperator inOperator ) { PX_UNUSED(inOperator); } template<typename TOperator> PxU32 visitBaseProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); return inStartIndex; } static PxU32 instancePropertyCount() { return 47; } static PxU32 totalPropertyCount() { return instancePropertyCount(); } template<typename TOperator> PxU32 visitInstanceProperties( TOperator inOperator, PxU32 inStartIndex = 0 ) const { PX_UNUSED(inOperator); PX_UNUSED(inStartIndex); inOperator( NbActiveConstraints, inStartIndex + 0 );; inOperator( NbActiveDynamicBodies, inStartIndex + 1 );; inOperator( NbActiveKinematicBodies, inStartIndex + 2 );; inOperator( NbStaticBodies, inStartIndex + 3 );; inOperator( NbDynamicBodies, inStartIndex + 4 );; inOperator( NbKinematicBodies, inStartIndex + 5 );; inOperator( NbAggregates, inStartIndex + 6 );; inOperator( NbArticulations, inStartIndex + 7 );; inOperator( NbAxisSolverConstraints, inStartIndex + 8 );; inOperator( CompressedContactSize, inStartIndex + 9 );; inOperator( RequiredContactConstraintMemory, inStartIndex + 10 );; inOperator( PeakConstraintMemory, inStartIndex + 11 );; inOperator( NbDiscreteContactPairsTotal, inStartIndex + 12 );; inOperator( NbDiscreteContactPairsWithCacheHits, inStartIndex + 13 );; inOperator( NbDiscreteContactPairsWithContacts, inStartIndex + 14 );; inOperator( NbNewPairs, inStartIndex + 15 );; inOperator( NbLostPairs, inStartIndex + 16 );; inOperator( NbNewTouches, inStartIndex + 17 );; inOperator( NbLostTouches, inStartIndex + 18 );; inOperator( NbPartitions, inStartIndex + 19 );; inOperator( GpuMemParticles, inStartIndex + 20 );; inOperator( GpuMemSoftBodies, inStartIndex + 21 );; inOperator( GpuMemFEMCloths, inStartIndex + 22 );; inOperator( GpuMemHairSystems, inStartIndex + 23 );; inOperator( GpuMemHeap, inStartIndex + 24 );; inOperator( GpuMemHeapBroadPhase, inStartIndex + 25 );; inOperator( GpuMemHeapNarrowPhase, inStartIndex + 26 );; inOperator( GpuMemHeapSolver, inStartIndex + 27 );; inOperator( GpuMemHeapArticulation, inStartIndex + 28 );; inOperator( GpuMemHeapSimulation, inStartIndex + 29 );; inOperator( GpuMemHeapSimulationArticulation, inStartIndex + 30 );; inOperator( GpuMemHeapSimulationParticles, inStartIndex + 31 );; inOperator( GpuMemHeapSimulationSoftBody, inStartIndex + 32 );; inOperator( GpuMemHeapSimulationFEMCloth, inStartIndex + 33 );; inOperator( GpuMemHeapSimulationHairSystem, inStartIndex + 34 );; inOperator( GpuMemHeapParticles, inStartIndex + 35 );; inOperator( GpuMemHeapSoftBodies, inStartIndex + 36 );; inOperator( GpuMemHeapFEMCloths, inStartIndex + 37 );; inOperator( GpuMemHeapHairSystems, inStartIndex + 38 );; inOperator( GpuMemHeapOther, inStartIndex + 39 );; inOperator( NbBroadPhaseAdds, inStartIndex + 40 );; inOperator( NbBroadPhaseRemoves, inStartIndex + 41 );; inOperator( NbDiscreteContactPairs, inStartIndex + 42 );; inOperator( NbModifiedContactPairs, inStartIndex + 43 );; inOperator( NbCCDPairs, inStartIndex + 44 );; inOperator( NbTriggerPairs, inStartIndex + 45 );; inOperator( NbShapes, inStartIndex + 46 );; return 47 + inStartIndex; } }; template<> struct PxClassInfoTraits<PxSimulationStatistics> { PxSimulationStatisticsGeneratedInfo Info; const PxSimulationStatisticsGeneratedInfo* getInfo() { return &Info; } }; #undef THERE_IS_NO_INCLUDE_GUARD_HERE_FOR_A_REASON #undef PX_PROPERTY_INFO_NAME
213,625
C
53.902596
218
0.791092
NVIDIA-Omniverse/PhysX/physx/source/physxmetadata/core/include/RepXMetaDataPropertyVisitor.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_REPX_META_DATA_PROPERTY_VISITOR_H #define PX_REPX_META_DATA_PROPERTY_VISITOR_H #include "PvdMetaDataPropertyVisitor.h" namespace physx { template<PxU32 TKey, typename TObjectType,typename TSetPropType, typename TPropertyType> struct PxRepXPropertyAccessor : public Vd::ValueStructOffsetRecord { typedef PxPropertyInfo<TKey,TObjectType,TSetPropType,TPropertyType> TPropertyInfoType; typedef TPropertyType prop_type; const TPropertyInfoType mProperty; PxRepXPropertyAccessor( const TPropertyInfoType& inProp ) : mProperty( inProp ) { } prop_type get( const TObjectType* inObj ) const { return mProperty.get( inObj ); } void set( TObjectType* inObj, prop_type val ) const { return mProperty.set( inObj, val ); } private: PxRepXPropertyAccessor& operator=(const PxRepXPropertyAccessor&); }; template<typename TSetPropType, typename TPropertyType> struct PxRepXPropertyAccessor<PxPropertyInfoName::PxRigidDynamic_WakeCounter, PxRigidDynamic, TSetPropType, TPropertyType> : public Vd::ValueStructOffsetRecord { typedef PxPropertyInfo<PxPropertyInfoName::PxRigidDynamic_WakeCounter,PxRigidDynamic,TSetPropType,TPropertyType> TPropertyInfoType; typedef TPropertyType prop_type; const TPropertyInfoType mProperty; PxRepXPropertyAccessor( const TPropertyInfoType& inProp ) : mProperty( inProp ) { } prop_type get( const PxRigidDynamic* inObj ) const { return mProperty.get( inObj ); } void set( PxRigidDynamic* inObj, prop_type val ) const { PX_UNUSED(val); PxRigidBodyFlags flags = inObj->getRigidBodyFlags(); if( !(flags & PxRigidBodyFlag::eKINEMATIC) ) return mProperty.set( inObj, val ); } private: PxRepXPropertyAccessor& operator=(const PxRepXPropertyAccessor&); }; typedef PxReadOnlyPropertyInfo<PxPropertyInfoName::PxArticulationLink_InboundJoint, PxArticulationLink, PxArticulationJointReducedCoordinate *> TIncomingJointPropType; //RepX cares about fewer property types than PVD does, //but I want to reuse the accessor architecture as it //greatly simplifies clients dealing with complex datatypes template<typename TOperatorType> struct RepXPropertyFilter { RepXPropertyFilter<TOperatorType> &operator=(const RepXPropertyFilter<TOperatorType> &); Vd::PvdPropertyFilter<TOperatorType> mFilter; RepXPropertyFilter( TOperatorType op ) : mFilter( op ) {} RepXPropertyFilter( const RepXPropertyFilter<TOperatorType>& other ) : mFilter( other.mFilter ) {} template<PxU32 TKey, typename TObjType, typename TPropertyType> void operator()( const PxReadOnlyPropertyInfo<TKey,TObjType,TPropertyType>&, PxU32 ) {} //repx ignores read only and write only properties template<PxU32 TKey, typename TObjType, typename TPropertyType> void operator()( const PxWriteOnlyPropertyInfo<TKey,TObjType,TPropertyType>&, PxU32 ) {} template<PxU32 TKey, typename TObjType, typename TCollectionType> void operator()( const PxReadOnlyCollectionPropertyInfo<TKey, TObjType, TCollectionType>&, PxU32 ) {} template<PxU32 TKey, typename TObjType, typename TCollectionType, typename TFilterType> void operator()( const PxReadOnlyFilteredCollectionPropertyInfo<TKey, TObjType, TCollectionType, TFilterType >&, PxU32 ) {} //forward these properties verbatim. template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropertyType> void operator()( const PxIndexedPropertyInfo<TKey, TObjType, TIndexType, TPropertyType >& inProp, PxU32 idx ) { mFilter( inProp, idx ); } template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropertyType> void operator()( const PxFixedSizeLookupTablePropertyInfo<TKey, TObjType, TIndexType,TPropertyType >& inProp, PxU32 idx ) { mFilter( inProp, idx ); } template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropertyType> void operator()( const PxExtendedIndexedPropertyInfo<TKey, TObjType, TIndexType, TPropertyType >& inProp, PxU32 idx) { mFilter( inProp, idx); } template<PxU32 TKey, typename TObjType, typename TIndexType, typename TIndex2Type, typename TPropertyType> void operator()( const PxDualIndexedPropertyInfo<TKey, TObjType, TIndexType, TIndex2Type, TPropertyType >& inProp, PxU32 idx ) { mFilter( inProp, idx ); } template<PxU32 TKey, typename TObjType, typename TIndexType, typename TIndex2Type, typename TPropertyType> void operator()( const PxExtendedDualIndexedPropertyInfo<TKey, TObjType, TIndexType, TIndex2Type, TPropertyType >& inProp, PxU32 idx ) { mFilter( inProp, idx ); } template<PxU32 TKey, typename TObjType, typename TPropertyType> void operator()( const PxRangePropertyInfo<TKey, TObjType, TPropertyType>& inProp, PxU32 idx ) { mFilter( inProp, idx ); } template<PxU32 TKey, typename TObjType, typename TPropertyType> void operator()( const PxBufferCollectionPropertyInfo<TKey, TObjType, TPropertyType>& inProp, PxU32 count ) { mFilter( inProp, count ); } template<PxU32 TKey, typename TObjType, typename TSetPropType, typename TPropertyType> void operator()( const PxPropertyInfo<TKey,TObjType,TSetPropType,TPropertyType>& prop, PxU32 ) { PxRepXPropertyAccessor< TKey, TObjType, TSetPropType, TPropertyType > theAccessor( prop ); mFilter.mOperator.pushName( prop.mName ); mFilter.template handleAccessor<TKey>( theAccessor ); mFilter.mOperator.popName(); } void operator()(const PxRigidActorGlobalPosePropertyInfo& inProp, PxU32) { mFilter.mOperator.pushName(inProp.mName); mFilter.mOperator.handleRigidActorGlobalPose(inProp); mFilter.mOperator.popName(); } void operator()( const PxRigidActorShapeCollection& inProp, PxU32 ) { mFilter.mOperator.pushName( "Shapes" ); mFilter.mOperator.handleShapes( inProp ); mFilter.mOperator.popName(); } void operator()( const PxArticulationLinkCollectionProp& inProp, PxU32 ) { mFilter.mOperator.pushName( "Links" ); mFilter.mOperator.handleArticulationLinks( inProp ); mFilter.mOperator.popName(); } void operator()( const PxShapeMaterialsProperty& inProp, PxU32 ) { mFilter.mOperator.pushName( "Materials" ); mFilter.mOperator.handleShapeMaterials( inProp ); mFilter.mOperator.popName(); } void operator()( const TIncomingJointPropType& inProp, PxU32 ) { mFilter.mOperator.handleIncomingJoint( inProp ); } void operator()( const PxShapeGeomProperty& inProp, PxU32 ) { mFilter.mOperator.handleGeomProperty( inProp ); } #define DEFINE_REPX_PROPERTY_NOP(datatype) \ template<PxU32 TKey, typename TObjType, typename TSetPropType> \ void operator()( const PxPropertyInfo<TKey,TObjType,TSetPropType,datatype>&, PxU32 ){} DEFINE_REPX_PROPERTY_NOP( const void* ) DEFINE_REPX_PROPERTY_NOP( void* ) DEFINE_REPX_PROPERTY_NOP( PxSimulationFilterCallback * ) DEFINE_REPX_PROPERTY_NOP( physx::PxTaskManager * ) DEFINE_REPX_PROPERTY_NOP( PxSimulationFilterShader * ) DEFINE_REPX_PROPERTY_NOP( PxSimulationFilterShader) DEFINE_REPX_PROPERTY_NOP( PxContactModifyCallback * ) DEFINE_REPX_PROPERTY_NOP( PxCCDContactModifyCallback * ) DEFINE_REPX_PROPERTY_NOP( PxSimulationEventCallback * ) DEFINE_REPX_PROPERTY_NOP( physx::PxCudaContextManager* ) DEFINE_REPX_PROPERTY_NOP( physx::PxCpuDispatcher * ) DEFINE_REPX_PROPERTY_NOP( PxRigidActor ) DEFINE_REPX_PROPERTY_NOP( const PxRigidActor ) DEFINE_REPX_PROPERTY_NOP( PxRigidActor& ) DEFINE_REPX_PROPERTY_NOP( const PxRigidActor& ) DEFINE_REPX_PROPERTY_NOP( PxScene* ) DEFINE_REPX_PROPERTY_NOP( PxAggregate * ) DEFINE_REPX_PROPERTY_NOP( PxArticulationReducedCoordinate& ) DEFINE_REPX_PROPERTY_NOP( const PxArticulationLink * ) DEFINE_REPX_PROPERTY_NOP( const PxRigidDynamic * ) DEFINE_REPX_PROPERTY_NOP( const PxRigidStatic * ) DEFINE_REPX_PROPERTY_NOP( PxStridedData ) //These are handled in a custom fasion. }; } #endif
9,616
C
42.713636
168
0.761543
NVIDIA-Omniverse/PhysX/physx/source/physxmetadata/core/include/PxMetaDataObjects.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_METADATAOBJECTS_H #define PX_METADATAOBJECTS_H #include "foundation/PxMemory.h" #include "foundation/PxPhysicsVersion.h" // include the base headers instead of the PxPhysicsAPI.h //Geometry Library #include "geometry/PxBoxGeometry.h" #include "geometry/PxCapsuleGeometry.h" #include "geometry/PxConvexMesh.h" #include "geometry/PxConvexMeshGeometry.h" #include "geometry/PxGeometry.h" #include "geometry/PxGeometryHelpers.h" #include "geometry/PxGeometryQuery.h" #include "geometry/PxHeightField.h" #include "geometry/PxHeightFieldDesc.h" #include "geometry/PxHeightFieldFlag.h" #include "geometry/PxHeightFieldGeometry.h" #include "geometry/PxHeightFieldSample.h" #include "geometry/PxMeshQuery.h" #include "geometry/PxMeshScale.h" #include "geometry/PxPlaneGeometry.h" #include "geometry/PxSimpleTriangleMesh.h" #include "geometry/PxSphereGeometry.h" #include "geometry/PxTriangle.h" #include "geometry/PxTriangleMesh.h" #include "geometry/PxTriangleMeshGeometry.h" #include "geometry/PxTetrahedron.h" #include "geometry/PxTetrahedronMesh.h" #include "geometry/PxTetrahedronMeshGeometry.h" // PhysX Core SDK #include "PxActor.h" #include "PxAggregate.h" #include "PxArticulationReducedCoordinate.h" #include "PxArticulationJointReducedCoordinate.h" #include "PxArticulationLink.h" #include "PxClient.h" #include "PxConstraint.h" #include "PxConstraintDesc.h" #include "PxContact.h" #include "PxContactModifyCallback.h" #include "PxDeletionListener.h" #include "PxFiltering.h" #include "PxForceMode.h" #include "PxLockedData.h" #include "PxMaterial.h" #include "PxFEMSoftBodyMaterial.h" #include "PxFEMClothMaterial.h" #include "PxPBDMaterial.h" #include "PxFLIPMaterial.h" #include "PxMPMMaterial.h" #include "PxPhysics.h" #include "PxPhysXConfig.h" #include "PxQueryFiltering.h" #include "PxQueryReport.h" #include "PxRigidActor.h" #include "PxRigidBody.h" #include "PxRigidDynamic.h" #include "PxRigidStatic.h" #include "PxScene.h" #include "PxSceneDesc.h" #include "PxSceneLock.h" #include "PxShape.h" #include "PxSimulationEventCallback.h" #include "PxSimulationStatistics.h" #include "PxVisualizationParameter.h" #include "PxPruningStructure.h" #if PX_LINUX && PX_CLANG #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wreserved-identifier" #endif /** \addtogroup physics @{ */ namespace physx { class PxArticulationLink; class PxArticulationJointReducedCoordinate; struct PxPropertyInfoName { enum Enum { Unnamed = 0, #include "PxAutoGeneratedMetaDataObjectNames.h" LastPxPropertyInfoName }; }; struct PxU32ToName { const char* mName; PxU32 mValue; }; struct PxPropertyInfoBase { const char* mName; PxU32 mKey; PxPropertyInfoBase( const char* n, PxU32 inKey ) : mName( n ) , mKey( inKey ) { } }; template<PxU32 TKey> struct PxPropertyInfoParameterizedBase : public PxPropertyInfoBase { PxPropertyInfoParameterizedBase( const char* inName ) : PxPropertyInfoBase( inName, TKey ) {} }; template<PxU32 TKey, typename TObjType, typename TPropertyType> struct PxReadOnlyPropertyInfo : public PxPropertyInfoParameterizedBase<TKey> { typedef TPropertyType (*TGetterType)( const TObjType* ); TGetterType mGetter; PxReadOnlyPropertyInfo( const char* inName, TGetterType inGetter ) : PxPropertyInfoParameterizedBase<TKey>( inName ) , mGetter( inGetter ) {} TPropertyType get( const TObjType* inObj ) const { return mGetter( inObj ); } }; template<PxU32 TKey, typename TObjType, typename TPropertyType> struct PxWriteOnlyPropertyInfo : public PxPropertyInfoParameterizedBase<TKey> { typedef void(*TSetterType)( TObjType*, TPropertyType inArg ); TSetterType mSetter; PxWriteOnlyPropertyInfo( const char* inName, TSetterType inSetter ) : PxPropertyInfoParameterizedBase<TKey>( inName ) , mSetter( inSetter ) {} void set( TObjType* inObj, TPropertyType inArg ) const { mSetter( inObj, inArg ); } }; //Define the property types on the auto-generated objects. template<PxU32 TKey, typename TObjType, typename TSetPropType, typename TGetPropType> struct PxPropertyInfo : public PxReadOnlyPropertyInfo<TKey, TObjType, TGetPropType> { typedef typename PxReadOnlyPropertyInfo<TKey, TObjType, TGetPropType>::TGetterType TGetterType; typedef void(*TSetterType)( TObjType*, TSetPropType inArg ); TSetterType mSetter; PxPropertyInfo( const char* inName, TSetterType inSetter, TGetterType inGetter ) : PxReadOnlyPropertyInfo<TKey, TObjType, TGetPropType>( inName, inGetter ) , mSetter( inSetter ) {} void set( TObjType* inObj, TSetPropType inArg ) const { mSetter( inObj, inArg ); } }; template<PxU32 TKey, typename TObjType, typename TPropertyType> struct PxRangePropertyInfo : public PxPropertyInfoParameterizedBase<TKey> { typedef void (*TSetterType)( TObjType*,TPropertyType,TPropertyType); typedef void (*TGetterType)( const TObjType*,TPropertyType&,TPropertyType&); const char* mArg0Name; const char* mArg1Name; TSetterType mSetter; TGetterType mGetter; PxRangePropertyInfo( const char* name, const char* arg0Name, const char* arg1Name , TSetterType setter, TGetterType getter ) : PxPropertyInfoParameterizedBase<TKey>( name ) , mArg0Name( arg0Name ) , mArg1Name( arg1Name ) , mSetter( setter ) , mGetter( getter ) { } void set( TObjType* inObj, TPropertyType arg0, TPropertyType arg1 ) const { mSetter( inObj, arg0, arg1 ); } void get( const TObjType* inObj, TPropertyType& arg0, TPropertyType& arg1 ) const { mGetter( inObj, arg0, arg1 ); } }; template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropertyType> struct PxIndexedPropertyInfo : public PxPropertyInfoParameterizedBase<TKey> { typedef void (*TSetterType)( TObjType*, TIndexType, TPropertyType ); typedef TPropertyType (*TGetterType)( const TObjType* inObj, TIndexType ); TSetterType mSetter; TGetterType mGetter; PxIndexedPropertyInfo( const char* name, TSetterType setter, TGetterType getter ) : PxPropertyInfoParameterizedBase<TKey>( name ) , mSetter( setter ) , mGetter( getter ) { } void set( TObjType* inObj, TIndexType inIndex, TPropertyType arg ) const { mSetter( inObj, inIndex, arg ); } TPropertyType get( const TObjType* inObj, TIndexType inIndex ) const { return mGetter( inObj, inIndex ); } }; template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropertyType> struct PxExtendedIndexedPropertyInfo : public PxPropertyInfoParameterizedBase<TKey> { typedef PxU32 (*TNbObjectsMember)( const TObjType* ); typedef void (*TSetterType)( TObjType*, TIndexType, TPropertyType ); typedef TPropertyType (*TGetterType)( const TObjType* inObj, TIndexType ); TSetterType mSetter; TGetterType mGetter; PxU32 mCount; TNbObjectsMember mNbObjectsMember; PxExtendedIndexedPropertyInfo( const char* name, TGetterType getter, TNbObjectsMember inNb, TSetterType setter) : PxPropertyInfoParameterizedBase<TKey>( name ) , mSetter( setter ) , mGetter( getter ) , mNbObjectsMember( inNb ) { } PxU32 size( const TObjType* inObj ) const { return mNbObjectsMember( inObj ); } void set( TObjType* inObj, TIndexType inIndex, TPropertyType arg ) const { mSetter( inObj, inIndex, arg ); } TPropertyType get( const TObjType* inObj, TIndexType inIndex ) const { return mGetter( inObj, inIndex ); } }; template<PxU32 TKey, typename TObjType, typename TIndex1Type, typename TIndex2Type, typename TPropertyType> struct PxDualIndexedPropertyInfo : public PxPropertyInfoParameterizedBase<TKey> { typedef void (*TSetterType)( TObjType*, TIndex1Type, TIndex2Type, TPropertyType ); typedef TPropertyType (*TGetterType)( const TObjType* inObj, TIndex1Type, TIndex2Type ); TSetterType mSetter; TGetterType mGetter; PxDualIndexedPropertyInfo( const char* name, TSetterType setter, TGetterType getter ) : PxPropertyInfoParameterizedBase<TKey>( name ) , mSetter( setter ) , mGetter( getter ) { } void set( TObjType* inObj, TIndex1Type inIdx1, TIndex2Type inIdx2, TPropertyType arg ) const { mSetter( inObj, inIdx1, inIdx2, arg ); } TPropertyType get( const TObjType* inObj, TIndex1Type inIdx1, TIndex2Type inIdx2 ) const { return mGetter( inObj, inIdx1, inIdx2 ); } }; template<PxU32 TKey, typename TObjType, typename TIndex1Type, typename TIndex2Type, typename TPropertyType> struct PxExtendedDualIndexedPropertyInfo : public PxPropertyInfoParameterizedBase<TKey> { typedef void (*TSetterType)( TObjType*, TIndex1Type, TIndex2Type, TPropertyType ); typedef TPropertyType (*TGetterType)( const TObjType* inObj, TIndex1Type, TIndex2Type ); TSetterType mSetter; TGetterType mGetter; PxU32 mId0Count; PxU32 mId1Count; PxExtendedDualIndexedPropertyInfo( const char* name, TSetterType setter, TGetterType getter, PxU32 id0Count, PxU32 id1Count ) : PxPropertyInfoParameterizedBase<TKey>( name ) , mSetter( setter ) , mGetter( getter ) , mId0Count( id0Count ) , mId1Count( id1Count ) { } void set( TObjType* inObj, TIndex1Type inIdx1, TIndex2Type inIdx2, TPropertyType arg ) const { mSetter( inObj, inIdx1, inIdx2, arg ); } TPropertyType get( const TObjType* inObj, TIndex1Type inIdx1, TIndex2Type inIdx2 ) const { return mGetter( inObj, inIdx1, inIdx2 ); } }; template<PxU32 TKey, typename TObjType, typename TCollectionType> struct PxBufferCollectionPropertyInfo : public PxPropertyInfoParameterizedBase<TKey> { typedef PxU32 (*TNbObjectsMember)( const TObjType* ); typedef PxU32 (*TGetObjectsMember)( const TObjType*, TCollectionType*, PxU32 ); typedef void (*TSetObjectsMember)( TObjType*, TCollectionType*, PxU32 ); TGetObjectsMember mGetObjectsMember; TNbObjectsMember mNbObjectsMember; TSetObjectsMember mSetObjectsMember; PxBufferCollectionPropertyInfo( const char* inName, TGetObjectsMember inGetter, TNbObjectsMember inNb, TSetObjectsMember inSet ) : PxPropertyInfoParameterizedBase<TKey>( inName ) , mGetObjectsMember( inGetter ) , mNbObjectsMember( inNb ) , mSetObjectsMember( inSet ) { } PxU32 size( const TObjType* inObj ) const { return mNbObjectsMember( inObj ); } PxU32 get( const TObjType* inObj, TCollectionType* inBuffer, PxU32 inNumItems ) const { return mGetObjectsMember( inObj, inBuffer, inNumItems ); } void set( TObjType* inObj, TCollectionType* inBuffer, PxU32 inNumItems ) const { mSetObjectsMember( inObj, inBuffer, inNumItems); } }; template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropertyType> struct PxFixedSizeLookupTablePropertyInfo : public PxPropertyInfoParameterizedBase<TKey> { typedef PxU32 (*TNbObjectsMember)( const TObjType* ); typedef PxReal (*TGetXMember)( const TObjType*, PxU32 ); typedef PxReal (*TGetYMember)( const TObjType*, PxU32 ); typedef void (*TAddPairMember)( TObjType*, PxReal, PxReal ); typedef void (*TClearMember)( TObjType* ); TGetXMember mGetXMember; TGetYMember mGetYMember; TNbObjectsMember mNbObjectsMember; TAddPairMember mAddPairMember; TClearMember mClearMember; PxFixedSizeLookupTablePropertyInfo( const char* inName, TGetXMember inGetterX, TGetYMember inGetterY, TNbObjectsMember inNb, TAddPairMember inAddPair, TClearMember inClear ) : PxPropertyInfoParameterizedBase<TKey>( inName ) , mGetXMember( inGetterX ) , mGetYMember( inGetterY ) , mNbObjectsMember( inNb ) , mAddPairMember( inAddPair ) , mClearMember( inClear ) { } PxU32 size( const TObjType* inObj ) const { return mNbObjectsMember( inObj ); } PxReal getX( const TObjType* inObj, const PxU32 index ) const { return mGetXMember( inObj, index ); } PxReal getY( const TObjType* inObj, const PxU32 index ) const { return mGetYMember( inObj, index ); } void addPair( TObjType* inObj, const PxReal x, const PxReal y ) { mAddPairMember( inObj, x, y ); } void clear( TObjType* inObj ) { mClearMember( inObj ); } }; template<PxU32 TKey, typename TObjType, typename TCollectionType> struct PxReadOnlyCollectionPropertyInfo : public PxPropertyInfoParameterizedBase<TKey> { typedef PxU32 (*TNbObjectsMember)( const TObjType* ); typedef PxU32 (*TGetObjectsMember)( const TObjType*, TCollectionType*, PxU32 ); TGetObjectsMember mGetObjectsMember; TNbObjectsMember mNbObjectsMember; PxReadOnlyCollectionPropertyInfo( const char* inName, TGetObjectsMember inGetter, TNbObjectsMember inNb ) : PxPropertyInfoParameterizedBase<TKey>( inName ) , mGetObjectsMember( inGetter ) , mNbObjectsMember( inNb ) { } PxU32 size( const TObjType* inObj ) const { return mNbObjectsMember( inObj ); } PxU32 get( const TObjType* inObj, TCollectionType* inBuffer, PxU32 inBufSize ) const { return mGetObjectsMember( inObj, inBuffer, inBufSize); } }; template<PxU32 TKey, typename TObjType, typename TCollectionType, typename TFilterType> struct PxReadOnlyFilteredCollectionPropertyInfo : public PxPropertyInfoParameterizedBase<TKey> { typedef PxU32 (*TNbObjectsMember)( const TObjType*, TFilterType ); typedef PxU32 (*TGetObjectsMember)( const TObjType*, TFilterType, TCollectionType*, PxU32 ); TGetObjectsMember mGetObjectsMember; TNbObjectsMember mNbObjectsMember; PxReadOnlyFilteredCollectionPropertyInfo( const char* inName, TGetObjectsMember inGetter, TNbObjectsMember inNb ) : PxPropertyInfoParameterizedBase<TKey>( inName ) , mGetObjectsMember( inGetter ) , mNbObjectsMember( inNb ) { } PxU32 size( const TObjType* inObj, TFilterType inFilter ) const { return mNbObjectsMember( inObj, inFilter ); } PxU32 get( const TObjType* inObj, TFilterType inFilter, TCollectionType* inBuffer, PxU32 inBufSize ) const { return mGetObjectsMember( inObj, inFilter, inBuffer, inBufSize); } }; template<PxU32 TKey, typename TObjType, typename TCollectionType, typename TCreateArg> struct PxFactoryCollectionPropertyInfo : public PxReadOnlyCollectionPropertyInfo< TKey, TObjType, TCollectionType > { typedef typename PxReadOnlyCollectionPropertyInfo< TKey, TObjType, TCollectionType >::TGetObjectsMember TGetObjectsMember; typedef typename PxReadOnlyCollectionPropertyInfo< TKey, TObjType, TCollectionType >::TNbObjectsMember TNbObjectsMember; typedef TCollectionType (*TCreateMember)( TObjType*, TCreateArg ); TCreateMember mCreateMember; PxFactoryCollectionPropertyInfo( const char* inName, TGetObjectsMember inGetter, TNbObjectsMember inNb, TCreateMember inMember ) : PxReadOnlyCollectionPropertyInfo< TKey, TObjType, TCollectionType >( inName, inGetter, inNb ) , mCreateMember( inMember ) { } TCollectionType create( TObjType* inObj, TCreateArg inArg ) const { return mCreateMember( inObj, inArg ); } }; template<PxU32 TKey, typename TObjType, typename TCollectionType> struct PxCollectionPropertyInfo : public PxReadOnlyCollectionPropertyInfo< TKey, TObjType, TCollectionType > { typedef typename PxReadOnlyCollectionPropertyInfo< TKey, TObjType, TCollectionType >::TGetObjectsMember TGetObjectsMember; typedef typename PxReadOnlyCollectionPropertyInfo< TKey, TObjType, TCollectionType >::TNbObjectsMember TNbObjectsMember; typedef void (*TAddMember)(TObjType*, TCollectionType&); typedef void (*TRemoveMember)(TObjType*, TCollectionType&); TAddMember mAddMember; TRemoveMember mRemoveMember; PxCollectionPropertyInfo( const char* inName, TGetObjectsMember inGetter, TNbObjectsMember inNb, TAddMember inMember, TRemoveMember inRemoveMember ) : PxReadOnlyCollectionPropertyInfo< TKey, TObjType, TCollectionType >( inName, inGetter, inNb ) , mAddMember( inMember ) , mRemoveMember( inRemoveMember ) { } void add( TObjType* inObj, TCollectionType& inArg ) const { mAddMember(inObj, inArg ); } void remove( TObjType* inObj, TCollectionType& inArg ) const { mRemoveMember( inObj, inArg ); } }; template<PxU32 TKey, typename TObjType, typename TCollectionType, typename TFilterType> struct PxFilteredCollectionPropertyInfo : public PxReadOnlyFilteredCollectionPropertyInfo<TKey, TObjType, TCollectionType, TFilterType> { typedef typename PxReadOnlyFilteredCollectionPropertyInfo< TKey, TObjType, TCollectionType, TFilterType >::TGetObjectsMember TGetObjectsMember; typedef typename PxReadOnlyFilteredCollectionPropertyInfo< TKey, TObjType, TCollectionType, TFilterType >::TNbObjectsMember TNbObjectsMember; typedef void (*TAddMember)(TObjType*, TCollectionType&); typedef void (*TRemoveMember)(TObjType*, TCollectionType&); TAddMember mAddMember; TRemoveMember mRemoveMember; PxFilteredCollectionPropertyInfo( const char* inName, TGetObjectsMember inGetter, TNbObjectsMember inNb, TAddMember inMember, TRemoveMember inRemoveMember ) : PxReadOnlyFilteredCollectionPropertyInfo<TKey, TObjType, TCollectionType, TFilterType>( inName, inGetter, inNb ) , mAddMember( inMember ) , mRemoveMember( inRemoveMember ) { } void add( TObjType* inObj, TCollectionType& inArg ) const { mAddMember(inObj, inArg ); } void remove( TObjType* inObj, TCollectionType& inArg ) const { mRemoveMember( inObj, inArg ); } }; //create a default info class for when we can't match //the type correctly. struct PxUnknownClassInfo { static const char* getClassName() { return "__unknown_class"; } template<typename TReturnType, typename TOperator> TReturnType visitType( TOperator ) { return TReturnType(); } template<typename TOperator> void visitBases( TOperator ) { } template<typename TOperator> PxU32 visitBaseProperties( TOperator, PxU32 inStartIndex = 0 ) const { return inStartIndex; } template<typename TOperator> PxU32 visitInstanceProperties( TOperator, PxU32 inStartIndex = 0 ) const { return inStartIndex; } }; template<typename TDataType> struct PxClassInfoTraits { PxUnknownClassInfo Info; static bool getInfo() { return false;} }; //move the bool typedef to the global namespace. typedef bool _Bool; template<PxU32 TPropertyName> struct PxPropertyToValueStructMemberMap { bool Offset; }; #define DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP( type, prop, valueStruct ) \ template<> struct PxPropertyToValueStructMemberMap< PxPropertyInfoName::type##_##prop > \ { \ PxU32 Offset; \ PxPropertyToValueStructMemberMap< PxPropertyInfoName::type##_##prop >() : Offset( PX_OFFSET_OF_RT( valueStruct, prop ) ) {} \ template<typename TOperator> void visitProp( TOperator inOperator, valueStruct& inStruct ) { inOperator( inStruct.prop ); } \ }; struct PxShapeGeomPropertyHelper { PX_PHYSX_CORE_API PxGeometryType::Enum getGeometryType(const PxShape* inShape) const; PX_PHYSX_CORE_API bool getGeometry(const PxShape* inShape, PxBoxGeometry& geometry) const; PX_PHYSX_CORE_API bool getGeometry(const PxShape* inShape, PxSphereGeometry& geometry) const; PX_PHYSX_CORE_API bool getGeometry(const PxShape* inShape, PxCapsuleGeometry& geometry) const; PX_PHYSX_CORE_API bool getGeometry(const PxShape* inShape, PxPlaneGeometry& geometry) const; PX_PHYSX_CORE_API bool getGeometry(const PxShape* inShape, PxConvexMeshGeometry& geometry) const; PX_PHYSX_CORE_API bool getGeometry(const PxShape* inShape, PxTetrahedronMeshGeometry& geometry) const; PX_PHYSX_CORE_API bool getGeometry(const PxShape* inShape, PxParticleSystemGeometry& geometry) const; PX_PHYSX_CORE_API bool getGeometry(const PxShape* inShape, PxTriangleMeshGeometry& geometry) const; PX_PHYSX_CORE_API bool getGeometry(const PxShape* inShape, PxHeightFieldGeometry& geometry) const; }; struct PxShapeGeomProperty : public PxWriteOnlyPropertyInfo< PxPropertyInfoName::PxShape_Geom, PxShape, const PxGeometry & > , public PxShapeGeomPropertyHelper { static void setPxShape_Geom( PxShape* inObj, const PxGeometry& inArg){ inObj->setGeometry( inArg ); } static PxGeometryHolder getPxShape_Geom( const PxShape* inObj ) { return PxGeometryHolder(inObj->getGeometry()); } typedef PxWriteOnlyPropertyInfo< PxPropertyInfoName::PxShape_Geom, PxShape, const PxGeometry & >::TSetterType TSetterType; typedef PxGeometryHolder (*TGetterType)( const PxShape* inObj ); PxShapeGeomProperty( const char* inName="Geometry", TSetterType inSetter=setPxShape_Geom, TGetterType=getPxShape_Geom ) : PxWriteOnlyPropertyInfo< PxPropertyInfoName::PxShape_Geom, PxShape, const PxGeometry & >( inName, inSetter ) { } }; struct PxShapeMaterialsPropertyHelper { PX_PHYSX_CORE_API void setMaterials(PxShape* inShape, PxMaterial*const* materials, PxU16 materialCount) const; }; struct PxShapeMaterialsProperty : public PxReadOnlyCollectionPropertyInfo<PxPropertyInfoName::PxShape_Materials, PxShape, PxMaterial*> , public PxShapeMaterialsPropertyHelper { typedef PxReadOnlyCollectionPropertyInfo< PxPropertyInfoName::PxShape_Materials, PxShape, PxMaterial* >::TGetObjectsMember TGetObjectsMember; typedef PxReadOnlyCollectionPropertyInfo< PxPropertyInfoName::PxShape_Materials, PxShape, PxMaterial* >::TNbObjectsMember TNbObjectsMember; PxShapeMaterialsProperty( const char* inName, TGetObjectsMember inGetter, TNbObjectsMember inNb ) : PxReadOnlyCollectionPropertyInfo<PxPropertyInfoName::PxShape_Materials, PxShape, PxMaterial*>( inName, inGetter, inNb ) { } }; typedef PxPropertyInfo<PxPropertyInfoName::PxRigidActor_GlobalPose, PxRigidActor, const PxTransform &, PxTransform > PxRigidActorGlobalPosePropertyInfo; struct PxRigidActorShapeCollectionHelper { PX_PHYSX_CORE_API PxShape* createShape(PxRigidActor* inActor, const PxGeometry& geometry, PxMaterial& material, PxShapeFlags shapeFlags = PxShapeFlag::eVISUALIZATION | PxShapeFlag::eSCENE_QUERY_SHAPE | PxShapeFlag::eSIMULATION_SHAPE) const; PX_PHYSX_CORE_API PxShape* createShape(PxRigidActor* inActor, const PxGeometry& geometry, PxMaterial *const* materials, PxU16 materialCount, PxShapeFlags shapeFlags = PxShapeFlag::eVISUALIZATION | PxShapeFlag::eSCENE_QUERY_SHAPE | PxShapeFlag::eSIMULATION_SHAPE) const; }; struct PxRigidActorShapeCollection : public PxReadOnlyCollectionPropertyInfo<PxPropertyInfoName::PxRigidActor_Shapes, PxRigidActor, PxShape*> , public PxRigidActorShapeCollectionHelper { typedef PxReadOnlyCollectionPropertyInfo< PxPropertyInfoName::PxRigidActor_Shapes, PxRigidActor, PxShape* >::TGetObjectsMember TGetObjectsMember; typedef PxReadOnlyCollectionPropertyInfo< PxPropertyInfoName::PxRigidActor_Shapes, PxRigidActor, PxShape* >::TNbObjectsMember TNbObjectsMember; PxRigidActorShapeCollection( const char* inName, TGetObjectsMember inGetter, TNbObjectsMember inNb ) : PxReadOnlyCollectionPropertyInfo<PxPropertyInfoName::PxRigidActor_Shapes, PxRigidActor, PxShape*>( inName, inGetter, inNb ) { } }; struct PxArticulationReducedCoordinateLinkCollectionPropHelper { PX_PHYSX_CORE_API PxArticulationLink* createLink(PxArticulationReducedCoordinate* inArticulation, PxArticulationLink* parent, const PxTransform& pose) const; }; struct PxArticulationLinkCollectionProp : public PxReadOnlyCollectionPropertyInfo<PxPropertyInfoName::PxArticulationReducedCoordinate_Links, PxArticulationReducedCoordinate, PxArticulationLink*> , public PxArticulationReducedCoordinateLinkCollectionPropHelper { PxArticulationLinkCollectionProp( const char* inName, TGetObjectsMember inGetter, TNbObjectsMember inNb ) : PxReadOnlyCollectionPropertyInfo<PxPropertyInfoName::PxArticulationReducedCoordinate_Links, PxArticulationReducedCoordinate, PxArticulationLink*>( inName, inGetter, inNb ) { } }; template<typename TDataType> struct PxEnumTraits { PxEnumTraits() : NameConversion( false ) {} bool NameConversion; }; struct NbShapesProperty : public PxIndexedPropertyInfo<PxPropertyInfoName::PxSimulationStatistics_NbShapes, PxSimulationStatistics, PxGeometryType::Enum, PxU32> { PX_PHYSX_CORE_API NbShapesProperty(); }; struct NbDiscreteContactPairsProperty : public PxDualIndexedPropertyInfo<PxPropertyInfoName::PxSimulationStatistics_NbDiscreteContactPairs , PxSimulationStatistics , PxGeometryType::Enum , PxGeometryType::Enum , PxU32> { PX_PHYSX_CORE_API NbDiscreteContactPairsProperty(); }; struct NbModifiedContactPairsProperty : public PxDualIndexedPropertyInfo<PxPropertyInfoName::PxSimulationStatistics_NbModifiedContactPairs , PxSimulationStatistics , PxGeometryType::Enum , PxGeometryType::Enum , PxU32> { PX_PHYSX_CORE_API NbModifiedContactPairsProperty(); }; struct NbCCDPairsProperty : public PxDualIndexedPropertyInfo<PxPropertyInfoName::PxSimulationStatistics_NbCCDPairs , PxSimulationStatistics , PxGeometryType::Enum , PxGeometryType::Enum , PxU32> { PX_PHYSX_CORE_API NbCCDPairsProperty(); }; struct NbTriggerPairsProperty : public PxDualIndexedPropertyInfo<PxPropertyInfoName::PxSimulationStatistics_NbTriggerPairs , PxSimulationStatistics , PxGeometryType::Enum , PxGeometryType::Enum , PxU32> { PX_PHYSX_CORE_API NbTriggerPairsProperty(); }; struct SimulationStatisticsProperty : public PxReadOnlyPropertyInfo<PxPropertyInfoName::PxScene_SimulationStatistics, PxScene, PxSimulationStatistics> { PX_PHYSX_CORE_API SimulationStatisticsProperty(); }; struct PxCustomGeometryCustomTypeProperty : public PxReadOnlyPropertyInfo<PxPropertyInfoName::PxCustomGeometry_CustomType, PxCustomGeometry, PxU32> { PX_PHYSX_CORE_API PxCustomGeometryCustomTypeProperty(); }; struct PxMetaDataPlane { PxVec3 normal; PxReal distance; PxMetaDataPlane( PxVec3 n = PxVec3( 0, 0, 0 ), PxReal d = 0 ) : normal( n ) , distance( d ) { } }; #include "PxAutoGeneratedMetaDataObjects.h" #undef DEFINE_PROPERTY_TO_VALUE_STRUCT_MAP static PxU32ToName g_physx__PxQueryFlag__EnumConversion[] = { { "eSTATIC", static_cast<PxU32>( PxQueryFlag::eSTATIC ) }, { "eDYNAMIC", static_cast<PxU32>( PxQueryFlag::eDYNAMIC ) }, { "ePREFILTER", static_cast<PxU32>( PxQueryFlag::ePREFILTER ) }, { "ePOSTFILTER", static_cast<PxU32>( PxQueryFlag::ePOSTFILTER ) }, { NULL, 0 } }; template<> struct PxEnumTraits<PxQueryFlag::Enum > { PxEnumTraits() : NameConversion( g_physx__PxQueryFlag__EnumConversion ) {} const PxU32ToName* NameConversion; }; template<typename TObjType, typename TOperator> inline PxU32 visitAllProperties( TOperator inOperator ) { PxU32 thePropCount = PxClassInfoTraits<TObjType>().Info.visitBaseProperties( inOperator ); return PxClassInfoTraits<TObjType>().Info.visitInstanceProperties( inOperator, thePropCount ); } template<typename TObjType, typename TOperator> inline void visitInstanceProperties( TOperator inOperator ) { PxClassInfoTraits<TObjType>().Info.visitInstanceProperties( inOperator, 0 ); } } #if PX_LINUX && PX_CLANG #pragma clang diagnostic pop #endif /** @} */ #endif
28,256
C
40.311403
270
0.778843
NVIDIA-Omniverse/PhysX/physx/source/physxmetadata/core/include/PxMetaDataCompare.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_METADATACOMPARE_H #define PX_METADATACOMPARE_H #include "PxMetaDataObjects.h" #include "foundation/PxInlineArray.h" //Implement a basic equality comparison system based on the meta data system. //if you implement a particular areequal specialized to exactly your type //before including this file it will be called in preference to the completely //generic one shown here. //If you don't care about the failure prop name you are welcome to pass in 'null', template<typename TBaseObjType> bool areEqual( const TBaseObjType& lhs, const TBaseObjType& rhs, const char** outFailurePropName ); //We don't have the ability right now to handle these types. inline bool areEqual( const PxAggregate&, const PxAggregate& ) { return true; } inline bool areEqual( const PxSimulationFilterShader&, const PxSimulationFilterShader& ) { return true; } inline bool areEqual( const PxSimulationFilterCallback&, const PxSimulationFilterCallback& ) { return true; } inline bool areEqual( const PxConvexMesh&, const PxConvexMesh& ) { return true; } inline bool areEqual( const PxTriangleMesh&, const PxTriangleMesh& ) { return true; } inline bool areEqual( const PxTetrahedronMesh&, const PxTetrahedronMesh&) { return true; } inline bool areEqual( const PxParticleSystemGeometry&, const PxParticleSystemGeometry&) { return true; } inline bool areEqual( const PxBVH33TriangleMesh&, const PxBVH33TriangleMesh& ) { return true; } inline bool areEqual( const PxBVH34TriangleMesh&, const PxBVH34TriangleMesh& ) { return true; } inline bool areEqual( const PxHeightField&, const PxHeightField& ) { return true; } inline bool areEqual( const void* inLhs, const void* inRhs ) { return inLhs == inRhs; } inline bool areEqual( void* inLhs, void* inRhs ) { return inLhs == inRhs; } //Operators are copied, so this object needs to point //to the important data rather than reference or own it. template<typename TBaseObjType> struct EqualityOp { bool* mVal; const TBaseObjType* mLhs; const TBaseObjType* mRhs; const char** mFailurePropName; EqualityOp( bool& inVal, const TBaseObjType& inLhs, const TBaseObjType& inRhs, const char*& inFailurePropName ) : mVal( &inVal ) , mLhs( &inLhs ) , mRhs( &inRhs ) , mFailurePropName( &inFailurePropName ) { } bool hasFailed() { return *mVal == false; } //Ensure failure propagates the result a ways. void update( bool inResult, const char* inName ) { *mVal = *mVal && inResult; if ( hasFailed() ) *mFailurePropName = inName; } //ignore any properties pointering back to the scene. template<PxU32 TKey, typename TObjType> void operator()( const PxReadOnlyPropertyInfo<TKey, TObjType, PxScene*> & inProp, PxU32 ) {} template<PxU32 TKey, typename TObjType> void operator()( const PxReadOnlyPropertyInfo<TKey, TObjType, const PxScene*> & inProp, PxU32 ) {} //ignore any properties pointering back to the impl. template<PxU32 TKey, typename TObjType> void operator()(const PxReadOnlyPropertyInfo<TKey, TObjType, void*> & inProp, PxU32) {} template<PxU32 TKey, typename TObjType> void operator()(const PxReadOnlyPropertyInfo<TKey, TObjType, const void*> & inProp, PxU32) {} //ignore all of these properties because they just point back to the 'this' object and cause //a stack overflow. //Children is unnecessary and articulation points back to the source. void operator()( const PxReadOnlyCollectionPropertyInfo<PxPropertyInfoName::PxArticulationLink_Children, PxArticulationLink, PxArticulationLink* >& inProp, PxU32 ) {} void operator()( const PxReadOnlyCollectionPropertyInfo<PxPropertyInfoName::PxRigidActor_Constraints, PxRigidActor, PxConstraint* >& inProp, PxU32 ){} void operator()( const PxReadOnlyCollectionPropertyInfo<PxPropertyInfoName::PxAggregate_Actors, PxAggregate, PxActor* >& inProp, PxU32 ) {} template<PxU32 TKey, typename TObjType, typename TGetPropType> void operator()( const PxBufferCollectionPropertyInfo<TKey, TObjType, TGetPropType> & inProp, PxU32 ) { } template<PxU32 TKey, typename TObjType, typename TGetPropType> void operator()( const PxReadOnlyPropertyInfo<TKey, TObjType, TGetPropType> & inProp, PxU32 ) { if ( hasFailed() ) return; TGetPropType lhs( inProp.get( mLhs ) ); TGetPropType rhs( inProp.get( mRhs ) ); update( areEqual( lhs, rhs, NULL ), inProp.mName ); } template<PxU32 TKey, typename TObjType, typename TPropType> void operator()( const PxRangePropertyInfo<TKey, TObjType, TPropType> & inProp, PxU32 ) { if ( hasFailed() ) return; TPropType lhsl, lhsr, rhsl, rhsr; inProp.get( mLhs, lhsl, lhsr ); inProp.get( mRhs, rhsl, rhsr ); update( areEqual( lhsl, rhsl, NULL ), inProp.mName ); update( areEqual( lhsr, rhsr, NULL ), inProp.mName ); } //Indexed properties where we don't know the range of index types are ignored template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropType> void compareIndex( const PxIndexedPropertyInfo<TKey, TObjType, TIndexType, TPropType> &, bool ) {} template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropType> void compareIndex( const PxIndexedPropertyInfo<TKey, TObjType, TIndexType, TPropType> &inProp, const PxU32ToName* inNames ) { for ( const PxU32ToName* theName = inNames; theName->mName != NULL && !hasFailed(); ++theName ) { TIndexType theIndex( static_cast<TIndexType>( theName->mValue ) ); update( areEqual( inProp.get( mLhs, theIndex ), inProp.get( mRhs, theIndex ), NULL ), inProp.mName ); } } template<PxU32 TKey, typename TObjType, typename TIndexType, typename TPropType> void operator()( const PxIndexedPropertyInfo<TKey, TObjType, TIndexType, TPropType> & inProp, PxU32 ) { if ( hasFailed() ) return; compareIndex( inProp, PxEnumTraits<TIndexType>().NameConversion ); } template<PxU32 TKey, typename TObjType, typename TCollectionType> void operator()( const PxReadOnlyCollectionPropertyInfo<TKey, TObjType, TCollectionType> & inProp, PxU32 ) { if ( hasFailed() ) return; physx::PxInlineArray<TCollectionType, 20> lhsArray; physx::PxInlineArray<TCollectionType, 20> rhsArray; PxU32 size = inProp.size( mLhs ); if ( size != inProp.size( mRhs ) ) update( false, inProp.mName ); else { lhsArray.resize( size ); rhsArray.resize( size ); inProp.get( mLhs, lhsArray.begin(), size ); inProp.get( mRhs, rhsArray.begin(), size ); for ( PxU32 idx =0; idx < size && !hasFailed(); ++idx ) update( areEqual( lhsArray[idx], rhsArray[idx], NULL ), inProp.mName ); } } //Filtered collections where we can't know the range of filter values are ignored. template<PxU32 TKey, typename TObjType, typename TFilterType, typename TCollectionType> void compare( const PxReadOnlyFilteredCollectionPropertyInfo< TKey, TObjType, TFilterType, TCollectionType >&, bool ) {} template<PxU32 TKey, typename TObjType, typename TFilterType, typename TCollectionType> void compare( const PxReadOnlyFilteredCollectionPropertyInfo< TKey, TObjType, TFilterType, TCollectionType >& inProp, const PxU32ToName* inNames ) { //Exaustively compare all items. physx::PxInlineArray<TCollectionType*, 20> lhsArray; physx::PxInlineArray<TCollectionType*, 20> rhsArray; for ( const PxU32ToName* theName = inNames; theName->mName != NULL && !hasFailed(); ++theName ) { TFilterType theFilter( static_cast<TFilterType>( theName->mValue ) ); PxU32 size = inProp.size( mLhs, theFilter ); if ( size != inProp.size( mRhs, theFilter ) ) update( false, inProp.mName ); else { lhsArray.resize( size ); rhsArray.resize( size ); inProp.get( mLhs, theFilter, lhsArray.begin(), size ); inProp.get( mRhs, theFilter, rhsArray.begin(), size ); for ( PxU32 idx =0; idx < size && !hasFailed(); ++idx ) update( areEqual( lhsArray[idx], rhsArray[idx], NULL ), inProp.mName ); } } } template<PxU32 TKey, typename TObjType, typename TFilterType, typename TCollectionType> void operator()( const PxReadOnlyFilteredCollectionPropertyInfo< TKey, TObjType, TFilterType, TCollectionType >& inProp, PxU32 ) { if ( hasFailed() ) return; compare( inProp, PxEnumTraits<TFilterType>().NameConversion ); } template<typename TGeometryType, typename TPropertyType> void compareGeometry( const TPropertyType& inProp ) { TGeometryType lhs; TGeometryType rhs; bool lsuc = inProp.getGeometry( mLhs, lhs ); bool rsuc = inProp.getGeometry( mRhs, rhs ); if ( !( lsuc && rsuc ) ) update( false, inProp.mName ); else update( areEqual( lhs, rhs, NULL ), inProp.mName ); } void operator()( const PxShapeGeomProperty& inProp, PxU32 ) { if ( hasFailed() ) return; PxGeometryType::Enum lhsType( inProp.getGeometryType( mLhs ) ); PxGeometryType::Enum rhsType( inProp.getGeometryType( mRhs ) ); if ( lhsType != rhsType ) update( false, inProp.mName ); else { switch( lhsType ) { case PxGeometryType::eSPHERE: compareGeometry<PxSphereGeometry>(inProp); break; case PxGeometryType::ePLANE: compareGeometry<PxPlaneGeometry>(inProp); break; case PxGeometryType::eCAPSULE: compareGeometry<PxCapsuleGeometry>(inProp); break; case PxGeometryType::eBOX: compareGeometry<PxBoxGeometry>(inProp); break; case PxGeometryType::eCONVEXMESH: compareGeometry<PxConvexMeshGeometry>(inProp); break; case PxGeometryType::eTETRAHEDRONMESH: compareGeometry<PxTetrahedronMeshGeometry>(inProp); break; case PxGeometryType::ePARTICLESYSTEM: compareGeometry<PxParticleSystemGeometry>(inProp); break; case PxGeometryType::eTRIANGLEMESH: compareGeometry<PxTriangleMeshGeometry>(inProp); break; case PxGeometryType::eHEIGHTFIELD: compareGeometry<PxHeightFieldGeometry>(inProp); break; default: PX_ASSERT( false ); break; } } } }; inline bool areEqual( const char* lhs, const char* rhs, const char**, const PxUnknownClassInfo& ) { if ( lhs && rhs ) return Pxstrcmp( lhs, rhs ) == 0; if ( lhs || rhs ) return false; return true; } inline bool areEqual( PxReal inLhs, PxReal inRhs ) { return PxAbs( inLhs - inRhs ) < 1e-5f; } inline bool areEqual( PxVec3& lhs, PxVec3& rhs ) { return areEqual( lhs.x, rhs.x ) && areEqual( lhs.y, rhs.y ) && areEqual( lhs.z, rhs.z ); } inline bool areEqual( const PxVec3& lhs, const PxVec3& rhs ) { return areEqual( lhs.x, rhs.x ) && areEqual( lhs.y, rhs.y ) && areEqual( lhs.z, rhs.z ); } inline bool areEqual( const PxVec4& lhs, const PxVec4& rhs ) { return areEqual( lhs.x, rhs.x ) && areEqual( lhs.y, rhs.y ) && areEqual( lhs.z, rhs.z ) && areEqual( lhs.w, rhs.w ); } inline bool areEqual( const PxQuat& lhs, const PxQuat& rhs ) { return areEqual( lhs.x, rhs.x ) && areEqual( lhs.y, rhs.y ) && areEqual( lhs.z, rhs.z ) && areEqual( lhs.w, rhs.w ); } inline bool areEqual( const PxTransform& lhs, const PxTransform& rhs ) { return areEqual(lhs.p, rhs.p) && areEqual(lhs.q, rhs.q); } inline bool areEqual( const PxBounds3& inLhs, const PxBounds3& inRhs ) { return areEqual(inLhs.minimum,inRhs.minimum) && areEqual(inLhs.maximum,inRhs.maximum); } inline bool areEqual( const PxMetaDataPlane& lhs, const PxMetaDataPlane& rhs ) { return areEqual( lhs.normal.x, rhs.normal.x ) && areEqual( lhs.normal.y, rhs.normal.y ) && areEqual( lhs.normal.z, rhs.normal.z ) && areEqual( lhs.distance, rhs.distance ); } template<typename TBaseObjType> inline bool areEqual( const TBaseObjType& lhs, const TBaseObjType& rhs ) { return lhs == rhs; } //If we don't know the class type, we must result in == operator template<typename TBaseObjType> inline bool areEqual( const TBaseObjType& lhs, const TBaseObjType& rhs, const char**, const PxUnknownClassInfo& ) { return areEqual( lhs, rhs ); } //If we don't know the class type, we must result in == operator template<typename TBaseObjType, typename TTraitsType> inline bool areEqual( const TBaseObjType& lhs, const TBaseObjType& rhs, const char** outFailurePropName, const TTraitsType& ) { const char* theFailureName = NULL; bool result = true; static int i = 0; ++i; visitAllProperties<TBaseObjType>( EqualityOp<TBaseObjType>( result, lhs, rhs, theFailureName ) ); if ( outFailurePropName != NULL && theFailureName ) *outFailurePropName = theFailureName; return result; } template<typename TBaseObjType> inline bool areEqualPointerCheck( const TBaseObjType& lhs, const TBaseObjType& rhs, const char** outFailurePropName, int ) { return areEqual( lhs, rhs, outFailurePropName, PxClassInfoTraits<TBaseObjType>().Info ); } inline bool areEqualPointerCheck( const void* lhs, const void* rhs, const char**, bool ) { return lhs == rhs; } inline bool areEqualPointerCheck( const char* lhs, const char* rhs, const char** outFailurePropName, bool ) { bool bRet = true; if ( lhs && rhs ) bRet = Pxstrcmp( lhs, rhs ) == 0; else if ( lhs || rhs ) bRet = false; return bRet; } inline bool areEqualPointerCheck( void* lhs, void* rhs, const char**, bool ) { return lhs == rhs; } template<typename TBaseObjType> inline bool areEqualPointerCheck( const TBaseObjType& lhs, const TBaseObjType& rhs, const char** outFailurePropName, bool ) { if ( lhs && rhs ) return areEqual( *lhs, *rhs, outFailurePropName ); if ( lhs || rhs ) return false; return true; } template < typename Tp > struct is_pointer { static const int val = 0; }; template < typename Tp > struct is_pointer<Tp*> { static const bool val = true; }; template<typename TBaseObjType> inline bool areEqual( const TBaseObjType& lhs, const TBaseObjType& rhs, const char** outFailurePropName ) { return areEqualPointerCheck( lhs, rhs, outFailurePropName, is_pointer<TBaseObjType>::val ); } #endif
15,297
C
37.631313
167
0.732562
NVIDIA-Omniverse/PhysX/physx/source/physxmetadata/core/include/PvdMetaDataDefineProperties.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PVD_META_DATA_DEFINE_PROPERTIES_H #define PVD_META_DATA_DEFINE_PROPERTIES_H #if PX_SUPPORT_PVD #include "common/PxCoreUtilityTypes.h" #include "PvdMetaDataPropertyVisitor.h" #include "PxPvdDataStreamHelpers.h" #include "PxPvdDataStream.h" namespace physx { namespace Vd { using namespace physx::pvdsdk; template<typename TPropType> struct PropertyDefinitionOp { void defineProperty( PvdPropertyDefinitionHelper& mHelper, NamespacedName mClassKey ) { mHelper.createProperty( mClassKey, "", getPvdNamespacedNameForType<TPropType>(), PropertyType::Scalar ); } }; template<> struct PropertyDefinitionOp<const char*> { void defineProperty( PvdPropertyDefinitionHelper& mHelper, NamespacedName mClassKey ) { mHelper.createProperty( mClassKey, "", getPvdNamespacedNameForType<StringHandle>(), PropertyType::Scalar ); } }; #define DEFINE_PROPERTY_DEFINITION_OP_NOP( type ) \ template<> struct PropertyDefinitionOp<type> { void defineProperty( PvdPropertyDefinitionHelper&, NamespacedName ){} }; //NOP out these two types. DEFINE_PROPERTY_DEFINITION_OP_NOP( PxStridedData ) DEFINE_PROPERTY_DEFINITION_OP_NOP( PxBoundedData ) #define DEFINE_PROPERTY_DEFINITION_OBJECT_REF( type ) \ template<> struct PropertyDefinitionOp<type> { \ void defineProperty( PvdPropertyDefinitionHelper& mHelper, NamespacedName mClassKey) \ { \ mHelper.createProperty( mClassKey, "", getPvdNamespacedNameForType<ObjectRef>(), PropertyType::Scalar ); \ } \ }; DEFINE_PROPERTY_DEFINITION_OBJECT_REF( PxTetrahedronMesh* ) DEFINE_PROPERTY_DEFINITION_OBJECT_REF( PxTriangleMesh* ) DEFINE_PROPERTY_DEFINITION_OBJECT_REF( PxBVH33TriangleMesh* ) DEFINE_PROPERTY_DEFINITION_OBJECT_REF( PxBVH34TriangleMesh* ) DEFINE_PROPERTY_DEFINITION_OBJECT_REF( PxConvexMesh* ) DEFINE_PROPERTY_DEFINITION_OBJECT_REF( PxHeightField* ) struct PvdClassInfoDefine { PvdPropertyDefinitionHelper& mHelper; NamespacedName mClassKey; PvdClassInfoDefine( PvdPropertyDefinitionHelper& info, NamespacedName inClassName ) : mHelper( info ) , mClassKey( inClassName ) { } PvdClassInfoDefine( const PvdClassInfoDefine& other ) : mHelper( other.mHelper ) , mClassKey( other.mClassKey ) { } void defineProperty( NamespacedName inDtype, const char* semantic = "", PropertyType::Enum inPType = PropertyType::Scalar ) { mHelper.createProperty( mClassKey, semantic, inDtype, inPType ); } void pushName( const char* inName ) { mHelper.pushName( inName ); } void pushBracketedName( const char* inName) { mHelper.pushBracketedName( inName ); } void popName() { mHelper.popName(); } inline void defineNameValueDefs( const PxU32ToName* theConversions ) { while( theConversions->mName != NULL ) { mHelper.addNamedValue( theConversions->mName, theConversions->mValue ); ++theConversions; } } template<typename TAccessorType> void simpleProperty( PxU32, TAccessorType& /*inProp */) { typedef typename TAccessorType::prop_type TPropertyType; PropertyDefinitionOp<TPropertyType>().defineProperty( mHelper, mClassKey ); } template<typename TAccessorType, typename TInfoType> void extendedIndexedProperty( PxU32* key, const TAccessorType& inProp, TInfoType& ) { simpleProperty(*key, inProp); } template<typename TDataType> static NamespacedName getNameForEnumType() { size_t s = sizeof( TDataType ); switch(s) { case 1: return getPvdNamespacedNameForType<PxU8>(); case 2: return getPvdNamespacedNameForType<PxU16>(); case 4: return getPvdNamespacedNameForType<PxU32>(); default: return getPvdNamespacedNameForType<PxU64>(); } } template<typename TAccessorType> void enumProperty( PxU32 /*key*/, TAccessorType& /*inProp*/, const PxU32ToName* inConversions ) { typedef typename TAccessorType::prop_type TPropType; defineNameValueDefs( inConversions ); defineProperty( getNameForEnumType<TPropType>(), "Enumeration Value" ); } template<typename TAccessorType> void flagsProperty( PxU32 /*key*/, const TAccessorType& /*inAccessor*/, const PxU32ToName* inConversions ) { typedef typename TAccessorType::prop_type TPropType; defineNameValueDefs( inConversions ); defineProperty( getNameForEnumType<TPropType>(), "Bitflag" ); } template<typename TAccessorType, typename TInfoType> void complexProperty( PxU32* key, const TAccessorType& inAccessor, TInfoType& inInfo ) { PxU32 theOffset = inAccessor.mOffset; inInfo.visitBaseProperties( makePvdPropertyFilter( *this, key, &theOffset ) ); inInfo.visitInstanceProperties( makePvdPropertyFilter( *this, key, &theOffset ) ); } template<typename TAccessorType, typename TInfoType> void bufferCollectionProperty( PxU32* key, const TAccessorType& inAccessor, TInfoType& inInfo ) { complexProperty(key, inAccessor, inInfo); } template<PxU32 TKey, typename TObjectType, typename TPropertyType, PxU32 TEnableFlag> void handleBuffer( const PxBufferPropertyInfo<TKey, TObjectType, const PxArray< TPropertyType >&, TEnableFlag>& inProp ) { mHelper.pushName( inProp.mName ); defineProperty( getPvdNamespacedNameForType<TPropertyType>(), "", PropertyType::Array ); mHelper.popName(); } template<PxU32 TKey, typename TObjectType, typename TCollectionType> void handleCollection( const PxReadOnlyCollectionPropertyInfo<TKey, TObjectType, TCollectionType>& inProp ) { mHelper.pushName( inProp.mName ); defineProperty( getPvdNamespacedNameForType<TCollectionType>(), "", PropertyType::Array ); mHelper.popName(); } template<PxU32 TKey, typename TObjectType, typename TEnumType> void handleCollection( const PxReadOnlyCollectionPropertyInfo<TKey, TObjectType, TEnumType>& inProp, const PxU32ToName* inConversions ) { mHelper.pushName( inProp.mName ); defineNameValueDefs( inConversions ); defineProperty( getNameForEnumType<TEnumType>(), "Enumeration Value", PropertyType::Array ); mHelper.popName(); } private: PvdClassInfoDefine& operator=(const PvdClassInfoDefine&); }; template<typename TPropType> struct SimplePropertyValueStructOp { void addPropertyMessageArg( PvdPropertyDefinitionHelper& mHelper, PxU32 inOffset ) { mHelper.addPropertyMessageArg<TPropType>( inOffset ); } }; #define DEFINE_SIMPLE_PROPERTY_VALUE_STRUCT_OP_NOP( type ) \ template<> struct SimplePropertyValueStructOp<type> { void addPropertyMessageArg( PvdPropertyDefinitionHelper&, PxU32 ){}}; DEFINE_SIMPLE_PROPERTY_VALUE_STRUCT_OP_NOP( PxStridedData ) DEFINE_SIMPLE_PROPERTY_VALUE_STRUCT_OP_NOP( PxBoundedData ) #define DEFINE_SIMPLE_PROPERTY_VALUE_STRUCT_VOIDPTR_OP( type ) \ template<> struct SimplePropertyValueStructOp<type> { \ void addPropertyMessageArg( PvdPropertyDefinitionHelper& mHelper, PxU32 inOffset ) \ { \ mHelper.addPropertyMessageArg<VoidPtr>( inOffset ); \ } \ }; DEFINE_SIMPLE_PROPERTY_VALUE_STRUCT_VOIDPTR_OP( PxTetrahedronMesh* ) DEFINE_SIMPLE_PROPERTY_VALUE_STRUCT_VOIDPTR_OP( PxTriangleMesh* ) DEFINE_SIMPLE_PROPERTY_VALUE_STRUCT_VOIDPTR_OP( PxBVH33TriangleMesh* ) DEFINE_SIMPLE_PROPERTY_VALUE_STRUCT_VOIDPTR_OP( PxBVH34TriangleMesh* ) DEFINE_SIMPLE_PROPERTY_VALUE_STRUCT_VOIDPTR_OP( PxConvexMesh* ) DEFINE_SIMPLE_PROPERTY_VALUE_STRUCT_VOIDPTR_OP( PxHeightField* ) struct PvdClassInfoValueStructDefine { private: PvdClassInfoValueStructDefine& operator=(const PvdClassInfoValueStructDefine&); public: PvdPropertyDefinitionHelper& mHelper; PvdClassInfoValueStructDefine( PvdPropertyDefinitionHelper& info ) : mHelper( info ) { } PvdClassInfoValueStructDefine( const PvdClassInfoValueStructDefine& other ) : mHelper( other.mHelper ) { } void defineValueStructOffset( const ValueStructOffsetRecord& inProp, PxU32 inPropSize ) { if( inProp.mHasValidOffset ) { switch( inPropSize ) { case 8: mHelper.addPropertyMessageArg<PxU64>( inProp.mOffset ); break; case 4: mHelper.addPropertyMessageArg<PxU32>( inProp.mOffset ); break; case 2: mHelper.addPropertyMessageArg<PxU16>( inProp.mOffset ); break; default: PX_ASSERT(1 == inPropSize); mHelper.addPropertyMessageArg<PxU8>( inProp.mOffset ); break; } } } void pushName( const char* inName ) { mHelper.pushName( inName ); } void pushBracketedName( const char* inName) { mHelper.pushBracketedName( inName ); } void popName() { mHelper.popName(); } template<typename TAccessorType, typename TInfoType> void bufferCollectionProperty( PxU32* /*key*/, const TAccessorType& /*inAccessor*/, TInfoType& /*inInfo*/ ) { //complexProperty(key, inAccessor, inInfo); } template<typename TAccessorType> void simpleProperty( PxU32 /*key*/, TAccessorType& inProp ) { typedef typename TAccessorType::prop_type TPropertyType; if ( inProp.mHasValidOffset ) { SimplePropertyValueStructOp<TPropertyType>().addPropertyMessageArg( mHelper, inProp.mOffset ); } } template<typename TAccessorType> void enumProperty( PxU32 /*key*/, TAccessorType& inAccessor, const PxU32ToName* /*inConversions */) { typedef typename TAccessorType::prop_type TPropType; defineValueStructOffset( inAccessor, sizeof( TPropType ) ); } template<typename TAccessorType> void flagsProperty( PxU32 /*key*/, const TAccessorType& inAccessor, const PxU32ToName* /*inConversions */) { typedef typename TAccessorType::prop_type TPropType; defineValueStructOffset( inAccessor, sizeof( TPropType ) ); } template<typename TAccessorType, typename TInfoType> void complexProperty( PxU32* key, const TAccessorType& inAccessor, TInfoType& inInfo ) { PxU32 theOffset = inAccessor.mOffset; inInfo.visitBaseProperties( makePvdPropertyFilter( *this, key, &theOffset ) ); inInfo.visitInstanceProperties( makePvdPropertyFilter( *this, key, &theOffset ) ); } template<PxU32 TKey, typename TObjectType, typename TCollectionType> void handleCollection( const PxReadOnlyCollectionPropertyInfo<TKey, TObjectType, TCollectionType>& /*prop*/ ) { } template<PxU32 TKey, typename TObjectType, typename TEnumType> void handleCollection( const PxReadOnlyCollectionPropertyInfo<TKey, TObjectType, TEnumType>& /*prop*/, const PxU32ToName* /*inConversions */) { } template<PxU32 TKey, typename TObjectType, typename TInfoType> void handleCollection( const PxBufferCollectionPropertyInfo<TKey, TObjectType, TInfoType>& /*prop*/, const TInfoType& /*inInfo */) { } }; } } #endif #endif
12,100
C
33.280453
142
0.759256
NVIDIA-Omniverse/PhysX/physx/source/physxmetadata/core/include/PxMetaDataCppPrefix.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_META_DATA_CPP_PREFIX_H #define PX_META_DATA_CPP_PREFIX_H //Header that is only included by the clang-generated cpp files. //Used to change compilation settings where necessary for only those files. #endif
1,915
C
50.783782
75
0.768146
NVIDIA-Omniverse/PhysX/physx/source/physxmetadata/core/include/PvdMetaDataExtensions.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_META_DATA_EXTENSIONS_H #define PX_META_DATA_EXTENSIONS_H #include "PxMetaDataObjects.h" #if PX_SUPPORT_PVD #include "PxPvdObjectModelBaseTypes.h" namespace physx { namespace pvdsdk { template<> PX_INLINE NamespacedName getPvdNamespacedNameForType<physx::PxMetaDataPlane>() { return getPvdNamespacedNameForType<PxVec4>(); } template<> PX_INLINE NamespacedName getPvdNamespacedNameForType<physx::PxRigidActor*>() { return getPvdNamespacedNameForType<VoidPtr>(); } }} #endif namespace physx { namespace Vd { //Additional properties that exist only in pvd land. struct PxPvdOnlyProperties { enum Enum { FirstProp = PxPropertyInfoName::LastPxPropertyInfoName, PxScene_Frame, PxScene_Contacts, PxScene_SimulateElapsedTime, #define DEFINE_ENUM_RANGE( stem, count ) \ stem##Begin, \ stem##End = stem##Begin + count //I can't easily add up the number of required property entries, but it is large due to the below //geometry count squared properties. Thus I punt and allocate way more than I need right now. DEFINE_ENUM_RANGE( PxScene_SimulationStatistics, 1000 ), DEFINE_ENUM_RANGE( PxSceneDesc_Limits, PxPropertyInfoName::PxSceneLimits_PropertiesStop - PxPropertyInfoName::PxSceneLimits_PropertiesStart ), DEFINE_ENUM_RANGE( PxSimulationStatistics_NumShapes, PxGeometryType::eGEOMETRY_COUNT ), DEFINE_ENUM_RANGE( PxSimulationStatistics_NumDiscreteContactPairs, PxGeometryType::eGEOMETRY_COUNT * PxGeometryType::eGEOMETRY_COUNT ), DEFINE_ENUM_RANGE( PxSimulationStatistics_NumModifiedContactPairs, PxGeometryType::eGEOMETRY_COUNT * PxGeometryType::eGEOMETRY_COUNT ), DEFINE_ENUM_RANGE( PxSimulationStatistics_NumSweptIntegrationPairs, PxGeometryType::eGEOMETRY_COUNT * PxGeometryType::eGEOMETRY_COUNT ), DEFINE_ENUM_RANGE( PxSimulationStatistics_NumTriggerPairs, PxGeometryType::eGEOMETRY_COUNT * PxGeometryType::eGEOMETRY_COUNT ), DEFINE_ENUM_RANGE( PxRigidDynamic_SolverIterationCounts, 2 ), DEFINE_ENUM_RANGE( PxArticulation_SolverIterationCounts, 2 ), DEFINE_ENUM_RANGE( PxArticulationJoint_SwingLimit, 2 ), DEFINE_ENUM_RANGE( PxArticulationJoint_TwistLimit, 2 ), DEFINE_ENUM_RANGE( PxConvexMeshGeometry_Scale, PxPropertyInfoName::PxMeshScale_PropertiesStop - PxPropertyInfoName::PxMeshScale_PropertiesStart ), DEFINE_ENUM_RANGE( PxTriangleMeshGeometry_Scale, PxPropertyInfoName::PxMeshScale_PropertiesStop - PxPropertyInfoName::PxMeshScale_PropertiesStart ), LastPxPvdOnlyProperty }; }; template<PxU32 TKey, typename TObjectType, typename TPropertyType, PxU32 TEnableFlag> struct PxBufferPropertyInfo : PxReadOnlyPropertyInfo< TKey, TObjectType, TPropertyType > { typedef PxReadOnlyPropertyInfo< TKey, TObjectType, TPropertyType > TBaseType; typedef typename TBaseType::TGetterType TGetterType; PxBufferPropertyInfo( const char* inName, TGetterType inGetter ) : TBaseType( inName, inGetter ) { } bool isEnabled( PxU32 inFlags ) const { return (inFlags & TEnableFlag) > 0; } }; #define DECLARE_BUFFER_PROPERTY( objectType, baseType, propType, propName, fieldName, flagName ) \ typedef PxBufferPropertyInfo< PxPvdOnlyProperties::baseType##_##propName, objectType, propType, flagName > T##objectType##propName##Base; \ inline propType get##propName( const objectType* inData ) { return inData->fieldName; } \ struct baseType##propName##Property : T##objectType##propName##Base \ { \ baseType##propName##Property() : T##objectType##propName##Base( #propName, get##propName ){} \ }; template<PxU32 PropertyKey, typename TEnumType > struct IndexerToNameMap { PxEnumTraits<TEnumType> Converter; }; struct ValueStructOffsetRecord { mutable bool mHasValidOffset; mutable PxU32 mOffset; ValueStructOffsetRecord() : mHasValidOffset( false ), mOffset( 0 ) {} void setupValueStructOffset( PxU32 inValue ) const { mHasValidOffset = true; mOffset = inValue; } }; template<PxU32 TKey, typename TObjectType, typename TPropertyType> struct PxPvdReadOnlyPropertyAccessor : public ValueStructOffsetRecord { typedef PxReadOnlyPropertyInfo<TKey,TObjectType,TPropertyType> TPropertyInfoType; typedef TPropertyType prop_type; const TPropertyInfoType mProperty; PxPvdReadOnlyPropertyAccessor( const TPropertyInfoType& inProp ) : mProperty( inProp ) { } prop_type get( const TObjectType* inObj ) const { return mProperty.get( inObj ); } private: PxPvdReadOnlyPropertyAccessor& operator=(const PxPvdReadOnlyPropertyAccessor&); }; template<PxU32 TKey, typename TObjectType, typename TPropertyType> struct PxBufferCollectionPropertyAccessor : public ValueStructOffsetRecord { typedef PxBufferCollectionPropertyInfo< TKey, TObjectType, TPropertyType > TPropertyInfoType; typedef TPropertyType prop_type; const TPropertyInfoType& mProperty; const char* mName; PxBufferCollectionPropertyAccessor( const TPropertyInfoType& inProp, const char* inName ) : mProperty( inProp ) , mName( inName ) { } const char* name() const { return mName; } PxU32 size( const TObjectType* inObj ) const { return mProperty.size( inObj ); } PxU32 get( const TObjectType* inObj, prop_type* buffer, PxU32 inNumItems) const { return mProperty.get( inObj, buffer, inNumItems); } void set( TObjectType* inObj, prop_type* inBuffer, PxU32 inNumItems ) const { mProperty.set( inObj, inBuffer, inNumItems ); } }; template<PxU32 TKey, typename TObjectType, typename TIndexType, typename TPropertyType> struct PxPvdIndexedPropertyAccessor : public ValueStructOffsetRecord { typedef PxIndexedPropertyInfo< TKey, TObjectType, TIndexType, TPropertyType > TPropertyInfoType; typedef TPropertyType prop_type; TIndexType mIndex; const TPropertyInfoType& mProperty; PxPvdIndexedPropertyAccessor( const TPropertyInfoType& inProp, PxU32 inIndex ) : mIndex( static_cast<TIndexType>( inIndex ) ) , mProperty( inProp ) { } prop_type get( const TObjectType* inObj ) const { return mProperty.get( inObj, mIndex ); } void set( TObjectType* inObj, prop_type val ) const { mProperty.set( inObj, mIndex, val ); } void operator = (PxPvdIndexedPropertyAccessor&) {} }; template<PxU32 TKey, typename TObjectType, typename TIndexType, typename TPropertyType> struct PxPvdExtendedIndexedPropertyAccessor : public ValueStructOffsetRecord { typedef PxExtendedIndexedPropertyInfo< TKey, TObjectType, TIndexType, TPropertyType > TPropertyInfoType; typedef TPropertyType prop_type; TIndexType mIndex; const TPropertyInfoType& mProperty; PxPvdExtendedIndexedPropertyAccessor( const TPropertyInfoType& inProp, PxU32 inIndex ) : mIndex( static_cast<TIndexType>( inIndex ) ) , mProperty( inProp ) { } PxU32 size( const TObjectType* inObj ) const { return mProperty.size( inObj ); } prop_type get( const TObjectType* inObj, TIndexType index ) const { return mProperty.get( inObj, index ); } void set( TObjectType* inObj, TIndexType index, prop_type val ) const { mProperty.set( inObj, index, val ); } void operator = (PxPvdExtendedIndexedPropertyAccessor&) {} }; template<PxU32 TKey, typename TObjectType, typename TIndexType, typename TPropertyType> struct PxPvdFixedSizeLookupTablePropertyAccessor : public ValueStructOffsetRecord { typedef PxFixedSizeLookupTablePropertyInfo< TKey, TObjectType, TIndexType, TPropertyType > TPropertyInfoType; typedef TPropertyType prop_type; TIndexType mIndex; const TPropertyInfoType& mProperty; PxPvdFixedSizeLookupTablePropertyAccessor( const TPropertyInfoType& inProp, const PxU32 inIndex3 ) : mIndex( static_cast<TIndexType>( inIndex3 ) ) , mProperty( inProp ) { } PxU32 size( const TObjectType* inObj ) const { return mProperty.size( inObj ); } prop_type getX( const TObjectType* inObj, const TIndexType index ) const { return mProperty.getX( inObj, index ); } prop_type getY( const TObjectType* inObj, const TIndexType index ) const { return mProperty.getY( inObj, index ); } void addPair( TObjectType* inObj, const PxReal x, const PxReal y ) { const_cast<TPropertyInfoType&>(mProperty).addPair( inObj, x, y ); } void clear( TObjectType* inObj ) { const_cast<TPropertyInfoType&>(mProperty).clear( inObj ); } void operator = (PxPvdFixedSizeLookupTablePropertyAccessor&) {} }; template<PxU32 TKey, typename TObjectType, typename TIdx0Type, typename TIdx1Type, typename TPropertyType> struct PxPvdDualIndexedPropertyAccessor : public ValueStructOffsetRecord { typedef PxDualIndexedPropertyInfo< TKey, TObjectType, TIdx0Type, TIdx1Type, TPropertyType > TPropertyInfoType; typedef TPropertyType prop_type; TIdx0Type mIdx0; TIdx1Type mIdx1; const TPropertyInfoType& mProperty; PxPvdDualIndexedPropertyAccessor( const TPropertyInfoType& inProp, PxU32 idx0, PxU32 idx1 ) : mIdx0( static_cast<TIdx0Type>( idx0 ) ) , mIdx1( static_cast<TIdx1Type>( idx1 ) ) , mProperty( inProp ) { } prop_type get( const TObjectType* inObj ) const { return mProperty.get( inObj, mIdx0, mIdx1 ); } void set( TObjectType* inObj, prop_type val ) const { mProperty.set( inObj, mIdx0, mIdx1, val ); } private: PxPvdDualIndexedPropertyAccessor& operator = (const PxPvdDualIndexedPropertyAccessor&); }; template<PxU32 TKey, typename TObjectType, typename TIdx0Type, typename TIdx1Type, typename TPropertyType> struct PxPvdExtendedDualIndexedPropertyAccessor : public ValueStructOffsetRecord { typedef PxExtendedDualIndexedPropertyInfo< TKey, TObjectType, TIdx0Type, TIdx1Type, TPropertyType > TPropertyInfoType; typedef TPropertyType prop_type; TIdx0Type mIdx0; TIdx1Type mIdx1; const TPropertyInfoType& mProperty; PxPvdExtendedDualIndexedPropertyAccessor( const TPropertyInfoType& inProp, PxU32 idx0, PxU32 idx1 ) : mIdx0( static_cast<TIdx0Type>( idx0 ) ) , mIdx1( static_cast<TIdx1Type>( idx1 ) ) , mProperty( inProp ) { } prop_type get( const TObjectType* inObj ) const { return mProperty.get( inObj, mIdx0, mIdx1 ); } void set( TObjectType* inObj, prop_type val ) const { mProperty.set( inObj, mIdx0, mIdx1, val ); } private: PxPvdExtendedDualIndexedPropertyAccessor& operator = (const PxPvdExtendedDualIndexedPropertyAccessor&); }; template<PxU32 TKey, typename TObjType, typename TPropertyType> struct PxPvdRangePropertyAccessor : public ValueStructOffsetRecord { typedef PxRangePropertyInfo<TKey, TObjType, TPropertyType> TPropertyInfoType; typedef TPropertyType prop_type; bool mFirstValue; const TPropertyInfoType& mProperty; PxPvdRangePropertyAccessor( const TPropertyInfoType& inProp, bool inFirstValue ) : mFirstValue( inFirstValue ) , mProperty( inProp ) { } prop_type get( const TObjType* inObj ) const { prop_type first,second; mProperty.get( inObj, first, second ); return mFirstValue ? first : second; } void set( TObjType* inObj, prop_type val ) const { prop_type first,second; mProperty.get( inObj, first, second ); if ( mFirstValue ) mProperty.set( inObj, val, second ); else mProperty.set( inObj, first, val ); } void operator = (PxPvdRangePropertyAccessor&) {} }; template<typename TDataType> struct IsFlagsType { bool FlagData; }; template<typename TEnumType, typename TStorageType> struct IsFlagsType<PxFlags<TEnumType, TStorageType> > { const PxU32ToName* FlagData; IsFlagsType<PxFlags<TEnumType, TStorageType> > () : FlagData( PxEnumTraits<TEnumType>().NameConversion ) {} }; template<typename TDataType> struct PvdClassForType { bool Unknown; }; } } #endif
13,059
C
40.069182
150
0.773643
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvd.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #include "PxPvdImpl.h" namespace physx { namespace pvdsdk { ForwardingAllocator gForwardingAllocator; PxAllocatorCallback* gPvdAllocatorCallback = &gForwardingAllocator; } // namespace pvdsdk PxPvd* PxCreatePvd(PxFoundation& foundation) { pvdsdk::gPvdAllocatorCallback = &foundation.getAllocatorCallback(); pvdsdk::PvdImpl::initialize(); return pvdsdk::PvdImpl::getInstance(); } } // namespace physx
2,101
C++
44.695651
74
0.772489
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdObjectModelMetaData.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. #include "PxPvdObjectModelInternalTypes.h" #include "PxPvdObjectModelMetaData.h" #include "PxPvdInternalByteStreams.h" #include "PxPvdMarshalling.h" using namespace physx; using namespace pvdsdk; namespace { struct PropDescImpl : public PropertyDescription, public PxUserAllocated { PxArray<NamedValue> mValueNames; PropDescImpl(const PropertyDescription& inBase, StringTable& table) : PropertyDescription(inBase), mValueNames("NamedValue") { mName = table.registerStr(mName); } PropDescImpl() : mValueNames("NamedValue") { } template <typename TSerializer> void serialize(TSerializer& serializer) { serializer.streamify(mOwnerClassName); serializer.streamify(mOwnerClassId); serializer.streamify(mSemantic); serializer.streamify(mDatatype); serializer.streamify(mDatatypeName); serializer.streamify(mPropertyType); serializer.streamify(mPropertyId); serializer.streamify(m32BitOffset); serializer.streamify(m64BitOffset); serializer.streamify(mValueNames); serializer.streamify(mName); } }; struct ClassDescImpl : public ClassDescription, public PxUserAllocated { PxArray<PropDescImpl*> mPropImps; PxArray<PtrOffset> m32OffsetArray; PxArray<PtrOffset> m64OffsetArray; ClassDescImpl(const ClassDescription& inBase) : ClassDescription(inBase) , mPropImps("PropDescImpl*") , m32OffsetArray("ClassDescImpl::m32OffsetArray") , m64OffsetArray("ClassDescImpl::m64OffsetArray") { PVD_FOREACH(idx, get32BitSizeInfo().mPtrOffsets.size()) m32OffsetArray.pushBack(get32BitSizeInfo().mPtrOffsets[idx]); PVD_FOREACH(idx, get64BitSizeInfo().mPtrOffsets.size()) m64OffsetArray.pushBack(get64BitSizeInfo().mPtrOffsets[idx]); } ClassDescImpl() : mPropImps("PropDescImpl*") , m32OffsetArray("ClassDescImpl::m32OffsetArray") , m64OffsetArray("ClassDescImpl::m64OffsetArray") { } PropDescImpl* findProperty(String name) { PVD_FOREACH(idx, mPropImps.size()) { if(safeStrEq(mPropImps[idx]->mName, name)) return mPropImps[idx]; } return NULL; } void addProperty(PropDescImpl* prop) { mPropImps.pushBack(prop); } void addPtrOffset(PtrOffsetType::Enum type, uint32_t offset32, uint32_t offset64) { m32OffsetArray.pushBack(PtrOffset(type, offset32)); m64OffsetArray.pushBack(PtrOffset(type, offset64)); get32BitSizeInfo().mPtrOffsets = DataRef<PtrOffset>(m32OffsetArray.begin(), m32OffsetArray.end()); get64BitSizeInfo().mPtrOffsets = DataRef<PtrOffset>(m64OffsetArray.begin(), m64OffsetArray.end()); } template <typename TSerializer> void serialize(TSerializer& serializer) { serializer.streamify(mName); serializer.streamify(mClassId); serializer.streamify(mBaseClass); serializer.streamify(mPackedUniformWidth); serializer.streamify(mPackedClassType); serializer.streamify(mLocked); serializer.streamify(mRequiresDestruction); serializer.streamify(get32BitSize()); serializer.streamify(get32BitSizeInfo().mDataByteSize); serializer.streamify(get32BitSizeInfo().mAlignment); serializer.streamify(get64BitSize()); serializer.streamify(get64BitSizeInfo().mDataByteSize); serializer.streamify(get64BitSizeInfo().mAlignment); serializer.streamifyLinks(mPropImps); serializer.streamify(m32OffsetArray); serializer.streamify(m64OffsetArray); get32BitSizeInfo().mPtrOffsets = DataRef<PtrOffset>(m32OffsetArray.begin(), m32OffsetArray.end()); get64BitSizeInfo().mPtrOffsets = DataRef<PtrOffset>(m64OffsetArray.begin(), m64OffsetArray.end()); } }; class StringTableImpl : public StringTable, public PxUserAllocated { PxHashMap<const char*, char*> mStrings; uint32_t mNextStrHandle; PxHashMap<uint32_t, char*> mHandleToStr; PxHashMap<const char*, uint32_t> mStrToHandle; public: StringTableImpl() : mStrings("StringTableImpl::mStrings") , mNextStrHandle(1) , mHandleToStr("StringTableImpl::mHandleToStr") , mStrToHandle("StringTableImpl::mStrToHandle") { } uint32_t nextHandleValue() { return mNextStrHandle++; } virtual ~StringTableImpl() { for(PxHashMap<const char*, char*>::Iterator iter = mStrings.getIterator(); !iter.done(); ++iter) PX_FREE(iter->second); mStrings.clear(); } virtual uint32_t getNbStrs() { return mStrings.size(); } virtual uint32_t getStrs(const char** outStrs, uint32_t bufLen, uint32_t startIdx = 0) { startIdx = PxMin(getNbStrs(), startIdx); uint32_t numStrs(PxMin(getNbStrs() - startIdx, bufLen)); PxHashMap<const char*, char*>::Iterator iter(mStrings.getIterator()); for(uint32_t idx = 0; idx < startIdx; ++idx, ++iter) ; for(uint32_t idx = 0; idx < numStrs && !iter.done(); ++idx, ++iter) outStrs[idx] = iter->second; return numStrs; } void addStringHandle(char* str, uint32_t hdl) { mHandleToStr.insert(hdl, str); mStrToHandle.insert(str, hdl); } uint32_t addStringHandle(char* str) { uint32_t theNewHandle = nextHandleValue(); addStringHandle(str, theNewHandle); return theNewHandle; } const char* doRegisterStr(const char* str, bool& outAdded) { PX_ASSERT(isMeaningful(str)); const PxHashMap<const char*, char*>::Entry* entry(mStrings.find(str)); if(entry == NULL) { outAdded = true; char* retval(copyStr(str)); mStrings.insert(retval, retval); return retval; } return entry->second; } virtual const char* registerStr(const char* str, bool& outAdded) { outAdded = false; if(isMeaningful(str) == false) return ""; const char* retval = doRegisterStr(str, outAdded); if(outAdded) addStringHandle(const_cast<char*>(retval)); return retval; } NamespacedName registerName(const NamespacedName& nm) { return NamespacedName(registerStr(nm.mNamespace), registerStr(nm.mName)); } const char* registerStr(const char* str) { bool ignored; return registerStr(str, ignored); } virtual StringHandle strToHandle(const char* str) { if(isMeaningful(str) == false) return 0; const PxHashMap<const char*, uint32_t>::Entry* entry(mStrToHandle.find(str)); if(entry) return entry->second; bool added = false; const char* registeredStr = doRegisterStr(str, added); uint32_t theNewHandle = addStringHandle(const_cast<char*>(registeredStr)); PX_ASSERT(mStrToHandle.find(str)); PX_ASSERT(added); return theNewHandle; } virtual const char* handleToStr(uint32_t hdl) { if(hdl == 0) return ""; const PxHashMap<uint32_t, char*>::Entry* entry(mHandleToStr.find(hdl)); if(entry) return entry->second; // unregistered handle... return ""; } void write(PvdOutputStream& stream) { uint32_t numStrs = static_cast<uint32_t>(mHandleToStr.size()); stream << numStrs; stream << mNextStrHandle; for(PxHashMap<uint32_t, char*>::Iterator iter = mHandleToStr.getIterator(); !iter.done(); ++iter) { stream << iter->first; uint32_t len = static_cast<uint32_t>(strlen(iter->second) + 1); stream << len; stream.write(reinterpret_cast<uint8_t*>(iter->second), len); } } template <typename TReader> void read(TReader& stream) { mHandleToStr.clear(); mStrToHandle.clear(); uint32_t numStrs; stream >> numStrs; stream >> mNextStrHandle; PxArray<uint8_t> readBuffer("StringTable::read::readBuffer"); uint32_t bufSize = 0; for(uint32_t idx = 0; idx < numStrs; ++idx) { uint32_t handleValue; uint32_t bufLen; stream >> handleValue; stream >> bufLen; if(bufSize < bufLen) readBuffer.resize(bufLen); bufSize = PxMax(bufSize, bufLen); stream.read(readBuffer.begin(), bufLen); bool ignored; const char* newStr = doRegisterStr(reinterpret_cast<const char*>(readBuffer.begin()), ignored); addStringHandle(const_cast<char*>(newStr), handleValue); } } virtual void release() { PVD_DELETE(this); } private: StringTableImpl& operator=(const StringTableImpl&); }; struct NamespacedNameHasher { uint32_t operator()(const NamespacedName& nm) { return PxHash<const char*>()(nm.mNamespace) ^ PxHash<const char*>()(nm.mName); } bool equal(const NamespacedName& lhs, const NamespacedName& rhs) { return safeStrEq(lhs.mNamespace, rhs.mNamespace) && safeStrEq(lhs.mName, rhs.mName); } }; struct ClassPropertyName { NamespacedName mName; String mPropName; ClassPropertyName(const NamespacedName& name = NamespacedName(), String propName = "") : mName(name), mPropName(propName) { } }; struct ClassPropertyNameHasher { uint32_t operator()(const ClassPropertyName& nm) { return NamespacedNameHasher()(nm.mName) ^ PxHash<const char*>()(nm.mPropName); } bool equal(const ClassPropertyName& lhs, const ClassPropertyName& rhs) { return NamespacedNameHasher().equal(lhs.mName, rhs.mName) && safeStrEq(lhs.mPropName, rhs.mPropName); } }; struct PropertyMessageEntryImpl : public PropertyMessageEntry { PropertyMessageEntryImpl(const PropertyMessageEntry& data) : PropertyMessageEntry(data) { } PropertyMessageEntryImpl() { } template <typename TSerializerType> void serialize(TSerializerType& serializer) { serializer.streamify(mDatatypeName); serializer.streamify(mDatatypeId); serializer.streamify(mMessageOffset); serializer.streamify(mByteSize); serializer.streamify(mDestByteSize); serializer.streamify(mProperty); } }; struct PropertyMessageDescriptionImpl : public PropertyMessageDescription, public PxUserAllocated { PxArray<PropertyMessageEntryImpl> mEntryImpls; PxArray<PropertyMessageEntry> mEntries; PxArray<uint32_t> mStringOffsetArray; PropertyMessageDescriptionImpl(const PropertyMessageDescription& data) : PropertyMessageDescription(data) , mEntryImpls("PropertyMessageDescriptionImpl::mEntryImpls") , mEntries("PropertyMessageDescriptionImpl::mEntries") , mStringOffsetArray("PropertyMessageDescriptionImpl::mStringOffsets") { } PropertyMessageDescriptionImpl() : mEntryImpls("PropertyMessageDescriptionImpl::mEntryImpls") , mEntries("PropertyMessageDescriptionImpl::mEntries") , mStringOffsetArray("PropertyMessageDescriptionImpl::mStringOffsets") { } ~PropertyMessageDescriptionImpl() { } void addEntry(const PropertyMessageEntryImpl& entry) { mEntryImpls.pushBack(entry); mEntries.pushBack(entry); mProperties = DataRef<PropertyMessageEntry>(mEntries.begin(), mEntries.end()); } template <typename TSerializerType> void serialize(TSerializerType& serializer) { serializer.streamify(mClassName); serializer.streamify(mClassId); // No other class has this id, it is DB-unique serializer.streamify(mMessageName); serializer.streamify(mMessageId); serializer.streamify(mMessageByteSize); serializer.streamify(mEntryImpls); serializer.streamify(mStringOffsetArray); if(mEntries.size() != mEntryImpls.size()) { mEntries.clear(); uint32_t numEntries = static_cast<uint32_t>(mEntryImpls.size()); for(uint32_t idx = 0; idx < numEntries; ++idx) mEntries.pushBack(mEntryImpls[idx]); } mProperties = DataRef<PropertyMessageEntry>(mEntries.begin(), mEntries.end()); mStringOffsets = DataRef<uint32_t>(mStringOffsetArray.begin(), mStringOffsetArray.end()); } private: PropertyMessageDescriptionImpl& operator=(const PropertyMessageDescriptionImpl&); }; struct PvdObjectModelMetaDataImpl : public PvdObjectModelMetaData, public PxUserAllocated { typedef PxHashMap<NamespacedName, ClassDescImpl*, NamespacedNameHasher> TNameToClassMap; typedef PxHashMap<ClassPropertyName, PropDescImpl*, ClassPropertyNameHasher> TNameToPropMap; typedef PxHashMap<NamespacedName, PropertyMessageDescriptionImpl*, NamespacedNameHasher> TNameToPropertyMessageMap; TNameToClassMap mNameToClasses; TNameToPropMap mNameToProperties; PxArray<ClassDescImpl*> mClasses; PxArray<PropDescImpl*> mProperties; StringTableImpl* mStringTable; TNameToPropertyMessageMap mPropertyMessageMap; PxArray<PropertyMessageDescriptionImpl*> mPropertyMessages; int32_t mNextClassId; uint32_t mRefCount; PvdObjectModelMetaDataImpl() : mNameToClasses("NamespacedName->ClassDescImpl*") , mNameToProperties("ClassPropertyName->PropDescImpl*") , mClasses("ClassDescImpl*") , mProperties("PropDescImpl*") , mStringTable(PVD_NEW(StringTableImpl)()) , mPropertyMessageMap("PropertyMessageMap") , mPropertyMessages("PvdObjectModelMetaDataImpl::mPropertyMessages") , mNextClassId(1) , mRefCount(0) { } private: PvdObjectModelMetaDataImpl& operator=(const PvdObjectModelMetaDataImpl&); public: int32_t nextClassId() { return mNextClassId++; } void initialize() { // Create the default classes. { ClassDescImpl& aryData = getOrCreateClassImpl(getPvdNamespacedNameForType<ArrayData>(), DataTypeToPvdTypeMap<ArrayData>::BaseTypeEnum); aryData.get32BitSize() = sizeof(ArrayData); aryData.get32BitSizeInfo().mAlignment = sizeof(void*); aryData.get64BitSize() = sizeof(ArrayData); aryData.get64BitSizeInfo().mAlignment = sizeof(void*); aryData.mLocked = true; } #define CREATE_BASIC_PVD_CLASS(type) \ { \ ClassDescImpl& cls = getOrCreateClassImpl(getPvdNamespacedNameForType<type>(), getPvdTypeForType<type>()); \ cls.get32BitSize() = sizeof(type); \ cls.get32BitSizeInfo().mAlignment = sizeof(type); \ cls.get64BitSize() = sizeof(type); \ cls.get64BitSizeInfo().mAlignment = sizeof(type); \ cls.mLocked = true; \ cls.mPackedUniformWidth = sizeof(type); \ cls.mPackedClassType = getPvdTypeForType<type>(); \ } CREATE_BASIC_PVD_CLASS(int8_t) CREATE_BASIC_PVD_CLASS(uint8_t) CREATE_BASIC_PVD_CLASS(bool) CREATE_BASIC_PVD_CLASS(int16_t) CREATE_BASIC_PVD_CLASS(uint16_t) CREATE_BASIC_PVD_CLASS(int32_t) CREATE_BASIC_PVD_CLASS(uint32_t) // CREATE_BASIC_PVD_CLASS(uint32_t) CREATE_BASIC_PVD_CLASS(int64_t) CREATE_BASIC_PVD_CLASS(uint64_t) CREATE_BASIC_PVD_CLASS(float) CREATE_BASIC_PVD_CLASS(double) #undef CREATE_BASIC_PVD_CLASS #define CREATE_PTR_TYPE_PVD_CLASS(type, ptrType) \ { \ ClassDescImpl& cls = getOrCreateClassImpl(getPvdNamespacedNameForType<type>(), getPvdTypeForType<type>()); \ cls.get32BitSize() = 4; \ cls.get32BitSizeInfo().mAlignment = 4; \ cls.get64BitSize() = 8; \ cls.get64BitSizeInfo().mAlignment = 8; \ cls.mLocked = true; \ cls.addPtrOffset(PtrOffsetType::ptrType, 0, 0); \ } CREATE_PTR_TYPE_PVD_CLASS(String, StringOffset) CREATE_PTR_TYPE_PVD_CLASS(VoidPtr, VoidPtrOffset) CREATE_PTR_TYPE_PVD_CLASS(StringHandle, StringOffset) CREATE_PTR_TYPE_PVD_CLASS(ObjectRef, VoidPtrOffset) #undef CREATE_64BIT_ADJUST_PVD_CLASS int32_t fltClassType = getPvdTypeForType<float>(); int32_t u32ClassType = getPvdTypeForType<uint32_t>(); int32_t v3ClassType = getPvdTypeForType<PxVec3>(); int32_t v4ClassType = getPvdTypeForType<PxVec4>(); int32_t qtClassType = getPvdTypeForType<PxQuat>(); { ClassDescImpl& cls = getOrCreateClassImpl(getPvdNamespacedNameForType<PvdColor>(), getPvdTypeForType<PvdColor>()); createProperty(cls.mClassId, "r", "", getPvdTypeForType<uint8_t>(), PropertyType::Scalar); createProperty(cls.mClassId, "g", "", getPvdTypeForType<uint8_t>(), PropertyType::Scalar); createProperty(cls.mClassId, "b", "", getPvdTypeForType<uint8_t>(), PropertyType::Scalar); createProperty(cls.mClassId, "a", "", getPvdTypeForType<uint8_t>(), PropertyType::Scalar); PX_ASSERT(cls.get32BitSizeInfo().mAlignment == 1); PX_ASSERT(cls.get32BitSize() == 4); PX_ASSERT(cls.get64BitSizeInfo().mAlignment == 1); PX_ASSERT(cls.get64BitSize() == 4); PX_ASSERT(cls.mPackedUniformWidth == 1); PX_ASSERT(cls.mPackedClassType == getPvdTypeForType<uint8_t>()); cls.mLocked = true; } { ClassDescImpl& cls = getOrCreateClassImpl(getPvdNamespacedNameForType<PxVec2>(), getPvdTypeForType<PxVec2>()); createProperty(cls.mClassId, "x", "", fltClassType, PropertyType::Scalar); createProperty(cls.mClassId, "y", "", fltClassType, PropertyType::Scalar); PX_ASSERT(cls.get32BitSizeInfo().mAlignment == 4); PX_ASSERT(cls.get32BitSize() == 8); PX_ASSERT(cls.get64BitSizeInfo().mAlignment == 4); PX_ASSERT(cls.get64BitSize() == 8); PX_ASSERT(cls.mPackedUniformWidth == 4); PX_ASSERT(cls.mPackedClassType == fltClassType); cls.mLocked = true; } { ClassDescImpl& cls = getOrCreateClassImpl(getPvdNamespacedNameForType<PxVec3>(), getPvdTypeForType<PxVec3>()); createProperty(cls.mClassId, "x", "", fltClassType, PropertyType::Scalar); createProperty(cls.mClassId, "y", "", fltClassType, PropertyType::Scalar); createProperty(cls.mClassId, "z", "", fltClassType, PropertyType::Scalar); PX_ASSERT(cls.get32BitSizeInfo().mAlignment == 4); PX_ASSERT(cls.get32BitSize() == 12); PX_ASSERT(cls.get64BitSizeInfo().mAlignment == 4); PX_ASSERT(cls.get64BitSize() == 12); PX_ASSERT(cls.mPackedUniformWidth == 4); PX_ASSERT(cls.mPackedClassType == fltClassType); cls.mLocked = true; } { ClassDescImpl& cls = getOrCreateClassImpl(getPvdNamespacedNameForType<PxVec4>(), getPvdTypeForType<PxVec4>()); createProperty(cls.mClassId, "x", "", fltClassType, PropertyType::Scalar); createProperty(cls.mClassId, "y", "", fltClassType, PropertyType::Scalar); createProperty(cls.mClassId, "z", "", fltClassType, PropertyType::Scalar); createProperty(cls.mClassId, "w", "", fltClassType, PropertyType::Scalar); PX_ASSERT(cls.get32BitSizeInfo().mAlignment == 4); PX_ASSERT(cls.get32BitSize() == 16); PX_ASSERT(cls.get64BitSizeInfo().mAlignment == 4); PX_ASSERT(cls.get64BitSize() == 16); PX_ASSERT(cls.mPackedUniformWidth == 4); PX_ASSERT(cls.mPackedClassType == fltClassType); cls.mLocked = true; } { ClassDescImpl& cls = getOrCreateClassImpl(getPvdNamespacedNameForType<PxQuat>(), getPvdTypeForType<PxQuat>()); createProperty(cls.mClassId, "x", "", fltClassType, PropertyType::Scalar); createProperty(cls.mClassId, "y", "", fltClassType, PropertyType::Scalar); createProperty(cls.mClassId, "z", "", fltClassType, PropertyType::Scalar); createProperty(cls.mClassId, "w", "", fltClassType, PropertyType::Scalar); PX_ASSERT(cls.get32BitSizeInfo().mAlignment == 4); PX_ASSERT(cls.get32BitSize() == 16); PX_ASSERT(cls.get64BitSizeInfo().mAlignment == 4); PX_ASSERT(cls.get64BitSize() == 16); PX_ASSERT(cls.mPackedUniformWidth == 4); PX_ASSERT(cls.mPackedClassType == fltClassType); cls.mLocked = true; } { ClassDescImpl& cls = getOrCreateClassImpl(getPvdNamespacedNameForType<PxBounds3>(), getPvdTypeForType<PxBounds3>()); createProperty(cls.mClassId, "minimum", "", v3ClassType, PropertyType::Scalar); createProperty(cls.mClassId, "maximum", "", v3ClassType, PropertyType::Scalar); PX_ASSERT(cls.get32BitSizeInfo().mAlignment == 4); PX_ASSERT(cls.get32BitSize() == 24); PX_ASSERT(cls.mPackedUniformWidth == 4); PX_ASSERT(cls.mPackedClassType == fltClassType); cls.mLocked = true; } { ClassDescImpl& cls = getOrCreateClassImpl(getPvdNamespacedNameForType<PxTransform>(), getPvdTypeForType<PxTransform>()); createProperty(cls.mClassId, "q", "", qtClassType, PropertyType::Scalar); createProperty(cls.mClassId, "p", "", v3ClassType, PropertyType::Scalar); PX_ASSERT(cls.get32BitSizeInfo().mAlignment == 4); PX_ASSERT(cls.get32BitSize() == 28); PX_ASSERT(cls.mPackedUniformWidth == 4); PX_ASSERT(cls.mPackedClassType == fltClassType); cls.mLocked = true; } { ClassDescImpl& cls = getOrCreateClassImpl(getPvdNamespacedNameForType<PxMat33>(), getPvdTypeForType<PxMat33>()); createProperty(cls.mClassId, "column0", "", v3ClassType, PropertyType::Scalar); createProperty(cls.mClassId, "column1", "", v3ClassType, PropertyType::Scalar); createProperty(cls.mClassId, "column2", "", v3ClassType, PropertyType::Scalar); PX_ASSERT(cls.get32BitSizeInfo().mAlignment == 4); PX_ASSERT(cls.get32BitSize() == 36); PX_ASSERT(cls.mPackedUniformWidth == 4); PX_ASSERT(cls.mPackedClassType == fltClassType); cls.mLocked = true; } { ClassDescImpl& cls = getOrCreateClassImpl(getPvdNamespacedNameForType<PxMat44>(), getPvdTypeForType<PxMat44>()); createProperty(cls.mClassId, "column0", "", v4ClassType, PropertyType::Scalar); createProperty(cls.mClassId, "column1", "", v4ClassType, PropertyType::Scalar); createProperty(cls.mClassId, "column2", "", v4ClassType, PropertyType::Scalar); createProperty(cls.mClassId, "column3", "", v4ClassType, PropertyType::Scalar); PX_ASSERT(cls.get32BitSizeInfo().mAlignment == 4); PX_ASSERT(cls.get32BitSize() == 64); PX_ASSERT(cls.mPackedUniformWidth == 4); PX_ASSERT(cls.mPackedClassType == fltClassType); cls.mLocked = true; } { ClassDescImpl& cls = getOrCreateClassImpl(getPvdNamespacedNameForType<U32Array4>(), getPvdTypeForType<U32Array4>()); createProperty(cls.mClassId, "d0", "", u32ClassType, PropertyType::Scalar); createProperty(cls.mClassId, "d1", "", u32ClassType, PropertyType::Scalar); createProperty(cls.mClassId, "d2", "", u32ClassType, PropertyType::Scalar); createProperty(cls.mClassId, "d3", "", u32ClassType, PropertyType::Scalar); cls.mLocked = true; } } virtual ~PvdObjectModelMetaDataImpl() { mStringTable->release(); PVD_FOREACH(idx, mClasses.size()) { if(mClasses[idx] != NULL) PVD_DELETE(mClasses[idx]); } mClasses.clear(); PVD_FOREACH(idx, mProperties.size()) PVD_DELETE(mProperties[idx]); mProperties.clear(); PVD_FOREACH(idx, mPropertyMessages.size()) PVD_DELETE(mPropertyMessages[idx]); mPropertyMessages.clear(); } ClassDescImpl& getOrCreateClassImpl(const NamespacedName& nm, int32_t idx) { ClassDescImpl* impl(getClassImpl(idx)); if(impl) return *impl; NamespacedName safeName(mStringTable->registerStr(nm.mNamespace), mStringTable->registerStr(nm.mName)); while(idx >= int32_t(mClasses.size())) mClasses.pushBack(NULL); mClasses[uint32_t(idx)] = PVD_NEW(ClassDescImpl)(ClassDescription(safeName, idx)); mNameToClasses.insert(nm, mClasses[uint32_t(idx)]); mNextClassId = PxMax(mNextClassId, idx + 1); return *mClasses[uint32_t(idx)]; } ClassDescImpl& getOrCreateClassImpl(const NamespacedName& nm) { ClassDescImpl* retval = findClassImpl(nm); if(retval) return *retval; return getOrCreateClassImpl(nm, nextClassId()); } virtual ClassDescription getOrCreateClass(const NamespacedName& nm) { return getOrCreateClassImpl(nm); } // get or create parent, lock parent. deriveFrom getOrCreatechild. virtual bool deriveClass(const NamespacedName& parent, const NamespacedName& child) { ClassDescImpl& p(getOrCreateClassImpl(parent)); ClassDescImpl& c(getOrCreateClassImpl(child)); if(c.mBaseClass >= 0) { PX_ASSERT(c.mBaseClass == p.mClassId); return false; } p.mLocked = true; c.mBaseClass = p.mClassId; c.get32BitSizeInfo() = p.get32BitSizeInfo(); c.get64BitSizeInfo() = p.get64BitSizeInfo(); c.mPackedClassType = p.mPackedClassType; c.mPackedUniformWidth = p.mPackedUniformWidth; c.mRequiresDestruction = p.mRequiresDestruction; c.m32OffsetArray = p.m32OffsetArray; c.m64OffsetArray = p.m64OffsetArray; // Add all the parent propertes to this class in the global name map. for(ClassDescImpl* parent0 = &p; parent0 != NULL; parent0 = getClassImpl(parent0->mBaseClass)) { PVD_FOREACH(idx, parent0->mPropImps.size()) mNameToProperties.insert(ClassPropertyName(c.mName, parent0->mPropImps[idx]->mName), parent0->mPropImps[idx]); if(parent0->mBaseClass < 0) break; } return true; } ClassDescImpl* findClassImpl(const NamespacedName& nm) const { const TNameToClassMap::Entry* entry(mNameToClasses.find(nm)); if(entry) return entry->second; return NULL; } virtual Option<ClassDescription> findClass(const NamespacedName& nm) const { ClassDescImpl* retval = findClassImpl(nm); if(retval) return *retval; return Option<ClassDescription>(); } ClassDescImpl* getClassImpl(int32_t classId) const { if(classId < 0) return NULL; uint32_t idx = uint32_t(classId); if(idx < mClasses.size()) return mClasses[idx]; return NULL; } virtual Option<ClassDescription> getClass(int32_t classId) const { ClassDescImpl* impl(getClassImpl(classId)); if(impl) return *impl; return None(); } virtual ClassDescription* getClassPtr(int32_t classId) const { return getClassImpl(classId); } virtual Option<ClassDescription> getParentClass(int32_t classId) const { ClassDescImpl* impl(getClassImpl(classId)); if(impl == NULL) return None(); return getClass(impl->mBaseClass); } virtual void lockClass(int32_t classId) { ClassDescImpl* impl(getClassImpl(classId)); PX_ASSERT(impl); if(impl) impl->mLocked = true; } virtual uint32_t getNbClasses() const { uint32_t total = 0; PVD_FOREACH(idx, mClasses.size()) if(mClasses[idx])++ total; return total; } virtual uint32_t getClasses(ClassDescription* outClasses, uint32_t requestCount, uint32_t startIndex = 0) const { uint32_t classCount(getNbClasses()); startIndex = PxMin(classCount, startIndex); uint32_t retAmount = PxMin(requestCount, classCount - startIndex); uint32_t idx = 0; while(startIndex) { if(mClasses[idx] != NULL) --startIndex; ++idx; } uint32_t inserted = 0; uint32_t classesSize = static_cast<uint32_t>(mClasses.size()); while(inserted < retAmount && idx < classesSize) { if(mClasses[idx] != NULL) { outClasses[inserted] = *mClasses[idx]; ++inserted; } ++idx; } return inserted; } uint32_t updateByteSizeAndGetPropertyAlignment(ClassDescriptionSizeInfo& dest, const ClassDescriptionSizeInfo& src) { uint32_t alignment = src.mAlignment; dest.mAlignment = PxMax(dest.mAlignment, alignment); uint32_t offset = align(dest.mDataByteSize, alignment); dest.mDataByteSize = offset + src.mByteSize; dest.mByteSize = align(dest.mDataByteSize, dest.mAlignment); return offset; } void transferPtrOffsets(ClassDescriptionSizeInfo& destInfo, PxArray<PtrOffset>& destArray, const PxArray<PtrOffset>& src, uint32_t offset) { PVD_FOREACH(idx, src.size()) destArray.pushBack(PtrOffset(src[idx].mOffsetType, src[idx].mOffset + offset)); destInfo.mPtrOffsets = DataRef<PtrOffset>(destArray.begin(), destArray.end()); } virtual Option<PropertyDescription> createProperty(int32_t classId, String name, String semantic, int32_t datatype, PropertyType::Enum propertyType) { ClassDescImpl* cls(getClassImpl(classId)); PX_ASSERT(cls); if(!cls) return None(); if(cls->mLocked) { PX_ASSERT(false); return None(); } PropDescImpl* impl(cls->findProperty(name)); // duplicate property definition if(impl) { PX_ASSERT(false); return None(); } if(datatype == getPvdTypeForType<String>()) { PX_ASSERT(false); return None(); } // The datatype for this property has not been declared. ClassDescImpl* propDType(getClassImpl(datatype)); PX_ASSERT(propDType); if(!propDType) return None(); NamespacedName propClsName(propDType->mName); int32_t propPackedWidth = propDType->mPackedUniformWidth; int32_t propPackedType = propDType->mPackedClassType; // The implications of properties being complex types aren't major //*until* you start trying to undue a property event that set values // of those complex types. Then things just get too complex. if(propDType->mRequiresDestruction) { PX_ASSERT(false); return None(); } bool requiresDestruction = propDType->mRequiresDestruction || cls->mRequiresDestruction; if(propertyType == PropertyType::Array) { int32_t tempId = DataTypeToPvdTypeMap<ArrayData>::BaseTypeEnum; propDType = getClassImpl(tempId); PX_ASSERT(propDType); if(!propDType) return None(); requiresDestruction = true; } uint32_t offset32 = updateByteSizeAndGetPropertyAlignment(cls->get32BitSizeInfo(), propDType->get32BitSizeInfo()); uint32_t offset64 = updateByteSizeAndGetPropertyAlignment(cls->get64BitSizeInfo(), propDType->get64BitSizeInfo()); transferPtrOffsets(cls->get32BitSizeInfo(), cls->m32OffsetArray, propDType->m32OffsetArray, offset32); transferPtrOffsets(cls->get64BitSizeInfo(), cls->m64OffsetArray, propDType->m64OffsetArray, offset64); propDType->mLocked = true; // Can't add members to the property type. cls->mRequiresDestruction = requiresDestruction; int32_t propId = int32_t(mProperties.size()); PropertyDescription newDesc(cls->mName, cls->mClassId, name, semantic, datatype, propClsName, propertyType, propId, offset32, offset64); mProperties.pushBack(PVD_NEW(PropDescImpl)(newDesc, *mStringTable)); mNameToProperties.insert(ClassPropertyName(cls->mName, mProperties.back()->mName), mProperties.back()); cls->addProperty(mProperties.back()); bool firstProp = cls->mPropImps.size() == 1; if(firstProp) { cls->mPackedUniformWidth = propPackedWidth; cls->mPackedClassType = propPackedType; } else { bool packed = (propPackedWidth > 0) && (cls->get32BitSizeInfo().mDataByteSize % propPackedWidth) == 0; if(cls->mPackedClassType >= 0) // maybe uncheck packed class type { if(propPackedType < 0 || cls->mPackedClassType != propPackedType // Object refs require conversion from stream to db id || datatype == getPvdTypeForType<ObjectRef>() // Strings also require conversion from stream to db id. || datatype == getPvdTypeForType<StringHandle>() || packed == false) cls->mPackedClassType = -1; } if(cls->mPackedUniformWidth >= 0) // maybe uncheck packed class width { if(propPackedWidth < 0 || cls->mPackedUniformWidth != propPackedWidth // object refs, because they require special treatment during parsing, // cannot be packed || datatype == getPvdTypeForType<ObjectRef>() // Likewise, string handles are special because the data needs to be sent *after* // the || datatype == getPvdTypeForType<StringHandle>() || packed == false) cls->mPackedUniformWidth = -1; // invalid packed width. } } return *mProperties.back(); } PropDescImpl* findPropImpl(const NamespacedName& clsName, String prop) const { const TNameToPropMap::Entry* entry = mNameToProperties.find(ClassPropertyName(clsName, prop)); if(entry) return entry->second; return NULL; } virtual Option<PropertyDescription> findProperty(const NamespacedName& cls, String propName) const { PropDescImpl* prop(findPropImpl(cls, propName)); if(prop) return *prop; return None(); } virtual Option<PropertyDescription> findProperty(int32_t clsId, String propName) const { ClassDescImpl* cls(getClassImpl(clsId)); PX_ASSERT(cls); if(!cls) return None(); PropDescImpl* prop(findPropImpl(cls->mName, propName)); if(prop) return *prop; return None(); } PropDescImpl* getPropertyImpl(int32_t propId) const { PX_ASSERT(propId >= 0); if(propId < 0) return NULL; uint32_t val = uint32_t(propId); if(val >= mProperties.size()) { PX_ASSERT(false); return NULL; } return mProperties[val]; } virtual Option<PropertyDescription> getProperty(int32_t propId) const { PropDescImpl* impl(getPropertyImpl(propId)); if(impl) return *impl; return None(); } virtual void setNamedPropertyValues(DataRef<NamedValue> values, int32_t propId) { PropDescImpl* impl(getPropertyImpl(propId)); if(impl) { impl->mValueNames.resize(values.size()); PVD_FOREACH(idx, values.size()) impl->mValueNames[idx] = values[idx]; } } virtual DataRef<NamedValue> getNamedPropertyValues(int32_t propId) const { PropDescImpl* impl(getPropertyImpl(propId)); if(impl) { return toDataRef(impl->mValueNames); } return DataRef<NamedValue>(); } virtual uint32_t getNbProperties(int32_t classId) const { uint32_t retval = 0; for(ClassDescImpl* impl(getClassImpl(classId)); impl; impl = getClassImpl(impl->mBaseClass)) { retval += impl->mPropImps.size(); if(impl->mBaseClass < 0) break; } return retval; } // Properties need to be returned in base class order, so this requires a recursive function. uint32_t getPropertiesImpl(int32_t classId, PropertyDescription*& outBuffer, uint32_t& numItems, uint32_t& startIdx) const { ClassDescImpl* impl = getClassImpl(classId); if(impl) { uint32_t retval = 0; if(impl->mBaseClass >= 0) retval = getPropertiesImpl(impl->mBaseClass, outBuffer, numItems, startIdx); uint32_t localStart = PxMin(impl->mPropImps.size(), startIdx); uint32_t localNumItems = PxMin(numItems, impl->mPropImps.size() - localStart); PVD_FOREACH(idx, localNumItems) { outBuffer[idx] = *impl->mPropImps[localStart + idx]; } startIdx -= localStart; numItems -= localNumItems; outBuffer += localNumItems; return retval + localNumItems; } return 0; } virtual uint32_t getProperties(int32_t classId, PropertyDescription* outBuffer, uint32_t numItems, uint32_t startIdx) const { return getPropertiesImpl(classId, outBuffer, numItems, startIdx); } virtual MarshalQueryResult checkMarshalling(int32_t srcClsId, int32_t dstClsId) const { Option<ClassDescription> propTypeOpt(getClass(dstClsId)); if(propTypeOpt.hasValue() == false) { PX_ASSERT(false); return MarshalQueryResult(); } const ClassDescription& propType(propTypeOpt); Option<ClassDescription> incomingTypeOpt(getClass(srcClsId)); if(incomingTypeOpt.hasValue() == false) { PX_ASSERT(false); return MarshalQueryResult(); } const ClassDescription& incomingType(incomingTypeOpt); // Can only marshal simple things at this point in time. bool needsMarshalling = false; bool canMarshal = false; TSingleMarshaller single = NULL; TBlockMarshaller block = NULL; if(incomingType.mClassId != propType.mClassId) { // Check that marshalling is even possible. if((incomingType.mPackedUniformWidth >= 0 && propType.mPackedUniformWidth >= 0) == false) { PX_ASSERT(false); return MarshalQueryResult(); } int32_t srcType = incomingType.mPackedClassType; int32_t dstType = propType.mPackedClassType; int32_t srcWidth = incomingType.mPackedUniformWidth; int32_t dstWidth = propType.mPackedUniformWidth; canMarshal = getMarshalOperators(single, block, srcType, dstType); if(srcWidth == dstWidth) needsMarshalling = canMarshal; // If the types are the same width, we assume we can convert between some // of them seamlessly (uint16_t, int16_t) else { needsMarshalling = true; // If we can't marshall and we have to then we can't set the property value. // This indicates that the src and dest are different properties and we don't // know how to convert between them. if(!canMarshal) { PX_ASSERT(false); return MarshalQueryResult(); } } } return MarshalQueryResult(srcClsId, dstClsId, canMarshal, needsMarshalling, block); } PropertyMessageDescriptionImpl* findPropertyMessageImpl(const NamespacedName& messageName) const { const TNameToPropertyMessageMap::Entry* entry = mPropertyMessageMap.find(messageName); if(entry) return entry->second; return NULL; } PropertyMessageDescriptionImpl* getPropertyMessageImpl(int32_t msg) const { int32_t msgCount = int32_t(mPropertyMessages.size()); if(msg >= 0 && msg < msgCount) return mPropertyMessages[uint32_t(msg)]; return NULL; } virtual Option<PropertyMessageDescription> createPropertyMessage(const NamespacedName& clsName, const NamespacedName& messageName, DataRef<PropertyMessageArg> entries, uint32_t messageSize) { PropertyMessageDescriptionImpl* existing(findPropertyMessageImpl(messageName)); if(existing) { PX_ASSERT(false); return None(); } ClassDescImpl* cls = findClassImpl(clsName); PX_ASSERT(cls); if(!cls) return None(); int32_t msgId = int32_t(mPropertyMessages.size()); PropertyMessageDescriptionImpl* newMessage = PVD_NEW(PropertyMessageDescriptionImpl)( PropertyMessageDescription(mStringTable->registerName(clsName), cls->mClassId, mStringTable->registerName(messageName), msgId, messageSize)); uint32_t calculatedSize = 0; PVD_FOREACH(idx, entries.size()) { PropertyMessageArg entry(entries[idx]); ClassDescImpl* dtypeCls = findClassImpl(entry.mDatatypeName); if(dtypeCls == NULL) { PX_ASSERT(false); goto DestroyNewMessage; } ClassDescriptionSizeInfo dtypeInfo(dtypeCls->get32BitSizeInfo()); uint32_t incomingSize = dtypeInfo.mByteSize; if(entry.mByteSize < incomingSize) { PX_ASSERT(false); goto DestroyNewMessage; } calculatedSize = PxMax(calculatedSize, entry.mMessageOffset + entry.mByteSize); if(calculatedSize > messageSize) { PX_ASSERT(false); goto DestroyNewMessage; } Option<PropertyDescription> propName(findProperty(cls->mClassId, entry.mPropertyName)); if(propName.hasValue() == false) { PX_ASSERT(false); goto DestroyNewMessage; } Option<ClassDescription> propCls(getClass(propName.getValue().mDatatype)); if(propCls.hasValue() == false) { PX_ASSERT(false); goto DestroyNewMessage; } PropertyMessageEntryImpl newEntry(PropertyMessageEntry( propName, dtypeCls->mName, dtypeCls->mClassId, entry.mMessageOffset, incomingSize, dtypeInfo.mByteSize)); newMessage->addEntry(newEntry); if(newEntry.mDatatypeId == getPvdTypeForType<String>()) newMessage->mStringOffsetArray.pushBack(entry.mMessageOffset); // property messages cannot be marshalled at this time. if(newEntry.mDatatypeId != getPvdTypeForType<String>() && newEntry.mDatatypeId != getPvdTypeForType<VoidPtr>()) { MarshalQueryResult marshalInfo = checkMarshalling(newEntry.mDatatypeId, newEntry.mProperty.mDatatype); if(marshalInfo.needsMarshalling) { PX_ASSERT(false); goto DestroyNewMessage; } } } if(newMessage) { newMessage->mStringOffsets = DataRef<uint32_t>(newMessage->mStringOffsetArray.begin(), newMessage->mStringOffsetArray.end()); mPropertyMessages.pushBack(newMessage); mPropertyMessageMap.insert(messageName, newMessage); return *newMessage; } DestroyNewMessage: if(newMessage) PVD_DELETE(newMessage); return None(); } virtual Option<PropertyMessageDescription> findPropertyMessage(const NamespacedName& msgName) const { PropertyMessageDescriptionImpl* desc(findPropertyMessageImpl(msgName)); if(desc) return *desc; return None(); } virtual Option<PropertyMessageDescription> getPropertyMessage(int32_t msgId) const { PropertyMessageDescriptionImpl* desc(getPropertyMessageImpl(msgId)); if(desc) return *desc; return None(); } virtual uint32_t getNbPropertyMessages() const { return mPropertyMessages.size(); } virtual uint32_t getPropertyMessages(PropertyMessageDescription* msgBuf, uint32_t bufLen, uint32_t startIdx = 0) const { startIdx = PxMin(startIdx, getNbPropertyMessages()); bufLen = PxMin(bufLen, getNbPropertyMessages() - startIdx); PVD_FOREACH(idx, bufLen) msgBuf[idx] = *mPropertyMessages[idx + startIdx]; return bufLen; } struct MetaDataWriter { const PvdObjectModelMetaDataImpl& mMetaData; PvdOutputStream& mStream; MetaDataWriter(const PvdObjectModelMetaDataImpl& meta, PvdOutputStream& stream) : mMetaData(meta), mStream(stream) { } void streamify(NamespacedName& type) { mStream << mMetaData.mStringTable->strToHandle(type.mNamespace); mStream << mMetaData.mStringTable->strToHandle(type.mName); } void streamify(String& type) { mStream << mMetaData.mStringTable->strToHandle(type); } void streamify(int32_t& type) { mStream << type; } void streamify(uint32_t& type) { mStream << type; } void streamify(uint8_t type) { mStream << type; } void streamify(bool type) { streamify( uint8_t(type)); } void streamify(PropertyType::Enum type) { uint32_t val = static_cast<uint32_t>(type); mStream << val; } void streamify(NamedValue& type) { streamify(type.mValue); streamify(type.mName); } void streamifyLinks(PropDescImpl* prop) { streamify(prop->mPropertyId); } void streamify(PropertyDescription& prop) { streamify(prop.mPropertyId); } void streamify(PropertyMessageEntryImpl& prop) { prop.serialize(*this); } void streamify(PtrOffset& off) { uint32_t type = off.mOffsetType; mStream << type; mStream << off.mOffset; } template <typename TDataType> void streamify(TDataType* type) { int32_t existMarker = type ? 1 : 0; mStream << existMarker; if(type) type->serialize(*this); } template <typename TArrayType> void streamify(const PxArray<TArrayType>& type) { mStream << static_cast<uint32_t>(type.size()); PVD_FOREACH(idx, type.size()) streamify(const_cast<TArrayType&>(type[idx])); } template <typename TArrayType> void streamifyLinks(const PxArray<TArrayType>& type) { mStream << static_cast<uint32_t>(type.size()); PVD_FOREACH(idx, type.size()) streamifyLinks(const_cast<TArrayType&>(type[idx])); } private: MetaDataWriter& operator=(const MetaDataWriter&); }; template <typename TStreamType> struct MetaDataReader { PvdObjectModelMetaDataImpl& mMetaData; TStreamType& mStream; MetaDataReader(PvdObjectModelMetaDataImpl& meta, TStreamType& stream) : mMetaData(meta), mStream(stream) { } void streamify(NamespacedName& type) { streamify(type.mNamespace); streamify(type.mName); } void streamify(String& type) { uint32_t handle; mStream >> handle; type = mMetaData.mStringTable->handleToStr(handle); } void streamify(int32_t& type) { mStream >> type; } void streamify(uint32_t& type) { mStream >> type; } void streamify(bool& type) { uint8_t data; mStream >> data; type = data ? true : false; } void streamify(PropertyType::Enum& type) { uint32_t val; mStream >> val; type = static_cast<PropertyType::Enum>(val); } void streamify(NamedValue& type) { streamify(type.mValue); streamify(type.mName); } void streamify(PropertyMessageEntryImpl& type) { type.serialize(*this); } void streamify(PtrOffset& off) { uint32_t type; mStream >> type; mStream >> off.mOffset; off.mOffsetType = static_cast<PtrOffsetType::Enum>(type); } void streamifyLinks(PropDescImpl*& prop) { int32_t propId; streamify(propId); prop = mMetaData.getPropertyImpl(propId); } void streamify(PropertyDescription& prop) { streamify(prop.mPropertyId); prop = mMetaData.getProperty(prop.mPropertyId); } template <typename TDataType> void streamify(TDataType*& type) { uint32_t existMarker; mStream >> existMarker; if(existMarker) { TDataType* newType = PVD_NEW(TDataType)(); newType->serialize(*this); type = newType; } else type = NULL; } template <typename TArrayType> void streamify(PxArray<TArrayType>& type) { uint32_t typeSize; mStream >> typeSize; type.resize(typeSize); PVD_FOREACH(idx, type.size()) streamify(type[idx]); } template <typename TArrayType> void streamifyLinks(PxArray<TArrayType>& type) { uint32_t typeSize; mStream >> typeSize; type.resize(typeSize); PVD_FOREACH(idx, type.size()) streamifyLinks(type[idx]); } private: MetaDataReader& operator=(const MetaDataReader&); }; virtual void write(PvdOutputStream& stream) const { stream << getCurrentPvdObjectModelVersion(); stream << mNextClassId; mStringTable->write(stream); MetaDataWriter writer(*this, stream); writer.streamify(mProperties); writer.streamify(mClasses); writer.streamify(mPropertyMessages); } template <typename TReaderType> void read(TReaderType& stream) { uint32_t version; stream >> version; stream >> mNextClassId; mStringTable->read(stream); MetaDataReader<TReaderType> reader(*this, stream); reader.streamify(mProperties); reader.streamify(mClasses); reader.streamify(mPropertyMessages); mNameToClasses.clear(); mNameToProperties.clear(); mPropertyMessageMap.clear(); PVD_FOREACH(i, mClasses.size()) { ClassDescImpl* cls(mClasses[i]); if(cls == NULL) continue; mNameToClasses.insert(cls->mName, mClasses[i]); uint32_t propCount = getNbProperties(cls->mClassId); PropertyDescription descs[16]; uint32_t offset = 0; for(uint32_t idx = 0; idx < propCount; idx = offset) { uint32_t numProps = getProperties(cls->mClassId, descs, 16, offset); offset += numProps; for(uint32_t propIdx = 0; propIdx < numProps; ++propIdx) { PropDescImpl* prop = getPropertyImpl(descs[propIdx].mPropertyId); if(prop) mNameToProperties.insert(ClassPropertyName(cls->mName, prop->mName), prop); } } } PVD_FOREACH(idx, mPropertyMessages.size()) mPropertyMessageMap.insert(mPropertyMessages[idx]->mMessageName, mPropertyMessages[idx]); } virtual StringTable& getStringTable() const { return *mStringTable; } virtual void addRef() { ++mRefCount; } virtual void release() { if(mRefCount) --mRefCount; if(!mRefCount) PVD_DELETE(this); } }; } uint32_t PvdObjectModelMetaData::getCurrentPvdObjectModelVersion() { return 1; } PvdObjectModelMetaData& PvdObjectModelMetaData::create() { PvdObjectModelMetaDataImpl& retval(*PVD_NEW(PvdObjectModelMetaDataImpl)()); retval.initialize(); return retval; } PvdObjectModelMetaData& PvdObjectModelMetaData::create(PvdInputStream& stream) { PvdObjectModelMetaDataImpl& retval(*PVD_NEW(PvdObjectModelMetaDataImpl)()); retval.read(stream); return retval; } StringTable& StringTable::create() { return *PVD_NEW(StringTableImpl)(); }
48,987
C++
31.61518
120
0.697001
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxProfileContextProviderImpl.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. #ifndef PX_PROFILE_CONTEXT_PROVIDER_IMPL_H #define PX_PROFILE_CONTEXT_PROVIDER_IMPL_H #include "PxProfileContextProvider.h" #include "foundation/PxThread.h" namespace physx { namespace profile { struct PxDefaultContextProvider { PxProfileEventExecutionContext getExecutionContext() { PxThread::Id theId( PxThread::getId() ); return PxProfileEventExecutionContext( static_cast<uint32_t>( theId ), static_cast<uint8_t>( PxThreadPriority::eNORMAL ), 0 ); } uint32_t getThreadId() { return static_cast<uint32_t>( PxThread::getId() ); } }; } } #endif
2,146
C
39.509433
129
0.756757
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxProfileEventImpl.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. #include "PxProfileEventBuffer.h" #include "PxProfileZoneImpl.h" #include "PxProfileZoneManagerImpl.h" #include "PxProfileMemoryEventBuffer.h" #include "foundation/PxUserAllocated.h" namespace physx { namespace profile { struct PxProfileNameProviderForward { PxProfileNames mNames; PxProfileNameProviderForward( PxProfileNames inNames ) : mNames( inNames ) { } PxProfileNames getProfileNames() const { return mNames; } }; PxProfileZone& PxProfileZone::createProfileZone( PxAllocatorCallback* inAllocator, const char* inSDKName, PxProfileNames inNames, uint32_t inEventBufferByteSize ) { typedef ZoneImpl<PxProfileNameProviderForward> TSDKType; return *PX_PROFILE_NEW( inAllocator, TSDKType ) ( inAllocator, inSDKName, inEventBufferByteSize, PxProfileNameProviderForward( inNames ) ); } PxProfileZoneManager& PxProfileZoneManager::createProfileZoneManager(PxAllocatorCallback* inAllocator ) { return *PX_PROFILE_NEW( inAllocator, ZoneManagerImpl ) ( inAllocator ); } PxProfileMemoryEventBuffer& PxProfileMemoryEventBuffer::createMemoryEventBuffer( PxAllocatorCallback& inAllocator, uint32_t inBufferSize ) { return *PX_PROFILE_NEW( &inAllocator, PxProfileMemoryEventBufferImpl )( inAllocator, inBufferSize ); } } }
2,818
C++
43.746031
163
0.78247
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxProfileEventNames.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. #ifndef PX_PROFILE_EVENT_NAMES_H #define PX_PROFILE_EVENT_NAMES_H #include "PxProfileEventId.h" namespace physx { namespace profile { /** \brief Mapping from event id to name. */ struct PxProfileEventName { const char* name; PxProfileEventId eventId; /** \brief Default constructor. \param inName Profile event name. \param inId Profile event id. */ PxProfileEventName( const char* inName, PxProfileEventId inId ) : name( inName ), eventId( inId ) {} }; /** \brief Aggregator of event id -> name mappings */ struct PxProfileNames { /** \brief Default constructor that doesn't point to any names. \param inEventCount Number of provided events. \param inSubsystems Event names array. */ PxProfileNames( uint32_t inEventCount = 0, const PxProfileEventName* inSubsystems = NULL ) : eventCount( inEventCount ) , events( inSubsystems ) { } uint32_t eventCount; const PxProfileEventName* events; }; /** \brief Provides a mapping from event ID -> name. */ class PxProfileNameProvider { public: /** \brief Returns profile event names. \return Profile event names. */ virtual PxProfileNames getProfileNames() const = 0; protected: virtual ~PxProfileNameProvider(){} PxProfileNameProvider& operator=(const PxProfileNameProvider&) { return *this; } }; } } #endif
2,914
C
31.388889
102
0.736788
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdUserRenderTypes.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. #define THERE_IS_NO_INCLUDE_GUARD_HERE_FOR_A_REASON #ifndef DECLARE_PVD_IMMEDIATE_RENDER_TYPE_NO_COMMA #define DECLARE_PVD_IMMEDIATE_RENDER_TYPE_NO_COMMA DECLARE_PVD_IMMEDIATE_RENDER_TYPE #endif DECLARE_PVD_IMMEDIATE_RENDER_TYPE(SetInstanceId) DECLARE_PVD_IMMEDIATE_RENDER_TYPE(Points) DECLARE_PVD_IMMEDIATE_RENDER_TYPE(Lines) DECLARE_PVD_IMMEDIATE_RENDER_TYPE(Triangles) DECLARE_PVD_IMMEDIATE_RENDER_TYPE(JointFrames) DECLARE_PVD_IMMEDIATE_RENDER_TYPE(LinearLimit) DECLARE_PVD_IMMEDIATE_RENDER_TYPE(AngularLimit) DECLARE_PVD_IMMEDIATE_RENDER_TYPE(LimitCone) DECLARE_PVD_IMMEDIATE_RENDER_TYPE(DoubleCone) DECLARE_PVD_IMMEDIATE_RENDER_TYPE(Text) DECLARE_PVD_IMMEDIATE_RENDER_TYPE_NO_COMMA(Debug) #undef DECLARE_PVD_IMMEDIATE_RENDER_TYPE_NO_COMMA #undef THERE_IS_NO_INCLUDE_GUARD_HERE_FOR_A_REASON
2,361
C
50.347825
84
0.789072
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxProfileDataParsing.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_PROFILE_DATA_PARSING_H #define PX_PROFILE_DATA_PARSING_H #include "foundation/Px.h" namespace physx { namespace profile { //Converts datatypes without using type punning. struct BlockParserDataConverter { union { uint8_t mU8[8]; uint16_t mU16[4]; uint32_t mU32[2]; uint64_t mU64[1]; int8_t mI8[8]; int16_t mI16[4]; int32_t mI32[2]; int64_t mI64[1]; float mF32[2]; double mF64[1]; }; template<typename TDataType> inline TDataType convert() { PX_ASSERT( false ); return TDataType(); } template<typename TDataType> inline void convert( const TDataType& ) {} }; template<> inline uint8_t BlockParserDataConverter::convert<uint8_t>() { return mU8[0]; } template<> inline uint16_t BlockParserDataConverter::convert<uint16_t>() { return mU16[0]; } template<> inline uint32_t BlockParserDataConverter::convert<uint32_t>() { return mU32[0]; } template<> inline uint64_t BlockParserDataConverter::convert<uint64_t>() { return mU64[0]; } template<> inline int8_t BlockParserDataConverter::convert<int8_t>() { return mI8[0]; } template<> inline int16_t BlockParserDataConverter::convert<int16_t>() { return mI16[0]; } template<> inline int32_t BlockParserDataConverter::convert<int32_t>() { return mI32[0]; } template<> inline int64_t BlockParserDataConverter::convert<int64_t>() { return mI64[0]; } template<> inline float BlockParserDataConverter::convert<float>() { return mF32[0]; } template<> inline double BlockParserDataConverter::convert<double>() { return mF64[0]; } template<> inline void BlockParserDataConverter::convert<uint8_t>( const uint8_t& inData ) { mU8[0] = inData; } template<> inline void BlockParserDataConverter::convert<uint16_t>( const uint16_t& inData ) { mU16[0] = inData; } template<> inline void BlockParserDataConverter::convert<uint32_t>( const uint32_t& inData ) { mU32[0] = inData; } template<> inline void BlockParserDataConverter::convert<uint64_t>( const uint64_t& inData ) { mU64[0] = inData; } template<> inline void BlockParserDataConverter::convert<int8_t>( const int8_t& inData ) { mI8[0] = inData; } template<> inline void BlockParserDataConverter::convert<int16_t>( const int16_t& inData ) { mI16[0] = inData; } template<> inline void BlockParserDataConverter::convert<int32_t>( const int32_t& inData ) { mI32[0] = inData; } template<> inline void BlockParserDataConverter::convert<int64_t>( const int64_t& inData ) { mI64[0] = inData; } template<> inline void BlockParserDataConverter::convert<float>( const float& inData ) { mF32[0] = inData; } template<> inline void BlockParserDataConverter::convert<double>( const double& inData ) { mF64[0] = inData; } //Handles various details around parsing blocks of uint8_t data. struct BlockParseFunctions { template<uint8_t ByteCount> static inline void swapBytes( uint8_t* inData ) { for ( uint32_t idx = 0; idx < ByteCount/2; ++idx ) { uint32_t endIdx = ByteCount-idx-1; uint8_t theTemp = inData[idx]; inData[idx] = inData[endIdx]; inData[endIdx] = theTemp; } } static inline bool checkLength( const uint8_t* inStart, const uint8_t* inStop, uint32_t inLength ) { return static_cast<uint32_t>(inStop - inStart) >= inLength; } //warning work-around template<typename T> static inline T val(T v) {return v;} template<bool DoSwapBytes, typename TDataType> static inline bool parse( const uint8_t*& inStart, const uint8_t* inStop, TDataType& outData ) { if ( checkLength( inStart, inStop, sizeof( TDataType ) ) ) { BlockParserDataConverter theConverter; for ( uint32_t idx =0; idx < sizeof( TDataType ); ++idx ) theConverter.mU8[idx] = inStart[idx]; if ( val(DoSwapBytes)) swapBytes<sizeof(TDataType)>( theConverter.mU8 ); outData = theConverter.convert<TDataType>(); inStart += sizeof( TDataType ); return true; } return false; } template<bool DoSwapBytes, typename TDataType> static inline bool parseBlock( const uint8_t*& inStart, const uint8_t* inStop, TDataType* outData, uint32_t inNumItems ) { uint32_t desired = sizeof(TDataType)*inNumItems; if ( checkLength( inStart, inStop, desired ) ) { if ( val(DoSwapBytes) ) { for ( uint32_t item = 0; item < inNumItems; ++item ) { BlockParserDataConverter theConverter; for ( uint32_t idx =0; idx < sizeof( TDataType ); ++idx ) theConverter.mU8[idx] = inStart[idx]; swapBytes<sizeof(TDataType)>( theConverter.mU8 ); outData[item] = theConverter.convert<TDataType>(); inStart += sizeof(TDataType); } } else { uint8_t* target = reinterpret_cast<uint8_t*>(outData); memmove( target, inStart, desired ); inStart += desired; } return true; } return false; } //In-place byte swapping block template<bool DoSwapBytes, typename TDataType> static inline bool parseBlock( uint8_t*& inStart, const uint8_t* inStop, uint32_t inNumItems ) { uint32_t desired = sizeof(TDataType)*inNumItems; if ( checkLength( inStart, inStop, desired ) ) { if ( val(DoSwapBytes) ) { for ( uint32_t item = 0; item < inNumItems; ++item, inStart += sizeof( TDataType ) ) swapBytes<sizeof(TDataType)>( inStart ); //In-place swap. } else inStart += sizeof( TDataType ) * inNumItems; return true; } return false; } }; //Wraps the begin/end keeping track of them. template<bool DoSwapBytes> struct BlockParser { const uint8_t* mBegin; const uint8_t* mEnd; BlockParser( const uint8_t* inBegin=NULL, const uint8_t* inEnd=NULL ) : mBegin( inBegin ) , mEnd( inEnd ) { } inline bool hasMoreData() const { return mBegin != mEnd; } inline bool checkLength( uint32_t inLength ) { return BlockParseFunctions::checkLength( mBegin, mEnd, inLength ); } template<typename TDataType> inline bool read( TDataType& outDatatype ) { return BlockParseFunctions::parse<DoSwapBytes>( mBegin, mEnd, outDatatype ); } template<typename TDataType> inline bool readBlock( TDataType* outDataPtr, uint32_t inNumItems ) { return BlockParseFunctions::parseBlock<DoSwapBytes>( mBegin, mEnd, outDataPtr, inNumItems ); } template<typename TDataType> inline bool readBlock( uint32_t inNumItems ) { uint8_t* theTempPtr = const_cast<uint8_t*>(mBegin); bool retval = BlockParseFunctions::parseBlock<DoSwapBytes, TDataType>( theTempPtr, mEnd, inNumItems ); mBegin = theTempPtr; return retval; } uint32_t amountLeft() const { return static_cast<uint32_t>( mEnd - mBegin ); } }; //Reads the data without checking for error conditions template<typename TDataType, typename TBlockParserType> inline TDataType blockParserRead( TBlockParserType& inType ) { TDataType retval; inType.read( retval ); return retval; } }} #endif
8,528
C
38.123853
166
0.707903
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxProfileEventBuffer.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_PROFILE_EVENT_BUFFER_H #define PX_PROFILE_EVENT_BUFFER_H #include "PxProfileEvents.h" #include "PxProfileEventSerialization.h" #include "PxProfileDataBuffer.h" #include "PxProfileContextProvider.h" #include "foundation/PxTime.h" namespace physx { namespace profile { /** * An event buffer maintains an in-memory buffer of events. When this buffer is full * it sends to buffer to all handlers registered and resets the buffer. * * It is parameterized in four ways. The first is a context provider that provides * both thread id and context id. * * The second is the mutex (which may be null) and a scoped locking mechanism. Thus the buffer * may be used in a multithreaded context but clients of the buffer don't pay for this if they * don't intend to use it this way. * * Finally the buffer may use an event filtering mechanism. This mechanism needs one function, * namely isEventEnabled( uint8_t subsystem, uint8_t eventId ). * * All of these systems can be parameterized at compile time leading to an event buffer * that should be as fast as possible given the constraints. * * Buffers may be chained together as this buffer has a handleBufferFlush method that * will grab the mutex and add the data to this event buffer. * * Overall, lets look at the PhysX SDK an how all the pieces fit together. * The SDK should have a mutex-protected event buffer where actual devs or users of PhysX * can register handlers. This buffer has slow but correct implementations of the * context provider interface. * * The SDK object should also have a concrete event filter which was used in the * construction of the event buffer and which it exposes through opaque interfaces. * * The SDK should protect its event buffer and its event filter from multithreaded * access and thus this provides the safest and slowest way to log events and to * enable/disable events. * * Each scene should also have a concrete event filter. This filter is updated from * the SDK event filter (in a mutex protected way) every frame. Thus scenes can change * their event filtering on a frame-by-frame basis. It means that tasks running * under the scene don't need a mutex when accessing the filter. * * Furthermore the scene should have an event buffer that always sets the context id * on each event to the scene. This allows PVD and other systems to correlate events * to scenes. Scenes should provide access only to a relative event sending system * that looks up thread id upon each event but uses the scene id. * * The SDK's event buffer should be setup as an EventBufferClient for each scene's * event buffer. Thus the SDK should expose an EventBufferClient interface that * any client can use. * * For extremely *extremely* performance sensitive areas we should create a specialized * per-scene, per-thread event buffer that is set on the task for these occasions. This buffer * uses a trivial event context setup with the scene's context id and the thread id. It should * share the scene's concrete event filter and it should have absolutely no locking. It should * empty into the scene's event buffer which in some cases should empty into the SDK's event buffer * which when full will push events all the way out of the system. The task should *always* flush * the event buffer (if it has one) when it is finished; nothing else will work reliably. * * If the per-scene,per-thread event buffer is correctly parameterized and fully defined adding * a new event should be an inline operation requiring no mutex grabs in the common case. I don't * believe you can get faster event production than this; the events are as small as possible (all * relative events) and they are all produced inline resulting in one 4 byte header and one * 8 byte timestamp per event. Reducing the memory pressure in this way reduces the communication * overhead, the mutex grabs, basically everything that makes profiling expensive at the cost * of a per-scene,per-thread event buffer (which could easily be reduced to a per-thread event * buffer. */ template<typename TContextProvider, typename TMutex, typename TScopedLock, typename TEventFilter> class EventBuffer : public DataBuffer<TMutex, TScopedLock> { public: typedef DataBuffer<TMutex, TScopedLock> TBaseType; typedef TContextProvider TContextProviderType; typedef TEventFilter TEventFilterType; typedef typename TBaseType::TMutexType TMutexType; typedef typename TBaseType::TScopedLockType TScopedLockType; typedef typename TBaseType::TU8AllocatorType TU8AllocatorType; typedef typename TBaseType::TMemoryBufferType TMemoryBufferType; typedef typename TBaseType::TBufferClientArray TBufferClientArray; private: EventContextInformation mEventContextInformation; uint64_t mLastTimestamp; TContextProvider mContextProvider; TEventFilterType mEventFilter; public: EventBuffer(PxAllocatorCallback* inFoundation , uint32_t inBufferFullAmount , const TContextProvider& inProvider , TMutexType* inBufferMutex , const TEventFilterType& inEventFilter ) : TBaseType( inFoundation, inBufferFullAmount, inBufferMutex, "struct physx::profile::ProfileEvent" ) , mLastTimestamp( 0 ) , mContextProvider( inProvider ) , mEventFilter( inEventFilter ) { memset(&mEventContextInformation,0,sizeof(EventContextInformation)); } TContextProvider& getContextProvider() { return mContextProvider; } PX_FORCE_INLINE void startEvent(uint16_t inId, uint32_t threadId, uint64_t contextId, uint8_t cpuId, uint8_t threadPriority, uint64_t inTimestamp) { TScopedLockType lock(TBaseType::mBufferMutex); if ( mEventFilter.isEventEnabled( inId ) ) { StartEvent theEvent; theEvent.init( threadId, contextId, cpuId, threadPriority, inTimestamp ); doAddProfileEvent( inId, theEvent ); } } PX_FORCE_INLINE void startEvent(uint16_t inId, uint64_t contextId) { PxProfileEventExecutionContext ctx( mContextProvider.getExecutionContext() ); startEvent( inId, ctx.mThreadId, contextId, ctx.mCpuId, static_cast<uint8_t>(ctx.mThreadPriority), PxTime::getCurrentCounterValue() ); } PX_FORCE_INLINE void startEvent(uint16_t inId, uint64_t contextId, uint32_t threadId) { startEvent( inId, threadId, contextId, 0, 0, PxTime::getCurrentCounterValue() ); } PX_FORCE_INLINE void stopEvent(uint16_t inId, uint32_t threadId, uint64_t contextId, uint8_t cpuId, uint8_t threadPriority, uint64_t inTimestamp) { TScopedLockType lock(TBaseType::mBufferMutex); if ( mEventFilter.isEventEnabled( inId ) ) { StopEvent theEvent; theEvent.init( threadId, contextId, cpuId, threadPriority, inTimestamp ); doAddProfileEvent( inId, theEvent ); } } PX_FORCE_INLINE void stopEvent(uint16_t inId, uint64_t contextId) { PxProfileEventExecutionContext ctx( mContextProvider.getExecutionContext() ); stopEvent( inId, ctx.mThreadId, contextId, ctx.mCpuId, static_cast<uint8_t>(ctx.mThreadPriority), PxTime::getCurrentCounterValue() ); } PX_FORCE_INLINE void stopEvent(uint16_t inId, uint64_t contextId, uint32_t threadId) { stopEvent( inId, threadId, contextId, 0, 0, PxTime::getCurrentCounterValue() ); } inline void eventValue( uint16_t inId, uint64_t contextId, int64_t inValue ) { eventValue( inId, mContextProvider.getThreadId(), contextId, inValue ); } inline void eventValue( uint16_t inId, uint32_t threadId, uint64_t contextId, int64_t inValue ) { TScopedLockType lock( TBaseType::mBufferMutex ); EventValue theEvent; theEvent.init( inValue, contextId, threadId ); EventHeader theHeader( static_cast<uint8_t>( getEventType<EventValue>() ), inId ); //set the header relative timestamp; EventValue& theType( theEvent ); theType.setupHeader( theHeader ); sendEvent( theHeader, theType ); } void flushProfileEvents() { TBaseType::flushEvents(); } void release() { PX_PROFILE_DELETE( TBaseType::mWrapper.mUserFoundation, this ); } protected: //Clears the cache meaning event compression //starts over again. //only called when the buffer mutex is held void clearCachedData() { mEventContextInformation.setToDefault(); mLastTimestamp = 0; } template<typename TProfileEventType> PX_FORCE_INLINE void doAddProfileEvent(uint16_t eventId, const TProfileEventType& inType) { TScopedLockType lock(TBaseType::mBufferMutex); if (mEventContextInformation == inType.mContextInformation) doAddEvent(static_cast<uint8_t>(inType.getRelativeEventType()), eventId, inType.getRelativeEvent()); else { mEventContextInformation = inType.mContextInformation; doAddEvent( static_cast<uint8_t>( getEventType<TProfileEventType>() ), eventId, inType ); } } template<typename TDataType> PX_FORCE_INLINE void doAddEvent(uint8_t inEventType, uint16_t eventId, const TDataType& inType) { EventHeader theHeader( inEventType, eventId ); //set the header relative timestamp; TDataType& theType( const_cast<TDataType&>( inType ) ); uint64_t currentTs = inType.getTimestamp(); theType.setupHeader(theHeader, mLastTimestamp); mLastTimestamp = currentTs; sendEvent( theHeader, theType ); } template<typename TDataType> PX_FORCE_INLINE void sendEvent( EventHeader& inHeader, TDataType& inType ) { uint32_t sizeToWrite = sizeof(inHeader) + inType.getEventSize(inHeader); PX_UNUSED(sizeToWrite); uint32_t writtenSize = inHeader.streamify( TBaseType::mSerializer ); writtenSize += inType.streamify(TBaseType::mSerializer, inHeader); PX_ASSERT(writtenSize == sizeToWrite); if ( TBaseType::mDataArray.size() >= TBaseType::mBufferFullAmount ) flushProfileEvents(); } }; }} #endif
11,552
C
42.269663
148
0.750779
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxProfileScopedEvent.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. #ifndef PX_PROFILE_SCOPED_EVENT_H #define PX_PROFILE_SCOPED_EVENT_H #include "PxProfileEventId.h" #include "PxProfileCompileTimeEventFilter.h" namespace physx { namespace profile { /** \brief Template version of startEvent, called directly on provided profile buffer. \param inBuffer Profile event buffer. \param inId Profile event id. \param inContext Profile event context. */ template<bool TEnabled, typename TBufferType> inline void startEvent( TBufferType* inBuffer, const PxProfileEventId& inId, uint64_t inContext ) { if ( TEnabled && inBuffer ) inBuffer->startEvent( inId, inContext ); } /** \brief Template version of stopEvent, called directly on provided profile buffer. \param inBuffer Profile event buffer. \param inId Profile event id. \param inContext Profile event context. */ template<bool TEnabled, typename TBufferType> inline void stopEvent( TBufferType* inBuffer, const PxProfileEventId& inId, uint64_t inContext ) { if ( TEnabled && inBuffer ) inBuffer->stopEvent( inId, inContext ); } /** \brief Template version of startEvent, called directly on provided profile buffer. \param inEnabled If profile event is enabled. \param inBuffer Profile event buffer. \param inId Profile event id. \param inContext Profile event context. */ template<typename TBufferType> inline void startEvent( bool inEnabled, TBufferType* inBuffer, const PxProfileEventId& inId, uint64_t inContext ) { if ( inEnabled && inBuffer ) inBuffer->startEvent( inId, inContext ); } /** \brief Template version of stopEvent, called directly on provided profile buffer. \param inEnabled If profile event is enabled. \param inBuffer Profile event buffer. \param inId Profile event id. \param inContext Profile event context. */ template<typename TBufferType> inline void stopEvent( bool inEnabled, TBufferType* inBuffer, const PxProfileEventId& inId, uint64_t inContext ) { if ( inEnabled && inBuffer ) inBuffer->stopEvent( inId, inContext ); } /** \brief Template version of eventValue, called directly on provided profile buffer. \param inEnabled If profile event is enabled. \param inBuffer Profile event buffer. \param inId Profile event id. \param inContext Profile event context. \param inValue Event value. */ template<typename TBufferType> inline void eventValue( bool inEnabled, TBufferType* inBuffer, const PxProfileEventId& inId, uint64_t inContext, int64_t inValue ) { if ( inEnabled && inBuffer ) inBuffer->eventValue( inId, inContext, inValue ); } }} #endif
4,102
C
36.99074
131
0.762311
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdImpl.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_PVD_IMPL_H #define PX_PVD_IMPL_H #include "foundation/PxProfiler.h" #include "foundation/PxAllocator.h" #include "PsPvd.h" #include "foundation/PxArray.h" #include "foundation/PxMutex.h" #include "PxPvdCommStreamTypes.h" #include "PxPvdFoundation.h" #include "PxPvdObjectModelMetaData.h" #include "PxPvdObjectRegistrar.h" namespace physx { namespace profile { class PxProfileZoneManager; } namespace pvdsdk { class PvdMemClient; class PvdProfileZoneClient; struct MetaDataProvider : public PvdOMMetaDataProvider, public PxUserAllocated { typedef PxMutex::ScopedLock TScopedLockType; typedef PxHashMap<const void*, int32_t> TInstTypeMap; PvdObjectModelMetaData& mMetaData; PxMutex mMutex; uint32_t mRefCount; TInstTypeMap mTypeMap; MetaDataProvider() : mMetaData(PvdObjectModelMetaData::create()), mRefCount(0), mTypeMap("MetaDataProvider::mTypeMap") { mMetaData.addRef(); } virtual ~MetaDataProvider() { mMetaData.release(); } virtual void addRef() { TScopedLockType locker(mMutex); ++mRefCount; } virtual void release() { { TScopedLockType locker(mMutex); if(mRefCount) --mRefCount; } if(!mRefCount) PVD_DELETE(this); } virtual PvdObjectModelMetaData& lock() { mMutex.lock(); return mMetaData; } virtual void unlock() { mMutex.unlock(); } virtual bool createInstance(const NamespacedName& clsName, const void* instance) { TScopedLockType locker(mMutex); Option<ClassDescription> cls(mMetaData.findClass(clsName)); if(cls.hasValue() == false) return false; int32_t instType = cls->mClassId; mTypeMap.insert(instance, instType); return true; } virtual bool isInstanceValid(const void* instance) { TScopedLockType locker(mMutex); ClassDescription classDesc; bool retval = mTypeMap.find(instance) != NULL; #if PX_DEBUG if(retval) classDesc = mMetaData.getClass(mTypeMap.find(instance)->second); #endif return retval; } virtual void destroyInstance(const void* instance) { { TScopedLockType locker(mMutex); mTypeMap.erase(instance); } } virtual int32_t getInstanceClassType(const void* instance) { TScopedLockType locker(mMutex); const TInstTypeMap::Entry* entry = mTypeMap.find(instance); if(entry) return entry->second; return -1; } private: MetaDataProvider& operator=(const MetaDataProvider&); MetaDataProvider(const MetaDataProvider&); }; ////////////////////////////////////////////////////////////////////////// /*! PvdImpl is the realization of PxPvd. It implements the interface methods and provides richer functionality for advanced users or internal clients (such as PhysX or APEX), including handler notification for clients. */ ////////////////////////////////////////////////////////////////////////// class PvdImpl : public PsPvd, public PxUserAllocated { PX_NOCOPY(PvdImpl) typedef PxMutex::ScopedLock TScopedLockType; typedef void (PvdImpl::*TAllocationHandler)(size_t size, const char* typeName, const char* filename, int line, void* allocatedMemory); typedef void (PvdImpl::*TDeallocationHandler)(void* allocatedMemory); public: PvdImpl(); virtual ~PvdImpl(); void release(); bool connect(PxPvdTransport& transport, PxPvdInstrumentationFlags flags); void disconnect(); bool isConnected(bool useCachedStatus = true); void flush(); PxPvdTransport* getTransport(); PxPvdInstrumentationFlags getInstrumentationFlags(); void addClient(PvdClient* client); void removeClient(PvdClient* client); PvdOMMetaDataProvider& getMetaDataProvider(); bool registerObject(const void* inItem); bool unRegisterObject(const void* inItem); //AllocationListener void onAllocation(size_t size, const char* typeName, const char* filename, int line, void* allocatedMemory); void onDeallocation(void* addr); uint64_t getNextStreamId(); static bool initialize(); static PvdImpl* getInstance(); // Profiling virtual void* zoneStart(const char* eventName, bool detached, uint64_t contextId); virtual void zoneEnd(void* profilerData, const char *eventName, bool detached, uint64_t contextId); private: void sendTransportInitialization(); PxPvdTransport* mPvdTransport; physx::PxArray<PvdClient*> mPvdClients; MetaDataProvider* mSharedMetaProvider; // shared between clients ObjectRegistrar mObjectRegistrar; PvdMemClient* mMemClient; PxPvdInstrumentationFlags mFlags; bool mIsConnected; bool mGPUProfilingWasConnected; bool mIsNVTXSupportEnabled; uint32_t mNVTXContext; uint64_t mNextStreamId; physx::profile::PxProfileZoneManager*mProfileZoneManager; PvdProfileZoneClient* mProfileClient; physx::profile::PxProfileZone* mProfileZone; static PvdImpl* sInstance; static uint32_t sRefCount; }; } // namespace pvdsdk } #endif
6,567
C
28.452915
117
0.730775
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxProfileEventSender.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. #ifndef PX_PROFILE_EVENT_SENDER_H #define PX_PROFILE_EVENT_SENDER_H #include "foundation/Px.h" namespace physx { namespace profile { /** \brief Tagging interface to indicate an object that is capable of flushing a profile event stream at a certain point. */ class PxProfileEventFlusher { protected: virtual ~PxProfileEventFlusher(){} public: /** \brief Flush profile events. Sends the profile event buffer to hooked clients. */ virtual void flushProfileEvents() = 0; }; /** \brief Sends the full events where the caller must provide the context and thread id. */ class PxProfileEventSender { protected: virtual ~PxProfileEventSender(){} public: /** \brief Use this as a thread id for events that start on one thread and end on another */ static const uint32_t CrossThreadId = 99999789; /** \brief Send a start profile event, optionally with a context. Events are sorted by thread and context in the client side. \param inId Profile event id. \param contextId Context id. */ virtual void startEvent( uint16_t inId, uint64_t contextId) = 0; /** \brief Send a stop profile event, optionally with a context. Events are sorted by thread and context in the client side. \param inId Profile event id. \param contextId Context id. */ virtual void stopEvent( uint16_t inId, uint64_t contextId) = 0; /** \brief Send a start profile event, optionally with a context. Events are sorted by thread and context in the client side. \param inId Profile event id. \param contextId Context id. \param threadId Thread id. */ virtual void startEvent( uint16_t inId, uint64_t contextId, uint32_t threadId) = 0; /** \brief Send a stop profile event, optionally with a context. Events are sorted by thread and context in the client side. \param inId Profile event id. \param contextId Context id. \param threadId Thread id. */ virtual void stopEvent( uint16_t inId, uint64_t contextId, uint32_t threadId ) = 0; virtual void atEvent(uint16_t inId, uint64_t contextId, uint32_t threadId, uint64_t start, uint64_t stop) = 0; /** \brief Set an specific events value. This is different than the profiling value for the event; it is a value recorded and kept around without a timestamp associated with it. This value is displayed when the event itself is processed. \param inId Profile event id. \param contextId Context id. \param inValue Value to set for the event. */ virtual void eventValue( uint16_t inId, uint64_t contextId, int64_t inValue ) = 0; }; } } #endif
4,134
C
35.919643
112
0.740687
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxProfileMemory.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_PROFILE_MEMORY_H #define PX_PROFILE_MEMORY_H #include "PxProfileEventBufferClientManager.h" #include "PxProfileEventSender.h" #include "foundation/PxBroadcast.h" namespace physx { namespace profile { /** \brief Record events so a late-connecting client knows about all outstanding allocations */ class PxProfileMemoryEventRecorder : public PxAllocationListener { protected: virtual ~PxProfileMemoryEventRecorder(){} public: /** \brief Set the allocation listener \param inListener Allocation listener. */ virtual void setListener(PxAllocationListener* inListener) = 0; /** \brief Release the instance. */ virtual void release() = 0; }; /** \brief Stores memory events into the memory buffer. */ class PxProfileMemoryEventBuffer : public PxAllocationListener //add a new event to the buffer , public PxProfileEventBufferClientManager //add clients to handle the serialized memory events , public PxProfileEventFlusher //flush the buffer { protected: virtual ~PxProfileMemoryEventBuffer(){} public: /** \brief Release the instance. */ virtual void release() = 0; /** \brief Create a non-mutex-protected event buffer. \param inAllocator Allocation callback. \param inBufferSize Internal buffer size. */ static PxProfileMemoryEventBuffer& createMemoryEventBuffer(PxAllocatorCallback& inAllocator, uint32_t inBufferSize = 0x1000); }; } } // namespace physx #endif
3,151
C
33.637362
127
0.757537
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxProfileEventId.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. #ifndef PX_PROFILE_EVENT_ID_H #define PX_PROFILE_EVENT_ID_H #include "foundation/Px.h" namespace physx { namespace profile { /** \brief A event id structure. Optionally includes information about if the event was enabled at compile time. */ struct PxProfileEventId { uint16_t eventId; mutable bool compileTimeEnabled; /** \brief Profile event id constructor. \param inId Profile event id. \param inCompileTimeEnabled Compile time enabled. */ PxProfileEventId( uint16_t inId = 0, bool inCompileTimeEnabled = true ) : eventId( inId ) , compileTimeEnabled( inCompileTimeEnabled ) { } operator uint16_t () const { return eventId; } bool operator==( const PxProfileEventId& inOther ) const { return eventId == inOther.eventId; } }; } } #endif
2,357
C
35.276923
74
0.747985
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxProfileMemoryEventBuffer.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_PROFILE_MEMORY_EVENT_BUFFER_H #define PX_PROFILE_MEMORY_EVENT_BUFFER_H #include "PxProfileDataBuffer.h" #include "PxProfileMemoryEvents.h" #include "PxProfileMemory.h" #include "PxProfileScopedMutexLock.h" #include "PxProfileAllocatorWrapper.h" #include "PxProfileEventMutex.h" #include "foundation/PxHash.h" #include "foundation/PxHashMap.h" #include "foundation/PxUserAllocated.h" namespace physx { namespace profile { template<typename TMutex, typename TScopedLock> class MemoryEventBuffer : public DataBuffer<TMutex, TScopedLock> { public: typedef DataBuffer<TMutex, TScopedLock> TBaseType; typedef typename TBaseType::TMutexType TMutexType; typedef typename TBaseType::TScopedLockType TScopedLockType; typedef typename TBaseType::TU8AllocatorType TU8AllocatorType; typedef typename TBaseType::TMemoryBufferType TMemoryBufferType; typedef typename TBaseType::TBufferClientArray TBufferClientArray; typedef PxHashMap<const char*, uint32_t, PxHash<const char*>, TU8AllocatorType> TCharPtrToHandleMap; protected: TCharPtrToHandleMap mStringTable; public: MemoryEventBuffer( PxAllocatorCallback& cback , uint32_t inBufferFullAmount , TMutexType* inBufferMutex ) : TBaseType( &cback, inBufferFullAmount, inBufferMutex, "struct physx::profile::MemoryEvent" ) , mStringTable( TU8AllocatorType( TBaseType::getWrapper(), "MemoryEventStringBuffer" ) ) { } uint32_t getHandle( const char* inData ) { if ( inData == NULL ) inData = ""; const typename TCharPtrToHandleMap::Entry* result( mStringTable.find( inData ) ); if ( result ) return result->second; uint32_t hdl = mStringTable.size() + 1; mStringTable.insert( inData, hdl ); StringTableEvent theEvent; theEvent.init( inData, hdl ); sendEvent( theEvent ); return hdl; } void onAllocation( size_t inSize, const char* inType, const char* inFile, uint32_t inLine, uint64_t addr ) { if ( addr == 0 ) return; uint32_t typeHdl( getHandle( inType ) ); uint32_t fileHdl( getHandle( inFile ) ); AllocationEvent theEvent; theEvent.init( inSize, typeHdl, fileHdl, inLine, addr ); sendEvent( theEvent ); } void onDeallocation( uint64_t addr ) { if ( addr == 0 ) return; DeallocationEvent theEvent; theEvent.init( addr ); sendEvent( theEvent ); } void flushProfileEvents() { TBaseType::flushEvents(); } protected: template<typename TDataType> void sendEvent( TDataType inType ) { MemoryEventHeader theHeader( getMemoryEventType<TDataType>() ); inType.setup( theHeader ); theHeader.streamify( TBaseType::mSerializer ); inType.streamify( TBaseType::mSerializer, theHeader ); if ( TBaseType::mDataArray.size() >= TBaseType::mBufferFullAmount ) flushProfileEvents(); } }; class PxProfileMemoryEventBufferImpl : public PxUserAllocated , public PxProfileMemoryEventBuffer { typedef MemoryEventBuffer<PxProfileEventMutex, NullLock> TMemoryBufferType; TMemoryBufferType mBuffer; public: PxProfileMemoryEventBufferImpl( PxAllocatorCallback& alloc, uint32_t inBufferFullAmount ) : mBuffer( alloc, inBufferFullAmount, NULL ) { } virtual void onAllocation( size_t size, const char* typeName, const char* filename, int line, void* allocatedMemory ) { mBuffer.onAllocation( size, typeName, filename, uint32_t(line), static_cast<uint64_t>(reinterpret_cast<size_t>(allocatedMemory)) ); } virtual void onDeallocation( void* allocatedMemory ) { mBuffer.onDeallocation(static_cast<uint64_t>(reinterpret_cast<size_t>(allocatedMemory)) ); } virtual void addClient( PxProfileEventBufferClient& inClient ) { mBuffer.addClient( inClient ); } virtual void removeClient( PxProfileEventBufferClient& inClient ) { mBuffer.removeClient( inClient ); } virtual bool hasClients() const { return mBuffer.hasClients(); } virtual void flushProfileEvents() { mBuffer.flushProfileEvents(); } virtual void release(){ PX_PROFILE_DELETE( mBuffer.getWrapper().getAllocator(), this ); } }; }} #endif
5,746
C
35.605095
134
0.748869
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdUserRenderer.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. #include "PxPvdUserRenderImpl.h" #include "PxPvdInternalByteStreams.h" #include "PxPvdBits.h" #include <stdarg.h> using namespace physx; using namespace physx::pvdsdk; namespace { template <typename TStreamType> struct RenderWriter : public RenderSerializer { TStreamType& mStream; RenderWriter(TStreamType& stream) : mStream(stream) { } template <typename TDataType> void write(const TDataType* val, uint32_t count) { uint32_t numBytes = count * sizeof(TDataType); mStream.write(reinterpret_cast<const uint8_t*>(val), numBytes); } template <typename TDataType> void write(const TDataType& val) { write(&val, 1); } template <typename TDataType> void writeRef(DataRef<TDataType>& val) { uint32_t amount = val.size(); write(amount); if(amount) write(val.begin(), amount); } virtual void streamify(uint64_t& val) { write(val); } virtual void streamify(uint32_t& val) { write(val); } virtual void streamify(float& val) { write(val); } virtual void streamify(uint8_t& val) { write(val); } virtual void streamify(DataRef<uint8_t>& val) { writeRef(val); } virtual void streamify(PxDebugText& val) { write(val.color); write(val.position); write(val.size); uint32_t amount = static_cast<uint32_t>(strlen(val.string)) + 1; write(amount); if(amount) write(val.string, amount); } virtual void streamify(DataRef<PxDebugPoint>& val) { writeRef(val); } virtual void streamify(DataRef<PxDebugLine>& val) { writeRef(val); } virtual void streamify(DataRef<PxDebugTriangle>& val) { writeRef(val); } virtual uint32_t hasData() { return false; } virtual bool isGood() { return true; } private: RenderWriter& operator=(const RenderWriter&); }; struct UserRenderer : public PvdUserRenderer { ForwardingMemoryBuffer mBuffer; uint32_t mBufferCapacity; RendererEventClient* mClient; UserRenderer(uint32_t bufferFullAmount) : mBuffer("UserRenderBuffer"), mBufferCapacity(bufferFullAmount), mClient(NULL) { } virtual ~UserRenderer() { } virtual void release() { PVD_DELETE(this); } template <typename TEventType> void handleEvent(TEventType evt) { RenderWriter<ForwardingMemoryBuffer> _writer(mBuffer); RenderSerializer& writer(_writer); PvdUserRenderTypes::Enum evtType(getPvdRenderTypeFromType<TEventType>()); writer.streamify(evtType); evt.serialize(writer); if(mBuffer.size() >= mBufferCapacity) flushRenderEvents(); } virtual void setInstanceId(const void* iid) { handleEvent(SetInstanceIdRenderEvent(PVD_POINTER_TO_U64(iid))); } // Draw these points associated with this instance virtual void drawPoints(const PxDebugPoint* points, uint32_t count) { handleEvent(PointsRenderEvent(points, count)); } // Draw these lines associated with this instance virtual void drawLines(const PxDebugLine* lines, uint32_t count) { handleEvent(LinesRenderEvent(lines, count)); } // Draw these triangles associated with this instance virtual void drawTriangles(const PxDebugTriangle* triangles, uint32_t count) { handleEvent(TrianglesRenderEvent(triangles, count)); } virtual void drawText(const PxDebugText& text) { handleEvent(TextRenderEvent(text)); } virtual void drawRenderbuffer(const PxDebugPoint* pointData, uint32_t pointCount, const PxDebugLine* lineData, uint32_t lineCount, const PxDebugTriangle* triangleData, uint32_t triangleCount) { handleEvent(DebugRenderEvent(pointData, pointCount, lineData, lineCount, triangleData, triangleCount)); } // Constraint visualization routines virtual void visualizeJointFrames(const PxTransform& parent, const PxTransform& child) PX_OVERRIDE { handleEvent(JointFramesRenderEvent(parent, child)); } virtual void visualizeLinearLimit(const PxTransform& t0, const PxTransform& t1, float value) PX_OVERRIDE { handleEvent(LinearLimitRenderEvent(t0, t1, value, true)); } virtual void visualizeAngularLimit(const PxTransform& t0, float lower, float upper) PX_OVERRIDE { handleEvent(AngularLimitRenderEvent(t0, lower, upper, true)); } virtual void visualizeLimitCone(const PxTransform& t, float tanQSwingY, float tanQSwingZ) PX_OVERRIDE { handleEvent(LimitConeRenderEvent(t, tanQSwingY, tanQSwingZ, true)); } virtual void visualizeDoubleCone(const PxTransform& t, float angle) PX_OVERRIDE { handleEvent(DoubleConeRenderEvent(t, angle, true)); } // Clear the immedate buffer. virtual void flushRenderEvents() { if(mClient) mClient->handleBufferFlush(mBuffer.begin(), mBuffer.size()); mBuffer.clear(); } virtual void setClient(RendererEventClient* client) { mClient = client; } private: UserRenderer& operator=(const UserRenderer&); }; template <bool swapBytes> struct RenderReader : public RenderSerializer { MemPvdInputStream mStream; ForwardingMemoryBuffer& mBuffer; RenderReader(ForwardingMemoryBuffer& buf) : mBuffer(buf) { } void setData(DataRef<const uint8_t> data) { mStream.setup(const_cast<uint8_t*>(data.begin()), const_cast<uint8_t*>(data.end())); } virtual void streamify(uint32_t& val) { mStream >> val; } virtual void streamify(uint64_t& val) { mStream >> val; } virtual void streamify(float& val) { mStream >> val; } virtual void streamify(uint8_t& val) { mStream >> val; } template <typename TDataType> void readRef(DataRef<TDataType>& val) { uint32_t count; mStream >> count; uint32_t numBytes = sizeof(TDataType) * count; TDataType* dataPtr = reinterpret_cast<TDataType*>(mBuffer.growBuf(numBytes)); mStream.read(reinterpret_cast<uint8_t*>(dataPtr), numBytes); val = DataRef<TDataType>(dataPtr, count); } virtual void streamify(DataRef<PxDebugPoint>& val) { readRef(val); } virtual void streamify(DataRef<PxDebugLine>& val) { readRef(val); } virtual void streamify(DataRef<PxDebugTriangle>& val) { readRef(val); } virtual void streamify(PxDebugText& val) { mStream >> val.color; mStream >> val.position; mStream >> val.size; uint32_t len = 0; mStream >> len; uint8_t* dataPtr = mBuffer.growBuf(len); mStream.read(dataPtr, len); val.string = reinterpret_cast<const char*>(dataPtr); } virtual void streamify(DataRef<uint8_t>& val) { readRef(val); } virtual bool isGood() { return mStream.isGood(); } virtual uint32_t hasData() { return uint32_t(mStream.size() > 0); } private: RenderReader& operator=(const RenderReader&); }; template <> struct RenderReader<true> : public RenderSerializer { MemPvdInputStream mStream; ForwardingMemoryBuffer& mBuffer; RenderReader(ForwardingMemoryBuffer& buf) : mBuffer(buf) { } void setData(DataRef<const uint8_t> data) { mStream.setup(const_cast<uint8_t*>(data.begin()), const_cast<uint8_t*>(data.end())); } template <typename TDataType> void read(TDataType& val) { mStream >> val; swapBytes(val); } virtual void streamify(uint64_t& val) { read(val); } virtual void streamify(uint32_t& val) { read(val); } virtual void streamify(float& val) { read(val); } virtual void streamify(uint8_t& val) { read(val); } template <typename TDataType> void readRef(DataRef<TDataType>& val) { uint32_t count; mStream >> count; swapBytes(count); uint32_t numBytes = sizeof(TDataType) * count; TDataType* dataPtr = reinterpret_cast<TDataType*>(mBuffer.growBuf(numBytes)); PVD_FOREACH(idx, count) RenderSerializerMap<TDataType>().serialize(*this, dataPtr[idx]); val = DataRef<TDataType>(dataPtr, count); } virtual void streamify(DataRef<PxDebugPoint>& val) { readRef(val); } virtual void streamify(DataRef<PxDebugLine>& val) { readRef(val); } virtual void streamify(DataRef<PxDebugTriangle>& val) { readRef(val); } virtual void streamify(PxDebugText& val) { mStream >> val.color; mStream >> val.position; mStream >> val.size; uint32_t len = 0; mStream >> len; uint8_t* dataPtr = mBuffer.growBuf(len); mStream.read(dataPtr, len); val.string = reinterpret_cast<const char*>(dataPtr); } virtual void streamify(DataRef<uint8_t>& val) { readRef(val); } virtual bool isGood() { return mStream.isGood(); } virtual uint32_t hasData() { return uint32_t(mStream.size() > 0); } private: RenderReader& operator=(const RenderReader&); }; } PvdUserRenderer* PvdUserRenderer::create(uint32_t bufferSize) { return PVD_NEW(UserRenderer)(bufferSize); }
9,923
C++
23.503704
111
0.727401
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdCommStreamEventSink.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. #ifndef PX_PVD_COMM_STREAM_EVENT_SINK_H #define PX_PVD_COMM_STREAM_EVENT_SINK_H #include "PxPvdObjectModelBaseTypes.h" #include "PxPvdCommStreamEvents.h" #include "PxPvdCommStreamTypes.h" namespace physx { namespace pvdsdk { class PvdCommStreamEventSink { public: template <typename TStreamType> static void writeStreamEvent(const EventSerializeable& evt, PvdCommStreamEventTypes::Enum evtType, TStreamType& stream) { EventStreamifier<TStreamType> streamifier_concrete(stream); PvdEventSerializer& streamifier(streamifier_concrete); streamifier.streamify(evtType); const_cast<EventSerializeable&>(evt).serialize(streamifier); } }; } // pvd } // physx #endif
2,240
C
39.017856
120
0.775
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdDefaultSocketTransport.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #include "PxPvdDefaultSocketTransport.h" namespace physx { namespace pvdsdk { PvdDefaultSocketTransport::PvdDefaultSocketTransport(const char* host, int port, unsigned int timeoutInMilliseconds) : mHost(host), mPort(uint16_t(port)), mTimeout(timeoutInMilliseconds), mConnected(false), mWrittenData(0) { } PvdDefaultSocketTransport::~PvdDefaultSocketTransport() { } bool PvdDefaultSocketTransport::connect() { if(mConnected) return true; if(mSocket.connect(mHost, mPort, mTimeout)) { mSocket.setBlocking(true); mConnected = true; } return mConnected; } void PvdDefaultSocketTransport::disconnect() { mSocket.flush(); mSocket.disconnect(); mConnected = false; } bool PvdDefaultSocketTransport::isConnected() { return mSocket.isConnected(); } bool PvdDefaultSocketTransport::write(const uint8_t* inBytes, uint32_t inLength) { if(mConnected) { if(inLength == 0) return true; uint32_t amountWritten = 0; uint32_t totalWritten = 0; do { // Sockets don't have to write as much as requested, so we need // to wrap this call in a do/while loop. // If they don't write any bytes then we consider them disconnected. amountWritten = mSocket.write(inBytes, inLength); inLength -= amountWritten; inBytes += amountWritten; totalWritten += amountWritten; } while(inLength && amountWritten); if(amountWritten == 0) return false; mWrittenData += totalWritten; return true; } else return false; } PxPvdTransport& PvdDefaultSocketTransport::lock() { mMutex.lock(); return *this; } void PvdDefaultSocketTransport::unlock() { mMutex.unlock(); } void PvdDefaultSocketTransport::flush() { mSocket.flush(); } uint64_t PvdDefaultSocketTransport::getWrittenDataSize() { return mWrittenData; } void PvdDefaultSocketTransport::release() { PX_DELETE_THIS; } } // namespace pvdsdk PxPvdTransport* PxDefaultPvdSocketTransportCreate(const char* host, int port, unsigned int timeoutInMilliseconds) { return PX_NEW(pvdsdk::PvdDefaultSocketTransport)(host, port, timeoutInMilliseconds); } } // namespace physx
3,762
C++
27.082089
116
0.754918
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdDefaultFileTransport.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #include "PxPvdDefaultFileTransport.h" namespace physx { namespace pvdsdk { PvdDefaultFileTransport::PvdDefaultFileTransport(const char* name) : mConnected(false), mWrittenData(0), mLocked(false) { mFileBuffer = PX_NEW(PsFileBuffer)(name, PxFileBuf::OPEN_WRITE_ONLY); } PvdDefaultFileTransport::~PvdDefaultFileTransport() { } bool PvdDefaultFileTransport::connect() { PX_ASSERT(mFileBuffer); mConnected = mFileBuffer->isOpen(); return mConnected; } void PvdDefaultFileTransport::disconnect() { mConnected = false; } bool PvdDefaultFileTransport::isConnected() { return mConnected; } bool PvdDefaultFileTransport::write(const uint8_t* inBytes, uint32_t inLength) { PX_ASSERT(mLocked); PX_ASSERT(mFileBuffer); if (mConnected) { uint32_t len = mFileBuffer->write(inBytes, inLength); mWrittenData += len; return len == inLength; } else return false; } PxPvdTransport& PvdDefaultFileTransport::lock() { mMutex.lock(); PX_ASSERT(!mLocked); mLocked = true; return *this; } void PvdDefaultFileTransport::unlock() { PX_ASSERT(mLocked); mLocked = false; mMutex.unlock(); } void PvdDefaultFileTransport::flush() { } uint64_t PvdDefaultFileTransport::getWrittenDataSize() { return mWrittenData; } void PvdDefaultFileTransport::release() { if (mFileBuffer) { mFileBuffer->close(); delete mFileBuffer; } mFileBuffer = NULL; PX_DELETE_THIS; } class NullFileTransport : public physx::PxPvdTransport, public physx::PxUserAllocated { PX_NOCOPY(NullFileTransport) public: NullFileTransport(); virtual ~NullFileTransport(); virtual bool connect(); virtual void disconnect(); virtual bool isConnected(); virtual bool write(const uint8_t* inBytes, uint32_t inLength); virtual PxPvdTransport& lock(); virtual void unlock(); virtual void flush(); virtual uint64_t getWrittenDataSize(); virtual void release(); private: bool mConnected; uint64_t mWrittenData; physx::PxMutex mMutex; bool mLocked; // for debug, remove it when finished }; NullFileTransport::NullFileTransport() : mConnected(false), mWrittenData(0), mLocked(false) { } NullFileTransport::~NullFileTransport() { } bool NullFileTransport::connect() { mConnected = true; return true; } void NullFileTransport::disconnect() { mConnected = false; } bool NullFileTransport::isConnected() { return mConnected; } bool NullFileTransport::write(const uint8_t* /*inBytes*/, uint32_t inLength) { PX_ASSERT(mLocked); if(mConnected) { uint32_t len = inLength; mWrittenData += len; return len == inLength; } else return false; } PxPvdTransport& NullFileTransport::lock() { mMutex.lock(); PX_ASSERT(!mLocked); mLocked = true; return *this; } void NullFileTransport::unlock() { PX_ASSERT(mLocked); mLocked = false; mMutex.unlock(); } void NullFileTransport::flush() { } uint64_t NullFileTransport::getWrittenDataSize() { return mWrittenData; } void NullFileTransport::release() { PX_DELETE_THIS; } } // namespace pvdsdk PxPvdTransport* PxDefaultPvdFileTransportCreate(const char* name) { if(name) return PX_NEW(pvdsdk::PvdDefaultFileTransport)(name); else return PX_NEW(pvdsdk::NullFileTransport)(); } } // namespace physx
4,866
C++
21.325688
119
0.748048
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxProfileEvents.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. #ifndef PX_PROFILE_EVENTS_H #define PX_PROFILE_EVENTS_H #include "foundation/PxMath.h" #include "foundation/PxAssert.h" #include "PxProfileEventId.h" #define PX_PROFILE_UNION_1(a) physx::profile::TUnion<a, physx::profile::Empty> #define PX_PROFILE_UNION_2(a,b) physx::profile::TUnion<a, PX_PROFILE_UNION_1(b)> #define PX_PROFILE_UNION_3(a,b,c) physx::profile::TUnion<a, PX_PROFILE_UNION_2(b,c)> #define PX_PROFILE_UNION_4(a,b,c,d) physx::profile::TUnion<a, PX_PROFILE_UNION_3(b,c,d)> #define PX_PROFILE_UNION_5(a,b,c,d,e) physx::profile::TUnion<a, PX_PROFILE_UNION_4(b,c,d,e)> #define PX_PROFILE_UNION_6(a,b,c,d,e,f) physx::profile::TUnion<a, PX_PROFILE_UNION_5(b,c,d,e,f)> #define PX_PROFILE_UNION_7(a,b,c,d,e,f,g) physx::profile::TUnion<a, PX_PROFILE_UNION_6(b,c,d,e,f,g)> #define PX_PROFILE_UNION_8(a,b,c,d,e,f,g,h) physx::profile::TUnion<a, PX_PROFILE_UNION_7(b,c,d,e,f,g,h)> #define PX_PROFILE_UNION_9(a,b,c,d,e,f,g,h,i) physx::profile::TUnion<a, PX_PROFILE_UNION_8(b,c,d,e,f,g,h,i)> namespace physx { namespace profile { struct Empty {}; template <typename T> struct Type2Type {}; template <typename U, typename V> union TUnion { typedef U Head; typedef V Tail; Head head; Tail tail; template <typename TDataType> void init(const TDataType& inData) { toType(Type2Type<TDataType>()).init(inData); } template <typename TDataType> PX_FORCE_INLINE TDataType& toType(const Type2Type<TDataType>& outData) { return tail.toType(outData); } PX_FORCE_INLINE Head& toType(const Type2Type<Head>&) { return head; } template <typename TDataType> PX_FORCE_INLINE const TDataType& toType(const Type2Type<TDataType>& outData) const { return tail.toType(outData); } PX_FORCE_INLINE const Head& toType(const Type2Type<Head>&) const { return head; } }; struct EventTypes { enum Enum { Unknown = 0, StartEvent, StopEvent, RelativeStartEvent, //reuses context,id from the earlier event. RelativeStopEvent, //reuses context,id from the earlier event. EventValue, CUDAProfileBuffer //obsolete, placeholder to skip data from PhysX SDKs < 3.4 }; }; struct EventStreamCompressionFlags { enum Enum { U8 = 0, U16 = 1, U32 = 2, U64 = 3, CompressionMask = 3 }; }; #if PX_APPLE_FAMILY #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wimplicit-fallthrough" #endif //Find the smallest value that will represent the incoming value without loss. //We can enlarge the current compression value, but we can't make is smaller. //In this way, we can use this function to find the smallest compression setting //that will work for a set of values. inline EventStreamCompressionFlags::Enum findCompressionValue( uint64_t inValue, EventStreamCompressionFlags::Enum inCurrentCompressionValue = EventStreamCompressionFlags::U8 ) { PX_ASSERT_WITH_MESSAGE( (inCurrentCompressionValue >= EventStreamCompressionFlags::U8) && (inCurrentCompressionValue <= EventStreamCompressionFlags::U64), "Invalid inCurrentCompressionValue in profile::findCompressionValue"); //Fallthrough is intentional switch( inCurrentCompressionValue ) { case EventStreamCompressionFlags::U8: if ( inValue <= UINT8_MAX ) return EventStreamCompressionFlags::U8; case EventStreamCompressionFlags::U16: if ( inValue <= UINT16_MAX ) return EventStreamCompressionFlags::U16; case EventStreamCompressionFlags::U32: if ( inValue <= UINT32_MAX ) return EventStreamCompressionFlags::U32; case EventStreamCompressionFlags::U64: break; } return EventStreamCompressionFlags::U64; } //Find the smallest value that will represent the incoming value without loss. //We can enlarge the current compression value, but we can't make is smaller. //In this way, we can use this function to find the smallest compression setting //that will work for a set of values. inline EventStreamCompressionFlags::Enum findCompressionValue( uint32_t inValue, EventStreamCompressionFlags::Enum inCurrentCompressionValue = EventStreamCompressionFlags::U8 ) { PX_ASSERT_WITH_MESSAGE( (inCurrentCompressionValue >= EventStreamCompressionFlags::U8) && (inCurrentCompressionValue <= EventStreamCompressionFlags::U64), "Invalid inCurrentCompressionValue in profile::findCompressionValue"); //Fallthrough is intentional switch( inCurrentCompressionValue ) { case EventStreamCompressionFlags::U8: if ( inValue <= UINT8_MAX ) return EventStreamCompressionFlags::U8; case EventStreamCompressionFlags::U16: if ( inValue <= UINT16_MAX ) return EventStreamCompressionFlags::U16; case EventStreamCompressionFlags::U32: case EventStreamCompressionFlags::U64: break; } return EventStreamCompressionFlags::U32; } #if PX_APPLE_FAMILY #pragma clang diagnostic pop #endif //Event header is 32 bytes and precedes all events. struct EventHeader { uint8_t mEventType; //Used to parse the correct event out of the stream uint8_t mStreamOptions; //Timestamp compression, etc. uint16_t mEventId; //16 bit per-event-system event id EventHeader( uint8_t type = 0, uint16_t id = 0 ) : mEventType( type ) , mStreamOptions( uint8_t(-1) ) , mEventId( id ) { } EventHeader( EventTypes::Enum type, uint16_t id ) : mEventType( static_cast<uint8_t>( type ) ) , mStreamOptions( uint8_t(-1) ) , mEventId( id ) { } EventStreamCompressionFlags::Enum getTimestampCompressionFlags() const { return static_cast<EventStreamCompressionFlags::Enum> ( mStreamOptions & EventStreamCompressionFlags::CompressionMask ); } uint64_t compressTimestamp( uint64_t inLastTimestamp, uint64_t inCurrentTimestamp ) { mStreamOptions = EventStreamCompressionFlags::U64; uint64_t retval = inCurrentTimestamp; if ( inLastTimestamp ) { retval = inCurrentTimestamp - inLastTimestamp; EventStreamCompressionFlags::Enum compressionValue = findCompressionValue( retval ); mStreamOptions = static_cast<uint8_t>( compressionValue ); if ( compressionValue == EventStreamCompressionFlags::U64 ) retval = inCurrentTimestamp; //just send the timestamp as is. } return retval; } uint64_t uncompressTimestamp( uint64_t inLastTimestamp, uint64_t inCurrentTimestamp ) const { if ( getTimestampCompressionFlags() != EventStreamCompressionFlags::U64 ) return inLastTimestamp + inCurrentTimestamp; return inCurrentTimestamp; } void setContextIdCompressionFlags( uint64_t inContextId ) { uint8_t options = static_cast<uint8_t>( findCompressionValue( inContextId ) ); mStreamOptions = uint8_t(mStreamOptions | options << 2); } EventStreamCompressionFlags::Enum getContextIdCompressionFlags() const { return static_cast< EventStreamCompressionFlags::Enum >( ( mStreamOptions >> 2 ) & EventStreamCompressionFlags::CompressionMask ); } bool operator==( const EventHeader& inOther ) const { return mEventType == inOther.mEventType && mStreamOptions == inOther.mStreamOptions && mEventId == inOther.mEventId; } template<typename TStreamType> inline uint32_t streamify( TStreamType& inStream ) { uint32_t writtenSize = inStream.streamify( "EventType", mEventType ); writtenSize += inStream.streamify("StreamOptions", mStreamOptions); //Timestamp compression, etc. writtenSize += inStream.streamify("EventId", mEventId); //16 bit per-event-system event id return writtenSize; } }; //Declaration of type level getEventType function that maps enumeration event types to datatypes template<typename TDataType> inline EventTypes::Enum getEventType() { PX_ASSERT( false ); return EventTypes::Unknown; } //Relative profile event means this event is sharing the context and thread id //with the event before it. struct RelativeProfileEvent { uint64_t mTensOfNanoSeconds; //timestamp is in tensOfNanonseconds void init( uint64_t inTs ) { mTensOfNanoSeconds = inTs; } void init( const RelativeProfileEvent& inData ) { mTensOfNanoSeconds = inData.mTensOfNanoSeconds; } bool operator==( const RelativeProfileEvent& other ) const { return mTensOfNanoSeconds == other.mTensOfNanoSeconds; } template<typename TStreamType> uint32_t streamify( TStreamType& inStream, const EventHeader& inHeader ) { return inStream.streamify( "TensOfNanoSeconds", mTensOfNanoSeconds, inHeader.getTimestampCompressionFlags() ); } uint64_t getTimestamp() const { return mTensOfNanoSeconds; } void setTimestamp( uint64_t inTs ) { mTensOfNanoSeconds = inTs; } void setupHeader( EventHeader& inHeader, uint64_t inLastTimestamp ) { mTensOfNanoSeconds = inHeader.compressTimestamp( inLastTimestamp, mTensOfNanoSeconds ); } uint32_t getEventSize(const EventHeader& inHeader) { uint32_t size = 0; switch (inHeader.getTimestampCompressionFlags()) { case EventStreamCompressionFlags::U8: size = 1; break; case EventStreamCompressionFlags::U16: size = 2; break; case EventStreamCompressionFlags::U32: size = 4; break; case EventStreamCompressionFlags::U64: size = 8; break; } return size; } }; //Start version of the relative event. struct RelativeStartEvent : public RelativeProfileEvent { void init( uint64_t inTs = 0 ) { RelativeProfileEvent::init( inTs ); } void init( const RelativeStartEvent& inData ) { RelativeProfileEvent::init( inData ); } template<typename THandlerType> void handle( THandlerType* inHdlr, uint16_t eventId, uint32_t thread, uint64_t context, uint8_t inCpuId, uint8_t threadPriority ) const { inHdlr->onStartEvent( PxProfileEventId( eventId ), thread, context, inCpuId, threadPriority, mTensOfNanoSeconds ); } }; template<> inline EventTypes::Enum getEventType<RelativeStartEvent>() { return EventTypes::RelativeStartEvent; } //Stop version of relative event. struct RelativeStopEvent : public RelativeProfileEvent { void init( uint64_t inTs = 0 ) { RelativeProfileEvent::init( inTs ); } void init( const RelativeStopEvent& inData ) { RelativeProfileEvent::init( inData ); } template<typename THandlerType> void handle( THandlerType* inHdlr, uint16_t eventId, uint32_t thread, uint64_t context, uint8_t inCpuId, uint8_t threadPriority ) const { inHdlr->onStopEvent( PxProfileEventId( eventId ), thread, context, inCpuId, threadPriority, mTensOfNanoSeconds ); } }; template<> inline EventTypes::Enum getEventType<RelativeStopEvent>() { return EventTypes::RelativeStopEvent; } struct EventContextInformation { uint64_t mContextId; uint32_t mThreadId; //Thread this event was taken from uint8_t mThreadPriority; uint8_t mCpuId; void init( uint32_t inThreadId = UINT32_MAX , uint64_t inContextId = (uint64_t(-1)) , uint8_t inPriority = UINT8_MAX , uint8_t inCpuId = UINT8_MAX ) { mContextId = inContextId; mThreadId = inThreadId; mThreadPriority = inPriority; mCpuId = inCpuId; } void init( const EventContextInformation& inData ) { mContextId = inData.mContextId; mThreadId = inData.mThreadId; mThreadPriority = inData.mThreadPriority; mCpuId = inData.mCpuId; } template<typename TStreamType> uint32_t streamify( TStreamType& inStream, EventStreamCompressionFlags::Enum inContextIdFlags ) { uint32_t writtenSize = inStream.streamify( "ThreadId", mThreadId ); writtenSize += inStream.streamify("ContextId", mContextId, inContextIdFlags); writtenSize += inStream.streamify("ThreadPriority", mThreadPriority); writtenSize += inStream.streamify("CpuId", mCpuId); return writtenSize; } bool operator==( const EventContextInformation& other ) const { return mThreadId == other.mThreadId && mContextId == other.mContextId && mThreadPriority == other.mThreadPriority && mCpuId == other.mCpuId; } void setToDefault() { *this = EventContextInformation(); } }; //Profile event contains all the data required to tell the profile what is going //on. struct ProfileEvent { EventContextInformation mContextInformation; RelativeProfileEvent mTimeData; //timestamp in seconds. void init( uint32_t inThreadId, uint64_t inContextId, uint8_t inCpuId, uint8_t inPriority, uint64_t inTs ) { mContextInformation.init( inThreadId, inContextId, inPriority, inCpuId ); mTimeData.init( inTs ); } void init( const ProfileEvent& inData ) { mContextInformation.init( inData.mContextInformation ); mTimeData.init( inData.mTimeData ); } bool operator==( const ProfileEvent& other ) const { return mContextInformation == other.mContextInformation && mTimeData == other.mTimeData; } template<typename TStreamType> uint32_t streamify( TStreamType& inStream, const EventHeader& inHeader ) { uint32_t writtenSize = mContextInformation.streamify(inStream, inHeader.getContextIdCompressionFlags()); writtenSize += mTimeData.streamify(inStream, inHeader); return writtenSize; } uint32_t getEventSize(const EventHeader& inHeader) { uint32_t eventSize = 0; // time is stored depending on the conpress flag mTimeData.streamify(inStream, inHeader); switch (inHeader.getTimestampCompressionFlags()) { case EventStreamCompressionFlags::U8: eventSize++; break; case EventStreamCompressionFlags::U16: eventSize += 2; break; case EventStreamCompressionFlags::U32: eventSize += 4; break; case EventStreamCompressionFlags::U64: eventSize += 8; break; } // context information // mContextInformation.streamify( inStream, inHeader.getContextIdCompressionFlags() ); eventSize += 6; // uint32_t mThreadId; uint8_t mThreadPriority; uint8_t mCpuId; switch (inHeader.getContextIdCompressionFlags()) { case EventStreamCompressionFlags::U8: eventSize++; break; case EventStreamCompressionFlags::U16: eventSize += 2; break; case EventStreamCompressionFlags::U32: eventSize += 4; break; case EventStreamCompressionFlags::U64: eventSize += 8; break; } return eventSize; } uint64_t getTimestamp() const { return mTimeData.getTimestamp(); } void setTimestamp( uint64_t inTs ) { mTimeData.setTimestamp( inTs ); } void setupHeader( EventHeader& inHeader, uint64_t inLastTimestamp ) { mTimeData.setupHeader( inHeader, inLastTimestamp ); inHeader.setContextIdCompressionFlags( mContextInformation.mContextId ); } }; //profile start event starts the profile session. struct StartEvent : public ProfileEvent { void init( uint32_t inThreadId = 0, uint64_t inContextId = 0, uint8_t inCpuId = 0, uint8_t inPriority = 0, uint64_t inTensOfNanoSeconds = 0 ) { ProfileEvent::init( inThreadId, inContextId, inCpuId, inPriority, inTensOfNanoSeconds ); } void init( const StartEvent& inData ) { ProfileEvent::init( inData ); } RelativeStartEvent getRelativeEvent() const { RelativeStartEvent theEvent; theEvent.init( mTimeData.mTensOfNanoSeconds ); return theEvent; } EventTypes::Enum getRelativeEventType() const { return getEventType<RelativeStartEvent>(); } }; template<> inline EventTypes::Enum getEventType<StartEvent>() { return EventTypes::StartEvent; } //Profile stop event stops the profile session. struct StopEvent : public ProfileEvent { void init( uint32_t inThreadId = 0, uint64_t inContextId = 0, uint8_t inCpuId = 0, uint8_t inPriority = 0, uint64_t inTensOfNanoSeconds = 0 ) { ProfileEvent::init( inThreadId, inContextId, inCpuId, inPriority, inTensOfNanoSeconds ); } void init( const StopEvent& inData ) { ProfileEvent::init( inData ); } RelativeStopEvent getRelativeEvent() const { RelativeStopEvent theEvent; theEvent.init( mTimeData.mTensOfNanoSeconds ); return theEvent; } EventTypes::Enum getRelativeEventType() const { return getEventType<RelativeStopEvent>(); } }; template<> inline EventTypes::Enum getEventType<StopEvent>() { return EventTypes::StopEvent; } struct EventValue { uint64_t mValue; uint64_t mContextId; uint32_t mThreadId; void init( int64_t inValue = 0, uint64_t inContextId = 0, uint32_t inThreadId = 0 ) { mValue = static_cast<uint64_t>( inValue ); mContextId = inContextId; mThreadId = inThreadId; } void init( const EventValue& inData ) { mValue = inData.mValue; mContextId = inData.mContextId; mThreadId = inData.mThreadId; } int64_t getValue() const { return static_cast<int16_t>( mValue ); } void setupHeader( EventHeader& inHeader ) { mValue = inHeader.compressTimestamp( 0, mValue ); inHeader.setContextIdCompressionFlags( mContextId ); } template<typename TStreamType> uint32_t streamify( TStreamType& inStream, const EventHeader& inHeader ) { uint32_t writtenSize = inStream.streamify("Value", mValue, inHeader.getTimestampCompressionFlags()); writtenSize += inStream.streamify("ContextId", mContextId, inHeader.getContextIdCompressionFlags()); writtenSize += inStream.streamify("ThreadId", mThreadId); return writtenSize; } uint32_t getEventSize(const EventHeader& inHeader) { uint32_t eventSize = 0; // value switch (inHeader.getTimestampCompressionFlags()) { case EventStreamCompressionFlags::U8: eventSize++; break; case EventStreamCompressionFlags::U16: eventSize += 2; break; case EventStreamCompressionFlags::U32: eventSize += 4; break; case EventStreamCompressionFlags::U64: eventSize += 8; break; } // context information switch (inHeader.getContextIdCompressionFlags()) { case EventStreamCompressionFlags::U8: eventSize++; break; case EventStreamCompressionFlags::U16: eventSize += 2; break; case EventStreamCompressionFlags::U32: eventSize += 4; break; case EventStreamCompressionFlags::U64: eventSize += 8; break; } eventSize += 4; // uint32_t mThreadId; return eventSize; } bool operator==( const EventValue& other ) const { return mValue == other.mValue && mContextId == other.mContextId && mThreadId == other.mThreadId; } template<typename THandlerType> void handle( THandlerType* inHdlr, uint16_t eventId ) const { inHdlr->onEventValue( PxProfileEventId( eventId ), mThreadId, mContextId, getValue() ); } }; template<> inline EventTypes::Enum getEventType<EventValue>() { return EventTypes::EventValue; } //obsolete, placeholder to skip data from PhysX SDKs < 3.4 struct CUDAProfileBuffer { uint64_t mTimestamp; float mTimespan; const uint8_t* mCudaData; uint32_t mBufLen; uint32_t mVersion; template<typename TStreamType> uint32_t streamify( TStreamType& inStream, const EventHeader& ) { uint32_t writtenSize = inStream.streamify("Timestamp", mTimestamp); writtenSize += inStream.streamify("Timespan", mTimespan); writtenSize += inStream.streamify("CudaData", mCudaData, mBufLen); writtenSize += inStream.streamify("BufLen", mBufLen); writtenSize += inStream.streamify("Version", mVersion); return writtenSize; } bool operator==( const CUDAProfileBuffer& other ) const { return mTimestamp == other.mTimestamp && mTimespan == other.mTimespan && mBufLen == other.mBufLen && memcmp( mCudaData, other.mCudaData, mBufLen ) == 0 && mVersion == other.mVersion; } }; template<> inline EventTypes::Enum getEventType<CUDAProfileBuffer>() { return EventTypes::CUDAProfileBuffer; } //Provides a generic equal operation for event data objects. template <typename TEventData> struct EventDataEqualOperator { TEventData mData; EventDataEqualOperator( const TEventData& inD ) : mData( inD ) {} template<typename TDataType> bool operator()( const TDataType& inRhs ) const { return mData.toType( Type2Type<TDataType>() ) == inRhs; } bool operator()() const { return false; } }; /** * Generic event container that combines and even header with the generic event data type. * Provides unsafe and typesafe access to the event data. */ class Event { public: typedef PX_PROFILE_UNION_7(StartEvent, StopEvent, RelativeStartEvent, RelativeStopEvent, EventValue, CUDAProfileBuffer, uint8_t) EventData; private: EventHeader mHeader; EventData mData; public: Event() {} template <typename TDataType> Event( EventHeader inHeader, const TDataType& inData ) : mHeader( inHeader ) { mData.init<TDataType>(inData); } template<typename TDataType> Event( uint16_t eventId, const TDataType& inData ) : mHeader( getEventType<TDataType>(), eventId ) { mData.init<TDataType>(inData); } const EventHeader& getHeader() const { return mHeader; } const EventData& getData() const { return mData; } template<typename TDataType> const TDataType& getValue() const { PX_ASSERT( mHeader.mEventType == getEventType<TDataType>() ); return mData.toType<TDataType>(); } template<typename TDataType> TDataType& getValue() { PX_ASSERT( mHeader.mEventType == getEventType<TDataType>() ); return mData.toType<TDataType>(); } template<typename TRetVal, typename TOperator> inline TRetVal visit( TOperator inOp ) const; bool operator==( const Event& inOther ) const { if ( !(mHeader == inOther.mHeader ) ) return false; if ( mHeader.mEventType ) return inOther.visit<bool>( EventDataEqualOperator<EventData>( mData ) ); return true; } }; //Combining the above union type with an event type means that an object can get the exact //data out of the union. Using this function means that all callsites will be forced to //deal with the newer datatypes and that the switch statement only exists in once place. //Implements conversion from enum -> datatype template<typename TRetVal, typename TOperator> TRetVal visit( EventTypes::Enum inEventType, const Event::EventData& inData, TOperator inOperator ) { switch( inEventType ) { case EventTypes::StartEvent: return inOperator( inData.toType( Type2Type<StartEvent>() ) ); case EventTypes::StopEvent: return inOperator( inData.toType( Type2Type<StopEvent>() ) ); case EventTypes::RelativeStartEvent: return inOperator( inData.toType( Type2Type<RelativeStartEvent>() ) ); case EventTypes::RelativeStopEvent: return inOperator( inData.toType( Type2Type<RelativeStopEvent>() ) ); case EventTypes::EventValue: return inOperator( inData.toType( Type2Type<EventValue>() ) ); //obsolete, placeholder to skip data from PhysX SDKs < 3.4 case EventTypes::CUDAProfileBuffer: return inOperator( inData.toType( Type2Type<CUDAProfileBuffer>() ) ); case EventTypes::Unknown: break; } uint8_t type = static_cast<uint8_t>( inEventType ); return inOperator( type ); } template<typename TRetVal, typename TOperator> inline TRetVal Event::visit( TOperator inOp ) const { return physx::profile::visit<TRetVal>( static_cast<EventTypes::Enum>(mHeader.mEventType), mData, inOp ); } } } #endif
24,440
C
33.61898
177
0.729378
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdObjectModelInternalTypes.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. #ifndef PX_PVD_OBJECT_MODEL_INTERNAL_TYPES_H #define PX_PVD_OBJECT_MODEL_INTERNAL_TYPES_H #include "foundation/PxMemory.h" #include "PxPvdObjectModelBaseTypes.h" #include "foundation/PxArray.h" #include "PxPvdFoundation.h" namespace physx { namespace pvdsdk { struct PvdInternalType { enum Enum { None = 0, #define DECLARE_INTERNAL_PVD_TYPE(type) type, #include "PxPvdObjectModelInternalTypeDefs.h" Last #undef DECLARE_INTERNAL_PVD_TYPE }; }; PX_COMPILE_TIME_ASSERT(uint32_t(PvdInternalType::Last) <= uint32_t(PvdBaseType::InternalStop)); template <typename T> struct DataTypeToPvdTypeMap { bool compile_error; }; template <PvdInternalType::Enum> struct PvdTypeToDataTypeMap { bool compile_error; }; #define DECLARE_INTERNAL_PVD_TYPE(type) \ template <> \ struct DataTypeToPvdTypeMap<type> \ { \ enum Enum \ { \ BaseTypeEnum = PvdInternalType::type \ }; \ }; \ template <> \ struct PvdTypeToDataTypeMap<PvdInternalType::type> \ { \ typedef type TDataType; \ }; \ template <> \ struct PvdDataTypeToNamespacedNameMap<type> \ { \ NamespacedName Name; \ PvdDataTypeToNamespacedNameMap<type>() : Name("physx3_debugger_internal", #type) \ { \ } \ }; #include "PxPvdObjectModelInternalTypeDefs.h" #undef DECLARE_INTERNAL_PVD_TYPE template <typename TDataType, typename TAlloc> DataRef<TDataType> toDataRef(const PxArray<TDataType, TAlloc>& data) { return DataRef<TDataType>(data.begin(), data.end()); } static inline bool safeStrEq(const DataRef<String>& lhs, const DataRef<String>& rhs) { uint32_t count = lhs.size(); if(count != rhs.size()) return false; for(uint32_t idx = 0; idx < count; ++idx) if(!safeStrEq(lhs[idx], rhs[idx])) return false; return true; } static inline char* copyStr(const char* str) { str = nonNull(str); uint32_t len = static_cast<uint32_t>(strlen(str)); char* newData = reinterpret_cast<char*>(PX_ALLOC(len + 1, "string")); PxMemCopy(newData, str, len); newData[len] = 0; return newData; } // Used for predictable bit fields. template <typename TDataType, uint8_t TNumBits, uint8_t TOffset, typename TInputType> struct BitMaskSetter { // Create a mask that masks out the orginal value shift into place static TDataType createOffsetMask() { return createMask() << TOffset; } // Create a mask of TNumBits number of tis static TDataType createMask() { return static_cast<TDataType>((1 << TNumBits) - 1); } void setValue(TDataType& inCurrent, TInputType inData) { PX_ASSERT(inData < (1 << TNumBits)); // Create a mask to remove the current value. TDataType theMask = ~(createOffsetMask()); // Clear out current value. inCurrent = inCurrent & theMask; // Create the new value. TDataType theAddition = reinterpret_cast<TDataType>(inData << TOffset); // or it into the existing value. inCurrent = inCurrent | theAddition; } TInputType getValue(TDataType inCurrent) { return static_cast<TInputType>((inCurrent >> TOffset) & createMask()); } }; } } #endif
6,519
C
41.337662
120
0.511888
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxProfileEventBufferAtomic.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_PROFILE_EVENT_BUFFER_ATOMIC_H #define PX_PROFILE_EVENT_BUFFER_ATOMIC_H #include "PxProfileEvents.h" #include "PxProfileEventSerialization.h" #include "PxProfileDataBuffer.h" #include "foundation/PxArray.h" #include "foundation/PxAtomic.h" #include "foundation/PxAllocator.h" #include "foundation/PxAlloca.h" #include "foundation/PxTime.h" namespace physx { namespace profile { static const uint32_t LOCAL_BUFFER_SIZE = 512; /** * An event buffer maintains an in-memory buffer of events. When this buffer is full * it sends to buffer to all handlers registered and resets the buffer. * * It is parameterized in four ways. The first is a context provider that provides * both thread id and context id. * * The second is the mutex (which may be null) and a scoped locking mechanism. Thus the buffer * may be used in a multithreaded context but clients of the buffer don't pay for this if they * don't intend to use it this way. * * Finally the buffer may use an event filtering mechanism. This mechanism needs one function, * namely isEventEnabled( uint8_t subsystem, uint8_t eventId ). * * All of these systems can be parameterized at compile time leading to an event buffer * that should be as fast as possible given the constraints. * * Buffers may be chained together as this buffer has a handleBufferFlush method that * will grab the mutex and add the data to this event buffer. * * Overall, lets look at the PhysX SDK an how all the pieces fit together. * The SDK should have a mutex-protected event buffer where actual devs or users of PhysX * can register handlers. This buffer has slow but correct implementations of the * context provider interface. * * The SDK object should also have a concrete event filter which was used in the * construction of the event buffer and which it exposes through opaque interfaces. * * The SDK should protect its event buffer and its event filter from multithreaded * access and thus this provides the safest and slowest way to log events and to * enable/disable events. * * Each scene should also have a concrete event filter. This filter is updated from * the SDK event filter (in a mutex protected way) every frame. Thus scenes can change * their event filtering on a frame-by-frame basis. It means that tasks running * under the scene don't need a mutex when accessing the filter. * * Furthermore the scene should have an event buffer that always sets the context id * on each event to the scene. This allows PVD and other systems to correlate events * to scenes. Scenes should provide access only to a relative event sending system * that looks up thread id upon each event but uses the scene id. * * The SDK's event buffer should be setup as an EventBufferClient for each scene's * event buffer. Thus the SDK should expose an EventBufferClient interface that * any client can use. * * For extremely *extremely* performance sensitive areas we should create a specialized * per-scene, per-thread event buffer that is set on the task for these occasions. This buffer * uses a trivial event context setup with the scene's context id and the thread id. It should * share the scene's concrete event filter and it should have absolutely no locking. It should * empty into the scene's event buffer which in some cases should empty into the SDK's event buffer * which when full will push events all the way out of the system. The task should *always* flush * the event buffer (if it has one) when it is finished; nothing else will work reliably. * * If the per-scene,per-thread event buffer is correctly parameterized and fully defined adding * a new event should be an inline operation requiring no mutex grabs in the common case. I don't * believe you can get faster event production than this; the events are as small as possible (all * relative events) and they are all produced inline resulting in one 4 byte header and one * 8 byte timestamp per event. Reducing the memory pressure in this way reduces the communication * overhead, the mutex grabs, basically everything that makes profiling expensive at the cost * of a per-scene,per-thread event buffer (which could easily be reduced to a per-thread event * buffer. */ template<typename TContextProvider, typename TMutex, typename TScopedLock, typename TEventFilter> class EventBufferAtomic : public DataBuffer < TMutex, TScopedLock > { public: typedef DataBuffer<TMutex, TScopedLock> TBaseType; typedef TContextProvider TContextProviderType; typedef TEventFilter TEventFilterType; typedef typename TBaseType::TMutexType TMutexType; typedef typename TBaseType::TScopedLockType TScopedLockType; typedef typename TBaseType::TU8AllocatorType TU8AllocatorType; typedef typename TBaseType::TMemoryBufferType TMemoryBufferType; typedef typename TBaseType::TBufferClientArray TBufferClientArray; private: TContextProvider mContextProvider; TEventFilterType mEventFilter; volatile int32_t mReserved; volatile int32_t mWritten; public: EventBufferAtomic(PxAllocatorCallback* inFoundation , uint32_t inBufferFullAmount , const TContextProvider& inProvider , TMutexType* inBufferMutex , const TEventFilterType& inEventFilter) : TBaseType(inFoundation, inBufferFullAmount, inBufferMutex, "struct physx::profile::ProfileEvent") , mContextProvider(inProvider) , mEventFilter(inEventFilter) , mReserved(0) , mWritten(0) { } TContextProvider& getContextProvider() { return mContextProvider; } PX_FORCE_INLINE void startEvent(uint16_t inId, uint32_t threadId, uint64_t contextId, uint8_t cpuId, uint8_t threadPriority, uint64_t inTimestamp) { if (mEventFilter.isEventEnabled(inId)) { StartEvent theEvent; theEvent.init(threadId, contextId, cpuId, threadPriority, inTimestamp); doAddProfileEvent(inId, theEvent); } } PX_FORCE_INLINE void startEvent(uint16_t inId, uint64_t contextId) { PxProfileEventExecutionContext ctx(mContextProvider.getExecutionContext()); startEvent(inId, ctx.mThreadId, contextId, ctx.mCpuId, static_cast<uint8_t>(ctx.mThreadPriority), PxTime::getCurrentCounterValue()); } PX_FORCE_INLINE void startEvent(uint16_t inId, uint64_t contextId, uint32_t threadId) { startEvent(inId, threadId, contextId, 0, 0, PxTime::getCurrentCounterValue()); } PX_FORCE_INLINE void stopEvent(uint16_t inId, uint32_t threadId, uint64_t contextId, uint8_t cpuId, uint8_t threadPriority, uint64_t inTimestamp) { if (mEventFilter.isEventEnabled(inId)) { StopEvent theEvent; theEvent.init(threadId, contextId, cpuId, threadPriority, inTimestamp); doAddProfileEvent(inId, theEvent); } } PX_FORCE_INLINE void stopEvent(uint16_t inId, uint64_t contextId) { PxProfileEventExecutionContext ctx(mContextProvider.getExecutionContext()); stopEvent(inId, ctx.mThreadId, contextId, ctx.mCpuId, static_cast<uint8_t>(ctx.mThreadPriority), PxTime::getCurrentCounterValue()); } PX_FORCE_INLINE void stopEvent(uint16_t inId, uint64_t contextId, uint32_t threadId) { stopEvent(inId, threadId, contextId, 0, 0, PxTime::getCurrentCounterValue()); } inline void eventValue(uint16_t inId, uint64_t contextId, int64_t inValue) { eventValue(inId, mContextProvider.getThreadId(), contextId, inValue); } inline void eventValue(uint16_t inId, uint32_t threadId, uint64_t contextId, int64_t inValue) { EventValue theEvent; theEvent.init(inValue, contextId, threadId); EventHeader theHeader(static_cast<uint8_t>(getEventType<EventValue>()), inId); //set the header relative timestamp; EventValue& theType(theEvent); theType.setupHeader(theHeader); int32_t sizeToWrite = int32_t(sizeof(theHeader) + theType.getEventSize(theHeader)); int32_t reserved = PxAtomicAdd(&mReserved, sizeToWrite); sendEvent(theHeader, theType, reserved, sizeToWrite); } void flushProfileEvents(int32_t reserved = -1) { TScopedLockType lock(TBaseType::mBufferMutex); // set the buffer full to lock additional writes int32_t reservedOld = PxAtomicExchange(&mReserved, int32_t(TBaseType::mBufferFullAmount + 1)); if (reserved == -1) reserved = reservedOld; // spin till we have written all the data while (reserved > mWritten) { } // check if we have written all data PX_ASSERT(reserved == mWritten); // set the correct size of the serialization data buffer TBaseType::mSerializer.mArray->setEnd(TBaseType::mSerializer.mArray->begin() + mWritten); // flush events TBaseType::flushEvents(); // write master timestamp and set reserved/written to start writing to buffer again mWritten = 0; mReserved = 0; } void release() { PX_PROFILE_DELETE(TBaseType::mWrapper.mUserFoundation, this); } protected: //Clears the cache meaning event compression //starts over again. //only called when the buffer mutex is held void clearCachedData() { } template<typename TProfileEventType> PX_FORCE_INLINE void doAddProfileEvent(uint16_t eventId, const TProfileEventType& inType) { doAddEvent(static_cast<uint8_t>(getEventType<TProfileEventType>()), eventId, inType); } template<typename TDataType> PX_FORCE_INLINE void doAddEvent(uint8_t inEventType, uint16_t eventId, const TDataType& inType) { EventHeader theHeader(inEventType, eventId); TDataType& theType(const_cast<TDataType&>(inType)); theType.setupHeader(theHeader, 0); const int32_t sizeToWrite = int32_t(sizeof(theHeader) + theType.getEventSize(theHeader)); int32_t reserved = PxAtomicAdd(&mReserved, sizeToWrite); sendEvent(theHeader, theType, reserved, sizeToWrite); } template<typename TDataType> PX_FORCE_INLINE void sendEvent(EventHeader& inHeader, TDataType& inType, int32_t reserved, int32_t sizeToWrite) { // if we don't fit to the buffer, we wait till it is flushed if (reserved - sizeToWrite >= int32_t(TBaseType::mBufferFullAmount)) { while (reserved - sizeToWrite >= int32_t(TBaseType::mBufferFullAmount)) { // I32 overflow if (mReserved < int32_t(TBaseType::mBufferFullAmount)) { reserved = PxAtomicAdd(&mReserved, sizeToWrite); } } } int32_t writeIndex = reserved - sizeToWrite; uint32_t writtenSize = 0; PX_ASSERT(writeIndex >= 0); PX_ALLOCA(tempBuffer, uint8_t, sizeToWrite); TempMemoryBuffer memoryBuffer(tempBuffer, sizeToWrite); EventSerializer<TempMemoryBuffer> eventSerializer(&memoryBuffer); writtenSize = inHeader.streamify(eventSerializer); writtenSize += inType.streamify(eventSerializer, inHeader); TBaseType::mSerializer.mArray->reserve(writeIndex + writtenSize); TBaseType::mSerializer.mArray->write(&tempBuffer[0], writtenSize, writeIndex); PX_ASSERT(writtenSize == uint32_t(sizeToWrite)); PxAtomicAdd(&mWritten, sizeToWrite); if (reserved >= int32_t(TBaseType::mBufferFullAmount)) { TScopedLockType lock(TBaseType::mBufferMutex); // we flush the buffer if its full and we did not flushed him in the meantime if(mReserved >= reserved) flushProfileEvents(reserved); } } }; } } #endif
13,175
C
40.564669
149
0.734801
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdMemClient.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_PVD_MEM_CLIENT_H #define PX_PVD_MEM_CLIENT_H #include "PxPvdClient.h" #include "foundation/PxHashMap.h" #include "foundation/PxMutex.h" #include "foundation/PxBroadcast.h" #include "PxProfileEventBufferClient.h" #include "PxProfileMemory.h" namespace physx { class PvdDataStream; namespace pvdsdk { class PvdImpl; class PvdMemClient : public PvdClient, public profile::PxProfileEventBufferClient, public PxUserAllocated { PX_NOCOPY(PvdMemClient) public: PvdMemClient(PvdImpl& pvd); virtual ~PvdMemClient(); bool isConnected() const; void onPvdConnected(); void onPvdDisconnected(); void flush(); PvdDataStream* getDataStream(); void sendMemEvents(); // memory event void onAllocation(size_t size, const char* typeName, const char* filename, int line, void* allocatedMemory); void onDeallocation(void* addr); private: PvdImpl& mSDKPvd; PvdDataStream* mPvdDataStream; bool mIsConnected; // mem profile PxMutex mMutex; // mem onallocation can called from different threads profile::PxProfileMemoryEventBuffer& mMemEventBuffer; void handleBufferFlush(const uint8_t* inData, uint32_t inLength); void handleClientRemoved(); }; } // namespace pvdsdk } // namespace physx #endif
2,973
C
34.831325
109
0.753448
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdObjectModelInternalTypeDefs.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. #define THERE_IS_NO_INCLUDE_GUARD_HERE_FOR_A_REASON DECLARE_INTERNAL_PVD_TYPE(ArrayData) #undef THERE_IS_NO_INCLUDE_GUARD_HERE_FOR_A_REASON
1,705
C
52.312498
74
0.770674
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdMemClient.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #include "PxPvdImpl.h" #include "PxPvdMemClient.h" namespace physx { namespace pvdsdk { PvdMemClient::PvdMemClient(PvdImpl& pvd) : mSDKPvd(pvd) , mPvdDataStream(NULL) , mIsConnected(false) , mMemEventBuffer(profile::PxProfileMemoryEventBuffer::createMemoryEventBuffer(*gPvdAllocatorCallback)) { } PvdMemClient::~PvdMemClient() { mSDKPvd.removeClient(this); if(mMemEventBuffer.hasClients()) mPvdDataStream->destroyInstance(&mMemEventBuffer); mMemEventBuffer.release(); } PvdDataStream* PvdMemClient::getDataStream() { return mPvdDataStream; } bool PvdMemClient::isConnected() const { return mIsConnected; } void PvdMemClient::onPvdConnected() { if(mIsConnected) return; mIsConnected = true; mPvdDataStream = PvdDataStream::create(&mSDKPvd); mPvdDataStream->createInstance(&mMemEventBuffer); mMemEventBuffer.addClient(*this); } void PvdMemClient::onPvdDisconnected() { if(!mIsConnected) return; mIsConnected = false; flush(); mMemEventBuffer.removeClient(*this); mPvdDataStream->release(); mPvdDataStream = NULL; } void PvdMemClient::onAllocation(size_t inSize, const char* inType, const char* inFile, int inLine, void* inAddr) { mMutex.lock(); mMemEventBuffer.onAllocation(inSize, inType, inFile, inLine, inAddr); mMutex.unlock(); } void PvdMemClient::onDeallocation(void* inAddr) { mMutex.lock(); mMemEventBuffer.onDeallocation(inAddr); mMutex.unlock(); } void PvdMemClient::flush() { mMutex.lock(); mMemEventBuffer.flushProfileEvents(); mMutex.unlock(); } void PvdMemClient::handleBufferFlush(const uint8_t* inData, uint32_t inLength) { if(mPvdDataStream) mPvdDataStream->setPropertyValue(&mMemEventBuffer, "events", inData, inLength); } void PvdMemClient::handleClientRemoved() { } } // pvd } // physx
3,453
C++
27.783333
112
0.764263
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdMarshalling.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. #ifndef PX_PVD_MARSHALLING_H #define PX_PVD_MARSHALLING_H #include "foundation/PxMathIntrinsics.h" #include "PxPvdObjectModelBaseTypes.h" #include "PxPvdBits.h" namespace physx { namespace pvdsdk { // Define marshalling template <typename TSmallerType, typename TLargerType> struct PvdMarshalling { bool canMarshal; PvdMarshalling() : canMarshal(false) { } }; template <typename smtype, typename lgtype> static inline void marshalSingleT(const uint8_t* srcData, uint8_t* destData) { smtype incoming; physx::intrinsics::memCopy(&incoming, srcData, sizeof(smtype)); lgtype outgoing = static_cast<lgtype>(incoming); physx::intrinsics::memCopy(destData, &outgoing, sizeof(lgtype)); } template <typename smtype, typename lgtype> static inline void marshalBlockT(const uint8_t* srcData, uint8_t* destData, uint32_t numBytes) { for(const uint8_t* item = srcData, *end = srcData + numBytes; item < end; item += sizeof(smtype), destData += sizeof(lgtype)) marshalSingleT<smtype, lgtype>(item, destData); } #define PVD_TYPE_MARSHALLER(smtype, lgtype) \ template <> \ struct PvdMarshalling<smtype, lgtype> \ { \ uint32_t canMarshal; \ static void marshalSingle(const uint8_t* srcData, uint8_t* destData) \ { \ marshalSingleT<smtype, lgtype>(srcData, destData); \ } \ static void marshalBlock(const uint8_t* srcData, uint8_t* destData, uint32_t numBytes) \ { \ marshalBlockT<smtype, lgtype>(srcData, destData, numBytes); \ } \ }; // define marshalling tables. PVD_TYPE_MARSHALLER(int8_t, int16_t) PVD_TYPE_MARSHALLER(int8_t, uint16_t) PVD_TYPE_MARSHALLER(int8_t, int32_t) PVD_TYPE_MARSHALLER(int8_t, uint32_t) PVD_TYPE_MARSHALLER(int8_t, int64_t) PVD_TYPE_MARSHALLER(int8_t, uint64_t) PVD_TYPE_MARSHALLER(int8_t, PvdF32) PVD_TYPE_MARSHALLER(int8_t, PvdF64) PVD_TYPE_MARSHALLER(uint8_t, int16_t) PVD_TYPE_MARSHALLER(uint8_t, uint16_t) PVD_TYPE_MARSHALLER(uint8_t, int32_t) PVD_TYPE_MARSHALLER(uint8_t, uint32_t) PVD_TYPE_MARSHALLER(uint8_t, int64_t) PVD_TYPE_MARSHALLER(uint8_t, uint64_t) PVD_TYPE_MARSHALLER(uint8_t, PvdF32) PVD_TYPE_MARSHALLER(uint8_t, PvdF64) PVD_TYPE_MARSHALLER(int16_t, int32_t) PVD_TYPE_MARSHALLER(int16_t, uint32_t) PVD_TYPE_MARSHALLER(int16_t, int64_t) PVD_TYPE_MARSHALLER(int16_t, uint64_t) PVD_TYPE_MARSHALLER(int16_t, PvdF32) PVD_TYPE_MARSHALLER(int16_t, PvdF64) PVD_TYPE_MARSHALLER(uint16_t, int32_t) PVD_TYPE_MARSHALLER(uint16_t, uint32_t) PVD_TYPE_MARSHALLER(uint16_t, int64_t) PVD_TYPE_MARSHALLER(uint16_t, uint64_t) PVD_TYPE_MARSHALLER(uint16_t, PvdF32) PVD_TYPE_MARSHALLER(uint16_t, PvdF64) PVD_TYPE_MARSHALLER(int32_t, int64_t) PVD_TYPE_MARSHALLER(int32_t, uint64_t) PVD_TYPE_MARSHALLER(int32_t, PvdF64) PVD_TYPE_MARSHALLER(int32_t, PvdF32) PVD_TYPE_MARSHALLER(uint32_t, int64_t) PVD_TYPE_MARSHALLER(uint32_t, uint64_t) PVD_TYPE_MARSHALLER(uint32_t, PvdF64) PVD_TYPE_MARSHALLER(uint32_t, PvdF32) PVD_TYPE_MARSHALLER(PvdF32, PvdF64) PVD_TYPE_MARSHALLER(PvdF32, uint32_t) PVD_TYPE_MARSHALLER(PvdF32, int32_t) PVD_TYPE_MARSHALLER(uint64_t, PvdF64) PVD_TYPE_MARSHALLER(int64_t, PvdF64) PVD_TYPE_MARSHALLER(PvdF64, uint64_t) PVD_TYPE_MARSHALLER(PvdF64, int64_t) template <typename TMarshaller> static inline bool getMarshalOperators(TSingleMarshaller&, TBlockMarshaller&, TMarshaller&, bool) { return false; } template <typename TMarshaller> static inline bool getMarshalOperators(TSingleMarshaller& single, TBlockMarshaller& block, TMarshaller&, uint32_t) { single = TMarshaller::marshalSingle; block = TMarshaller::marshalBlock; return true; } template <typename smtype, typename lgtype> static inline bool getMarshalOperators(TSingleMarshaller& single, TBlockMarshaller& block) { single = NULL; block = NULL; PvdMarshalling<smtype, lgtype> marshaller = PvdMarshalling<smtype, lgtype>(); return getMarshalOperators(single, block, marshaller, marshaller.canMarshal); } template <typename smtype> static inline bool getMarshalOperators(TSingleMarshaller& single, TBlockMarshaller& block, int32_t lgtypeId) { switch(lgtypeId) { case PvdBaseType::PvdI8: // int8_t: return getMarshalOperators<smtype, int8_t>(single, block); case PvdBaseType::PvdU8: // uint8_t: return getMarshalOperators<smtype, uint8_t>(single, block); case PvdBaseType::PvdI16: // int16_t: return getMarshalOperators<smtype, int16_t>(single, block); case PvdBaseType::PvdU16: // uint16_t: return getMarshalOperators<smtype, uint16_t>(single, block); case PvdBaseType::PvdI32: // int32_t: return getMarshalOperators<smtype, int32_t>(single, block); case PvdBaseType::PvdU32: // uint32_t: return getMarshalOperators<smtype, uint32_t>(single, block); case PvdBaseType::PvdI64: // int64_t: return getMarshalOperators<smtype, int64_t>(single, block); case PvdBaseType::PvdU64: // uint64_t: return getMarshalOperators<smtype, uint64_t>(single, block); case PvdBaseType::PvdF32: return getMarshalOperators<smtype, PvdF32>(single, block); case PvdBaseType::PvdF64: return getMarshalOperators<smtype, PvdF64>(single, block); } return false; } static inline bool getMarshalOperators(TSingleMarshaller& single, TBlockMarshaller& block, int32_t smtypeId, int32_t lgtypeId) { switch(smtypeId) { case PvdBaseType::PvdI8: // int8_t: return getMarshalOperators<int8_t>(single, block, lgtypeId); case PvdBaseType::PvdU8: // uint8_t: return getMarshalOperators<uint8_t>(single, block, lgtypeId); case PvdBaseType::PvdI16: // int16_t: return getMarshalOperators<int16_t>(single, block, lgtypeId); case PvdBaseType::PvdU16: // uint16_t: return getMarshalOperators<uint16_t>(single, block, lgtypeId); case PvdBaseType::PvdI32: // int32_t: return getMarshalOperators<int32_t>(single, block, lgtypeId); case PvdBaseType::PvdU32: // uint32_t: return getMarshalOperators<uint32_t>(single, block, lgtypeId); case PvdBaseType::PvdI64: // int64_t: return getMarshalOperators<int64_t>(single, block, lgtypeId); case PvdBaseType::PvdU64: // uint64_t: return getMarshalOperators<uint64_t>(single, block, lgtypeId); case PvdBaseType::PvdF32: return getMarshalOperators<PvdF32>(single, block, lgtypeId); case PvdBaseType::PvdF64: return getMarshalOperators<PvdF64>(single, block, lgtypeId); } return false; } } } #endif
8,876
C
39.167421
120
0.666629
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxProfileEventSerialization.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_PROFILE_EVENT_SERIALIZATION_H #define PX_PROFILE_EVENT_SERIALIZATION_H #include "PxProfileDataParsing.h" #include "PxProfileEvents.h" namespace physx { namespace profile { /** * Array type must be a pxu8 container. Templated so that this object can write * to different collections. */ template<typename TArrayType> struct EventSerializer { TArrayType* mArray; EventSerializer( TArrayType* inA ) : mArray( inA ) {} template<typename TDataType> uint32_t streamify( const char*, const TDataType& inType ) { return mArray->write( inType ); } uint32_t streamify( const char*, const char*& inType ) { PX_ASSERT( inType != NULL ); uint32_t len( static_cast<uint32_t>( strlen( inType ) ) ); ++len; //include the null terminator uint32_t writtenSize = 0; writtenSize = mArray->write(len); writtenSize += mArray->write(inType, len); return writtenSize; } uint32_t streamify( const char*, const uint8_t* inData, uint32_t len ) { uint32_t writtenSize = mArray->write(len); if ( len ) writtenSize += mArray->write(inData, len); return writtenSize; } uint32_t streamify( const char* nm, const uint64_t& inType, EventStreamCompressionFlags::Enum inFlags ) { uint32_t writtenSize = 0; switch( inFlags ) { case EventStreamCompressionFlags::U8: writtenSize = streamify(nm, static_cast<uint8_t>(inType)); break; case EventStreamCompressionFlags::U16: writtenSize = streamify(nm, static_cast<uint16_t>(inType)); break; case EventStreamCompressionFlags::U32: writtenSize = streamify(nm, static_cast<uint32_t>(inType)); break; case EventStreamCompressionFlags::U64: writtenSize = streamify(nm, inType); break; } return writtenSize; } uint32_t streamify( const char* nm, const uint32_t& inType, EventStreamCompressionFlags::Enum inFlags ) { uint32_t writtenSize = 0; switch( inFlags ) { case EventStreamCompressionFlags::U8: writtenSize = streamify(nm, static_cast<uint8_t>(inType)); break; case EventStreamCompressionFlags::U16: writtenSize = streamify(nm, static_cast<uint16_t>(inType)); break; case EventStreamCompressionFlags::U32: case EventStreamCompressionFlags::U64: writtenSize = streamify(nm, inType); break; } return writtenSize; } }; /** * The event deserializes takes a buffer implements the streamify functions * by setting the passed in data to the data in the buffer. */ template<bool TSwapBytes> struct EventDeserializer { const uint8_t* mData; uint32_t mLength; bool mFail; EventDeserializer( const uint8_t* inData, uint32_t inLength ) : mData( inData ) , mLength( inLength ) , mFail( false ) { if ( mData == NULL ) mLength = 0; } bool val() { return TSwapBytes; } uint32_t streamify( const char* , uint8_t& inType ) { uint8_t* theData = reinterpret_cast<uint8_t*>( &inType ); //type punned pointer... if ( mFail || sizeof( inType ) > mLength ) { PX_ASSERT( false ); mFail = true; } else { for( uint32_t idx = 0; idx < sizeof( uint8_t ); ++idx, ++mData, --mLength ) theData[idx] = *mData; } return 0; } //default streamify reads things natively as bytes. template<typename TDataType> uint32_t streamify( const char* , TDataType& inType ) { uint8_t* theData = reinterpret_cast<uint8_t*>( &inType ); //type punned pointer... if ( mFail || sizeof( inType ) > mLength ) { PX_ASSERT( false ); mFail = true; } else { for( uint32_t idx = 0; idx < sizeof( TDataType ); ++idx, ++mData, --mLength ) theData[idx] = *mData; bool temp = val(); if ( temp ) BlockParseFunctions::swapBytes<sizeof(TDataType)>( theData ); } return 0; } uint32_t streamify( const char*, const char*& inType ) { uint32_t theLen; streamify( "", theLen ); theLen = PxMin( theLen, mLength ); inType = reinterpret_cast<const char*>( mData ); mData += theLen; mLength -= theLen; return 0; } uint32_t streamify( const char*, const uint8_t*& inData, uint32_t& len ) { uint32_t theLen; streamify( "", theLen ); theLen = PxMin( theLen, mLength ); len = theLen; inData = reinterpret_cast<const uint8_t*>( mData ); mData += theLen; mLength -= theLen; return 0; } uint32_t streamify( const char* nm, uint64_t& inType, EventStreamCompressionFlags::Enum inFlags ) { switch( inFlags ) { case EventStreamCompressionFlags::U8: { uint8_t val=0; streamify( nm, val ); inType = val; } break; case EventStreamCompressionFlags::U16: { uint16_t val; streamify( nm, val ); inType = val; } break; case EventStreamCompressionFlags::U32: { uint32_t val; streamify( nm, val ); inType = val; } break; case EventStreamCompressionFlags::U64: streamify( nm, inType ); break; } return 0; } uint32_t streamify( const char* nm, uint32_t& inType, EventStreamCompressionFlags::Enum inFlags ) { switch( inFlags ) { case EventStreamCompressionFlags::U8: { uint8_t val=0; streamify( nm, val ); inType = val; } break; case EventStreamCompressionFlags::U16: { uint16_t val=0; streamify( nm, val ); inType = val; } break; case EventStreamCompressionFlags::U32: case EventStreamCompressionFlags::U64: streamify( nm, inType ); break; } return 0; } }; }} #endif
7,248
C
27.206226
105
0.66984
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdImpl.cpp
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #include "PxPvdImpl.h" #include "PxPvdMemClient.h" #include "PxPvdProfileZoneClient.h" #include "PxPvdProfileZone.h" #if PX_SUPPORT_GPU_PHYSX #include "gpu/PxGpu.h" #endif #if PX_NVTX #include "nvToolsExt.h" #endif namespace { const char* gSdkName = "PhysXSDK"; } namespace physx { namespace pvdsdk { class CmEventNameProvider : public physx::profile::PxProfileNameProvider { public: physx::profile::PxProfileNames getProfileNames() const { physx::profile::PxProfileNames ret; ret.eventCount = 0; return ret; } }; CmEventNameProvider gProfileNameProvider; void initializeModelTypes(PvdDataStream& stream) { stream.createClass<profile::PxProfileZone>(); stream.createProperty<profile::PxProfileZone, uint8_t>( "events", PvdCommStreamEmbeddedTypes::getProfileEventStreamSemantic(), PropertyType::Array); stream.createClass<profile::PxProfileMemoryEventBuffer>(); stream.createProperty<profile::PxProfileMemoryEventBuffer, uint8_t>( "events", PvdCommStreamEmbeddedTypes::getMemoryEventStreamSemantic(), PropertyType::Array); stream.createClass<PvdUserRenderer>(); stream.createProperty<PvdUserRenderer, uint8_t>( "events", PvdCommStreamEmbeddedTypes::getRendererEventStreamSemantic(), PropertyType::Array); } PvdImpl* PvdImpl::sInstance = NULL; uint32_t PvdImpl::sRefCount = 0; PvdImpl::PvdImpl() : mPvdTransport(NULL) , mSharedMetaProvider(NULL) , mMemClient(NULL) , mIsConnected(false) , mGPUProfilingWasConnected(false) , mIsNVTXSupportEnabled(true) , mNVTXContext(0) , mNextStreamId(1) , mProfileClient(NULL) , mProfileZone(NULL) { mProfileZoneManager = &physx::profile::PxProfileZoneManager::createProfileZoneManager(PxGetBroadcastAllocator()); mProfileClient = PVD_NEW(PvdProfileZoneClient)(*this); } PvdImpl::~PvdImpl() { if((mFlags & PxPvdInstrumentationFlag::ePROFILE) ) { PxSetProfilerCallback(NULL); #if PX_SUPPORT_GPU_PHYSX if (mGPUProfilingWasConnected) { PxSetPhysXGpuProfilerCallback(NULL); } #endif } disconnect(); if ( mProfileZoneManager ) { mProfileZoneManager->release(); mProfileZoneManager = NULL; } PVD_DELETE(mProfileClient); mProfileClient = NULL; } bool PvdImpl::connect(PxPvdTransport& transport, PxPvdInstrumentationFlags flags) { if(mIsConnected) { PxGetFoundation().error(PxErrorCode::eINVALID_PARAMETER, PX_FL, "PxPvd::connect - recall connect! Should call disconnect before re-connect."); return false; } mFlags = flags; mPvdTransport = &transport; mIsConnected = mPvdTransport->connect(); if(mIsConnected) { mSharedMetaProvider = PVD_NEW(MetaDataProvider); sendTransportInitialization(); PvdDataStream* stream = PvdDataStream::create(this); initializeModelTypes(*stream); stream->release(); if(mFlags & PxPvdInstrumentationFlag::eMEMORY) { mMemClient = PVD_NEW(PvdMemClient)(*this); mPvdClients.pushBack(mMemClient); } if((mFlags & PxPvdInstrumentationFlag::ePROFILE) && mProfileZoneManager) { mPvdClients.pushBack(mProfileClient); mProfileZone = &physx::profile::PxProfileZone::createProfileZone(PxGetBroadcastAllocator(),gSdkName,gProfileNameProvider.getProfileNames()); } for(uint32_t i = 0; i < mPvdClients.size(); i++) mPvdClients[i]->onPvdConnected(); if (mProfileZone) { mProfileZoneManager->addProfileZoneHandler(*mProfileClient); mProfileZoneManager->addProfileZone( *mProfileZone ); } if ((mFlags & PxPvdInstrumentationFlag::ePROFILE)) { PxSetProfilerCallback(this); #if PX_SUPPORT_GPU_PHYSX PxSetPhysXGpuProfilerCallback(this); mGPUProfilingWasConnected = true; #endif } } return mIsConnected; } void PvdImpl::disconnect() { if(mProfileZone) { mProfileZoneManager->removeProfileZoneHandler(*mProfileClient); mProfileZoneManager->removeProfileZone( *mProfileZone ); mProfileZone->release(); mProfileZone=NULL; removeClient(mProfileClient); } if(mIsConnected) { for(uint32_t i = 0; i < mPvdClients.size(); i++) mPvdClients[i]->onPvdDisconnected(); if(mMemClient) { removeClient(mMemClient); PvdMemClient* tmp = mMemClient; //avoid tracking deallocation itsself mMemClient = NULL; PVD_DELETE(tmp); } mSharedMetaProvider->release(); mPvdTransport->disconnect(); mObjectRegistrar.clear(); mIsConnected = false; } } void PvdImpl::flush() { for(uint32_t i = 0; i < mPvdClients.size(); i++) mPvdClients[i]->flush(); if ( mProfileZone ) { mProfileZone->flushEventIdNameMap(); mProfileZone->flushProfileEvents(); } } bool PvdImpl::isConnected(bool useCachedStatus) { if(mPvdTransport) return useCachedStatus ? mIsConnected : mPvdTransport->isConnected(); else return false; } PxPvdTransport* PvdImpl::getTransport() { return mPvdTransport; } PxPvdInstrumentationFlags PvdImpl::getInstrumentationFlags() { return mFlags; } void PvdImpl::sendTransportInitialization() { StreamInitialization init; EventStreamifier<PxPvdTransport> stream(mPvdTransport->lock()); init.serialize(stream); mPvdTransport->unlock(); } void PvdImpl::addClient(PvdClient* client) { PX_ASSERT(client); for(uint32_t i = 0; i < mPvdClients.size(); i++) { if(client == mPvdClients[i]) return; } mPvdClients.pushBack(client); if(mIsConnected) { client->onPvdConnected(); } } void PvdImpl::removeClient(PvdClient* client) { for(uint32_t i = 0; i < mPvdClients.size(); i++) { if(client == mPvdClients[i]) { client->onPvdDisconnected(); mPvdClients.remove(i); } } } void PvdImpl::onAllocation(size_t inSize, const char* inType, const char* inFile, int inLine, void* inAddr) { if(mMemClient) mMemClient->onAllocation(inSize, inType, inFile, inLine, inAddr); } void PvdImpl::onDeallocation(void* inAddr) { if(mMemClient) mMemClient->onDeallocation(inAddr); } PvdOMMetaDataProvider& PvdImpl::getMetaDataProvider() { return *mSharedMetaProvider; } bool PvdImpl::registerObject(const void* inItem) { return mObjectRegistrar.addItem(inItem); } bool PvdImpl::unRegisterObject(const void* inItem) { return mObjectRegistrar.decItem(inItem); } uint64_t PvdImpl::getNextStreamId() { uint64_t retval = ++mNextStreamId; return retval; } bool PvdImpl::initialize() { if(0 == sRefCount) { sInstance = PVD_NEW(PvdImpl)(); } ++sRefCount; return !!sInstance; } void PvdImpl::release() { if(sRefCount > 0) { if(--sRefCount) return; PVD_DELETE(sInstance); sInstance = NULL; } } PvdImpl* PvdImpl::getInstance() { return sInstance; } /************************************************************************************************************************** Instrumented profiling events ***************************************************************************************************************************/ static const uint32_t CrossThreadId = 99999789; void* PvdImpl::zoneStart(const char* eventName, bool detached, uint64_t contextId) { if(mProfileZone) { const uint16_t id = mProfileZone->getEventIdForName(eventName); if(detached) mProfileZone->startEvent(id, contextId, CrossThreadId); else mProfileZone->startEvent(id, contextId); } #if PX_NVTX if(mIsNVTXSupportEnabled) { if(detached) { // TODO : Need to use the nvtxRangeStart API for cross thread events nvtxEventAttributes_t eventAttrib; memset(&eventAttrib, 0, sizeof(eventAttrib)); eventAttrib.version = NVTX_VERSION; eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE; eventAttrib.colorType = NVTX_COLOR_ARGB; eventAttrib.color = 0xFF00FF00; eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII; eventAttrib.message.ascii = eventName; nvtxMarkEx(&eventAttrib); } else { nvtxRangePush(eventName); } } #endif return NULL; } void PvdImpl::zoneEnd(void* /*profilerData*/, const char* eventName, bool detached, uint64_t contextId) { if(mProfileZone) { const uint16_t id = mProfileZone->getEventIdForName(eventName); if(detached) mProfileZone->stopEvent(id, contextId, CrossThreadId); else mProfileZone->stopEvent(id, contextId); } #if PX_NVTX if(mIsNVTXSupportEnabled) { if(detached) { nvtxEventAttributes_t eventAttrib; memset(&eventAttrib, 0, sizeof(eventAttrib)); eventAttrib.version = NVTX_VERSION; eventAttrib.size = NVTX_EVENT_ATTRIB_STRUCT_SIZE; eventAttrib.colorType = NVTX_COLOR_ARGB; eventAttrib.color = 0xFFFF0000; eventAttrib.messageType = NVTX_MESSAGE_TYPE_ASCII; eventAttrib.message.ascii = eventName; nvtxMarkEx(&eventAttrib); } else { nvtxRangePop(); } } #endif } } // pvd } // physx
10,222
C++
23.753027
144
0.7207
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdDefaultFileTransport.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. // Copyright (c) 2001-2004 NovodeX AG. All rights reserved. #ifndef PX_PVD_DEFAULT_FILE_TRANSPORT_H #define PX_PVD_DEFAULT_FILE_TRANSPORT_H #include "pvd/PxPvdTransport.h" #include "foundation/PxUserAllocated.h" #include "PsFileBuffer.h" #include "foundation/PxMutex.h" namespace physx { namespace pvdsdk { class PvdDefaultFileTransport : public physx::PxPvdTransport, public physx::PxUserAllocated { PX_NOCOPY(PvdDefaultFileTransport) public: PvdDefaultFileTransport(const char* name); virtual ~PvdDefaultFileTransport(); virtual bool connect(); virtual void disconnect(); virtual bool isConnected(); virtual bool write(const uint8_t* inBytes, uint32_t inLength); virtual PxPvdTransport& lock(); virtual void unlock(); virtual void flush(); virtual uint64_t getWrittenDataSize(); virtual void release(); private: physx::PsFileBuffer* mFileBuffer; bool mConnected; uint64_t mWrittenData; physx::PxMutex mMutex; bool mLocked; // for debug, remove it when finished }; } // pvdsdk } // physx #endif
2,667
C
33.205128
91
0.764154
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxProfileContextProvider.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. #ifndef PX_PROFILE_CONTEXT_PROVIDER_H #define PX_PROFILE_CONTEXT_PROVIDER_H #include "foundation/Px.h" namespace physx { namespace profile { struct PxProfileEventExecutionContext { uint32_t mThreadId; uint8_t mCpuId; uint8_t mThreadPriority; PxProfileEventExecutionContext( uint32_t inThreadId = 0, uint8_t inThreadPriority = 2 /*eThreadPriorityNormal*/, uint8_t inCpuId = 0 ) : mThreadId( inThreadId ) , mCpuId( inCpuId ) , mThreadPriority( inThreadPriority ) { } bool operator==( const PxProfileEventExecutionContext& inOther ) const { return mThreadId == inOther.mThreadId && mCpuId == inOther.mCpuId && mThreadPriority == inOther.mThreadPriority; } }; } } #endif
2,290
C
37.830508
136
0.750655
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdObjectModelMetaData.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. #ifndef PX_PVD_OBJECT_MODEL_METADATA_H #define PX_PVD_OBJECT_MODEL_METADATA_H #include "foundation/PxAssert.h" #include "PxPvdObjectModelBaseTypes.h" #include "PxPvdBits.h" namespace physx { namespace pvdsdk { class PvdInputStream; class PvdOutputStream; struct PropertyDescription { NamespacedName mOwnerClassName; int32_t mOwnerClassId; String mName; String mSemantic; // The datatype this property corresponds to. int32_t mDatatype; // The name of the datatype NamespacedName mDatatypeName; // Scalar or array. PropertyType::Enum mPropertyType; // No other property under any class has this id, it is DB-unique. int32_t mPropertyId; // Offset in bytes into the object's data section where this property starts. uint32_t m32BitOffset; // Offset in bytes into the object's data section where this property starts. uint32_t m64BitOffset; PropertyDescription(const NamespacedName& clsName, int32_t classId, String name, String semantic, int32_t datatype, const NamespacedName& datatypeName, PropertyType::Enum propType, int32_t propId, uint32_t offset32, uint32_t offset64) : mOwnerClassName(clsName) , mOwnerClassId(classId) , mName(name) , mSemantic(semantic) , mDatatype(datatype) , mDatatypeName(datatypeName) , mPropertyType(propType) , mPropertyId(propId) , m32BitOffset(offset32) , m64BitOffset(offset64) { } PropertyDescription() : mOwnerClassId(-1) , mName("") , mSemantic("") , mDatatype(-1) , mPropertyType(PropertyType::Unknown) , mPropertyId(-1) , m32BitOffset(0) , m64BitOffset(0) { } virtual ~PropertyDescription() { } }; struct PtrOffsetType { enum Enum { UnknownOffset, VoidPtrOffset, StringOffset }; }; struct PtrOffset { PtrOffsetType::Enum mOffsetType; uint32_t mOffset; PtrOffset(PtrOffsetType::Enum type, uint32_t offset) : mOffsetType(type), mOffset(offset) { } PtrOffset() : mOffsetType(PtrOffsetType::UnknownOffset), mOffset(0) { } }; inline uint32_t align(uint32_t offset, uint32_t alignment) { uint32_t startOffset = offset; uint32_t alignmentMask = ~(alignment - 1); offset = (offset + alignment - 1) & alignmentMask; PX_ASSERT(offset >= startOffset && (offset % alignment) == 0); (void)startOffset; return offset; } struct ClassDescriptionSizeInfo { // The size of the data section of this object, padded to alignment. uint32_t mByteSize; // The last data member goes to here. uint32_t mDataByteSize; // Alignment in bytes of the data section of this object. uint32_t mAlignment; // the offsets of string handles in the binary value of this class DataRef<PtrOffset> mPtrOffsets; ClassDescriptionSizeInfo() : mByteSize(0), mDataByteSize(0), mAlignment(0) { } }; struct ClassDescription { NamespacedName mName; // No other class has this id, it is DB-unique int32_t mClassId; // Only single derivation supported. int32_t mBaseClass; // If this class has properties that are of uniform type, then we note that. // This means that when deserialization an array of these objects we can just use // single function to endian convert the entire mess at once. int32_t mPackedUniformWidth; // If this class is composed uniformly of members of a given type // Or all of its properties are composed uniformly of members of // a give ntype, then this class's packed type is that type. // PxTransform's packed type would be float. int32_t mPackedClassType; // 0: 32Bit 1: 64Bit ClassDescriptionSizeInfo mSizeInfo[2]; // No further property additions allowed. bool mLocked; // True when this datatype has an array on it that needs to be // separately deleted. bool mRequiresDestruction; ClassDescription(NamespacedName name, int32_t id) : mName(name) , mClassId(id) , mBaseClass(-1) , mPackedUniformWidth(-1) , mPackedClassType(-1) , mLocked(false) , mRequiresDestruction(false) { } ClassDescription() : mClassId(-1), mBaseClass(-1), mPackedUniformWidth(-1), mPackedClassType(-1), mLocked(false), mRequiresDestruction(false) { } virtual ~ClassDescription() { } ClassDescriptionSizeInfo& get32BitSizeInfo() { return mSizeInfo[0]; } ClassDescriptionSizeInfo& get64BitSizeInfo() { return mSizeInfo[1]; } uint32_t& get32BitSize() { return get32BitSizeInfo().mByteSize; } uint32_t& get64BitSize() { return get64BitSizeInfo().mByteSize; } uint32_t get32BitSize() const { return mSizeInfo[0].mByteSize; } const ClassDescriptionSizeInfo& getNativeSizeInfo() const { return mSizeInfo[(sizeof(void*) >> 2) - 1]; } uint32_t getNativeSize() const { return getNativeSizeInfo().mByteSize; } }; struct MarshalQueryResult { int32_t srcType; int32_t dstType; // If canMarshal != needsMarshalling we have a problem. bool canMarshal; bool needsMarshalling; // Non null if marshalling is possible. TBlockMarshaller marshaller; MarshalQueryResult(int32_t _srcType = -1, int32_t _dstType = -1, bool _canMarshal = false, bool _needs = false, TBlockMarshaller _m = NULL) : srcType(_srcType), dstType(_dstType), canMarshal(_canMarshal), needsMarshalling(_needs), marshaller(_m) { } }; struct PropertyMessageEntry { PropertyDescription mProperty; NamespacedName mDatatypeName; // datatype of the data in the message. int32_t mDatatypeId; // where in the message this property starts. uint32_t mMessageOffset; // size of this entry object uint32_t mByteSize; // If the chain of properties doesn't have any array properties this indicates the uint32_t mDestByteSize; PropertyMessageEntry(PropertyDescription propName, NamespacedName dtypeName, int32_t dtype, uint32_t messageOff, uint32_t byteSize, uint32_t destByteSize) : mProperty(propName) , mDatatypeName(dtypeName) , mDatatypeId(dtype) , mMessageOffset(messageOff) , mByteSize(byteSize) , mDestByteSize(destByteSize) { } PropertyMessageEntry() : mDatatypeId(-1), mMessageOffset(0), mByteSize(0), mDestByteSize(0) { } }; // Create a struct that defines a subset of the properties on an object. struct PropertyMessageDescription { NamespacedName mClassName; // No other class has this id, it is DB-unique int32_t mClassId; NamespacedName mMessageName; int32_t mMessageId; DataRef<PropertyMessageEntry> mProperties; uint32_t mMessageByteSize; // Offsets into the property message where const char* items are. DataRef<uint32_t> mStringOffsets; PropertyMessageDescription(const NamespacedName& nm, int32_t clsId, const NamespacedName& msgName, int32_t msgId, uint32_t msgSize) : mClassName(nm), mClassId(clsId), mMessageName(msgName), mMessageId(msgId), mMessageByteSize(msgSize) { } PropertyMessageDescription() : mClassId(-1), mMessageId(-1), mMessageByteSize(0) { } virtual ~PropertyMessageDescription() { } }; class StringTable { protected: virtual ~StringTable() { } public: virtual uint32_t getNbStrs() = 0; virtual uint32_t getStrs(const char** outStrs, uint32_t bufLen, uint32_t startIdx = 0) = 0; virtual const char* registerStr(const char* str, bool& outAdded) = 0; const char* registerStr(const char* str) { bool ignored; return registerStr(str, ignored); } virtual StringHandle strToHandle(const char* str) = 0; virtual const char* handleToStr(uint32_t hdl) = 0; virtual void release() = 0; static StringTable& create(); }; struct None { }; template <typename T> class Option { T mValue; bool mHasValue; public: Option(const T& val) : mValue(val), mHasValue(true) { } Option(None nothing = None()) : mHasValue(false) { (void)nothing; } Option(const Option& other) : mValue(other.mValue), mHasValue(other.mHasValue) { } Option& operator=(const Option& other) { mValue = other.mValue; mHasValue = other.mHasValue; return *this; } bool hasValue() const { return mHasValue; } const T& getValue() const { PX_ASSERT(hasValue()); return mValue; } T& getValue() { PX_ASSERT(hasValue()); return mValue; } operator const T&() const { return getValue(); } operator T&() { return getValue(); } T* operator->() { return &getValue(); } const T* operator->() const { return &getValue(); } }; /** * Create new classes and add properties to some existing ones. * The default classes are created already, the simple types * along with the basic math types. * (uint8_t, int8_t, etc ) * (PxVec3, PxQuat, PxTransform, PxMat33, PxMat34, PxMat44) */ class PvdObjectModelMetaData { protected: virtual ~PvdObjectModelMetaData() { } public: virtual ClassDescription getOrCreateClass(const NamespacedName& nm) = 0; // get or create parent, lock parent. deriveFrom getOrCreatechild. virtual bool deriveClass(const NamespacedName& parent, const NamespacedName& child) = 0; virtual Option<ClassDescription> findClass(const NamespacedName& nm) const = 0; template <typename TDataType> Option<ClassDescription> findClass() { return findClass(getPvdNamespacedNameForType<TDataType>()); } virtual Option<ClassDescription> getClass(int32_t classId) const = 0; virtual ClassDescription* getClassPtr(int32_t classId) const = 0; virtual Option<ClassDescription> getParentClass(int32_t classId) const = 0; bool isDerivedFrom(int32_t classId, int32_t parentClass) const { if(classId == parentClass) return true; ClassDescription* p = getClassPtr(getClassPtr(classId)->mBaseClass); while(p != NULL) { if(p->mClassId == parentClass) return true; p = getClassPtr(p->mBaseClass); } return false; } virtual void lockClass(int32_t classId) = 0; virtual uint32_t getNbClasses() const = 0; virtual uint32_t getClasses(ClassDescription* outClasses, uint32_t requestCount, uint32_t startIndex = 0) const = 0; // Create a nested property. // This way you can have obj.p.x without explicity defining the class p. virtual Option<PropertyDescription> createProperty(int32_t classId, String name, String semantic, int32_t datatype, PropertyType::Enum propertyType = PropertyType::Scalar) = 0; Option<PropertyDescription> createProperty(NamespacedName clsId, String name, String semantic, NamespacedName dtype, PropertyType::Enum propertyType = PropertyType::Scalar) { return createProperty(findClass(clsId)->mClassId, name, semantic, findClass(dtype)->mClassId, propertyType); } Option<PropertyDescription> createProperty(NamespacedName clsId, String name, NamespacedName dtype, PropertyType::Enum propertyType = PropertyType::Scalar) { return createProperty(findClass(clsId)->mClassId, name, "", findClass(dtype)->mClassId, propertyType); } Option<PropertyDescription> createProperty(int32_t clsId, String name, int32_t dtype, PropertyType::Enum propertyType = PropertyType::Scalar) { return createProperty(clsId, name, "", dtype, propertyType); } template <typename TDataType> Option<PropertyDescription> createProperty(int32_t clsId, String name, String semantic = "", PropertyType::Enum propertyType = PropertyType::Scalar) { return createProperty(clsId, name, semantic, getPvdNamespacedNameForType<TDataType>(), propertyType); } virtual Option<PropertyDescription> findProperty(const NamespacedName& cls, String prop) const = 0; virtual Option<PropertyDescription> findProperty(int32_t clsId, String prop) const = 0; virtual Option<PropertyDescription> getProperty(int32_t propId) const = 0; virtual void setNamedPropertyValues(DataRef<NamedValue> values, int32_t propId) = 0; // for enumerations and flags. virtual DataRef<NamedValue> getNamedPropertyValues(int32_t propId) const = 0; virtual uint32_t getNbProperties(int32_t classId) const = 0; virtual uint32_t getProperties(int32_t classId, PropertyDescription* outBuffer, uint32_t bufCount, uint32_t startIdx = 0) const = 0; // Does one cls id differ marshalling to another and if so return the functions to do it. virtual MarshalQueryResult checkMarshalling(int32_t srcClsId, int32_t dstClsId) const = 0; // messages and classes are stored in separate maps, so a property message can have the same name as a class. virtual Option<PropertyMessageDescription> createPropertyMessage(const NamespacedName& cls, const NamespacedName& msgName, DataRef<PropertyMessageArg> entries, uint32_t messageSize) = 0; virtual Option<PropertyMessageDescription> findPropertyMessage(const NamespacedName& msgName) const = 0; virtual Option<PropertyMessageDescription> getPropertyMessage(int32_t msgId) const = 0; virtual uint32_t getNbPropertyMessages() const = 0; virtual uint32_t getPropertyMessages(PropertyMessageDescription* msgBuf, uint32_t bufLen, uint32_t startIdx = 0) const = 0; virtual StringTable& getStringTable() const = 0; virtual void write(PvdOutputStream& stream) const = 0; void save(PvdOutputStream& stream) const { write(stream); } virtual void addRef() = 0; virtual void release() = 0; static uint32_t getCurrentPvdObjectModelVersion(); static PvdObjectModelMetaData& create(); static PvdObjectModelMetaData& create(PvdInputStream& stream); }; } } #endif
15,021
C
30.165975
123
0.721656
NVIDIA-Omniverse/PhysX/physx/source/pvd/src/PxPvdByteStreams.h
// Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // * Neither the name of NVIDIA CORPORATION nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // // Copyright (c) 2008-2023 NVIDIA Corporation. All rights reserved. #ifndef PX_PVD_BYTE_STREAMS_H #define PX_PVD_BYTE_STREAMS_H #include "PxPvdObjectModelBaseTypes.h" namespace physx { namespace pvdsdk { static inline uint32_t strLen(const char* inStr) { uint32_t len = 0; if(inStr) { while(*inStr) { ++len; ++inStr; } } return len; } class PvdInputStream { protected: virtual ~PvdInputStream() { } public: // Return false if you can't write the number of bytes requested // But make an absolute best effort to read the data... virtual bool read(uint8_t* buffer, uint32_t& len) = 0; template <typename TDataType> bool read(TDataType* buffer, uint32_t numItems) { uint32_t expected = numItems; uint32_t amountToRead = numItems * sizeof(TDataType); read(reinterpret_cast<uint8_t*>(buffer), amountToRead); numItems = amountToRead / sizeof(TDataType); PX_ASSERT(numItems == expected); return expected == numItems; } template <typename TDataType> PvdInputStream& operator>>(TDataType& data) { uint32_t dataSize = static_cast<uint32_t>(sizeof(TDataType)); bool success = read(reinterpret_cast<uint8_t*>(&data), dataSize); // PX_ASSERT( success ); // PX_ASSERT( dataSize == sizeof( data ) ); (void)success; return *this; } }; class PvdOutputStream { protected: virtual ~PvdOutputStream() { } public: // Return false if you can't write the number of bytes requested // But make an absolute best effort to write the data... virtual bool write(const uint8_t* buffer, uint32_t len) = 0; virtual bool directCopy(PvdInputStream& inStream, uint32_t len) = 0; template <typename TDataType> bool write(const TDataType* buffer, uint32_t numItems) { return write(reinterpret_cast<const uint8_t*>(buffer), numItems * sizeof(TDataType)); } template <typename TDataType> PvdOutputStream& operator<<(const TDataType& data) { bool success = write(reinterpret_cast<const uint8_t*>(&data), sizeof(data)); PX_ASSERT(success); (void)success; return *this; } PvdOutputStream& operator<<(const char* inString) { if(inString && *inString) { uint32_t len(strLen(inString)); write(inString, len); } return *this; } }; } } #endif
3,709
C
28.212598
87
0.72742