aboutsummaryrefslogtreecommitdiff
path: root/PhysX_3.4/Source/PhysX/src
diff options
context:
space:
mode:
authorSheikh Dawood Abdul Ajees <[email protected]>2017-09-15 15:41:57 -0500
committerSheikh Dawood Abdul Ajees <[email protected]>2017-09-15 15:41:57 -0500
commitd1c812f1162e5fdb13c215792725b2591d7428f5 (patch)
tree407056c45c7e9320c48fca6a3697d81a061c4ea0 /PhysX_3.4/Source/PhysX/src
parentPhysX 3.4, APEX 1.4 patch release @22121272 (diff)
downloadphysx-3.4-d1c812f1162e5fdb13c215792725b2591d7428f5.tar.xz
physx-3.4-d1c812f1162e5fdb13c215792725b2591d7428f5.zip
PhysX 3.4.1, APEX 1.4.1 Release @22845541v3.4.1
Diffstat (limited to 'PhysX_3.4/Source/PhysX/src')
-rw-r--r--PhysX_3.4/Source/PhysX/src/NpPhysics.cpp6
-rw-r--r--PhysX_3.4/Source/PhysX/src/NpRigidActorTemplate.h6
-rw-r--r--PhysX_3.4/Source/PhysX/src/NpScene.cpp17
-rw-r--r--PhysX_3.4/Source/PhysX/src/NpShapeManager.cpp60
-rw-r--r--PhysX_3.4/Source/PhysX/src/NpShapeManager.h3
-rw-r--r--PhysX_3.4/Source/PhysX/src/buffering/ScbArticulation.h4
-rw-r--r--PhysX_3.4/Source/PhysX/src/buffering/ScbBody.h2
-rw-r--r--PhysX_3.4/Source/PhysX/src/gpu/PxPhysXGpuModuleLoader.cpp9
8 files changed, 48 insertions, 59 deletions
diff --git a/PhysX_3.4/Source/PhysX/src/NpPhysics.cpp b/PhysX_3.4/Source/PhysX/src/NpPhysics.cpp
index 57f7feeb..606f55b6 100644
--- a/PhysX_3.4/Source/PhysX/src/NpPhysics.cpp
+++ b/PhysX_3.4/Source/PhysX/src/NpPhysics.cpp
@@ -73,8 +73,8 @@
#include "NpCloth.h"
#endif
-#if PX_NX
-#include "nx/NpMiddlewareInfo.h"
+#if PX_SWITCH
+#include "switch/NpMiddlewareInfo.h"
#endif
using namespace physx;
@@ -233,7 +233,7 @@ NpPhysics* NpPhysics::createInstance(PxU32 version, PxFoundation& foundation, co
{
PX_UNUSED(foundation);
-#if PX_NX
+#if PX_SWITCH
NpSetMiddlewareInfo(); // register middleware info such that PhysX usage can be tracked
#endif
diff --git a/PhysX_3.4/Source/PhysX/src/NpRigidActorTemplate.h b/PhysX_3.4/Source/PhysX/src/NpRigidActorTemplate.h
index e7bef5c6..855409a1 100644
--- a/PhysX_3.4/Source/PhysX/src/NpRigidActorTemplate.h
+++ b/PhysX_3.4/Source/PhysX/src/NpRigidActorTemplate.h
@@ -233,14 +233,16 @@ template<class APIClass>
void NpRigidActorTemplate<APIClass>::detachShape(PxShape& shape, bool wakeOnLostTouch)
{
NP_WRITE_CHECK(NpActor::getOwnerScene(*this));
- PX_CHECK_AND_RETURN(mShapeManager.shapeIsAttached(static_cast<NpShape&>(shape)), "PxRigidActor::detachShape: shape is not attached!")
if (mShapeManager.getPruningStructure())
{
Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "PxRigidActor::detachShape: Actor is part of a pruning structure, pruning structure is now invalid!");
mShapeManager.getPruningStructure()->invalidate(this);
}
- mShapeManager.detachShape(static_cast<NpShape&>(shape), *this, wakeOnLostTouch);
+ if(!mShapeManager.detachShape(static_cast<NpShape&>(shape), *this, wakeOnLostTouch))
+ {
+ Ps::getFoundation().error(PxErrorCode::eINVALID_OPERATION, __FILE__, __LINE__, "PxRigidActor::detachShape: shape is not attached to this actor!");
+ }
}
diff --git a/PhysX_3.4/Source/PhysX/src/NpScene.cpp b/PhysX_3.4/Source/PhysX/src/NpScene.cpp
index 783436da..2afb7e08 100644
--- a/PhysX_3.4/Source/PhysX/src/NpScene.cpp
+++ b/PhysX_3.4/Source/PhysX/src/NpScene.cpp
@@ -136,6 +136,7 @@ NpScene::NpScene(const PxSceneDesc& desc) :
mHasSimulatedOnce (false),
mBetweenFetchResults (false)
{
+
mSceneExecution.setObject(this);
mSceneCollide.setObject(this);
mSceneAdvance.setObject(this);
@@ -143,6 +144,10 @@ NpScene::NpScene(const PxSceneDesc& desc) :
mTaskManager = mScene.getScScene().getTaskManagerPtr();
mThreadReadWriteDepth = Ps::TlsAlloc();
+#if PX_SUPPORT_GPU_PHYSX
+ updatePhysXIndicator();
+#endif
+
}
NpSceneQueries::~NpSceneQueries()
@@ -1555,6 +1560,16 @@ void NpScene::visualize()
}
}
+ if(getVisualizationParameter(PxVisualizationParameter::eCULL_BOX)!=0.0f)
+ {
+ const PxBounds3& cullbox = getScene().getVisualizationCullingBox();
+ if(!cullbox.isEmpty())
+ {
+ out << PxU32(PxDebugColor::eARGB_YELLOW);
+ out << Cm::DebugBox(cullbox);
+ }
+ }
+
#if PX_SUPPORT_PVD
mScene.getScenePvdClient().visualize(mRenderBuffer);
#endif
@@ -2625,7 +2640,7 @@ void NpScene::removeCloth(NpCloth& cloth)
void NpScene::updatePhysXIndicator()
{
- Ps::IntBool isGpu = 0;
+ Ps::IntBool isGpu = mScene.getScScene().isUsingGpuRigidBodies();
#if PX_USE_PARTICLE_SYSTEM_API
PxParticleBase*const* particleBaseList = mPxParticleBaseSet.getEntries();
diff --git a/PhysX_3.4/Source/PhysX/src/NpShapeManager.cpp b/PhysX_3.4/Source/PhysX/src/NpShapeManager.cpp
index e93883fa..d7a904e5 100644
--- a/PhysX_3.4/Source/PhysX/src/NpShapeManager.cpp
+++ b/PhysX_3.4/Source/PhysX/src/NpShapeManager.cpp
@@ -103,32 +103,26 @@ void NpShapeManager::attachShape(NpShape& shape, PxRigidActor& actor)
shape.onActorAttach(actor);
}
-void NpShapeManager::detachShape(NpShape& s, PxRigidActor& actor, bool wakeOnLostTouch)
+bool NpShapeManager::detachShape(NpShape& s, PxRigidActor& actor, bool wakeOnLostTouch)
{
PX_ASSERT(!mPruningStructure);
- PtrTableStorageManager& sm = NpFactory::getInstance().getPtrTableStorageManager();
-
const PxU32 index = mShapes.find(&s);
- PX_ASSERT(index!=0xffffffff);
-
- Scb::RigidObject& ro = static_cast<Scb::RigidObject&>(NpActor::getScbFromPxActor(actor));
+ if(index==0xffffffff)
+ return false;
NpScene* scene = NpActor::getAPIScene(actor);
if(scene && isSceneQuery(s))
scene->getSceneQueryManagerFast().removePrunerShape(getPrunerData(index));
- Scb::Shape& scbShape = s.getScbShape();
- ro.onShapeDetach(scbShape, wakeOnLostTouch, (s.getRefCount() == 1));
+ Scb::RigidObject& ro = static_cast<Scb::RigidObject&>(NpActor::getScbFromPxActor(actor));
+ ro.onShapeDetach(s.getScbShape(), wakeOnLostTouch, (s.getRefCount() == 1));
+ PtrTableStorageManager& sm = NpFactory::getInstance().getPtrTableStorageManager();
mShapes.replaceWithLast(index, sm);
mSceneQueryData.replaceWithLast(index, sm);
s.onActorDetach();
-}
-
-bool NpShapeManager::shapeIsAttached(NpShape& s) const
-{
- return mShapes.find(&s)!=0xffffffff;
+ return true;
}
void NpShapeManager::detachAll(NpScene* scene)
@@ -291,24 +285,6 @@ void NpShapeManager::teardownSceneQuery(SceneQueryManager& sqManager, PxU32 inde
#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)
@@ -528,7 +504,7 @@ static void visualizeTriangleMesh(const PxTriangleMeshGeometry& geometry, Render
{
if(visualizeShapes)
{
- PxU32 scolor = gCollisionShapeColor;
+ const PxU32 scolor = gCollisionShapeColor;
out << midt << scolor; // PT: no need to output this for each segment!
@@ -542,11 +518,6 @@ static void visualizeTriangleMesh(const PxTriangleMeshGeometry& geometry, Render
{
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;
}
@@ -569,8 +540,7 @@ static void visualizeHeightField(const PxHeightFieldGeometry& hfGeometry, Render
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 PxU32 scolor = gCollisionShapeColor;
const PxMat44 midt = PxMat44(PxIdentity);
HeightFieldUtil hfUtil(hfGeometry);
@@ -603,10 +573,6 @@ static void visualizeHeightField(const PxHeightFieldGeometry& hfGeometry, Render
//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;
}
@@ -623,15 +589,13 @@ static void visualizeHeightField(const PxHeightFieldGeometry& hfGeometry, Render
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]);
+ outputTriangle(segments, tmpVerts[vi0], tmpVerts[vi1], tmpVerts[vi2], scolor);
}
}
PX_FREE(tmpVerts);
@@ -686,17 +650,17 @@ void NpShapeManager::visualize(RenderOutput& out, NpScene* scene, const PxRigidA
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 PxBounds3& cullbox = scene->getScene().getVisualizationCullingBox();
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 useCullBox = !cullbox.isEmpty();
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();
diff --git a/PhysX_3.4/Source/PhysX/src/NpShapeManager.h b/PhysX_3.4/Source/PhysX/src/NpShapeManager.h
index f777f105..be12bf05 100644
--- a/PhysX_3.4/Source/PhysX/src/NpShapeManager.h
+++ b/PhysX_3.4/Source/PhysX/src/NpShapeManager.h
@@ -73,8 +73,7 @@ public:
PxU32 getShapes(PxShape** buffer, PxU32 bufferSize, PxU32 startIndex=0) const;
void attachShape(NpShape& shape, PxRigidActor& actor);
- void detachShape(NpShape& s, PxRigidActor &actor, bool wakeOnLostTouch);
- bool shapeIsAttached(NpShape& s) const;
+ bool detachShape(NpShape& s, PxRigidActor &actor, bool wakeOnLostTouch);
void detachAll(NpScene *scene);
void teardownSceneQuery(Sq::SceneQueryManager& sqManager, const NpShape& shape);
diff --git a/PhysX_3.4/Source/PhysX/src/buffering/ScbArticulation.h b/PhysX_3.4/Source/PhysX/src/buffering/ScbArticulation.h
index 702b9b18..75465694 100644
--- a/PhysX_3.4/Source/PhysX/src/buffering/ScbArticulation.h
+++ b/PhysX_3.4/Source/PhysX/src/buffering/ScbArticulation.h
@@ -105,8 +105,8 @@ public:
PX_INLINE PxReal getSleepThreshold() const { return read<Buf::BF_SleepThreshold>(); }
PX_INLINE void setSleepThreshold(const PxReal v) { write<Buf::BF_SleepThreshold>(v); }
- PX_INLINE PxReal getFreezeThreshold() const { return read<Buf::BF_SleepThreshold>(); }
- PX_INLINE void setFreezeThreshold(const PxReal v) { write<Buf::BF_SleepThreshold>(v); }
+ PX_INLINE PxReal getFreezeThreshold() const { return read<Buf::BF_FreezeThreshold>(); }
+ PX_INLINE void setFreezeThreshold(const PxReal v) { write<Buf::BF_FreezeThreshold>(v); }
PX_INLINE PxReal getWakeCounter() const { return mBufferedWakeCounter; }
PX_INLINE void setWakeCounter(const PxReal v);
diff --git a/PhysX_3.4/Source/PhysX/src/buffering/ScbBody.h b/PhysX_3.4/Source/PhysX/src/buffering/ScbBody.h
index ba8325da..e38961b4 100644
--- a/PhysX_3.4/Source/PhysX/src/buffering/ScbBody.h
+++ b/PhysX_3.4/Source/PhysX/src/buffering/ScbBody.h
@@ -577,7 +577,7 @@ PX_INLINE bool Body::getKinematicTarget(PxTransform& p) const
p = getBodyBuffer()->mKinematicTarget;
return true;
}
- else if(getControlState() != ControlState::eREMOVE_PENDING)
+ else if(getControlState() != ControlState::eREMOVE_PENDING && (mBodyCore.getFlags() & PxRigidBodyFlag::eKINEMATIC))
return mBodyCore.getKinematicTarget(p);
else
return false;
diff --git a/PhysX_3.4/Source/PhysX/src/gpu/PxPhysXGpuModuleLoader.cpp b/PhysX_3.4/Source/PhysX/src/gpu/PxPhysXGpuModuleLoader.cpp
index fe44e8bf..88d0d516 100644
--- a/PhysX_3.4/Source/PhysX/src/gpu/PxPhysXGpuModuleLoader.cpp
+++ b/PhysX_3.4/Source/PhysX/src/gpu/PxPhysXGpuModuleLoader.cpp
@@ -35,6 +35,9 @@
#include "PxGpu.h"
#include "cudamanager/PxCudaContextManager.h"
+#if PX_WINDOWS
+#include "../../../Common/src/CmPhysXCommon.h"
+#endif
#define STRINGIFY(x) #x
#define GETSTRING(x) STRINGIFY(x)
@@ -130,6 +133,12 @@ namespace physx
g_PxCreateCudaContextManager_Func = (PxCreateCudaContextManager_FUNC*)GetProcAddress(s_library, "PxCreateCudaContextManager");
g_PxGetSuggestedCudaDeviceOrdinal_Func = (PxGetSuggestedCudaDeviceOrdinal_FUNC*)GetProcAddress(s_library, "PxGetSuggestedCudaDeviceOrdinal");
}
+
+ // Check for errors
+ if (s_library == NULL)
+ Ps::getFoundation().error(PxErrorCode::eINTERNAL_ERROR, __FILE__, __LINE__, "Failed to load PhysXGpu dll!");
+ if (g_PxCreatePhysXGpu_Func == NULL || g_PxCreateCudaContextManager_Func == NULL || g_PxGetSuggestedCudaDeviceOrdinal_Func == NULL)
+ Ps::getFoundation().error(PxErrorCode::eINTERNAL_ERROR, __FILE__, __LINE__, "PhysXGpu dll is incompatible with this version of PhysX!");
}
#elif PX_LINUX