diff options
| author | git perforce import user <a@b> | 2016-10-25 12:29:14 -0600 |
|---|---|---|
| committer | Sheikh Dawood Abdul Ajees <Sheikh Dawood Abdul Ajees> | 2016-10-25 18:56:37 -0500 |
| commit | 3dfe2108cfab31ba3ee5527e217d0d8e99a51162 (patch) | |
| tree | fa6485c169e50d7415a651bf838f5bcd0fd3bfbd /PhysX_3.4/Source/SimulationController/include | |
| download | physx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.tar.xz physx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.zip | |
Initial commit:
PhysX 3.4.0 Update @ 21294896
APEX 1.4.0 Update @ 21275617
[CL 21300167]
Diffstat (limited to 'PhysX_3.4/Source/SimulationController/include')
15 files changed, 3181 insertions, 0 deletions
diff --git a/PhysX_3.4/Source/SimulationController/include/ScActorCore.h b/PhysX_3.4/Source/SimulationController/include/ScActorCore.h new file mode 100644 index 00000000..77c2e0b2 --- /dev/null +++ b/PhysX_3.4/Source/SimulationController/include/ScActorCore.h @@ -0,0 +1,137 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 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_COLLISION_ACTOR_CORE +#define PX_COLLISION_ACTOR_CORE + +#include "PsUserAllocated.h" +#include "CmPhysXCommon.h" +#include "PxMetaData.h" +#include "PxActor.h" + +namespace physx +{ + +class PxActor; + +namespace Sc +{ + + class Scene; + class ActorSim; + + class ActorCore : public Ps::UserAllocated + { + //= ATTENTION! ===================================================================================== + // Changing the data layout of this class breaks the binary serialization format. See comments for + // PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData + // function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION + // accordingly. + //================================================================================================== + public: +// PX_SERIALIZATION + ActorCore(const PxEMPTY) : mSim(NULL), mActorFlags(PxEmpty) + { + } + static void getBinaryMetaData(PxOutputStream& stream); +//~PX_SERIALIZATION + ActorCore(PxActorType::Enum actorType, PxU8 actorFlags, + PxClientID owner, PxU8 behavior, PxDominanceGroup dominanceGroup); + /*virtual*/ ~ActorCore(); + + PX_FORCE_INLINE ActorSim* getSim() const { return mSim; } + PX_FORCE_INLINE void setSim(ActorSim* sim) + { + PX_ASSERT((sim==NULL) ^ (mSim==NULL)); + mSim = sim; + } + + PX_FORCE_INLINE PxActorFlags getActorFlags() const { return mActorFlags; } + void setActorFlags(PxActorFlags af); + + PX_FORCE_INLINE PxDominanceGroup getDominanceGroup() const + { + return PxDominanceGroup(mDominanceGroup); + } + void setDominanceGroup(PxDominanceGroup g); + + PX_FORCE_INLINE void setOwnerClient(PxClientID inId) + { + const PxU32 aggid = mAggregateIDOwnerClient & 0x00ffffff; + mAggregateIDOwnerClient = (PxU32(inId)<<24) | aggid; + + } + PX_FORCE_INLINE PxClientID getOwnerClient() const + { + return mAggregateIDOwnerClient>>24; + } + + PX_FORCE_INLINE PxActorClientBehaviorFlags getClientBehaviorFlags() const { return mClientBehaviorFlags; } + PX_FORCE_INLINE void setClientBehaviorFlags(PxActorClientBehaviorFlags b) { mClientBehaviorFlags = b; } + + PX_FORCE_INLINE PxActorType::Enum getActorCoreType() const { return PxActorType::Enum(mActorType); } + + void reinsertShapes(); +// PX_AGGREGATE + PX_FORCE_INLINE void setAggregateID(PxU32 id) + { + PX_ASSERT(id==0xffffffff || id<(1<<24)); + const PxU32 ownerClient = mAggregateIDOwnerClient & 0xff000000; + mAggregateIDOwnerClient = (id & 0x00ffffff) | ownerClient; + } + PX_FORCE_INLINE PxU32 getAggregateID() const + { + const PxU32 id = mAggregateIDOwnerClient & 0x00ffffff; + return id == 0x00ffffff ? PX_INVALID_U32 : id; + } +//~PX_AGGREGATE + private: + ActorSim* mSim; // + PxU32 mAggregateIDOwnerClient; // PxClientID (8bit) | aggregate ID (24bit) + // PT: TODO: the remaining members could be packed into just a 16bit mask + PxActorFlags mActorFlags; // PxActor's flags (PxU8) => only 4 bits used + PxU8 mActorType; // Actor type (8 bits, but 3 would be enough) + PxActorClientBehaviorFlags mClientBehaviorFlags; // PxU8 => only 4 bits used + PxU8 mDominanceGroup; // Dominance group (8 bits, but 5 would be enough because "must be < 32") + }; + +#if PX_P64_FAMILY + PX_COMPILE_TIME_ASSERT(sizeof(Sc::ActorCore)==16); +#else + PX_COMPILE_TIME_ASSERT(sizeof(Sc::ActorCore)==12); +#endif + +} // namespace Sc + +} + +////////////////////////////////////////////////////////////////////////// + +#endif diff --git a/PhysX_3.4/Source/SimulationController/include/ScArticulationCore.h b/PhysX_3.4/Source/SimulationController/include/ScArticulationCore.h new file mode 100644 index 00000000..77f2285a --- /dev/null +++ b/PhysX_3.4/Source/SimulationController/include/ScArticulationCore.h @@ -0,0 +1,170 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 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_PHYSICS_SCP_ARTICULATION_CORE +#define PX_PHYSICS_SCP_ARTICULATION_CORE + +#include "ScActorCore.h" +#include "DyArticulation.h" + +namespace physx +{ + +class PxvArticulation; + +namespace IG +{ + class NodeIndex; +} + + +namespace Sc +{ + typedef Dy::FsData ArticulationDriveCache; + + class ArticulationSim; + class BodyCore; + + class ArticulationCore + { + //= ATTENTION! ===================================================================================== + // Changing the data layout of this class breaks the binary serialization format. See comments for + // PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData + // function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION + // accordingly. + //================================================================================================== + + //--------------------------------------------------------------------------------- + // Construction, destruction & initialization + //--------------------------------------------------------------------------------- + +// PX_SERIALIZATION + public: + ArticulationCore(const PxEMPTY) : mSim(NULL) {} + static void getBinaryMetaData(PxOutputStream& stream); +//~PX_SERIALIZATION + ArticulationCore(); + ~ArticulationCore(); + + //--------------------------------------------------------------------------------- + // External API + //--------------------------------------------------------------------------------- + PxU32 getInternalDriveIterations() const; + void setInternalDriveIterations(const PxU32 v); + + PxU32 getExternalDriveIterations() const; + void setExternalDriveIterations(const PxU32 v); + + PxU32 getMaxProjectionIterations() const; + void setMaxProjectionIterations(const PxU32 v); + + PxReal getSeparationTolerance() const; + void setSeparationTolerance(const PxReal v); + + PxReal getSleepThreshold() const; + void setSleepThreshold(const PxReal v); + + PxReal getFreezeThreshold() const; + void setFreezeThreshold(const PxReal v); + + PxReal getWakeCounter() const; + void setWakeCounter(const PxReal v); + void setWakeCounterInternal(const PxReal v); + + bool isSleeping() const; + void wakeUp(PxReal wakeCounter); + void putToSleep(); + + PxU16 getSolverIterationCounts() const; + void setSolverIterationCounts(PxU16 c); + + PxArticulation* getPxArticulation(); + const PxArticulation* getPxArticulation() const; + + + //--------------------------------------------------------------------------------- + // Drive Cache API + //--------------------------------------------------------------------------------- + ArticulationDriveCache* createDriveCache(PxReal compliance, + PxU32 driveIterations) const; + + void updateDriveCache(ArticulationDriveCache& cache, + PxReal compliance, + PxU32 driveIterations) const; + + void releaseDriveCache(ArticulationDriveCache& cache) const; + + PxU32 getCacheLinkCount(const ArticulationDriveCache& cache) const; + + void applyImpulse(BodyCore& link, + const ArticulationDriveCache& driveCache, + const PxVec3& force, + const PxVec3& torque); + + void computeImpulseResponse(BodyCore& link, + PxVec3& linearResponse, + PxVec3& angularResponse, + const ArticulationDriveCache& driveCache, + const PxVec3& force, + const PxVec3& torque) const; + + //--------------------------------------------------------------------------------- + // Internal API + //--------------------------------------------------------------------------------- + public: + PX_FORCE_INLINE void setSim(ArticulationSim* sim) + { + PX_ASSERT((sim==0) ^ (mSim == 0)); + mSim = sim; + } + PX_FORCE_INLINE ArticulationSim* getSim() const { return mSim; } + + PX_FORCE_INLINE const Dy::ArticulationCore& getCore() { return mCore; } + + static PX_FORCE_INLINE ArticulationCore& getArticulationCore(ArticulationCore& core) + { + size_t offset = PX_OFFSET_OF(ArticulationCore, mCore); + return *reinterpret_cast<ArticulationCore*>(reinterpret_cast<PxU8*>(&core) - offset); + } + + IG::NodeIndex getIslandNodeIndex() const; + + private: + ArticulationSim* mSim; + Dy::ArticulationCore mCore; + }; + + + +} // namespace Sc + +} + +#endif diff --git a/PhysX_3.4/Source/SimulationController/include/ScArticulationJointCore.h b/PhysX_3.4/Source/SimulationController/include/ScArticulationJointCore.h new file mode 100644 index 00000000..7572f5b0 --- /dev/null +++ b/PhysX_3.4/Source/SimulationController/include/ScArticulationJointCore.h @@ -0,0 +1,157 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 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_PHYSICS_SCP_ARTICULATION_JOINT_CORE +#define PX_PHYSICS_SCP_ARTICULATION_JOINT_CORE + +#include "foundation/PxTransform.h" +#include "CmPhysXCommon.h" +#include "PsUserAllocated.h" +#include "DyArticulation.h" +#include "PxMetaData.h" + +namespace physx +{ +namespace Sc +{ + + class BodyCore; + class ArticulationJointSim; + + class ArticulationJointDesc + { + public: + BodyCore* parent; + BodyCore* child; + PxTransform parentPose; + PxTransform childPose; + }; + + class ArticulationJointCore : public Ps::UserAllocated + { + //= ATTENTION! ===================================================================================== + // Changing the data layout of this class breaks the binary serialization format. See comments for + // PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData + // function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION + // accordingly. + //================================================================================================== + + //--------------------------------------------------------------------------------- + // Construction, destruction & initialization + //--------------------------------------------------------------------------------- + public: +// PX_SERIALIZATION + ArticulationJointCore(const PxEMPTY) : mSim(NULL), mCore(PxEmpty) {} + static void getBinaryMetaData(PxOutputStream& stream); +//~PX_SERIALIZATION + ArticulationJointCore(const PxTransform& parentFrame, + const PxTransform& childFrame); + + ~ArticulationJointCore(); + + //--------------------------------------------------------------------------------- + // External API + //--------------------------------------------------------------------------------- + + const PxTransform& getParentPose() const { return mCore.parentPose; } + void setParentPose(const PxTransform&); + + const PxTransform& getChildPose() const { return mCore.childPose; } + void setChildPose(const PxTransform&); + + const PxQuat& getTargetOrientation() const { return mCore.targetPosition; } + void setTargetOrientation(const PxQuat&); + + const PxVec3& getTargetVelocity() const { return mCore.targetVelocity; } + void setTargetVelocity(const PxVec3&); + + PxReal getStiffness() const { return mCore.spring; } + void setStiffness(PxReal); + + PxReal getDamping() const { return mCore.damping; } + void setDamping(PxReal); + + PxReal getInternalCompliance() const { return mCore.internalCompliance; } + void setInternalCompliance(PxReal); + + PxReal getExternalCompliance() const { return mCore.externalCompliance; } + void setExternalCompliance(PxReal); + + void getSwingLimit(PxReal& yLimit, PxReal& zLimit) const { yLimit = mCore.swingYLimit; zLimit = mCore.swingZLimit; } + void setSwingLimit(PxReal yLimit, PxReal zLimit); + + PxReal getTangentialStiffness() const { return mCore.tangentialStiffness; } + void setTangentialStiffness(PxReal); + + PxReal getTangentialDamping() const { return mCore.tangentialDamping; } + void setTangentialDamping(PxReal); + + bool getSwingLimitEnabled() const { return mCore.swingLimited; } + void setSwingLimitEnabled(bool); + + PxReal getSwingLimitContactDistance() const { return mCore.swingLimitContactDistance; } + void setSwingLimitContactDistance(PxReal); + + void getTwistLimit(PxReal& lower, PxReal& upper) const { lower = mCore.twistLimitLow; upper = mCore.twistLimitHigh; } + void setTwistLimit(PxReal lower, PxReal upper); + + bool getTwistLimitEnabled() const { return mCore.twistLimited; } + void setTwistLimitEnabled(bool); + + PxReal getTwistLimitContactDistance() const { return mCore.twistLimitContactDistance; } + void setTwistLimitContactDistance(PxReal); + + void setDriveType(PxArticulationJointDriveType::Enum type); + PxArticulationJointDriveType::Enum + getDriveType() const { return PxArticulationJointDriveType::Enum(mCore.driveType); } + + //--------------------------------------------------------------------------------- + // Low Level data access - some wouldn't be needed if the interface wasn't virtual + //--------------------------------------------------------------------------------- + + PX_FORCE_INLINE ArticulationJointSim* getSim() const { return mSim; } + PX_FORCE_INLINE void setSim(ArticulationJointSim* sim) + { + PX_ASSERT((sim==0) ^ (mSim == 0)); + mSim = sim; + } + + PX_FORCE_INLINE const Dy::ArticulationJointCore& getCore() { return mCore; } + + private: + ArticulationJointSim* mSim; + Dy::ArticulationJointCore mCore; + }; + +} // namespace Sc + +} + +#endif diff --git a/PhysX_3.4/Source/SimulationController/include/ScBodyCore.h b/PhysX_3.4/Source/SimulationController/include/ScBodyCore.h new file mode 100644 index 00000000..54fa5b38 --- /dev/null +++ b/PhysX_3.4/Source/SimulationController/include/ScBodyCore.h @@ -0,0 +1,213 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 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_PHYSICS_SCP_BODYCORE +#define PX_PHYSICS_SCP_BODYCORE + +#include "foundation/PxTransform.h" +#include "ScRigidCore.h" +#include "PxRigidDynamic.h" +#include "PxvDynamics.h" +#include "PxvConfig.h" +#include "PsPool.h" + +namespace physx +{ + +class PxRigidBodyDesc; + +namespace Sc +{ + class BodySim; + struct SimStateData; + + struct KinematicTransform + { + PxTransform targetPose; // The body will move to this pose over the superstep following this getting set. + PxU8 targetValid; // User set a kinematic target. + PxU8 pad[2]; + PxU8 type; + }; + + class BodyCore : public RigidCore + { + //= ATTENTION! ===================================================================================== + // Changing the data layout of this class breaks the binary serialization format. See comments for + // PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData + // function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION + // accordingly. + //================================================================================================== + + //--------------------------------------------------------------------------------- + // Construction, destruction & initialization + //--------------------------------------------------------------------------------- + public: +// PX_SERIALIZATION + BodyCore(const PxEMPTY) : RigidCore(PxEmpty), mCore(PxEmpty), mSimStateData(NULL) {} + static void getBinaryMetaData(PxOutputStream& stream); + void disableInternalCaching(bool disable); + size_t getSerialCore(PxsBodyCore& serialCore); +//~PX_SERIALIZATION + BodyCore(PxActorType::Enum type, const PxTransform& bodyPose); + /*virtual*/ ~BodyCore(); + + //--------------------------------------------------------------------------------- + // External API + //--------------------------------------------------------------------------------- + PX_FORCE_INLINE const PxTransform& getBody2World() const { return mCore.body2World; } + void setBody2World(const PxTransform& p); + + PX_FORCE_INLINE const PxVec3& getLinearVelocity() const { return mCore.linearVelocity; } + void setLinearVelocity(const PxVec3& v); + + PX_FORCE_INLINE const PxVec3& getAngularVelocity() const { return mCore.angularVelocity; } + void setAngularVelocity(const PxVec3& v); + + + PX_FORCE_INLINE void updateVelocities(const PxVec3& linearVelModPerStep, const PxVec3& angularVelModPerStep) + { + mCore.linearVelocity += linearVelModPerStep; + mCore.angularVelocity += angularVelModPerStep; + } + + PX_FORCE_INLINE const PxTransform& getBody2Actor() const { return mCore.getBody2Actor(); } + void setBody2Actor(const PxTransform& p); + + void addSpatialAcceleration(Ps::Pool<SimStateData>* simStateDataPool, const PxVec3* linAcc, const PxVec3* angAcc); + void clearSpatialAcceleration(bool force, bool torque); + void addSpatialVelocity(Ps::Pool<SimStateData>* simStateDataPool, const PxVec3* linVelDelta, const PxVec3* angVelDelta); + void clearSpatialVelocity(bool force, bool torque); + + PX_FORCE_INLINE PxReal getMaxPenetrationBias() const { return mCore.maxPenBias; } + PX_FORCE_INLINE void setMaxPenetrationBias(PxReal p) { mCore.maxPenBias = p; } + + PxReal getInverseMass() const; + void setInverseMass(PxReal m); + const PxVec3& getInverseInertia() const; + void setInverseInertia(const PxVec3& i); + + PxReal getLinearDamping() const; + void setLinearDamping(PxReal d); + + PxReal getAngularDamping() const; + void setAngularDamping(PxReal d); + + PX_FORCE_INLINE PxRigidBodyFlags getFlags() const { return mCore.mFlags; } + void setFlags(Ps::Pool<SimStateData>* simStateDataPool, PxRigidBodyFlags f); + + PX_FORCE_INLINE PxRigidDynamicLockFlags getRigidDynamicLockFlags() const { return mCore.lockFlags; } + + PX_FORCE_INLINE void setRigidDynamicLockFlags(PxRigidDynamicLockFlags flags) { mCore.lockFlags = flags; } + + PX_FORCE_INLINE PxReal getSleepThreshold() const { return mCore.sleepThreshold; } + void setSleepThreshold(PxReal t); + + PX_FORCE_INLINE PxReal getFreezeThreshold() const { return mCore.freezeThreshold; } + void setFreezeThreshold(PxReal t); + + PX_FORCE_INLINE PxReal getMaxContactImpulse() const { return mCore.maxContactImpulse; } + void setMaxContactImpulse(PxReal m); + + PX_FORCE_INLINE PxReal getWakeCounter() const { return mCore.wakeCounter; } + void setWakeCounter(PxReal wakeCounter, bool forceWakeUp=false); + + bool isSleeping() const; + PX_FORCE_INLINE void wakeUp(PxReal wakeCounter) { setWakeCounter(wakeCounter, true); } + void putToSleep(); + + PxReal getMaxAngVelSq() const; + void setMaxAngVelSq(PxReal v); + + + PxU32 getSolverIterationCounts() const { return mCore.solverIterationCounts; } + void setSolverIterationCounts(PxU16 c); + + bool getKinematicTarget(PxTransform& p) const; + bool getHasValidKinematicTarget() const; + void setKinematicTarget(Ps::Pool<SimStateData>* simStateDataPool, const PxTransform& p, PxReal wakeCounter); + void invalidateKinematicTarget(); + + PX_FORCE_INLINE PxReal getContactReportThreshold() const { return mCore.contactReportThreshold; } + void setContactReportThreshold(PxReal t) { mCore.contactReportThreshold = t; } + + void onOriginShift(const PxVec3& shift); + + //--------------------------------------------------------------------------------- + // Internal API + //--------------------------------------------------------------------------------- + + PX_FORCE_INLINE void setLinearVelocityInternal(const PxVec3& v) { mCore.linearVelocity = v; } + PX_FORCE_INLINE void setAngularVelocityInternal(const PxVec3& v) { mCore.angularVelocity = v; } + PX_FORCE_INLINE void setWakeCounterFromSim(PxReal c) { mCore.wakeCounter = c; } + + BodySim* getSim() const; + + PX_FORCE_INLINE PxsBodyCore& getCore() { return mCore; } + PX_FORCE_INLINE const PxsBodyCore& getCore() const { return mCore; } + + PX_FORCE_INLINE PxReal getCCDAdvanceCoefficient() const { return mCore.ccdAdvanceCoefficient; } + PX_FORCE_INLINE void setCCDAdvanceCoefficient(PxReal c) { mCore.ccdAdvanceCoefficient = c; } + + bool setupSimStateData(Ps::Pool<SimStateData>* simStateDataPool, const bool isKinematic, const bool targetValid = false); + void tearDownSimStateData(Ps::Pool<SimStateData>* simStateDataPool, const bool isKinematic); + + bool checkSimStateKinematicStatus(bool) const; + + Ps::IntBool isFrozen() const; + void setFrozen(); + void clearFrozen(); + + PX_FORCE_INLINE const SimStateData* getSimStateData(bool isKinematic) const { return (mSimStateData && (checkSimStateKinematicStatus(isKinematic)) ? mSimStateData : NULL); } + PX_FORCE_INLINE SimStateData* getSimStateData(bool isKinematic) { return (mSimStateData && (checkSimStateKinematicStatus(isKinematic)) ? mSimStateData : NULL); } + + static PX_FORCE_INLINE BodyCore& getCore(PxsBodyCore& core) + { + size_t offset = PX_OFFSET_OF_RT(BodyCore, mCore); + return *reinterpret_cast<BodyCore*>(reinterpret_cast<PxU8*>(&core) - offset); + } + + private: + void backup(SimStateData&); + void restore(); + + PX_ALIGN_PREFIX(16) PxsBodyCore mCore PX_ALIGN_SUFFIX(16); + /*PxReal mSleepThreshold; + PxReal mFreezeThreshold; + PxReal mWakeCounter;*/ + SimStateData* mSimStateData; + }; + + PxActor* getPxActorFromBodyCore(Sc::BodyCore* bodyCore, PxActorType::Enum& type); + +} // namespace Sc + +} + +#endif diff --git a/PhysX_3.4/Source/SimulationController/include/ScClothCore.h b/PhysX_3.4/Source/SimulationController/include/ScClothCore.h new file mode 100644 index 00000000..b6e63639 --- /dev/null +++ b/PhysX_3.4/Source/SimulationController/include/ScClothCore.h @@ -0,0 +1,336 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 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_PHYSICS_SCP_CLOTH_CORE +#define PX_PHYSICS_SCP_CLOTH_CORE + +#include "CmPhysXCommon.h" +#include "PxPhysXConfig.h" +#if PX_USE_CLOTH_API + +#include "ScActorCore.h" + +#include "foundation/PxTransform.h" +#include "PxFiltering.h" +#include "PxCloth.h" +#include "PxClothTypes.h" +#include "PxClothCollisionData.h" + +#include "PsArray.h" + +namespace physx +{ + +struct PxClothCollisionSphere; + +namespace cloth +{ + class Cloth; + struct PhaseConfig; +} + +namespace Sc +{ + class ClothFabricCore; + class ClothSim; + + bool DefaultClothInterCollisionFilter(void* cloth0, void* cloth1); + + struct ClothBulkData : public Ps::UserAllocated + { + //= ATTENTION! ===================================================================================== + // Changing the data layout of this class breaks the binary serialization format. See comments for + // PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData + // function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION + // accordingly. + //================================================================================================== + + // constructor and destructor are needed because some compilers zero the memory in the + // default constructor and that breaks the serialization related memory markers for + // implicitly padded bytes + ClothBulkData() {} + ~ClothBulkData() {} + + void exportExtraData(PxSerializationContext& stream); + void importExtraData(PxDeserializationContext& context); + static void getBinaryMetaData(PxOutputStream& stream); + + shdfnd::Array<PxClothParticle> mParticles; + shdfnd::Array<PxU32> mVpData; + shdfnd::Array<PxVec3> mVpWeightData; + shdfnd::Array<PxClothCollisionSphere> mCollisionSpheres; + shdfnd::Array<PxU32> mCollisionPairs; + shdfnd::Array<PxClothCollisionPlane> mCollisionPlanes; + shdfnd::Array<PxU32> mConvexMasks; + shdfnd::Array<PxClothCollisionTriangle> mCollisionTriangles; + shdfnd::Array<PxClothParticleMotionConstraint> mConstraints; + shdfnd::Array<PxClothParticleSeparationConstraint> mSeparationConstraints; + shdfnd::Array<PxVec4> mParticleAccelerations; + shdfnd::Array<PxU32> mSelfCollisionIndices; + shdfnd::Array<PxVec4> mRestPositions; + + // misc data + PxReal mTetherConstraintScale; + PxReal mTetherConstraintStiffness; + PxReal mMotionConstraintScale; + PxReal mMotionConstraintBias; + PxReal mMotionConstraintStiffness; + PxVec3 mAcceleration; + PxVec3 mDamping; + PxReal mFriction; + PxReal mCollisionMassScale; + PxVec3 mLinearDrag; + PxVec3 mAngularDrag; + PxVec3 mLinearInertia; + PxVec3 mAngularInertia; + PxVec3 mCentrifugalInertia; + PxReal mSolverFrequency; + PxReal mStiffnessFrequency; + PxReal mSelfCollisionDistance; + PxReal mSelfCollisionStiffness; + PxTransform mGlobalPose; + PxReal mSleepThreshold; + PxReal mWakeCounter; + PxVec3 mWindVelocity; + PxReal mDragCoefficient; + PxReal mLiftCoefficient; + }; + + + class ClothCore : public ActorCore + { + //= ATTENTION! ===================================================================================== + // Changing the data layout of this class breaks the binary serialization format. See comments for + // PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData + // function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION + // accordingly. + //================================================================================================== + public: +// PX_SERIALIZATION + ClothCore(const PxEMPTY) : ActorCore(PxEmpty), mLowLevelCloth(NULL), mFabric(NULL) {} + void exportExtraData(PxSerializationContext& stream); + void importExtraData(PxDeserializationContext& context); + void resolveReferences(Sc::ClothFabricCore& fabric); + static void getBinaryMetaData(PxOutputStream& stream); +//~PX_SERIALIZATION + ClothCore(const PxTransform& globalPose, Sc::ClothFabricCore& fabric, const PxClothParticle* particles, PxClothFlags flags); + ~ClothCore(); + + //--------------------------------------------------------------------------------- + // External API + //--------------------------------------------------------------------------------- + PX_FORCE_INLINE ClothFabricCore* getFabric() const { return mFabric; } + PX_FORCE_INLINE void resetFabric() { mFabric = NULL; } + + void setParticles(const PxClothParticle* currentParticles, const PxClothParticle* previousParticles); + PxU32 getNbParticles() const; + + void setMotionConstraints(const PxClothParticleMotionConstraint* motionConstraints); + bool getMotionConstraints(PxClothParticleMotionConstraint* motionConstraintsBuffer) const; + PxU32 getNbMotionConstraints() const; + + void setMotionConstraintConfig(const PxClothMotionConstraintConfig& config); + PxClothMotionConstraintConfig getMotionConstraintConfig() const; + + void setSeparationConstraints(const PxClothParticleSeparationConstraint* separationConstraints); + bool getSeparationConstraints(PxClothParticleSeparationConstraint* separationConstraintsBuffer) const; + PxU32 getNbSeparationConstraints() const; + + void clearInterpolation(); + + void setParticleAccelerations(const PxVec4* particleAccelerations); + bool getParticleAccelerations(PxVec4* particleAccelerationsBuffer) const; + PxU32 getNbParticleAccelerations() const; + + void addCollisionSphere(const PxClothCollisionSphere& sphere); + void removeCollisionSphere(PxU32 index); + void setCollisionSpheres(const PxClothCollisionSphere* spheresBuffer, PxU32 count); + PxU32 getNbCollisionSpheres() const; + + void getCollisionData(PxClothCollisionSphere* spheresBuffer, PxU32* capsulesBuffer, + PxClothCollisionPlane* planesBuffer, PxU32* convexesBuffer, PxClothCollisionTriangle* trianglesBuffer) const; + + void addCollisionCapsule(PxU32 first, PxU32 second); + void removeCollisionCapsule(PxU32 index); + PxU32 getNbCollisionCapsules() const; + + void addCollisionTriangle(const PxClothCollisionTriangle& triangle); + void removeCollisionTriangle(PxU32 index); + void setCollisionTriangles(const PxClothCollisionTriangle* trianglesBuffer, PxU32 count); + PxU32 getNbCollisionTriangles() const; + + void addCollisionPlane(const PxClothCollisionPlane& plane); + void removeCollisionPlane(PxU32 index); + void setCollisionPlanes(const PxClothCollisionPlane* planesBuffer, PxU32 count); + PxU32 getNbCollisionPlanes() const; + + void addCollisionConvex(PxU32 mask); + void removeCollisionConvex(PxU32 index); + PxU32 getNbCollisionConvexes() const; + + void setVirtualParticles(PxU32 numParticles, const PxU32* indices, PxU32 numWeights, const PxVec3* weights); + + PxU32 getNbVirtualParticles() const; + void getVirtualParticles(PxU32* indicesBuffer) const; + + PxU32 getNbVirtualParticleWeights() const; + void getVirtualParticleWeights(PxVec3* weightsBuffer) const; + + PxTransform getGlobalPose() const; + void setGlobalPose(const PxTransform& pose); + + void setTargetPose(const PxTransform& pose); + + PxVec3 getExternalAcceleration() const; + void setExternalAcceleration(PxVec3 acceleration); + + PxVec3 getDampingCoefficient() const; + void setDampingCoefficient(PxVec3 dampingCoefficient); + + PxReal getFrictionCoefficient() const; + void setFrictionCoefficient(PxReal frictionCoefficient); + + PxVec3 getLinearDragCoefficient() const; + void setLinearDragCoefficient(PxVec3 dragCoefficient); + PxVec3 getAngularDragCoefficient() const; + void setAngularDragCoefficient(PxVec3 dragCoefficient); + + PxReal getCollisionMassScale() const; + void setCollisionMassScale(PxReal scalingCoefficient); + + void setSelfCollisionDistance(PxReal distance); + PxReal getSelfCollisionDistance() const; + void setSelfCollisionStiffness(PxReal stiffness); + PxReal getSelfCollisionStiffness() const; + + void setSelfCollisionIndices(const PxU32* indices, PxU32 nbIndices); + bool getSelfCollisionIndices(PxU32* indices) const; + PxU32 getNbSelfCollisionIndices() const; + + void setRestPositions(const PxVec4* restPositions); + bool getRestPositions(PxVec4* restPositions) const; + PxU32 getNbRestPositions() const; + + PxReal getSolverFrequency() const; + void setSolverFrequency(PxReal); + + PxReal getStiffnessFrequency() const; + void setStiffnessFrequency(PxReal); + + PxVec3 getLinearInertiaScale() const; + void setLinearInertiaScale( PxVec3 ); + PxVec3 getAngularInertiaScale() const; + void setAngularInertiaScale( PxVec3 ); + PxVec3 getCentrifugalInertiaScale() const; + void setCentrifugalInertiaScale( PxVec3 ); + + PxClothStretchConfig getStretchConfig(PxClothFabricPhaseType::Enum type) const; + PxClothTetherConfig getTetherConfig() const; + + void setStretchConfig(PxClothFabricPhaseType::Enum type, const PxClothStretchConfig& config); + void setTetherConfig(const PxClothTetherConfig& config); + + PxClothFlags getClothFlags() const; + void setClothFlags(PxClothFlags flags); + + PxVec3 getWindVelocity() const; + void setWindVelocity(PxVec3); + PxReal getDragCoefficient() const; + void setDragCoefficient(PxReal); + PxReal getLiftCoefficient() const; + void setLiftCoefficient(PxReal); + + + bool isSleeping() const; + PxReal getSleepLinearVelocity() const; + void setSleepLinearVelocity(PxReal threshold); + void setWakeCounter(PxReal wakeCounterValue); + PxReal getWakeCounter() const; + void wakeUp(PxReal wakeCounter); + void putToSleep(); + + void getParticleData(PxClothParticleData& readData); + void unlockParticleData(); + + PxReal getPreviousTimeStep() const; + + PxBounds3 getWorldBounds() const; + + void setSimulationFilterData(const PxFilterData& data); + PxFilterData getSimulationFilterData() const; + + void setContactOffset(PxReal); + PxReal getContactOffset() const; + void setRestOffset(PxReal); + PxReal getRestOffset() const; + + public: + ClothSim* getSim() const; + + PxCloth* getPxCloth(); + + PX_FORCE_INLINE cloth::Cloth* getLowLevelCloth() { return mLowLevelCloth; } + + void onOriginShift(const PxVec3& shift); + + void switchCloth(cloth::Cloth*); + PX_FORCE_INLINE bool isGpu() const { return mClothFlags & PxClothFlag::eCUDA; } + + private: + + void updateBulkData(ClothBulkData& bulkData); + void initLowLevel(const PxTransform& globalPose, const PxClothParticle* particles); + + private: + PxVec3 mExternalAcceleration; + cloth::Cloth* mLowLevelCloth; + ClothFabricCore* mFabric; + ClothBulkData* mBulkData; + cloth::PhaseConfig* mPhaseConfigs; + PxFilterData mFilterData; + PxClothFlags mClothFlags; + PxReal mContactOffset; + PxReal mRestOffset; + + public: // + PxU32 mNumUserSpheres; + PxU32 mNumUserCapsules; + PxU32 mNumUserPlanes; + PxU32 mNumUserConvexes; + PxU32 mNumUserTriangles; + }; + +} // namespace Sc + +} + +#endif // PX_USE_CLOTH_API + +#endif diff --git a/PhysX_3.4/Source/SimulationController/include/ScClothFabricCore.h b/PhysX_3.4/Source/SimulationController/include/ScClothFabricCore.h new file mode 100644 index 00000000..5dfeb76d --- /dev/null +++ b/PhysX_3.4/Source/SimulationController/include/ScClothFabricCore.h @@ -0,0 +1,146 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 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_PHYSICS_SCP_CLOTH_FABRIC_CORE +#define PX_PHYSICS_SCP_CLOTH_FABRIC_CORE + +#include "CmPhysXCommon.h" +#include "PsUserAllocated.h" +#include "PxPhysXConfig.h" +#include "PxClothFabric.h" +#include "PsArray.h" + +namespace physx +{ + +#if PX_USE_CLOTH_API + +class PxSerializationContext; + +namespace cloth +{ + class Fabric; +} + + +namespace Sc +{ + struct ClothFabricBulkData : public Ps::UserAllocated + { + //= ATTENTION! ===================================================================================== + // Changing the data layout of this class breaks the binary serialization format. See comments for + // PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData + // function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION + // accordingly. + //================================================================================================== + + // constructor and destructor are needed because some compilers zero the memory in the + // default constructor and that breaks the serialization related memory markers for + // implicitly padded bytes + ClothFabricBulkData() {} + ~ClothFabricBulkData() {} + + void exportExtraData(PxSerializationContext& stream); + void importExtraData(PxDeserializationContext& context); + static void getBinaryMetaData(PxOutputStream& stream); + + PxU32 mNbParticles; + + shdfnd::Array<PxU32> mPhases; + shdfnd::Array<PxU32> mSets; + shdfnd::Array<float> mRestvalues; + shdfnd::Array<PxU32> mIndices; + shdfnd::Array<PxU32> mTetherAnchors; + shdfnd::Array<PxReal> mTetherLengths; + shdfnd::Array<PxU32> mTriangles; + }; + + + class ClothFabricCore : public Ps::UserAllocated + { + //= ATTENTION! ===================================================================================== + // Changing the data layout of this class breaks the binary serialization format. See comments for + // PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData + // function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION + // accordingly. + //================================================================================================== + public: +// PX_SERIALIZATION + ClothFabricCore(const PxEMPTY); + void exportExtraData(PxSerializationContext& stream); + void importExtraData(PxDeserializationContext& context); + static void getBinaryMetaData(PxOutputStream& stream); +//~PX_SERIALIZATION + ClothFabricCore(); + ~ClothFabricCore(); + + PX_FORCE_INLINE cloth::Fabric& getLowLevelFabric() const { PX_ASSERT(mLowLevelFabric); return *mLowLevelFabric; } + PX_FORCE_INLINE void setLowLevelGpuFabric(cloth::Fabric* fabric) { mLowLevelGpuFabric = fabric; } + + bool load(PxInputStream& stream); + bool load(const PxClothFabricDesc& desc); + + PxU32 getNbParticles() const; + PxU32 getNbPhases() const; + PxU32 getNbSets() const; + PxU32 getNbParticleIndices() const; + PxU32 getNbRestvalues() const; + PxU32 getNbTethers() const; + + PxU32 getPhases(PxClothFabricPhase* userPhaseIndexBuffer, PxU32 bufferSize) const; + PxU32 getRestvalues(PxReal* userRestvalueBuffer, PxU32 bufferSize) const; + + PxU32 getSets(PxU32* userPhaseBuffer, PxU32 bufferSize) const; + PxU32 getParticleIndices(PxU32* userParticleIndexBuffer, PxU32 bufferSize) const; + + PxU32 getTetherAnchors(PxU32* userAnchorBuffer, PxU32 bufferSize) const; + PxU32 getTetherLengths(PxReal* userLengthBuffer, PxU32 bufferSize) const; + + PxClothFabricPhaseType::Enum getPhaseType(PxU32 phaseIndex) const { return mPhaseTypes[phaseIndex]; } + + void scaleRestlengths(PxReal scale); + + private: + cloth::Fabric* mLowLevelFabric; + cloth::Fabric* mLowLevelGpuFabric; + + // Each phase has a type defined in PxClothFabricPhaseType::Enum. + // The size of this array is the same as number of phases (mPhases.size()) + Ps::Array<PxClothFabricPhaseType::Enum> mPhaseTypes; + }; + +} // namespace Sc + + +#endif // PX_USE_CLOTH_API + +} + +#endif diff --git a/PhysX_3.4/Source/SimulationController/include/ScConstraintCore.h b/PhysX_3.4/Source/SimulationController/include/ScConstraintCore.h new file mode 100644 index 00000000..ff9791e3 --- /dev/null +++ b/PhysX_3.4/Source/SimulationController/include/ScConstraintCore.h @@ -0,0 +1,134 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 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_PHYSICS_CONSTRAINTCORE +#define PX_PHYSICS_CONSTRAINTCORE + +#include "CmPhysXCommon.h" +#include "PxConstraintDesc.h" +#include "PsAllocator.h" +#include "PxConstraint.h" + +namespace physx +{ + +class PxConstraint; + +namespace Sc +{ + class ConstraintCore; + class ConstraintSim; + class RigidCore; + + + class ConstraintCore : public Ps::UserAllocated + { + //= ATTENTION! ===================================================================================== + // Changing the data layout of this class breaks the binary serialization format. See comments for + // PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData + // function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION + // accordingly. + //================================================================================================== + public: +// PX_SERIALIZATION + ConstraintCore(const PxEMPTY) : mConnector(NULL), mSim(NULL) {} + PX_FORCE_INLINE void setConstraintFunctions(PxConstraintConnector& n, + const PxConstraintShaderTable& shaders) + { + mConnector = &n; + mSolverPrep = shaders.solverPrep; + mProject = shaders.project; + mVisualize = shaders.visualize; + } + static void getBinaryMetaData(PxOutputStream& stream); +//~PX_SERIALIZATION + ConstraintCore(PxConstraintConnector& connector, const PxConstraintShaderTable& shaders, PxU32 dataSize); + ~ConstraintCore(); + + // The two-step protocol here allows us to unlink the constraint prior to deleting + // the actors when synchronizing the scene, then set the bodies after new actors have been inserted + + void prepareForSetBodies(); + void setBodies(RigidCore* r0v, RigidCore* r1v); + + PxConstraint* getPxConstraint(); + const PxConstraint* getPxConstraint() const; + PX_FORCE_INLINE PxConstraintConnector* getPxConnector() const { return mConnector; } + + PX_FORCE_INLINE PxConstraintFlags getFlags() const { return mFlags; } + void setFlags(PxConstraintFlags flags); + + void getForce(PxVec3& force, PxVec3& torque) const; + + bool updateConstants(void* addr); + + void setBreakForce(PxReal linear, PxReal angular); + void getBreakForce(PxReal& linear, PxReal& angular) const; + + void setMinResponseThreshold(PxReal threshold); + PxReal getMinResponseThreshold() const { return mMinResponseThreshold; } + + void breakApart(); + + PX_FORCE_INLINE PxConstraintVisualize getVisualize() const { return mVisualize; } + PX_FORCE_INLINE PxConstraintProject getProject() const { return mProject; } + PX_FORCE_INLINE PxConstraintSolverPrep getSolverPrep() const { return mSolverPrep; } + PX_FORCE_INLINE PxU32 getConstantBlockSize() const { return mDataSize; } + + PX_FORCE_INLINE void setSim(ConstraintSim* sim) + { + PX_ASSERT((sim==0) ^ (mSim == 0)); + mSim = sim; + } + PX_FORCE_INLINE ConstraintSim* getSim() const { return mSim; } + private: + PxConstraintFlags mFlags; + PxU16 mPaddingFromFlags; // PT: because flags are PxU16 + + PxVec3 mAppliedForce; + PxVec3 mAppliedTorque; + + PxConstraintConnector* mConnector; + PxConstraintProject mProject; + PxConstraintSolverPrep mSolverPrep; + PxConstraintVisualize mVisualize; + PxU32 mDataSize; + PxReal mLinearBreakForce; + PxReal mAngularBreakForce; + PxReal mMinResponseThreshold; + + ConstraintSim* mSim; + }; + +} // namespace Sc + +} + +#endif diff --git a/PhysX_3.4/Source/SimulationController/include/ScIterators.h b/PhysX_3.4/Source/SimulationController/include/ScIterators.h new file mode 100644 index 00000000..89b67ebc --- /dev/null +++ b/PhysX_3.4/Source/SimulationController/include/ScIterators.h @@ -0,0 +1,129 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 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_PHYSICS_SCP_ITERATOR +#define PX_PHYSICS_SCP_ITERATOR + +#include "foundation/PxVec3.h" +#include "PxContact.h" + +namespace physx +{ + +class PxShape; +class PxRigidBody; +class PxsContactManagerOutputIterator; + +namespace Sq +{ + typedef size_t PrunerData; +} + +namespace Sc +{ + class ShapeSim; + class Interaction; + + + struct SqBoundsSync + { + virtual void sync(const PxU32* sqRefs, const PxU32* indices, const PxBounds3* bounds, PxU32 count) = 0; + + virtual ~SqBoundsSync() {} + }; + + struct SqRefFinder + { + virtual PxU32 find(const PxRigidBody * body, const PxShape* shape) = 0; + + virtual ~SqRefFinder() {} + }; + + + struct Contact + { + Contact() + : normal(0.0f) + , point(0.0f) + , separation(0.0f) + , normalForce(0.0f) + {} + + PxVec3 normal; + PxVec3 point; + PxShape* shape0; + PxShape* shape1; + PxReal separation; + PxReal normalForce; + PxU32 faceIndex0; // these are the external indices + PxU32 faceIndex1; + bool normalForceAvailable; + }; + + class ContactIterator + { + public: + + class Pair + { + public: + Pair() : mIter(NULL, NULL, NULL, 0, 0) {} + Pair(const void*& contactPatches, const void*& contactPoints, const PxU32 /*contactDataSize*/, const PxReal*& forces, PxU32 numContacts, PxU32 numPatches, ShapeSim& shape0, ShapeSim& shape1); + Contact* getNextContact(); + + private: + PxU32 mIndex; + PxU32 mNumContacts; + PxContactStreamIterator mIter; + const PxReal* mForces; + Contact mCurrentContact; + ShapeSim* mShape0; + ShapeSim* mShape1; + }; + + ContactIterator() {} + explicit ContactIterator(Interaction** first, Interaction** last, PxsContactManagerOutputIterator& outputs): mCurrent(first), mLast(last), mOffset(0), mOutputs(&outputs) {} + Pair* getNextPair(); + + private: + Interaction** mCurrent; + Interaction** mLast; + Pair mCurrentPair; + PxU32 mOffset; + PxsContactManagerOutputIterator* mOutputs; + + private: + }; + +} // namespace Sc + +} + +#endif diff --git a/PhysX_3.4/Source/SimulationController/include/ScMaterialCore.h b/PhysX_3.4/Source/SimulationController/include/ScMaterialCore.h new file mode 100644 index 00000000..1a84d220 --- /dev/null +++ b/PhysX_3.4/Source/SimulationController/include/ScMaterialCore.h @@ -0,0 +1,74 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 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_PHYSICS_SCP_MATERIAL_CORE +#define PX_PHYSICS_SCP_MATERIAL_CORE + +#include "foundation/PxVec3.h" +#include "PsUserAllocated.h" +#include "CmPhysXCommon.h" +#include "PxMaterial.h" +#include "PxsMaterialCore.h" + +namespace physx +{ + +class PxMaterial; + +namespace Sc +{ + +typedef PxsMaterialData MaterialData; + +class MaterialCore : public PxsMaterialCore +{ +//= ATTENTION! ===================================================================================== +// Changing the data layout of this class breaks the binary serialization format. See comments for +// PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData +// function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION +// accordingly. +//================================================================================================== +public: + MaterialCore(const MaterialData& desc); + MaterialCore(const PxEMPTY) : PxsMaterialCore(PxEmpty) {} + MaterialCore(){} + ~MaterialCore(); + static void getBinaryMetaData(PxOutputStream& stream); + + PX_FORCE_INLINE void save(MaterialData& data) const { data = *this; } + PX_FORCE_INLINE void load(const MaterialData& data) { static_cast<MaterialData&>(*this) = data; } // To make synchronization between master material and scene material table less painful + +}; + +} // namespace Sc + +} + +#endif diff --git a/PhysX_3.4/Source/SimulationController/include/ScParticleSystemCore.h b/PhysX_3.4/Source/SimulationController/include/ScParticleSystemCore.h new file mode 100644 index 00000000..9c8db669 --- /dev/null +++ b/PhysX_3.4/Source/SimulationController/include/ScParticleSystemCore.h @@ -0,0 +1,205 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 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_PHYSICS_SCP_PARTICLE_SYSTEM_CORE +#define PX_PHYSICS_SCP_PARTICLE_SYSTEM_CORE + +#include "CmPhysXCommon.h" +#include "PxPhysXConfig.h" +#if PX_USE_PARTICLE_SYSTEM_API + +#include "PsArray.h" +#include "CmBitMap.h" +#include "ScActorCore.h" +#include "PxFiltering.h" +#include "PtParticleSystemCore.h" +#include "particles/PxParticleBaseFlag.h" +#include "particles/PxParticleFluidReadData.h" + +namespace physx +{ + +class PxParticleCreationData; +class PxParticleBase; +class PxvObjectFactory; + +#if PX_SUPPORT_GPU_PHYSX +class PxParticleDeviceExclusiveAccess; +#endif + +namespace Pt +{ + class ParticleData; + class ParticleSystemState; +} + +#define MAX_PARTICLES_PER_PARTICLE_SYSTEM PT_PARTICLE_SYSTEM_PARTICLE_LIMIT +#define SPH_KERNEL_RADIUS_MULT 2.0f +#define SPH_REST_DENSITY 1000.0f + +namespace Sc +{ + + class ParticleSystemSim; + + class ParticleSystemCore : public ActorCore + { + //= ATTENTION! ===================================================================================== + // Changing the data layout of this class breaks the binary serialization format. See comments for + // PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData + // function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION + // accordingly. + //================================================================================================== + public: +// PX_SERIALIZATION + ParticleSystemCore(const PxEMPTY) : ActorCore(PxEmpty), mSimulationFilterData(PxEmpty), mLLParameter(PxEmpty) {} + void exportExtraData(PxSerializationContext& stream); + void importExtraData(PxDeserializationContext& context); + static void getBinaryMetaData(PxOutputStream& stream); +//~PX_SERIALIZATION + ParticleSystemCore(const PxActorType::Enum&, PxU32, bool); + ~ParticleSystemCore(); + + //--------------------------------------------------------------------------------- + // External API + //--------------------------------------------------------------------------------- + PxParticleBase* getPxParticleBase(); + + PxReal getStiffness() const; + void setStiffness(PxReal); + + PxReal getViscosity() const; + void setViscosity(PxReal); + + PxReal getDamping() const; + void setDamping(PxReal); + + PxReal getParticleMass() const; + void setParticleMass(PxReal); + + PxReal getRestitution() const; + void setRestitution(PxReal); + + PxReal getDynamicFriction() const; + void setDynamicFriction(PxReal); + + PxReal getStaticFriction() const; + void setStaticFriction(PxReal); + + const PxFilterData& getSimulationFilterData() const; + void setSimulationFilterData(const PxFilterData& data); + void resetFiltering(); + + PxParticleBaseFlags getFlags() const; + void setFlags(PxParticleBaseFlags); + PxU32 getInternalFlags() const; + void setInternalFlags(PxParticleBaseFlags flags); + void notifyCpuFallback(); + + PxParticleReadDataFlags getParticleReadDataFlags() const; + void setParticleReadDataFlags(PxParticleReadDataFlags); + + PxU32 getMaxParticles() const; + + PxReal getMaxMotionDistance() const; + void setMaxMotionDistance(PxReal); + PxReal getRestOffset() const; + void setRestOffset(PxReal); + PxReal getContactOffset() const; + void setContactOffset(PxReal); + PxReal getGridSize() const; + void setGridSize(PxReal); + PxReal getRestParticleDistance() const; + void setRestParticleDistance(PxReal); + + //---------------------------------------------------------------------------------------------------------------------------// + + bool createParticles(const PxParticleCreationData& creationData); + void releaseParticles(PxU32 numParticles, const PxStrideIterator<const PxU32>& indices); + void releaseParticles(); + void setPositions(PxU32 numParticles, const PxStrideIterator<const PxU32>& indexBuffer, const PxStrideIterator<const PxVec3>& positionBuffer); + void setVelocities(PxU32 numParticles, const PxStrideIterator<const PxU32>& indexBuffer, const PxStrideIterator<const PxVec3>& velocityBuffer); + void setRestOffsets(PxU32 numParticles, const PxStrideIterator<const PxU32>& indexBuffer, const PxStrideIterator<const PxF32>& restOffsetBuffer); + void addDeltaVelocities(const Cm::BitMap& bufferMap, const PxVec3* buffer, PxReal multiplier); + + void getParticleReadData(PxParticleFluidReadData& readData) const; + + PxU32 getParticleCount() const; + const Cm::BitMap& getParticleMap() const; + PxBounds3 getWorldBounds() const; + + //---------------------------------------------------------------------------------------------------------------------------// + + const PxVec3& getExternalAcceleration() const; + void setExternalAcceleration(const PxVec3&); + + const PxPlane& getProjectionPlane() const; + void setProjectionPlane(const PxPlane& plane); + +#if PX_SUPPORT_GPU_PHYSX + void enableDeviceExclusiveModeGpu(); + PxParticleDeviceExclusiveAccess* + getDeviceExclusiveAccessGpu() const; + bool isGpu() const; +#endif + + public: + // non-DDI methods: + Pt::ParticleSystemParameter& getLowLevelParameter() { return mLLParameter; } + ParticleSystemSim* getSim() const; + Pt::ParticleData* obtainStandaloneData(); + void returnStandaloneData(Pt::ParticleData* stateBuffer); + + void onOriginShift(const PxVec3& shift); + + private: + Pt::ParticleSystemState& getParticleState(); + const Pt::ParticleSystemState& getParticleState() const; + + private: + Pt::ParticleData* mStandaloneData; + PxFilterData mSimulationFilterData; // The filter data + + // External acceleration is set every frame for the LL sim object + PxVec3 mExternalAcceleration; + + // Used for two way interaction executed in HL + PxReal mParticleMass; + + // Merged particleSystem/particleFluid, API + internal parameter + Pt::ParticleSystemParameter mLLParameter; + }; + +} // namespace Sc + +} + +#endif // PX_USE_PARTICLE_SYSTEM_API +#endif // PX_PHYSICS_SCP_PARTICLE_SYSTEM_CORE diff --git a/PhysX_3.4/Source/SimulationController/include/ScPhysics.h b/PhysX_3.4/Source/SimulationController/include/ScPhysics.h new file mode 100644 index 00000000..62a41e28 --- /dev/null +++ b/PhysX_3.4/Source/SimulationController/include/ScPhysics.h @@ -0,0 +1,137 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 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_PHYSICS_SC_PHYSICS +#define PX_PHYSICS_SC_PHYSICS + +#include "PxPhysics.h" +#include "PxScene.h" +#include "PsUserAllocated.h" +#include "CmPhysXCommon.h" +#include "PsBasicTemplates.h" +#include "PxActor.h" + +namespace physx +{ + +namespace cloth +{ +class Factory; +} + + +class PxMaterial; +class PxTolerancesScale; +struct PxvOffsetTable; + +#if PX_SUPPORT_GPU_PHYSX +class PxPhysXGpu; +#endif + +namespace Sc +{ + class Scene; + class StaticCore; + class RigidCore; + class BodyCore; + class ArticulationCore; + class ConstraintCore; + class ParticleSystemCore; + class ClothCore; + class ShapeCore; + + struct OffsetTable + { + PX_FORCE_INLINE OffsetTable() {} + + PX_FORCE_INLINE PxActor* convertScRigidStatic2PxActor(StaticCore* sc) const { return Ps::pointerOffset<PxActor*>(sc, scRigidStatic2PxActor); } + PX_FORCE_INLINE PxActor* convertScRigidDynamic2PxActor(BodyCore* sc) const { return Ps::pointerOffset<PxActor*>(sc, scRigidDynamic2PxActor); } + PX_FORCE_INLINE PxActor* convertScArticulationLink2PxActor(BodyCore* sc) const { return Ps::pointerOffset<PxActor*>(sc, scArticulationLink2PxActor); } + + PX_FORCE_INLINE PxShape* convertScShape2Px(ShapeCore* sc) const { return Ps::pointerOffset<PxShape*>(sc, scShape2Px); } + PX_FORCE_INLINE const PxShape* convertScShape2Px(const ShapeCore* sc) const { return Ps::pointerOffset<const PxShape*>(sc, scShape2Px); } + + PX_FORCE_INLINE PxArticulation* convertScArticulation2Px(ArticulationCore* sc) const { return Ps::pointerOffset<PxArticulation*>(sc, scArticulation2Px); } + PX_FORCE_INLINE const PxArticulation* convertScArticulation2Px(const ArticulationCore* sc) const { return Ps::pointerOffset<const PxArticulation*>(sc, scArticulation2Px); } + + PX_FORCE_INLINE PxConstraint* convertScConstraint2Px(ConstraintCore* sc) const { return Ps::pointerOffset<PxConstraint*>(sc, scConstraint2Px); } + PX_FORCE_INLINE const PxConstraint* convertScConstraint2Px(const ConstraintCore* sc) const { return Ps::pointerOffset<const PxConstraint*>(sc, scConstraint2Px); } + + PX_FORCE_INLINE PxParticleFluid* convertScParticleSystem2PxParticleFluid(ParticleSystemCore* sc) const { return Ps::pointerOffset<PxParticleFluid*>(sc, scParticleSystem2PxParticleFluid); } + PX_FORCE_INLINE PxParticleSystem* convertScParticleSystem2Px(ParticleSystemCore* sc) const { return Ps::pointerOffset<PxParticleSystem*>(sc, scParticleSystem2Px); } + + PX_FORCE_INLINE PxCloth* convertScCloth2Px(ClothCore* sc) const { return Ps::pointerOffset<PxCloth*>(sc, scCloth2Px); } + + ptrdiff_t scRigidStatic2PxActor; + ptrdiff_t scRigidDynamic2PxActor; + ptrdiff_t scArticulationLink2PxActor; + ptrdiff_t scShape2Px; + ptrdiff_t scArticulation2Px; + ptrdiff_t scConstraint2Px; + ptrdiff_t scParticleSystem2PxParticleFluid; + ptrdiff_t scParticleSystem2Px; + ptrdiff_t scCloth2Px; + + ptrdiff_t scCore2PxActor[PxActorType::eACTOR_COUNT]; + }; + extern OffsetTable gOffsetTable; + + class Physics : public Ps::UserAllocated + { + public: + PX_FORCE_INLINE static Physics& getInstance() { return *mInstance; } + + Physics(const PxTolerancesScale&, const PxvOffsetTable& pxvOffsetTable); + ~Physics(); // use release() instead + public: + void release(); + + PX_FORCE_INLINE const PxTolerancesScale& getTolerancesScale() const { return mScale; } + +#if PX_USE_CLOTH_API + void registerCloth(); + PX_FORCE_INLINE bool hasLowLevelClothFactory() const { return mLowLevelClothFactory != 0; } + PX_FORCE_INLINE cloth::Factory& getLowLevelClothFactory() { PX_ASSERT(mLowLevelClothFactory); return *mLowLevelClothFactory; } +#endif + + private: + PxTolerancesScale mScale; + static Physics* mInstance; + cloth::Factory* mLowLevelClothFactory; + + public: + static const PxReal sWakeCounterOnCreation; + }; + +} // namespace Sc + +} + +#endif diff --git a/PhysX_3.4/Source/SimulationController/include/ScRigidCore.h b/PhysX_3.4/Source/SimulationController/include/ScRigidCore.h new file mode 100644 index 00000000..6ab9c8fe --- /dev/null +++ b/PhysX_3.4/Source/SimulationController/include/ScRigidCore.h @@ -0,0 +1,93 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 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_PHYSICS_SCP_RB_CORE +#define PX_PHYSICS_SCP_RB_CORE + +#include "ScActorCore.h" +#include "PxvDynamics.h" +#include "PxShape.h" + +namespace physx +{ + +namespace Sc +{ + + class RigidSim; + + struct ShapeChangeNotifyFlag + { + enum Enum + { + eGEOMETRY = 1<<0, + eMATERIAL = 1<<1, + eSHAPE2BODY = 1<<2, + eFILTERDATA = 1<<3, + eCONTACTOFFSET = 1<<4, + eRESTOFFSET = 1<<5, + eFLAGS = 1<<6, + eRESET_FILTERING = 1<<7 + + }; + }; + typedef PxFlags<ShapeChangeNotifyFlag::Enum, PxU32> ShapeChangeNotifyFlags; + PX_FLAGS_OPERATORS(ShapeChangeNotifyFlag::Enum,PxU32) + + + class ShapeCore; + + class RigidCore : public ActorCore + { + //= ATTENTION! ===================================================================================== + // Changing the data layout of this class breaks the binary serialization format. See comments for + // PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData + // function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION + // accordingly. + //================================================================================================== + public: + PxActor* getPxActor() const; + void addShapeToScene(ShapeCore& shape); + void removeShapeFromScene(ShapeCore& shape, bool wakeOnLostTouch); + void onShapeChange(ShapeCore& shape, ShapeChangeNotifyFlags notifyFlags, PxShapeFlags newShapeFlags = PxShapeFlags(), bool forceBoundsUpdate = false); + + RigidSim* getSim() const; + static void getBinaryMetaData(PxOutputStream& stream); + protected: + RigidCore(const PxEMPTY) : ActorCore(PxEmpty) {} + RigidCore(PxActorType::Enum type); + ~RigidCore(); + }; + +} // namespace Sc + +} + +#endif diff --git a/PhysX_3.4/Source/SimulationController/include/ScScene.h b/PhysX_3.4/Source/SimulationController/include/ScScene.h new file mode 100644 index 00000000..4e80a610 --- /dev/null +++ b/PhysX_3.4/Source/SimulationController/include/ScScene.h @@ -0,0 +1,1043 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 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_PHYSICS_SCP_SCENE +#define PX_PHYSICS_SCP_SCENE + +#include "foundation/PxProfiler.h" +#include "CmPhysXCommon.h" +#include "PxPhysXConfig.h" +#include "PxScene.h" +#include "PxSceneDesc.h" +#include "PxSimulationEventCallback.h" +#include "PsPool.h" +#include "PsHashSet.h" +#include "CmRenderOutput.h" +#include "CmTask.h" +#include "CmFlushPool.h" +#include "CmPreallocatingPool.h" +#include "CmBitMap.h" +#include "ScIterators.h" +#include "PxvContext.h" +#include "PxsMaterialManager.h" +#include "PxvManager.h" +#include "ScBodyCore.h" + +#define EXTRA_PROFILING 0 +#define PX_MAX_DOMINANCE_GROUP 32 + + +#if EXTRA_PROFILING +#include <cstdio> +#endif + +class OverlapFilterTask; + +namespace physx +{ +class PxSceneGpu; +struct PxTriggerPair; + +class PxsIslandManager; +class PxsSimulationController; +class PxsSimulationControllerCallback; +class PxsMemoryManager; + +#if PX_SUPPORT_GPU_PHYSX +class PxsKernelWranglerManager; +class PxsHeapMemoryAllocatorManager; +#endif + +namespace IG +{ + class SimpleIslandManager; +} + +class PxsCCDContext; + +namespace Cm +{ + class DeferredIDPool; + class IDPool; +} +#if PX_USE_CLOTH_API +namespace cloth +{ + class Solver; + class Factory; +} +#endif + +namespace Bp +{ + class SimpleAABBManager; + class BroadPhase; + class BoundsArray; +} + + +namespace Dy +{ + class Articulation; + class Context; +} + +namespace Pt +{ + class Context; +} + +namespace Sc +{ + class ActorSim; + class ElementSim; + class Interaction; + + class ShapeCore; + class RigidCore; + class StaticCore; + class ConstraintCore; + class MaterialCore; + class ArticulationCore; + class ArticulationJointCore; + class LLArticulationPool; + class ClothCore; + class BodyCore; + class ParticleSystemCore; + + class NPhaseCore; + class LowLevelThreadingThunk; + class Client; + class ConstraintInteraction; + + class BodySim; + class ShapeSim; + class RigidSim; + class StaticSim; + class ConstraintSim; + struct ConstraintGroupNode; + class ConstraintProjectionManager; + struct TriggerPairExtraData; + class ObjectIDTracker; + class ActorPairReport; + class ContactStreamManager; + class SqBoundsManager; + class ShapeInteraction; + class ElementInteractionMarker; + class ArticulationSim; + +#if PX_USE_PARTICLE_SYSTEM_API + class ParticleSystemSim; + class ParticlePacketShape; +#endif + +#if PX_USE_CLOTH_API + class ClothShape; +#endif + + class SimStats; + + struct SimStateData; + + struct BatchInsertionState + { + BodySim* bodySim; + StaticSim*staticSim; + ShapeSim* shapeSim; + ptrdiff_t staticActorOffset; + ptrdiff_t staticShapeTableOffset; + ptrdiff_t dynamicActorOffset; + ptrdiff_t dynamicShapeTableOffset; + ptrdiff_t shapeOffset; + }; + + struct BatchRemoveState + { + Ps::InlineArray<Sc::ShapeSim*, 64> bufferedShapes; + Ps::InlineArray<const Sc::ShapeCore*, 64> removedShapes; + }; + + + struct InteractionType + { + enum Enum + { + eOVERLAP = 0, // corresponds to ShapeInteraction + eTRIGGER, // corresponds to TriggerInteraction + eMARKER, // corresponds to ElementInteractionMarker + eTRACKED_IN_SCENE_COUNT, // not a real type, interactions above this limit are tracked in the scene + eCONSTRAINTSHADER, // corresponds to ConstraintInteraction +#if PX_USE_PARTICLE_SYSTEM_API + ePARTICLE_BODY, // corresponds to ParticleElementRbElementInteraction +#endif + eARTICULATION, // corresponds to ArticulationJointSim + + eINVALID + }; + }; + + + struct SceneInternalFlag + { + enum Enum + { + eSCENE_SIP_STATES_DIRTY_DOMINANCE = (1<<1), + eSCENE_SIP_STATES_DIRTY_VISUALIZATION = (1<<2), + eSCENE_DEFAULT = 0 + }; + }; + + + struct SimulationStage + { + enum Enum + { + eCOMPLETE, + eCOLLIDE, + eFETCHCOLLIDE, + eADVANCE, + eFETCHRESULT + }; + }; + + + + class Scene : public Ps::UserAllocated + { + struct SimpleBodyPair + { + BodySim* body1; + BodySim* body2; + PxU32 body1ID; + PxU32 body2ID; + }; + + PX_NOCOPY(Scene) + + //--------------------------------------------------------------------------------- + // External interface + //--------------------------------------------------------------------------------- + public: + + void release(); + + PX_FORCE_INLINE void setGravity(const PxVec3& g) { mGravity = g; mBodyGravityDirty = true; } + PX_FORCE_INLINE PxVec3 getGravity() const { return mGravity; } + PX_FORCE_INLINE void setElapsedTime(const PxReal t) { mDt = t; mOneOverDt = t > 0.0f ? 1.0f/t : 0.0f; } + + void setBounceThresholdVelocity(const PxReal t); + PxReal getBounceThresholdVelocity() const; + + PX_FORCE_INLINE void setPublicFlags(PxSceneFlags flags) { mPublicFlags = flags; } + PX_FORCE_INLINE PxSceneFlags getPublicFlags() const { return mPublicFlags; } + + void setFrictionType(PxFrictionType::Enum model); + PxFrictionType::Enum getFrictionType() const; + void setPCM(bool enabled); + void setContactCache(bool enabled); + + void addStatic(StaticCore&, void*const *shapes, PxU32 nbShapes, size_t shapePtrOffset, PxBounds3* uninflatedBounds); + void removeStatic(StaticCore&, Ps::InlineArray<const Sc::ShapeCore*,64>& removedShapes, bool wakeOnLostTouch); + + void addBody(BodyCore&, void*const *shapes, PxU32 nbShapes, size_t shapePtrOffset, PxBounds3* uninflatedBounds); + void removeBody(BodyCore&, Ps::InlineArray<const Sc::ShapeCore*,64>& removedShapes, bool wakeOnLostTouch); + + // Batch insertion API. + // the bounds generated here are the uninflated bounds for the shapes, *if* they are trigger or sim shapes. + // It's up to the caller to ensure the bounds array is big enough. + // Some care is required in handling these since sim and SQ tweak the bounds in slightly different ways. + + void startBatchInsertion(BatchInsertionState&); + void addStatic(PxActor* actor, BatchInsertionState&, PxBounds3* outBounds); + void addBody(PxActor* actor, BatchInsertionState&, PxBounds3* outBounds); + void finishBatchInsertion(BatchInsertionState&); + + // Batch remove helpers + PX_FORCE_INLINE void setBatchRemove(BatchRemoveState* bs) { mBatchRemoveState = bs; } + PX_FORCE_INLINE BatchRemoveState* getBatchRemove() const { return mBatchRemoveState; } + void prefetchForRemove(const BodyCore& ) const; + void prefetchForRemove(const StaticCore& ) const; + + void addConstraint(ConstraintCore&, RigidCore*, RigidCore*); + void removeConstraint(ConstraintCore&); + + void addArticulation(ArticulationCore&, BodyCore& root); + void removeArticulation(ArticulationCore&); + + void addArticulationJoint(ArticulationJointCore&, BodyCore& parent, BodyCore& child); + void removeArticulationJoint(ArticulationJointCore&); + +#if PX_USE_PARTICLE_SYSTEM_API + void addParticleSystem(ParticleSystemCore&); + void removeParticleSystem(ParticleSystemCore&, bool isRelease); + + PxU32 getNbParticleSystems() const; + ParticleSystemCore* const* getParticleSystems(); +#endif + bool hasParticleSystems() const; + +#if PX_USE_CLOTH_API + bool addCloth(ClothCore&); + void removeCloth(ClothCore&); +#endif + bool hasCloths() const; + + PxU32 getNbArticulations() const; + Sc::ArticulationCore* const* getArticulations(); + + PxU32 getNbConstraints() const; + Sc::ConstraintCore*const * getConstraints(); + + void initContactsIterator(ContactIterator&, PxsContactManagerOutputIterator&); + + // Simulation events + void setSimulationEventCallback(PxSimulationEventCallback* callback, PxClientID client); + PxSimulationEventCallback* getSimulationEventCallback(PxClientID client) const; + + // Contact modification + void setContactModifyCallback(PxContactModifyCallback* callback); + PxContactModifyCallback* getContactModifyCallback() const; + void setCCDContactModifyCallback(PxCCDContactModifyCallback* callback); + PxCCDContactModifyCallback* getCCDContactModifyCallback() const; + + void setCCDMaxPasses(PxU32 ccdMaxPasses); + PxU32 getCCDMaxPasses() const; + + // Broad-phase callback + void setBroadPhaseCallback(PxBroadPhaseCallback* callback, PxClientID client); + PxBroadPhaseCallback* getBroadPhaseCallback(PxClientID client) const; + + // Broad-phase management + void finishBroadPhase(const PxU32 ccdPass, PxBaseTask* continuation); + void finishBroadPhaseStage2(const PxU32 ccdPass); + void preallocateContactManagers(PxBaseTask* continuation); + + void islandInsertion(PxBaseTask* continuation); + void registerContactManagers(PxBaseTask* continuation); + void registerInteractions(PxBaseTask* continuation); + void registerSceneInteractions(PxBaseTask* continuation); + + void secondPassNarrowPhase(PxBaseTask* continuation); + + // Groups + void setDominanceGroupPair(PxDominanceGroup group1, PxDominanceGroup group2, const PxDominanceGroupPair& dominance); + PxDominanceGroupPair getDominanceGroupPair(PxDominanceGroup group1, PxDominanceGroup group2) const; + + void setSolverBatchSize(PxU32 solverBatchSize); + PxU32 getSolverBatchSize() const; + + void setVisualizationParameter(PxVisualizationParameter::Enum param, PxReal value); + PxReal getVisualizationParameter(PxVisualizationParameter::Enum param) const; + + void setVisualizationCullingBox(const PxBounds3& box); + const PxBounds3& getVisualizationCullingBox() const; + + // Run + void simulate(PxReal timeStep, PxBaseTask* continuation); + void advance(PxReal timeStep, PxBaseTask* continuation); + void collide(PxReal timeStep, PxBaseTask* continuation); + void endSimulation(); + void flush(bool sendPendingReports); + void fireBrokenConstraintCallbacks(); + void fireTriggerCallbacks(); + void fireQueuedContactCallbacks(bool asPartOfFlush); + void fireOnAdvanceCallback(); + + const Ps::Array<PxContactPairHeader>& + getQueuedContactPairHeaders(); + + bool fireOutOfBoundsCallbacks(); + void prepareOutOfBoundsCallbacks(); + void postCallbacksPreSync(); + void postReportsCleanup(); + void fireCallbacksPostSync(); + void syncSceneQueryBounds(SqBoundsSync& sync, SqRefFinder& finder); + PxU32 getErrorState(); + + PxU32 getDefaultContactReportStreamBufferSize() const; + + PxReal getFrictionOffsetThreshold() const; + + void setLimits(const PxSceneLimits& limits); + const PxSceneLimits& getLimits() const; + + void visualizeStartStep(); + void visualizeEndStep(); + Cm::RenderBuffer& getRenderBuffer(); + + void setNbContactDataBlocks(PxU32 blockCount); + PxU32 getNbContactDataBlocksUsed() const; + PxU32 getMaxNbContactDataBlocksUsed() const; + PxU32 getMaxNbConstraintDataBlocksUsed() const; + + void setScratchBlock(void* addr, PxU32 size); + +// PX_ENABLE_SIM_STATS + void getStats(PxSimulationStatistics& stats) const; + PX_FORCE_INLINE SimStats& getStatsInternal() { return *mStats; } +// PX_ENABLE_SIM_STATS + + PX_DEPRECATED void buildActiveTransforms(); + PX_DEPRECATED PxActiveTransform* getActiveTransforms(PxU32& nbTransformsOut, PxClientID client); + void buildActiveActors(); + PxActor** getActiveActors(PxU32& nbActorsOut, PxClientID client); + + void finalizeContactStreamAndCreateHeader(PxContactPairHeader& header, + const ActorPairReport& aPair, + ContactStreamManager& cs, PxU32 removedShapeTestMask); + + PxClientID createClient(); + void setClientBehaviorFlags(PxClientID client, PxClientBehaviorFlags clientBehaviorFlags); + PxClientBehaviorFlags getClientBehaviorFlags(PxClientID client) const; + +#if PX_USE_CLOTH_API + void setClothInterCollisionDistance(PxF32 distance); + PxF32 getClothInterCollisionDistance() const; + void setClothInterCollisionStiffness(PxF32 stiffness); + PxF32 getClothInterCollisionStiffness() const; + void setClothInterCollisionNbIterations(PxU32 nbIterations); + PxU32 getClothInterCollisionNbIterations() const; + void createClothSolver(); +#endif + + PxSceneGpu* getSceneGpu(bool createIfNeeded = false); + + PxTaskManager* getTaskManagerPtr() const { return mTaskManager; } + + void shiftOrigin(const PxVec3& shift); + + Ps::Pool<SimStateData>* getSimStateDataPool() { return mSimStateDataPool; } + + //--------------------------------------------------------------------------------- + // Miscellaneous + //--------------------------------------------------------------------------------- + //internal public methods: + public: + Scene(const PxSceneDesc& desc, PxU64 contextID); + ~Scene() {} //use release() plz. + + void preAllocate(PxU32 nbStatics, PxU32 nbBodies, PxU32 nbStaticShapes, PxU32 nbDynamicShapes); + + PX_FORCE_INLINE PxsContext* getLowLevelContext() { return mLLContext; } + PX_FORCE_INLINE const PxsContext* getLowLevelContext() const { return mLLContext; } + + PX_FORCE_INLINE Dy::Context* getDynamicsContext() { return mDynamicsContext; } + PX_FORCE_INLINE const Dy::Context* getDynamicsContext() const { return mDynamicsContext; } + + PX_FORCE_INLINE PxsSimulationController* getSimulationController() { return mSimulationController; } + PX_FORCE_INLINE const PxsSimulationController* getSimulationController() const { return mSimulationController; } + + PX_FORCE_INLINE Bp::SimpleAABBManager* getAABBManager() { return mAABBManager; } + PX_FORCE_INLINE const Bp::SimpleAABBManager*getAABBManager() const { return mAABBManager; } + PX_FORCE_INLINE Ps::Array<BodySim*>& getCcdBodies() { return mCcdBodies; } + +#if PX_USE_PARTICLE_SYSTEM_API + PX_FORCE_INLINE Pt::Context* getParticleContext() { return mParticleContext; } +#endif + + /*PX_FORCE_INLINE PxsIslandManager* getIslandManager() { return mIslandManager; } + PX_FORCE_INLINE const PxsIslandManager* getIslandManager() const { return mIslandManager; }*/ + + PX_FORCE_INLINE IG::SimpleIslandManager* getSimpleIslandManager() { return mSimpleIslandManager; } + PX_FORCE_INLINE const IG::SimpleIslandManager* getSimpleIslandManager() const { return mSimpleIslandManager; } + + PX_FORCE_INLINE Sc::SimulationStage::Enum getSimulationStage() const { return mSimulationStage; } + PX_FORCE_INLINE void setSimulationStage(Sc::SimulationStage::Enum stage) { mSimulationStage = stage; } + + void addShape(RigidSim&, ShapeCore&, PxBounds3* uninflatedBounds); + void removeShape(ShapeSim&, bool wakeOnLostTouch); + + void registerShapeInNphase(const ShapeCore& shapeCore); + void unregisterShapeFromNphase(const ShapeCore& shapeCore); + + void notifyNphaseOnUpdateShapeMaterial(const ShapeCore& shapeCore); + + // Get an array of the active actors. + PX_FORCE_INLINE BodyCore*const* getActiveBodiesArray() const { return mActiveBodies.begin(); } + PX_FORCE_INLINE PxU32 getNumActiveBodies() const { return mActiveBodies.size(); } + + PX_FORCE_INLINE PxU32 getNbInteractions(InteractionType::Enum type) const { return mInteractions[type].size(); } + PX_FORCE_INLINE PxU32 getNbActiveInteractions(InteractionType::Enum type) const { return mActiveInteractionCount[type]; } + // Get all interactions of a certain type + PX_FORCE_INLINE Interaction** getInteractions(InteractionType::Enum type) { return mInteractions[type].begin(); } + PX_FORCE_INLINE Interaction** getActiveInteractions(InteractionType::Enum type) { return mInteractions[type].begin(); } + + void registerInteraction(Interaction* interaction, bool active); + void unregisterInteraction(Interaction* interaction); + + void notifyInteractionActivated(Interaction* interaction); + void notifyInteractionDeactivated(Interaction* interaction); + + // for pool management of interaction arrays, a major cause of dynamic allocation + void** allocatePointerBlock(PxU32 size); + void deallocatePointerBlock(void**, PxU32 size); + + private: + // Get the number of active one-way dominator actors + PX_FORCE_INLINE PxU32 getActiveKinematicBodiesCount() const { return mActiveKinematicBodyCount; } + + // Get an iterator to the active one-way dominator actors + PX_FORCE_INLINE BodyCore*const* getActiveKinematicBodies() const { return mActiveBodies.begin(); } + + // Get the number of active non-kinematic actors + PX_FORCE_INLINE PxU32 getActiveDynamicBodiesCount() const { return mActiveBodies.size() - mActiveKinematicBodyCount; } + + // Get the active non-kinematic actors + PX_FORCE_INLINE BodyCore*const* getActiveDynamicBodies() const { return mActiveBodies.begin() + mActiveKinematicBodyCount; } + + void swapInteractionArrayIndices(PxU32 id1, PxU32 id2, InteractionType::Enum type); + + + + public: + + PX_FORCE_INLINE Cm::BitMap& getDirtyShapeSimMap() { return mDirtyShapeSimMap; } + + void addToActiveBodyList(BodySim& actor); + void removeFromActiveBodyList(BodySim& actor); + void swapInActiveBodyList(BodySim& body); // call when an active body gets switched from dynamic to kinematic or vice versa + + void addBrokenConstraint(Sc::ConstraintCore*); + void addActiveBreakableConstraint(Sc::ConstraintSim*, ConstraintInteraction*); + void removeActiveBreakableConstraint(Sc::ConstraintSim*); + //the Actor should register its top level shapes with these. + void removeBody(BodySim&); + + void raiseSceneFlag(SceneInternalFlag::Enum flag) { mInternalFlags |= flag; } + + //lists of actors woken up or put to sleep last simulate + void onBodyWakeUp(BodySim* body); + void onBodySleep(BodySim* body); + + bool isValid() const; + + void addToLostTouchList(BodySim* body1, BodySim* body2); + + void initDominanceMatrix(); + + void setCreateContactReports(bool s); + +// PX_AGGREGATE + PxU32 createAggregate(void* userData, bool selfCollisions); + void deleteAggregate(PxU32 id); +//~PX_AGGREGATE + Dy::Articulation* createLLArticulation(Sc::ArticulationSim* sim); + void destroyLLArticulation(Dy::Articulation&); + + + Ps::Pool<ConstraintInteraction>* + getConstraintInteractionPool() const { return mConstraintInteractionPool; } + public: + PxBroadPhaseType::Enum getBroadPhaseType() const; + bool getBroadPhaseCaps(PxBroadPhaseCaps& caps) const; + PxU32 getNbBroadPhaseRegions() const; + PxU32 getBroadPhaseRegions(PxBroadPhaseRegionInfo* userBuffer, PxU32 bufferSize, PxU32 startIndex) const; + PxU32 addBroadPhaseRegion(const PxBroadPhaseRegion& region, bool populateRegion); + bool removeBroadPhaseRegion(PxU32 handle); + void** getOutOfBoundsAggregates(); + PxU32 getNbOutOfBoundsAggregates(); + void clearOutOfBoundsAggregates(); + + + PX_FORCE_INLINE const PxsMaterialManager& getMaterialManager() const { return mMaterialManager; } + PX_FORCE_INLINE PxsMaterialManager& getMaterialManager() { return mMaterialManager; } + + //material management functions to be called from Scb::Scene + void registerMaterialInNP(const PxsMaterialCore& materialCore); + void updateMaterialInNP(const PxsMaterialCore& materialCore); + void unregisterMaterialInNP(const PxsMaterialCore& materialCore); + + // Collision filtering + void setFilterShaderData(const void* data, PxU32 dataSize); + PX_FORCE_INLINE const void* getFilterShaderDataFast() const { return mFilterShaderData; } + PX_FORCE_INLINE PxU32 getFilterShaderDataSizeFast() const { return mFilterShaderDataSize; } + PX_FORCE_INLINE PxSimulationFilterShader getFilterShaderFast() const { return mFilterShader; } + PX_FORCE_INLINE PxSimulationFilterCallback* getFilterCallbackFast() const { return mFilterCallback; } + + PX_FORCE_INLINE PxU32 getTimeStamp() const { return mTimeStamp; } + PX_FORCE_INLINE PxU32 getReportShapePairTimeStamp() const { return mReportShapePairTimeStamp; } + + PX_FORCE_INLINE PxReal getOneOverDt() const { return mOneOverDt; } + PX_FORCE_INLINE PxReal getDt() const { return mDt; } + + PX_FORCE_INLINE const PxVec3& getGravityFast() const { return mGravity; } + PX_FORCE_INLINE bool readFlag(SceneInternalFlag::Enum flag) const { return (mInternalFlags & flag) != 0; } + PX_FORCE_INLINE bool readPublicFlag(PxSceneFlag::Enum flag) const { return (mPublicFlags & flag); } + + PX_FORCE_INLINE NPhaseCore* getNPhaseCore() const { return mNPhaseCore; } + + void checkConstraintBreakage(); + + PX_FORCE_INLINE Ps::Array<TriggerPairExtraData>& + getTriggerBufferExtraData() { return *mTriggerBufferExtraData; } + PX_FORCE_INLINE Ps::Array<PxTriggerPair>& getTriggerBufferAPI() { return mTriggerBufferAPI; } + void reserveTriggerReportBufferSpace(const PxU32 pairCount, PxTriggerPair*& triggerPairBuffer, TriggerPairExtraData*& triggerPairExtraBuffer); + + PX_FORCE_INLINE ObjectIDTracker& getRigidIDTracker() { return *mRigidIDTracker; } + PX_FORCE_INLINE ObjectIDTracker& getShapeIDTracker() { return *mShapeIDTracker; } + + PX_FORCE_INLINE void markReleasedBodyIDForLostTouch(PxU32 id) { mLostTouchPairsDeletedBodyIDs.growAndSet(id); } + void resizeReleasedBodyIDMaps(PxU32 maxActors, PxU32 numActors); + + PX_FORCE_INLINE StaticSim& getStaticAnchor() { return *mStaticAnchor; } + + PX_FORCE_INLINE ConstraintProjectionManager& getProjectionManager() { return *mProjectionManager; } + + PX_FORCE_INLINE Bp::BoundsArray& getBoundsArray() const { return *mBoundsArray; } + PX_FORCE_INLINE void updateContactDistance(PxU32 idx, PxReal distance) { (*mContactDistance)[idx] = distance; mHasContactDistanceChanged = true; } + PX_FORCE_INLINE SqBoundsManager& getSqBoundsManager() const { return *mSqBoundsManager; } + + PX_FORCE_INLINE PxReal getVisualizationScale() const { return mVisualizationScale; } // This is actually redundant but makes checks whether debug visualization is enabled faster + + PX_FORCE_INLINE BodyCore* const* getSleepBodiesArray(PxU32& count) { count = mSleepBodies.size(); return mSleepBodies.getEntries(); } + + PX_FORCE_INLINE PxTaskManager& getTaskManager() const { PX_ASSERT(mTaskManager); return *mTaskManager; } + + Cm::FlushPool* getFlushPool(); + + PX_FORCE_INLINE bool getStabilizationEnabled() const { return mEnableStabilization; } + + PX_FORCE_INLINE void setPostSolverVelocityNeeded() { mContactReportsNeedPostSolverVelocity = true; } + + ObjectIDTracker& getConstraintIDTracker() { return *mConstraintIDTracker; } + + + void* allocateConstraintBlock(PxU32 size); + void deallocateConstraintBlock(void* addr, PxU32 size); + + PX_INLINE ObjectIDTracker& getElementIDPool() { return *mElementIDPool; } + + PX_FORCE_INLINE Cm::BitMap& getVelocityModifyMap() { return mVelocityModifyMap; } + + void stepSetupCollide();//This is very important to guarantee thread safty in the collide + PX_FORCE_INLINE void addToPosePreviewList(BodySim& b) { PX_ASSERT(!mPosePreviewBodies.contains(&b)); mPosePreviewBodies.insert(&b); } + PX_FORCE_INLINE void removeFromPosePreviewList(BodySim& b) { PX_ASSERT(mPosePreviewBodies.contains(&b)); mPosePreviewBodies.erase(&b); } +#if PX_DEBUG + PX_FORCE_INLINE bool isInPosePreviewList(BodySim& b) const { return mPosePreviewBodies.contains(&b); } +#endif + + PX_FORCE_INLINE void setSpeculativeCCDRigidBody(const PxU32 index) { mSpeculativeCCDRigidBodyBitMap.growAndSet(index); } + PX_FORCE_INLINE void resetSpeculativeCCDRigidBody(const PxU32 index) { mSpeculativeCCDRigidBodyBitMap.reset(index); } + + PX_FORCE_INLINE void setSpeculativeCCDArticulationLink(const PxU32 index) { mSpeculativeCDDArticulationBitMap.growAndSet(index); } + PX_FORCE_INLINE void resetSpeculativeCCDArticulationLink(const PxU32 index) { mSpeculativeCDDArticulationBitMap.reset(index); } + + PX_FORCE_INLINE PxU64 getContextId() const { return mContextId; } + + //internal private methods: + private: + void releaseConstraints(bool endOfScene); + PX_INLINE void clearBrokenConstraintBuffer(); + + ///////////////////////////////////////////////////////////// + + void prepareCollide(); + + void collideStep(PxBaseTask* continuation); + void advanceStep(PxBaseTask* continuation); + + // subroutines of collideStep/solveStep: + void kinematicsSetup(); + void stepSetupSolve(); + //void stepSetupSimulate(); + + void fetchPatchEvents(PxBaseTask*); + void processNarrowPhaseTouchEvents(); + void processNarrowPhaseTouchEventsStage2(PxBaseTask*); + void setEdgesConnected(PxBaseTask*); + void processNarrowPhaseLostTouchEvents(PxBaseTask*); + void processNarrowPhaseLostTouchEventsIslands(PxBaseTask*); + void processLostTouchPairs(); + void integrateKinematicPose(); + void updateKinematicCached(); + + void beforeSolver(PxBaseTask* continuation); + void checkForceThresholdContactEvents(const PxU32 ccdPass); + void processCallbacks(bool pendingReportsOnly = false); + void endStep(); + private: + PxBaseTask& scheduleCloth(PxBaseTask& continuation, bool afterBroadPhase); + void scheduleClothGpu(PxBaseTask& continuation); + PxBaseTask& scheduleParticleShapeGeneration(PxBaseTask& broadPhaseDependent, + PxBaseTask& dynamicsCpuDependent); + PxBaseTask& scheduleParticleDynamicsCpu(PxBaseTask& continuation); + PxBaseTask& scheduleParticleCollisionPrep(PxBaseTask& collisionCpuDependent, + PxBaseTask& gpuDependent); + PxBaseTask& scheduleParticleCollisionCpu(PxBaseTask& continuation); + PxBaseTask& scheduleParticleGpu(PxBaseTask& continuation); + + void prepareParticleSystems(); + void finishParticleSystems(); + + PX_FORCE_INLINE void putObjectsToSleep(PxU32 infoFlag); + PX_FORCE_INLINE void putInteractionsToSleep(PxU32 infoFlag); + PX_FORCE_INLINE void wakeObjectsUp(PxU32 infoFlag); + PX_FORCE_INLINE void wakeInteractions(PxU32 infoFlag); + + void collectPostSolverVelocitiesBeforeCCD(); + void updateFromVisualizationParameters(); + + void clearSleepWakeBodies(void); + PX_INLINE void cleanUpSleepBodies(); + PX_INLINE void cleanUpWokenBodies(); + PX_INLINE void cleanUpSleepOrWokenBodies(Ps::CoalescedHashSet<BodyCore*>& bodyList, PxU32 removeFlag, bool& validMarker); + + //internal variables: + private: + // Material manager + PX_ALIGN(16, PxsMaterialManager mMaterialManager); + + PxU64 mContextId; + + Ps::Array<BodyCore*> mActiveBodies; // Sorted: kinematic before dynamic + PxU32 mActiveKinematicBodyCount; // Number of active kinematics. This is also the index in mActiveBodies where the active dynamic bodies start. + + + Ps::Array<Interaction*> mInteractions[InteractionType::eTRACKED_IN_SCENE_COUNT]; + PxU32 mActiveInteractionCount[InteractionType::eTRACKED_IN_SCENE_COUNT]; // Interactions with id < activeInteractionCount are active + + template <typename T, PxU32 size> + struct Block + { + PxU8 mem[sizeof(T)*size]; + Block() {} // get around VS warning C4345, otherwise useless + }; + + typedef Block<void*, 8> PointerBlock8; + typedef Block<void*, 16> PointerBlock16; + typedef Block<void*, 32> PointerBlock32; + + Ps::Pool<PointerBlock8> mPointerBlock8Pool; + Ps::Pool<PointerBlock16> mPointerBlock16Pool; + Ps::Pool<PointerBlock32> mPointerBlock32Pool; + + PxsContext* mLLContext; + + Bp::SimpleAABBManager* mAABBManager; + Bp::BroadPhase* mBP; + PxsCCDContext* mCCDContext; + PxI32 mNumFastMovingShapes; + PxU32 mCCDPass; + + //PxsIslandManager* mIslandManager; + + IG::SimpleIslandManager* mSimpleIslandManager; + + Dy::Context* mDynamicsContext; + + + PxsMemoryManager* mMemoryManager; + +#if PX_SUPPORT_GPU_PHYSX + PxsKernelWranglerManager* mGpuWranglerManagers; + PxsHeapMemoryAllocatorManager* mHeapMemoryAllocationManager; +#endif + + PxsSimulationController* mSimulationController; + + PxsSimulationControllerCallback* mSimulationControllerCallback; + + PxSceneLimits mLimits; + + PxVec3 mGravity; //!< Gravity vector + PxU32 mBodyGravityDirty; // Set to true before body->updateForces() when the mGravity has changed + + Ps::Array<PxContactPairHeader> + mQueuedContactPairHeaders; + //time: + //constants set with setTiming(): + PxReal mDt; //delta time for current step. + PxReal mOneOverDt; //inverse of dt. + //stepping / counters: + PxU32 mTimeStamp; //Counts number of steps. + PxU32 mReportShapePairTimeStamp; //Timestamp for refreshing the shape pair report structure. Updated before delayed shape/actor deletion and before CCD passes. + //containers: + // Those ones contain shape ptrs from Actor, i.e. compound level, not subparts + + Ps::CoalescedHashSet<Sc::ConstraintCore*> + mConstraints; + + Sc::ConstraintProjectionManager* mProjectionManager; + Bp::BoundsArray* mBoundsArray; + Ps::Array<PxReal, Ps::VirtualAllocator>* mContactDistance; + bool mHasContactDistanceChanged; + SqBoundsManager* mSqBoundsManager; + + Ps::Array<BodySim*> mCcdBodies; + Ps::Array<BodySim*> mProjectedBodies; + Ps::Array<PxTriggerPair> mTriggerBufferAPI; + Ps::Array<TriggerPairExtraData>* + mTriggerBufferExtraData; + + PxU32 mRemovedShapeCountAtSimStart; // counter used to detect whether there have been buffered shape removals + + Ps::CoalescedHashSet<ArticulationCore*> mArticulations; + +#if PX_USE_PARTICLE_SYSTEM_API + Pt::Context* mParticleContext; + Ps::CoalescedHashSet<ParticleSystemCore*> mParticleSystems; + Ps::Array<ParticleSystemSim*> mEnabledParticleSystems; // List of enabled particle systems updated every simulation step. +#endif + +#if PX_USE_CLOTH_API + Ps::CoalescedHashSet<ClothCore*> mCloths; + + static const PxU32 mNumClothSolvers = 2; + cloth::Solver* mClothSolvers[mNumClothSolvers]; + PxBaseTask* mClothTasks[mNumClothSolvers]; // first element unused + cloth::Factory* mClothFactories[mNumClothSolvers]; // necessary because we have a context manager per scene +#endif + + Ps::Array<Sc::ConstraintCore*> mBrokenConstraints; + Ps::CoalescedHashSet<Sc::ConstraintSim*> mActiveBreakableConstraints; + + // pools for joint buffers + // Fixed joint is 92 bytes, D6 is 364 bytes right now. So these three pools cover all the internal cases + typedef Block<PxU8, 128> MemBlock128; + typedef Block<PxU8, 256> MemBlock256; + typedef Block<PxU8, 384> MemBlock384; + + Ps::Pool2<MemBlock128, 8192> mMemBlock128Pool; + Ps::Pool2<MemBlock256, 8192> mMemBlock256Pool; + Ps::Pool2<MemBlock384, 8192> mMemBlock384Pool; + + + // broad phase data: + NPhaseCore* mNPhaseCore; + + // Collision filtering + void* mFilterShaderData; + PxU32 mFilterShaderDataSize; + PxU32 mFilterShaderDataCapacity; + PxSimulationFilterShader mFilterShader; + PxSimulationFilterCallback* mFilterCallback; + + Ps::CoalescedHashSet<BodyCore*> mSleepBodies; + Ps::CoalescedHashSet<BodyCore*> mWokeBodies; + bool mWokeBodyListValid; + bool mSleepBodyListValid; + bool mEnableStabilization; + Ps::Array<Client*> mClients; //an array of transform arrays, one for each client. + SimStats* mStats; + PxU32 mInternalFlags; //!< Combination of ::SceneFlag + PxSceneFlags mPublicFlags; //copy of PxSceneDesc::flags, of type PxSceneFlag + + ObjectIDTracker* mConstraintIDTracker; + ObjectIDTracker* mShapeIDTracker; + ObjectIDTracker* mRigidIDTracker; + ObjectIDTracker* mElementIDPool; + + StaticSim* mStaticAnchor; + + Cm::PreallocatingPool<ShapeSim>* mShapeSimPool; + Cm::PreallocatingPool<StaticSim>* mStaticSimPool; + Cm::PreallocatingPool<BodySim>* mBodySimPool; + Ps::Pool<ConstraintSim>* mConstraintSimPool; + LLArticulationPool* mLLArticulationPool; + + Ps::Pool<ConstraintInteraction>* + mConstraintInteractionPool; + + Ps::Pool<SimStateData>* mSimStateDataPool; + + BatchRemoveState* mBatchRemoveState; + + Ps::Array<SimpleBodyPair> mLostTouchPairs; + Cm::BitMap mLostTouchPairsDeletedBodyIDs; // Need to know which bodies have been deleted when processing the lost touch pair list. + // Can't use the existing rigid object ID tracker class since this map needs to be cleared at + // another point in time. + + Cm::BitMap mVelocityModifyMap; + + Ps::Array<PxvContactManagerTouchEvent> mTouchFoundEvents; + Ps::Array<PxvContactManagerTouchEvent> mTouchLostEvents; + + Ps::Array<PxsContactManager*> mFoundPatchManagers; + Ps::Array<PxsContactManager*> mLostPatchManagers; + + Ps::Array<PxU32> mOutOfBoundsIDs; + + Cm::BitMap mDirtyShapeSimMap; + + PxU32 mErrorState; + + PxU32 mDominanceBitMatrix[PX_MAX_DOMINANCE_GROUP]; + + PxReal mVisualizationScale; // Redundant but makes checks whether debug visualization is enabled faster + + bool mVisualizationParameterChanged; + + // statics: + PxU32 mNbRigidStatics; + PxU32 mNbRigidDynamics; + PxU32 mNbGeometries[PxGeometryType::eGEOMETRY_COUNT]; + + PxU32 mNumDeactivatingNodes[2]; + +#if EXTRA_PROFILING + private: + FILE* mExtraProfileFile; + PxU32 mLineNum; +#endif + + + // task decomposition + void preBroadPhase(PxBaseTask* continuation); + void broadPhase(PxBaseTask* continuation); + void postBroadPhase(PxBaseTask* continuation); + void preRigidBodyNarrowPhase(PxBaseTask* continuation); + void postBroadPhaseStage2(PxBaseTask* continuation); + void postBroadPhaseStage3(PxBaseTask* continuation); + void rigidBodyNarrowPhase(PxBaseTask* continuation); + void unblockNarrowPhase(PxBaseTask* continuation); + void islandGen(PxBaseTask* continuation); + void processLostSolverPatches(PxBaseTask* continuation); + void postIslandGen(PxBaseTask* continuation); + void processTriggerInteractions(PxBaseTask* continuation); + void solver(PxBaseTask* continuation); + void updateBodiesAndShapes(PxBaseTask* continuation); + void updateSimulationController(PxBaseTask* continuation); + void updateDynamics(PxBaseTask* continuation); + void processLostContacts(PxBaseTask*); + void processLostContacts2(PxBaseTask*); + void processLostContacts3(PxBaseTask*); + void destroyManagers(PxBaseTask*); + void lostTouchReports(PxBaseTask*); + void unregisterInteractions(PxBaseTask*); + void postThirdPassIslandGen(PxBaseTask*); + void postSolver(PxBaseTask* continuation); + void constraintProjection(PxBaseTask* continuation); + void afterIntegration(PxBaseTask* continuation); // performs sleep check, for instance + void postCCDPass(PxBaseTask* continuation); + void ccdBroadPhaseAABB(PxBaseTask* continuation); + void ccdBroadPhase(PxBaseTask* continuation); + void updateCCDMultiPass(PxBaseTask* continuation); + void updateCCDSinglePass(PxBaseTask* continuation); + void updateCCDSinglePassStage2(PxBaseTask* continuation); + void updateCCDSinglePassStage3(PxBaseTask* continuation); + void finalizationPhase(PxBaseTask* continuation); + + void postNarrowPhase(PxBaseTask* continuation); + void particlePostCollPrep(PxBaseTask* continuation); + void particlePostShapeGen(PxBaseTask* continuation); + + + void clothPreprocessing(PxBaseTask* continuation); + + void addShapes(void *const* shapes, PxU32 nbShapes, size_t ptrOffset, RigidSim& sim, PxBounds3* outBounds); + void removeShapes(RigidSim& , Ps::InlineArray<Sc::ShapeSim*, 64>& , Ps::InlineArray<const Sc::ShapeCore*, 64>&, bool wakeOnLostTouch); + + + private: + + void addShapes(void *const* shapes, PxU32 nbShapes, size_t ptrOffset, RigidSim& sim, ShapeSim*& prefetchedShapeSim, PxBounds3* outBounds); + + Cm::DelegateTask<Sc::Scene, &Sc::Scene::clothPreprocessing> mClothPreprocessing; + + Cm::DelegateTask<Sc::Scene, &Sc::Scene::secondPassNarrowPhase> mSecondPassNarrowPhase; + Cm::DelegateFanoutTask<Sc::Scene, &Sc::Scene::postNarrowPhase> mPostNarrowPhase; + Cm::FanoutTask mParticlePostCollPrep; + Cm::DelegateFanoutTask<Sc::Scene, &Sc::Scene::particlePostShapeGen> mParticlePostShapeGen; + Cm::DelegateFanoutTask<Sc::Scene, &Sc::Scene::finalizationPhase> mFinalizationPhase; + Cm::DelegateTask<Sc::Scene, &Sc::Scene::updateCCDMultiPass> mUpdateCCDMultiPass; + + //multi-pass ccd stuff + Ps::Array<Cm::DelegateTask<Sc::Scene, &Sc::Scene::updateCCDSinglePass> > mUpdateCCDSinglePass; + Ps::Array<Cm::DelegateTask<Sc::Scene, &Sc::Scene::updateCCDSinglePassStage2> > mUpdateCCDSinglePass2; + Ps::Array<Cm::DelegateTask<Sc::Scene, &Sc::Scene::updateCCDSinglePassStage3> > mUpdateCCDSinglePass3; + Ps::Array<Cm::DelegateTask<Sc::Scene, &Sc::Scene::ccdBroadPhaseAABB> > mCCDBroadPhaseAABB; + Ps::Array<Cm::DelegateTask<Sc::Scene, &Sc::Scene::ccdBroadPhase> > mCCDBroadPhase; + Ps::Array<Cm::DelegateTask<Sc::Scene, &Sc::Scene::postCCDPass> > mPostCCDPass; + PxU32 mCurrentCCDTask; + + Cm::DelegateTask<Sc::Scene, &Sc::Scene::afterIntegration> mAfterIntegration; + Cm::DelegateTask<Sc::Scene, &Sc::Scene::constraintProjection> mConstraintProjection; + Cm::DelegateTask<Sc::Scene, &Sc::Scene::postSolver> mPostSolver; + Cm::DelegateTask<Sc::Scene, &Sc::Scene::solver> mSolver; + Cm::DelegateTask<Sc::Scene, &Sc::Scene::updateBodiesAndShapes> mUpdateBodiesAndShapes; + Cm::DelegateTask<Sc::Scene, &Sc::Scene::updateSimulationController> mUpdateSimulationController; + Cm::DelegateTask<Sc::Scene, &Sc::Scene::updateDynamics> mUpdateDynamics; + Cm::DelegateTask<Sc::Scene, &Sc::Scene::processLostContacts> mProcessLostContactsTask; + Cm::DelegateTask<Sc::Scene, &Sc::Scene::processLostContacts2> mProcessLostContactsTask2; + Cm::DelegateTask<Sc::Scene, &Sc::Scene::processLostContacts3> mProcessLostContactsTask3; + Cm::DelegateTask<Sc::Scene, &Sc::Scene::destroyManagers> mDestroyManagersTask; + Cm::DelegateTask<Sc::Scene, &Sc::Scene::lostTouchReports> mLostTouchReportsTask; + Cm::DelegateTask<Sc::Scene, &Sc::Scene::unregisterInteractions> mUnregisterInteractionsTask; + Cm::DelegateTask<Sc::Scene, + &Sc::Scene::processNarrowPhaseLostTouchEventsIslands> mProcessNarrowPhaseLostTouchTasks; + Cm::DelegateTask<Sc::Scene, + &Sc::Scene::processNarrowPhaseLostTouchEvents> mProcessNPLostTouchEvents; + Cm::DelegateTask<Sc::Scene, &Sc::Scene::postThirdPassIslandGen> mPostThirdPassIslandGenTask; + Cm::DelegateTask<Sc::Scene, &Sc::Scene::postIslandGen> mPostIslandGen; + Cm::DelegateTask<Sc::Scene, &Sc::Scene::islandGen> mIslandGen; + Cm::DelegateTask<Sc::Scene, &Sc::Scene::preRigidBodyNarrowPhase> mPreRigidBodyNarrowPhase; + Cm::DelegateTask<Sc::Scene, &Sc::Scene::setEdgesConnected> mSetEdgesConnectedTask; + Cm::DelegateTask<Sc::Scene, &Sc::Scene::fetchPatchEvents> mFetchPatchEventsTask; + Cm::DelegateTask<Sc::Scene, &Sc::Scene::processLostSolverPatches> mProcessLostPatchesTask; + Cm::DelegateTask<Sc::Scene, &Sc::Scene::rigidBodyNarrowPhase> mRigidBodyNarrowPhase; + Cm::DelegateTask<Sc::Scene, &Sc::Scene::unblockNarrowPhase> mRigidBodyNPhaseUnlock; + Cm::DelegateTask<Sc::Scene, &Sc::Scene::postBroadPhase> mPostBroadPhase; + Cm::DelegateTask<Sc::Scene, &Sc::Scene::postBroadPhaseStage2> mPostBroadPhase2; + Cm::DelegateFanoutTask<Sc::Scene, &Sc::Scene::postBroadPhaseStage3> mPostBroadPhase3; + Cm::DelegateTask<Sc::Scene, &Sc::Scene::preallocateContactManagers> mPreallocateContactManagers; + Cm::DelegateTask<Sc::Scene, &Sc::Scene::islandInsertion> mIslandInsertion; + Cm::DelegateTask<Sc::Scene, &Sc::Scene::registerContactManagers> mRegisterContactManagers; + Cm::DelegateTask<Sc::Scene, &Sc::Scene::registerInteractions> mRegisterInteractions; + Cm::DelegateTask<Sc::Scene, &Sc::Scene::registerSceneInteractions> mRegisterSceneInteractions; + Cm::DelegateTask<Sc::Scene, &Sc::Scene::broadPhase> mBroadPhase; + Cm::DelegateTask<Sc::Scene, &Sc::Scene::advanceStep> mAdvanceStep; + Cm::DelegateTask<Sc::Scene, &Sc::Scene::collideStep> mCollideStep; + + Cm::FlushPool mTaskPool; + PxTaskManager* mTaskManager; + + bool mContactReportsNeedPostSolverVelocity; + + SimulationStage::Enum mSimulationStage; + + ConstraintGroupNode** mTmpConstraintGroupRootBuffer; // temporary list of constraint group roots, used for constraint projection + + Ps::CoalescedHashSet<const BodySim*> mPosePreviewBodies; // list of bodies that requested early report of the integrated pose (eENABLE_POSE_INTEGRATION_PREVIEW). + + Ps::Array<PxsContactManager*> mPreallocatedContactManagers; + Ps::Array<ShapeInteraction*> mPreallocatedShapeInteractions; + Ps::Array<ElementInteractionMarker*> mPreallocatedInteractionMarkers; + + Ps::Array<OverlapFilterTask*> mOverlapFilterTasks; + Ps::Array<PxFilterInfo> mFilterInfo; + Cm::BitMap mSpeculativeCCDRigidBodyBitMap; + Cm::BitMap mSpeculativeCDDArticulationBitMap; + }; + +} // namespace Sc + +} + +#endif diff --git a/PhysX_3.4/Source/SimulationController/include/ScShapeCore.h b/PhysX_3.4/Source/SimulationController/include/ScShapeCore.h new file mode 100644 index 00000000..be65cd60 --- /dev/null +++ b/PhysX_3.4/Source/SimulationController/include/ScShapeCore.h @@ -0,0 +1,129 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 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_PHYSICS_SCP_SHAPECORE +#define PX_PHYSICS_SCP_SHAPECORE + +#include "PsUserAllocated.h" +#include "GuGeometryUnion.h" +#include "PxvGeometry.h" +#include "PsUtilities.h" +#include "PxFiltering.h" +#include "PxShape.h" + +namespace physx +{ +class PxShape; + +namespace Sc +{ + class Scene; + class RigidCore; + class BodyCore; + class ShapeSim; + class MaterialCore; + + class ShapeCore : public Ps::UserAllocated + { + //= ATTENTION! ===================================================================================== + // Changing the data layout of this class breaks the binary serialization format. See comments for + // PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData + // function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION + // accordingly. + //================================================================================================== + public: +// PX_SERIALIZATION + ShapeCore(const PxEMPTY); + void exportExtraData(PxSerializationContext& stream); + void importExtraData(PxDeserializationContext& context); + void resolveReferences(PxDeserializationContext& context); + static void getBinaryMetaData(PxOutputStream& stream); + void resolveMaterialReference(PxU32 materialTableIndex, PxU16 materialIndex); +//~PX_SERIALIZATION + + ShapeCore(const PxGeometry& geometry, + PxShapeFlags shapeFlags, + const PxU16* materialIndices, + PxU16 materialCount); + + ~ShapeCore(); + + PX_FORCE_INLINE PxGeometryType::Enum getGeometryType() const { return mCore.geometry.getType(); } + PxShape* getPxShape(); + const PxShape* getPxShape() const; + + PX_FORCE_INLINE const Gu::GeometryUnion& getGeometryUnion() const { return mCore.geometry; } + PX_FORCE_INLINE const PxGeometry& getGeometry() const { return mCore.geometry.getGeometry(); } + void setGeometry(const PxGeometry& geom); + + PxU16 getNbMaterialIndices() const; + const PxU16* getMaterialIndices() const; + void setMaterialIndices(const PxU16* materialIndices, PxU16 materialIndexCount); + + PX_FORCE_INLINE const PxTransform& getShape2Actor() const { return mCore.transform; } + PX_FORCE_INLINE void setShape2Actor(const PxTransform& s2b) { mCore.transform = s2b; } + + PX_FORCE_INLINE const PxFilterData& getSimulationFilterData() const { return mSimulationFilterData; } + PX_FORCE_INLINE void setSimulationFilterData(const PxFilterData& data) { mSimulationFilterData = data; } + + // PT: this one doesn't need double buffering + PX_FORCE_INLINE const PxFilterData& getQueryFilterData() const { return mQueryFilterData; } + PX_FORCE_INLINE void setQueryFilterData(const PxFilterData& data) { mQueryFilterData = data; } + + PX_FORCE_INLINE PxReal getContactOffset() const { return mCore.contactOffset; } + PX_FORCE_INLINE void setContactOffset(PxReal offset) { mCore.contactOffset = offset; } + + PX_FORCE_INLINE PxReal getRestOffset() const { return mRestOffset; } + PX_FORCE_INLINE void setRestOffset(PxReal offset) { mRestOffset = offset; } + + PX_FORCE_INLINE PxShapeFlags getFlags() const { return PxShapeFlags(mCore.mShapeFlags); } + PX_FORCE_INLINE void setFlags(PxShapeFlags f) { mCore.mShapeFlags = f; } + + PX_FORCE_INLINE const PxsShapeCore& getCore() const { return mCore; } + + static PX_FORCE_INLINE ShapeCore& getCore(PxsShapeCore& core) + { + size_t offset = PX_OFFSET_OF(ShapeCore, mCore); + return *reinterpret_cast<ShapeCore*>(reinterpret_cast<PxU8*>(&core) - offset); + } + + protected: + PxFilterData mQueryFilterData; // Query filter data PT: TODO: consider moving this to SceneQueryShapeData + PxFilterData mSimulationFilterData; // Simulation filter data + PxsShapeCore PX_ALIGN(16, mCore); + PxReal mRestOffset; // same as the API property of the same name + }; + +} // namespace Sc + + +} + +#endif diff --git a/PhysX_3.4/Source/SimulationController/include/ScStaticCore.h b/PhysX_3.4/Source/SimulationController/include/ScStaticCore.h new file mode 100644 index 00000000..b71f405f --- /dev/null +++ b/PhysX_3.4/Source/SimulationController/include/ScStaticCore.h @@ -0,0 +1,78 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 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_PHYSICS_SCP_STATIC_CORE +#define PX_PHYSICS_SCP_STATIC_CORE + +#include "ScRigidCore.h" +#include "PxvDynamics.h" + +namespace physx +{ +namespace Sc +{ + + class StaticSim; + + class StaticCore: public RigidCore + { + //= ATTENTION! ===================================================================================== + // Changing the data layout of this class breaks the binary serialization format. See comments for + // PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData + // function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION + // accordingly. + //================================================================================================== + public: + StaticCore(const PxTransform& actor2World): RigidCore(PxActorType::eRIGID_STATIC) + { + mCore.body2World = actor2World; + mCore.mFlags = PxRigidBodyFlags(); + } + + PX_FORCE_INLINE const PxTransform& getActor2World() const { return mCore.body2World; } + void setActor2World(const PxTransform& actor2World); + + PX_FORCE_INLINE PxsRigidCore& getCore() { return mCore; } + + StaticCore(const PxEMPTY) : RigidCore(PxEmpty), mCore(PxEmpty) {} + static void getBinaryMetaData(PxOutputStream& stream); + + StaticSim* getSim() const; + + PX_FORCE_INLINE void onOriginShift(const PxVec3& shift) { mCore.body2World.p -= shift; } + private: + PxsRigidCore mCore; + }; + +} // namespace Sc + +} + +#endif |