aboutsummaryrefslogtreecommitdiff
path: root/PhysX_3.4/Source/PhysX/src
diff options
context:
space:
mode:
Diffstat (limited to 'PhysX_3.4/Source/PhysX/src')
-rw-r--r--PhysX_3.4/Source/PhysX/src/NpActor.cpp4
-rw-r--r--PhysX_3.4/Source/PhysX/src/NpArticulationLink.cpp4
-rw-r--r--PhysX_3.4/Source/PhysX/src/NpBatchQuery.cpp2
-rw-r--r--PhysX_3.4/Source/PhysX/src/NpFactory.cpp26
-rw-r--r--PhysX_3.4/Source/PhysX/src/NpPhysics.cpp12
-rw-r--r--PhysX_3.4/Source/PhysX/src/NpPvdSceneQueryCollector.cpp27
-rw-r--r--PhysX_3.4/Source/PhysX/src/NpPvdSceneQueryCollector.h134
-rw-r--r--PhysX_3.4/Source/PhysX/src/NpRigidDynamic.cpp4
-rw-r--r--PhysX_3.4/Source/PhysX/src/NpRigidDynamic.h2
-rw-r--r--PhysX_3.4/Source/PhysX/src/NpScene.cpp19
-rw-r--r--PhysX_3.4/Source/PhysX/src/NpScene.h2
-rw-r--r--PhysX_3.4/Source/PhysX/src/NpSceneQueries.cpp2
-rw-r--r--PhysX_3.4/Source/PhysX/src/NpShape.cpp113
-rw-r--r--PhysX_3.4/Source/PhysX/src/NpShape.h6
-rw-r--r--PhysX_3.4/Source/PhysX/src/NpShapeManager.cpp460
-rw-r--r--PhysX_3.4/Source/PhysX/src/NpShapeManager.h2
-rw-r--r--PhysX_3.4/Source/PhysX/src/NpSpatialIndex.cpp41
-rw-r--r--PhysX_3.4/Source/PhysX/src/NpSpatialIndex.h2
-rw-r--r--PhysX_3.4/Source/PhysX/src/PvdMetaDataPvdBinding.cpp108
-rw-r--r--PhysX_3.4/Source/PhysX/src/PvdMetaDataPvdBinding.h12
-rw-r--r--PhysX_3.4/Source/PhysX/src/PvdPhysicsClient.h1
-rw-r--r--PhysX_3.4/Source/PhysX/src/buffering/ScbActor.cpp34
-rw-r--r--PhysX_3.4/Source/PhysX/src/buffering/ScbActor.h16
-rw-r--r--PhysX_3.4/Source/PhysX/src/buffering/ScbAggregate.cpp35
-rw-r--r--PhysX_3.4/Source/PhysX/src/buffering/ScbAggregate.h39
-rw-r--r--PhysX_3.4/Source/PhysX/src/buffering/ScbArticulation.h60
-rw-r--r--PhysX_3.4/Source/PhysX/src/buffering/ScbArticulationJoint.h34
-rw-r--r--PhysX_3.4/Source/PhysX/src/buffering/ScbBase.cpp1
-rw-r--r--PhysX_3.4/Source/PhysX/src/buffering/ScbBase.h45
-rw-r--r--PhysX_3.4/Source/PhysX/src/buffering/ScbBody.h145
-rw-r--r--PhysX_3.4/Source/PhysX/src/buffering/ScbCloth.cpp8
-rw-r--r--PhysX_3.4/Source/PhysX/src/buffering/ScbCloth.h266
-rw-r--r--PhysX_3.4/Source/PhysX/src/buffering/ScbConstraint.h53
-rw-r--r--PhysX_3.4/Source/PhysX/src/buffering/ScbDefs.h50
-rw-r--r--PhysX_3.4/Source/PhysX/src/buffering/ScbMetaData.cpp1
-rw-r--r--PhysX_3.4/Source/PhysX/src/buffering/ScbParticleSystem.cpp14
-rw-r--r--PhysX_3.4/Source/PhysX/src/buffering/ScbParticleSystem.h107
-rw-r--r--PhysX_3.4/Source/PhysX/src/buffering/ScbRigidObject.h103
-rw-r--r--PhysX_3.4/Source/PhysX/src/buffering/ScbRigidStatic.h22
-rw-r--r--PhysX_3.4/Source/PhysX/src/buffering/ScbScene.cpp122
-rw-r--r--PhysX_3.4/Source/PhysX/src/buffering/ScbScene.h216
-rw-r--r--PhysX_3.4/Source/PhysX/src/buffering/ScbSceneBuffer.h98
-rw-r--r--PhysX_3.4/Source/PhysX/src/buffering/ScbScenePvdClient.cpp196
-rw-r--r--PhysX_3.4/Source/PhysX/src/buffering/ScbScenePvdClient.h25
-rw-r--r--PhysX_3.4/Source/PhysX/src/buffering/ScbShape.cpp55
-rw-r--r--PhysX_3.4/Source/PhysX/src/buffering/ScbShape.h102
-rw-r--r--PhysX_3.4/Source/PhysX/src/buffering/ScbType.h27
-rw-r--r--PhysX_3.4/Source/PhysX/src/gpu/PxPhysXGpuModuleLoader.cpp24
48 files changed, 1384 insertions, 1497 deletions
diff --git a/PhysX_3.4/Source/PhysX/src/NpActor.cpp b/PhysX_3.4/Source/PhysX/src/NpActor.cpp
index 940c1dc8..69b49f12 100644
--- a/PhysX_3.4/Source/PhysX/src/NpActor.cpp
+++ b/PhysX_3.4/Source/PhysX/src/NpActor.cpp
@@ -429,13 +429,13 @@ void NpActor::getGlobalPose(PxTransform& globalPose, const Scb::Shape& scbShape,
// PT: TODO: duplicated from SqBounds.cpp. Refactor.
const ScbType::Enum actorType = scbActor.getScbType();
- if(actorType==ScbType::RIGID_STATIC)
+ if(actorType==ScbType::eRIGID_STATIC)
{
Cm::getStaticGlobalPoseAligned(static_cast<const Scb::RigidStatic&>(scbActor).getActor2World(), shape2Actor, globalPose);
}
else
{
- PX_ASSERT(actorType==ScbType::BODY || actorType == ScbType::BODY_FROM_ARTICULATION_LINK);
+ PX_ASSERT(actorType==ScbType::eBODY || actorType == ScbType::eBODY_FROM_ARTICULATION_LINK);
const Scb::Body& body = static_cast<const Scb::Body&>(scbActor);
PX_ALIGN(16, PxTransform) kinematicTarget;
diff --git a/PhysX_3.4/Source/PhysX/src/NpArticulationLink.cpp b/PhysX_3.4/Source/PhysX/src/NpArticulationLink.cpp
index 1843d7d1..19f99046 100644
--- a/PhysX_3.4/Source/PhysX/src/NpArticulationLink.cpp
+++ b/PhysX_3.4/Source/PhysX/src/NpArticulationLink.cpp
@@ -90,8 +90,8 @@ NpArticulationLink::NpArticulationLink(const PxTransform& bodyPose, NpArticulati
, mInboundJoint(NULL)
, mParent(parent)
{
- PX_ASSERT(mBody.getScbType() == ScbType::BODY);
- mBody.setScbType(ScbType::BODY_FROM_ARTICULATION_LINK);
+ PX_ASSERT(mBody.getScbType() == ScbType::eBODY);
+ mBody.setScbType(ScbType::eBODY_FROM_ARTICULATION_LINK);
mRoot->addToLinkList(*this);
diff --git a/PhysX_3.4/Source/PhysX/src/NpBatchQuery.cpp b/PhysX_3.4/Source/PhysX/src/NpBatchQuery.cpp
index f428e706..250548ca 100644
--- a/PhysX_3.4/Source/PhysX/src/NpBatchQuery.cpp
+++ b/PhysX_3.4/Source/PhysX/src/NpBatchQuery.cpp
@@ -327,7 +327,7 @@ void NpBatchQuery::execute()
PxU32 pvdSweepQstartIdx = 0;
Vd::ScbScenePvdClient& pvdClient = mNpScene->mScene.getScenePvdClient();
- const bool needUpdatePvd = pvdClient.checkPvdDebugFlag() && (pvdClient.getScenePvdFlags() & PxPvdSceneFlag::eTRANSMIT_SCENEQUERIES);
+ const bool needUpdatePvd = pvdClient.checkPvdDebugFlag() && (pvdClient.getScenePvdFlagsFast() & PxPvdSceneFlag::eTRANSMIT_SCENEQUERIES);
if(needUpdatePvd)
{
diff --git a/PhysX_3.4/Source/PhysX/src/NpFactory.cpp b/PhysX_3.4/Source/PhysX/src/NpFactory.cpp
index bd026191..0d23052e 100644
--- a/PhysX_3.4/Source/PhysX/src/NpFactory.cpp
+++ b/PhysX_3.4/Source/PhysX/src/NpFactory.cpp
@@ -1231,23 +1231,23 @@ namespace physx
{
switch(base.getScbType())
{
- case ScbType::SHAPE_EXCLUSIVE:
- case ScbType::SHAPE_SHARED: { NpDestroyShape(static_cast<Scb::Shape&>(base)); }break;
- case ScbType::BODY: { NpDestroyRigidDynamic(static_cast<Scb::Body&>(base)); }break;
- case ScbType::BODY_FROM_ARTICULATION_LINK: { NpDestroyArticulationLink(static_cast<Scb::Body&>(base)); }break;
- case ScbType::RIGID_STATIC: { NpDestroyRigidActor(static_cast<Scb::RigidStatic&>(base)); }break;
- case ScbType::CONSTRAINT: { NpDestroyConstraint(static_cast<Scb::Constraint&>(base)); }break;
+ case ScbType::eSHAPE_EXCLUSIVE:
+ case ScbType::eSHAPE_SHARED: { NpDestroyShape(static_cast<Scb::Shape&>(base)); }break;
+ case ScbType::eBODY: { NpDestroyRigidDynamic(static_cast<Scb::Body&>(base)); }break;
+ case ScbType::eBODY_FROM_ARTICULATION_LINK: { NpDestroyArticulationLink(static_cast<Scb::Body&>(base)); }break;
+ case ScbType::eRIGID_STATIC: { NpDestroyRigidActor(static_cast<Scb::RigidStatic&>(base)); }break;
+ case ScbType::eCONSTRAINT: { NpDestroyConstraint(static_cast<Scb::Constraint&>(base)); }break;
#if PX_USE_PARTICLE_SYSTEM_API
- case ScbType::PARTICLE_SYSTEM: { NpDestroyParticleSystem(static_cast<Scb::ParticleSystem&>(base)); }break;
+ case ScbType::ePARTICLE_SYSTEM: { NpDestroyParticleSystem(static_cast<Scb::ParticleSystem&>(base)); }break;
#endif
- case ScbType::ARTICULATION: { NpDestroyArticulation(static_cast<Scb::Articulation&>(base)); }break;
- case ScbType::ARTICULATION_JOINT: { NpDestroyArticulationJoint(static_cast<Scb::ArticulationJoint&>(base)); }break;
- case ScbType::AGGREGATE: { NpDestroyAggregate(static_cast<Scb::Aggregate&>(base)); }break;
+ case ScbType::eARTICULATION: { NpDestroyArticulation(static_cast<Scb::Articulation&>(base)); }break;
+ case ScbType::eARTICULATION_JOINT: { NpDestroyArticulationJoint(static_cast<Scb::ArticulationJoint&>(base)); }break;
+ case ScbType::eAGGREGATE: { NpDestroyAggregate(static_cast<Scb::Aggregate&>(base)); }break;
#if PX_USE_CLOTH_API
- case ScbType::CLOTH: { NpDestroyCloth(static_cast<Scb::Cloth&>(base)); }break;
+ case ScbType::eCLOTH: { NpDestroyCloth(static_cast<Scb::Cloth&>(base)); }break;
#endif
- case ScbType::UNDEFINED:
- case ScbType::TYPE_COUNT:
+ case ScbType::eUNDEFINED:
+ case ScbType::eTYPE_COUNT:
PX_ALWAYS_ASSERT_MESSAGE("NpDestroy: missing type!");
break;
}
diff --git a/PhysX_3.4/Source/PhysX/src/NpPhysics.cpp b/PhysX_3.4/Source/PhysX/src/NpPhysics.cpp
index f2397d90..0c2c07ea 100644
--- a/PhysX_3.4/Source/PhysX/src/NpPhysics.cpp
+++ b/PhysX_3.4/Source/PhysX/src/NpPhysics.cpp
@@ -202,18 +202,18 @@ void NpPhysics::initOffsetTables(PxvOffsetTable& pxvOffsetTable)
offsetTable.pxActorToScbActor[PxConcreteType::eCLOTH] = reinterpret_cast<ptrdiff_t>(&static_cast<NpCloth*>(n)->getScbCloth()) - addr;
#endif
// init scb2sc
- for(PxU32 i=0;i<ScbType::TYPE_COUNT;i++)
+ for(PxU32 i=0;i<ScbType::eTYPE_COUNT;i++)
offsetTable.scbToSc[i] = 0;
ptrdiff_t staticOffset = static_cast<ptrdiff_t>(Scb::RigidStatic::getScOffset());
ptrdiff_t bodyOffset = static_cast<ptrdiff_t>(Scb::Body::getScOffset());
- offsetTable.scbToSc[ScbType::RIGID_STATIC] = staticOffset;
- offsetTable.scbToSc[ScbType::BODY] = bodyOffset;
- offsetTable.scbToSc[ScbType::BODY_FROM_ARTICULATION_LINK] = bodyOffset;
+ offsetTable.scbToSc[ScbType::eRIGID_STATIC] = staticOffset;
+ offsetTable.scbToSc[ScbType::eBODY] = bodyOffset;
+ offsetTable.scbToSc[ScbType::eBODY_FROM_ARTICULATION_LINK] = bodyOffset;
#if PX_USE_PARTICLE_SYSTEM_API
- offsetTable.scbToSc[ScbType::PARTICLE_SYSTEM] = static_cast<ptrdiff_t>(Scb::ParticleSystem::getScOffset());
+ offsetTable.scbToSc[ScbType::ePARTICLE_SYSTEM] = static_cast<ptrdiff_t>(Scb::ParticleSystem::getScOffset());
#endif
#if PX_USE_CLOTH_API
- offsetTable.scbToSc[ScbType::CLOTH] = static_cast<ptrdiff_t>(Scb::Cloth::getScOffset());
+ offsetTable.scbToSc[ScbType::eCLOTH] = static_cast<ptrdiff_t>(Scb::Cloth::getScOffset());
#endif
}
{
diff --git a/PhysX_3.4/Source/PhysX/src/NpPvdSceneQueryCollector.cpp b/PhysX_3.4/Source/PhysX/src/NpPvdSceneQueryCollector.cpp
index 2756f1a1..a4f2cc55 100644
--- a/PhysX_3.4/Source/PhysX/src/NpPvdSceneQueryCollector.cpp
+++ b/PhysX_3.4/Source/PhysX/src/NpPvdSceneQueryCollector.cpp
@@ -34,6 +34,29 @@ using namespace physx;
using namespace Sq;
using namespace Vd;
+static const char* gName_PvdRaycast[2] = { "SceneQueries.Raycasts", "BatchedQueries.Raycasts" };
+static const char* gName_PvdSweep[2] = { "SceneQueries.Sweeps", "BatchedQueries.Sweeps" };
+static const char* gName_PvdOverlap[2] = { "SceneQueries.Overlaps", "BatchedQueries.Overlaps" };
+static const char* gName_PvdSqHit[2] = { "SceneQueries.Hits", "BatchedQueries.Hits" };
+static const char* gName_PxTransform[2] = { "SceneQueries.PoseList", "BatchedQueries.PoseList" };
+static const char* gName_PxFilterData[2] = { "SceneQueries.FilterDataList", "BatchedQueries.FilterDataList" };
+static const char* gName_PxGeometryHolder[2] = { "SceneQueries.GeometryList", "BatchedQueries.GeometryList" };
+
+PvdSceneQueryCollector::PvdSceneQueryCollector(Scb::Scene& scene, bool isBatched) :
+ mAccumulatedRaycastQueries (gName_PvdRaycast),
+ mAccumulatedSweepQueries (gName_PvdSweep),
+ mAccumulatedOverlapQueries (gName_PvdOverlap),
+ mPvdSqHits (gName_PvdSqHit),
+ mPoses (gName_PxTransform),
+ mFilterData (gName_PxFilterData),
+ mScene (scene),
+ mGeometries0 (gName_PxGeometryHolder),
+ mGeometries1 (gName_PxGeometryHolder),
+ mInUse (0),
+ mIsBatched (isBatched)
+{
+}
+
void PvdSceneQueryCollector::release()
{
physx::pvdsdk::PvdDataStream* stream = mScene.getScenePvdClient().getDataStream();
@@ -122,7 +145,7 @@ void PvdSceneQueryCollector::sweep(const PxGeometry& geometry, const PxTransform
Ps::Mutex::ScopedLock lock(mMutex);
PvdSweep sweepQuery;
- pushBackT(mGeometries[mInUse], PxGeometryHolder(geometry), sweepQuery.mGeometries, getArrayName(mGeometries[mInUse])); // PT: TODO: optimize this. We memcopy once to the stack, then again to the array....
+ pushBackT(getGeometries(mInUse), PxGeometryHolder(geometry), sweepQuery.mGeometries, getArrayName(getGeometries(mInUse))); // PT: TODO: optimize this. We memcopy once to the stack, then again to the array....
pushBackT(mPoses, pose, sweepQuery.mPoses, getArrayName(mPoses));
pushBackT(mFilterData, fd.data, sweepQuery.mFilterData, getArrayName(mFilterData));
@@ -143,7 +166,7 @@ void PvdSceneQueryCollector::overlapMultiple(const PxGeometry& geometry, const P
Ps::Mutex::ScopedLock lock(mMutex);
PvdOverlap overlapQuery;
- pushBackT(mGeometries[mInUse], PxGeometryHolder(geometry), overlapQuery.mGeometries, getArrayName(mGeometries[mInUse])); // PT: TODO: optimize this. We memcopy once to the stack, then again to the array....
+ pushBackT(getGeometries(mInUse), PxGeometryHolder(geometry), overlapQuery.mGeometries, getArrayName(getGeometries(mInUse))); // PT: TODO: optimize this. We memcopy once to the stack, then again to the array....
const PxGeometryType::Enum type = geometry.getType();
if(type==PxGeometryType::eBOX) overlapQuery.mType = pose.q.isIdentity() ? QueryID::QUERY_OVERLAP_AABB_ALL_OBJECTS : QueryID::QUERY_OVERLAP_OBB_ALL_OBJECTS;
diff --git a/PhysX_3.4/Source/PhysX/src/NpPvdSceneQueryCollector.h b/PhysX_3.4/Source/PhysX/src/NpPvdSceneQueryCollector.h
index 38fe3091..b5d464da 100644
--- a/PhysX_3.4/Source/PhysX/src/NpPvdSceneQueryCollector.h
+++ b/PhysX_3.4/Source/PhysX/src/NpPvdSceneQueryCollector.h
@@ -147,88 +147,21 @@ struct PvdSqHit
}
};
-template <typename T, bool isBatched>
-inline const char* PvdGetArrayName()
+template <class T>
+class NamedArray : public Ps::Array<T>
{
- return T::template getArrayName<isBatched>();
-}
-template <>
-inline const char* PvdGetArrayName<PxGeometryHolder, false>()
-{
- return "SceneQueries.GeometryList";
-}
-template <>
-inline const char* PvdGetArrayName<PxTransform, false>()
-{
- return "SceneQueries.PoseList";
-}
-template <>
-inline const char* PvdGetArrayName<PxFilterData, false>()
-{
- return "SceneQueries.FilterDataList";
-}
-template <>
-inline const char* PvdGetArrayName<PvdRaycast, false>()
-{
- return "SceneQueries.Raycasts";
-}
-template <>
-inline const char* PvdGetArrayName<PvdOverlap, false>()
-{
- return "SceneQueries.Overlaps";
-}
-template <>
-inline const char* PvdGetArrayName<PvdSweep, false>()
-{
- return "SceneQueries.Sweeps";
-}
-template <>
-inline const char* PvdGetArrayName<PvdSqHit, false>()
-{
- return "SceneQueries.Hits";
-}
-template <>
-inline const char* PvdGetArrayName<PxGeometryHolder, true>()
-{
- return "BatchedQueries.GeometryList";
-}
-template <>
-inline const char* PvdGetArrayName<PxTransform, true>()
-{
- return "BatchedQueries.PoseList";
-}
-template <>
-inline const char* PvdGetArrayName<PxFilterData, true>()
-{
- return "BatchedQueries.FilterDataList";
-}
-template <>
-inline const char* PvdGetArrayName<PvdRaycast, true>()
-{
- return "BatchedQueries.Raycasts";
-}
-template <>
-inline const char* PvdGetArrayName<PvdOverlap, true>()
-{
- return "BatchedQueries.Overlaps";
-}
-template <>
-inline const char* PvdGetArrayName<PvdSweep, true>()
-{
- return "BatchedQueries.Sweeps";
-}
-template <>
-inline const char* PvdGetArrayName<PvdSqHit, true>()
-{
- return "BatchedQueries.Hits";
-}
+ public:
+ NamedArray(const char* names[2]) { mNames[0] = names[0]; mNames[1] = names[1]; }
+
+ const char* mNames[2];
+};
class PvdSceneQueryCollector
{
PX_NOCOPY(PvdSceneQueryCollector)
public:
- PvdSceneQueryCollector(Scb::Scene& scene, bool isBatched) : mScene(scene), mInUse(0), mIsBatched(isBatched) {}
- ~PvdSceneQueryCollector() {}
+ PvdSceneQueryCollector(Scb::Scene& scene, bool isBatched);
+ ~PvdSceneQueryCollector() {}
void clear()
{
@@ -244,8 +177,8 @@ public:
void clearGeometryArrays()
{
- mGeometries[0].clear();
- mGeometries[1].clear();
+ mGeometries0.clear();
+ mGeometries1.clear();
}
void release();
@@ -258,42 +191,35 @@ public:
const PxOverlapQueryResult* overlapResults, PxU32 nbOverlapResults, PxU32 batchedOverlapQstartIdx,
const PxSweepQueryResult* sweepResults, PxU32 nbSweepResults, PxU32 batchedSweepQstartIdx);
- PX_FORCE_INLINE Ps::Mutex& getLock()
- {
- return mMutex;
- }
+ PX_FORCE_INLINE Ps::Mutex& getLock() { return mMutex; }
+
+ template <class T>
+ PX_FORCE_INLINE const char* getArrayName(const NamedArray<T>& namedArray) const { return namedArray.mNames[mIsBatched]; }
+
+ PX_FORCE_INLINE const NamedArray<PxGeometryHolder>& getGeometries(PxU32 index) const { return index ? mGeometries1 : mGeometries0; }
+ PX_FORCE_INLINE NamedArray<PxGeometryHolder>& getGeometries(PxU32 index) { return index ? mGeometries1 : mGeometries0; }
+
+ PX_FORCE_INLINE const NamedArray<PxGeometryHolder>& getCurrentFrameGeometries() const { return getGeometries(mInUse); }
+ PX_FORCE_INLINE const NamedArray<PxGeometryHolder>& getPrevFrameGeometries() const { return getGeometries(mInUse ^ 1); }
- PX_FORCE_INLINE const Ps::Array<PxGeometryHolder>& getCurrentFrameGeometries() const
- {
- return mGeometries[mInUse];
- }
- PX_FORCE_INLINE const Ps::Array<PxGeometryHolder>& getPrevFrameGeometries() const
- {
- return mGeometries[mInUse ^ 1];
- }
void prepareNextFrameGeometries()
{
mInUse ^= 1;
- mGeometries[mInUse].clear();
- }
- template <typename T>
- const char* getArrayName(const Ps::Array<T>&)
- {
- return mIsBatched ? PvdGetArrayName<T, 1>() : PvdGetArrayName<T, 0>();
+ getGeometries(mInUse).clear();
}
- // Scene query and hits for pvd, collected in current frame
- Ps::Array<PvdRaycast> mAccumulatedRaycastQueries;
- Ps::Array<PvdSweep> mAccumulatedSweepQueries;
- Ps::Array<PvdOverlap> mAccumulatedOverlapQueries;
- Ps::Array<PvdSqHit> mPvdSqHits;
- Ps::Array<PxTransform> mPoses;
- Ps::Array<PxFilterData> mFilterData;
+ NamedArray<PvdRaycast> mAccumulatedRaycastQueries;
+ NamedArray<PvdSweep> mAccumulatedSweepQueries;
+ NamedArray<PvdOverlap> mAccumulatedOverlapQueries;
+ NamedArray<PvdSqHit> mPvdSqHits;
+ NamedArray<PxTransform> mPoses;
+ NamedArray<PxFilterData> mFilterData;
private:
Scb::Scene& mScene;
Ps::Mutex mMutex;
- Ps::Array<PxGeometryHolder> mGeometries[2];
+ NamedArray<PxGeometryHolder>mGeometries0;
+ NamedArray<PxGeometryHolder>mGeometries1;
PxU32 mInUse;
const bool mIsBatched;
};
diff --git a/PhysX_3.4/Source/PhysX/src/NpRigidDynamic.cpp b/PhysX_3.4/Source/PhysX/src/NpRigidDynamic.cpp
index 52ccccab..e5303657 100644
--- a/PhysX_3.4/Source/PhysX/src/NpRigidDynamic.cpp
+++ b/PhysX_3.4/Source/PhysX/src/NpRigidDynamic.cpp
@@ -133,11 +133,11 @@ void NpRigidDynamic::setKinematicTarget(const PxTransform& destination)
}
-bool NpRigidDynamic::getKinematicTarget(PxTransform& target)
+bool NpRigidDynamic::getKinematicTarget(PxTransform& target) const
{
NP_READ_CHECK(NpActor::getOwnerScene(*this));
- Scb::Body& b = getScbBodyFast();
+ const Scb::Body& b = getScbBodyFast();
if(b.getFlags() & PxRigidBodyFlag::eKINEMATIC)
{
PxTransform bodyTarget;
diff --git a/PhysX_3.4/Source/PhysX/src/NpRigidDynamic.h b/PhysX_3.4/Source/PhysX/src/NpRigidDynamic.h
index 1458f0fe..ae429749 100644
--- a/PhysX_3.4/Source/PhysX/src/NpRigidDynamic.h
+++ b/PhysX_3.4/Source/PhysX/src/NpRigidDynamic.h
@@ -87,7 +87,7 @@ public:
}
virtual void setKinematicTarget(const PxTransform& destination);
- virtual bool getKinematicTarget(PxTransform& target);
+ virtual bool getKinematicTarget(PxTransform& target) const;
// Center of mass pose
virtual void setCMassLocalPose(const PxTransform&);
diff --git a/PhysX_3.4/Source/PhysX/src/NpScene.cpp b/PhysX_3.4/Source/PhysX/src/NpScene.cpp
index eb81cb66..2d9eb731 100644
--- a/PhysX_3.4/Source/PhysX/src/NpScene.cpp
+++ b/PhysX_3.4/Source/PhysX/src/NpScene.cpp
@@ -907,7 +907,7 @@ void NpScene::addArticulation(PxArticulation& articulation)
}
Scb::Articulation& art = static_cast<NpArticulation&>(articulation).getArticulation();
- Scb::ControlState::Enum cs = art.getControlState();
+ const Scb::ControlState::Enum cs = art.getControlState();
if ((cs == Scb::ControlState::eNOT_IN_SCENE) || ((cs == Scb::ControlState::eREMOVE_PENDING) && (art.getScbScene()->getPxScene() == this)))
addArticulationInternal(articulation);
else
@@ -1130,7 +1130,7 @@ void NpScene::addAggregate(PxAggregate& aggregate)
#endif
Scb::Aggregate& agg = np.getScbAggregate();
- Scb::ControlState::Enum cs = agg.getControlState();
+ const Scb::ControlState::Enum cs = agg.getControlState();
if ((cs == Scb::ControlState::eNOT_IN_SCENE) || ((cs == Scb::ControlState::eREMOVE_PENDING) && (agg.getScbScene()->getPxScene() == this)))
{
mScene.addAggregate(agg);
@@ -1490,6 +1490,8 @@ void NpScene::visualize()
{
NP_READ_CHECK(this);
+ PX_PROFILE_ZONE("NpScene::visualize", getContextId());
+
mRenderBuffer.clear(); // clear last frame visualizations
#if PX_ENABLE_DEBUG_VISUALIZATION
@@ -2187,9 +2189,9 @@ bool NpScene::fetchCollision(bool block)
class SqRefFinder: public Sc::SqRefFinder
{
public:
- PxU32 find(const PxRigidBody * body, const PxShape* shape)
+ virtual Sq::PrunerHandle find(const PxRigidBody* body, const PxShape* shape)
{
- Sq::PrunerData prunerdata = NpActor::getShapeManager(*body)->findSceneQueryData(*static_cast<const NpShape*>(shape));
+ const Sq::PrunerData prunerdata = NpActor::getShapeManager(*body)->findSceneQueryData(*static_cast<const NpShape*>(shape));
return Sq::getPrunerHandle(prunerdata);
}
private:
@@ -2224,8 +2226,7 @@ void NpScene::fetchResultsPreContactCallbacks()
void NpScene::fetchResultsPostContactCallbacks()
{
mScene.postCallbacksPreSync();
- mScene.setPhysicsBuffering(false); // Clear the buffering flag to allow buffered writes to execute immediately. Once collision detection is running, buffering is automatically forced on
- mScene.syncEntireScene(NULL); // double buffering
+ mScene.syncEntireScene(); // double buffering
SqRefFinder sqRefFinder;
mScene.getScScene().syncSceneQueryBounds(mSQManager.getDynamicBoundsSync(), sqRefFinder);
@@ -2314,7 +2315,7 @@ bool NpScene::fetchResults(bool block, PxU32* errorState)
PX_PROFILE_STOP_CROSSTHREAD("Basic.simulate", getContextId());
if(errorState)
- *errorState = mScene.getScScene().getErrorState();
+ *errorState = 0;
}
#if PX_SUPPORT_PVD
@@ -2430,7 +2431,7 @@ void NpScene::fetchResultsFinish(PxU32* errorState)
fetchResultsPostContactCallbacks();
if (errorState)
- *errorState = mScene.getScScene().getErrorState();
+ *errorState = 0;
PX_PROFILE_STOP_CROSSTHREAD("Basic.fetchResults", getContextId());
PX_PROFILE_STOP_CROSSTHREAD("Basic.simulate", getContextId());
@@ -2741,7 +2742,7 @@ void NpScene::setVisualizationCullingBox(const PxBounds3& box)
mScene.setVisualizationCullingBox(box);
}
-const PxBounds3& NpScene::getVisualizationCullingBox() const
+PxBounds3 NpScene::getVisualizationCullingBox() const
{
NP_READ_CHECK(this);
const PxBounds3& bounds = mScene.getVisualizationCullingBox();
diff --git a/PhysX_3.4/Source/PhysX/src/NpScene.h b/PhysX_3.4/Source/PhysX/src/NpScene.h
index 892e0f99..3190af8b 100644
--- a/PhysX_3.4/Source/PhysX/src/NpScene.h
+++ b/PhysX_3.4/Source/PhysX/src/NpScene.h
@@ -245,7 +245,7 @@ class NpScene : public NpSceneQueries, public Ps::UserAllocated
virtual PxReal getVisualizationParameter(PxVisualizationParameter::Enum param) const;
virtual void setVisualizationCullingBox(const PxBounds3& box);
- virtual const PxBounds3& getVisualizationCullingBox() const;
+ virtual PxBounds3 getVisualizationCullingBox() const;
virtual PxTaskManager* getTaskManager() { return mTaskManager; }
void checkBeginWrite() const {}
diff --git a/PhysX_3.4/Source/PhysX/src/NpSceneQueries.cpp b/PhysX_3.4/Source/PhysX/src/NpSceneQueries.cpp
index afadf740..1ccaa43a 100644
--- a/PhysX_3.4/Source/PhysX/src/NpSceneQueries.cpp
+++ b/PhysX_3.4/Source/PhysX/src/NpSceneQueries.cpp
@@ -610,7 +610,7 @@ struct CapturePvdOnReturn : public PxHitCallback<HitType>
~CapturePvdOnReturn()
{
const physx::Vd::ScbScenePvdClient& pvdClient = mSQ->getScene().getScenePvdClient();
- if(!(pvdClient.isConnected() && (pvdClient.getScenePvdFlags() & PxPvdSceneFlag::eTRANSMIT_SCENEQUERIES)))
+ if(!(pvdClient.checkPvdDebugFlag() && (pvdClient.getScenePvdFlagsFast() & PxPvdSceneFlag::eTRANSMIT_SCENEQUERIES)))
return;
physx::Vd::PvdSceneQueryCollector& collector = mBFD ? mSQ->getBatchedSqCollector() : mSQ->getSingleSqCollector();
diff --git a/PhysX_3.4/Source/PhysX/src/NpShape.cpp b/PhysX_3.4/Source/PhysX/src/NpShape.cpp
index eafbd852..23636404 100644
--- a/PhysX_3.4/Source/PhysX/src/NpShape.cpp
+++ b/PhysX_3.4/Source/PhysX/src/NpShape.cpp
@@ -214,6 +214,27 @@ Sc::RigidCore& NpShape::getScRigidObjectExclusive() const
return static_cast<NpRigidStatic&>(*mActor).getScbRigidStaticFast().getScStatic();
}
+void NpShape::updateSQ(const char* errorMessage)
+{
+ if(mActor && (mShape.getFlags() & PxShapeFlag::eSCENE_QUERY_SHAPE))
+ {
+ NpScene* scene = NpActor::getAPIScene(*mActor);
+ NpShapeManager* shapeManager = NpActor::getShapeManager(*mActor);
+ if(scene)
+ {
+ const PrunerData sqData = shapeManager->findSceneQueryData(*this);
+ scene->getSceneQueryManagerFast().markForUpdate(sqData);
+ }
+
+ // invalidate the pruning structure if the actor bounds changed
+ if(shapeManager->getPruningStructure())
+ {
+ Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, errorMessage);
+ shapeManager->getPruningStructure()->invalidate(mActor);
+ }
+ }
+}
+
PxGeometryType::Enum NpShape::getGeometryType() const
{
NP_READ_CHECK(getOwnerScene());
@@ -284,25 +305,7 @@ void NpShape::setGeometry(const PxGeometry& g)
incMeshRefCount();
- if((mShape.getFlags() & PxShapeFlag::eSCENE_QUERY_SHAPE) && mActor)
- {
- PX_ASSERT(mActor);
-
- NpScene* scene = NpActor::getOwnerScene(*mActor);
- NpShapeManager* shapeManager = NpActor::getShapeManager(*mActor);
- if(scene)
- {
- const PrunerData sqData = shapeManager->findSceneQueryData(*this);
- scene->getSceneQueryManagerFast().markForUpdate(sqData);
- }
-
- // invalidate the pruning structure if the actor bounds changed
- if (shapeManager->getPruningStructure())
- {
- Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "PxShape::setGeometry: Shape is a part of pruning structure, pruning structure is now invalid!");
- shapeManager->getPruningStructure()->invalidate(mActor);
- }
- }
+ updateSQ("PxShape::setGeometry: Shape is a part of pruning structure, pruning structure is now invalid!");
}
PxGeometryHolder NpShape::getGeometry() const
@@ -345,23 +348,7 @@ void NpShape::setLocalPose(const PxTransform& newShape2Actor)
mShape.setShape2Actor(newShape2Actor.getNormalized());
- if(mShape.getFlags() & PxShapeFlag::eSCENE_QUERY_SHAPE && mActor)
- {
- NpScene* scene = NpActor::getAPIScene(*mActor);
- NpShapeManager* shapeManager = NpActor::getShapeManager(*mActor);
- if(scene)
- {
- const PrunerData sqData = shapeManager->findSceneQueryData(*this);
- scene->getSceneQueryManagerFast().markForUpdate(sqData);
- }
-
- // invalidate the pruning structure if the actor bounds changed
- if (shapeManager->getPruningStructure())
- {
- Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "PxShape::setLocalPose: Shape is a part of pruning structure, pruning structure is now invalid!");
- shapeManager->getPruningStructure()->invalidate(mActor);
- }
- }
+ updateSQ("PxShape::setLocalPose: Shape is a part of pruning structure, pruning structure is now invalid!");
}
PxTransform NpShape::getLocalPose() const
@@ -596,9 +583,10 @@ void NpShape::setFlag(PxShapeFlag::Enum flag, bool value)
setFlagsInternal(shapeFlags);
}
-void NpShape::setFlags( PxShapeFlags inFlags )
+void NpShape::setFlags(PxShapeFlags inFlags)
{
NP_WRITE_CHECK(getOwnerScene());
+ PX_CHECK_AND_RETURN(isWritable(), "PxShape::setFlags: shared shapes attached to actors are not writable.");
PX_SIMD_GUARD;
setFlagsInternal(inFlags);
@@ -666,7 +654,7 @@ NpScene* NpShape::getAPIScene() const
namespace physx
{
-Sc::RigidCore* NpShapeGetScRigidObjectFromScbSLOW(const Scb::Shape &scb)
+Sc::RigidCore* NpShapeGetScRigidObjectFromScbSLOW(const Scb::Shape& scb)
{
const NpShape* np = getNpShape(&scb);
return np->NpShape::getActor() ? &np->getScRigidObjectExclusive() : NULL;
@@ -691,8 +679,7 @@ void NpShapeDecRefCount(Scb::Shape& scb)
}
}
-// see NpConvexMesh.h, NpHeightField.h, NpTriangleMesh.h for details on how ref counting works
-// for meshes
+// see NpConvexMesh.h, NpHeightField.h, NpTriangleMesh.h for details on how ref counting works for meshes
Cm::RefCountable* NpShape::getMeshRefCountable()
{
switch(mShape.getGeometryType())
@@ -803,49 +790,3 @@ bool NpShape::checkMaterialSetup(const PxGeometry& geom, const char* errorMsgPre
}
///////////////////////////////////////////////////////////////////////////////
-
-#if PX_ENABLE_DEBUG_VISUALIZATION
-#include "GuDebug.h"
-
-void NpShape::visualize(Cm::RenderOutput& out, const PxRigidActor& actor)
-{
- NpScene* npScene = NpActor::getOwnerScene(actor);
- PX_ASSERT(npScene);
-
- const PxReal scale = npScene->getVisualizationParameter(PxVisualizationParameter::eSCALE);
- if(!scale) return;
-
- const PxTransform absPose = actor.getGlobalPose() * mShape.getShape2Actor();
-
- if(npScene->getVisualizationParameter(PxVisualizationParameter::eCOLLISION_AABBS))
- out << PxU32(PxDebugColor::eARGB_YELLOW) << PxMat44(PxIdentity) << Cm::DebugBox(Gu::computeBounds(mShape.getGeometry(), absPose, !gUnifiedHeightfieldCollision));
-
- const PxReal collisionAxes = scale * npScene->getVisualizationParameter(PxVisualizationParameter::eCOLLISION_AXES);
- if(collisionAxes != 0.0f)
- out << PxMat44(absPose) << Cm::DebugBasis(PxVec3(collisionAxes), 0xcf0000, 0x00cf00, 0x0000cf);
-
- if( npScene->getVisualizationParameter(PxVisualizationParameter::eCOLLISION_SHAPES) ||
- npScene->getVisualizationParameter(PxVisualizationParameter::eCOLLISION_FNORMALS) ||
- npScene->getVisualizationParameter(PxVisualizationParameter::eCOLLISION_EDGES))
- {
- const PxBounds3& cullbox = npScene->getVisualizationCullingBox();
-
- const PxReal fscale = scale * npScene->getVisualizationParameter(PxVisualizationParameter::eCOLLISION_FNORMALS);
-
- // Pack bool params into bit mask.
- PxU64 mask = 0;
-
- #define SET_MASK(mask, param) (mask |= (PxU64(!!npScene->getVisualizationParameter(param))) << param)
-
- SET_MASK(mask, PxVisualizationParameter::eCULL_BOX);
- SET_MASK(mask, PxVisualizationParameter::eCOLLISION_FNORMALS);
- SET_MASK(mask, PxVisualizationParameter::eCOLLISION_EDGES);
- SET_MASK(mask, PxVisualizationParameter::eCOLLISION_SHAPES);
-
- Sc::ShapeCore& shape = mShape.getScShape();
- const PxU32 numMaterials = shape.getNbMaterialIndices();
- Gu::Debug::visualize(getGeometryFast().getGeometry(), out, absPose, cullbox, mask, fscale, numMaterials);
- }
-}
-
-#endif // PX_ENABLE_DEBUG_VISUALIZATION
diff --git a/PhysX_3.4/Source/PhysX/src/NpShape.h b/PhysX_3.4/Source/PhysX/src/NpShape.h
index fb2b4e2a..d3d36455 100644
--- a/PhysX_3.4/Source/PhysX/src/NpShape.h
+++ b/PhysX_3.4/Source/PhysX/src/NpShape.h
@@ -183,11 +183,6 @@ public:
void onActorAttach(PxRigidActor& actor);
void onActorDetach();
-#if PX_ENABLE_DEBUG_VISUALIZATION
-public:
- virtual void visualize(Cm::RenderOutput& out, const PxRigidActor& owner);
-#endif
-
// These methods are used only for sync'ing, and may only be called on exclusive shapes since only exclusive shapes have buffering
Sc::RigidCore& getScRigidObjectExclusive() const;
void releaseInternal();
@@ -200,6 +195,7 @@ private:
void decMeshRefCount();
Cm::RefCountable* getMeshRefCountable();
bool isWritable();
+ void updateSQ(const char* errorMessage);
PxRigidActor* mActor; // Auto-resolving refs breaks DLL loading for some reason
Scb::Shape mShape;
diff --git a/PhysX_3.4/Source/PhysX/src/NpShapeManager.cpp b/PhysX_3.4/Source/PhysX/src/NpShapeManager.cpp
index ab2d6d8b..55eceec6 100644
--- a/PhysX_3.4/Source/PhysX/src/NpShapeManager.cpp
+++ b/PhysX_3.4/Source/PhysX/src/NpShapeManager.cpp
@@ -31,7 +31,6 @@
#include "NpFactory.h"
#include "ScbRigidObject.h"
#include "NpActor.h"
-#include "SqSceneQueryManager.h"
#include "SqPruningStructure.h"
#include "NpScene.h"
#include "NpPtrTableStorageManager.h"
@@ -40,6 +39,8 @@
using namespace physx;
using namespace Sq;
+using namespace Gu;
+using namespace Cm;
namespace physx
{
@@ -63,7 +64,7 @@ NpShapeManager::NpShapeManager(const PxEMPTY) :
NpShapeManager::~NpShapeManager()
{
PX_ASSERT(!mPruningStructure);
- Cm::PtrTableStorageManager& sm = NpFactory::getInstance().getPtrTableStorageManager();
+ PtrTableStorageManager& sm = NpFactory::getInstance().getPtrTableStorageManager();
mShapes.clear(sm);
mSceneQueryData.clear(sm);
}
@@ -85,7 +86,7 @@ void NpShapeManager::attachShape(NpShape& shape, PxRigidActor& actor)
{
PX_ASSERT(!mPruningStructure);
- Cm::PtrTableStorageManager& sm = NpFactory::getInstance().getPtrTableStorageManager();
+ PtrTableStorageManager& sm = NpFactory::getInstance().getPtrTableStorageManager();
const PxU32 index = getNbShapes();
mShapes.add(&shape, sm);
@@ -106,7 +107,7 @@ void NpShapeManager::detachShape(NpShape& s, PxRigidActor& actor, bool wakeOnLos
{
PX_ASSERT(!mPruningStructure);
- Cm::PtrTableStorageManager& sm = NpFactory::getInstance().getPtrTableStorageManager();
+ PtrTableStorageManager& sm = NpFactory::getInstance().getPtrTableStorageManager();
const PxU32 index = mShapes.find(&s);
PX_ASSERT(index!=0xffffffff);
@@ -143,7 +144,7 @@ void NpShapeManager::detachAll(NpScene* scene)
for(PxU32 i=0;i<nbShapes;i++)
shapes[i]->onActorDetach();
- Cm::PtrTableStorageManager& sm = NpFactory::getInstance().getPtrTableStorageManager();
+ PtrTableStorageManager& sm = NpFactory::getInstance().getPtrTableStorageManager();
mShapes.clear(sm);
mSceneQueryData.clear(sm);
@@ -151,7 +152,7 @@ void NpShapeManager::detachAll(NpScene* scene)
PxU32 NpShapeManager::getShapes(PxShape** buffer, PxU32 bufferSize, PxU32 startIndex) const
{
- return Cm::getArrayOfPointers(buffer, bufferSize, startIndex, getShapes(), getNbShapes());
+ return getArrayOfPointers(buffer, bufferSize, startIndex, getShapes(), getNbShapes());
}
PxBounds3 NpShapeManager::getWorldBounds(const PxRigidActor& actor) const
@@ -159,11 +160,11 @@ PxBounds3 NpShapeManager::getWorldBounds(const PxRigidActor& actor) const
PxBounds3 bounds(PxBounds3::empty());
const PxU32 nbShapes = getNbShapes();
- PxTransform actorPose = actor.getGlobalPose();
+ const PxTransform actorPose = actor.getGlobalPose();
NpShape*const* PX_RESTRICT shapes = getShapes();
for(PxU32 i=0;i<nbShapes;i++)
- bounds.include(Gu::computeBounds(shapes[i]->getScbShape().getGeometry(), actorPose * shapes[i]->getLocalPoseFast(), !physx::gUnifiedHeightfieldCollision));
+ bounds.include(Gu::computeBounds(shapes[i]->getScbShape().getGeometry(), actorPose * shapes[i]->getLocalPoseFast(), !gUnifiedHeightfieldCollision));
return bounds;
}
@@ -284,26 +285,453 @@ void NpShapeManager::teardownSceneQuery(SceneQueryManager& sqManager, PxU32 inde
}
#if PX_ENABLE_DEBUG_VISUALIZATION
-void NpShapeManager::visualize(Cm::RenderOutput& out, NpScene* scene, const PxRigidActor& actor)
+#include "GuHeightFieldUtil.h"
+#include "PxGeometryQuery.h"
+#include "PxMeshQuery.h"
+#include "GuConvexEdgeFlags.h"
+#include "GuMidphaseInterface.h"
+
+static const PxDebugColor::Enum gColors[] =
+{
+ PxDebugColor::eARGB_BLACK,
+ PxDebugColor::eARGB_RED,
+ PxDebugColor::eARGB_GREEN,
+ PxDebugColor::eARGB_BLUE,
+ PxDebugColor::eARGB_YELLOW,
+ PxDebugColor::eARGB_MAGENTA,
+ PxDebugColor::eARGB_CYAN,
+ PxDebugColor::eARGB_WHITE,
+ PxDebugColor::eARGB_GREY,
+ PxDebugColor::eARGB_DARKRED,
+ PxDebugColor::eARGB_DARKGREEN,
+ PxDebugColor::eARGB_DARKBLUE,
+};
+
+static const PxU32 gColorCount = sizeof(gColors)/sizeof(PxDebugColor::Enum);
+
+static const PxU32 gCollisionShapeColor = PxU32(PxDebugColor::eARGB_MAGENTA);
+
+static void visualizeSphere(const PxSphereGeometry& geometry, RenderOutput& out, const PxTransform& absPose)
+{
+ out << gCollisionShapeColor; // PT: no need to output this for each segment!
+
+ out << absPose << DebugCircle(100, geometry.radius);
+
+ PxMat44 rotPose(absPose);
+ Ps::swap(rotPose.column1, rotPose.column2);
+ rotPose.column1 = -rotPose.column1;
+ out << rotPose << DebugCircle(100, geometry.radius);
+
+ Ps::swap(rotPose.column0, rotPose.column2);
+ rotPose.column0 = -rotPose.column0;
+ out << rotPose << DebugCircle(100, geometry.radius);
+}
+
+static void visualizePlane(const PxPlaneGeometry& /*geometry*/, RenderOutput& out, const PxTransform& absPose)
+{
+ PxMat44 rotPose(absPose);
+ Ps::swap(rotPose.column1, rotPose.column2);
+ rotPose.column1 = -rotPose.column1;
+
+ Ps::swap(rotPose.column0, rotPose.column2);
+ rotPose.column0 = -rotPose.column0;
+
+ out << rotPose << gCollisionShapeColor; // PT: no need to output this for each segment!
+ for(PxReal radius = 2.0f; radius < 20.0f ; radius += 2.0f)
+ out << DebugCircle(100, radius*radius);
+}
+
+static void visualizeCapsule(const PxCapsuleGeometry& geometry, RenderOutput& out, const PxTransform& absPose)
+{
+ out << gCollisionShapeColor;
+ out.outputCapsule(geometry.radius, geometry.halfHeight, absPose);
+}
+
+static void visualizeBox(const PxBoxGeometry& geometry, RenderOutput& out, const PxTransform& absPose)
+{
+ out << gCollisionShapeColor;
+ out << absPose << DebugBox(geometry.halfExtents);
+}
+
+static void visualizeConvexMesh(const PxConvexMeshGeometry& geometry, RenderOutput& out, const PxTransform& absPose)
+{
+ const ConvexMesh* convexMesh = static_cast<const ConvexMesh*>(geometry.convexMesh);
+ const ConvexHullData& hullData = convexMesh->getHull();
+
+ const PxVec3* vertices = hullData.getHullVertices();
+ const PxU8* indexBuffer = hullData.getVertexData8();
+ const PxU32 nbPolygons = convexMesh->getNbPolygonsFast();
+
+ const PxMat44 m44(PxMat33(absPose.q) * geometry.scale.toMat33(), absPose.p);
+
+ out << m44 << gCollisionShapeColor; // PT: no need to output this for each segment!
+
+ for(PxU32 i=0; i<nbPolygons; i++)
+ {
+ const PxU32 pnbVertices = hullData.mPolygons[i].mNbVerts;
+
+ PxVec3 begin = m44.transform(vertices[indexBuffer[0]]); // PT: transform it only once before the loop starts
+ for(PxU32 j=1; j<pnbVertices; j++)
+ {
+ const PxVec3 end = m44.transform(vertices[indexBuffer[j]]);
+ out.outputSegment(begin, end);
+ begin = end;
+ }
+ out.outputSegment(begin, m44.transform(vertices[indexBuffer[0]]));
+
+ indexBuffer += pnbVertices;
+ }
+}
+
+static void getTriangle(const Gu::TriangleMesh&, PxU32 i, PxVec3* wp, const PxVec3* vertices, const void* indices, bool has16BitIndices)
+{
+ PxU32 ref0, ref1, ref2;
+
+ if(!has16BitIndices)
+ {
+ const PxU32* dtriangles = reinterpret_cast<const PxU32*>(indices);
+ ref0 = dtriangles[i*3+0];
+ ref1 = dtriangles[i*3+1];
+ ref2 = dtriangles[i*3+2];
+ }
+ else
+ {
+ const PxU16* wtriangles = reinterpret_cast<const PxU16*>(indices);
+ ref0 = wtriangles[i*3+0];
+ ref1 = wtriangles[i*3+1];
+ ref2 = wtriangles[i*3+2];
+ }
+
+ wp[0] = vertices[ref0];
+ wp[1] = vertices[ref1];
+ wp[2] = vertices[ref2];
+}
+
+static void getTriangle(const Gu::TriangleMesh& mesh, PxU32 i, PxVec3* wp, const PxVec3* vertices, const void* indices, const Matrix34& absPose, bool has16BitIndices)
+{
+ PxVec3 localVerts[3];
+ getTriangle(mesh, i, localVerts, vertices, indices, has16BitIndices);
+
+ wp[0] = absPose.transform(localVerts[0]);
+ wp[1] = absPose.transform(localVerts[1]);
+ wp[2] = absPose.transform(localVerts[2]);
+}
+
+static void visualizeActiveEdges(RenderOutput& out, const Gu::TriangleMesh& mesh, PxU32 nbTriangles, const PxU32* results, const Matrix34& absPose)
+{
+ const PxU8* extraTrigData = mesh.getExtraTrigData();
+ PX_ASSERT(extraTrigData);
+
+ const PxVec3* vertices = mesh.getVerticesFast();
+ const void* indices = mesh.getTrianglesFast();
+
+ out << PxU32(PxDebugColor::eARGB_YELLOW); // PT: no need to output this for each segment!
+
+ const bool has16Bit = mesh.has16BitIndices();
+ for(PxU32 i=0; i<nbTriangles; i++)
+ {
+ const PxU32 index = results ? results[i] : i;
+
+ PxVec3 wp[3];
+ getTriangle(mesh, index, wp, vertices, indices, absPose, has16Bit);
+
+ const PxU32 flags = extraTrigData[index];
+
+ if(flags & Gu::ETD_CONVEX_EDGE_01)
+ out.outputSegment(wp[0], wp[1]);
+
+ if(flags & Gu::ETD_CONVEX_EDGE_12)
+ out.outputSegment(wp[1], wp[2]);
+
+ if(flags & Gu::ETD_CONVEX_EDGE_20)
+ out.outputSegment(wp[0], wp[2]);
+ }
+}
+
+static void visualizeFaceNormals( PxReal fscale, RenderOutput& out, const TriangleMesh& mesh, PxU32 nbTriangles, const PxVec3* vertices,
+ const void* indices, bool has16Bit, const PxU32* results, const Matrix34& absPose, const PxMat44& midt)
+{
+ if(fscale==0.0f)
+ return;
+
+ out << midt << PxU32(PxDebugColor::eARGB_DARKRED); // PT: no need to output this for each segment!
+
+ for(PxU32 i=0; i<nbTriangles; i++)
+ {
+ const PxU32 index = results ? results[i] : i;
+ PxVec3 wp[3];
+ getTriangle(mesh, index, wp, vertices, indices, absPose, has16Bit);
+
+ const PxVec3 center = (wp[0] + wp[1] + wp[2]) / 3.0f;
+ PxVec3 normal = (wp[0] - wp[1]).cross(wp[0] - wp[2]);
+ PX_ASSERT(!normal.isZero());
+ normal = normal.getNormalized();
+
+ out << DebugArrow(center, normal * fscale);
+ }
+}
+
+static PX_FORCE_INLINE void outputTriangle(PxDebugLine* segments, const PxVec3& v0, const PxVec3& v1, const PxVec3& v2, PxU32 color)
+{
+ // PT: TODO: use SIMD
+ segments[0] = PxDebugLine(v0, v1, color);
+ segments[1] = PxDebugLine(v1, v2, color);
+ segments[2] = PxDebugLine(v2, v0, color);
+}
+
+static void visualizeTriangleMesh(const PxTriangleMeshGeometry& geometry, RenderOutput& out, const PxTransform& pose, const PxBounds3& cullbox, const PxReal fscale, bool visualizeShapes, bool visualizeEdges, bool useCullBox)
+{
+ const TriangleMesh* triangleMesh = static_cast<const TriangleMesh*>(geometry.triangleMesh);
+
+ const PxMat44 midt(PxIdentity);
+ const Matrix34 absPose(PxMat33(pose.q) * geometry.scale.toMat33(), pose.p);
+
+ PxU32 nbTriangles = triangleMesh->getNbTrianglesFast();
+ const PxU32 nbVertices = triangleMesh->getNbVerticesFast();
+ const PxVec3* vertices = triangleMesh->getVerticesFast();
+ const void* indices = triangleMesh->getTrianglesFast();
+ const bool has16Bit = triangleMesh->has16BitIndices();
+
+ // PT: TODO: don't render the same edge multiple times
+
+ PxU32* results = NULL;
+ if(useCullBox)
+ {
+ const Gu::Box worldBox(
+ (cullbox.maximum + cullbox.minimum)*0.5f,
+ (cullbox.maximum - cullbox.minimum)*0.5f,
+ PxMat33(PxIdentity));
+
+ // PT: TODO: use the callback version here to avoid allocating this huge array
+ results = reinterpret_cast<PxU32*>(PX_ALLOC_TEMP(sizeof(PxU32)*nbTriangles, "tmp triangle indices"));
+ LimitedResults limitedResults(results, nbTriangles, 0);
+ Midphase::intersectBoxVsMesh(worldBox, *triangleMesh, pose, geometry.scale, &limitedResults);
+ nbTriangles = limitedResults.mNbResults;
+
+ if(visualizeShapes)
+ {
+ const PxU32 scolor = gCollisionShapeColor;
+
+ out << midt << scolor; // PT: no need to output this for each segment!
+
+ PxDebugLine* segments = out.reserveSegments(nbTriangles*3);
+ for(PxU32 i=0; i<nbTriangles; i++)
+ {
+ PxVec3 wp[3];
+ getTriangle(*triangleMesh, results[i], wp, vertices, indices, absPose, has16Bit);
+ outputTriangle(segments, wp[0], wp[1], wp[2], scolor);
+ segments+=3;
+ }
+ }
+ }
+ else
+ {
+ if(visualizeShapes)
+ {
+ PxU32 scolor = gCollisionShapeColor;
+
+ out << midt << scolor; // PT: no need to output this for each segment!
+
+ // PT: TODO: use SIMD
+ PxVec3* transformed = reinterpret_cast<PxVec3*>(PX_ALLOC(sizeof(PxVec3)*nbVertices, "PxVec3"));
+ for(PxU32 i=0;i<nbVertices;i++)
+ transformed[i] = absPose.transform(vertices[i]);
+
+ PxDebugLine* segments = out.reserveSegments(nbTriangles*3);
+ for(PxU32 i=0; i<nbTriangles; i++)
+ {
+ PxVec3 wp[3];
+ getTriangle(*triangleMesh, i, wp, transformed, indices, has16Bit);
+ const PxU32 localMaterialIndex = triangleMesh->getTriangleMaterialIndex(i);
+ // PT: TODO: I doubt this is correct. "localMaterialIndex" will be 0xffff for most meshes so
+ // the color we pick is basically random. Also, get rid of these modulos (==divisions)
+ scolor = gColors[localMaterialIndex % gColorCount];
+
+ outputTriangle(segments, wp[0], wp[1], wp[2], scolor);
+ segments+=3;
+ }
+
+ PX_FREE(transformed);
+ }
+ }
+
+ visualizeFaceNormals(fscale, out, *triangleMesh, nbTriangles, vertices, indices, has16Bit, results, absPose, midt);
+
+ if(visualizeEdges && triangleMesh->getExtraTrigData())
+ visualizeActiveEdges(out, *triangleMesh, nbTriangles, results, absPose);
+
+ if(results)
+ PX_FREE(results);
+}
+
+static void visualizeHeightField(const PxHeightFieldGeometry& hfGeometry, RenderOutput& out, const PxTransform& absPose, const PxBounds3& cullbox, bool useCullBox)
{
+ const HeightField* heightfield = static_cast<const HeightField*>(hfGeometry.heightField);
+
+ // PT: TODO: the debug viz for HFs is minimal at the moment...
+ // PT: TODO: REALLY? all shapes use magenta but HFs use yellow?
+ PxU32 scolor = PxU32(PxDebugColor::eARGB_YELLOW);
+ const PxMat44 midt = PxMat44(PxIdentity);
+
+ HeightFieldUtil hfUtil(hfGeometry);
+
+ const PxU32 nbRows = heightfield->getNbRowsFast();
+ const PxU32 nbColumns = heightfield->getNbColumnsFast();
+ const PxU32 nbVerts = nbRows * nbColumns;
+ const PxU32 nbTriangles = 2 * nbVerts;
+
+ out << midt << scolor; // PT: no need to output the same matrix/color for each triangle
+
+ if(useCullBox)
+ {
+ const PxTransform pose0((cullbox.maximum + cullbox.minimum)*0.5f);
+ const PxBoxGeometry boxGeometry((cullbox.maximum - cullbox.minimum)*0.5f);
+
+ PxU32* results = reinterpret_cast<PxU32*>(PX_ALLOC(sizeof(PxU32)*nbTriangles, "tmp triangle indices"));
+
+ bool overflow = false;
+ PxU32 nbTouchedTris = PxMeshQuery::findOverlapHeightField(boxGeometry, pose0, hfGeometry, absPose, results, nbTriangles, 0, overflow);
+
+ PxDebugLine* segments = out.reserveSegments(nbTouchedTris*3);
+
+ for(PxU32 i=0; i<nbTouchedTris; i++)
+ {
+ const PxU32 index = results[i];
+ PxTriangle currentTriangle;
+ PxMeshQuery::getTriangle(hfGeometry, absPose, index, currentTriangle);
+
+ //The check has been done in the findOverlapHeightField
+ //if(heightfield->isValidTriangle(index) && heightfield->getTriangleMaterial(index) != PxHeightFieldMaterial::eHOLE)
+ {
+ const PxU16 localMaterialIndex = heightfield->getTriangleMaterialIndex(index);
+ // PT: TODO: optimize away modulos/divisions
+ scolor = gColors[localMaterialIndex % gColorCount];
+
+ outputTriangle(segments, currentTriangle.verts[0], currentTriangle.verts[1], currentTriangle.verts[2], scolor);
+ segments+=3;
+ }
+ }
+ PX_FREE(results);
+ }
+ else
+ {
+ // PT: transform vertices only once
+ PxVec3* tmpVerts = reinterpret_cast<PxVec3*>(PX_ALLOC(sizeof(PxVec3)*nbVerts, "PxVec3"));
+ // PT: TODO: optimize the following line
+ for(PxU32 i=0;i<nbVerts;i++)
+ tmpVerts[i] = absPose.transform(hfUtil.hf2shapep(heightfield->getVertex(i)));
+
+ for(PxU32 i=0; i<nbTriangles; i++)
+ {
+ // PT: TODO: optimize away the useless divisions/modulos in the lines below
+ if(heightfield->isValidTriangle(i) && heightfield->getTriangleMaterial(i) != PxHeightFieldMaterial::eHOLE)
+ {
+ PxU32 vi0, vi1, vi2;
+ heightfield->getTriangleVertexIndices(i, vi0, vi1, vi2);
+ const PxU16 localMaterialIndex = heightfield->getTriangleMaterialIndex(i);
+
+ PxDebugLine* segments = out.reserveSegments(3);
+ outputTriangle(segments, tmpVerts[vi0], tmpVerts[vi1], tmpVerts[vi2], gColors[localMaterialIndex % gColorCount]);
+ }
+ }
+ PX_FREE(tmpVerts);
+ }
+}
+
+static void visualize(const PxGeometry& geometry, RenderOutput& out, const PxTransform& absPose, const PxBounds3& cullbox, const PxReal fscale, bool visualizeShapes, bool visualizeEdges, bool useCullBox)
+{
+ // triangle meshes can render active edges or face normals, but for other types we can just early out if there are no collision shapes
+ if(!visualizeShapes && geometry.getType() != PxGeometryType::eTRIANGLEMESH)
+ return;
+
+ switch(geometry.getType())
+ {
+ case PxGeometryType::eSPHERE:
+ visualizeSphere(static_cast<const PxSphereGeometry&>(geometry), out, absPose);
+ break;
+ case PxGeometryType::eBOX:
+ visualizeBox(static_cast<const PxBoxGeometry&>(geometry), out, absPose);
+ break;
+ case PxGeometryType::ePLANE:
+ visualizePlane(static_cast<const PxPlaneGeometry&>(geometry), out, absPose);
+ break;
+ case PxGeometryType::eCAPSULE:
+ visualizeCapsule(static_cast<const PxCapsuleGeometry&>(geometry), out, absPose);
+ break;
+ case PxGeometryType::eCONVEXMESH:
+ visualizeConvexMesh(static_cast<const PxConvexMeshGeometry&>(geometry), out, absPose);
+ break;
+ case PxGeometryType::eTRIANGLEMESH:
+ visualizeTriangleMesh(static_cast<const PxTriangleMeshGeometry&>(geometry), out, absPose, cullbox, fscale, visualizeShapes, visualizeEdges, useCullBox);
+ break;
+ case PxGeometryType::eHEIGHTFIELD:
+ visualizeHeightField(static_cast<const PxHeightFieldGeometry&>(geometry), out, absPose, cullbox, useCullBox);
+ break;
+ case PxGeometryType::eINVALID:
+ break;
+ case PxGeometryType::eGEOMETRY_COUNT:
+ break;
+ }
+}
+
+void NpShapeManager::visualize(RenderOutput& out, NpScene* scene, const PxRigidActor& actor)
+{
+ const PxReal scale = scene->getVisualizationParameter(PxVisualizationParameter::eSCALE);
+ if(!scale)
+ return;
+
const PxU32 nbShapes = getNbShapes();
NpShape*const* PX_RESTRICT shapes = getShapes();
- PxTransform actorPose = actor.getGlobalPose();
const bool visualizeCompounds = (nbShapes>1) && scene->getVisualizationParameter(PxVisualizationParameter::eCOLLISION_COMPOUNDS)!=0.0f;
+ // PT: moved all these out of the loop, no need to grab them once per shape
+ const bool visualizeAABBs = scene->getVisualizationParameter(PxVisualizationParameter::eCOLLISION_AABBS)!=0.0f;
+ const bool visualizeShapes = scene->getVisualizationParameter(PxVisualizationParameter::eCOLLISION_SHAPES)!=0.0f;
+ const bool visualizeEdges = scene->getVisualizationParameter(PxVisualizationParameter::eCOLLISION_EDGES)!=0.0f;
+ const float fNormals = scene->getVisualizationParameter(PxVisualizationParameter::eCOLLISION_FNORMALS);
+ const bool visualizeFNormals = fNormals!=0.0f;
+ const bool visualizeCollision = visualizeShapes || visualizeFNormals || visualizeEdges;
+ const bool useCullBox = scene->getVisualizationParameter(PxVisualizationParameter::eCULL_BOX)!=0.0f;
+ const bool needsShapeBounds0 = visualizeCompounds || (visualizeCollision && useCullBox);
+ const PxReal collisionAxes = scale * scene->getVisualizationParameter(PxVisualizationParameter::eCOLLISION_AXES);
+ const PxReal fscale = scale * fNormals;
+ const PxBounds3& cullbox = scene->getScene().getVisualizationCullingBox();
+
+ const PxTransform actorPose = actor.getGlobalPose();
+
PxBounds3 compoundBounds(PxBounds3::empty());
for(PxU32 i=0;i<nbShapes;i++)
{
- Scb::Shape& shape = shapes[i]->getScbShape();
- if(shape.getFlags() & PxShapeFlag::eVISUALIZATION)
+ const Scb::Shape& scbShape = shapes[i]->getScbShape();
+
+ const PxTransform absPose = actorPose * scbShape.getShape2Actor();
+ const PxGeometry& geom = scbShape.getGeometry();
+
+ const bool shapeDebugVizEnabled = scbShape.getFlags() & PxShapeFlag::eVISUALIZATION;
+
+ const bool needsShapeBounds = needsShapeBounds0 || (visualizeAABBs && shapeDebugVizEnabled);
+ const PxBounds3 currentShapeBounds = needsShapeBounds ? Gu::computeBounds(geom, absPose, !gUnifiedHeightfieldCollision) : PxBounds3::empty();
+
+ if(shapeDebugVizEnabled)
{
- shapes[i]->visualize(out, actor);
- if(visualizeCompounds)
- compoundBounds.include(Gu::computeBounds(shape.getGeometry(), actorPose*shapes[i]->getLocalPose(), !physx::gUnifiedHeightfieldCollision));
+ if(visualizeAABBs)
+ out << PxU32(PxDebugColor::eARGB_YELLOW) << PxMat44(PxIdentity) << DebugBox(currentShapeBounds);
+
+ if(collisionAxes != 0.0f)
+ out << PxMat44(absPose) << DebugBasis(PxVec3(collisionAxes), 0xcf0000, 0x00cf00, 0x0000cf);
+
+ if(visualizeCollision)
+ {
+ if(!useCullBox || cullbox.intersects(currentShapeBounds))
+ ::visualize(geom, out, absPose, cullbox, fscale, visualizeShapes, visualizeEdges, useCullBox);
+ }
}
+
+ if(visualizeCompounds)
+ compoundBounds.include(currentShapeBounds);
}
if(visualizeCompounds && !compoundBounds.isEmpty())
- out << PxU32(PxDebugColor::eARGB_MAGENTA) << PxMat44(PxIdentity) << Cm::DebugBox(compoundBounds);
+ out << gCollisionShapeColor << PxMat44(PxIdentity) << DebugBox(compoundBounds);
}
#endif // PX_ENABLE_DEBUG_VISUALIZATION
diff --git a/PhysX_3.4/Source/PhysX/src/NpShapeManager.h b/PhysX_3.4/Source/PhysX/src/NpShapeManager.h
index d7d22ea6..431fbd5e 100644
--- a/PhysX_3.4/Source/PhysX/src/NpShapeManager.h
+++ b/PhysX_3.4/Source/PhysX/src/NpShapeManager.h
@@ -33,6 +33,7 @@
#include "NpShape.h"
#include "CmPtrTable.h"
+#include "SqSceneQueryManager.h"
#if PX_ENABLE_DEBUG_VISUALIZATION
#include "CmRenderOutput.h"
@@ -43,7 +44,6 @@ namespace physx
namespace Sq
{
- typedef size_t PrunerData;
class SceneQueryManager;
class PruningStructure;
}
diff --git a/PhysX_3.4/Source/PhysX/src/NpSpatialIndex.cpp b/PhysX_3.4/Source/PhysX/src/NpSpatialIndex.cpp
index bda0b2ff..3164b473 100644
--- a/PhysX_3.4/Source/PhysX/src/NpSpatialIndex.cpp
+++ b/PhysX_3.4/Source/PhysX/src/NpSpatialIndex.cpp
@@ -49,27 +49,29 @@ NpSpatialIndex::~NpSpatialIndex()
PX_DELETE(mPruner);
}
-PxSpatialIndexItemId NpSpatialIndex::insert(PxSpatialIndexItem& item,
- const PxBounds3& bounds)
+PxSpatialIndexItemId NpSpatialIndex::insert(PxSpatialIndexItem& item, const PxBounds3& bounds)
{
PX_SIMD_GUARD;
- PX_CHECK_AND_RETURN_VAL(bounds.isValid(), "PxSpatialIndex::insert: bounds are not valid.", PX_SPATIAL_INDEX_INVALID_ITEM_ID);
+ PX_CHECK_AND_RETURN_VAL(bounds.isValid(), "PxSpatialIndex::insert: bounds are not valid.", PX_SPATIAL_INDEX_INVALID_ITEM_ID);
PrunerHandle output;
PrunerPayload payload;
payload.data[0] = reinterpret_cast<size_t>(&item);
- mPruner->addObjects(&output, &bounds, &payload);
+ mPruner->addObjects(&output, &bounds, &payload, 1, false);
mPendingUpdates = true;
return output;
}
-void NpSpatialIndex::update(PxSpatialIndexItemId id,
- const PxBounds3& bounds)
+void NpSpatialIndex::update(PxSpatialIndexItemId id, const PxBounds3& bounds)
{
PX_SIMD_GUARD;
- PX_CHECK_AND_RETURN(bounds.isValid(), "PxSpatialIndex::update: bounds are not valid.");
+ PX_CHECK_AND_RETURN(bounds.isValid(), "PxSpatialIndex::update: bounds are not valid.");
+
+ PxBounds3* b;
+ mPruner->getPayload(id, b);
+ *b = bounds;
+ mPruner->updateObjectsAfterManualBoundsUpdates(&id, 1);
- mPruner->updateObjects(&id, &bounds);
mPendingUpdates = true;
}
@@ -77,15 +79,10 @@ void NpSpatialIndex::remove(PxSpatialIndexItemId id)
{
PX_SIMD_GUARD;
- mPruner->removeObjects(&id);
+ mPruner->removeObjects(&id, 1);
mPendingUpdates = true;
}
-PxBounds3 NpSpatialIndex::getBounds(PxSpatialIndexItemId /*id*/) const
-{
- return PxBounds3();
-}
-
namespace
{
struct OverlapCallback: public PrunerCallback
@@ -137,11 +134,10 @@ void NpSpatialIndex::flushUpdates() const
mPendingUpdates = false;
}
-void NpSpatialIndex::overlap(const PxBounds3& aabb,
- PxSpatialOverlapCallback& callback) const
+void NpSpatialIndex::overlap(const PxBounds3& aabb, PxSpatialOverlapCallback& callback) const
{
PX_SIMD_GUARD;
- PX_CHECK_AND_RETURN(aabb.isValid(), "PxSpatialIndex::overlap: aabb is not valid.");
+ PX_CHECK_AND_RETURN(aabb.isValid(), "PxSpatialIndex::overlap: aabb is not valid.");
flushUpdates();
OverlapCallback cb(callback);
@@ -151,10 +147,7 @@ void NpSpatialIndex::overlap(const PxBounds3& aabb,
mPruner->overlap(shapeData, cb);
}
-void NpSpatialIndex::raycast(const PxVec3& origin,
- const PxVec3& unitDir,
- PxReal maxDist,
- PxSpatialLocationCallback& callback) const
+void NpSpatialIndex::raycast(const PxVec3& origin, const PxVec3& unitDir, PxReal maxDist, PxSpatialLocationCallback& callback) const
{
PX_SIMD_GUARD;
@@ -167,10 +160,7 @@ void NpSpatialIndex::raycast(const PxVec3& origin,
mPruner->raycast(origin, unitDir, maxDist, cb);
}
-void NpSpatialIndex::sweep(const PxBounds3& aabb,
- const PxVec3& unitDir,
- PxReal maxDist,
- PxSpatialLocationCallback& callback) const
+void NpSpatialIndex::sweep(const PxBounds3& aabb, const PxVec3& unitDir, PxReal maxDist, PxSpatialLocationCallback& callback) const
{
PX_SIMD_GUARD;
@@ -213,7 +203,6 @@ void NpSpatialIndex::release()
delete this;
}
-
PxSpatialIndex* physx::PxCreateSpatialIndex()
{
return PX_NEW(NpSpatialIndex)();
diff --git a/PhysX_3.4/Source/PhysX/src/NpSpatialIndex.h b/PhysX_3.4/Source/PhysX/src/NpSpatialIndex.h
index 4d46f006..67cc2d00 100644
--- a/PhysX_3.4/Source/PhysX/src/NpSpatialIndex.h
+++ b/PhysX_3.4/Source/PhysX/src/NpSpatialIndex.h
@@ -56,8 +56,6 @@ public:
virtual void remove(PxSpatialIndexItemId id);
- virtual PxBounds3 getBounds(PxSpatialIndexItemId id) const;
-
virtual void overlap(const PxBounds3& aabb,
PxSpatialOverlapCallback& callback) const;
diff --git a/PhysX_3.4/Source/PhysX/src/PvdMetaDataPvdBinding.cpp b/PhysX_3.4/Source/PhysX/src/PvdMetaDataPvdBinding.cpp
index 33951453..dd61760d 100644
--- a/PhysX_3.4/Source/PhysX/src/PvdMetaDataPvdBinding.cpp
+++ b/PhysX_3.4/Source/PhysX/src/PvdMetaDataPvdBinding.cpp
@@ -110,7 +110,7 @@ PvdMetaDataBinding::~PvdMetaDataBinding()
}
template <typename TDataType, typename TValueType, typename TClassType>
-inline void definePropertyStruct(PvdDataStream& inStream, const char* pushName = NULL)
+static inline void definePropertyStruct(PvdDataStream& inStream, const char* pushName = NULL)
{
PvdPropertyDefinitionHelper& helper(inStream.getPropertyDefinitionHelper());
PvdClassInfoValueStructDefine definitionObj(helper);
@@ -124,7 +124,7 @@ inline void definePropertyStruct(PvdDataStream& inStream, const char* pushName =
}
template <typename TDataType>
-inline void createClassAndDefineProperties(PvdDataStream& inStream)
+static inline void createClassAndDefineProperties(PvdDataStream& inStream)
{
inStream.createClass<TDataType>();
PvdPropertyDefinitionHelper& helper(inStream.getPropertyDefinitionHelper());
@@ -133,7 +133,7 @@ inline void createClassAndDefineProperties(PvdDataStream& inStream)
}
template <typename TDataType, typename TParentType>
-inline void createClassDeriveAndDefineProperties(PvdDataStream& inStream)
+static inline void createClassDeriveAndDefineProperties(PvdDataStream& inStream)
{
inStream.createClass<TDataType>();
inStream.deriveClass<TParentType, TDataType>();
@@ -143,7 +143,7 @@ inline void createClassDeriveAndDefineProperties(PvdDataStream& inStream)
}
template <typename TDataType, typename TConvertSrc, typename TConvertData>
-inline void defineProperty(PvdDataStream& inStream, const char* inPropertyName, const char* semantic)
+static inline void defineProperty(PvdDataStream& inStream, const char* inPropertyName, const char* semantic)
{
PvdPropertyDefinitionHelper& helper(inStream.getPropertyDefinitionHelper());
// PxEnumTraits< TValueType > filterFlagsEnum;
@@ -158,12 +158,12 @@ inline void defineProperty(PvdDataStream& inStream, const char* inPropertyName,
}
template <typename TDataType, typename TConvertSrc, typename TConvertData>
-inline void definePropertyFlags(PvdDataStream& inStream, const char* inPropertyName)
+static inline void definePropertyFlags(PvdDataStream& inStream, const char* inPropertyName)
{
defineProperty<TDataType, TConvertSrc, TConvertData>(inStream, inPropertyName, "Bitflag");
}
template <typename TDataType, typename TConvertSrc, typename TConvertData>
-inline void definePropertyEnums(PvdDataStream& inStream, const char* inPropertyName)
+static inline void definePropertyEnums(PvdDataStream& inStream, const char* inPropertyName)
{
defineProperty<TDataType, TConvertSrc, TConvertData>(inStream, inPropertyName, "Enumeration Value");
}
@@ -787,7 +787,7 @@ void PvdMetaDataBinding::sendEndFrame(PvdDataStream& inStream, const PxScene* in
}
template <typename TDataType>
-void addPhysicsGroupProperty(PvdDataStream& inStream, const char* groupName, const TDataType& inData, const PxPhysics& ownerPhysics)
+static void addPhysicsGroupProperty(PvdDataStream& inStream, const char* groupName, const TDataType& inData, const PxPhysics& ownerPhysics)
{
inStream.setPropertyValue(&inData, "Physics", reinterpret_cast<const void*>(&ownerPhysics));
inStream.pushBackObjectRef(&ownerPhysics, groupName, &inData);
@@ -795,7 +795,7 @@ void addPhysicsGroupProperty(PvdDataStream& inStream, const char* groupName, con
}
template <typename TDataType>
-void removePhysicsGroupProperty(PvdDataStream& inStream, const char* groupName, const TDataType& inData, const PxPhysics& ownerPhysics)
+static void removePhysicsGroupProperty(PvdDataStream& inStream, const char* groupName, const TDataType& inData, const PxPhysics& ownerPhysics)
{
inStream.removeObjectRef(&ownerPhysics, groupName, &inData);
inStream.destroyInstance(&inData);
@@ -980,7 +980,7 @@ void PvdMetaDataBinding::registrarPhysicsObject<PxHeightFieldGeometry>(PvdDataSt
}
template <typename TGeneratedValuesType, typename TGeomType>
-void sendGeometry(PvdMetaDataBinding& metaBind, PvdDataStream& inStream, const PxShape& inShape, const TGeomType& geom, PsPvd* pvd)
+static void sendGeometry(PvdMetaDataBinding& metaBind, PvdDataStream& inStream, const PxShape& inShape, const TGeomType& geom, PsPvd* pvd)
{
const void* geomInst = (reinterpret_cast<const PxU8*>(&inShape)) + 4;
inStream.createInstance(getPvdNamespacedNameForType<TGeomType>(), geomInst);
@@ -991,7 +991,7 @@ void sendGeometry(PvdMetaDataBinding& metaBind, PvdDataStream& inStream, const P
inStream.setPropertyValue(geomInst, "Shape", reinterpret_cast<const void*>(&inShape));
}
-void setGeometry(PvdMetaDataBinding& metaBind, PvdDataStream& inStream, const PxShape& inObj, PsPvd* pvd)
+static void setGeometry(PvdMetaDataBinding& metaBind, PvdDataStream& inStream, const PxShape& inObj, PsPvd* pvd)
{
switch(inObj.getGeometryType())
{
@@ -1029,7 +1029,7 @@ void setGeometry(PvdMetaDataBinding& metaBind, PvdDataStream& inStream, const Px
}
}
-void setMaterials(PvdMetaDataBinding& metaBing, PvdDataStream& inStream, const PxShape& inObj, PsPvd* pvd, PvdMetaDataBindingData* mBindingData)
+static void setMaterials(PvdMetaDataBinding& metaBing, PvdDataStream& inStream, const PxShape& inObj, PsPvd* pvd, PvdMetaDataBindingData* mBindingData)
{
PxU32 numMaterials = inObj.getNbMaterials();
PxMaterial** materialPtr = mBindingData->allocateTemp<PxMaterial*>(numMaterials);
@@ -1042,7 +1042,7 @@ void setMaterials(PvdMetaDataBinding& metaBing, PvdDataStream& inStream, const P
}
}
-void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxShape& inObj, const PxRigidActor& owner, PsPvd* pvd)
+void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxShape& inObj, const PxRigidActor& owner, const PxPhysics& ownerPhysics, PsPvd* pvd)
{
if(!inStream.isInstanceValid(&owner))
return;
@@ -1076,7 +1076,7 @@ void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxShape&
setGeometry(*this, inStream, inObj, pvd);
setMaterials(*this, inStream, inObj, pvd, mBindingData);
if(!inObj.isExclusive())
- inStream.pushBackObjectRef(&owner.getScene()->getPhysics(), "SharedShapes", &inObj);
+ inStream.pushBackObjectRef(&ownerPhysics, "SharedShapes", &inObj);
}
void PvdMetaDataBinding::sendAllProperties(PvdDataStream& inStream, const PxShape& inObj)
@@ -1163,7 +1163,7 @@ void PvdMetaDataBinding::destroyInstance(PvdDataStream& inStream, const PxShape&
}
template <typename TDataType>
-void addSceneGroupProperty(PvdDataStream& inStream, const char* groupName, const TDataType& inObj, const PxScene& inScene)
+static void addSceneGroupProperty(PvdDataStream& inStream, const char* groupName, const TDataType& inObj, const PxScene& inScene)
{
inStream.createInstance(&inObj);
inStream.pushBackObjectRef(&inScene, groupName, &inObj);
@@ -1171,23 +1171,23 @@ void addSceneGroupProperty(PvdDataStream& inStream, const char* groupName, const
}
template <typename TDataType>
-void removeSceneGroupProperty(PvdDataStream& inStream, const char* groupName, const TDataType& inObj, const PxScene& inScene)
+static void removeSceneGroupProperty(PvdDataStream& inStream, const char* groupName, const TDataType& inObj, const PxScene& inScene)
{
inStream.removeObjectRef(&inScene, groupName, &inObj);
inStream.destroyInstance(&inObj);
}
-void sendShapes(PvdMetaDataBinding& binding, PvdDataStream& inStream, const PxRigidActor& inObj, PsPvd* pvd)
+static void sendShapes(PvdMetaDataBinding& binding, PvdDataStream& inStream, const PxRigidActor& inObj, const PxPhysics& ownerPhysics, PsPvd* pvd)
{
InlineArray<PxShape*, 5> shapeData;
PxU32 nbShapes = inObj.getNbShapes();
shapeData.resize(nbShapes);
inObj.getShapes(shapeData.begin(), nbShapes);
for(PxU32 idx = 0; idx < nbShapes; ++idx)
- binding.createInstance(inStream, *shapeData[idx], inObj, pvd);
+ binding.createInstance(inStream, *shapeData[idx], inObj, ownerPhysics, pvd);
}
-void releaseShapes(PvdMetaDataBinding& binding, PvdDataStream& inStream, const PxRigidActor& inObj)
+static void releaseShapes(PvdMetaDataBinding& binding, PvdDataStream& inStream, const PxRigidActor& inObj)
{
InlineArray<PxShape*, 5> shapeData;
PxU32 nbShapes = inObj.getNbShapes();
@@ -1197,11 +1197,11 @@ void releaseShapes(PvdMetaDataBinding& binding, PvdDataStream& inStream, const P
binding.destroyInstance(inStream, *shapeData[idx], inObj);
}
-void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxRigidStatic& inObj, const PxScene& ownerScene, PsPvd* pvd)
+void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxRigidStatic& inObj, const PxScene& ownerScene, const PxPhysics& ownerPhysics, PsPvd* pvd)
{
addSceneGroupProperty(inStream, "RigidStatics", inObj, ownerScene);
sendAllProperties(inStream, inObj);
- sendShapes(*this, inStream, inObj, pvd);
+ sendShapes(*this, inStream, inObj, ownerPhysics, pvd);
}
void PvdMetaDataBinding::sendAllProperties(PvdDataStream& inStream, const PxRigidStatic& inObj)
{
@@ -1213,11 +1213,11 @@ void PvdMetaDataBinding::destroyInstance(PvdDataStream& inStream, const PxRigidS
releaseShapes(*this, inStream, inObj);
removeSceneGroupProperty(inStream, "RigidStatics", inObj, ownerScene);
}
-void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxRigidDynamic& inObj, const PxScene& ownerScene, PsPvd* pvd)
+void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxRigidDynamic& inObj, const PxScene& ownerScene, const PxPhysics& ownerPhysics, PsPvd* pvd)
{
addSceneGroupProperty(inStream, "RigidDynamics", inObj, ownerScene);
sendAllProperties(inStream, inObj);
- sendShapes(*this, inStream, inObj, pvd);
+ sendShapes(*this, inStream, inObj, ownerPhysics, pvd);
}
void PvdMetaDataBinding::sendAllProperties(PvdDataStream& inStream, const PxRigidDynamic& inObj)
{
@@ -1230,13 +1230,13 @@ void PvdMetaDataBinding::destroyInstance(PvdDataStream& inStream, const PxRigidD
removeSceneGroupProperty(inStream, "RigidDynamics", inObj, ownerScene);
}
-void addChild(PvdDataStream& inStream, const void* inParent, const PxArticulationLink& inChild)
+static void addChild(PvdDataStream& inStream, const void* inParent, const PxArticulationLink& inChild)
{
inStream.pushBackObjectRef(inParent, "Links", &inChild);
inStream.setPropertyValue(&inChild, "Parent", inParent);
}
-void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxArticulation& inObj, const PxScene& ownerScene, PsPvd* pvd)
+void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxArticulation& inObj, const PxScene& ownerScene, const PxPhysics& ownerPhysics, PsPvd* pvd)
{
addSceneGroupProperty(inStream, "Articulations", inObj, ownerScene);
sendAllProperties(inStream, inObj);
@@ -1253,7 +1253,7 @@ void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxArticul
for(PxU32 idx = 0; idx < numLinks; ++idx)
{
if(!inStream.isInstanceValid(mBindingData->mArticulationLinks[idx]))
- createInstance(inStream, *mBindingData->mArticulationLinks[idx], pvd);
+ createInstance(inStream, *mBindingData->mArticulationLinks[idx], ownerPhysics, pvd);
}
// Setup the link graph
@@ -1282,7 +1282,7 @@ void PvdMetaDataBinding::destroyInstance(PvdDataStream& inStream, const PxArticu
removeSceneGroupProperty(inStream, "Articulations", inObj, ownerScene);
}
-void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxArticulationLink& inObj, PsPvd* pvd)
+void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxArticulationLink& inObj, const PxPhysics& ownerPhysics, PsPvd* pvd)
{
inStream.createInstance(&inObj);
PxArticulationJoint* joint(inObj.getInboundJoint());
@@ -1294,7 +1294,7 @@ void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxArticul
sendAllProperties(inStream, *joint);
}
sendAllProperties(inStream, inObj);
- sendShapes(*this, inStream, inObj, pvd);
+ sendShapes(*this, inStream, inObj, ownerPhysics, pvd);
}
void PvdMetaDataBinding::sendAllProperties(PvdDataStream& inStream, const PxArticulationLink& inObj)
@@ -1461,7 +1461,7 @@ void PvdMetaDataBinding::destroyInstance(PvdDataStream& inStream, const PxPartic
#endif // PX_USE_PARTICLE_SYSTEM_API
template <typename TBlockType, typename TActorType, typename TOperator>
-void updateActor(PvdDataStream& inStream, TActorType** actorGroup, PxU32 numActors, TOperator sleepingOp, PvdMetaDataBindingData& bindingData)
+static void updateActor(PvdDataStream& inStream, TActorType** actorGroup, PxU32 numActors, TOperator sleepingOp, PvdMetaDataBindingData& bindingData)
{
TBlockType theBlock;
if(numActors == 0)
@@ -1674,8 +1674,11 @@ void PvdMetaDataBinding::destroyInstance(PvdDataStream& inStream, const PxClothF
removePhysicsGroupProperty(inStream, "ClothFabrics", fabric, ownerPhysics);
}
-void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxCloth& cloth, const PxScene& ownerScene, PsPvd* pvd)
+void PvdMetaDataBinding::createInstance(PvdDataStream& inStream, const PxCloth& cloth, const PxScene& ownerScene, const PxPhysics& ownerPhysics, PsPvd* pvd)
{
+ // PT: this is only needed to please some bonkers template code that expects all "createInstance" to have the same signature.
+ PX_UNUSED(ownerPhysics);
+
addSceneGroupProperty(inStream, "Cloths", cloth, ownerScene);
PxClothFabric* fabric = cloth.getFabric();
if(fabric != NULL)
@@ -1692,6 +1695,7 @@ void PvdMetaDataBinding::sendAllProperties(PvdDataStream& inStream, const PxClot
sendSimpleProperties(inStream, cloth);
sendParticleAccelerations(inStream, cloth);
sendMotionConstraints(inStream, cloth);
+ // PT: TODO: are we sending the collision spheres twice here? The "sendPairs" param is never "false" in the entire SDK.....
sendCollisionSpheres(inStream, cloth);
sendCollisionSpheres(inStream, cloth, true);
sendCollisionTriangles(inStream, cloth);
@@ -2198,7 +2202,6 @@ void PvdMetaDataBinding::destroyInstance(PvdDataStream& inStream, const PxAggreg
removeSceneGroupProperty(inStream, "Aggregates", inObj, ownerScene);
}
-template <bool bPushBack>
class ChangeOjectRefCmd : public PvdDataStream::PvdCommand
{
ChangeOjectRefCmd& operator=(const ChangeOjectRefCmd&)
@@ -2207,46 +2210,46 @@ class ChangeOjectRefCmd : public PvdDataStream::PvdCommand
return *this;
} // PX_NOCOPY doesn't work for local classes
public:
- const void* instance;
- String propName;
- const void* propObj;
+ const void* mInstance;
+ String mPropName;
+ const void* mPropObj;
+ const bool mPushBack;
- ChangeOjectRefCmd(const void* inInst, String inName, const void* inObj)
- : instance(inInst), propName(inName), propObj(inObj)
+ ChangeOjectRefCmd(const void* inInst, String inName, const void* inObj, bool pushBack)
+ : mInstance(inInst), mPropName(inName), mPropObj(inObj), mPushBack(pushBack)
{
}
// Assigned is needed for copying
ChangeOjectRefCmd(const ChangeOjectRefCmd& other)
- : instance(other.instance), propName(other.propName), propObj(other.propObj)
+ : PvdDataStream::PvdCommand(other), mInstance(other.mInstance), mPropName(other.mPropName), mPropObj(other.mPropObj), mPushBack(other.mPushBack)
{
}
virtual bool canRun(PvdInstanceDataStream& inStream)
{
- PX_ASSERT(inStream.isInstanceValid(instance));
- return inStream.isInstanceValid(propObj);
+ PX_ASSERT(inStream.isInstanceValid(mInstance));
+ return inStream.isInstanceValid(mPropObj);
}
virtual void run(PvdInstanceDataStream& inStream)
{
- if(!inStream.isInstanceValid(instance))
+ if(!inStream.isInstanceValid(mInstance))
return;
- if(bPushBack)
+ if(mPushBack)
{
- if(inStream.isInstanceValid(propObj))
- inStream.pushBackObjectRef(instance, propName, propObj);
+ if(inStream.isInstanceValid(mPropObj))
+ inStream.pushBackObjectRef(mInstance, mPropName, mPropObj);
}
else
{
// the called function will assert if propobj is already removed
- inStream.removeObjectRef(instance, propName, propObj);
+ inStream.removeObjectRef(mInstance, mPropName, mPropObj);
}
}
};
-template <class Command>
-void changeAggregateSubActors(PvdDataStream& inStream, const PxAggregate& inObj, const PxActor& inActor)
+static void changeAggregateSubActors(PvdDataStream& inStream, const PxAggregate& inObj, const PxActor& inActor, bool pushBack)
{
const PxArticulationLink* link = inActor.is<PxArticulationLink>();
String propName = NULL;
@@ -2264,7 +2267,7 @@ void changeAggregateSubActors(PvdDataStream& inStream, const PxAggregate& inObj,
else
return;
- Command* cmd = PX_PLACEMENT_NEW(inStream.allocateMemForCmd(sizeof(Command)), Command)(&inObj, propName, object);
+ ChangeOjectRefCmd* cmd = PX_PLACEMENT_NEW(inStream.allocateMemForCmd(sizeof(ChangeOjectRefCmd)), ChangeOjectRefCmd)(&inObj, propName, object, pushBack);
if(cmd->canRun(inStream))
cmd->run(inStream);
@@ -2273,14 +2276,12 @@ void changeAggregateSubActors(PvdDataStream& inStream, const PxAggregate& inObj,
}
void PvdMetaDataBinding::detachAggregateActor(PvdDataStream& inStream, const PxAggregate& inObj, const PxActor& inActor)
{
- typedef ChangeOjectRefCmd<false> RemoveOjectRefCmd;
- changeAggregateSubActors<RemoveOjectRefCmd>(inStream, inObj, inActor);
+ changeAggregateSubActors(inStream, inObj, inActor, false);
}
void PvdMetaDataBinding::attachAggregateActor(PvdDataStream& inStream, const PxAggregate& inObj, const PxActor& inActor)
{
- typedef ChangeOjectRefCmd<true> PushbackOjectRefCmd;
- changeAggregateSubActors<PushbackOjectRefCmd>(inStream, inObj, inActor);
+ changeAggregateSubActors(inStream, inObj, inActor, true);
}
#else
void PvdMetaDataBinding::createInstance(PvdDataStream&, const PxAggregate&, const PxScene&, ObjectRegistrar&)
@@ -2305,7 +2306,7 @@ void PvdMetaDataBinding::attachAggregateActor(PvdDataStream&, const PxAggregate&
#endif
template <typename TDataType>
-void sendSceneArray(PvdDataStream& inStream, const PxScene& inScene, const Ps::Array<TDataType>& inArray, const char* propName)
+static void sendSceneArray(PvdDataStream& inStream, const PxScene& inScene, const Ps::Array<TDataType>& inArray, const char* propName)
{
if(0 == inArray.size())
inStream.setPropertyValue(&inScene, propName, DataRef<const PxU8>(), getPvdNamespacedNameForType<TDataType>());
@@ -2317,7 +2318,7 @@ void sendSceneArray(PvdDataStream& inStream, const PxScene& inScene, const Ps::A
}
}
-void sendSceneArray(PvdDataStream& inStream, const PxScene& inScene, const Ps::Array<PvdSqHit>& inArray, const char* propName)
+static void sendSceneArray(PvdDataStream& inStream, const PxScene& inScene, const Ps::Array<PvdSqHit>& inArray, const char* propName)
{
if(0 == inArray.size())
inStream.setPropertyValue(&inScene, propName, DataRef<const PxU8>(), getPvdNamespacedNameForType<PvdSqHit>());
@@ -2338,6 +2339,7 @@ void sendSceneArray(PvdDataStream& inStream, const PxScene& inScene, const Ps::A
}
}
}
+
void PvdMetaDataBinding::sendSceneQueries(PvdDataStream& inStream, const PxScene& inScene, PsPvd* pvd)
{
if(!inStream.isConnected())
@@ -2359,7 +2361,7 @@ void PvdMetaDataBinding::sendSceneQueries(PvdDataStream& inStream, const PxScene
propName = collector.getArrayName(collector.mFilterData);
sendSceneArray(inStream, inScene, collector.mFilterData, propName);
- const Ps::Array<PxGeometryHolder>& geometriesToDestroy = collector.getPrevFrameGeometries();
+ const NamedArray<PxGeometryHolder>& geometriesToDestroy = collector.getPrevFrameGeometries();
propName = collector.getArrayName(geometriesToDestroy);
for(PxU32 k = 0; k < geometriesToDestroy.size(); ++k)
{
diff --git a/PhysX_3.4/Source/PhysX/src/PvdMetaDataPvdBinding.h b/PhysX_3.4/Source/PhysX/src/PvdMetaDataPvdBinding.h
index f76cb2f9..c78d2f1b 100644
--- a/PhysX_3.4/Source/PhysX/src/PvdMetaDataPvdBinding.h
+++ b/PhysX_3.4/Source/PhysX/src/PvdMetaDataPvdBinding.h
@@ -104,23 +104,23 @@ class PvdMetaDataBinding
void createInstance(PvdDataStream& inStream, const PxTriangleMesh& inData, const PxPhysics& ownerPhysics);
void destroyInstance(PvdDataStream& inStream, const PxTriangleMesh& inData, const PxPhysics& ownerPhysics);
- void createInstance(PvdDataStream& inStream, const PxRigidStatic& inObj, const PxScene& ownerScene, PsPvd* pvd);
+ void createInstance(PvdDataStream& inStream, const PxRigidStatic& inObj, const PxScene& ownerScene, const PxPhysics& ownerPhysics, PsPvd* pvd);
void sendAllProperties(PvdDataStream& inStream, const PxRigidStatic& inObj);
void destroyInstance(PvdDataStream& inStream, const PxRigidStatic& inObj, const PxScene& ownerScene);
- void createInstance(PvdDataStream& inStream, const PxRigidDynamic& inObj, const PxScene& ownerScene, PsPvd* pvd);
+ void createInstance(PvdDataStream& inStream, const PxRigidDynamic& inObj, const PxScene& ownerScene, const PxPhysics& ownerPhysics, PsPvd* pvd);
void sendAllProperties(PvdDataStream& inStream, const PxRigidDynamic& inObj);
void destroyInstance(PvdDataStream& inStream, const PxRigidDynamic& inObj, const PxScene& ownerScene);
- void createInstance(PvdDataStream& inStream, const PxArticulation& inObj, const PxScene& ownerScene, PsPvd* pvd);
+ void createInstance(PvdDataStream& inStream, const PxArticulation& inObj, const PxScene& ownerScene, const PxPhysics& ownerPhysics, PsPvd* pvd);
void sendAllProperties(PvdDataStream& inStream, const PxArticulation& inObj);
void destroyInstance(PvdDataStream& inStream, const PxArticulation& inObj, const PxScene& ownerScene);
- void createInstance(PvdDataStream& inStream, const PxArticulationLink& inObj, PsPvd* pvd);
+ void createInstance(PvdDataStream& inStream, const PxArticulationLink& inObj, const PxPhysics& ownerPhysics, PsPvd* pvd);
void sendAllProperties(PvdDataStream& inStream, const PxArticulationLink& inObj);
void destroyInstance(PvdDataStream& inStream, const PxArticulationLink& inObj);
- void createInstance(PvdDataStream& inStream, const PxShape& inObj, const PxRigidActor& owner, PsPvd* pvd);
+ void createInstance(PvdDataStream& inStream, const PxShape& inObj, const PxRigidActor& owner, const PxPhysics& ownerPhysics, PsPvd* pvd);
void sendAllProperties(PvdDataStream& inStream, const PxShape& inObj);
void releaseAndRecreateGeometry(PvdDataStream& inStream, const PxShape& inObj, PxPhysics& ownerPhysics, PsPvd* pvd);
void updateMaterials(PvdDataStream& inStream, const PxShape& inObj, PsPvd* pvd);
@@ -156,7 +156,7 @@ class PvdMetaDataBinding
void sendAllProperties(PvdDataStream& inStream, const PxClothFabric& fabric);
void destroyInstance(PvdDataStream& inStream, const PxClothFabric& fabric, const PxPhysics& ownerPhysics);
- void createInstance(PvdDataStream& inStream, const PxCloth& cloth, const PxScene& ownerScene, PsPvd* pvd);
+ void createInstance(PvdDataStream& inStream, const PxCloth& cloth, const PxScene& ownerScene, const PxPhysics& ownerPhysics, PsPvd* pvd);
void sendAllProperties(PvdDataStream& inStream, const PxCloth& cloth);
void sendSimpleProperties(PvdDataStream& inStream, const PxCloth& cloth);
void sendMotionConstraints(PvdDataStream& inStream, const PxCloth& cloth);
diff --git a/PhysX_3.4/Source/PhysX/src/PvdPhysicsClient.h b/PhysX_3.4/Source/PhysX/src/PvdPhysicsClient.h
index 36ac4b81..ca7768a8 100644
--- a/PhysX_3.4/Source/PhysX/src/PvdPhysicsClient.h
+++ b/PhysX_3.4/Source/PhysX/src/PvdPhysicsClient.h
@@ -57,7 +57,6 @@ class PvdPhysicsClient : public PvdClient, public PxErrorCallback, public NpFact
void onPvdDisconnected();
void flush();
- PsPvd* getPsPvd();
physx::pvdsdk::PvdDataStream* getDataStream();
PvdMetaDataBinding* getMetaDataBinding();
PvdUserRenderer* getUserRender();
diff --git a/PhysX_3.4/Source/PhysX/src/buffering/ScbActor.cpp b/PhysX_3.4/Source/PhysX/src/buffering/ScbActor.cpp
index 9c91235a..25f39af3 100644
--- a/PhysX_3.4/Source/PhysX/src/buffering/ScbActor.cpp
+++ b/PhysX_3.4/Source/PhysX/src/buffering/ScbActor.cpp
@@ -27,58 +27,42 @@
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
-
#include "ScbBase.h"
using namespace physx;
using namespace Scb;
-using namespace physx;
-using namespace Scb;
-
#include "ScbActor.h"
#include "ScbRigidStatic.h"
#include "ScbBody.h"
#include "ScbParticleSystem.h"
#include "ScbCloth.h"
-namespace physx
-{
-namespace Scb
-{
-
Actor::Offsets::Offsets()
{
- size_t staticOffset = reinterpret_cast<size_t>(&(reinterpret_cast<Scb::RigidStatic*>(0)->getScStatic()));
- size_t bodyOffset = reinterpret_cast<size_t>(&(reinterpret_cast<Scb::Body*>(0)->getScBody()));
+ const size_t staticOffset = reinterpret_cast<size_t>(&(reinterpret_cast<Scb::RigidStatic*>(0)->getScStatic()));
+ const size_t bodyOffset = reinterpret_cast<size_t>(&(reinterpret_cast<Scb::Body*>(0)->getScBody()));
scToScb[PxActorType::eRIGID_STATIC] = staticOffset;
scToScb[PxActorType::eRIGID_DYNAMIC] = bodyOffset;
scToScb[PxActorType::eARTICULATION_LINK] = bodyOffset;
- scbToSc[ScbType::RIGID_STATIC] = staticOffset;
- scbToSc[ScbType::BODY] = bodyOffset;
- scbToSc[ScbType::BODY_FROM_ARTICULATION_LINK] = bodyOffset;
+ scbToSc[ScbType::eRIGID_STATIC] = staticOffset;
+ scbToSc[ScbType::eBODY] = bodyOffset;
+ scbToSc[ScbType::eBODY_FROM_ARTICULATION_LINK] = bodyOffset;
#if PX_USE_PARTICLE_SYSTEM_API
- size_t particleOffset = reinterpret_cast<size_t>(&(reinterpret_cast<Scb::ParticleSystem*>(0)->getScParticleSystem()));
+ const size_t particleOffset = reinterpret_cast<size_t>(&(reinterpret_cast<Scb::ParticleSystem*>(0)->getScParticleSystem()));
scToScb[PxActorType::ePARTICLE_FLUID] = particleOffset;
scToScb[PxActorType::ePARTICLE_SYSTEM] = particleOffset;
- scbToSc[ScbType::PARTICLE_SYSTEM] = particleOffset;
+ scbToSc[ScbType::ePARTICLE_SYSTEM] = particleOffset;
#endif
#if PX_USE_CLOTH_API
- size_t clothOffset = reinterpret_cast<size_t>(&(reinterpret_cast<Scb::Cloth*>(0)->getScCloth()));
+ const size_t clothOffset = reinterpret_cast<size_t>(&(reinterpret_cast<Scb::Cloth*>(0)->getScCloth()));
scToScb[PxActorType::eCLOTH] = clothOffset;
- scbToSc[ScbType::CLOTH] = clothOffset;
+ scbToSc[ScbType::eCLOTH] = clothOffset;
#endif
-
-
}
-
-
-
const Actor::Offsets Actor::sOffsets;
-}
-}
diff --git a/PhysX_3.4/Source/PhysX/src/buffering/ScbActor.h b/PhysX_3.4/Source/PhysX/src/buffering/ScbActor.h
index 364972b1..21f623e5 100644
--- a/PhysX_3.4/Source/PhysX/src/buffering/ScbActor.h
+++ b/PhysX_3.4/Source/PhysX/src/buffering/ScbActor.h
@@ -27,7 +27,6 @@
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
-
#ifndef PX_PHYSICS_SCB_FSACTOR
#define PX_PHYSICS_SCB_FSACTOR
@@ -58,7 +57,6 @@ protected:
~ActorBuffer(){}
};
-
class Actor : public Base
{
//= ATTENTION! =====================================================================================
@@ -97,7 +95,6 @@ public:
//---------------------------------------------------------------------------------
// Miscellaneous
//---------------------------------------------------------------------------------
-
PX_FORCE_INLINE const Core& getActorCore() const { return *reinterpret_cast<const Core*>(reinterpret_cast<size_t>(this) + sOffsets.scbToSc[getScbType()]); }
PX_FORCE_INLINE Core& getActorCore() { return *reinterpret_cast<Core*>(reinterpret_cast<size_t>(this) + sOffsets.scbToSc[getScbType()]); }
@@ -124,19 +121,18 @@ protected:
struct Offsets
{
size_t scToScb[PxActorType::eACTOR_COUNT];
- size_t scbToSc[ScbType::TYPE_COUNT];
+ size_t scbToSc[ScbType::eTYPE_COUNT];
Offsets();
};
static const Offsets sOffsets;
};
-
PX_INLINE void Actor::setActorFlags(PxActorFlags v)
{
#if PX_CHECKED
PxActorFlags aFlags = getActorFlags();
PxActorType::Enum aType = getActorType();
- if ((!aFlags.isSet(PxActorFlag::eDISABLE_SIMULATION)) && v.isSet(PxActorFlag::eDISABLE_SIMULATION) &&
+ if((!aFlags.isSet(PxActorFlag::eDISABLE_SIMULATION)) && v.isSet(PxActorFlag::eDISABLE_SIMULATION) &&
(aType != PxActorType::eRIGID_DYNAMIC) && (aType != PxActorType::eRIGID_STATIC))
{
Ps::getFoundation().error(PxErrorCode::eINVALID_PARAMETER, __FILE__, __LINE__,
@@ -147,11 +143,11 @@ PX_INLINE void Actor::setActorFlags(PxActorFlags v)
write<Buf::BF_ActorFlags>(v);
}
-PX_INLINE void Actor::setOwnerClient( PxClientID inId )
+PX_INLINE void Actor::setOwnerClient(PxClientID inId)
{
//This call is only valid if we aren't in a scene.
//Thus we can't be buffering yet
- if (!isBuffering())
+ if(!isBuffering())
{
getActorCore().setOwnerClient( inId );
UPDATE_PVD_PROPERTIES_OBJECT()
@@ -168,10 +164,10 @@ PX_INLINE void Actor::syncState()
//this should be called from syncState() of derived classes
const PxU32 flags = getBufferFlags();
- if (flags & (Buf::BF_ActorFlags|Buf::BF_DominanceGroup|Buf::BF_ClientBehaviorFlags))
+ if(flags & (Buf::BF_ActorFlags|Buf::BF_DominanceGroup|Buf::BF_ClientBehaviorFlags))
{
Core& core = getActorCore();
- Buf& buffer = *reinterpret_cast<Buf*>(getStream());
+ const Buf& buffer = *reinterpret_cast<const Buf*>(getStream());
flush<Buf::BF_ActorFlags>(core, buffer);
flush<Buf::BF_DominanceGroup>(core, buffer);
diff --git a/PhysX_3.4/Source/PhysX/src/buffering/ScbAggregate.cpp b/PhysX_3.4/Source/PhysX/src/buffering/ScbAggregate.cpp
index 22a26abd..e79b10b5 100644
--- a/PhysX_3.4/Source/PhysX/src/buffering/ScbAggregate.cpp
+++ b/PhysX_3.4/Source/PhysX/src/buffering/ScbAggregate.cpp
@@ -27,13 +27,11 @@
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
-
#include "ScbAggregate.h"
#include "ScbActor.h"
using namespace physx;
-
void Scb::Aggregate::addActor(Scb::Actor& actor)
{
const ControlState::Enum state = getControlState();
@@ -44,16 +42,16 @@ void Scb::Aggregate::addActor(Scb::Actor& actor)
PvdAttachActorToAggregate( this, &actor );
PvdUpdateProperties( this );
}
- else if ((state != ControlState::eREMOVE_PENDING)) // If the aggregate is pending for deletion, adding/removing an actor should not be double buffered because the aggregateID must not be set for the actors
+ else if((state != ControlState::eREMOVE_PENDING)) // If the aggregate is pending for deletion, adding/removing an actor should not be double buffered because the aggregateID must not be set for the actors
{
// if available, search in list of removed actors to cover the remove-add case
Scb::AggregateBuffer* PX_RESTRICT bufferedData = getBufferedData();
- if (bufferedData->removeBufferIdx != 0xffffffff)
+ if(bufferedData->removeBufferIdx != 0xffffffff)
{
Scb::Actor** removeBuffer = getScbScene()->getActorBuffer(bufferedData->removeBufferIdx);
- for(PxU32 i=0; i < bufferedData->removeCount; i++)
+ for(PxU32 i=0; i<bufferedData->removeCount; i++)
{
- if (removeBuffer[i] == &actor)
+ if(removeBuffer[i] == &actor)
{
removeBuffer[i] = removeBuffer[bufferedData->removeCount - 1];
PX_ASSERT(bufferedData->removeCount > 0);
@@ -64,20 +62,16 @@ void Scb::Aggregate::addActor(Scb::Actor& actor)
}
Scb::Actor** actorBuffer;
- if (bufferedData->addBufferIdx == 0xffffffff)
- {
+ if(bufferedData->addBufferIdx == 0xffffffff)
actorBuffer = getScbScene()->allocActorBuffer(mMaxNbActors, bufferedData->addBufferIdx);
- }
else
- {
actorBuffer = getScbScene()->getActorBuffer(bufferedData->addBufferIdx);
- }
PX_ASSERT(bufferedData->addCount < mMaxNbActors);
actorBuffer[bufferedData->addCount] = &actor;
bufferedData->addCount++;
- if (state != ControlState::eINSERT_PENDING)
+ if(state != ControlState::eINSERT_PENDING)
markUpdated(BF_ADD_ACTOR);
else
{
@@ -88,7 +82,6 @@ void Scb::Aggregate::addActor(Scb::Actor& actor)
}
}
-
void Scb::Aggregate::removeActor(Scb::Actor& actor, bool reinsert)
{
const ControlState::Enum state = getControlState();
@@ -100,20 +93,18 @@ void Scb::Aggregate::removeActor(Scb::Actor& actor, bool reinsert)
ac.setAggregateID(PX_INVALID_U32);
if(getScbSceneForAPI() && reinsert)
- {
ac.reinsertShapes();
- }
}
- else if ((state != ControlState::eREMOVE_PENDING))
+ else if((state != ControlState::eREMOVE_PENDING))
{
// if available, search in list of added actors to cover the add-remove case
Scb::AggregateBuffer* PX_RESTRICT bufferedData = getBufferedData();
- if (bufferedData->addBufferIdx != 0xffffffff)
+ if(bufferedData->addBufferIdx != 0xffffffff)
{
Scb::Actor** addBuffer = getScbScene()->getActorBuffer(bufferedData->addBufferIdx);
- for(PxU32 i=0; i < bufferedData->addCount; i++)
+ for(PxU32 i=0; i<bufferedData->addCount; i++)
{
- if (addBuffer[i] == &actor)
+ if(addBuffer[i] == &actor)
{
addBuffer[i] = addBuffer[bufferedData->addCount - 1];
PX_ASSERT(bufferedData->addCount > 0);
@@ -124,14 +115,10 @@ void Scb::Aggregate::removeActor(Scb::Actor& actor, bool reinsert)
}
Scb::Actor** actorBuffer;
- if (bufferedData->removeBufferIdx == 0xffffffff)
- {
+ if(bufferedData->removeBufferIdx == 0xffffffff)
actorBuffer = getScbScene()->allocActorBuffer(mMaxNbActors, bufferedData->removeBufferIdx);
- }
else
- {
actorBuffer = getScbScene()->getActorBuffer(bufferedData->removeBufferIdx);
- }
PX_ASSERT(bufferedData->removeCount < mMaxNbActors);
actorBuffer[bufferedData->removeCount] = &actor;
diff --git a/PhysX_3.4/Source/PhysX/src/buffering/ScbAggregate.h b/PhysX_3.4/Source/PhysX/src/buffering/ScbAggregate.h
index 55911d22..8e55deb5 100644
--- a/PhysX_3.4/Source/PhysX/src/buffering/ScbAggregate.h
+++ b/PhysX_3.4/Source/PhysX/src/buffering/ScbAggregate.h
@@ -27,7 +27,6 @@
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
-
#ifndef PX_PHYSICS_SCB_AGGREGATE
#define PX_PHYSICS_SCB_AGGREGATE
@@ -58,7 +57,6 @@ struct AggregateBuffer
PxU32 removeCount;
};
-
class Aggregate : public Base
{
//= ATTENTION! =====================================================================================
@@ -86,7 +84,6 @@ public:
void addActor(Scb::Actor&);
void removeActor(Scb::Actor& actor, bool reinsert);
-
//---------------------------------------------------------------------------------
// Data synchronization
//---------------------------------------------------------------------------------
@@ -112,17 +109,15 @@ private:
PX_FORCE_INLINE Scb::AggregateBuffer* getBufferedData() { return reinterpret_cast<Scb::AggregateBuffer*>(getStream()); }
};
-
PX_INLINE Aggregate::Aggregate(PxAggregate* px, PxU32 maxActors, bool selfCollision) :
mPxAggregate (px),
mAggregateID (PX_INVALID_U32),
mMaxNbActors (maxActors),
mSelfCollide (selfCollision)
{
- setScbType(ScbType::AGGREGATE);
+ setScbType(ScbType::eAGGREGATE);
}
-
PX_INLINE Aggregate::~Aggregate()
{
}
@@ -151,33 +146,27 @@ namespace
PX_FORCE_INLINE void PvdAttachActorToAggregate(Scb::Aggregate* pAggregate, Scb::Actor* pScbActor)
{
Scb::Scene* scbScene = pAggregate->getScbSceneForAPI();
- if( scbScene/* && scbScene->getScenePvdClient().isInstanceValid(pAggregate)*/)
- {
+ if(scbScene/* && scbScene->getScenePvdClient().isInstanceValid(pAggregate)*/)
scbScene->getScenePvdClient().attachAggregateActor( pAggregate, pScbActor );
- }
}
PX_FORCE_INLINE void PvdDetachActorFromAggregate(Scb::Aggregate* pAggregate, Scb::Actor* pScbActor)
{
Scb::Scene* scbScene = pAggregate->getScbSceneForAPI();
- if( scbScene/*&& scbScene->getScenePvdClient().isInstanceValid(pAggregate)*/)
- {
+ if(scbScene/*&& scbScene->getScenePvdClient().isInstanceValid(pAggregate)*/)
scbScene->getScenePvdClient().detachAggregateActor( pAggregate, pScbActor );
- }
}
PX_FORCE_INLINE void PvdUpdateProperties(Scb::Aggregate* pAggregate)
{
Scb::Scene* scbScene = pAggregate->getScbSceneForAPI();
- if( scbScene /*&& scbScene->getScenePvdClient().isInstanceValid(pAggregate)*/)
- {
+ if(scbScene /*&& scbScene->getScenePvdClient().isInstanceValid(pAggregate)*/)
scbScene->getScenePvdClient().updatePvdProperties( pAggregate );
- }
}
#else
-#define PvdAttachActorToAggregate(aggregate, scbActor) {}
-#define PvdDetachActorFromAggregate(aggregate, scbActor) {}
-#define PvdUpdateProperties(aggregate) {}
+#define PvdAttachActorToAggregate(aggregate, scbActor) {}
+#define PvdDetachActorFromAggregate(aggregate, scbActor) {}
+#define PvdUpdateProperties(aggregate) {}
#endif
}
@@ -189,7 +178,7 @@ namespace
PX_INLINE void Aggregate::syncState(Scb::Scene& scene)
{
- PxU32 flags = getBufferFlags();
+ const PxU32 flags = getBufferFlags();
enum AggregateSyncDirtyType
{
@@ -200,30 +189,30 @@ PX_INLINE void Aggregate::syncState(Scb::Scene& scene)
PxU32 dirtyType = DIRTY_NONE;
- if (flags)
+ if(flags)
{
const Scb::AggregateBuffer* PX_RESTRICT bufferedData = getBufferedData();
- if (flags & BF_ADD_ACTOR)
+ if(flags & BF_ADD_ACTOR)
{
dirtyType |= DIRTY_ADD_ACTOR;
Scb::Actor* const* actorBuffer = scene.getActorBuffer(bufferedData->addBufferIdx);
PX_ASSERT(mAggregateID != PX_INVALID_U32);
- for(PxU32 i=0; i < bufferedData->addCount; i++)
+ for(PxU32 i=0; i<bufferedData->addCount; i++)
{
actorBuffer[i]->getActorCore().setAggregateID(mAggregateID);
PvdAttachActorToAggregate( this, actorBuffer[i] );
}
}
- if (flags & BF_REMOVE_ACTOR)
+ if(flags & BF_REMOVE_ACTOR)
{
dirtyType |= DIRTY_REMOVE_ACTOR;
Scb::Actor* const* actorBuffer = scene.getActorBuffer(bufferedData->removeBufferIdx);
- for(PxU32 i=0; i < bufferedData->removeCount; i++)
+ for(PxU32 i=0; i<bufferedData->removeCount; i++)
{
const ControlState::Enum state = actorBuffer[i]->getControlState();
@@ -231,7 +220,7 @@ PX_INLINE void Aggregate::syncState(Scb::Scene& scene)
ac.setAggregateID(PX_INVALID_U32);
if(state != ControlState::eREMOVE_PENDING)
PvdDetachActorFromAggregate( this, actorBuffer[i] );
- if (state == ControlState::eINSERT_PENDING || state == ControlState::eIN_SCENE)
+ if(state == ControlState::eINSERT_PENDING || state == ControlState::eIN_SCENE)
ac.reinsertShapes();
}
}
diff --git a/PhysX_3.4/Source/PhysX/src/buffering/ScbArticulation.h b/PhysX_3.4/Source/PhysX/src/buffering/ScbArticulation.h
index 424cf34b..16d20070 100644
--- a/PhysX_3.4/Source/PhysX/src/buffering/ScbArticulation.h
+++ b/PhysX_3.4/Source/PhysX/src/buffering/ScbArticulation.h
@@ -27,7 +27,6 @@
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
-
#ifndef PX_PHYSICS_SCB_ARTICULATION
#define PX_PHYSICS_SCB_ARTICULATION
@@ -58,7 +57,6 @@ struct ArticulationBuffer
enum { BF_WakeCounter = 1<<7 };
enum { BF_PutToSleep = 1<<8 };
enum { BF_WakeUp = 1<<9 };
-
};
class Articulation : public Base
@@ -127,10 +125,8 @@ public:
PX_FORCE_INLINE static Articulation& fromSc(Core &a) { return *reinterpret_cast<Articulation*>(reinterpret_cast<PxU8*>(&a)-getScOffset()); }
PX_FORCE_INLINE static const Articulation& fromSc(const Core &a) { return *reinterpret_cast<const Articulation*>(reinterpret_cast<const PxU8*>(&a)-getScOffset()); }
- static size_t getScOffset()
- {
- return reinterpret_cast<size_t>(&reinterpret_cast<Articulation*>(0)->mArticulation);
- }
+
+ static size_t getScOffset() { return reinterpret_cast<size_t>(&reinterpret_cast<Articulation*>(0)->mArticulation); }
PX_FORCE_INLINE void wakeUpInternal(PxReal wakeCounter);
@@ -146,7 +142,6 @@ private:
PX_FORCE_INLINE const Buf* getArticulationBuffer() const { return reinterpret_cast<const Buf*>(getStream()); }
PX_FORCE_INLINE Buf* getArticulationBuffer() { return reinterpret_cast<Buf*>(getStream()); }
-
//---------------------------------------------------------------------------------
// Infrastructure for regular attributes
//---------------------------------------------------------------------------------
@@ -155,33 +150,30 @@ private:
template<PxU32 f> PX_FORCE_INLINE typename Buf::Fns<f,0>::Arg read() const { return Access::read<Buf::Fns<f,0> >(*this, mArticulation); }
template<PxU32 f> PX_FORCE_INLINE void write(typename Buf::Fns<f,0>::Arg v) { Access::write<Buf::Fns<f,0> >(*this, mArticulation, v); }
template<PxU32 f> PX_FORCE_INLINE void flush(const Buf& buf) { Access::flush<Buf::Fns<f,0> >(*this, mArticulation, buf); }
-
};
-
Articulation::Articulation()
{
- setScbType(ScbType::ARTICULATION);
- mBufferedWakeCounter = getScArticulation().getWakeCounter();
+ setScbType(ScbType::eARTICULATION);
+ mBufferedWakeCounter = mArticulation.getWakeCounter();
mBufferedIsSleeping = 1; // this is the specified value for free standing objects
}
-
PX_INLINE void Articulation::setWakeCounter(PxReal counter)
{
mBufferedWakeCounter = counter;
- if (!isBuffering())
+ if(!isBuffering())
{
- if (getScbScene() && (counter > 0.0f))
+ if(getScbScene() && (counter > 0.0f))
mBufferedIsSleeping = 0;
- getScArticulation().setWakeCounter(counter);
+ mArticulation.setWakeCounter(counter);
UPDATE_PVD_PROPERTIES_OBJECT()
}
else
{
- if (counter > 0.0f)
+ if(counter > 0.0f)
{
mBufferedIsSleeping = 0;
markUpdated(Buf::BF_WakeUp | Buf::BF_WakeCounter);
@@ -192,7 +184,6 @@ PX_INLINE void Articulation::setWakeCounter(PxReal counter)
}
}
-
PX_FORCE_INLINE void Articulation::wakeUp()
{
Scene* scene = getScbScene();
@@ -201,7 +192,6 @@ PX_FORCE_INLINE void Articulation::wakeUp()
wakeUpInternal(scene->getWakeCounterResetValue());
}
-
PX_FORCE_INLINE void Articulation::wakeUpInternal(PxReal wakeCounter)
{
PX_ASSERT(getScbScene());
@@ -209,9 +199,9 @@ PX_FORCE_INLINE void Articulation::wakeUpInternal(PxReal wakeCounter)
mBufferedWakeCounter = wakeCounter;
mBufferedIsSleeping = 0;
- if (!isBuffering())
+ if(!isBuffering())
{
- getScArticulation().wakeUp(wakeCounter);
+ mArticulation.wakeUp(wakeCounter);
}
else
{
@@ -220,15 +210,14 @@ PX_FORCE_INLINE void Articulation::wakeUpInternal(PxReal wakeCounter)
}
}
-
PX_FORCE_INLINE void Articulation::putToSleep()
{
mBufferedWakeCounter = 0.0f;
mBufferedIsSleeping = 1;
- if (!isBuffering())
+ if(!isBuffering())
{
- getScArticulation().putToSleep();
+ mArticulation.putToSleep();
}
else
{
@@ -237,12 +226,11 @@ PX_FORCE_INLINE void Articulation::putToSleep()
}
}
-
PX_FORCE_INLINE void Articulation::initBufferedState()
{
PX_ASSERT(mBufferedIsSleeping); // this method is only meant to get called when an object is added to the scene
- if (getWakeCounter() == 0.0f)
+ if(getWakeCounter() == 0.0f)
mBufferedIsSleeping = 1;
else
mBufferedIsSleeping = 0;
@@ -251,13 +239,11 @@ PX_FORCE_INLINE void Articulation::initBufferedState()
// are added, an additional check will wake the articulation up if necessary.
}
-
PX_FORCE_INLINE void Articulation::clearBufferedState()
{
mBufferedIsSleeping = 1; // the expected state when an object gets removed from the scene
}
-
PX_FORCE_INLINE void Articulation::clearBufferedSleepStateChange()
{
resetBufferFlag(Buf::BF_WakeUp | Buf::BF_PutToSleep);
@@ -275,26 +261,26 @@ PX_INLINE void Articulation::syncState()
PX_ASSERT( (getControlState() != ControlState::eREMOVE_PENDING) ||
(mBufferedIsSleeping && (!isBuffered(Buf::BF_WakeUp | Buf::BF_PutToSleep))) );
- PxU32 flags = getBufferFlags();
+ const PxU32 flags = getBufferFlags();
//----
- if ((flags & Buf::BF_WakeCounter) == 0)
- mBufferedWakeCounter = getScArticulation().getWakeCounter();
+ if((flags & Buf::BF_WakeCounter) == 0)
+ mBufferedWakeCounter = mArticulation.getWakeCounter();
else if (!(flags & (Buf::BF_WakeUp | Buf::BF_PutToSleep))) // if there has been at least one buffered sleep state transition, then there is no use in adjusting the wake counter separately because it will
// get done in the sleep state update.
{
PX_ASSERT(mBufferedWakeCounter == 0.0f); // a wake counter change is always connected to a sleep state change, except one case: if setWakeCounter(0.0f) was called
- getScArticulation().setWakeCounter(mBufferedWakeCounter);
+ mArticulation.setWakeCounter(mBufferedWakeCounter);
}
//----
- bool isSimObjectSleeping = getScArticulation().isSleeping();
- if ((flags & (Buf::BF_WakeUp | Buf::BF_PutToSleep)) == 0)
+ if((flags & (Buf::BF_WakeUp | Buf::BF_PutToSleep)) == 0)
{
- if (getControlState() != ControlState::eREMOVE_PENDING) // we do not want the simulation sleep state to take effect if the object was removed (free standing objects have buffered state sleeping)
+ const bool isSimObjectSleeping = mArticulation.isSleeping();
+ if(getControlState() != ControlState::eREMOVE_PENDING) // we do not want the simulation sleep state to take effect if the object was removed (free standing objects have buffered state sleeping)
mBufferedIsSleeping = PxU8(isSimObjectSleeping);
else
PX_ASSERT(mBufferedIsSleeping); // this must get set immediately at remove
@@ -304,19 +290,19 @@ PX_INLINE void Articulation::syncState()
PX_ASSERT(flags & Buf::BF_WakeCounter); // sleep state transitions always mark the wake counter dirty
PX_ASSERT(getControlState() != ControlState::eREMOVE_PENDING); // removing an object should clear pending wakeUp/putToSleep operations since the state for a free standing object gets set according to specification.
- if (flags & Buf::BF_PutToSleep)
+ if(flags & Buf::BF_PutToSleep)
{
PX_ASSERT(mBufferedIsSleeping);
PX_ASSERT(!(flags & Buf::BF_WakeUp));
PX_ASSERT(mBufferedWakeCounter == 0.0f);
- getScArticulation().putToSleep();
+ mArticulation.putToSleep();
}
else
{
PX_ASSERT(!mBufferedIsSleeping);
PX_ASSERT(flags & Buf::BF_WakeUp);
- getScArticulation().wakeUp(mBufferedWakeCounter);
+ mArticulation.wakeUp(mBufferedWakeCounter);
}
}
diff --git a/PhysX_3.4/Source/PhysX/src/buffering/ScbArticulationJoint.h b/PhysX_3.4/Source/PhysX/src/buffering/ScbArticulationJoint.h
index 04a49f1c..b6437371 100644
--- a/PhysX_3.4/Source/PhysX/src/buffering/ScbArticulationJoint.h
+++ b/PhysX_3.4/Source/PhysX/src/buffering/ScbArticulationJoint.h
@@ -27,7 +27,6 @@
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
-
#ifndef PX_PHYSICS_SCB_ARTICULATION_JOINT
#define PX_PHYSICS_SCB_ARTICULATION_JOINT
@@ -175,35 +174,31 @@ private:
template<PxU32 f> PX_FORCE_INLINE void flush(const Buf& buf) { Access::flush<Buf::Fns<f,0> >(*this, mJoint, buf); }
};
-
-ArticulationJoint::ArticulationJoint(const PxTransform& parentFrame,
- const PxTransform& childFrame) :
+ArticulationJoint::ArticulationJoint(const PxTransform& parentFrame, const PxTransform& childFrame) :
mJoint(parentFrame, childFrame)
{
- setScbType(ScbType::ARTICULATION_JOINT);
+ setScbType(ScbType::eARTICULATION_JOINT);
}
-
ArticulationJoint::~ArticulationJoint()
{
}
PX_INLINE void ArticulationJoint::getSwingLimit(PxReal &yLimit, PxReal &zLimit) const
{
- if (isBuffered(Buf::BF_SwingLimit))
+ if(isBuffered(Buf::BF_SwingLimit))
{
yLimit = getBuffer()->mSwingLimitY;
zLimit = getBuffer()->mSwingLimitZ;
}
else
- getScArticulationJoint().getSwingLimit(yLimit, zLimit);
+ mJoint.getSwingLimit(yLimit, zLimit);
}
-
PX_INLINE void ArticulationJoint::setSwingLimit(PxReal yLimit, PxReal zLimit)
{
- if (!isBuffering())
- getScArticulationJoint().setSwingLimit(yLimit, zLimit);
+ if(!isBuffering())
+ mJoint.setSwingLimit(yLimit, zLimit);
else
{
getBuffer()->mSwingLimitY = yLimit;
@@ -212,10 +207,9 @@ PX_INLINE void ArticulationJoint::setSwingLimit(PxReal yLimit, PxReal zLimit)
}
}
-
PX_INLINE void ArticulationJoint::getTwistLimit(PxReal &lower, PxReal &upper) const
{
- if (isBuffered(Buf::BF_TwistLimit))
+ if(isBuffered(Buf::BF_TwistLimit))
{
lower = getBuffer()->mTwistLimitLower;
upper = getBuffer()->mTwistLimitUpper;
@@ -224,10 +218,9 @@ PX_INLINE void ArticulationJoint::getTwistLimit(PxReal &lower, PxReal &upper) co
mJoint.getTwistLimit(lower, upper);
}
-
PX_INLINE void ArticulationJoint::setTwistLimit(PxReal lower, PxReal upper)
{
- if (!isBuffering())
+ if(!isBuffering())
mJoint.setTwistLimit(lower, upper);
else
{
@@ -237,7 +230,6 @@ PX_INLINE void ArticulationJoint::setTwistLimit(PxReal lower, PxReal upper)
}
}
-
//--------------------------------------------------------------
//
// Data synchronization
@@ -246,7 +238,7 @@ PX_INLINE void ArticulationJoint::setTwistLimit(PxReal lower, PxReal upper)
PX_INLINE void ArticulationJoint::syncState()
{
- PxU32 flags = getBufferFlags();
+ const PxU32 flags = getBufferFlags();
if(flags) // Optimization to avoid all the if-statements below if possible
{
const Buf& buffer = *getBuffer();
@@ -266,11 +258,11 @@ PX_INLINE void ArticulationJoint::syncState()
flush<Buf::BF_TangentialStiffness>(buffer);
flush<Buf::BF_TangentialDamping>(buffer);
- if (isBuffered(Buf::BF_SwingLimit))
- getScArticulationJoint().setSwingLimit( buffer.mSwingLimitY, buffer.mSwingLimitZ);
+ if(isBuffered(Buf::BF_SwingLimit))
+ mJoint.setSwingLimit(buffer.mSwingLimitY, buffer.mSwingLimitZ);
- if (isBuffered(Buf::BF_TwistLimit))
- getScArticulationJoint().setTwistLimit( buffer.mTwistLimitLower, buffer.mTwistLimitUpper);
+ if(isBuffered(Buf::BF_TwistLimit))
+ mJoint.setTwistLimit(buffer.mTwistLimitLower, buffer.mTwistLimitUpper);
}
postSyncState();
diff --git a/PhysX_3.4/Source/PhysX/src/buffering/ScbBase.cpp b/PhysX_3.4/Source/PhysX/src/buffering/ScbBase.cpp
index fb23dad6..03fb6537 100644
--- a/PhysX_3.4/Source/PhysX/src/buffering/ScbBase.cpp
+++ b/PhysX_3.4/Source/PhysX/src/buffering/ScbBase.cpp
@@ -27,7 +27,6 @@
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
-
#include "ScbBase.h"
#include "ScbNpDeps.h"
diff --git a/PhysX_3.4/Source/PhysX/src/buffering/ScbBase.h b/PhysX_3.4/Source/PhysX/src/buffering/ScbBase.h
index 15fb0f75..3c6b8f79 100644
--- a/PhysX_3.4/Source/PhysX/src/buffering/ScbBase.h
+++ b/PhysX_3.4/Source/PhysX/src/buffering/ScbBase.h
@@ -27,7 +27,6 @@
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
-
#ifndef PX_PHYSICS_SCB_BASE
#define PX_PHYSICS_SCB_BASE
@@ -36,13 +35,12 @@
namespace physx
{
-
#if PX_SUPPORT_PVD
// PT: updatePvdProperties() is overloaded and the compiler needs to know 'this' type to do the right thing.
// Thus we can't just move this as an inlined Base function.
- #define UPDATE_PVD_PROPERTIES_OBJECT() { \
- Scb::Scene* scene_ = getScbSceneForAPI(); \
- if(scene_ && !insertPending() ) \
+ #define UPDATE_PVD_PROPERTIES_OBJECT() { \
+ Scb::Scene* scene_ = getScbSceneForAPI(); \
+ if(scene_ && !insertPending() ) \
scene_->getScenePvdClient().updatePvdProperties(this); }
#else
#define UPDATE_PVD_PROPERTIES_OBJECT() {}
@@ -125,7 +123,6 @@ namespace Scb
};
};
-
/**
\brief Base class for objects that should support buffering.
@@ -148,8 +145,8 @@ namespace Scb
// PX_SERIALIZATION
Base(const PxEMPTY) :
- mScene (NULL),
- mStreamPtr(NULL)
+ mScene (NULL),
+ mStreamPtr (NULL)
{
resetAllBufferFlags();
resetControl(ControlState::eNOT_IN_SCENE);
@@ -157,10 +154,10 @@ namespace Scb
static void getBinaryMetaData(PxOutputStream& stream);
//~PX_SERIALIZATION
Base() :
- mScene (NULL),
- mStreamPtr (NULL)
+ mScene (NULL),
+ mStreamPtr (NULL)
{
- setScbType(ScbType::UNDEFINED);
+ setScbType(ScbType::eUNDEFINED);
resetControl(ControlState::eNOT_IN_SCENE);
resetAllBufferFlags();
}
@@ -172,7 +169,6 @@ namespace Scb
(state == ControlState::eIN_SCENE && mScene->isPhysicsBuffering());
}
-
PX_FORCE_INLINE Ps::IntBool insertPending() const { return getControlState() == ControlState::eINSERT_PENDING; }
PX_FORCE_INLINE ScbType::Enum getScbType() const { return ScbType::Enum((mControlState&eTYPE_MASK)>>eTYPE_SHIFT); }
PX_FORCE_INLINE void setScbType(ScbType::Enum type) { mControlState = (mControlState&~eTYPE_MASK)|(type<<eTYPE_SHIFT); }
@@ -180,15 +176,10 @@ namespace Scb
// the scene value field set if the object is either inserted, in simulation, or waiting for removal. If any of these things
// is true, it can't be added to a different scene
- PX_FORCE_INLINE void setScbScene(Scb::Scene* scene)
- {
- mScene = scene;
- }
-
- PX_FORCE_INLINE Scb::Scene* getScbScene() const
- {
- return mScene;
- }
+ PX_FORCE_INLINE void setScbScene(Scb::Scene* scene) { mScene = scene; }
+ PX_FORCE_INLINE Scb::Scene* getScbScene() const { return mScene; }
+ // PT: TODO: remove this redundant function
+ PX_FORCE_INLINE void resetScbScene() { mScene = NULL; }
/**
\brief Get scene pointer from a users perspective.
@@ -200,12 +191,10 @@ namespace Scb
*/
PX_FORCE_INLINE Scb::Scene* getScbSceneForAPI() const
{
- ControlState::Enum state = getControlState();
- return state == ControlState::eINSERT_PENDING || state == ControlState::eIN_SCENE ? mScene : NULL;
+ const ControlState::Enum state = getControlState();
+ return state == ControlState::eINSERT_PENDING || state == ControlState::eIN_SCENE ? mScene : NULL;
}
- PX_FORCE_INLINE void resetScbScene() { mScene = NULL; }
-
PX_FORCE_INLINE bool hasUpdates() const { return getControlFlags() & ControlFlag::eIS_UPDATED; }
PX_FORCE_INLINE PxU32 getControlFlags() const { return (mControlState&eCONTROLFLAG_MASK)>>eCONTROLFLAG_SHIFT; }
PX_FORCE_INLINE void setControlFlag(ControlFlag::Enum f) { mControlState |= (f<<eCONTROLFLAG_SHIFT); }
@@ -254,7 +243,6 @@ namespace Scb
scheduleForUpdate();
mControlState |= flag;
}
-
protected:
~Base(){}
@@ -263,7 +251,6 @@ namespace Scb
PX_FORCE_INLINE void resetBufferFlag(PxU32 flag) { PX_ASSERT((flag & eBUFFERFLAG_MASK) == flag); mControlState &= ~flag; }
PX_FORCE_INLINE void resetAllBufferFlags() { mControlState &=~eBUFFERFLAG_MASK; }
-
/**
\brief Cleanup method after the object has been synced.
@@ -275,12 +262,12 @@ namespace Scb
// DS: this can get called even when mScene == NULL, by removeAggregate (see AggregateFreeStandingCreateDelete test)
// TODO(dsequeira): investigate that when the dust settles on shape refactoring
PX_ASSERT(getControlState()!=ControlState::eNOT_IN_SCENE || mScene == NULL);
- PX_ASSERT(getScbType()!=ScbType::UNDEFINED);
+ PX_ASSERT(getScbType()!=ScbType::eUNDEFINED);
mStreamPtr = NULL;
resetAllBufferFlags();
+// resetControlFlag(ControlFlag::eIS_UPDATED);
}
-
private:
enum { eBUFFERFLAG_MASK = (1<<24) - 1,
eTYPE_MASK = 15<<24,
diff --git a/PhysX_3.4/Source/PhysX/src/buffering/ScbBody.h b/PhysX_3.4/Source/PhysX/src/buffering/ScbBody.h
index 00ce9f52..eec9a032 100644
--- a/PhysX_3.4/Source/PhysX/src/buffering/ScbBody.h
+++ b/PhysX_3.4/Source/PhysX/src/buffering/ScbBody.h
@@ -27,7 +27,6 @@
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
-
#ifndef PX_PHYSICS_SCB_BODY
#define PX_PHYSICS_SCB_BODY
@@ -110,7 +109,6 @@ struct BodyBuffer : public RigidObjectBuffer //once RigidObject has its own buf
BodyBuffer(): mLinAcceleration(0), mAngAcceleration(0), mLinDeltaVelocity(0), mAngDeltaVelocity(0) {}
};
-
#if PX_VC
#pragma warning(pop)
#endif
@@ -138,8 +136,6 @@ public:
//---------------------------------------------------------------------------------
// Wrapper for Sc::BodyCore interface
//---------------------------------------------------------------------------------
-
-
PX_FORCE_INLINE const PxTransform& getBody2World() const { return mBufferedBody2World; } // PT: important: keep returning an address here (else update prefetch in SceneQueryManager::addShapes)
PX_INLINE void setBody2World(const PxTransform& p, bool asPartOfBody2ActorChange);
@@ -215,10 +211,7 @@ public:
PX_INLINE void syncState();
PX_INLINE void syncCollisionWriteThroughState();
- static size_t getScOffset()
- {
- return reinterpret_cast<size_t>(&reinterpret_cast<Body*>(0)->mBodyCore);
- }
+ static size_t getScOffset() { return reinterpret_cast<size_t>(&reinterpret_cast<Body*>(0)->mBodyCore); }
/**
\brief Shadowed method of #Scb::Base::markUpdated() to store the buffered property flags in a separate location (ran out of flag space)
@@ -340,13 +333,12 @@ private:
template<PxU32 f> PX_FORCE_INLINE typename Buf::Fns<f,0>::Arg read() const { return Access::read<Buf::Fns<f,0> >(*this, mBodyCore); }
template<PxU32 f> PX_FORCE_INLINE void write(typename Buf::Fns<f,0>::Arg v) { Access::write<Buf::Fns<f,0> >(*this, mBodyCore, v); }
template<PxU32 f> PX_FORCE_INLINE void flush(const Buf& buf) { Access::flush<Buf::Fns<f,0> >(*this, mBodyCore, buf); }
-
};
PX_INLINE Body::Body(PxActorType::Enum type, const PxTransform& bodyPose) : mBodyCore(type, bodyPose)
{
- setScbType(ScbType::BODY);
+ setScbType(ScbType::eBODY);
mBufferedBody2World = mBodyCore.getBody2World();
mBufferedLinVelocity = mBodyCore.getLinearVelocity();
@@ -360,21 +352,21 @@ PX_INLINE void Body::setBody2World(const PxTransform& p, bool asPartOfBody2Actor
{
mBufferedBody2World = p;
- if (!isBuffering())
+ if(!isBuffering())
{
mBodyCore.setBody2World(p);
UPDATE_PVD_PROPERTIES_OBJECT()
}
else
{
- if (!asPartOfBody2ActorChange)
+ if(!asPartOfBody2ActorChange)
{
// call was triggered by a setGlobalPose(). This means the simulated body pose will get
// overwritten by the user value, so we do not need to adjust it.
mBodyBufferFlags &= ~Buf::BF_Body2World_CoM;
}
- else if (!(mBodyBufferFlags & Buf::BF_Body2World))
+ else if(!(mBodyBufferFlags & Buf::BF_Body2World))
{
// there has been no setGlobalPose() on the body yet and the center of mass changes.
// This case needs special treatment because the simulation results for such a body will be based on
@@ -391,7 +383,7 @@ PX_INLINE void Body::setLinearVelocity(const PxVec3& v)
{
mBufferedLinVelocity = v;
- if (!isBuffering())
+ if(!isBuffering())
{
mBodyCore.setLinearVelocity(v);
UPDATE_PVD_PROPERTIES_OBJECT()
@@ -404,7 +396,7 @@ PX_INLINE void Body::setAngularVelocity(const PxVec3& v)
{
mBufferedAngVelocity = v;
- if (!isBuffering())
+ if(!isBuffering())
{
mBodyCore.setAngularVelocity(v);
UPDATE_PVD_PROPERTIES_OBJECT()
@@ -418,7 +410,7 @@ PX_INLINE void Body::wakeUpInternal(PxReal wakeCounter)
{
PX_ASSERT(getScbScene());
- if (!isBuffering())
+ if(!isBuffering())
{
setBufferedParamsForAwake(wakeCounter);
mBodyCore.wakeUp(wakeCounter);
@@ -441,10 +433,9 @@ PX_FORCE_INLINE void Body::wakeUp()
wakeUpInternal(scene->getWakeCounterResetValue());
}
-
PX_INLINE void Body::putToSleepInternal()
{
- if (!isBuffering())
+ if(!isBuffering())
{
setBufferedParamsForAsleep();
mBodyCore.putToSleep();
@@ -465,7 +456,6 @@ PX_INLINE void Body::putToSleepInternal()
}
}
-
PX_FORCE_INLINE void Body::putToSleep()
{
PX_ASSERT(!(getFlags() & PxRigidBodyFlag::eKINEMATIC));
@@ -473,16 +463,15 @@ PX_FORCE_INLINE void Body::putToSleep()
putToSleepInternal();
}
-
PX_INLINE void Body::setWakeCounter(PxReal w)
{
PX_ASSERT(!(getFlags() & PxRigidBodyFlag::eKINEMATIC));
mBufferedWakeCounter = w;
- if (!isBuffering())
+ if(!isBuffering())
{
- if (getScbScene() && (w > 0.0f))
+ if(getScbScene() && (w > 0.0f))
mBufferedIsSleeping = 0;
mBodyCore.setWakeCounter(w);
@@ -491,24 +480,23 @@ PX_INLINE void Body::setWakeCounter(PxReal w)
}
else
{
- if (w > 0.0f)
+ if(w > 0.0f)
wakeUpInternal(w);
else
markUpdated(Buf::BF_WakeCounter);
}
}
-
PX_INLINE void Body::setFlags(PxRigidBodyFlags f)
{
- PxU32 wasKinematic = getFlags() & PxRigidBodyFlag::eKINEMATIC;
- PxU32 isKinematic = f & PxRigidBodyFlag::eKINEMATIC;
- bool switchToKinematic = ((!wasKinematic) && isKinematic);
- bool switchToDynamic = (wasKinematic && (!isKinematic));
+ const PxU32 wasKinematic = getFlags() & PxRigidBodyFlag::eKINEMATIC;
+ const PxU32 isKinematic = f & PxRigidBodyFlag::eKINEMATIC;
+ const bool switchToKinematic = ((!wasKinematic) && isKinematic);
+ const bool switchToDynamic = (wasKinematic && (!isKinematic));
- if (!isBuffering())
+ if(!isBuffering())
{
- if (switchToKinematic)
+ if(switchToKinematic)
setBufferedParamsForAsleep();
mBodyCore.setFlags(getScbScene() ? getScbScene()->getScScene().getSimStateDataPool() : NULL, f);
@@ -516,9 +504,9 @@ PX_INLINE void Body::setFlags(PxRigidBodyFlags f)
}
else
{
- if (switchToKinematic)
+ if(switchToKinematic)
putToSleepInternal();
- else if (switchToDynamic)
+ else if(switchToDynamic)
mBodyBufferFlags &= ~Buf::BF_KinematicTarget;
getBodyBuffer()->mRigidBodyFlags = f;
@@ -526,10 +514,9 @@ PX_INLINE void Body::setFlags(PxRigidBodyFlags f)
}
}
-
PX_INLINE void Body::addSpatialAcceleration(const PxVec3* linAcc, const PxVec3* angAcc)
{
- if (!isBuffering())
+ if(!isBuffering())
{
mBodyCore.addSpatialAcceleration(getScbScene()->getScScene().getSimStateDataPool(), linAcc, angAcc);
//Spatial acceleration isn't sent to PVD.
@@ -541,10 +528,9 @@ PX_INLINE void Body::addSpatialAcceleration(const PxVec3* linAcc, const PxVec3*
}
}
-
PX_INLINE void Body::clearSpatialAcceleration(bool force, bool torque)
{
- if (!isBuffering())
+ if(!isBuffering())
{
mBodyCore.clearSpatialAcceleration(force, torque);
//Spatial acceleration isn't sent to PVD.
@@ -556,10 +542,9 @@ PX_INLINE void Body::clearSpatialAcceleration(bool force, bool torque)
}
}
-
PX_INLINE void Body::addSpatialVelocity(const PxVec3* linVelDelta, const PxVec3* angVelDelta)
{
- if (!isBuffering())
+ if(!isBuffering())
{
mBodyCore.addSpatialVelocity(getScbScene()->getScScene().getSimStateDataPool(), linVelDelta, angVelDelta);
UPDATE_PVD_PROPERTIES_OBJECT()
@@ -571,10 +556,9 @@ PX_INLINE void Body::addSpatialVelocity(const PxVec3* linVelDelta, const PxVec3*
}
}
-
PX_INLINE void Body::clearSpatialVelocity(bool force, bool torque)
{
- if (!isBuffering())
+ if(!isBuffering())
{
mBodyCore.clearSpatialVelocity(force, torque);
UPDATE_PVD_PROPERTIES_OBJECT()
@@ -586,28 +570,26 @@ PX_INLINE void Body::clearSpatialVelocity(bool force, bool torque)
}
}
-
PX_INLINE bool Body::getKinematicTarget(PxTransform& p) const
{
- if (isBuffered(Buf::BF_KinematicTarget))
+ if(isBuffered(Buf::BF_KinematicTarget))
{
p = getBodyBuffer()->mKinematicTarget;
return true;
}
- else if (getControlState() != ControlState::eREMOVE_PENDING)
+ else if(getControlState() != ControlState::eREMOVE_PENDING)
return mBodyCore.getKinematicTarget(p);
else
return false;
}
-
PX_INLINE void Body::setKinematicTarget(const PxTransform& p)
{
Scene* scene = getScbScene();
PX_ASSERT(scene); // only allowed for an object in a scene
PxReal wakeCounterResetValue = scene->getWakeCounterResetValue();
- if (!isBuffering())
+ if(!isBuffering())
{
mBodyCore.setKinematicTarget(scene->getScScene().getSimStateDataPool(), p, wakeCounterResetValue);
setBufferedParamsForAwake(wakeCounterResetValue);
@@ -624,21 +606,16 @@ PX_INLINE void Body::setKinematicTarget(const PxTransform& p)
}
#if PX_SUPPORT_PVD
if(getControlState() == ControlState::eIN_SCENE)
- {
scene->getScenePvdClient().updateKinematicTarget(this, p);
- }
#endif
}
-
PX_FORCE_INLINE void Body::onOriginShift(const PxVec3& shift)
{
mBufferedBody2World.p -= shift;
mBodyCore.onOriginShift(shift);
}
-
-
//--------------------------------------------------------------
//
// Miscellaneous
@@ -647,23 +624,19 @@ PX_FORCE_INLINE void Body::onOriginShift(const PxVec3& shift)
PX_FORCE_INLINE bool Body::hasKinematicTarget() const
{
- return
- (
- isBuffered(BodyBuffer::BF_KinematicTarget) || mBodyCore.getHasValidKinematicTarget()
- );
+ return (isBuffered(BodyBuffer::BF_KinematicTarget) || mBodyCore.getHasValidKinematicTarget());
}
-
PX_FORCE_INLINE void Body::clearSimStateDataForPendingInsert()
{
- Sc::BodyCore& core = getScBody();
- if (insertPending())
+ if(insertPending())
{
// not-so-nice-code to cover the following cases:
// - user adds a kinematic to the scene, sets a target and removes the kinematic from scene again (all while the sim is running)
// - same as above but instead of removing the kinematic it gets switched to dynamic
// - user adds a dynamic to the scene, sets a target and removes the dynamic from scene again (all while the sim is running)
+ Sc::BodyCore& core = mBodyCore;
if(core.getSimStateData(true))
core.tearDownSimStateData(getScbScene()->getScScene().getSimStateDataPool(), true);
else if(core.getSimStateData(false))
@@ -671,23 +644,19 @@ PX_FORCE_INLINE void Body::clearSimStateDataForPendingInsert()
}
}
-
PX_FORCE_INLINE void Body::transitionSimStateDataForPendingInsert()
{
- Sc::BodyCore& core = getScBody();
- if (insertPending())
+ if(insertPending())
{
// not-so-nice-code to cover the following case:
// - user adds a dynamic, adds force, then switches to kinematic (all while the sim is running)
+ Sc::BodyCore& core = mBodyCore;
if(core.getSimStateData(false))
- {
core.setupSimStateData(getScbScene()->getScScene().getSimStateDataPool(), true); // note: this won't allocate the memory twice
- }
}
}
-
PX_INLINE PxMat33 Body::getGlobalInertiaTensorInverse() const
{
PxMat33 inverseInertiaWorldSpace;
@@ -695,28 +664,25 @@ PX_INLINE PxMat33 Body::getGlobalInertiaTensorInverse() const
return inverseInertiaWorldSpace;
}
-
PX_FORCE_INLINE bool Body::checkSleepReadinessBesidesWakeCounter()
{
return (getLinearVelocity().isZero() && getAngularVelocity().isZero());
// no need to test for pending force updates yet since currently this is not supported on scene insertion
}
-
PX_FORCE_INLINE void Body::initBufferedState()
{
PX_ASSERT(mBufferedIsSleeping); // this method is only meant to get called when an object is added to the scene
- if ((getWakeCounter() == 0.0f) && checkSleepReadinessBesidesWakeCounter())
+ if((getWakeCounter() == 0.0f) && checkSleepReadinessBesidesWakeCounter())
mBufferedIsSleeping = 1;
else
mBufferedIsSleeping = 0;
}
-
PX_FORCE_INLINE void Body::clearBufferedState()
{
- if (!(getFlags() & PxRigidBodyFlag::eKINEMATIC))
+ if(!(getFlags() & PxRigidBodyFlag::eKINEMATIC))
{
mBufferedIsSleeping = 1; // the expected state when an object gets removed from the scene.
mBodyBufferFlags &= ~(Buf::BF_Acceleration | Buf::BF_DeltaVelocity);
@@ -734,32 +700,29 @@ PX_FORCE_INLINE void Body::clearBufferedState()
RigidObject::clearBufferedState();
}
-
PX_FORCE_INLINE void Body::clearBufferedSleepStateChange()
{
mBodyBufferFlags &= ~(Buf::BF_WakeUp | Buf::BF_PutToSleep);
}
-
PX_FORCE_INLINE void Body::switchBodyToNoSim()
{
Scb::Scene* scene = getScbScene();
switchToNoSim(true);
- if ((!scene) || (!getScbScene()->isPhysicsBuffering()))
+ if((!scene) || (!getScbScene()->isPhysicsBuffering()))
{
setBufferedParamsForAsleep();
- getScBody().putToSleep();
+ mBodyCore.putToSleep();
}
else
putToSleepInternal();
- if (scene)
+ if(scene)
clearSimStateDataForPendingInsert();
}
-
//--------------------------------------------------------------
//
// Data synchronization
@@ -782,7 +745,7 @@ PX_INLINE void Body::syncCollisionWriteThroughState()
PxU32 bufferFlags = mBodyBufferFlags;
//----
- if ((bufferFlags & Buf::BF_LinearVelocity) == 0)
+ if((bufferFlags & Buf::BF_LinearVelocity) == 0)
mBufferedLinVelocity = mBodyCore.getLinearVelocity();
else
{
@@ -800,7 +763,7 @@ PX_INLINE void Body::syncCollisionWriteThroughState()
//----
- if ((bufferFlags & Buf::BF_AngularVelocity) == 0)
+ if((bufferFlags & Buf::BF_AngularVelocity) == 0)
mBufferedAngVelocity = mBodyCore.getAngularVelocity();
else
{
@@ -818,7 +781,7 @@ PX_INLINE void Body::syncCollisionWriteThroughState()
//----
- if (bufferFlags & Buf::BF_KinematicTarget)
+ if(bufferFlags & Buf::BF_KinematicTarget)
{
//don't apply kinematic target unless the actor is kinematic already. setKinematicTarget is write-through properties for split sim but setRigidBodyFlag transition from rigid body to kinematic isn't write-through
if(mBodyCore.getFlags() & PxRigidBodyFlag::eKINEMATIC)
@@ -889,10 +852,10 @@ PX_INLINE void Body::syncCollisionWriteThroughState()
//----
- if ((bufferFlags & Buf::BF_WakeCounter) == 0)
+ if((bufferFlags & Buf::BF_WakeCounter) == 0)
mBufferedWakeCounter = mBodyCore.getWakeCounter();
- else if (!(bufferFlags & (Buf::BF_WakeUp | Buf::BF_PutToSleep))) // if there has been at least one buffered sleep state transition, then there is no use in adjusting the wake counter separately because it will
- // get done in the sleep state update.
+ else if(!(bufferFlags & (Buf::BF_WakeUp | Buf::BF_PutToSleep))) // if there has been at least one buffered sleep state transition, then there is no use in adjusting the wake counter separately because it will
+ // get done in the sleep state update.
{
PX_ASSERT((getControlState() == ControlState::eREMOVE_PENDING) || (mBufferedWakeCounter == 0.0f)); // a wake counter change is always connected to a sleep state change, except if setWakeCounter(0.0f) was called or an object gets removed from the scene after it was woken up.
@@ -943,7 +906,6 @@ PX_INLINE void Body::syncState()
PX_ASSERT( (getControlState() != ControlState::eREMOVE_PENDING) ||
(mBufferedIsSleeping && (!isBuffered(Buf::BF_WakeUp | Buf::BF_PutToSleep))) );
-
//
// IMPORTANT: Since we ran out of space for buffered property flags, the Scb::Body property related flags are stored in mBodyBufferFlags.
// To get the buffer flags from the base classes, use getBufferFlags()
@@ -951,9 +913,9 @@ PX_INLINE void Body::syncState()
const PxU32 bufferFlags = mBodyBufferFlags;
const PxU32 baseBufferFlags = getBufferFlags();
- if ((bufferFlags & Buf::BF_Body2World) == 0)
+ if((bufferFlags & Buf::BF_Body2World) == 0)
mBufferedBody2World = mBodyCore.getBody2World();
- else if ((bufferFlags & Buf::BF_Body2World_CoM) == 0)
+ else if((bufferFlags & Buf::BF_Body2World_CoM) == 0)
mBodyCore.setBody2World(mBufferedBody2World);
else
{
@@ -971,7 +933,7 @@ PX_INLINE void Body::syncState()
//----
- if (baseBufferFlags & Buf::BF_ActorFlags)
+ if(baseBufferFlags & Buf::BF_ActorFlags)
syncNoSimSwitch(*getBodyBuffer(), mBodyCore, true);
//----
@@ -979,7 +941,7 @@ PX_INLINE void Body::syncState()
if(bufferFlags & ~( Buf::BF_WakeCounter|Buf::BF_Body2World|Buf::BF_LinearVelocity|Buf::BF_AngularVelocity
|Buf::BF_WakeUp|Buf::BF_PutToSleep)) // Optimization to avoid all the if-statements below if possible
{
- Buf& buffer = *getBodyBuffer();
+ const Buf& buffer = *getBodyBuffer();
flush<Buf::BF_InverseMass>(buffer);
flush<Buf::BF_InverseInertia>(buffer);
@@ -993,22 +955,19 @@ PX_INLINE void Body::syncState()
flush<Buf::BF_FreezeThreshold>(buffer);
flush<Buf::BF_MaxPenetrationBias>(buffer);
flush<Buf::BF_MaxContactImpulse>(buffer);
- if (bufferFlags & Buf::BF_RigidBodyFlags)
- {
+ if(bufferFlags & Buf::BF_RigidBodyFlags)
mBodyCore.setFlags(getScbScene()->getScScene().getSimStateDataPool(), buffer.mRigidBodyFlags);
- }
}
-
//This method sync all the write through properties in collision and is called in fetchCollision()
syncCollisionWriteThroughState();
//----
- bool isSimObjectSleeping = mBodyCore.isSleeping();
- if ((bufferFlags & (Buf::BF_PutToSleep)) == 0)
+ if((bufferFlags & (Buf::BF_PutToSleep)) == 0)
{
- if (getControlState() != ControlState::eREMOVE_PENDING) // we do not want to sync the simulation sleep state if the object was removed (free standing objects have buffered state sleeping)
+ const bool isSimObjectSleeping = mBodyCore.isSleeping();
+ if(getControlState() != ControlState::eREMOVE_PENDING) // we do not want to sync the simulation sleep state if the object was removed (free standing objects have buffered state sleeping)
mBufferedIsSleeping = PxU32(isSimObjectSleeping);
else
PX_ASSERT(mBufferedIsSleeping); // this must get set immediately at remove
@@ -1046,7 +1005,7 @@ PX_INLINE void Body::syncState()
PX_ASSERT((getControlState() != ControlState::eREMOVE_PENDING) || mBufferedIsSleeping); // nothing in this method should change this
#ifdef _DEBUG
// make sure that for a removed kinematic, the buffered params hold the values as defined in our specification
- if ((mBodyCore.getFlags() & PxRigidBodyFlag::eKINEMATIC) && (getControlState() == ControlState::eREMOVE_PENDING))
+ if((mBodyCore.getFlags() & PxRigidBodyFlag::eKINEMATIC) && (getControlState() == ControlState::eREMOVE_PENDING))
{
PX_ASSERT(mBufferedLinVelocity.isZero());
PX_ASSERT(mBufferedAngVelocity.isZero());
diff --git a/PhysX_3.4/Source/PhysX/src/buffering/ScbCloth.cpp b/PhysX_3.4/Source/PhysX/src/buffering/ScbCloth.cpp
index ecee8baa..7aaf9f83 100644
--- a/PhysX_3.4/Source/PhysX/src/buffering/ScbCloth.cpp
+++ b/PhysX_3.4/Source/PhysX/src/buffering/ScbCloth.cpp
@@ -38,21 +38,17 @@ using namespace physx;
Scb::Cloth::Cloth(const PxTransform& globalPose, Sc::ClothFabricCore& fabric, const PxClothParticle* particles, PxClothFlags flags) :
mCloth(globalPose, fabric, particles, flags)
{
- setScbType(ScbType::CLOTH);
+ setScbType(ScbType::eCLOTH);
}
-
Scb::Cloth::~Cloth()
{
}
-
void Scb::Cloth::syncState()
{
- if (getBufferFlags()) // Optimization to avoid all the if-statements below if possible
- {
+ if(getBufferFlags()) // Optimization to avoid all the if-statements below if possible
Actor::syncState();
- }
postSyncState();
}
diff --git a/PhysX_3.4/Source/PhysX/src/buffering/ScbCloth.h b/PhysX_3.4/Source/PhysX/src/buffering/ScbCloth.h
index 238df91f..31f505dc 100644
--- a/PhysX_3.4/Source/PhysX/src/buffering/ScbCloth.h
+++ b/PhysX_3.4/Source/PhysX/src/buffering/ScbCloth.h
@@ -27,7 +27,6 @@
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
-
#ifndef PX_PHYSICS_SCB_CLOTH
#define PX_PHYSICS_SCB_CLOTH
@@ -42,12 +41,10 @@
namespace physx
{
-
struct PxClothCollisionSphere;
namespace Scb
{
-
class Cloth : public Scb::Actor
{
//= ATTENTION! =====================================================================================
@@ -72,8 +69,8 @@ public:
// Wrapper for Sc::ClothCore interface
//---------------------------------------------------------------------------------
- PX_INLINE Sc::ClothFabricCore* getFabric() const;
- PX_INLINE void resetFabric();
+ PX_INLINE Sc::ClothFabricCore* getFabric() const { return mCloth.getFabric(); }
+ PX_INLINE void resetFabric() { return mCloth.resetFabric(); }
PX_INLINE void setParticles(const PxClothParticle* currentParticles, const PxClothParticle* previousParticles);
PX_INLINE PxU32 getNbParticles() const;
@@ -215,7 +212,6 @@ public:
PX_INLINE void setRestOffset(PxReal);
PX_INLINE PxReal getRestOffset() const;
-
//---------------------------------------------------------------------------------
// Data synchronization
//---------------------------------------------------------------------------------
@@ -229,29 +225,15 @@ public:
PX_FORCE_INLINE const Sc::ClothCore& getScCloth() const { return mCloth; } // Only use if you know what you're doing!
PX_FORCE_INLINE Sc::ClothCore& getScCloth() { return mCloth; } // Only use if you know what you're doing!
- static size_t getScOffset()
- {
- return reinterpret_cast<size_t>(&reinterpret_cast<Cloth*>(0)->mCloth);
- }
+ static size_t getScOffset() { return reinterpret_cast<size_t>(&reinterpret_cast<Cloth*>(0)->mCloth); }
private:
Sc::ClothCore mCloth;
};
-
-PX_INLINE Sc::ClothFabricCore* Cloth::getFabric() const
-{
- return mCloth.getFabric();
-}
-
-PX_INLINE void Cloth::resetFabric()
-{
- return mCloth.resetFabric();
-}
-
PX_INLINE void Cloth::setParticles(const PxClothParticle* currentParticles, const PxClothParticle* previousParticles)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setParticles(currentParticles, previousParticles);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setParticles() not allowed while simulation is running.");
@@ -264,16 +246,15 @@ PX_INLINE PxU32 Cloth::getNbParticles() const
PX_INLINE void Cloth::setMotionConstraints(const PxClothParticleMotionConstraint* motionConstraints)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setMotionConstraints(motionConstraints);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setMotionConstraints() not allowed while simulation is running.");
}
-
PX_INLINE bool Cloth::getMotionConstraints(PxClothParticleMotionConstraint* motionConstraintsBuffer) const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getMotionConstraints(motionConstraintsBuffer);
else
{
@@ -289,7 +270,7 @@ PX_INLINE PxU32 Cloth::getNbMotionConstraints() const
PX_INLINE PxClothMotionConstraintConfig Cloth::getMotionConstraintConfig() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getMotionConstraintConfig();
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::getMotionConstraintScaleBias() not allowed while simulation is running.");
@@ -297,10 +278,9 @@ PX_INLINE PxClothMotionConstraintConfig Cloth::getMotionConstraintConfig() const
return PxClothMotionConstraintConfig();
}
-
PX_INLINE void Cloth::setMotionConstraintConfig(const PxClothMotionConstraintConfig& config)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setMotionConstraintConfig(config);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setMotionConstraintConfig() not allowed while simulation is running.");
@@ -308,16 +288,15 @@ PX_INLINE void Cloth::setMotionConstraintConfig(const PxClothMotionConstraintCon
PX_INLINE void Cloth::setSeparationConstraints(const PxClothParticleSeparationConstraint* separationConstraints)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setSeparationConstraints(separationConstraints);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setSeparationConstraints() not allowed while simulation is running.");
}
-
PX_INLINE bool Cloth::getSeparationConstraints(PxClothParticleSeparationConstraint* separationConstraintsBuffer) const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getSeparationConstraints(separationConstraintsBuffer);
else
{
@@ -338,16 +317,15 @@ PX_INLINE void Cloth::clearInterpolation()
PX_INLINE void Cloth::setParticleAccelerations(const PxVec4* particleAccelerations)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setParticleAccelerations(particleAccelerations);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setParticleAccelerations() not allowed while simulation is running.");
}
-
PX_INLINE bool Cloth::getParticleAccelerations(PxVec4* particleAccelerationsBuffer) const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getParticleAccelerations(particleAccelerationsBuffer);
else
{
@@ -363,28 +341,31 @@ PX_INLINE PxU32 Cloth::getNbParticleAccelerations() const
PX_INLINE void Cloth::addCollisionSphere(const PxClothCollisionSphere& sphere)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.addCollisionSphere(sphere);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::addCollisionSphere() not allowed while simulation is running.");
}
+
PX_INLINE void Cloth::removeCollisionSphere(PxU32 index)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.removeCollisionSphere(index);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::removeCollisionSphere() not allowed while simulation is running.");
}
+
PX_INLINE void Cloth::setCollisionSpheres(const PxClothCollisionSphere* spheresBuffer, PxU32 count)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setCollisionSpheres(spheresBuffer, count);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setCollisionSpheres() not allowed while simulation is running.");
}
+
PX_INLINE PxU32 Cloth::getNbCollisionSpheres() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getNbCollisionSpheres();
else
{
@@ -396,30 +377,31 @@ PX_INLINE PxU32 Cloth::getNbCollisionSpheres() const
PX_INLINE void Cloth::getCollisionData( PxClothCollisionSphere* spheresBuffer, PxU32* capsulesBuffer,
PxClothCollisionPlane* planesBuffer, PxU32* convexesBuffer, PxClothCollisionTriangle* trianglesBuffer ) const
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.getCollisionData(spheresBuffer, capsulesBuffer, planesBuffer, convexesBuffer, trianglesBuffer);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::getCollisionData() not allowed while simulation is running.");
}
-
PX_INLINE void Cloth::addCollisionCapsule(PxU32 first, PxU32 second)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.addCollisionCapsule(first, second);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::addCollisionCapsule() not allowed while simulation is running.");
}
+
PX_INLINE void Cloth::removeCollisionCapsule(PxU32 index)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.removeCollisionCapsule(index);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::removeCollisionCapsule() not allowed while simulation is running.");
}
+
PX_INLINE PxU32 Cloth::getNbCollisionCapsules() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getNbCollisionCapsules();
else
{
@@ -430,28 +412,31 @@ PX_INLINE PxU32 Cloth::getNbCollisionCapsules() const
PX_INLINE void Cloth::addCollisionTriangle(const PxClothCollisionTriangle& triangle)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.addCollisionTriangle(triangle);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::addCollisionTriangle() not allowed while simulation is running.");
}
+
PX_INLINE void Cloth::removeCollisionTriangle(PxU32 index)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.removeCollisionTriangle(index);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::removeCollisionTriangle() not allowed while simulation is running.");
}
+
PX_INLINE void Cloth::setCollisionTriangles(const PxClothCollisionTriangle* trianglesBuffer, PxU32 count)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setCollisionTriangles(trianglesBuffer, count);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setCollisionTriangles() not allowed while simulation is running.");
}
+
PX_INLINE PxU32 Cloth::getNbCollisionTriangles() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getNbCollisionTriangles();
else
{
@@ -462,28 +447,31 @@ PX_INLINE PxU32 Cloth::getNbCollisionTriangles() const
PX_INLINE void Cloth::addCollisionPlane(const PxClothCollisionPlane& plane)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.addCollisionPlane(plane);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::addCollisionPlane() not allowed while simulation is running.");
}
+
PX_INLINE void Cloth::removeCollisionPlane(PxU32 index)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.removeCollisionPlane(index);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::removeCollisionPlane() not allowed while simulation is running.");
}
+
PX_INLINE void Cloth::setCollisionPlanes(const PxClothCollisionPlane* planesBuffer, PxU32 count)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setCollisionPlanes(planesBuffer, count);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setCollisionPlanes() not allowed while simulation is running.");
}
+
PX_INLINE PxU32 Cloth::getNbCollisionPlanes() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getNbCollisionPlanes();
else
{
@@ -494,21 +482,23 @@ PX_INLINE PxU32 Cloth::getNbCollisionPlanes() const
PX_INLINE void Cloth::addCollisionConvex(PxU32 mask)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.addCollisionConvex(mask);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::addCollisionConvex() not allowed while simulation is running.");
}
+
PX_INLINE void Cloth::removeCollisionConvex(PxU32 index)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.removeCollisionConvex(index);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::removeCollisionConvex() not allowed while simulation is running.");
}
+
PX_INLINE PxU32 Cloth::getNbCollisionConvexes() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getNbCollisionConvexes();
else
{
@@ -517,19 +507,17 @@ PX_INLINE PxU32 Cloth::getNbCollisionConvexes() const
}
}
-
PX_INLINE void Cloth::setVirtualParticles(PxU32 numParticles, const PxU32* indices, PxU32 numWeights, const PxVec3* weights)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setVirtualParticles(numParticles, indices, numWeights, weights);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setVirtualParticles() not allowed while simulation is running.");
}
-
PX_INLINE PxU32 Cloth::getNbVirtualParticles() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getNbVirtualParticles();
else
{
@@ -538,19 +526,17 @@ PX_INLINE PxU32 Cloth::getNbVirtualParticles() const
}
}
-
PX_INLINE void Cloth::getVirtualParticles(PxU32* indicesBuffer) const
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.getVirtualParticles(indicesBuffer);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::getVirtualParticles() not allowed while simulation is running.");
}
-
PX_INLINE PxU32 Cloth::getNbVirtualParticleWeights() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getNbVirtualParticleWeights();
else
{
@@ -559,19 +545,17 @@ PX_INLINE PxU32 Cloth::getNbVirtualParticleWeights() const
}
}
-
PX_INLINE void Cloth::getVirtualParticleWeights(PxVec3* weightsBuffer) const
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.getVirtualParticleWeights(weightsBuffer);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::getVirtualParticleWeights() not allowed while simulation is running.");
}
-
PX_INLINE PxTransform Cloth::getGlobalPose() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getGlobalPose();
else
{
@@ -580,28 +564,25 @@ PX_INLINE PxTransform Cloth::getGlobalPose() const
}
}
-
PX_INLINE void Cloth::setGlobalPose(const PxTransform& pose)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setGlobalPose(pose);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setGlobalPose() not allowed while simulation is running.");
}
-
PX_INLINE void Cloth::setTargetPose(const PxTransform& pose)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setTargetPose(pose);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setTargetPose() not allowed while simulation is running.");
}
-
PX_INLINE PxVec3 Cloth::getExternalAcceleration() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getExternalAcceleration();
else
{
@@ -610,10 +591,9 @@ PX_INLINE PxVec3 Cloth::getExternalAcceleration() const
}
}
-
PX_INLINE void Cloth::setExternalAcceleration(PxVec3 acceleration)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setExternalAcceleration(acceleration);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setExternalAcceleration() not allowed while simulation is running.");
@@ -621,7 +601,7 @@ PX_INLINE void Cloth::setExternalAcceleration(PxVec3 acceleration)
PX_INLINE PxVec3 Cloth::getLinearInertiaScale() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getLinearInertiaScale();
else
{
@@ -630,10 +610,9 @@ PX_INLINE PxVec3 Cloth::getLinearInertiaScale() const
}
}
-
PX_INLINE void Cloth::setLinearInertiaScale(PxVec3 scale)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setLinearInertiaScale(scale);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setLinearInertiaScale() not allowed while simulation is running.");
@@ -641,7 +620,7 @@ PX_INLINE void Cloth::setLinearInertiaScale(PxVec3 scale)
PX_INLINE PxVec3 Cloth::getAngularInertiaScale() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getAngularInertiaScale();
else
{
@@ -650,10 +629,9 @@ PX_INLINE PxVec3 Cloth::getAngularInertiaScale() const
}
}
-
PX_INLINE void Cloth::setAngularInertiaScale(PxVec3 scale)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setAngularInertiaScale(scale);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setAngularInertiaScale() not allowed while simulation is running.");
@@ -661,7 +639,7 @@ PX_INLINE void Cloth::setAngularInertiaScale(PxVec3 scale)
PX_INLINE PxVec3 Cloth::getCentrifugalInertiaScale() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getCentrifugalInertiaScale();
else
{
@@ -670,10 +648,9 @@ PX_INLINE PxVec3 Cloth::getCentrifugalInertiaScale() const
}
}
-
PX_INLINE void Cloth::setCentrifugalInertiaScale(PxVec3 scale)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setCentrifugalInertiaScale(scale);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setCentrifugalInertiaScale() not allowed while simulation is running.");
@@ -681,7 +658,7 @@ PX_INLINE void Cloth::setCentrifugalInertiaScale(PxVec3 scale)
PX_INLINE PxVec3 Cloth::getDampingCoefficient() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getDampingCoefficient();
else
{
@@ -690,10 +667,9 @@ PX_INLINE PxVec3 Cloth::getDampingCoefficient() const
}
}
-
PX_INLINE void Cloth::setDampingCoefficient(PxVec3 dampingCoefficient)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setDampingCoefficient(dampingCoefficient);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setDampingCoefficient() not allowed while simulation is running.");
@@ -701,7 +677,7 @@ PX_INLINE void Cloth::setDampingCoefficient(PxVec3 dampingCoefficient)
PX_INLINE PxReal Cloth::getFrictionCoefficient() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getFrictionCoefficient();
else
{
@@ -710,10 +686,9 @@ PX_INLINE PxReal Cloth::getFrictionCoefficient() const
}
}
-
PX_INLINE void Cloth::setFrictionCoefficient(PxReal frictionCoefficient)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setFrictionCoefficient(frictionCoefficient);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setFrictionCoefficient() not allowed while simulation is running.");
@@ -721,7 +696,7 @@ PX_INLINE void Cloth::setFrictionCoefficient(PxReal frictionCoefficient)
PX_INLINE PxVec3 Cloth::getLinearDragCoefficient() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getLinearDragCoefficient();
else
{
@@ -730,10 +705,9 @@ PX_INLINE PxVec3 Cloth::getLinearDragCoefficient() const
}
}
-
PX_INLINE void Cloth::setLinearDragCoefficient(PxVec3 dampingCoefficient)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setLinearDragCoefficient(dampingCoefficient);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setLinearDragCoefficient() not allowed while simulation is running.");
@@ -741,7 +715,7 @@ PX_INLINE void Cloth::setLinearDragCoefficient(PxVec3 dampingCoefficient)
PX_INLINE PxVec3 Cloth::getAngularDragCoefficient() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getAngularDragCoefficient();
else
{
@@ -750,10 +724,9 @@ PX_INLINE PxVec3 Cloth::getAngularDragCoefficient() const
}
}
-
PX_INLINE void Cloth::setAngularDragCoefficient(PxVec3 dampingCoefficient)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setAngularDragCoefficient(dampingCoefficient);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setAngularDragCoefficient() not allowed while simulation is running.");
@@ -761,7 +734,7 @@ PX_INLINE void Cloth::setAngularDragCoefficient(PxVec3 dampingCoefficient)
PX_INLINE PxReal Cloth::getCollisionMassScale() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getCollisionMassScale();
else
{
@@ -769,9 +742,10 @@ PX_INLINE PxReal Cloth::getCollisionMassScale() const
return 0.0f;
}
}
+
PX_INLINE void Cloth::setCollisionMassScale(PxReal scalingCoefficient)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setCollisionMassScale(scalingCoefficient);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setCollisionMassScale() not allowed while simulation is running.");
@@ -779,7 +753,7 @@ PX_INLINE void Cloth::setCollisionMassScale(PxReal scalingCoefficient)
PX_INLINE PxReal Cloth::getSelfCollisionDistance() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getSelfCollisionDistance();
else
{
@@ -787,16 +761,18 @@ PX_INLINE PxReal Cloth::getSelfCollisionDistance() const
return 0.0f;
}
}
+
PX_INLINE void Cloth::setSelfCollisionDistance(PxReal distance)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setSelfCollisionDistance(distance);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setSelfCollisionDistance() not allowed while simulation is running.");
}
+
PX_INLINE PxReal Cloth::getSelfCollisionStiffness() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getSelfCollisionStiffness();
else
{
@@ -804,9 +780,10 @@ PX_INLINE PxReal Cloth::getSelfCollisionStiffness() const
return 0.0f;
}
}
+
PX_INLINE void Cloth::setSelfCollisionStiffness(PxReal stiffness)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setSelfCollisionStiffness(stiffness);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setSelfCollisionStiffness() not allowed while simulation is running.");
@@ -814,7 +791,7 @@ PX_INLINE void Cloth::setSelfCollisionStiffness(PxReal stiffness)
PX_INLINE void Cloth::setSelfCollisionIndices(const PxU32* indices, PxU32 nbIndices)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setSelfCollisionIndices(indices, nbIndices);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setSelfCollisionIndices() not allowed while simulation is running.");
@@ -822,7 +799,7 @@ PX_INLINE void Cloth::setSelfCollisionIndices(const PxU32* indices, PxU32 nbIndi
PX_INLINE bool Cloth::getSelfCollisionIndices(PxU32* indices) const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getSelfCollisionIndices(indices);
else
{
@@ -836,10 +813,9 @@ PX_INLINE PxU32 Cloth::getNbSelfCollisionIndices() const
return mCloth.getNbSelfCollisionIndices();
}
-
PX_INLINE void Cloth::setRestPositions(const PxVec4* restPositions)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setRestPositions(restPositions);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setRestPositions() not allowed while simulation is running.");
@@ -847,7 +823,7 @@ PX_INLINE void Cloth::setRestPositions(const PxVec4* restPositions)
PX_INLINE bool Cloth::getRestPositions(PxVec4* restPositions) const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getRestPositions(restPositions);
else
{
@@ -863,7 +839,7 @@ PX_INLINE PxU32 Cloth::getNbRestPositions() const
PX_INLINE PxReal Cloth::getSolverFrequency() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getSolverFrequency();
else
{
@@ -872,10 +848,9 @@ PX_INLINE PxReal Cloth::getSolverFrequency() const
}
}
-
PX_INLINE void Cloth::setSolverFrequency(PxReal solverFreq)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setSolverFrequency(solverFreq);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setSolverFrequency() not allowed while simulation is running.");
@@ -883,7 +858,7 @@ PX_INLINE void Cloth::setSolverFrequency(PxReal solverFreq)
PX_INLINE PxReal Cloth::getStiffnessFrequency() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getStiffnessFrequency();
else
{
@@ -892,19 +867,17 @@ PX_INLINE PxReal Cloth::getStiffnessFrequency() const
}
}
-
PX_INLINE void Cloth::setStiffnessFrequency(PxReal solverFreq)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setStiffnessFrequency(solverFreq);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setStiffnessFrequency() not allowed while simulation is running.");
}
-
PX_INLINE void Cloth::setStretchConfig(PxClothFabricPhaseType::Enum type, const PxClothStretchConfig& config)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setStretchConfig(type, config);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setStretchConfig() not allowed while simulation is running.");
@@ -912,7 +885,7 @@ PX_INLINE void Cloth::setStretchConfig(PxClothFabricPhaseType::Enum type, const
PX_INLINE void Cloth::setTetherConfig(const PxClothTetherConfig& config)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setTetherConfig(config);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setTetherConfig() not allowed while simulation is running.");
@@ -920,7 +893,7 @@ PX_INLINE void Cloth::setTetherConfig(const PxClothTetherConfig& config)
PX_INLINE PxClothStretchConfig Cloth::getStretchConfig(PxClothFabricPhaseType::Enum type) const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getStretchConfig(type);
else
{
@@ -931,7 +904,7 @@ PX_INLINE PxClothStretchConfig Cloth::getStretchConfig(PxClothFabricPhaseType::E
PX_INLINE PxClothTetherConfig Cloth::getTetherConfig() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getTetherConfig();
else
{
@@ -942,7 +915,7 @@ PX_INLINE PxClothTetherConfig Cloth::getTetherConfig() const
PX_INLINE PxClothFlags Cloth::getClothFlags() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getClothFlags();
else
{
@@ -951,10 +924,9 @@ PX_INLINE PxClothFlags Cloth::getClothFlags() const
}
}
-
PX_INLINE void Cloth::setClothFlags(PxClothFlags flags)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setClothFlags(flags);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setClothFlag() not allowed while simulation is running.");
@@ -962,7 +934,7 @@ PX_INLINE void Cloth::setClothFlags(PxClothFlags flags)
PX_INLINE PxVec3 Cloth::getWindVelocity() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getWindVelocity();
else
{
@@ -973,7 +945,7 @@ PX_INLINE PxVec3 Cloth::getWindVelocity() const
PX_INLINE void Cloth::setWindVelocity(PxVec3 wind)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setWindVelocity(wind);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setWindVelocity() not allowed while simulation is running.");
@@ -981,7 +953,7 @@ PX_INLINE void Cloth::setWindVelocity(PxVec3 wind)
PX_INLINE PxReal Cloth::getDragCoefficient() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getDragCoefficient();
else
{
@@ -992,7 +964,7 @@ PX_INLINE PxReal Cloth::getDragCoefficient() const
PX_INLINE void Cloth::setDragCoefficient(PxReal value)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setDragCoefficient(value);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setDragCoefficient() not allowed while simulation is running.");
@@ -1000,7 +972,7 @@ PX_INLINE void Cloth::setDragCoefficient(PxReal value)
PX_INLINE PxReal Cloth::getLiftCoefficient() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getLiftCoefficient();
else
{
@@ -1011,16 +983,15 @@ PX_INLINE PxReal Cloth::getLiftCoefficient() const
PX_INLINE void Cloth::setLiftCoefficient(PxReal value)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setLiftCoefficient(value);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setLiftCoefficient() not allowed while simulation is running.");
}
-
PX_INLINE bool Cloth::isSleeping() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.isSleeping();
else
{
@@ -1029,10 +1000,9 @@ PX_INLINE bool Cloth::isSleeping() const
}
}
-
PX_INLINE PxReal Cloth::getSleepLinearVelocity() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getSleepLinearVelocity();
else
{
@@ -1041,28 +1011,25 @@ PX_INLINE PxReal Cloth::getSleepLinearVelocity() const
}
}
-
PX_INLINE void Cloth::setSleepLinearVelocity(PxReal threshold)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setSleepLinearVelocity(threshold);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setSleepLinearVelocity() not allowed while simulation is running.");
}
-
PX_INLINE void Cloth::setWakeCounter(PxReal wakeCounterValue)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setWakeCounter(wakeCounterValue);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setWakeCounter() not allowed while simulation is running.");
}
-
PX_INLINE PxReal Cloth::getWakeCounter() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getWakeCounter();
else
{
@@ -1071,31 +1038,28 @@ PX_INLINE PxReal Cloth::getWakeCounter() const
}
}
-
PX_INLINE void Cloth::wakeUp()
{
Scene* scene = getScbScene();
PX_ASSERT(scene); // only allowed for an object in a scene
- if (!isBuffering())
+ if(!isBuffering())
mCloth.wakeUp(scene->getWakeCounterResetValue());
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::wakeUp() not allowed while simulation is running.");
}
-
PX_INLINE void Cloth::putToSleep()
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.putToSleep();
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::putToSleep() not allowed while simulation is running.");
}
-
PX_INLINE void Cloth::getParticleData(NpClothParticleData& particleData)
{
- if (!isBuffering())
+ if(!isBuffering())
return getScCloth().getParticleData(particleData);
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__,
@@ -1105,10 +1069,9 @@ PX_INLINE void Cloth::getParticleData(NpClothParticleData& particleData)
particleData.previousParticles = 0;
}
-
PxReal Cloth::getPreviousTimeStep() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getPreviousTimeStep();
else
{
@@ -1117,10 +1080,9 @@ PxReal Cloth::getPreviousTimeStep() const
}
}
-
PX_INLINE PxBounds3 Cloth::getWorldBounds() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getWorldBounds();
else
{
@@ -1131,7 +1093,7 @@ PX_INLINE PxBounds3 Cloth::getWorldBounds() const
PX_INLINE void Cloth::setSimulationFilterData(const PxFilterData& data)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setSimulationFilterData(data);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setSimulationFilterData() not allowed while simulation is running.");
@@ -1139,7 +1101,7 @@ PX_INLINE void Cloth::setSimulationFilterData(const PxFilterData& data)
PX_INLINE PxFilterData Cloth::getSimulationFilterData() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getSimulationFilterData();
else
{
@@ -1150,7 +1112,7 @@ PX_INLINE PxFilterData Cloth::getSimulationFilterData() const
PX_INLINE void Cloth::setContactOffset(PxReal offset)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setContactOffset(offset);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setContactOffset() not allowed while simulation is running.");
@@ -1158,7 +1120,7 @@ PX_INLINE void Cloth::setContactOffset(PxReal offset)
PX_INLINE PxReal Cloth::getContactOffset() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getContactOffset();
else
{
@@ -1169,7 +1131,7 @@ PX_INLINE PxReal Cloth::getContactOffset() const
PX_INLINE void Cloth::setRestOffset(PxReal offset)
{
- if (!isBuffering())
+ if(!isBuffering())
mCloth.setRestOffset(offset);
else
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Call to PxCloth::setRestOffset() not allowed while simulation is running.");
@@ -1177,7 +1139,7 @@ PX_INLINE void Cloth::setRestOffset(PxReal offset)
PX_INLINE PxReal Cloth::getRestOffset() const
{
- if (!isBuffering())
+ if(!isBuffering())
return mCloth.getRestOffset();
else
{
diff --git a/PhysX_3.4/Source/PhysX/src/buffering/ScbConstraint.h b/PhysX_3.4/Source/PhysX/src/buffering/ScbConstraint.h
index d4661e2d..53dcef8f 100644
--- a/PhysX_3.4/Source/PhysX/src/buffering/ScbConstraint.h
+++ b/PhysX_3.4/Source/PhysX/src/buffering/ScbConstraint.h
@@ -27,7 +27,6 @@
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
-
#ifndef PX_PHYSICS_SCB_CONSTRAINTSHADER
#define PX_PHYSICS_SCB_CONSTRAINTSHADER
@@ -110,28 +109,22 @@ public:
PX_INLINE bool updateConstants(void* addr);
-
//---------------------------------------------------------------------------------
// Data synchronization
//---------------------------------------------------------------------------------
PX_INLINE void prepareForActorRemoval();
PX_INLINE void syncState();
-
//---------------------------------------------------------------------------------
// Miscellaneous
//---------------------------------------------------------------------------------
- PX_FORCE_INLINE const Core& getScConstraint() const { return mConstraint; } // Only use if you know what you're doing!
- PX_FORCE_INLINE Core& getScConstraint() { return mConstraint; } // Only use if you know what you're doing!
+ PX_FORCE_INLINE const Core& getScConstraint() const { return mConstraint; } // Only use if you know what you're doing!
+ PX_FORCE_INLINE Core& getScConstraint() { return mConstraint; } // Only use if you know what you're doing!
PX_FORCE_INLINE static Constraint& fromSc(Core &a) { return *reinterpret_cast<Constraint*>(reinterpret_cast<PxU8*>(&a)-getScOffset()); }
PX_FORCE_INLINE static const Constraint& fromSc(const Core &a) { return *reinterpret_cast<const Constraint*>(reinterpret_cast<const PxU8*>(&a)-getScOffset()); }
-
- static size_t getScOffset()
- {
- return reinterpret_cast<size_t>(&reinterpret_cast<Constraint*>(0)->mConstraint);
- }
+ static size_t getScOffset() { return reinterpret_cast<size_t>(&reinterpret_cast<Constraint*>(0)->mConstraint); }
private:
Core mConstraint;
@@ -144,18 +137,18 @@ private:
PxConstraintFlags mBrokenFlag;
PX_FORCE_INLINE const Buf* getBufferedData() const { return reinterpret_cast<const Buf*>(getStream()); }
- PX_FORCE_INLINE Buf* getBufferedData() { return reinterpret_cast<Buf*>(getStream()); }
+ PX_FORCE_INLINE Buf* getBufferedData() { return reinterpret_cast<Buf*>(getStream()); }
};
} // namespace Scb
PX_INLINE Scb::Constraint::Constraint(PxConstraintConnector& connector, const PxConstraintShaderTable& shaders, PxU32 dataSize) :
- mConstraint(connector, shaders, dataSize),
- mBufferedForce(0.0f),
- mBufferedTorque(0.0f),
- mBrokenFlag(0)
+ mConstraint (connector, shaders, dataSize),
+ mBufferedForce (0.0f),
+ mBufferedTorque (0.0f),
+ mBrokenFlag (0)
{
- setScbType(ScbType::CONSTRAINT);
+ setScbType(ScbType::eCONSTRAINT);
}
PX_INLINE PxConstraintConnector* Scb::Constraint::getPxConnector() const
@@ -165,7 +158,7 @@ PX_INLINE PxConstraintConnector* Scb::Constraint::getPxConnector() const
PX_INLINE void Scb::Constraint::setFlags(PxConstraintFlags f)
{
- if (!isBuffering())
+ if(!isBuffering())
{
mConstraint.setFlags(f);
UPDATE_PVD_PROPERTIES_OBJECT()
@@ -183,13 +176,12 @@ PX_INLINE PxConstraintFlags Scb::Constraint::getFlags() const
: mConstraint.getFlags() & (~(PxConstraintFlag::eBROKEN | PxConstraintFlag::eGPU_COMPATIBLE) | mBrokenFlag);
}
-
PX_INLINE void Scb::Constraint::setBodies(Scb::RigidObject* r0, Scb::RigidObject* r1)
{
Sc::RigidCore* scR0 = r0 ? &r0->getScRigidCore() : NULL;
Sc::RigidCore* scR1 = r1 ? &r1->getScRigidCore() : NULL;
- if (!isBuffering())
+ if(!isBuffering())
{
mConstraint.prepareForSetBodies();
mConstraint.setBodies(scR0, scR1);
@@ -203,22 +195,19 @@ PX_INLINE void Scb::Constraint::setBodies(Scb::RigidObject* r0, Scb::RigidObject
markUpdated(BF_BODIES);
}
- mBufferedForce = PxVec3(0);
- mBufferedTorque = PxVec3(0);
+ mBufferedForce = PxVec3(0.0f);
+ mBufferedTorque = PxVec3(0.0f);
}
-
-
PX_INLINE void Scb::Constraint::getForce(PxVec3& force, PxVec3& torque) const
{
force = mBufferedForce;
torque = mBufferedTorque;
}
-
PX_INLINE void Scb::Constraint::setBreakForce(PxReal linear, PxReal angular)
{
- if (!isBuffering())
+ if(!isBuffering())
{
mConstraint.setBreakForce(linear, angular);
UPDATE_PVD_PROPERTIES_OBJECT()
@@ -232,10 +221,9 @@ PX_INLINE void Scb::Constraint::setBreakForce(PxReal linear, PxReal angular)
}
}
-
PX_INLINE void Scb::Constraint::getBreakForce(PxReal& linear, PxReal& angular) const
{
- if (isBuffered(BF_BREAK_IMPULSE))
+ if(isBuffered(BF_BREAK_IMPULSE))
{
const Buf* PX_RESTRICT bufferedData = getBufferedData();
linear = bufferedData->linBreakForce;
@@ -245,10 +233,9 @@ PX_INLINE void Scb::Constraint::getBreakForce(PxReal& linear, PxReal& angular) c
mConstraint.getBreakForce(linear, angular);
}
-
PX_INLINE void Scb::Constraint::setMinResponseThreshold(PxReal threshold)
{
- if (!isBuffering())
+ if(!isBuffering())
{
mConstraint.setMinResponseThreshold(threshold);
UPDATE_PVD_PROPERTIES_OBJECT()
@@ -261,10 +248,9 @@ PX_INLINE void Scb::Constraint::setMinResponseThreshold(PxReal threshold)
}
}
-
PX_INLINE PxReal Scb::Constraint::getMinResponseThreshold() const
{
- if (isBuffered(BF_MIN_RESPONSE_THRESHOLD))
+ if(isBuffered(BF_MIN_RESPONSE_THRESHOLD))
{
const Buf* PX_RESTRICT bufferedData = getBufferedData();
return bufferedData->minResponseThreshold;
@@ -273,8 +259,6 @@ PX_INLINE PxReal Scb::Constraint::getMinResponseThreshold() const
return mConstraint.getMinResponseThreshold();
}
-
-
PX_INLINE bool Scb::Constraint::updateConstants(void* addr)
{
PX_ASSERT(!getScbScene()->isPhysicsBuffering());
@@ -282,7 +266,6 @@ PX_INLINE bool Scb::Constraint::updateConstants(void* addr)
return mConstraint.updateConstants(addr);
}
-
//--------------------------------------------------------------
//
// Data synchronization
@@ -306,7 +289,7 @@ PX_INLINE void Scb::Constraint::syncState()
mBrokenFlag = mConstraint.getFlags() & PxConstraintFlag::eBROKEN;
- PxU32 flags = getBufferFlags();
+ const PxU32 flags = getBufferFlags();
if(flags)
{
const Buf* PX_RESTRICT bufferedData = getBufferedData();
diff --git a/PhysX_3.4/Source/PhysX/src/buffering/ScbDefs.h b/PhysX_3.4/Source/PhysX/src/buffering/ScbDefs.h
index bd3fd4cd..cdbc75f6 100644
--- a/PhysX_3.4/Source/PhysX/src/buffering/ScbDefs.h
+++ b/PhysX_3.4/Source/PhysX/src/buffering/ScbDefs.h
@@ -27,7 +27,6 @@
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
-
#ifndef PX_PHYSICS_SCB_DEFS
#define PX_PHYSICS_SCB_DEFS
@@ -48,37 +47,34 @@
// BufferAccess template (e.g. to compile without buffering), and also to size-reduce that template
// by passing function pointers if necessary
-#define SCB_REGULAR_ATTRIBUTE(_val, _type, _name) \
-enum { BF_##_name = 1<<(_val) }; \
-_type m##_name; \
-template<PxU32 Dummy> struct Fns<1<<(_val),Dummy> \
-{ \
- typedef typename ArgType<_type>::Type Arg; \
- enum { flag = 1<<(_val) }; \
- static PX_FORCE_INLINE Arg getBuffered(const Buf& buf) { return Arg(buf.m##_name);} \
- static PX_FORCE_INLINE void setBuffered(Buf& buf, Arg v) { buf.m##_name = v;} \
- static PX_FORCE_INLINE Arg getCore(const Core& core) { return Arg(core.get##_name());} \
- static PX_FORCE_INLINE void setCore(Core& core, Arg v) { core.set##_name(v);} \
+#define SCB_REGULAR_ATTRIBUTE(_val, _type, _name) \
+enum { BF_##_name = 1<<(_val) }; \
+_type m##_name; \
+template<PxU32 Dummy> struct Fns<1<<(_val),Dummy> \
+{ \
+ typedef typename ArgType<_type>::Type Arg; \
+ enum { flag = 1<<(_val) }; \
+ static PX_FORCE_INLINE Arg getBuffered(const Buf& buf) { return Arg(buf.m##_name);} \
+ static PX_FORCE_INLINE void setBuffered(Buf& buf, Arg v) { buf.m##_name = v;} \
+ static PX_FORCE_INLINE Arg getCore(const Core& core) { return Arg(core.get##_name());} \
+ static PX_FORCE_INLINE void setCore(Core& core, Arg v) { core.set##_name(v);} \
};
-#define SCB_REGULAR_ATTRIBUTE_ALIGNED(_val, _type, _name, _alignment) \
-enum { BF_##_name = 1<<(_val) }; \
-PX_ALIGN(_alignment, _type) m##_name; \
-template<PxU32 Dummy> struct Fns<1<<(_val),Dummy> \
-{ \
- typedef typename ArgType<_type>::Type Arg; \
- enum { flag = 1<<(_val) }; \
- static PX_FORCE_INLINE Arg getBuffered(const Buf& buf) { return buf.m##_name;} \
- static PX_FORCE_INLINE void setBuffered(Buf& buf, Arg v) { buf.m##_name = v;} \
- static PX_FORCE_INLINE Arg getCore(const Core& core) { return core.get##_name();} \
- static PX_FORCE_INLINE void setCore(Core& core, Arg v) { core.set##_name(v);} \
+#define SCB_REGULAR_ATTRIBUTE_ALIGNED(_val, _type, _name, _alignment) \
+enum { BF_##_name = 1<<(_val) }; \
+PX_ALIGN(_alignment, _type) m##_name; \
+template<PxU32 Dummy> struct Fns<1<<(_val),Dummy> \
+{ \
+ typedef typename ArgType<_type>::Type Arg; \
+ enum { flag = 1<<(_val) }; \
+ static PX_FORCE_INLINE Arg getBuffered(const Buf& buf) { return buf.m##_name;} \
+ static PX_FORCE_INLINE void setBuffered(Buf& buf, Arg v) { buf.m##_name = v;} \
+ static PX_FORCE_INLINE Arg getCore(const Core& core) { return core.get##_name();} \
+ static PX_FORCE_INLINE void setCore(Core& core, Arg v) { core.set##_name(v);} \
};
-
-
namespace physx
{
-
namespace Scb
{
class Scene;
@@ -107,7 +103,7 @@ struct BufferedAccess
template<typename Fns>
static PX_FORCE_INLINE void write(BaseClass& base, Core& core, typename Fns::Arg v)
{
- if (!base.isBuffering())
+ if(!base.isBuffering())
{
Fns::setCore(core, v);
#if PX_SUPPORT_PVD
diff --git a/PhysX_3.4/Source/PhysX/src/buffering/ScbMetaData.cpp b/PhysX_3.4/Source/PhysX/src/buffering/ScbMetaData.cpp
index fea9a5f3..8e0895ac 100644
--- a/PhysX_3.4/Source/PhysX/src/buffering/ScbMetaData.cpp
+++ b/PhysX_3.4/Source/PhysX/src/buffering/ScbMetaData.cpp
@@ -40,7 +40,6 @@
using namespace physx;
-
///////////////////////////////////////////////////////////////////////////////
void Scb::Base::getBinaryMetaData(PxOutputStream& stream)
diff --git a/PhysX_3.4/Source/PhysX/src/buffering/ScbParticleSystem.cpp b/PhysX_3.4/Source/PhysX/src/buffering/ScbParticleSystem.cpp
index 078f3a24..4b430183 100644
--- a/PhysX_3.4/Source/PhysX/src/buffering/ScbParticleSystem.cpp
+++ b/PhysX_3.4/Source/PhysX/src/buffering/ScbParticleSystem.cpp
@@ -67,11 +67,11 @@ void Scb::ParticleSystem::ForceUpdates::destroy()
//----------------------------------------------------------------------------//
-Scb::ParticleSystem::ParticleSystem(const PxActorType::Enum& actorType, PxU32 maxParticles, bool perParticleRestOffset)
-: mParticleSystem(actorType, maxParticles, perParticleRestOffset)
-, mReadParticleFluidData(NULL)
+Scb::ParticleSystem::ParticleSystem(const PxActorType::Enum& actorType, PxU32 maxParticles, bool perParticleRestOffset) :
+ mParticleSystem (actorType, maxParticles, perParticleRestOffset),
+ mReadParticleFluidData (NULL)
{
- setScbType(ScbType::PARTICLE_SYSTEM);
+ setScbType(ScbType::ePARTICLE_SYSTEM);
}
//----------------------------------------------------------------------------//
@@ -279,8 +279,8 @@ void Scb::ParticleSystem::syncState()
{
LOCK_PARTICLE_USER_BUFFERS("PxScene::fetchResults()")
- PxU32 flags = getBufferFlags();
- if (flags) // Optimization to avoid all the if-statements below if possible
+ const PxU32 flags = getBufferFlags();
+ if(flags) // Optimization to avoid all the if-statements below if possible
{
const Buf& buffer = *getParticleSystemBuffer();
@@ -294,7 +294,7 @@ void Scb::ParticleSystem::syncState()
flush<Buf::BF_DynamicFriction>(buffer);
flush<Buf::BF_StaticFriction>(buffer);
- if (flags & Buf::BF_ResetFiltering)
+ if(flags & Buf::BF_ResetFiltering)
mParticleSystem.resetFiltering();
flush<Buf::BF_SimulationFilterData>(buffer);
diff --git a/PhysX_3.4/Source/PhysX/src/buffering/ScbParticleSystem.h b/PhysX_3.4/Source/PhysX/src/buffering/ScbParticleSystem.h
index a0d720d1..ff9683cf 100644
--- a/PhysX_3.4/Source/PhysX/src/buffering/ScbParticleSystem.h
+++ b/PhysX_3.4/Source/PhysX/src/buffering/ScbParticleSystem.h
@@ -27,7 +27,6 @@
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
-
#ifndef PX_PHYSICS_SCB_PARTICLE_SYSTEM
#define PX_PHYSICS_SCB_PARTICLE_SYSTEM
@@ -44,12 +43,10 @@
namespace physx
{
-
struct PxCudaReadWriteParticleBuffers;
namespace Scb
{
-
struct ParticleSystemBuffer : public Scb::ActorBuffer
{
template <PxU32 I, PxU32 Dummy> struct Fns {}; // TODO : make the base class traits visible
@@ -72,10 +69,8 @@ struct ParticleSystemBuffer : public Scb::ActorBuffer
SCB_REGULAR_ATTRIBUTE(BF_Base+12, PxParticleBaseFlags, Flags)
enum { BF_ResetFiltering = 1<<(BF_Base+13) };
-
};
-
class DebugIndexPool;
class ParticleSystem : public Scb::Actor
@@ -92,8 +87,8 @@ class ParticleSystem : public Scb::Actor
struct UserBufferLock
{
- UserBufferLock(NpParticleFluidReadData* db, const char* callerName) : dataBuffer(db) { if (dataBuffer) { dataBuffer->lock(callerName); } }
- ~UserBufferLock() { if (dataBuffer) { dataBuffer->unlock(); } }
+ UserBufferLock(NpParticleFluidReadData* db, const char* callerName) : dataBuffer(db) { if(dataBuffer) { dataBuffer->lock(callerName); } }
+ ~UserBufferLock() { if(dataBuffer) { dataBuffer->unlock(); } }
NpParticleFluidReadData* dataBuffer;
private:
@@ -111,7 +106,7 @@ class ParticleSystem : public Scb::Actor
PX_INLINE void add(PxU32 index, const PxVec3& value)
{
hasUpdates = true;
- if (!map->test(index))
+ if(!map->test(index))
{
map->set(index);
values[index] = value;
@@ -128,7 +123,7 @@ class ParticleSystem : public Scb::Actor
PX_INLINE void clear()
{
- if (!hasUpdates)
+ if(!hasUpdates)
return;
PX_ASSERT(map);
@@ -136,9 +131,9 @@ class ParticleSystem : public Scb::Actor
hasUpdates = false;
}
- Cm::BitMap* map; // can we make this an instance?
- PxVec3* values;
- bool hasUpdates;
+ Cm::BitMap* map; // can we make this an instance?
+ PxVec3* values;
+ bool hasUpdates;
};
public:
@@ -212,7 +207,6 @@ public:
PX_INLINE PxParticleReadDataFlags getParticleReadDataFlags() const;
PX_INLINE void setParticleReadDataFlags(PxParticleReadDataFlags);
-
PX_INLINE PxU32 getParticleCount() const;
PX_INLINE const Cm::BitMap& getParticleMap() const;
@@ -255,13 +249,9 @@ public:
PX_UNUSED(ps);
return static_cast<ParticleSystem&>(Actor::fromSc(a));
-
}
- static size_t getScOffset()
- {
- return reinterpret_cast<size_t>(&reinterpret_cast<ParticleSystem*>(0)->mParticleSystem);
- }
+ static size_t getScOffset() { return reinterpret_cast<size_t>(&reinterpret_cast<ParticleSystem*>(0)->mParticleSystem); }
#if PX_SUPPORT_GPU_PHYSX
PX_INLINE void enableDeviceExclusiveModeGpu();
@@ -292,10 +282,9 @@ private:
PX_INLINE PxParticleBase* ParticleSystem::getPxParticleSystem()
{
- return getScParticleSystem().getPxParticleBase();
+ return mParticleSystem.getPxParticleBase();
}
-
PX_INLINE void ParticleSystem::removeFromScene()
{
PX_ASSERT(!isBuffering() || getControlState()==ControlState::eREMOVE_PENDING);
@@ -304,172 +293,158 @@ PX_INLINE void ParticleSystem::removeFromScene()
mForceUpdatesVel.destroy();
}
-
PX_INLINE PxParticleReadData* ParticleSystem::lockParticleReadData(PxDataAccessFlags flags)
{
// Don't use the macro here since releasing the lock should not be done automatically but by the user
- if (isBuffering())
+ if(isBuffering())
{
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "Particle data read not allowed while simulation is running.");
return NULL;
}
- if (!mReadParticleFluidData)
- {
+ if(!mReadParticleFluidData)
mReadParticleFluidData = PX_NEW(NpParticleFluidReadData)();
- }
mReadParticleFluidData->lock("PxParticleBase::lockParticleReadData()");
mReadParticleFluidData->setDataAccessFlags(flags);
- getScParticleSystem().getParticleReadData(*mReadParticleFluidData);
+ mParticleSystem.getParticleReadData(*mReadParticleFluidData);
return mReadParticleFluidData;
}
-
-
-
PX_INLINE void ParticleSystem::resetFiltering()
{
- if (!isBuffering())
+ if(!isBuffering())
{
- getScParticleSystem().resetFiltering();
+ mParticleSystem.resetFiltering();
UPDATE_PVD_PROPERTIES_OBJECT()
}
else
- {
markUpdated(Buf::BF_ResetFiltering);
- }
}
-
-
PX_INLINE PxParticleReadDataFlags ParticleSystem::getParticleReadDataFlags() const
{
- return getScParticleSystem().getParticleReadDataFlags();
+ return mParticleSystem.getParticleReadDataFlags();
}
PX_INLINE void ParticleSystem::setParticleReadDataFlags(PxParticleReadDataFlags flags)
{
- if (!isBuffering())
+ if(!isBuffering())
{
- getScParticleSystem().setParticleReadDataFlags(flags);
+ mParticleSystem.setParticleReadDataFlags(flags);
UPDATE_PVD_PROPERTIES_OBJECT()
}
}
PX_INLINE PxU32 ParticleSystem::getParticleCount() const
{
- return getScParticleSystem().getParticleCount();
+ return mParticleSystem.getParticleCount();
}
PX_INLINE const Cm::BitMap& ParticleSystem::getParticleMap() const
{
- return getScParticleSystem().getParticleMap();
+ return mParticleSystem.getParticleMap();
}
PX_INLINE PxU32 ParticleSystem::getMaxParticles() const
{
- return getScParticleSystem().getMaxParticles();
+ return mParticleSystem.getMaxParticles();
}
-
PX_INLINE PxReal ParticleSystem::getMaxMotionDistance() const
{
- return getScParticleSystem().getMaxMotionDistance();
+ return mParticleSystem.getMaxMotionDistance();
}
PX_INLINE void ParticleSystem::setMaxMotionDistance(PxReal distance)
{
- if (!isBuffering())
+ if(!isBuffering())
{
- getScParticleSystem().setMaxMotionDistance(distance);
+ mParticleSystem.setMaxMotionDistance(distance);
UPDATE_PVD_PROPERTIES_OBJECT()
}
}
PX_INLINE PxReal ParticleSystem::getRestOffset() const
{
- return getScParticleSystem().getRestOffset();
+ return mParticleSystem.getRestOffset();
}
-
PX_INLINE void ParticleSystem::setRestOffset(PxReal restOffset)
{
- if (!isBuffering())
+ if(!isBuffering())
{
- getScParticleSystem().setRestOffset(restOffset);
+ mParticleSystem.setRestOffset(restOffset);
UPDATE_PVD_PROPERTIES_OBJECT()
}
}
PX_INLINE PxReal ParticleSystem::getContactOffset() const
{
- return getScParticleSystem().getContactOffset();
+ return mParticleSystem.getContactOffset();
}
PX_INLINE void ParticleSystem::setContactOffset(PxReal contactOffset)
{
- if (!isBuffering())
+ if(!isBuffering())
{
- getScParticleSystem().setContactOffset(contactOffset);
+ mParticleSystem.setContactOffset(contactOffset);
UPDATE_PVD_PROPERTIES_OBJECT()
}
}
PX_INLINE PxReal ParticleSystem::getRestParticleDistance() const
{
- return getScParticleSystem().getRestParticleDistance();
+ return mParticleSystem.getRestParticleDistance();
}
PX_INLINE void ParticleSystem::setRestParticleDistance(PxReal restParticleDistance)
{
- if (!isBuffering())
+ if(!isBuffering())
{
- getScParticleSystem().setRestParticleDistance(restParticleDistance);
+ mParticleSystem.setRestParticleDistance(restParticleDistance);
UPDATE_PVD_PROPERTIES_OBJECT()
}
}
-
PX_INLINE PxReal ParticleSystem::getGridSize() const
{
- return getScParticleSystem().getGridSize();
+ return mParticleSystem.getGridSize();
}
PX_INLINE void ParticleSystem::setGridSize(PxReal gridSize)
{
- if (!isBuffering())
+ if(!isBuffering())
{
- getScParticleSystem().setGridSize(gridSize);
+ mParticleSystem.setGridSize(gridSize);
UPDATE_PVD_PROPERTIES_OBJECT()
}
}
PX_INLINE PxBounds3 ParticleSystem::getWorldBounds() const
{
- if (isBuffering())
+ if(isBuffering())
{
Ps::getFoundation().error(PxErrorCode::eDEBUG_WARNING, __FILE__, __LINE__,
"PxActor::getWorldBounds(): Can't access particle world bounds during simulation without enabling bulk buffering.");
return PxBounds3();
}
- return getScParticleSystem().getWorldBounds();
+ return mParticleSystem.getWorldBounds();
}
#if PX_SUPPORT_GPU_PHYSX
PX_INLINE void ParticleSystem::enableDeviceExclusiveModeGpu()
{
- getScParticleSystem().enableDeviceExclusiveModeGpu();
+ mParticleSystem.enableDeviceExclusiveModeGpu();
}
PX_INLINE PxParticleDeviceExclusiveAccess* ParticleSystem::getDeviceExclusiveAccessGpu() const
{
- if (getFlags() & PxParticleBaseFlag::eGPU)
- {
- return getScParticleSystem().getDeviceExclusiveAccessGpu();
- }
+ if(getFlags() & PxParticleBaseFlag::eGPU)
+ return mParticleSystem.getDeviceExclusiveAccessGpu();
+
return NULL;
}
diff --git a/PhysX_3.4/Source/PhysX/src/buffering/ScbRigidObject.h b/PhysX_3.4/Source/PhysX/src/buffering/ScbRigidObject.h
index e1ea7a43..49d65bd6 100644
--- a/PhysX_3.4/Source/PhysX/src/buffering/ScbRigidObject.h
+++ b/PhysX_3.4/Source/PhysX/src/buffering/ScbRigidObject.h
@@ -27,7 +27,6 @@
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
-
#ifndef PX_PHYSICS_SCB_RIGID_OBJECT
#define PX_PHYSICS_SCB_RIGID_OBJECT
@@ -44,7 +43,6 @@ namespace physx
namespace Scb
{
-
struct RemovedShape
{
RemovedShape() : mShape(NULL), mWakeTouching(0) {}
@@ -64,7 +62,6 @@ struct RemovedShape
PxU8 mWakeTouching;
};
-
struct RigidObjectBuffer : public ActorBuffer //once RigidObject has its own buffered elements, derive from that instead
{
RigidObjectBuffer(): mResetFilterShape(0), mResetFilterShapeCount(0) {}
@@ -106,8 +103,8 @@ class RigidObject : public Scb::Actor
public:
// PX_SERIALIZATION
- RigidObject() {}
- RigidObject(const PxEMPTY) : Scb::Actor(PxEmpty) {}
+ RigidObject() {}
+ RigidObject(const PxEMPTY) : Scb::Actor(PxEmpty) {}
static void getBinaryMetaData(PxOutputStream& stream);
//~PX_SERIALIZATION
@@ -148,7 +145,7 @@ public:
#if PX_SUPPORT_PVD
scene->getScenePvdClient().releasePvdInstance(&shape, pxActor);
#endif
- if (!isSimDisabledInternally())
+ if(!isSimDisabledInternally())
{
rc.removeShapeFromScene(shape.getScShape(), (rs.mWakeTouching != 0));
@@ -166,9 +163,9 @@ public:
PX_INLINE void syncState()
{
- PxU32 bufferFlags = getBufferFlags();
+ const PxU32 bufferFlags = getBufferFlags();
- if (bufferFlags & Buf::BF_ResetFiltering)
+ if(bufferFlags & Buf::BF_ResetFiltering)
{
PX_ASSERT(getControlState() != ControlState::eREMOVE_PENDING); // removing the actor should have cleared BF_ResetFiltering
@@ -176,12 +173,12 @@ public:
Sc::RigidCore& scCore = getScRigidCore();
RigidObjectBuffer* b = getBuffer();
Scb::Shape* const* shapes = (b->mResetFilterShapeCount == 1) ? &b->mResetFilterShape : scene->getShapeBuffer(b->mResetFilterShapesIdx);
- for(PxU32 i=0; i < b->mResetFilterShapeCount; i++)
+ for(PxU32 i=0; i<b->mResetFilterShapeCount; i++)
{
Sc::ShapeCore& scShape = shapes[i]->getScShape();
// do not process the call if the shape will not be a broadphase shape any longer
- if (shapes[i]->getFlags() & (PxShapeFlag::eSIMULATION_SHAPE | PxShapeFlag::eTRIGGER_SHAPE))
+ if(shapes[i]->getFlags() & (PxShapeFlag::eSIMULATION_SHAPE | PxShapeFlag::eTRIGGER_SHAPE))
scCore.onShapeChange(scShape, Sc::ShapeChangeNotifyFlag::eRESET_FILTERING, PxShapeFlags());
}
}
@@ -199,11 +196,11 @@ public:
// it can happen that a shape gets attached while the sim is running but then the actor is removed from the scene,
// so we need to distinguish those two cases
- if (cs != ControlState::eREMOVE_PENDING)
+ if(cs != ControlState::eREMOVE_PENDING)
{
shape.setControlStateIfExclusive(getScbScene(), Scb::ControlState::eIN_SCENE);
- if (!(getActorFlags() & PxActorFlag::eDISABLE_SIMULATION)) // important to use the buffered flags since we want the new state.
+ if(!(getActorFlags() & PxActorFlag::eDISABLE_SIMULATION)) // important to use the buffered flags since we want the new state.
{
getScRigidCore().addShapeToScene(shape.getScShape());
NpShapeIncRefCount(shape);
@@ -223,7 +220,11 @@ public:
Actor::syncState();
}
- PX_FORCE_INLINE void scheduleForWakeTouching() { PX_ASSERT(getScbScene() && getScbScene()->isPhysicsBuffering()); setBufferFlag(RigidObjectBuffer::BF_WakeTouching); }
+ PX_FORCE_INLINE void scheduleForWakeTouching()
+ {
+ PX_ASSERT(getScbScene() && getScbScene()->isPhysicsBuffering());
+ setBufferFlag(RigidObjectBuffer::BF_WakeTouching);
+ }
//---------------------------------------------------------------------------------
// Miscellaneous
@@ -232,15 +233,6 @@ public:
PX_INLINE const Sc::RigidCore& getScRigidCore() const { return static_cast<const Sc::RigidCore&>(getActorCore()); } // Only use if you know what you're doing!
PX_INLINE Sc::RigidCore& getScRigidCore() { return static_cast<Sc::RigidCore&>(getActorCore()); } // Only use if you know what you're doing!
- PX_INLINE void setShapeStateIfExclusive(Scb::Shape& shape, ControlState::Enum cs, Scb::Scene& scene)
- {
- if(shape.isExclusive())
- {
- shape.setScbScene(&scene);
- shape.setControlState(cs);
- }
- }
-
PX_INLINE void onShapeAttach(Scb::Shape& shape)
{
// there are two things to do here: add the shape to the sim (if unbuffered) or set it up for
@@ -254,19 +246,19 @@ public:
Scene* scbScene = getScbScene();
if(!scbScene->isPhysicsBuffering())
{
- if (!(getActorFlags() & PxActorFlag::eDISABLE_SIMULATION))
+ if(!(getActorFlags() & PxActorFlag::eDISABLE_SIMULATION))
{
NpShapeIncRefCount(shape);
getScRigidCore().addShapeToScene(shape.getScShape());
}
#if PX_SUPPORT_PVD
- getScbScene()->getScenePvdClient().createPvdInstance(&shape, *getScRigidCore().getPxActor());
+ scbScene->getScenePvdClient().createPvdInstance(&shape, *getScRigidCore().getPxActor());
#endif
shape.setControlStateIfExclusive(scbScene, ControlState::eIN_SCENE);
return;
}
- else if (cs == ControlState::eINSERT_PENDING)
+ else if(cs == ControlState::eINSERT_PENDING)
{
shape.setControlStateIfExclusive(scbScene, ControlState::eINSERT_PENDING);
return;
@@ -280,7 +272,6 @@ public:
shape.setControlStateIfExclusive(scbScene, ControlState::eINSERT_PENDING);
}
-
PX_INLINE void onShapeDetach(Scb::Shape& shape, bool wakeOnLostTouch, bool toBeReleased)
{
// see comments in onShapeAttach
@@ -294,7 +285,7 @@ public:
#if PX_SUPPORT_PVD
scbScene->getScenePvdClient().releasePvdInstance(&shape, *getScRigidCore().getPxActor());
#endif
- if (!(getActorFlags() & PxActorFlag::eDISABLE_SIMULATION))
+ if(!(getActorFlags() & PxActorFlag::eDISABLE_SIMULATION))
{
getScRigidCore().removeShapeFromScene(shape.getScShape(), wakeOnLostTouch);
NpShapeDecRefCount(shape);
@@ -303,7 +294,7 @@ public:
shape.setControlStateIfExclusive(NULL, ControlState::eNOT_IN_SCENE);
return;
}
- else if (cs == ControlState::eINSERT_PENDING)
+ else if(cs == ControlState::eINSERT_PENDING)
{
shape.setControlStateIfExclusive(NULL, ControlState::eNOT_IN_SCENE);
return;
@@ -312,12 +303,12 @@ public:
RigidObjectBuffer* b = getBuffer();
// remove from the resetFiltering list
- PxU32 bufferFlags = getBufferFlags();
- if (bufferFlags & Buf::BF_ResetFiltering)
+ const PxU32 bufferFlags = getBufferFlags();
+ if(bufferFlags & Buf::BF_ResetFiltering)
{
- if (b->mResetFilterShapeCount == 1)
+ if(b->mResetFilterShapeCount == 1)
{
- if (b->mResetFilterShape == &shape)
+ if(b->mResetFilterShape == &shape)
{
b->mResetFilterShapeCount = 0;
b->mResetFilterShape = 0;
@@ -331,7 +322,7 @@ public:
PxU32 lastIdx = b->mResetFilterShapeCount;
for(PxU32 k=0; k < b->mResetFilterShapeCount; k++) // need to iterate over whole list, same shape can be in there multiple times
{
- if (shapes[idx] != &shape)
+ if(shapes[idx] != &shape)
idx++;
else
{
@@ -340,12 +331,12 @@ public:
}
}
b->mResetFilterShapeCount = idx;
- if (idx == 0)
+ if(idx == 0)
{
b->mResetFilterShape = 0;
resetBufferFlag(Buf::BF_ResetFiltering);
}
- else if (idx == 1)
+ else if(idx == 1)
b->mResetFilterShape = shapes[0];
}
}
@@ -354,7 +345,7 @@ public:
shape.setControlStateIfExclusive(scbScene, ControlState::eIN_SCENE);
else
{
- if (!isSimDisabledInternally())
+ if(!isSimDisabledInternally())
{
b->mRemovedShapes.pushBack(RemovedShape(&shape, PxU8(wakeOnLostTouch ? 1 : 0)));
}
@@ -362,7 +353,7 @@ public:
{
PX_ASSERT(scbScene);
PX_ASSERT(scbScene->isPhysicsBuffering());
- if (toBeReleased)
+ if(toBeReleased)
{
shape.checkUpdateOnRemove<false>(scbScene);
#if PX_SUPPORT_PVD
@@ -399,7 +390,6 @@ private:
PX_FORCE_INLINE void copyResetFilterShapes(Scb::Shape** shapePtrs, Scb::Shape*const* oldShapes, PxU32 oldShapeCount, Scb::Shape*const* newShapes, PxU32 newShapeCount);
};
-
PX_INLINE void RigidObject::resetFiltering(Scb::Shape*const* shapes, PxU32 shapeCount)
{
PX_ASSERT(!(getActorFlags() & PxActorFlag::eDISABLE_SIMULATION));
@@ -413,9 +403,9 @@ PX_INLINE void RigidObject::resetFiltering(Scb::Shape*const* shapes, PxU32 shape
{
RigidObjectBuffer* b = getBuffer();
- if (b->mResetFilterShapeCount == 0)
+ if(b->mResetFilterShapeCount == 0)
{
- if (shapeCount == 1)
+ if(shapeCount == 1)
{
b->mResetFilterShape = shapes[0];
b->mResetFilterShapeCount = 1;
@@ -425,7 +415,7 @@ PX_INLINE void RigidObject::resetFiltering(Scb::Shape*const* shapes, PxU32 shape
{
PxU32 bufferIdx;
Scb::Shape** shapePtrs = getScbScene()->allocShapeBuffer(shapeCount, bufferIdx);
- if (shapePtrs)
+ if(shapePtrs)
{
for(PxU32 i=0; i < shapeCount; i++)
shapePtrs[i] = shapes[i];
@@ -440,9 +430,9 @@ PX_INLINE void RigidObject::resetFiltering(Scb::Shape*const* shapes, PxU32 shape
PxU32 newCount = b->mResetFilterShapeCount + shapeCount;
PxU32 bufferIdx;
Scb::Shape** shapePtrs = getScbScene()->allocShapeBuffer(newCount, bufferIdx);
- if (shapePtrs)
+ if(shapePtrs)
{
- if (b->mResetFilterShapeCount == 1)
+ if(b->mResetFilterShapeCount == 1)
copyResetFilterShapes(shapePtrs, &b->mResetFilterShape, 1, shapes, shapeCount);
else
copyResetFilterShapes(shapePtrs, getScbScene()->getShapeBuffer(b->mResetFilterShapesIdx), b->mResetFilterShapeCount, shapes, shapeCount);
@@ -454,12 +444,11 @@ PX_INLINE void RigidObject::resetFiltering(Scb::Shape*const* shapes, PxU32 shape
}
}
-
PX_INLINE bool RigidObject::isAddedShape(Scb::Shape& shape)
{
PX_ASSERT(isBuffered(Buf::BF_Shapes));
- if (shape.isExclusive())
+ if(shape.isExclusive())
{
return (shape.getControlState() == Scb::ControlState::eINSERT_PENDING);
}
@@ -472,48 +461,41 @@ PX_INLINE bool RigidObject::isAddedShape(Scb::Shape& shape)
const PxU32 addedShapeCount = buf->mAddedShapes.size();
for(PxU32 k=0; k < addedShapeCount; k++)
{
- if (&shape == buf->mAddedShapes[k])
- {
+ if(&shape == buf->mAddedShapes[k])
return true;
- }
}
-
return false;
}
}
-
PX_FORCE_INLINE void RigidObject::switchToNoSim(bool isDynamic)
{
Scb::Scene* scene = getScbScene();
- if (scene && (!scene->isPhysicsBuffering()))
+ if(scene && (!scene->isPhysicsBuffering()))
scene->switchRigidToNoSim(*this, isDynamic);
}
-
PX_FORCE_INLINE void RigidObject::switchFromNoSim(bool isDynamic)
{
Scb::Scene* scene = getScbScene();
- if (scene && (!scene->isPhysicsBuffering()))
+ if(scene && (!scene->isPhysicsBuffering()))
scene->switchRigidFromNoSim(*this, isDynamic);
}
-
PX_FORCE_INLINE void RigidObject::syncNoSimSwitch(const Buf& buf, Sc::RigidCore& rc, bool isDynamic)
{
- PxActorFlags oldFlags = rc.getActorFlags();
- bool oldNoSim = oldFlags.isSet(PxActorFlag::eDISABLE_SIMULATION);
- bool newNoSim = buf.mActorFlags.isSet(PxActorFlag::eDISABLE_SIMULATION);
+ const PxActorFlags oldFlags = rc.getActorFlags();
+ const bool oldNoSim = oldFlags.isSet(PxActorFlag::eDISABLE_SIMULATION);
+ const bool newNoSim = buf.mActorFlags.isSet(PxActorFlag::eDISABLE_SIMULATION);
- if (oldNoSim && (!newNoSim))
+ if(oldNoSim && (!newNoSim))
getScbScene()->switchRigidFromNoSim(*this, isDynamic);
- else if ((!oldNoSim) && newNoSim)
+ else if((!oldNoSim) && newNoSim)
getScbScene()->switchRigidToNoSim(*this, isDynamic);
}
-
PX_FORCE_INLINE void RigidObject::copyResetFilterShapes(Scb::Shape** shapePtrs, Scb::Shape*const* oldShapes, PxU32 oldShapeCount, Scb::Shape*const* newShapes, PxU32 newShapeCount)
{
for(PxU32 i=0; i < oldShapeCount; i++)
@@ -522,7 +504,6 @@ PX_FORCE_INLINE void RigidObject::copyResetFilterShapes(Scb::Shape** shapePtrs,
shapePtrs[i+oldShapeCount] = newShapes[i];
}
-
} // namespace Scb
}
diff --git a/PhysX_3.4/Source/PhysX/src/buffering/ScbRigidStatic.h b/PhysX_3.4/Source/PhysX/src/buffering/ScbRigidStatic.h
index d783f203..41263184 100644
--- a/PhysX_3.4/Source/PhysX/src/buffering/ScbRigidStatic.h
+++ b/PhysX_3.4/Source/PhysX/src/buffering/ScbRigidStatic.h
@@ -27,7 +27,6 @@
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
-
#ifndef PX_PHYSICS_SCB_RIGID_STATIC
#define PX_PHYSICS_SCB_RIGID_STATIC
@@ -38,10 +37,8 @@
namespace physx
{
-
namespace Scb
{
-
#if PX_VC
#pragma warning(push)
#pragma warning( disable : 4324 ) // Padding was added at the end of a structure because of a __declspec(align) value.
@@ -62,7 +59,6 @@ struct RigidStaticBuffer : public RigidObjectBuffer
#pragma warning(pop)
#endif
-
class RigidStatic : public Scb::RigidObject
{
//= ATTENTION! =====================================================================================
@@ -93,10 +89,7 @@ public:
//---------------------------------------------------------------------------------
PX_INLINE void syncState();
- static size_t getScOffset()
- {
- return reinterpret_cast<size_t>(&reinterpret_cast<RigidStatic*>(0)->mStatic);
- }
+ static size_t getScOffset() { return reinterpret_cast<size_t>(&reinterpret_cast<RigidStatic*>(0)->mStatic); }
PX_FORCE_INLINE Sc::StaticCore& getScStatic() { return mStatic; }
@@ -116,33 +109,30 @@ private:
template<PxU32 f> PX_FORCE_INLINE typename Buf::Fns<f,0>::Arg read() const { return Access::read<Buf::Fns<f,0> >(*this, mStatic); }
template<PxU32 f> PX_FORCE_INLINE void write(typename Buf::Fns<f,0>::Arg v) { Access::write<Buf::Fns<f,0> >(*this, mStatic, v); }
- template<PxU32 f> PX_FORCE_INLINE void flush(const Buf& buf) { Access::flush<Buf::Fns<f,0> >(*this, mStatic, buf); }
-
+ template<PxU32 f> PX_FORCE_INLINE void flush(const Buf& buf) { Access::flush<Buf::Fns<f,0> >(*this, mStatic, buf); }
};
RigidStatic::RigidStatic(const PxTransform& actor2World) :
mStatic(actor2World)
{
- setScbType(ScbType::RIGID_STATIC);
+ setScbType(ScbType::eRIGID_STATIC);
}
-
//--------------------------------------------------------------
//
// Data synchronization
//
//--------------------------------------------------------------
-
PX_INLINE void RigidStatic::syncState()
{
- PxU32 bufferFlags = getBufferFlags();
+ const PxU32 bufferFlags = getBufferFlags();
- if (bufferFlags & Buf::BF_ActorFlags)
+ if(bufferFlags & Buf::BF_ActorFlags)
syncNoSimSwitch(*getRigidActorBuffer(), mStatic, false);
RigidObject::syncState();
- if (bufferFlags & Buf::BF_Actor2World)
+ if(bufferFlags & Buf::BF_Actor2World)
flush<Buf::BF_Actor2World>(*getRigidActorBuffer());
postSyncState();
diff --git a/PhysX_3.4/Source/PhysX/src/buffering/ScbScene.cpp b/PhysX_3.4/Source/PhysX/src/buffering/ScbScene.cpp
index 0d0ac638..04b355a4 100644
--- a/PhysX_3.4/Source/PhysX/src/buffering/ScbScene.cpp
+++ b/PhysX_3.4/Source/PhysX/src/buffering/ScbScene.cpp
@@ -880,63 +880,61 @@ void Scb::Scene::preSimulateUpdateAppThread(PxReal timeStep)
void Scb::Scene::syncState()
{
//process client creation -- must be done before BF_CLIENT_BEHAVIOR_FLAGS processing in the below block:
- while (mBufferedData.numClientsCreated)
+ while(mBufferedData.mNumClientsCreated)
{
mScene.createClient();
- mBufferedData.numClientsCreated--;
+ mBufferedData.mNumClientsCreated--;
}
- if (mBufferFlags)
+ if(mBufferFlags)
{
- if (isBuffered(BF_GRAVITY))
- mScene.setGravity(mBufferedData.gravity);
+ if(isBuffered(BF_GRAVITY))
+ mScene.setGravity(mBufferedData.mGravity);
if(isBuffered(BF_BOUNCETHRESHOLDVELOCITY))
- mScene.setBounceThresholdVelocity(mBufferedData.bounceThresholdVelocity);
+ mScene.setBounceThresholdVelocity(mBufferedData.mBounceThresholdVelocity);
- if (isBuffered(BF_FLAGS))
- mScene.setPublicFlags(mBufferedData.flags);
+ if(isBuffered(BF_FLAGS))
+ mScene.setPublicFlags(mBufferedData.mFlags);
- if (isBuffered(BF_DOMINANCE_PAIRS))
+ if(isBuffered(BF_DOMINANCE_PAIRS))
mBufferedData.syncDominancePairs(mScene);
- if (isBuffered(BF_SOLVER_BATCH_SIZE))
- mScene.setSolverBatchSize(mBufferedData.solverBatchSize);
+ if(isBuffered(BF_SOLVER_BATCH_SIZE))
+ mScene.setSolverBatchSize(mBufferedData.mSolverBatchSize);
- if (isBuffered(BF_CLIENT_BEHAVIOR_FLAGS))
+ if(isBuffered(BF_CLIENT_BEHAVIOR_FLAGS))
{
- for (PxU32 i = 0; i < mBufferedData.clientBehaviorFlags.size(); i++)
+ for(PxU32 i=0; i<mBufferedData.mClientBehaviorFlags.size(); i++)
{
- if (mBufferedData.clientBehaviorFlags[i] != PxClientBehaviorFlag_eNOT_BUFFERED) //not PxClientBehaviorFlag_eNOT_BUFFERED means it was written.
+ if(mBufferedData.mClientBehaviorFlags[i] != PxClientBehaviorFlag_eNOT_BUFFERED) //not PxClientBehaviorFlag_eNOT_BUFFERED means it was written.
{
- mScene.setClientBehaviorFlags(PxClientID(i), mBufferedData.clientBehaviorFlags[i]);
- mBufferedData.clientBehaviorFlags[i] = PxClientBehaviorFlag_eNOT_BUFFERED;
+ mScene.setClientBehaviorFlags(PxClientID(i), mBufferedData.mClientBehaviorFlags[i]);
+ mBufferedData.mClientBehaviorFlags[i] = PxClientBehaviorFlag_eNOT_BUFFERED;
}
-
}
}
- if (isBuffered(BF_VISUALIZATION))
+ if(isBuffered(BF_VISUALIZATION))
{
- for(PxU32 i=0; i < PxVisualizationParameter::eNUM_VALUES; i++)
+ for(PxU32 i=0; i<PxVisualizationParameter::eNUM_VALUES; i++)
{
- if (mBufferedData.visualizationParamChanged[i])
- {
- mScene.setVisualizationParameter(static_cast<PxVisualizationParameter::Enum>(i), mBufferedData.visualizationParam[i]);
- }
+ if(mBufferedData.mVisualizationParamChanged[i])
+ mScene.setVisualizationParameter(PxVisualizationParameter::Enum(i), mBufferedData.mVisualizationParam[i]);
}
+
+ mBufferedData.clearVisualizationParams();
}
+ if(isBuffered(BF_CULLING_BOX))
+ mScene.setVisualizationCullingBox(mBufferedData.mVisualizationCullingBox);
+
#if PX_SUPPORT_PVD
if(mScenePvdClient.checkPvdDebugFlag())
mScenePvdClient.updatePvdProperties();
#endif
+ mBufferFlags = 0;
}
-
-
- mBufferFlags = 0;
- mBufferedData.clearDominanceBuffer();
- mBufferedData.clearVisualizationParams();
}
template<typename T>
@@ -1015,11 +1013,11 @@ void Scb::Scene::syncWriteThroughProperties()
mStream.unlock();
}
-void Scb::Scene::syncEntireScene(PxU32* error)
+void Scb::Scene::syncEntireScene()
{
PX_PROFILE_ZONE("Sim.syncState", getContextId());
- if (error)
- *error = mScene.getErrorState();
+
+ setPhysicsBuffering(false); // Clear the buffering flag to allow buffered writes to execute immediately. Once collision detection is running, buffering is automatically forced on
mStream.lock();
syncState();
@@ -1201,9 +1199,9 @@ void Scb::Scene::processRemoves(ObjectTracker& tracker)
bool wakeOnLostTouch = false;
if (wakeOnLostTouchCheck)
{
- PX_ASSERT( (v->getScbType() == ScbType::BODY) ||
- (v->getScbType() == ScbType::BODY_FROM_ARTICULATION_LINK) ||
- (v->getScbType() == ScbType::RIGID_STATIC) );
+ PX_ASSERT( (v->getScbType() == ScbType::eBODY) ||
+ (v->getScbType() == ScbType::eBODY_FROM_ARTICULATION_LINK) ||
+ (v->getScbType() == ScbType::eRIGID_STATIC) );
wakeOnLostTouch = (v->Base::isBuffered(RigidObjectBuffer::BF_WakeTouching) != 0); // important to use Scb::Base::isBuffered() because Scb::Body, for example, has a shadowed implementation of this method
}
@@ -1275,31 +1273,29 @@ void Scb::Scene::processPendingRemove()
#endif
}
}
-
-
}
void Scb::Scene::scheduleForUpdate(Scb::Base& object)
{
switch(object.getScbType())
{
- case ScbType::SHAPE_EXCLUSIVE:
- case ScbType::SHAPE_SHARED: { mShapeManager.scheduleForUpdate(object); }break;
- case ScbType::BODY: { mBodyManager.scheduleForUpdate(object); }break;
- case ScbType::BODY_FROM_ARTICULATION_LINK: { mBodyManager.scheduleForUpdate(object); }break;
- case ScbType::RIGID_STATIC: { mRigidStaticManager.scheduleForUpdate(object); }break;
- case ScbType::CONSTRAINT: { mConstraintManager.scheduleForUpdate(object); }break;
+ case ScbType::eSHAPE_EXCLUSIVE:
+ case ScbType::eSHAPE_SHARED: { mShapeManager.scheduleForUpdate(object); }break;
+ case ScbType::eBODY: { mBodyManager.scheduleForUpdate(object); }break;
+ case ScbType::eBODY_FROM_ARTICULATION_LINK: { mBodyManager.scheduleForUpdate(object); }break;
+ case ScbType::eRIGID_STATIC: { mRigidStaticManager.scheduleForUpdate(object); }break;
+ case ScbType::eCONSTRAINT: { mConstraintManager.scheduleForUpdate(object); }break;
#if PX_USE_PARTICLE_SYSTEM_API
- case ScbType::PARTICLE_SYSTEM: { mParticleSystemManager.scheduleForUpdate(object); }break;
+ case ScbType::ePARTICLE_SYSTEM: { mParticleSystemManager.scheduleForUpdate(object); }break;
#endif
- case ScbType::ARTICULATION: { mArticulationManager.scheduleForUpdate(object); }break;
- case ScbType::ARTICULATION_JOINT: { mArticulationJointManager.scheduleForUpdate(object); }break;
- case ScbType::AGGREGATE: { mAggregateManager.scheduleForUpdate(object); }break;
+ case ScbType::eARTICULATION: { mArticulationManager.scheduleForUpdate(object); }break;
+ case ScbType::eARTICULATION_JOINT: { mArticulationJointManager.scheduleForUpdate(object); }break;
+ case ScbType::eAGGREGATE: { mAggregateManager.scheduleForUpdate(object); }break;
#if PX_USE_CLOTH_API
- case ScbType::CLOTH: { mClothManager.scheduleForUpdate(object); }break;
+ case ScbType::eCLOTH: { mClothManager.scheduleForUpdate(object); }break;
#endif
- case ScbType::UNDEFINED:
- case ScbType::TYPE_COUNT:
+ case ScbType::eUNDEFINED:
+ case ScbType::eTYPE_COUNT:
PX_ALWAYS_ASSERT_MESSAGE( "scheduleForUpdate: missing type!");
break;
}
@@ -1310,24 +1306,24 @@ PxU8* Scb::Scene::getStream(ScbType::Enum type)
PxU8* memory = NULL;
switch(type)
{
- case ScbType::SHAPE_EXCLUSIVE:
- case ScbType::SHAPE_SHARED: { memory = reinterpret_cast<PxU8*>(mStream.allocateNotThreadSafe(sizeof(Scb::ShapeBuffer))); new (memory) Scb::ShapeBuffer; }break;
- case ScbType::BODY: { memory = reinterpret_cast<PxU8*>(mStream.allocateNotThreadSafe(sizeof(Scb::BodyBuffer))); new (memory) Scb::BodyBuffer; }break;
- case ScbType::BODY_FROM_ARTICULATION_LINK: { memory = reinterpret_cast<PxU8*>(mStream.allocateNotThreadSafe(sizeof(Scb::BodyBuffer))); new (memory) Scb::BodyBuffer; }break;
- case ScbType::RIGID_STATIC: { memory = reinterpret_cast<PxU8*>(mStream.allocateNotThreadSafe(sizeof(Scb::RigidStaticBuffer))); new (memory) Scb::RigidStaticBuffer; }break;
- case ScbType::CONSTRAINT: { memory = reinterpret_cast<PxU8*>(mStream.allocateNotThreadSafe(sizeof(Scb::ConstraintBuffer))); new (memory) Scb::ConstraintBuffer; }break;
+ case ScbType::eSHAPE_EXCLUSIVE:
+ case ScbType::eSHAPE_SHARED: { memory = reinterpret_cast<PxU8*>(mStream.allocateNotThreadSafe(sizeof(Scb::ShapeBuffer))); new (memory) Scb::ShapeBuffer; }break;
+ case ScbType::eBODY: { memory = reinterpret_cast<PxU8*>(mStream.allocateNotThreadSafe(sizeof(Scb::BodyBuffer))); new (memory) Scb::BodyBuffer; }break;
+ case ScbType::eBODY_FROM_ARTICULATION_LINK: { memory = reinterpret_cast<PxU8*>(mStream.allocateNotThreadSafe(sizeof(Scb::BodyBuffer))); new (memory) Scb::BodyBuffer; }break;
+ case ScbType::eRIGID_STATIC: { memory = reinterpret_cast<PxU8*>(mStream.allocateNotThreadSafe(sizeof(Scb::RigidStaticBuffer))); new (memory) Scb::RigidStaticBuffer; }break;
+ case ScbType::eCONSTRAINT: { memory = reinterpret_cast<PxU8*>(mStream.allocateNotThreadSafe(sizeof(Scb::ConstraintBuffer))); new (memory) Scb::ConstraintBuffer; }break;
#if PX_USE_PARTICLE_SYSTEM_API
- case ScbType::PARTICLE_SYSTEM: { memory = reinterpret_cast<PxU8*>(mStream.allocateNotThreadSafe(sizeof(Scb::ParticleSystemBuffer))); new (memory) Scb::ParticleSystemBuffer; }break;
+ case ScbType::ePARTICLE_SYSTEM: { memory = reinterpret_cast<PxU8*>(mStream.allocateNotThreadSafe(sizeof(Scb::ParticleSystemBuffer))); new (memory) Scb::ParticleSystemBuffer; }break;
#endif
- case ScbType::ARTICULATION: { memory = reinterpret_cast<PxU8*>(mStream.allocateNotThreadSafe(sizeof(Scb::ArticulationBuffer))); new (memory) Scb::ArticulationBuffer; }break;
- case ScbType::ARTICULATION_JOINT: { memory = reinterpret_cast<PxU8*>(mStream.allocateNotThreadSafe(sizeof(Scb::ArticulationJointBuffer))); new (memory) Scb::ArticulationJointBuffer; }break;
- case ScbType::AGGREGATE: { memory = reinterpret_cast<PxU8*>(mStream.allocateNotThreadSafe(sizeof(Scb::AggregateBuffer))); new (memory) Scb::AggregateBuffer; }break;
+ case ScbType::eARTICULATION: { memory = reinterpret_cast<PxU8*>(mStream.allocateNotThreadSafe(sizeof(Scb::ArticulationBuffer))); new (memory) Scb::ArticulationBuffer; }break;
+ case ScbType::eARTICULATION_JOINT: { memory = reinterpret_cast<PxU8*>(mStream.allocateNotThreadSafe(sizeof(Scb::ArticulationJointBuffer))); new (memory) Scb::ArticulationJointBuffer; }break;
+ case ScbType::eAGGREGATE: { memory = reinterpret_cast<PxU8*>(mStream.allocateNotThreadSafe(sizeof(Scb::AggregateBuffer))); new (memory) Scb::AggregateBuffer; }break;
#if PX_USE_CLOTH_API
- case ScbType::CLOTH:
+ case ScbType::eCLOTH:
#endif
- case ScbType::UNDEFINED:
- case ScbType::TYPE_COUNT:
+ case ScbType::eUNDEFINED:
+ case ScbType::eTYPE_COUNT:
PX_ALWAYS_ASSERT_MESSAGE("getStream: missing type!");
return NULL;
}
@@ -1389,7 +1385,7 @@ bool Scb::Scene::removeBroadPhaseRegion(PxU32 handle)
template <bool TSimRunning, bool TAdd, bool TIsDynamic, bool TIsNonSimObject, class T>
PX_FORCE_INLINE static void addOrRemoveRigidObject(Sc::Scene& s, T& rigidObject, bool wakeOnLostTouch, PxBounds3* uninflatedBounds)
{
- PX_ASSERT(TIsDynamic || (rigidObject.getScbType() == ScbType::RIGID_STATIC));
+ PX_ASSERT(TIsDynamic || (rigidObject.getScbType() == ScbType::eRIGID_STATIC));
if (TSimRunning && TIsNonSimObject && TAdd)
PX_ASSERT(rigidObject.getActorFlags() & PxActorFlag::eDISABLE_SIMULATION);
if (TSimRunning && TIsNonSimObject&& !TAdd)
diff --git a/PhysX_3.4/Source/PhysX/src/buffering/ScbScene.h b/PhysX_3.4/Source/PhysX/src/buffering/ScbScene.h
index 3a3ae43d..eca47c0f 100644
--- a/PhysX_3.4/Source/PhysX/src/buffering/ScbScene.h
+++ b/PhysX_3.4/Source/PhysX/src/buffering/ScbScene.h
@@ -27,7 +27,6 @@
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
-
#ifndef PX_PHYSICS_SCB_SCENE
#define PX_PHYSICS_SCB_SCENE
@@ -162,8 +161,7 @@ namespace Scb
BF_SOLVER_BATCH_SIZE = (1 << 4),
BF_CLIENT_BEHAVIOR_FLAGS = (1 << 5),
BF_VISUALIZATION = (1 << 6),
- BF_SCENE_PARAMS = (1 << 7)
-
+ BF_CULLING_BOX = (1 << 7)
};
public:
@@ -186,8 +184,8 @@ namespace Scb
PX_INLINE void setFlags(PxSceneFlags flags);
PX_INLINE PxSceneFlags getFlags() const;
- PX_INLINE void setFrictionType(PxFrictionType::Enum);
- PX_INLINE PxFrictionType::Enum getFrictionType() const;
+ PX_INLINE void setFrictionType(PxFrictionType::Enum type) { mScene.setFrictionType(type); }
+ PX_INLINE PxFrictionType::Enum getFrictionType() const { return mScene.getFrictionType(); }
void addActor(Scb::RigidStatic&, bool noSim, PxBounds3* uninflatedBounds);
void removeActor(Scb::RigidStatic&, bool wakeOnLostTouch, bool noSim);
@@ -222,8 +220,9 @@ namespace Scb
void removeMaterial(const Sc::MaterialCore& mat);
void updateLowLevelMaterial(NpMaterial** masterMaterials);
// These methods are only to be called at fetchResults!
- PX_INLINE PxU32 getNumActiveBodies() const;
- PX_INLINE Sc::BodyCore* const* getActiveBodiesArray() const;
+ PX_INLINE PxU32 getNumActiveBodies() const { return mScene.getNumActiveBodies(); }
+ PX_INLINE Sc::BodyCore* const* getActiveBodiesArray() const { return mScene.getActiveBodiesArray(); }
+
PX_INLINE PxSimulationEventCallback* getSimulationEventCallback(PxClientID client) const;
PX_INLINE void setSimulationEventCallback(PxSimulationEventCallback* callback, PxClientID client);
PX_INLINE PxContactModifyCallback* getContactModifyCallback() const;
@@ -255,10 +254,11 @@ namespace Scb
PX_INLINE void setSolverBatchSize(PxU32 solverBatchSize);
PX_INLINE PxU32 getSolverBatchSize() const;
- PX_INLINE void simulate(PxReal timeStep, PxBaseTask* continuation);
- PX_INLINE void collide(PxReal timeStep, PxBaseTask* continuation);
- PX_INLINE void advance(PxReal timeStep, PxBaseTask* continuation);
- PX_INLINE void endSimulation();
+ PX_INLINE void simulate(PxReal timeStep, PxBaseTask* continuation) { mScene.simulate(timeStep, continuation); }
+ PX_INLINE void collide(PxReal timeStep, PxBaseTask* continuation) { mScene.collide(timeStep, continuation); }
+ PX_INLINE void advance(PxReal timeStep, PxBaseTask* continuation) { mScene.advance(timeStep, continuation); }
+ PX_INLINE void endSimulation() { mScene.endSimulation(); }
+
PX_INLINE void flush(bool sendPendingReports);
PX_INLINE void fireBrokenConstraintCallbacks() { mScene.fireBrokenConstraintCallbacks(); }
PX_INLINE void fireTriggerCallbacks() { mScene.fireTriggerCallbacks(); }
@@ -267,12 +267,11 @@ namespace Scb
getQueuedContactPairHeaders() { return mScene.getQueuedContactPairHeaders(); }
PX_FORCE_INLINE void postCallbacksPreSync() { mScene.postCallbacksPreSync(); } //cleanup tasks after the pre-sync callbacks have fired
-
PX_INLINE void fireCallBacksPostSync() { mScene.fireCallbacksPostSync(); } //callbacks that are fired on the core side, after the buffers get synced
PX_INLINE void postReportsCleanup();
- PX_INLINE const PxSceneLimits& getLimits() const;
- PX_INLINE void setLimits(const PxSceneLimits& limits);
+ PX_INLINE const PxSceneLimits& getLimits() const { return mScene.getLimits(); }
+ PX_INLINE void setLimits(const PxSceneLimits& limits) { mScene.setLimits(limits); }
PX_INLINE void getStats(PxSimulationStatistics& stats) const;
@@ -308,7 +307,7 @@ namespace Scb
//---------------------------------------------------------------------------------
public:
void syncWriteThroughProperties();
- void syncEntireScene(PxU32* error);
+ void syncEntireScene();
void processPendingRemove();
PX_FORCE_INLINE PxU16* allocShapeMaterialBuffer(PxU32 count, PxU32& startIdx) { return allocArrayBuffer(mShapeMaterialBuffer, count, startIdx); }
@@ -330,7 +329,7 @@ namespace Scb
private:
void syncState();
PX_FORCE_INLINE Ps::IntBool isBuffered(BufferFlag f) const { return Ps::IntBool(mBufferFlags& f); }
- PX_FORCE_INLINE void markUpdated(BufferFlag f) { mBufferFlags |= f; }
+ PX_FORCE_INLINE void markUpdated(BufferFlag f) { mBufferFlags |= f; }
//---------------------------------------------------------------------------------
// Miscellaneous
@@ -360,7 +359,6 @@ namespace Scb
PX_FORCE_INLINE Vd::ScbScenePvdClient& getScenePvdClient() { return mScenePvdClient; }
PX_FORCE_INLINE const Vd::ScbScenePvdClient& getScenePvdClient() const { return mScenePvdClient; }
#endif
-
PX_FORCE_INLINE PxU64 getContextId() const { return mScene.getContextId(); }
private:
@@ -374,10 +372,10 @@ namespace Scb
template<bool TIsDynamic, class T>
PX_FORCE_INLINE void addActorT(T& actor, ObjectTracker& tracker, bool noSim, PxBounds3* uninflatedBounds);
- template<typename T> void add(T& v, ObjectTracker &tracker, PxBounds3* uninflatedBounds);
- template<typename T> void remove(T& v, ObjectTracker &tracker, bool wakeOnLostTouch = false);
- template<bool TIsDynamic, typename T> void addRigidNoSim(T& v, ObjectTracker &tracker);
- template<bool TIsDynamic, typename T> void removeRigidNoSim(T& v, ObjectTracker &tracker);
+ template<typename T> void add(T& v, ObjectTracker& tracker, PxBounds3* uninflatedBounds);
+ template<typename T> void remove(T& v, ObjectTracker& tracker, bool wakeOnLostTouch = false);
+ template<bool TIsDynamic, typename T> void addRigidNoSim(T& v, ObjectTracker& tracker);
+ template<bool TIsDynamic, typename T> void removeRigidNoSim(T& v, ObjectTracker& tracker);
template<typename T, typename S> void processSimUpdates(S*const * scObjects, PxU32 nbObjects);
template<typename T> void processUserUpdates(ObjectTracker& tracker);
template<typename T, bool syncOnRemove, bool wakeOnLostTouchCheck> void processRemoves(ObjectTracker& tracker);
@@ -436,7 +434,6 @@ namespace Scb
} // namespace Scb
-
template<typename T>
T* Scb::Scene::allocArrayBuffer(Ps::Array<T>& buffer, PxU32 count, PxU32& startIdx)
{
@@ -448,62 +445,51 @@ T* Scb::Scene::allocArrayBuffer(Ps::Array<T>& buffer, PxU32 count, PxU32& startI
PX_INLINE void Scb::Scene::setGravity(const PxVec3& gravity)
{
- if (!isPhysicsBuffering())
+ if(!isPhysicsBuffering())
{
mScene.setGravity(gravity);
updatePvdProperties();
}
else
{
- mBufferedData.gravity = gravity;
+ mBufferedData.mGravity = gravity;
markUpdated(BF_GRAVITY);
}
}
PX_INLINE PxVec3 Scb::Scene::getGravity() const
{
- if (isBuffered(BF_GRAVITY))
- return mBufferedData.gravity;
+ if(isBuffered(BF_GRAVITY))
+ return mBufferedData.mGravity;
else
return mScene.getGravity();
}
void Scb::Scene::setBounceThresholdVelocity(const PxReal t)
{
- if (!isPhysicsBuffering())
+ if(!isPhysicsBuffering())
{
mScene.setBounceThresholdVelocity(t);
updatePvdProperties();
}
else
{
- mBufferedData.bounceThresholdVelocity = t;
+ mBufferedData.mBounceThresholdVelocity = t;
markUpdated(BF_BOUNCETHRESHOLDVELOCITY);
}
}
PxReal Scb::Scene::getBounceThresholdVelocity() const
{
- if (isBuffered(BF_BOUNCETHRESHOLDVELOCITY))
- return mBufferedData.bounceThresholdVelocity;
+ if(isBuffered(BF_BOUNCETHRESHOLDVELOCITY))
+ return mBufferedData.mBounceThresholdVelocity;
else
return mScene.getBounceThresholdVelocity();
}
-PX_INLINE void Scb::Scene::setFrictionType(PxFrictionType::Enum frictionType)
-{
- mScene.setFrictionType(frictionType);
-}
-
-PX_INLINE PxFrictionType::Enum Scb::Scene::getFrictionType() const
-{
- return mScene.getFrictionType();
-}
-
-
PX_INLINE void Scb::Scene::setFlags(PxSceneFlags flags)
{
- if (!isPhysicsBuffering())
+ if(!isPhysicsBuffering())
{
mScene.setPublicFlags(flags);
const bool pcm = (flags & PxSceneFlag::eENABLE_PCM);
@@ -514,16 +500,15 @@ PX_INLINE void Scb::Scene::setFlags(PxSceneFlags flags)
}
else
{
- mBufferedData.flags = flags;
+ mBufferedData.mFlags = flags;
markUpdated(BF_FLAGS);
}
}
-
PX_INLINE PxSceneFlags Scb::Scene::getFlags() const
{
- if (isBuffered(BF_FLAGS))
- return mBufferedData.flags;
+ if(isBuffered(BF_FLAGS))
+ return mBufferedData.mFlags;
else
return mScene.getPublicFlags();
}
@@ -605,52 +590,26 @@ PX_INLINE void Scb::Scene::setFilterShaderData(const void* data, PxU32 dataSize)
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "PxScene::setFilterShaderData() not allowed while simulation is running. Call will be ignored.");
}
-
PX_INLINE const void* Scb::Scene::getFilterShaderData() const
{
return mScene.getFilterShaderDataFast();
}
-
PX_INLINE PxU32 Scb::Scene::getFilterShaderDataSize() const
{
return mScene.getFilterShaderDataSizeFast();
}
-
-PX_INLINE PxSimulationFilterShader Scb::Scene::getFilterShader() const
+PX_INLINE PxSimulationFilterShader Scb::Scene::getFilterShader() const
{
return mScene.getFilterShaderFast();
}
-
PX_INLINE PxSimulationFilterCallback* Scb::Scene::getFilterCallback() const
{
return mScene.getFilterCallbackFast();
}
-
-PX_INLINE void Scb::Scene::simulate(PxReal timeStep, PxBaseTask* continuation)
-{
- mScene.simulate(timeStep, continuation);
-}
-
-PX_INLINE void Scb::Scene::advance(PxReal timeStep, PxBaseTask* continuation)
-{
- mScene.advance(timeStep, continuation);
-}
-
-PX_INLINE void Scb::Scene::collide(PxReal timeStep, PxBaseTask* continuation)
-{
- mScene.collide(timeStep, continuation);
-}
-
-PX_INLINE void Scb::Scene::endSimulation()
-{
- mScene.endSimulation();
-}
-
-
PX_INLINE void Scb::Scene::flush(bool sendPendingReports)
{
PX_ASSERT(!isPhysicsBuffering());
@@ -664,27 +623,15 @@ PX_INLINE void Scb::Scene::flush(bool sendPendingReports)
mScene.flush(sendPendingReports);
}
-
PX_INLINE void Scb::Scene::postReportsCleanup()
{
PX_ASSERT(!isPhysicsBuffering());
mScene.postReportsCleanup();
}
-
-PX_INLINE const PxSceneLimits& Scb::Scene::getLimits() const
-{
- return mScene.getLimits();
-}
-
-PX_INLINE void Scb::Scene::setLimits(const PxSceneLimits& limits)
-{
- mScene.setLimits(limits);
-}
-
PX_INLINE void Scb::Scene::setDominanceGroupPair(PxDominanceGroup group1, PxDominanceGroup group2, const PxDominanceGroupPair& dominance)
{
- if (!isPhysicsBuffering())
+ if(!isPhysicsBuffering())
{
mScene.setDominanceGroupPair(group1, group2, dominance);
updatePvdProperties();
@@ -696,43 +643,40 @@ PX_INLINE void Scb::Scene::setDominanceGroupPair(PxDominanceGroup group1, PxDomi
}
}
-
PX_INLINE PxDominanceGroupPair Scb::Scene::getDominanceGroupPair(PxDominanceGroup group1, PxDominanceGroup group2) const
{
- if (isBuffered(BF_DOMINANCE_PAIRS))
+ if(isBuffered(BF_DOMINANCE_PAIRS))
{
PxDominanceGroupPair dominance(0, 0);
- if (mBufferedData.getDominancePair(group1, group2, dominance))
+ if(mBufferedData.getDominancePair(group1, group2, dominance))
return dominance;
}
return mScene.getDominanceGroupPair(group1, group2);
}
-
PX_INLINE void Scb::Scene::setSolverBatchSize(PxU32 solverBatchSize)
{
- if (!isPhysicsBuffering())
+ if(!isPhysicsBuffering())
{
mScene.setSolverBatchSize(solverBatchSize);
updatePvdProperties();
}
else
{
- mBufferedData.solverBatchSize = solverBatchSize;
+ mBufferedData.mSolverBatchSize = solverBatchSize;
markUpdated(BF_SOLVER_BATCH_SIZE);
}
}
PX_INLINE PxU32 Scb::Scene::getSolverBatchSize() const
{
- if (isBuffered(BF_SOLVER_BATCH_SIZE))
- return mBufferedData.solverBatchSize;
+ if(isBuffered(BF_SOLVER_BATCH_SIZE))
+ return mBufferedData.mSolverBatchSize;
else
return mScene.getSolverBatchSize();
}
-
PX_INLINE void Scb::Scene::getStats(PxSimulationStatistics& stats) const
{
PX_ASSERT(!isPhysicsBuffering());
@@ -740,7 +684,6 @@ PX_INLINE void Scb::Scene::getStats(PxSimulationStatistics& stats) const
mScene.getStats(stats);
}
-
PX_DEPRECATED PX_INLINE void Scb::Scene::buildActiveTransforms()
{
PX_ASSERT(!isPhysicsBuffering());
@@ -748,13 +691,10 @@ PX_DEPRECATED PX_INLINE void Scb::Scene::buildActiveTransforms()
mScene.buildActiveTransforms();
}
-
PX_DEPRECATED PX_INLINE PxActiveTransform* Scb::Scene::getActiveTransforms(PxU32& nbTransformsOut, PxClientID client)
{
- if (!isPhysicsBuffering())
- {
+ if(!isPhysicsBuffering())
return mScene.getActiveTransforms(nbTransformsOut, client);
- }
else
{
Ps::getFoundation().error(PxErrorCode::eDEBUG_WARNING, __FILE__, __LINE__, "PxScene::getActiveTransforms() not allowed while simulation is running. Call will be ignored.");
@@ -772,10 +712,8 @@ PX_INLINE void Scb::Scene::buildActiveActors()
PX_INLINE PxActor** Scb::Scene::getActiveActors(PxU32& nbActorsOut, PxClientID client)
{
- if (!isPhysicsBuffering())
- {
+ if(!isPhysicsBuffering())
return mScene.getActiveActors(nbActorsOut, client);
- }
else
{
Ps::getFoundation().error(PxErrorCode::eDEBUG_WARNING, __FILE__, __LINE__, "PxScene::getActiveActors() not allowed while simulation is running. Call will be ignored.");
@@ -784,44 +722,43 @@ PX_INLINE PxActor** Scb::Scene::getActiveActors(PxU32& nbActorsOut, PxClientID c
}
}
-
PX_INLINE PxClientID Scb::Scene::createClient()
{
- mBufferedData.clientBehaviorFlags.pushBack(PxClientBehaviorFlag_eNOT_BUFFERED); //PxClientBehaviorFlag_eNOT_BUFFERED means its not storing anything. Do this either way to make sure this buffer is big enough for behavior bit set/gets later.
+ mBufferedData.mClientBehaviorFlags.pushBack(PxClientBehaviorFlag_eNOT_BUFFERED); //PxClientBehaviorFlag_eNOT_BUFFERED means its not storing anything. Do this either way to make sure this buffer is big enough for behavior bit set/gets later.
- if (!isPhysicsBuffering())
+ if(!isPhysicsBuffering())
{
PxClientID i = mScene.createClient();
- PX_ASSERT(mBufferedData.clientBehaviorFlags.size()-1 == i);
+ PX_ASSERT(mBufferedData.mClientBehaviorFlags.size()-1 == i);
return i;
}
else
{
- mBufferedData.numClientsCreated++;
- return PxClientID(mBufferedData.clientBehaviorFlags.size()-1); //mScene.createClient();
+ mBufferedData.mNumClientsCreated++;
+ return PxClientID(mBufferedData.mClientBehaviorFlags.size()-1); //mScene.createClient();
}
}
PX_INLINE void Scb::Scene::setClientBehaviorFlags(PxClientID client, PxClientBehaviorFlags clientBehaviorFlags)
{
- if (!isPhysicsBuffering())
+ if(!isPhysicsBuffering())
{
mScene.setClientBehaviorFlags(client, clientBehaviorFlags);
updatePvdProperties();
}
else
{
- PX_ASSERT(mBufferedData.clientBehaviorFlags.size() > client);
- mBufferedData.clientBehaviorFlags[client] = clientBehaviorFlags;
+ PX_ASSERT(mBufferedData.mClientBehaviorFlags.size() > client);
+ mBufferedData.mClientBehaviorFlags[client] = clientBehaviorFlags;
markUpdated(BF_CLIENT_BEHAVIOR_FLAGS);
}
}
PX_INLINE PxClientBehaviorFlags Scb::Scene::getClientBehaviorFlags(PxClientID client) const
{
- PX_ASSERT(mBufferedData.clientBehaviorFlags.size() > client);
- if (isBuffered(BF_CLIENT_BEHAVIOR_FLAGS) && (mBufferedData.clientBehaviorFlags[client] != PxClientBehaviorFlag_eNOT_BUFFERED))
- return mBufferedData.clientBehaviorFlags[client];
+ PX_ASSERT(mBufferedData.mClientBehaviorFlags.size() > client);
+ if(isBuffered(BF_CLIENT_BEHAVIOR_FLAGS) && (mBufferedData.mClientBehaviorFlags[client] != PxClientBehaviorFlag_eNOT_BUFFERED))
+ return mBufferedData.mClientBehaviorFlags[client];
else
return mScene.getClientBehaviorFlags(client);
}
@@ -830,14 +767,10 @@ PX_INLINE PxClientBehaviorFlags Scb::Scene::getClientBehaviorFlags(PxClientID cl
PX_INLINE void Scb::Scene::setClothInterCollisionDistance(PxF32 distance)
{
- if (!isPhysicsBuffering())
- {
+ if(!isPhysicsBuffering())
mScene.setClothInterCollisionDistance(distance);
- }
else
- {
Ps::getFoundation().error(PxErrorCode::eDEBUG_WARNING, __FILE__, __LINE__, "PxScene::setClothInterCollisionDistance() not allowed while simulation is running. Call will be ignored.");
- }
}
PX_INLINE PxF32 Scb::Scene::getClothInterCollisionDistance() const
@@ -847,14 +780,10 @@ PX_INLINE PxF32 Scb::Scene::getClothInterCollisionDistance() const
PX_INLINE void Scb::Scene::setClothInterCollisionStiffness(PxF32 stiffness)
{
- if (!isPhysicsBuffering())
- {
+ if(!isPhysicsBuffering())
mScene.setClothInterCollisionStiffness(stiffness);
- }
else
- {
Ps::getFoundation().error(PxErrorCode::eDEBUG_WARNING, __FILE__, __LINE__, "PxScene::setClothInterCollisionStiffness() not allowed while simulation is running. Call will be ignored.");
- }
}
PX_INLINE PxF32 Scb::Scene::getClothInterCollisionStiffness() const
@@ -864,14 +793,10 @@ PX_INLINE PxF32 Scb::Scene::getClothInterCollisionStiffness() const
PX_INLINE void Scb::Scene::setClothInterCollisionNbIterations(PxU32 nbIterations)
{
- if (!isPhysicsBuffering())
- {
+ if(!isPhysicsBuffering())
mScene.setClothInterCollisionNbIterations(nbIterations);
- }
else
- {
Ps::getFoundation().error(PxErrorCode::eDEBUG_WARNING, __FILE__, __LINE__, "PxScene::setClothInterCollisionNbIterations() not allowed while simulation is running. Call will be ignored.");
- }
}
PX_INLINE PxU32 Scb::Scene::getClothInterCollisionNbIterations() const
@@ -881,16 +806,15 @@ PX_INLINE PxU32 Scb::Scene::getClothInterCollisionNbIterations() const
#endif
-
PX_INLINE void Scb::Scene::setVisualizationParameter(PxVisualizationParameter::Enum param, PxReal value)
{
- if (!isPhysicsBuffering())
+ if(!isPhysicsBuffering())
mScene.setVisualizationParameter(param, value);
else
{
PX_ASSERT(param < PxVisualizationParameter::eNUM_VALUES);
- mBufferedData.visualizationParamChanged[param] = 1;
- mBufferedData.visualizationParam[param] = value;
+ mBufferedData.mVisualizationParamChanged[param] = 1;
+ mBufferedData.mVisualizationParam[param] = value;
markUpdated(BF_VISUALIZATION);
}
}
@@ -899,41 +823,31 @@ PX_INLINE PxReal Scb::Scene::getVisualizationParameter(PxVisualizationParameter:
{
PX_ASSERT(param < PxVisualizationParameter::eNUM_VALUES);
- if (isBuffered(BF_VISUALIZATION) && mBufferedData.visualizationParamChanged[param])
- return mBufferedData.visualizationParam[param];
+ if(isBuffered(BF_VISUALIZATION) && mBufferedData.mVisualizationParamChanged[param])
+ return mBufferedData.mVisualizationParam[param];
else
return mScene.getVisualizationParameter(param);
}
PX_INLINE void Scb::Scene::setVisualizationCullingBox(const PxBounds3& box)
{
- if (!isPhysicsBuffering())
+ if(!isPhysicsBuffering())
mScene.setVisualizationCullingBox(box);
else
{
- mBufferedData.visualizationCullingBoxChanged = 1;
- mBufferedData.visualizationCullingBox = box;
- markUpdated(BF_VISUALIZATION);
+ mBufferedData.mVisualizationCullingBox = box;
+ markUpdated(BF_CULLING_BOX);
}
}
PX_INLINE const PxBounds3& Scb::Scene::getVisualizationCullingBox() const
{
- if (isBuffered(BF_VISUALIZATION) && mBufferedData.visualizationCullingBoxChanged)
- return mBufferedData.visualizationCullingBox;
+ if(isBuffered(BF_CULLING_BOX))
+ return mBufferedData.mVisualizationCullingBox;
else
return mScene.getVisualizationCullingBox();
}
-PX_INLINE PxU32 Scb::Scene::getNumActiveBodies() const
-{
- return mScene.getNumActiveBodies();
-}
-PX_INLINE Sc::BodyCore* const* Scb::Scene::getActiveBodiesArray() const
-{
- return mScene.getActiveBodiesArray();
-}
-
}
#endif
diff --git a/PhysX_3.4/Source/PhysX/src/buffering/ScbSceneBuffer.h b/PhysX_3.4/Source/PhysX/src/buffering/ScbSceneBuffer.h
index 61fea2af..b9b03a07 100644
--- a/PhysX_3.4/Source/PhysX/src/buffering/ScbSceneBuffer.h
+++ b/PhysX_3.4/Source/PhysX/src/buffering/ScbSceneBuffer.h
@@ -56,104 +56,98 @@ public:
PX_INLINE void clearVisualizationParams();
- PxReal visualizationParam[PxVisualizationParameter::eNUM_VALUES];
- PxU8 visualizationParamChanged[PxVisualizationParameter::eNUM_VALUES];
- PxBounds3 visualizationCullingBox;
- PxU8 visualizationCullingBoxChanged;
- PxU32 dominancePairFlag[sMaxNbDominanceGroups - 1];
- PxU32 dominancePairValues[sMaxNbDominanceGroups];
- PxVec3 gravity;
- PxReal bounceThresholdVelocity;
- PxSceneFlags flags;
- PxU32 solverBatchSize;
- PxU32 numClientsCreated;
- Ps::Array<PxClientBehaviorFlags> clientBehaviorFlags; //a value is buffered if it is not -1.
+ PxReal mVisualizationParam[PxVisualizationParameter::eNUM_VALUES];
+ PxU8 mVisualizationParamChanged[PxVisualizationParameter::eNUM_VALUES];
+ PxBounds3 mVisualizationCullingBox;
+private:
+ PxU32 mDominancePairFlag[sMaxNbDominanceGroups - 1];
+ PxU32 mDominancePairValues[sMaxNbDominanceGroups];
+public:
+ PxVec3 mGravity;
+ PxReal mBounceThresholdVelocity;
+ PxSceneFlags mFlags;
+ PxU32 mSolverBatchSize;
+ PxU32 mNumClientsCreated;
+ Ps::Array<PxClientBehaviorFlags> mClientBehaviorFlags; //a value is buffered if it is not -1.
};
-
-PX_INLINE SceneBuffer::SceneBuffer() : clientBehaviorFlags(PX_DEBUG_EXP("clientBehaviorFlags"))
+PX_INLINE SceneBuffer::SceneBuffer() :
+ mNumClientsCreated (0),
+ mClientBehaviorFlags(PX_DEBUG_EXP("clientBehaviorFlags"))
{
clearDominanceBuffer();
clearVisualizationParams();
- numClientsCreated = 0;
- clientBehaviorFlags.pushBack(PxClientBehaviorFlag_eNOT_BUFFERED); //need member for default client, PxClientBehaviorFlag_eNOT_BUFFERED means its not storing anything.
+ mClientBehaviorFlags.pushBack(PxClientBehaviorFlag_eNOT_BUFFERED); //need member for default client, PxClientBehaviorFlag_eNOT_BUFFERED means its not storing anything.
}
-
-PX_INLINE void SceneBuffer::clearDominanceBuffer()
+PX_FORCE_INLINE void SceneBuffer::clearDominanceBuffer()
{
- PxMemSet(&dominancePairFlag, 0, (sMaxNbDominanceGroups - 1) * sizeof(PxU32));
+ PxMemZero(&mDominancePairFlag, (sMaxNbDominanceGroups - 1) * sizeof(PxU32));
}
-
-PX_INLINE void SceneBuffer::clearVisualizationParams()
+PX_FORCE_INLINE void SceneBuffer::clearVisualizationParams()
{
- PxMemZero(visualizationParamChanged, PxVisualizationParameter::eNUM_VALUES * sizeof(PxU8));
+ PxMemZero(mVisualizationParamChanged, PxVisualizationParameter::eNUM_VALUES * sizeof(PxU8));
}
-
PX_INLINE void SceneBuffer::setDominancePair(PxU32 group1, PxU32 group2, const PxDominanceGroupPair& dominance)
{
PX_ASSERT(group1 != group2);
PX_ASSERT(group1 < sMaxNbDominanceGroups);
PX_ASSERT(group2 < sMaxNbDominanceGroups);
- if (group1 < group2)
- dominancePairFlag[group1] = dominancePairFlag[group1] | (1 << group2);
+ if(group1 < group2)
+ mDominancePairFlag[group1] |= (1 << group2);
else
- dominancePairFlag[group2] = dominancePairFlag[group2] | (1 << group1);
+ mDominancePairFlag[group2] |= (1 << group1);
- if (dominance.dominance0 != 0.0f)
- dominancePairValues[group1] = dominancePairValues[group1] | (1 << group2);
+ if(dominance.dominance0 != 0.0f)
+ mDominancePairValues[group1] |= (1 << group2);
else
- dominancePairValues[group1] = dominancePairValues[group1] & (~(1 << group2));
+ mDominancePairValues[group1] &= ~(1 << group2);
- if (dominance.dominance1 != 0.0f)
- dominancePairValues[group2] = dominancePairValues[group2] | (1 << group1);
+ if(dominance.dominance1 != 0.0f)
+ mDominancePairValues[group2] |= (1 << group1);
else
- dominancePairValues[group2] = dominancePairValues[group2] & (~(1 << group1));
+ mDominancePairValues[group2] &= ~(1 << group1);
}
-
PX_INLINE bool SceneBuffer::getDominancePair(PxU32 group1, PxU32 group2, PxDominanceGroupPair& dominance) const
{
PX_ASSERT(group1 != group2);
PX_ASSERT(group1 < sMaxNbDominanceGroups);
PX_ASSERT(group2 < sMaxNbDominanceGroups);
- PxU32 isBuffered = 0;
- if (group1 < group2)
- isBuffered = dominancePairFlag[group1] & (1 << group2);
+ PxU32 isBuffered;
+ if(group1 < group2)
+ isBuffered = mDominancePairFlag[group1] & (1 << group2);
else
- isBuffered = dominancePairFlag[group2] & (1 << group1);
+ isBuffered = mDominancePairFlag[group2] & (1 << group1);
- if (isBuffered)
- {
- dominance.dominance0 = PxU8((dominancePairValues[group1] & (1 << group2)) >> group2 );
- dominance.dominance1 = PxU8((dominancePairValues[group2] & (1 << group1)) >> group1 );
- return true;
- }
-
- return false;
-}
+ if(!isBuffered)
+ return false;
+ dominance.dominance0 = PxU8((mDominancePairValues[group1] & (1 << group2)) >> group2);
+ dominance.dominance1 = PxU8((mDominancePairValues[group2] & (1 << group1)) >> group1);
+ return true;
+}
PX_INLINE void SceneBuffer::syncDominancePairs(Sc::Scene& scene)
{
- for(PxU32 i=0; i < (sMaxNbDominanceGroups - 1); i++)
+ for(PxU32 i=0; i<(sMaxNbDominanceGroups - 1); i++)
{
- if (dominancePairFlag[i])
+ if(mDominancePairFlag[i])
{
- for(PxU32 j=(i+1); j < sMaxNbDominanceGroups; j++)
+ for(PxU32 j=(i+1); j<sMaxNbDominanceGroups; j++)
{
PxDominanceGroupPair dominance(0, 0);
- if (getDominancePair(i, j, dominance))
- {
+ if(getDominancePair(i, j, dominance))
scene.setDominanceGroupPair(PxDominanceGroup(i), PxDominanceGroup(j), dominance);
- }
}
}
}
+
+ clearDominanceBuffer();
}
diff --git a/PhysX_3.4/Source/PhysX/src/buffering/ScbScenePvdClient.cpp b/PhysX_3.4/Source/PhysX/src/buffering/ScbScenePvdClient.cpp
index 03161149..7a59c8aa 100644
--- a/PhysX_3.4/Source/PhysX/src/buffering/ScbScenePvdClient.cpp
+++ b/PhysX_3.4/Source/PhysX/src/buffering/ScbScenePvdClient.cpp
@@ -55,7 +55,6 @@ using namespace physx::Vd;
using namespace physx::pvdsdk;
using namespace Scb;
-
namespace
{
PX_FORCE_INLINE PxU64 getContextId(Scb::Scene& scene) { return scene.getContextId(); }
@@ -71,14 +70,12 @@ namespace
}
#if PX_USE_PARTICLE_SYSTEM_API
-
// Sc-to-Scb
PX_FORCE_INLINE static Scb::ParticleSystem* getScbParticleSystem(Sc::ParticleSystemCore* scParticleSystem)
{
const size_t offset = reinterpret_cast<size_t>(&(reinterpret_cast<Scb::ParticleSystem*>(0)->getScParticleSystem()));
return reinterpret_cast<Scb::ParticleSystem*>(reinterpret_cast<char*>(scParticleSystem) - offset);
}
-
#endif
///////////////////////////////////////////////////////////////////////////////
@@ -87,34 +84,21 @@ namespace
{
const PxActorType::Enum type = scbActor->getActorCore().getActorCoreType();
if(type == PxActorType::eRIGID_DYNAMIC)
- {
return getNpRigidDynamic(static_cast<const Scb::Body*>(scbActor));
- }
else if(type == PxActorType::eRIGID_STATIC)
- {
return getNpRigidStatic(static_cast<const Scb::RigidStatic*>(scbActor));
- }
#if PX_USE_PARTICLE_SYSTEM_API
else if(type == PxActorType::ePARTICLE_SYSTEM)
- {
return getNpParticleSystem(static_cast<const Scb::ParticleSystem*>(scbActor));
- }
else if(type == PxActorType::ePARTICLE_FLUID)
- {
return getNpParticleFluid(static_cast<const Scb::ParticleSystem*>(scbActor));
- }
#endif
else if(type == PxActorType::eARTICULATION_LINK)
- {
return getNpArticulationLink(static_cast<const Scb::Body*>(scbActor));
- }
#if PX_USE_CLOTH_API
else if(type == PxActorType::eCLOTH)
- {
return getNpCloth(const_cast<Scb::Cloth*>(static_cast<const Scb::Cloth*>(scbActor)));
- }
#endif
-
return NULL;
}
@@ -132,7 +116,7 @@ namespace
template <typename TDataType>
void operator()(const TDataType& dtype)
{
- mBinding.createInstance(mStream, dtype, mScene, mPvd);
+ mBinding.createInstance(mStream, dtype, mScene, PxGetPhysics(), mPvd);
}
void operator()(const PxArticulationLink&)
{
@@ -312,8 +296,13 @@ namespace
} // namespace
-ScbScenePvdClient::ScbScenePvdClient(Scb::Scene& scene)
- : mPvd(NULL), mScbScene(scene), mPvdDataStream(NULL), mUserRender(NULL), mRenderClient(NULL), mIsConnected(false)
+ScbScenePvdClient::ScbScenePvdClient(Scb::Scene& scene) :
+ mPvd (NULL),
+ mScbScene (scene),
+ mPvdDataStream (NULL),
+ mUserRender (NULL),
+ mRenderClient (NULL),
+ mIsConnected (false)
{
}
@@ -353,27 +342,6 @@ void ScbScenePvdClient::drawText(const PvdDebugText& text)
mUserRender->drawText(text);
}
-PvdUserRenderer* ScbScenePvdClient::getUserRender()
-{
- return mUserRender;
-}
-
-
-PsPvd* ScbScenePvdClient::getPsPvd()
-{
- return mPvd;
-}
-
-void ScbScenePvdClient::setPsPvd(PsPvd* pvd)
-{
- mPvd = pvd;
-}
-
-physx::pvdsdk::PvdClient* ScbScenePvdClient::getClientInternal()
-{
- return this;
-}
-
void ScbScenePvdClient::setScenePvdFlag(PxPvdSceneFlag::Enum flag, bool value)
{
if(value)
@@ -382,21 +350,6 @@ void ScbScenePvdClient::setScenePvdFlag(PxPvdSceneFlag::Enum flag, bool value)
mFlags &= ~flag;
}
-void ScbScenePvdClient::setScenePvdFlags(PxPvdSceneFlags flags)
-{
- mFlags = flags;
-}
-
-PxPvdSceneFlags ScbScenePvdClient::getScenePvdFlags() const
-{
- return mFlags;
-}
-
-bool ScbScenePvdClient::isConnected() const
-{
- return mIsConnected;
-}
-
void ScbScenePvdClient::onPvdConnected()
{
if(mIsConnected || !mPvd)
@@ -404,12 +357,12 @@ void ScbScenePvdClient::onPvdConnected()
mIsConnected = true;
-
mPvdDataStream = PvdDataStream::create(mPvd);
mUserRender = PvdUserRenderer::create();
mRenderClient = PX_NEW(SceneRendererClient)(mUserRender, mPvd);
mUserRender->setClient(mRenderClient);
+
sendEntireScene();
}
@@ -427,20 +380,6 @@ void ScbScenePvdClient::onPvdDisconnected()
mPvdDataStream = NULL;
}
-void ScbScenePvdClient::flush()
-{
-}
-
-PvdDataStream* ScbScenePvdClient::getDataStream()
-{
- return mPvdDataStream;
-}
-
-PvdMetaDataBinding* ScbScenePvdClient::getMetaDataBinding()
-{
- return &mMetaDataBinding;
-}
-
void ScbScenePvdClient::updatePvdProperties()
{
mMetaDataBinding.sendAllProperties(*mPvdDataStream, *mScbScene.getPxScene());
@@ -465,15 +404,15 @@ void ScbScenePvdClient::sendEntireScene()
if(npScene->getFlagsFast() & PxSceneFlag::eREQUIRE_RW_LOCK) // getFlagsFast() will trigger a warning of lock check
npScene->lockRead(__FILE__, __LINE__);
+ PxPhysics& physics = PxGetPhysics();
{
PxScene* theScene = mScbScene.getPxScene();
mPvdDataStream->createInstance(theScene);
updatePvdProperties();
- PxPhysics* physics = &PxGetPhysics();
// Create parent/child relationship.
- mPvdDataStream->setPropertyValue(theScene, "Physics", reinterpret_cast<const void*>(physics));
- mPvdDataStream->pushBackObjectRef(physics, "Scenes", theScene);
+ mPvdDataStream->setPropertyValue(theScene, "Physics", reinterpret_cast<const void*>(&physics));
+ mPvdDataStream->pushBackObjectRef(&physics, "Scenes", theScene);
}
// materials:
@@ -485,7 +424,7 @@ void ScbScenePvdClient::sendEntireScene()
{
const PxMaterial* theMaterial = mat->getNxMaterial();
if(mPvd->registerObject(theMaterial))
- mMetaDataBinding.createInstance(*mPvdDataStream, *theMaterial, PxGetPhysics());
+ mMetaDataBinding.createInstance(*mPvdDataStream, *theMaterial, physics);
};
}
@@ -504,9 +443,9 @@ void ScbScenePvdClient::sendEntireScene()
{
PxActor* pxActor = actorArray[i];
if(pxActor->is<PxRigidStatic>())
- mMetaDataBinding.createInstance(*mPvdDataStream, *static_cast<PxRigidStatic*>(pxActor), *npScene, mPvd);
+ mMetaDataBinding.createInstance(*mPvdDataStream, *static_cast<PxRigidStatic*>(pxActor), *npScene, physics, mPvd);
else
- mMetaDataBinding.createInstance(*mPvdDataStream, *static_cast<PxRigidDynamic*>(pxActor), *npScene, mPvd);
+ mMetaDataBinding.createInstance(*mPvdDataStream, *static_cast<PxRigidDynamic*>(pxActor), *npScene, physics, mPvd);
}
}
// articulations & links
@@ -516,7 +455,7 @@ void ScbScenePvdClient::sendEntireScene()
articulations.resize(numArticulations);
npScene->getArticulations(articulations.begin(), articulations.size());
for(PxU32 i = 0; i < numArticulations; i++)
- mMetaDataBinding.createInstance(*mPvdDataStream, *articulations[i], *npScene, mPvd);
+ mMetaDataBinding.createInstance(*mPvdDataStream, *articulations[i], *npScene, physics, mPvd);
}
#if PX_USE_PARTICLE_SYSTEM_API
@@ -633,7 +572,7 @@ void ScbScenePvdClient::updateKinematicTarget(const Scb::Body* body, const PxTra
void ScbScenePvdClient::createPvdInstance(const Scb::RigidStatic* rigidStatic)
{
if(checkPvdDebugFlag())
- mMetaDataBinding.createInstance(*mPvdDataStream, *getNpRigidStatic(rigidStatic), *mScbScene.getPxScene(), mPvd);
+ mMetaDataBinding.createInstance(*mPvdDataStream, *getNpRigidStatic(rigidStatic), *mScbScene.getPxScene(), PxGetPhysics(), mPvd);
}
void ScbScenePvdClient::updatePvdProperties(const Scb::RigidStatic* rigidStatic)
@@ -674,7 +613,7 @@ void ScbScenePvdClient::releasePvdInstance(const Scb::Constraint* constraint)
void ScbScenePvdClient::createPvdInstance(const Scb::Articulation* articulation)
{
if(checkPvdDebugFlag())
- mMetaDataBinding.createInstance(*mPvdDataStream, *getNpArticulation(articulation), *mScbScene.getPxScene(), mPvd);
+ mMetaDataBinding.createInstance(*mPvdDataStream, *getNpArticulation(articulation), *mScbScene.getPxScene(), PxGetPhysics(), mPvd);
}
void ScbScenePvdClient::updatePvdProperties(const Scb::Articulation* articulation)
@@ -739,17 +678,18 @@ void ScbScenePvdClient::createPvdInstance(const Scb::Shape* shape, PxActor& owne
{
PX_PROFILE_ZONE("PVD.createPVDInstance", getContextId(mScbScene));
const PxShape* npShape = getNpShape(shape);
- mMetaDataBinding.createInstance(*mPvdDataStream, *npShape, static_cast<PxRigidActor&>(owner), mPvd);
+ mMetaDataBinding.createInstance(*mPvdDataStream, *npShape, static_cast<PxRigidActor&>(owner), PxGetPhysics(), mPvd);
}
}
static void addShapesToPvd(PxU32 nbShapes, void* const* shapes, const size_t offset, PxActor& pxActor, PsPvd* pvd, PvdDataStream& stream, PvdMetaDataBinding& binding)
{
+ PxPhysics& physics = PxGetPhysics();
for(PxU32 i=0;i<nbShapes;i++)
{
const Scb::Shape* shape = reinterpret_cast<Scb::Shape*>(reinterpret_cast<char*>(shapes[i]) + offset);
const PxShape* npShape = getNpShape(shape);
- binding.createInstance(stream, *npShape, static_cast<PxRigidActor&>(pxActor), pvd);
+ binding.createInstance(stream, *npShape, static_cast<PxRigidActor&>(pxActor), physics, pvd);
}
}
@@ -988,12 +928,13 @@ void ScbScenePvdClient::frameEnd()
if(mPvd->getInstrumentationFlags() & PxPvdInstrumentationFlag::eDEBUG)
{
+ PX_PROFILE_ZONE("PVD.sceneUpdate", getContextId(mScbScene));
+
PvdVisualizer* vizualizer = NULL;
- const bool visualizeJoints = getScenePvdFlags() & PxPvdSceneFlag::eTRANSMIT_CONSTRAINTS;
+ const bool visualizeJoints = getScenePvdFlagsFast() & PxPvdSceneFlag::eTRANSMIT_CONSTRAINTS;
if(visualizeJoints)
vizualizer = this;
- PX_PROFILE_ZONE("PVD.sceneUpdate", getContextId(mScbScene));
mMetaDataBinding.updateDynamicActorsAndArticulations(*mPvdDataStream, theScene, vizualizer);
}
@@ -1052,7 +993,7 @@ static inline const PxCloth* toPx(const Scb::Cloth* cloth)
void ScbScenePvdClient::createPvdInstance(const Scb::Cloth* cloth)
{
if(checkPvdDebugFlag())
- mMetaDataBinding.createInstance(*mPvdDataStream, *getNpCloth(cloth), *mScbScene.getPxScene(), mPvd);
+ mMetaDataBinding.createInstance(*mPvdDataStream, *getNpCloth(cloth), *mScbScene.getPxScene(), PxGetPhysics(), mPvd);
}
void ScbScenePvdClient::sendSimpleProperties(const Scb::Cloth* cloth)
@@ -1128,46 +1069,44 @@ void ScbScenePvdClient::updateJoints()
{
if(checkPvdDebugFlag())
{
- const bool visualizeJoints = getScenePvdFlags() & PxPvdSceneFlag::eTRANSMIT_CONTACTS;
+ PX_PROFILE_ZONE("PVD.updateJoints", getContextId(mScbScene));
- // joints
- {
- PX_PROFILE_ZONE("PVD.updateJoints", getContextId(mScbScene));
- Sc::ConstraintCore*const * constraints = mScbScene.getScScene().getConstraints();
- PxU32 nbConstraints = mScbScene.getScScene().getNbConstraints();
- PxI64 constraintCount = 0;
+ const bool visualizeJoints = getScenePvdFlagsFast() & PxPvdSceneFlag::eTRANSMIT_CONSTRAINTS;
- for(PxU32 i = 0; i < nbConstraints; i++)
+ Sc::ConstraintCore*const * constraints = mScbScene.getScScene().getConstraints();
+ const PxU32 nbConstraints = mScbScene.getScScene().getNbConstraints();
+ PxI64 constraintCount = 0;
+
+ for(PxU32 i=0; i<nbConstraints; i++)
+ {
+ Sc::ConstraintCore* constraint = constraints[i];
+ PxPvdUpdateType::Enum updateType = getNpConstraint(constraint)->isDirty()
+ ? PxPvdUpdateType::UPDATE_ALL_PROPERTIES
+ : PxPvdUpdateType::UPDATE_SIM_PROPERTIES;
+ updateConstraint(*constraint, updateType);
+ PxConstraintConnector* conn = constraint->getPxConnector();
+ // visualization is updated here
{
- Sc::ConstraintCore* constraint = constraints[i];
- PxPvdUpdateType::Enum updateType = getNpConstraint(constraint)->isDirty()
- ? PxPvdUpdateType::UPDATE_ALL_PROPERTIES
- : PxPvdUpdateType::UPDATE_SIM_PROPERTIES;
- updateConstraint(*constraint, updateType);
- PxConstraintConnector* conn = constraint->getPxConnector();
- // visualization is updated here
+ PxU32 typeId = 0;
+ void* joint = NULL;
+ if(conn)
+ joint = conn->getExternalReference(typeId);
+ // visualize:
+ Sc::ConstraintSim* sim = constraint->getSim();
+ if(visualizeJoints && sim && sim->getConstantsLL() && joint && constraint->getVisualize())
{
- PxU32 typeId = 0;
- void* joint = NULL;
- if(conn)
- joint = conn->getExternalReference(typeId);
- // visualize:
- Sc::ConstraintSim* sim = constraint->getSim();
- if(visualizeJoints && sim && sim->getConstantsLL() && joint && constraint->getVisualize())
- {
- Sc::BodySim* b0 = sim->getBody(0);
- Sc::BodySim* b1 = sim->getBody(1);
- PxTransform t0 = b0 ? b0->getBody2World() : PxTransform(PxIdentity);
- PxTransform t1 = b1 ? b1->getBody2World() : PxTransform(PxIdentity);
- PvdConstraintVisualizer viz(joint, *mUserRender);
- (*constraint->getVisualize())(viz, sim->getConstantsLL(), t0, t1, 0xffffFFFF);
- }
+ Sc::BodySim* b0 = sim->getBody(0);
+ Sc::BodySim* b1 = sim->getBody(1);
+ PxTransform t0 = b0 ? b0->getBody2World() : PxTransform(PxIdentity);
+ PxTransform t1 = b1 ? b1->getBody2World() : PxTransform(PxIdentity);
+ PvdConstraintVisualizer viz(joint, *mUserRender);
+ (*constraint->getVisualize())(viz, sim->getConstantsLL(), t0, t1, 0xffffFFFF);
}
- ++constraintCount;
}
-
- mUserRender->flushRenderEvents();
+ ++constraintCount;
}
+
+ mUserRender->flushRenderEvents();
}
}
@@ -1176,16 +1115,16 @@ void ScbScenePvdClient::updateContacts()
if(!checkPvdDebugFlag())
return;
+ PX_PROFILE_ZONE("PVD.updateContacts", getContextId(mScbScene));
+
// if contacts are disabled, send empty array and return
const PxScene* theScene(mScbScene.getPxScene());
- if(!(getScenePvdFlags() & PxPvdSceneFlag::eTRANSMIT_CONTACTS))
+ if(!(getScenePvdFlagsFast() & PxPvdSceneFlag::eTRANSMIT_CONTACTS))
{
mMetaDataBinding.sendContacts(*mPvdDataStream, *theScene);
return;
}
- PX_PROFILE_ZONE("PVD.updateContacts", getContextId(mScbScene));
-
PxsContactManagerOutputIterator outputIter;
Sc::ContactIterator contactIter;
@@ -1202,11 +1141,9 @@ void ScbScenePvdClient::updateContacts()
mMetaDataBinding.sendContacts(*mPvdDataStream, *theScene, contacts);
}
-
void ScbScenePvdClient::updateSceneQueries()
{
- // if contacts are disabled, send empty array and return
- if(checkPvdDebugFlag() && (getScenePvdFlags() & PxPvdSceneFlag::eTRANSMIT_SCENEQUERIES))
+ if(checkPvdDebugFlag() && (getScenePvdFlagsFast() & PxPvdSceneFlag::eTRANSMIT_SCENEQUERIES))
mMetaDataBinding.sendSceneQueries(*mPvdDataStream, *mScbScene.getPxScene(), mPvd);
}
@@ -1230,9 +1167,16 @@ void ScbScenePvdClient::visualize(const PxRenderBuffer& debugRenderable)
{
if(mUserRender)
{
- mUserRender->drawRenderbuffer(reinterpret_cast<const PvdDebugPoint*>(debugRenderable.getPoints()), debugRenderable.getNbPoints(),
- reinterpret_cast<const PvdDebugLine*>(debugRenderable.getLines()), debugRenderable.getNbLines(),
- reinterpret_cast<const PvdDebugTriangle*>(debugRenderable.getTriangles()), debugRenderable.getNbTriangles());
+ // PT: I think the mUserRender object can contain extra data (including things coming from the user), because the various
+ // draw functions are exposed e.g. in PxPvdSceneClient.h. So I suppose we have to keep the render buffer around regardless
+ // of the connection flags. Thus I only skip the "drawRenderbuffer" call, for minimal intrusion into this file.
+ if(checkPvdDebugFlag())
+ {
+ mUserRender->drawRenderbuffer(
+ reinterpret_cast<const PvdDebugPoint*>(debugRenderable.getPoints()), debugRenderable.getNbPoints(),
+ reinterpret_cast<const PvdDebugLine*>(debugRenderable.getLines()), debugRenderable.getNbLines(),
+ reinterpret_cast<const PvdDebugTriangle*>(debugRenderable.getTriangles()), debugRenderable.getNbTriangles());
+ }
mUserRender->flushRenderEvents();
}
}
diff --git a/PhysX_3.4/Source/PhysX/src/buffering/ScbScenePvdClient.h b/PhysX_3.4/Source/PhysX/src/buffering/ScbScenePvdClient.h
index a7461571..92652efb 100644
--- a/PhysX_3.4/Source/PhysX/src/buffering/ScbScenePvdClient.h
+++ b/PhysX_3.4/Source/PhysX/src/buffering/ScbScenePvdClient.h
@@ -80,7 +80,6 @@ class ParticleSystemCore;
namespace Vd
{
-
class ScbScenePvdClient : public PxPvdSceneClient, public PvdClient, public PvdVisualizer
{
PX_NOCOPY(ScbScenePvdClient)
@@ -90,34 +89,34 @@ class ScbScenePvdClient : public PxPvdSceneClient, public PvdClient, public PvdV
// PxPvdSceneClient
virtual void setScenePvdFlag(PxPvdSceneFlag::Enum flag, bool value);
- virtual void setScenePvdFlags(PxPvdSceneFlags flags);
- virtual PxPvdSceneFlags getScenePvdFlags() const;
+ virtual void setScenePvdFlags(PxPvdSceneFlags flags) { mFlags = flags; }
+ virtual PxPvdSceneFlags getScenePvdFlags() const { return mFlags; }
virtual void updateCamera(const char* name, const PxVec3& origin, const PxVec3& up, const PxVec3& target);
virtual void drawPoints(const PvdDebugPoint* points, PxU32 count);
virtual void drawLines(const PvdDebugLine* lines, PxU32 count);
virtual void drawTriangles(const PvdDebugTriangle* triangles, PxU32 count);
virtual void drawText(const PvdDebugText& text);
- virtual PvdClient* getClientInternal();
+ virtual PvdClient* getClientInternal() { return this; }
//~PxPvdSceneClient
// pvdClient
- virtual PvdDataStream* getDataStream();
- virtual PvdMetaDataBinding* getMetaDataBinding();
- virtual PvdUserRenderer* getUserRender();
- virtual bool isConnected() const ;
+ virtual PvdDataStream* getDataStream() { return mPvdDataStream; }
+ virtual PvdMetaDataBinding* getMetaDataBinding() { return &mMetaDataBinding; }
+ virtual PvdUserRenderer* getUserRender() { return mUserRender; }
+ virtual bool isConnected() const { return mIsConnected; }
virtual void onPvdConnected();
virtual void onPvdDisconnected();
- virtual void flush();
+ virtual void flush() {}
//~pvdClient
- PsPvd* getPsPvd();
- void setPsPvd(PsPvd* pvd);
-
- PX_INLINE bool checkPvdDebugFlag()
+ PX_FORCE_INLINE bool checkPvdDebugFlag() const
{
return mIsConnected && (mPvd->getInstrumentationFlags() & PxPvdInstrumentationFlag::eDEBUG);
}
+ PX_FORCE_INLINE PxPvdSceneFlags getScenePvdFlagsFast() const { return mFlags; }
+ PX_FORCE_INLINE void setPsPvd(PsPvd* pvd) { mPvd = pvd; }
+
void frameStart(PxReal simulateElapsedTime);
void frameEnd();
diff --git a/PhysX_3.4/Source/PhysX/src/buffering/ScbShape.cpp b/PhysX_3.4/Source/PhysX/src/buffering/ScbShape.cpp
index 59f07169..9ae22ddb 100644
--- a/PhysX_3.4/Source/PhysX/src/buffering/ScbShape.cpp
+++ b/PhysX_3.4/Source/PhysX/src/buffering/ScbShape.cpp
@@ -27,7 +27,6 @@
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
-
#include "ScbShape.h"
using namespace physx;
@@ -36,7 +35,7 @@ bool Scb::Shape::setMaterialsHelper(PxMaterial* const* materials, PxU16 material
{
PX_ASSERT(!isBuffering());
- if (materialCount == 1)
+ if(materialCount == 1)
{
PxU16 materialIndex = Ps::to16((static_cast<NpMaterial*>(materials[0]))->getHandle());
@@ -48,7 +47,7 @@ bool Scb::Shape::setMaterialsHelper(PxMaterial* const* materials, PxU16 material
PX_ALLOCA(materialIndices, PxU16, materialCount);
- if (materialIndices)
+ if(materialIndices)
{
NpMaterial::getMaterialIndices(materials, materialIndices, materialCount);
mShape.setMaterialIndices(materialIndices, materialCount);
@@ -62,57 +61,51 @@ bool Scb::Shape::setMaterialsHelper(PxMaterial* const* materials, PxU16 material
}
Scb::Scene* sc = getScbScene();
-
- if (sc)
- {
+ if(sc)
sc->getScScene().notifyNphaseOnUpdateShapeMaterial(mShape);
- }
return true;
}
-
void Scb::Shape::syncState()
{
- PxU32 flags = getBufferFlags();
- if (flags)
+ const PxU32 flags = getBufferFlags();
+ if(flags)
{
-
- PxShapeFlags oldShapeFlags = mShape.getFlags();
+ const PxShapeFlags oldShapeFlags = mShape.getFlags();
const Scb::ShapeBuffer& buffer = *getBufferedData();
- if (flags & Buf::BF_Geometry)
- {
- Scb::Scene* sc = getScbScene();
+ Scb::Scene* scbScene = getScbScene(); // PT: can be NULL. See e.g. RbShapeTest.ReleaseShapeWithPendingUpdate UT.
- if (sc)
- {
- sc->getScScene().unregisterShapeFromNphase(mShape);
- }
+ if(flags & Buf::BF_Geometry)
+ {
+ if(scbScene)
+ scbScene->getScScene().unregisterShapeFromNphase(mShape);
mShape.setGeometry(buffer.geometry.getGeometry());
- if (sc)
- {
- sc->getScScene().registerShapeInNphase(mShape);
- }
+ if(scbScene)
+ scbScene->getScScene().registerShapeInNphase(mShape);
#if PX_SUPPORT_PVD
if(getControlState() == ControlState::eIN_SCENE)
{
- Scb::Scene* scbScene = getScbScene();
PX_ASSERT(scbScene);
scbScene->getScenePvdClient().releaseAndRecreateGeometry(this);
}
#endif
}
- if (flags & Buf::BF_Material)
+ if(flags & Buf::BF_Material)
{
- const PxU16* materialIndices = getMaterialBuffer(*getScbScene(), buffer);
- mShape.setMaterialIndices(materialIndices, buffer.materialCount);
- getScbScene()->getScScene().notifyNphaseOnUpdateShapeMaterial(mShape);
+ // PT: not sure if this is correct. Added the check for PX-800 but "getMaterialBuffer" doesn't always need the scene pointer...
+ if(scbScene)
+ {
+ const PxU16* materialIndices = getMaterialBuffer(*scbScene, buffer);
+ mShape.setMaterialIndices(materialIndices, buffer.materialCount);
+ scbScene->getScScene().notifyNphaseOnUpdateShapeMaterial(mShape);
+ }
UPDATE_PVD_MATERIALS()
// TODO: So far we did not bother to fail gracefully in the case of running out of memory. If that should change then this
// method is somewhat problematic. The material ref counters have been adjusted at the time when the public API was called.
@@ -127,19 +120,15 @@ void Scb::Shape::syncState()
flush<Buf::BF_SimulationFilterData>(buffer);
if(isBuffered(Buf::BF_ContactOffset))
- {
mShape.setContactOffset(buffer.mContactOffset);
- }
flush<Buf::BF_RestOffset>(buffer);
flush<Buf::BF_Flags>(buffer);
Sc::RigidCore* scRigidCore = NpShapeGetScRigidObjectFromScbSLOW(*this);
- if (scRigidCore) // may be NULL for exclusive shapes because of pending shape updates after buffered release of actor.
- {
+ if(scRigidCore) // may be NULL for exclusive shapes because of pending shape updates after buffered release of actor.
scRigidCore->onShapeChange(mShape, Sc::ShapeChangeNotifyFlags(flags), oldShapeFlags, true);
- }
}
postSyncState();
diff --git a/PhysX_3.4/Source/PhysX/src/buffering/ScbShape.h b/PhysX_3.4/Source/PhysX/src/buffering/ScbShape.h
index 697017bf..b4440dbe 100644
--- a/PhysX_3.4/Source/PhysX/src/buffering/ScbShape.h
+++ b/PhysX_3.4/Source/PhysX/src/buffering/ScbShape.h
@@ -27,7 +27,6 @@
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
-
#ifndef PX_PHYSICS_SCB_SHAPE
#define PX_PHYSICS_SCB_SHAPE
@@ -47,13 +46,10 @@
namespace physx
{
-
#if PX_SUPPORT_PVD
- #define UPDATE_PVD_MATERIALS() \
- if(getControlState() == ControlState::eIN_SCENE) \
- { \
- getScbScene()->getScenePvdClient().updateMaterials(this); \
- }
+ #define UPDATE_PVD_MATERIALS() \
+ if(getControlState() == ControlState::eIN_SCENE) \
+ getScbScene()->getScenePvdClient().updateMaterials(this);
#else
#define UPDATE_PVD_MATERIALS() {}
#endif
@@ -71,6 +67,8 @@ struct ShapeBuffer
ShapeBuffer() : materialBufferIndex(0), materialCount(0) {}
+ // PT: I think we start with "2" (instead of 0) because the two first bits are reserved
+ // below, for geometry & materials.
SCB_REGULAR_ATTRIBUTE_ALIGNED(2, PxTransform, Shape2Actor, 16)
SCB_REGULAR_ATTRIBUTE(3, PxFilterData, SimulationFilterData)
SCB_REGULAR_ATTRIBUTE(4, PxReal, ContactOffset)
@@ -86,12 +84,11 @@ struct ShapeBuffer
};
PxU16 materialCount;
- enum
+ enum
{
- BF_Geometry = 1<<0,
- BF_Material = 1<<1
+ BF_Geometry = 1<<0,
+ BF_Material = 1<<1
};
-
};
class Shape : public Base
@@ -135,7 +132,7 @@ public:
PX_INLINE void setSimulationFilterData(const PxFilterData& v) { write<Buf::BF_SimulationFilterData>(v); }
PX_INLINE PxReal getContactOffset() const { return read<Buf::BF_ContactOffset>(); }
- PX_INLINE void setContactOffset(PxReal v);
+ PX_INLINE void setContactOffset(PxReal v) { write<Buf::BF_ContactOffset>(v); }
PX_INLINE PxReal getRestOffset() const { return read<Buf::BF_RestOffset>(); }
PX_INLINE void setRestOffset(PxReal v) { write<Buf::BF_RestOffset>(v); }
@@ -143,13 +140,11 @@ public:
PX_INLINE PxShapeFlags getFlags() const { return read<Buf::BF_Flags>(); }
PX_INLINE void setFlags(PxShapeFlags v) { write<Buf::BF_Flags>(v); }
-
//---------------------------------------------------------------------------------
// Data synchronization
//---------------------------------------------------------------------------------
void syncState();
-
//---------------------------------------------------------------------------------
// Miscellaneous
//---------------------------------------------------------------------------------
@@ -158,15 +153,12 @@ public:
PX_FORCE_INLINE Sc::ShapeCore& getScShape() { return mShape; } // Only use if you know what you're doing!
PX_FORCE_INLINE const Sc::ShapeCore& getScShape() const { return mShape; }
- PX_FORCE_INLINE bool isExclusive() const { return getScbType() == ScbType::SHAPE_EXCLUSIVE; }
+ PX_FORCE_INLINE bool isExclusive() const { return getScbType() == ScbType::eSHAPE_EXCLUSIVE; }
PX_FORCE_INLINE void setControlStateIfExclusive(Scene* s, ControlState::Enum cs); // for exclusive shapes
template<bool sync> PX_FORCE_INLINE void checkUpdateOnRemove(Scene* s);
- static size_t getScOffset()
- {
- return reinterpret_cast<size_t>(&reinterpret_cast<Shape*>(0)->mShape);
- }
+ static size_t getScOffset() { return reinterpret_cast<size_t>(&reinterpret_cast<Shape*>(0)->mShape); }
private:
bool setMaterialsHelper(PxMaterial* const* materials, PxU16 materialCount);
@@ -176,10 +168,9 @@ private:
PX_FORCE_INLINE const Scb::ShapeBuffer* getBufferedData() const { return reinterpret_cast<const Scb::ShapeBuffer*>(getStream()); }
PX_FORCE_INLINE Scb::ShapeBuffer* getBufferedData() { return reinterpret_cast<Scb::ShapeBuffer*>(getStream()); }
-
PX_FORCE_INLINE const PxU16* getMaterialBuffer(const Scb::Scene& scene, const Scb::ShapeBuffer& sb) const
{
- if (sb.materialCount == 1)
+ if(sb.materialCount == 1)
return &sb.materialIndex;
else
return scene.getShapeMaterialBuffer(sb.materialBufferIndex);
@@ -194,7 +185,7 @@ private:
template<typename Fns>
static PX_FORCE_INLINE void write(Shape& base, Core& core, typename Fns::Arg v)
{
- if (!base.isBuffering())
+ if(!base.isBuffering())
{
PxShapeFlags oldShapeFlags = core.getFlags();
Fns::setCore(core, v);
@@ -214,16 +205,14 @@ private:
Fns::setBuffered(*reinterpret_cast<Buf*>(base.getStream()), v);
base.markUpdated(Fns::flag);
}
- }
-
+ }
};
+
template<PxU32 f> PX_FORCE_INLINE typename Buf::Fns<f,0>::Arg read() const { return Access::read<Buf::Fns<f,0> >(*this, mShape); }
template<PxU32 f> PX_FORCE_INLINE void write(typename Buf::Fns<f,0>::Arg v) { Access::write<Buf::Fns<f,0> >(*this, mShape, v); }
template<PxU32 f> PX_FORCE_INLINE void flush(const Buf& buf) { Access::flush<Buf::Fns<f,0> >(*this, mShape, buf); }
-
};
-
PX_INLINE Shape::Shape(const PxGeometry& geometry,
PxShapeFlags shapeFlags,
const PxU16* materialIndices,
@@ -242,13 +231,12 @@ PX_INLINE Shape::Shape(const PxGeometry& geometry,
PX_COMPILE_TIME_ASSERT(PxU32(ShapeBuffer::BF_Flags) == PxU32(Sc::ShapeChangeNotifyFlag::eFLAGS));
PX_COMPILE_TIME_ASSERT(PxU32(ShapeBuffer::BF_Geometry) == PxU32(Sc::ShapeChangeNotifyFlag::eGEOMETRY));
- if (isExclusive)
- setScbType(ScbType::SHAPE_EXCLUSIVE);
+ if(isExclusive)
+ setScbType(ScbType::eSHAPE_EXCLUSIVE);
else
- setScbType(ScbType::SHAPE_SHARED);
+ setScbType(ScbType::eSHAPE_SHARED);
}
-
PX_INLINE PxGeometryType::Enum Shape::getGeometryType() const
{
return mShape.getGeometryType();
@@ -256,7 +244,7 @@ PX_INLINE PxGeometryType::Enum Shape::getGeometryType() const
PX_INLINE const PxGeometry& Shape::getGeometry() const
{
- if (isBuffered(Buf::BF_Geometry))
+ if(isBuffered(Buf::BF_Geometry))
return getBufferedData()->geometry.getGeometry();
else
return mShape.getGeometry();
@@ -264,13 +252,12 @@ PX_INLINE const PxGeometry& Shape::getGeometry() const
PX_INLINE const Gu::GeometryUnion& Shape::getGeometryUnion() const
{
- if (isBuffered(Buf::BF_Geometry))
+ if(isBuffered(Buf::BF_Geometry))
return getBufferedData()->geometry;
else
return mShape.getGeometryUnion();
}
-
PX_INLINE Scb::ShapeBuffer* Shape::setGeometry(const PxGeometry& geom)
{
Scb::ShapeBuffer* shapeBuffer = NULL;
@@ -278,17 +265,13 @@ PX_INLINE Scb::ShapeBuffer* Shape::setGeometry(const PxGeometry& geom)
{
Scb::Scene* sc = getScbScene();
- if (sc)
- {
+ if(sc)
sc->getScScene().unregisterShapeFromNphase(mShape);
- }
mShape.setGeometry(geom);
- if (sc)
- {
+ if(sc)
sc->getScScene().registerShapeInNphase(mShape);
- }
Sc::RigidCore* rigidCore = NpShapeGetScRigidObjectFromScbSLOW(*this);
if(rigidCore)
@@ -297,9 +280,7 @@ PX_INLINE Scb::ShapeBuffer* Shape::setGeometry(const PxGeometry& geom)
#if PX_SUPPORT_PVD
Scb::Scene* scbScene = getScbSceneForAPI();
if(scbScene)
- {
- scbScene->getScenePvdClient().releaseAndRecreateGeometry( this );
- }
+ scbScene->getScenePvdClient().releaseAndRecreateGeometry(this);
#endif
}
else
@@ -312,22 +293,20 @@ PX_INLINE Scb::ShapeBuffer* Shape::setGeometry(const PxGeometry& geom)
return shapeBuffer;
}
-
PX_INLINE PxU16 Shape::getNbMaterials() const
{
- if (isBuffered(Buf::BF_Material))
+ if(isBuffered(Buf::BF_Material))
return getBufferedData()->materialCount;
else
return mShape.getNbMaterialIndices();
}
-
PX_INLINE PxMaterial* Shape::getMaterial(PxU32 index) const
{
PX_ASSERT(index < getNbMaterials());
NpMaterialManager& matManager = NpPhysics::getInstance().getMaterialManager();
- if (isBuffered(Buf::BF_Material))
+ if(isBuffered(Buf::BF_Material))
{
const PxU16* materialIndices = getMaterialBuffer(*getScbScene(), *getBufferedData());
return matManager.getMaterial(materialIndices[index]);
@@ -339,13 +318,12 @@ PX_INLINE PxMaterial* Shape::getMaterial(PxU32 index) const
}
}
-
PX_INLINE PxU32 Shape::getMaterials(PxMaterial** buffer, PxU32 bufferSize, PxU32 startIndex) const
{
const PxU16* materialIndices;
PxU32 matCount;
NpMaterialManager& matManager = NpPhysics::getInstance().getMaterialManager();
- if (isBuffered(Buf::BF_Material))
+ if(isBuffered(Buf::BF_Material))
{
// IMPORTANT:
// As long as the material pointers get copied to a user buffer, this works fine.
@@ -375,10 +353,9 @@ PX_INLINE PxU32 Shape::getMaterials(PxMaterial** buffer, PxU32 bufferSize, PxU32
return writeCount;
}
-
PX_INLINE bool Shape::setMaterials(PxMaterial* const* materials, PxU16 materialCount)
{
- if (!isBuffering())
+ if(!isBuffering())
{
bool ret = setMaterialsHelper(materials, materialCount);
UPDATE_PVD_MATERIALS()
@@ -389,7 +366,7 @@ PX_INLINE bool Shape::setMaterials(PxMaterial* const* materials, PxU16 materialC
Scb::ShapeBuffer* PX_RESTRICT bufferedData = getBufferedData();
PxU16* materialIndices;
- if (materialCount == 1)
+ if(materialCount == 1)
materialIndices = &bufferedData->materialIndex;
else
{
@@ -407,44 +384,31 @@ PX_INLINE bool Shape::setMaterials(PxMaterial* const* materials, PxU16 materialC
}
}
-PX_INLINE void Shape::setContactOffset(PxReal v)
-{
- write<Buf::BF_ContactOffset>(v);
-}
-
-
PX_FORCE_INLINE void Shape::setControlStateIfExclusive(Scene* s, ControlState::Enum cs)
{
- if (isExclusive())
+ if(isExclusive())
{
setControlState(cs);
setScbScene(s);
}
}
-
template<bool sync>
PX_FORCE_INLINE void Shape::checkUpdateOnRemove(Scene* s)
{
// special code to cover the case where a shape has a pending update and gets released. The following operations have to be done
// before the ref-counter of the shape gets decremented because that could cause the shape to be deleted in which case it must not
// be in the pending update list any longer.
- if (getControlFlags() & Scb::ControlFlag::eIS_UPDATED)
+ if(getControlFlags() & Scb::ControlFlag::eIS_UPDATED)
{
- if (sync)
+ if(sync)
syncState();
s->removeShapeFromPendingUpdateList(*this);
+
+ resetControlFlag(ControlFlag::eIS_UPDATED);
}
}
-
-//--------------------------------------------------------------
-//
-// Data synchronization
-//
-//--------------------------------------------------------------
-
-
} // namespace Scb
}
diff --git a/PhysX_3.4/Source/PhysX/src/buffering/ScbType.h b/PhysX_3.4/Source/PhysX/src/buffering/ScbType.h
index b1725661..55fc5c97 100644
--- a/PhysX_3.4/Source/PhysX/src/buffering/ScbType.h
+++ b/PhysX_3.4/Source/PhysX/src/buffering/ScbType.h
@@ -27,7 +27,6 @@
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
-
#ifndef PX_PHYSICS_SCB_TYPE
#define PX_PHYSICS_SCB_TYPE
@@ -37,23 +36,23 @@ namespace physx
{
enum Enum
{
- UNDEFINED,
- SHAPE_EXCLUSIVE,
- SHAPE_SHARED,
- BODY,
- BODY_FROM_ARTICULATION_LINK,
- RIGID_STATIC,
- CONSTRAINT,
+ eUNDEFINED,
+ eSHAPE_EXCLUSIVE,
+ eSHAPE_SHARED,
+ eBODY,
+ eBODY_FROM_ARTICULATION_LINK,
+ eRIGID_STATIC,
+ eCONSTRAINT,
#if PX_USE_PARTICLE_SYSTEM_API
- PARTICLE_SYSTEM,
+ ePARTICLE_SYSTEM,
#endif
- ARTICULATION,
- ARTICULATION_JOINT,
- AGGREGATE,
+ eARTICULATION,
+ eARTICULATION_JOINT,
+ eAGGREGATE,
#if PX_USE_CLOTH_API
- CLOTH,
+ eCLOTH,
#endif
- TYPE_COUNT
+ eTYPE_COUNT
};
};
}
diff --git a/PhysX_3.4/Source/PhysX/src/gpu/PxPhysXGpuModuleLoader.cpp b/PhysX_3.4/Source/PhysX/src/gpu/PxPhysXGpuModuleLoader.cpp
index 1d5f7388..2664c6f5 100644
--- a/PhysX_3.4/Source/PhysX/src/gpu/PxPhysXGpuModuleLoader.cpp
+++ b/PhysX_3.4/Source/PhysX/src/gpu/PxPhysXGpuModuleLoader.cpp
@@ -32,6 +32,7 @@
#include "foundation/Px.h"
#include "PsFoundation.h"
#include "PxPhysics.h"
+#include "PxGpu.h"
#include "cudamanager/PxCudaContextManager.h"
@@ -66,6 +67,29 @@ static const char* gPhysXGpuLibraryName = "./libPhysX3Gpu" CONFIG_SUB_STR "_" PL
#undef GETSTRING
#undef STRINGIFY
+void PxSetPhysXGpuLoadHook(const PxGpuLoadHook* hook)
+{
+ if(strstr(gPhysXGpuLibraryName, "DEBUG"))
+ {
+ gPhysXGpuLibraryName = hook->getPhysXGpuDEBUGDllName();
+ return;
+ }
+
+ if(strstr(gPhysXGpuLibraryName, "CHECKED"))
+ {
+ gPhysXGpuLibraryName = hook->getPhysXGpuCHECKEDDllName();
+ return;
+ }
+
+ if(strstr(gPhysXGpuLibraryName, "PROFILE"))
+ {
+ gPhysXGpuLibraryName = hook->getPhysXGpuPROFILEDllName();
+ return;
+ }
+
+ gPhysXGpuLibraryName = hook->getPhysXGpuDllName();
+}
+
namespace physx
{
#if PX_VC