aboutsummaryrefslogtreecommitdiff
path: root/PhysX_3.4/Source/GeomUtils/src
diff options
context:
space:
mode:
Diffstat (limited to 'PhysX_3.4/Source/GeomUtils/src')
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/GuBox.cpp14
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/GuDebug.cpp264
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/GuGeometryUnion.h10
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/contact/GuContactMethodImpl.h2
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/convex/GuConvexMesh.cpp38
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/convex/GuConvexMesh.h17
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/hf/GuHeightField.h32
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/hf/GuHeightFieldUtil.cpp84
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4Build.cpp3
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_Slabs.h11
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_Slabs_KajiyaNoOrder.h2
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_Slabs_KajiyaOrdered.h2
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/mesh/GuBVConstants.h (renamed from PhysX_3.4/Source/GeomUtils/src/GuDebug.h)38
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/mesh/GuRTreeQueries.cpp10
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/mesh/GuTriangleMesh.cpp229
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/mesh/GuTriangleMesh.h13
16 files changed, 111 insertions, 658 deletions
diff --git a/PhysX_3.4/Source/GeomUtils/src/GuBox.cpp b/PhysX_3.4/Source/GeomUtils/src/GuBox.cpp
index 5b91d443..f75b9158 100644
--- a/PhysX_3.4/Source/GeomUtils/src/GuBox.cpp
+++ b/PhysX_3.4/Source/GeomUtils/src/GuBox.cpp
@@ -42,17 +42,21 @@ void Gu::Box::create(const Gu::Capsule& capsule)
// Box center = center of the two LSS's endpoints
center = capsule.computeCenter();
- PxVec3 dir = capsule.p1 - capsule.p0;
+ // Box orientation
+ const PxVec3 dir = capsule.p1 - capsule.p0;
const float d = dir.magnitude();
- rot.column0 = dir / d;
+ if(d!=0.0f)
+ {
+ rot.column0 = dir / d;
+ Ps::computeBasis(rot.column0, rot.column1, rot.column2);
+ }
+ else
+ rot = PxMat33(PxIdentity);
// Box extents
extents.x = capsule.radius + (d * 0.5f);
extents.y = capsule.radius;
extents.z = capsule.radius;
-
- // Box orientation
- Ps::computeBasis(rot.column0, rot.column1, rot.column2);
}
diff --git a/PhysX_3.4/Source/GeomUtils/src/GuDebug.cpp b/PhysX_3.4/Source/GeomUtils/src/GuDebug.cpp
deleted file mode 100644
index 26000832..00000000
--- a/PhysX_3.4/Source/GeomUtils/src/GuDebug.cpp
+++ /dev/null
@@ -1,264 +0,0 @@
-// This code contains NVIDIA Confidential Information and is disclosed to you
-// under a form of NVIDIA software license agreement provided separately to you.
-//
-// Notice
-// NVIDIA Corporation and its licensors retain all intellectual property and
-// proprietary rights in and to this software and related documentation and
-// any modifications thereto. Any use, reproduction, disclosure, or
-// distribution of this software and related documentation without an express
-// license agreement from NVIDIA Corporation is strictly prohibited.
-//
-// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
-// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
-// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
-// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
-//
-// Information and code furnished is believed to be accurate and reliable.
-// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
-// information or for any infringement of patents or other rights of third parties that may
-// result from its use. No license is granted by implication or otherwise under any patent
-// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
-// This code supersedes and replaces all information previously supplied.
-// NVIDIA Corporation products are not authorized for use as critical
-// components in life support devices or systems without express written approval of
-// NVIDIA Corporation.
-//
-// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved.
-// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
-// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
-
-#include "GuDebug.h"
-#include "GuHeightFieldUtil.h"
-#include "GuTriangleMesh.h"
-#include "GuConvexMesh.h"
-#include "PxVisualizationParameter.h"
-#include "PxBoxGeometry.h"
-#include "PxSphereGeometry.h"
-#include "PxPlaneGeometry.h"
-#include "PxCapsuleGeometry.h"
-#include "PxConvexMeshGeometry.h"
-#include "PxGeometryQuery.h"
-#include "PxMeshQuery.h"
-
-using namespace physx;
-using namespace Gu;
-
-#if PX_ENABLE_DEBUG_VISUALIZATION
-
-static void visualizeSphere(const PxSphereGeometry& geometry, Cm::RenderOutput& out, const PxTransform& absPose)
-{
- const PxU32 scolor = PxU32(PxDebugColor::eARGB_MAGENTA);
-
- out << scolor << absPose << Cm::DebugCircle(100, geometry.radius);
-
- PxMat44 rotPose(absPose);
- Ps::swap(rotPose.column1, rotPose.column2);
- rotPose.column1 = -rotPose.column1;
- out << scolor << rotPose << Cm::DebugCircle(100, geometry.radius);
-
- Ps::swap(rotPose.column0, rotPose.column2);
- rotPose.column0 = -rotPose.column0;
- out << scolor << rotPose << Cm::DebugCircle(100, geometry.radius);
-}
-
-static void visualizePlane(const PxPlaneGeometry& /*geometry*/, Cm::RenderOutput& out, const PxTransform& absPose)
-{
- const PxU32 scolor = PxU32(PxDebugColor::eARGB_MAGENTA);
-
- PxMat44 rotPose(absPose);
- Ps::swap(rotPose.column1, rotPose.column2);
- rotPose.column1 = -rotPose.column1;
-
- Ps::swap(rotPose.column0, rotPose.column2);
- rotPose.column0 = -rotPose.column0;
- for(PxReal radius = 2.0f; radius < 20.0f ; radius += 2.0f)
- out << scolor << rotPose << Cm::DebugCircle(100, radius*radius);
-}
-
-static void visualizeCapsule(const PxCapsuleGeometry& geometry, Cm::RenderOutput& out, const PxTransform& absPose)
-{
- out << PxU32(PxDebugColor::eARGB_MAGENTA);
- out.outputCapsule(geometry.radius, geometry.halfHeight, absPose);
-}
-
-static void visualizeBox(const PxBoxGeometry& geometry, Cm::RenderOutput& out, const PxTransform& absPose)
-{
- out << PxU32(PxDebugColor::eARGB_MAGENTA);
- out << absPose << Cm::DebugBox(geometry.halfExtents);
-}
-
-static void visualizeConvexMesh(const PxConvexMeshGeometry& geometry, Cm::RenderOutput& out, const PxTransform& absPose)
-{
- (static_cast<const ConvexMesh*>(geometry.convexMesh))->debugVisualize(out, absPose, geometry.scale);
-}
-
-static void visualizeTriangleMesh(const PxTriangleMeshGeometry& geometry, Cm::RenderOutput& out, const PxTransform& absPose,
- const PxBounds3& cullbox, const PxU64 mask, const PxReal fscale, const PxU32 numMaterials)
-{
- (static_cast<const TriangleMesh*>(geometry.triangleMesh))->debugVisualize(out, absPose, geometry.scale, cullbox, mask, fscale, numMaterials);
-}
-
-static void visualizeHeightField(const PxHeightFieldGeometry& hfGeometry,
- Cm::RenderOutput& out, const PxTransform& absPose, const PxBounds3& cullbox,
- const PxU64 mask)
-{
- const HeightField* heightfield = static_cast<const HeightField*>(hfGeometry.heightField);
- const bool cscale = !!(mask & (PxU64(1) << PxVisualizationParameter::eCULL_BOX));
-
- const PxDebugColor::Enum colors[] =
- {
- 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,
- };
- const PxU32 colorCount = sizeof(colors)/sizeof(PxDebugColor::Enum);
-
- if (mask & (PxU64(1) << PxVisualizationParameter::eCOLLISION_SHAPES))
- {
-
- // PT: TODO: the debug viz for HFs is minimal at the moment...
- 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(cscale)
- {
- const PxTransform pose0((cullbox.maximum + cullbox.minimum)*0.5f);
- const PxBoxGeometry boxGeometry((cullbox.maximum - cullbox.minimum)*0.5f);
-
- const PxTransform pose1(absPose);
-
- PxU32* results = reinterpret_cast<PxU32*>(PX_ALLOC(sizeof(PxU32)*nbTriangles, "tmp triangle indices"));
-
- bool overflow = false;
- PxU32 nbTouchedTris = PxMeshQuery::findOverlapHeightField(boxGeometry, pose0, hfGeometry, pose1, 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, pose1, 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);
- scolor = colors[localMaterialIndex % colorCount];
-
- segments[0] = PxDebugLine(currentTriangle.verts[0], currentTriangle.verts[1], scolor);
- segments[1] = PxDebugLine(currentTriangle.verts[1], currentTriangle.verts[2], scolor);
- segments[2] = PxDebugLine(currentTriangle.verts[2], currentTriangle.verts[0], 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);
- out << colors[localMaterialIndex % colorCount];
-
- const PxVec3& vw0 = tmpVerts[vi0];
- const PxVec3& vw1 = tmpVerts[vi1];
- const PxVec3& vw2 = tmpVerts[vi2];
-
- out.outputSegment(vw0, vw1);
- out.outputSegment(vw1, vw2);
- out.outputSegment(vw2, vw0);
- }
- }
- PX_FREE(tmpVerts);
- }
- }
-}
-
-namespace physx
-{
-namespace Gu
-{
-
-void Debug::visualize(const PxGeometry& geometry,
- Cm::RenderOutput& out,
- const PxTransform& absPose,
- const PxBounds3& cullbox,
- const PxU64 mask,
- const PxReal fscale,
- const PxU32 numMaterials)
-{
-
- const bool cull((mask & (PxU64(1) << PxVisualizationParameter::eCULL_BOX)) != 0);
- const bool collisionShapes((mask & (PxU64(1) << PxVisualizationParameter::eCOLLISION_SHAPES)) != 0);
-
- if(cull && !cullbox.intersects(PxGeometryQuery::getWorldBounds(geometry, absPose, 0.0f)))
- return;
-
- // triangle meshes can render active edges, but for other types we can just early out if there are no collision shapes
- if(!collisionShapes && 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, mask, fscale, numMaterials);
- break;
- case PxGeometryType::eHEIGHTFIELD:
- visualizeHeightField(static_cast<const PxHeightFieldGeometry&>(geometry), out, absPose, cullbox, mask);
- break;
- case PxGeometryType::eINVALID:
- break;
- case PxGeometryType::eGEOMETRY_COUNT:
- break;
- }
-}
-}
-}
-
-#endif
diff --git a/PhysX_3.4/Source/GeomUtils/src/GuGeometryUnion.h b/PhysX_3.4/Source/GeomUtils/src/GuGeometryUnion.h
index 97f9a461..7866bab2 100644
--- a/PhysX_3.4/Source/GeomUtils/src/GuGeometryUnion.h
+++ b/PhysX_3.4/Source/GeomUtils/src/GuGeometryUnion.h
@@ -167,7 +167,7 @@ namespace Gu
class InvalidGeometry : public PxGeometry
{
public:
- PX_CUDA_CALLABLE PX_INLINE InvalidGeometry() : PxGeometry(PxGeometryType::eINVALID) {}
+ PX_CUDA_CALLABLE PX_FORCE_INLINE InvalidGeometry() : PxGeometry(PxGeometryType::eINVALID) {}
};
class PX_PHYSX_COMMON_API GeometryUnion
@@ -184,11 +184,11 @@ public:
static void getBinaryMetaData(PxOutputStream& stream);
//~PX_SERIALIZATION
- PX_CUDA_CALLABLE PX_INLINE GeometryUnion() { reinterpret_cast<InvalidGeometry&>(mGeometry) = InvalidGeometry(); }
- PX_CUDA_CALLABLE PX_INLINE GeometryUnion(const PxGeometry& g) { set(g); }
+ PX_CUDA_CALLABLE PX_FORCE_INLINE GeometryUnion() { reinterpret_cast<InvalidGeometry&>(mGeometry) = InvalidGeometry(); }
+ PX_CUDA_CALLABLE PX_FORCE_INLINE GeometryUnion(const PxGeometry& g) { set(g); }
- PX_CUDA_CALLABLE PX_FORCE_INLINE const PxGeometry& getGeometry() const { return reinterpret_cast<const PxGeometry&>(mGeometry); }
- PX_CUDA_CALLABLE PX_FORCE_INLINE PxGeometryType::Enum getType() const { return reinterpret_cast<const PxGeometry&>(mGeometry).getType(); }
+ PX_CUDA_CALLABLE PX_FORCE_INLINE const PxGeometry& getGeometry() const { return reinterpret_cast<const PxGeometry&>(mGeometry); }
+ PX_CUDA_CALLABLE PX_FORCE_INLINE PxGeometryType::Enum getType() const { return reinterpret_cast<const PxGeometry&>(mGeometry).getType(); }
PX_CUDA_CALLABLE void set(const PxGeometry& g);
diff --git a/PhysX_3.4/Source/GeomUtils/src/contact/GuContactMethodImpl.h b/PhysX_3.4/Source/GeomUtils/src/contact/GuContactMethodImpl.h
index 86101dc3..fb40143c 100644
--- a/PhysX_3.4/Source/GeomUtils/src/contact/GuContactMethodImpl.h
+++ b/PhysX_3.4/Source/GeomUtils/src/contact/GuContactMethodImpl.h
@@ -64,12 +64,14 @@ namespace Gu
PX_FORCE_INLINE void setManifold(void* manifold)
{
+ PX_ASSERT((size_t(manifold) & 0xF) == 0);
mCachedData = reinterpret_cast<PxU8*>(manifold);
mManifoldFlags |= IS_MANIFOLD;
}
PX_FORCE_INLINE void setMultiManifold(void* manifold)
{
+ PX_ASSERT((size_t(manifold) & 0xF) == 0);
mCachedData = reinterpret_cast<PxU8*>(manifold);
mManifoldFlags |= IS_MANIFOLD|IS_MULTI_MANIFOLD;
}
diff --git a/PhysX_3.4/Source/GeomUtils/src/convex/GuConvexMesh.cpp b/PhysX_3.4/Source/GeomUtils/src/convex/GuConvexMesh.cpp
index 53d67504..da1302d2 100644
--- a/PhysX_3.4/Source/GeomUtils/src/convex/GuConvexMesh.cpp
+++ b/PhysX_3.4/Source/GeomUtils/src/convex/GuConvexMesh.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 "PxVisualizationParameter.h"
#include "PsIntrinsics.h"
#include "CmPhysXCommon.h"
@@ -375,8 +374,6 @@ bool Gu::ConvexMesh::load(PxInputStream& stream)
return true;
}
-
-
void Gu::ConvexMesh::release()
{
decRefCount();
@@ -419,38 +416,3 @@ PxBounds3 Gu::ConvexMesh::getLocalBounds() const
PX_ASSERT(mHullData.mAABB.isValid());
return PxBounds3::centerExtents(mHullData.mAABB.mCenter, mHullData.mAABB.mExtents);
}
-
-
-#if PX_ENABLE_DEBUG_VISUALIZATION
-#include "CmMatrix34.h"
-#include "GuDebug.h"
-void Gu::ConvexMesh::debugVisualize(Cm::RenderOutput& out, const PxTransform& pose, const PxMeshScale& scale) const
-{
- const PxU32 scolor = PxU32(PxDebugColor::eARGB_MAGENTA);
-
- const PxVec3* vertices = mHullData.getHullVertices();
- const PxU8* indexBuffer = mHullData.getVertexData8();
- const PxU32 nbPolygons = getNbPolygonsFast();
-
- const PxMat44 m44(PxMat33(pose.q) * scale.toMat33(), pose.p);
-
- out << m44 << scolor; // PT: no need to output this for each segment!
-
- for (PxU32 i = 0; i < nbPolygons; i++)
- {
- const PxU32 pnbVertices = mHullData.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++)
- {
- PxVec3 end = m44.transform(vertices[indexBuffer[j]]);
- out.outputSegment(begin, end);
- begin = end;
- }
- out.outputSegment(begin, m44.transform(vertices[indexBuffer[0]]));
-
- indexBuffer += pnbVertices;
- }
-}
-
-#endif
diff --git a/PhysX_3.4/Source/GeomUtils/src/convex/GuConvexMesh.h b/PhysX_3.4/Source/GeomUtils/src/convex/GuConvexMesh.h
index cf75ec31..46088706 100644
--- a/PhysX_3.4/Source/GeomUtils/src/convex/GuConvexMesh.h
+++ b/PhysX_3.4/Source/GeomUtils/src/convex/GuConvexMesh.h
@@ -155,6 +155,8 @@ namespace Gu
PX_FORCE_INLINE void setMeshFactory(GuMeshFactory* f) { mMeshFactory = f; }
+ PX_FORCE_INLINE void setNb(PxU32 nb) { mNb = nb; }
+
protected:
ConvexHullData mHullData;
PxBitAndDword mNb; // ### PT: added for serialization. Try to remove later?
@@ -166,20 +168,7 @@ private:
GuMeshFactory* mMeshFactory; // PT: changed to pointer for serialization
PX_FORCE_INLINE PxU32 getNb() const { return mNb; }
- PX_FORCE_INLINE PxU32 ownsMemory() const { return PxU32(!mNb.isBitSet()); }
-
-#if PX_ENABLE_DEBUG_VISUALIZATION
-public:
- /**
- \brief Perform convex mesh geometry debug visualization
-
- \param out Debug renderer.
- \param pose World position.
- \param scale Scale to apply.
- */
- void debugVisualize( Cm::RenderOutput& out, const PxTransform& pose, const PxMeshScale& scale) const;
-
-#endif
+ PX_FORCE_INLINE PxU32 ownsMemory() const { return PxU32(!mNb.isBitSet()); }
};
} // namespace Gu
diff --git a/PhysX_3.4/Source/GeomUtils/src/hf/GuHeightField.h b/PhysX_3.4/Source/GeomUtils/src/hf/GuHeightField.h
index 4cc9c6ba..3030b4df 100644
--- a/PhysX_3.4/Source/GeomUtils/src/hf/GuHeightField.h
+++ b/PhysX_3.4/Source/GeomUtils/src/hf/GuHeightField.h
@@ -191,10 +191,34 @@ public:
// PX_INLINE PxU32 computeCellCoordinates(PxReal x, PxReal z, PxU32 nbColumns, PxReal& fracX, PxReal& fracZ) const;
PX_PHYSX_COMMON_API PxU32 computeCellCoordinates(PxReal x, PxReal z, PxReal& fracX, PxReal& fracZ) const;
- PX_CUDA_CALLABLE PX_FORCE_INLINE PxU32 getMinRow(PxReal x) const { return PxU32(PxClamp(PxI32(Ps::floor(x)), PxI32(0), PxI32(mData.rows-2))); }
- PX_CUDA_CALLABLE PX_FORCE_INLINE PxU32 getMaxRow(PxReal x) const { return PxU32(PxClamp(PxI32(Ps::ceil(x)), PxI32(0), PxI32(mData.rows-1))); }
- PX_CUDA_CALLABLE PX_FORCE_INLINE PxU32 getMinColumn(PxReal z) const { return PxU32(PxClamp(PxI32(Ps::floor(z)), PxI32(0), PxI32(mData.columns-2))); }
- PX_CUDA_CALLABLE PX_FORCE_INLINE PxU32 getMaxColumn(PxReal z) const { return PxU32(PxClamp(PxI32(Ps::ceil(z)), PxI32(0), PxI32(mData.columns-1))); }
+ PX_CUDA_CALLABLE PX_FORCE_INLINE PxU32 getMin(PxReal x, PxU32 nb) const
+ {
+ if(x<0.0f)
+ return 0;
+ if(x>PxReal(nb))
+ return nb;
+
+ const PxReal cx = Ps::floor(x);
+ const PxU32 icx = PxU32(cx);
+ return icx;
+ }
+
+ PX_CUDA_CALLABLE PX_FORCE_INLINE PxU32 getMax(PxReal x, PxU32 nb) const
+ {
+ if(x<0.0f)
+ return 0;
+ if(x>PxReal(nb))
+ return nb;
+
+ const PxReal cx = Ps::ceil(x);
+ const PxU32 icx = PxU32(cx);
+ return icx;
+ }
+
+ PX_CUDA_CALLABLE PX_FORCE_INLINE PxU32 getMinRow(PxReal x) const { return getMin(x, mData.rows-2); }
+ PX_CUDA_CALLABLE PX_FORCE_INLINE PxU32 getMaxRow(PxReal x) const { return getMax(x, mData.rows-1); }
+ PX_CUDA_CALLABLE PX_FORCE_INLINE PxU32 getMinColumn(PxReal z) const { return getMin(z, mData.columns-2); }
+ PX_CUDA_CALLABLE PX_FORCE_INLINE PxU32 getMaxColumn(PxReal z) const { return getMax(z, mData.columns-1); }
PX_CUDA_CALLABLE PX_INLINE bool isValidTriangle(PxU32 triangleIndex) const;
PX_CUDA_CALLABLE PX_FORCE_INLINE bool isFirstTriangle(PxU32 triangleIndex) const { return ((triangleIndex & 0x1) == 0); }
diff --git a/PhysX_3.4/Source/GeomUtils/src/hf/GuHeightFieldUtil.cpp b/PhysX_3.4/Source/GeomUtils/src/hf/GuHeightFieldUtil.cpp
index a5ffaccf..b0bd4124 100644
--- a/PhysX_3.4/Source/GeomUtils/src/hf/GuHeightFieldUtil.cpp
+++ b/PhysX_3.4/Source/GeomUtils/src/hf/GuHeightFieldUtil.cpp
@@ -818,16 +818,11 @@ void Gu::HeightFieldUtil::getEdge(PxU32 edgeIndex, PxU32 cell, PxU32 row, PxU32
}
}
-bool Gu::HeightFieldUtil::overlapAABBTriangles(
- const PxTransform& pose, const PxBounds3& bounds, PxU32 flags, EntityReport<PxU32>* callback) const
+bool Gu::HeightFieldUtil::overlapAABBTriangles(const PxTransform& pose, const PxBounds3& bounds, PxU32 flags, EntityReport<PxU32>* callback) const
{
- PxBounds3 localBounds = bounds;
+ PX_ASSERT(!bounds.isEmpty());
- if(flags & GuHfQueryFlags::eWORLD_SPACE)
- {
- PX_ASSERT(!localBounds.isEmpty());
- localBounds = PxBounds3::transformFast(pose.getInverse(), localBounds);
- }
+ PxBounds3 localBounds = (flags & GuHfQueryFlags::eWORLD_SPACE) ? PxBounds3::transformFast(pose.getInverse(), bounds) : bounds;
localBounds.minimum.x *= mOneOverRowScale;
localBounds.minimum.y *= mOneOverHeightScale;
@@ -837,65 +832,60 @@ bool Gu::HeightFieldUtil::overlapAABBTriangles(
localBounds.maximum.y *= mOneOverHeightScale;
localBounds.maximum.z *= mOneOverColumnScale;
- if (mHfGeom->rowScale < 0)
- {
- PxReal swap = localBounds.minimum.x;
- localBounds.minimum.x = localBounds.maximum.x;
- localBounds.maximum.x = swap;
- }
+ if(mHfGeom->rowScale < 0.0f)
+ Ps::swap(localBounds.minimum.x, localBounds.maximum.x);
- if (mHfGeom->columnScale < 0)
- {
- PxReal swap = localBounds.minimum.z;
- localBounds.minimum.z = localBounds.maximum.z;
- localBounds.maximum.z = swap;
- }
+ if(mHfGeom->columnScale < 0.0f)
+ Ps::swap(localBounds.minimum.z, localBounds.maximum.z);
// early exit for aabb does not overlap in XZ plane
// DO NOT MOVE: since rowScale / columnScale may be negative this has to be done after scaling localBounds
- if (localBounds.minimum.x > mHeightField->getNbRowsFast() - 1)
+ const PxU32 nbRows = mHeightField->getNbRowsFast();
+ const PxU32 nbColumns = mHeightField->getNbColumnsFast();
+ if(localBounds.minimum.x > float(nbRows - 1))
return false;
- if (localBounds.minimum.z > mHeightField->getNbColumnsFast() - 1)
+ if(localBounds.minimum.z > float(nbColumns - 1))
return false;
- if (localBounds.maximum.x < 0)
+ if(localBounds.maximum.x < 0.0f)
return false;
- if (localBounds.maximum.z < 0)
+ if(localBounds.maximum.z < 0.0f)
return false;
- PxU32 minRow = mHeightField->getMinRow(localBounds.minimum.x);
- PxU32 maxRow = mHeightField->getMaxRow(localBounds.maximum.x);
- PxU32 minColumn = mHeightField->getMinColumn(localBounds.minimum.z);
- PxU32 maxColumn = mHeightField->getMaxColumn(localBounds.maximum.z);
+ const PxU32 minRow = mHeightField->getMinRow(localBounds.minimum.x);
+ const PxU32 maxRow = mHeightField->getMaxRow(localBounds.maximum.x);
+ const PxU32 minColumn = mHeightField->getMinColumn(localBounds.minimum.z);
+ const PxU32 maxColumn = mHeightField->getMaxColumn(localBounds.maximum.z);
PxU32 maxNbTriangles = 2 * (maxColumn - minColumn) * (maxRow - minRow);
- if (maxNbTriangles == 0)
+ if(!maxNbTriangles)
return false;
- if (flags & GuHfQueryFlags::eFIRST_CONTACT) maxNbTriangles = 1;
+ if(flags & GuHfQueryFlags::eFIRST_CONTACT)
+ maxNbTriangles = 1;
- static const PxU32 bufferSize = HF_SWEEP_REPORT_BUFFER_SIZE;
+ const PxU32 bufferSize = HF_SWEEP_REPORT_BUFFER_SIZE;
PxU32 indexBuffer[bufferSize];
PxU32 indexBufferUsed = 0;
PxU32 nb = 0;
PxU32 offset = minRow * mHeightField->getNbColumnsFast() + minColumn;
- const PxReal& miny = localBounds.minimum.y;
- const PxReal& maxy = localBounds.maximum.y;
+ const PxReal miny = localBounds.minimum.y;
+ const PxReal maxy = localBounds.maximum.y;
- for (PxU32 row = minRow; row < maxRow; row++)
+ for(PxU32 row=minRow; row<maxRow; row++)
{
- for (PxU32 column = minColumn; column < maxColumn; column++)
+ for(PxU32 column=minColumn; column<maxColumn; column++)
{
- PxReal h0 = mHeightField->getHeight(offset);
- PxReal h1 = mHeightField->getHeight(offset + 1);
- PxReal h2 = mHeightField->getHeight(offset + mHeightField->getNbColumnsFast());
- PxReal h3 = mHeightField->getHeight(offset + mHeightField->getNbColumnsFast() + 1);
- if (!((maxy < h0 && maxy < h1 && maxy < h2 && maxy < h3) || (miny > h0 && miny > h1 && miny > h2 && miny > h3)))
+ const PxReal h0 = mHeightField->getHeight(offset);
+ const PxReal h1 = mHeightField->getHeight(offset + 1);
+ const PxReal h2 = mHeightField->getHeight(offset + mHeightField->getNbColumnsFast());
+ const PxReal h3 = mHeightField->getHeight(offset + mHeightField->getNbColumnsFast() + 1);
+ if(!((maxy < h0 && maxy < h1 && maxy < h2 && maxy < h3) || (miny > h0 && miny > h1 && miny > h2 && miny > h3)))
{
- PxU32 material0 = mHeightField->getMaterialIndex0(offset);
- if (material0 != PxHeightFieldMaterial::eHOLE)
+ const PxU32 material0 = mHeightField->getMaterialIndex0(offset);
+ if(material0 != PxHeightFieldMaterial::eHOLE)
{
if(indexBufferUsed >= bufferSize)
{
@@ -906,11 +896,12 @@ bool Gu::HeightFieldUtil::overlapAABBTriangles(
indexBuffer[indexBufferUsed++] = offset << 1;
nb++;
- if (flags & GuHfQueryFlags::eFIRST_CONTACT) goto search_done;
+ if(flags & GuHfQueryFlags::eFIRST_CONTACT)
+ goto search_done;
}
- PxU32 material1 = mHeightField->getMaterialIndex1(offset);
- if (material1 != PxHeightFieldMaterial::eHOLE)
+ const PxU32 material1 = mHeightField->getMaterialIndex1(offset);
+ if(material1 != PxHeightFieldMaterial::eHOLE)
{
if(indexBufferUsed >= bufferSize)
{
@@ -921,7 +912,8 @@ bool Gu::HeightFieldUtil::overlapAABBTriangles(
indexBuffer[indexBufferUsed++] = (offset << 1) + 1;
nb++;
- if (flags & GuHfQueryFlags::eFIRST_CONTACT) goto search_done;
+ if(flags & GuHfQueryFlags::eFIRST_CONTACT)
+ goto search_done;
}
}
offset++;
diff --git a/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4Build.cpp b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4Build.cpp
index fbe97042..48e14eab 100644
--- a/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4Build.cpp
+++ b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4Build.cpp
@@ -28,6 +28,7 @@
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "foundation/PxVec4.h"
+#include "foundation/PxMemory.h"
#include "GuBV4Build.h"
#include "GuBV4.h"
#include "PxTriangle.h"
@@ -1188,7 +1189,7 @@ static bool BuildBV4Internal(BV4Tree& tree, const AABBTree& Source, SourceMesh*
{
PX_ASSERT(sizeof(BVDataSwizzled)==sizeof(BVDataPacked)*4);
BVDataPacked* Copy = PX_NEW(BVDataPacked)[NbNeeded];
- memcpy(Copy, Nodes, sizeof(BVDataPacked)*NbNeeded);
+ PxMemCopy(Copy, Nodes, sizeof(BVDataPacked)*NbNeeded);
for(PxU32 i=0;i<NbNeeded/4;i++)
{
const BVDataPacked* Src = Copy + i*4;
diff --git a/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_Slabs.h b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_Slabs.h
index a371ea93..b0c624dd 100644
--- a/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_Slabs.h
+++ b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_Slabs.h
@@ -190,17 +190,6 @@
} \
}
-#if PX_INTEL_FAMILY
-namespace
-{
- const VecU32V signMask = U4LoadXYZW((PxU32(1)<<31), (PxU32(1)<<31), (PxU32(1)<<31), (PxU32(1)<<31));
- const Vec4V epsFloat4 = V4Load(1e-9f);
- const Vec4V zeroes = V4Zero();
- const Vec4V twos = V4Load(2.0f);
- const Vec4V epsInflateFloat4 = V4Load(1e-7f);
-}
-#endif // PX_INTEL_FAMILY
-
#endif // GU_BV4_USE_SLABS
#endif // GU_BV4_SLABS_H
diff --git a/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_Slabs_KajiyaNoOrder.h b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_Slabs_KajiyaNoOrder.h
index 45f4e4a9..0b3b9e44 100644
--- a/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_Slabs_KajiyaNoOrder.h
+++ b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_Slabs_KajiyaNoOrder.h
@@ -30,6 +30,8 @@
#ifndef GU_BV4_SLABS_KAJIYA_NO_ORDER_H
#define GU_BV4_SLABS_KAJIYA_NO_ORDER_H
+#include "GuBVConstants.h"
+
// Kajiya, no sort
template<int inflateT, class LeafTestT, class ParamsT>
static Ps::IntBool BV4_ProcessStreamKajiyaNoOrder(const BVDataPacked* PX_RESTRICT node, PxU32 initData, ParamsT* PX_RESTRICT params)
diff --git a/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_Slabs_KajiyaOrdered.h b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_Slabs_KajiyaOrdered.h
index 4bdcee3a..f2ad73db 100644
--- a/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_Slabs_KajiyaOrdered.h
+++ b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4_Slabs_KajiyaOrdered.h
@@ -30,6 +30,8 @@
#ifndef GU_BV4_SLABS_KAJIYA_ORDERED_H
#define GU_BV4_SLABS_KAJIYA_ORDERED_H
+#include "GuBVConstants.h"
+
// Kajiya + PNS
template<const int inflateT, class LeafTestT, class ParamsT>
static void BV4_ProcessStreamKajiyaOrdered(const BVDataPacked* PX_RESTRICT node, PxU32 initData, ParamsT* PX_RESTRICT params)
diff --git a/PhysX_3.4/Source/GeomUtils/src/GuDebug.h b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBVConstants.h
index 10ad4fb1..052b3d24 100644
--- a/PhysX_3.4/Source/GeomUtils/src/GuDebug.h
+++ b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBVConstants.h
@@ -27,36 +27,18 @@
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
-#ifndef GU_DEBUG_H
-#define GU_DEBUG_H
+#ifndef GU_BV_CONSTANTS_H
+#define GU_BV_CONSTANTS_H
-#include "CmRenderOutput.h"
-#include "CmPhysXCommon.h"
+#include "PsVecMath.h"
-namespace physx
+namespace
{
-#if PX_ENABLE_DEBUG_VISUALIZATION
-
-class PxGeometry;
-namespace Gu
-{
- class Debug
- {
-
- public :
-
- PX_PHYSX_COMMON_API static void visualize(const PxGeometry& geometry,
- Cm::RenderOutput& out,
- const PxTransform& absPose,
- const PxBounds3& cullbox,
- const PxU64 mask,
- const PxReal fscale,
- const PxU32 numMaterials);
- };
-}
-
-#endif
-
+ const physx::Ps::aos::VecU32V signMask = physx::Ps::aos::U4LoadXYZW((physx::PxU32(1)<<31), (physx::PxU32(1)<<31), (physx::PxU32(1)<<31), (physx::PxU32(1)<<31));
+ const physx::Ps::aos::Vec4V epsFloat4 = physx::Ps::aos::V4Load(1e-9f);
+ const physx::Ps::aos::Vec4V zeroes = physx::Ps::aos::V4Zero();
+ const physx::Ps::aos::Vec4V twos = physx::Ps::aos::V4Load(2.0f);
+ const physx::Ps::aos::Vec4V epsInflateFloat4 = physx::Ps::aos::V4Load(1e-7f);
}
-#endif
+#endif // GU_BV_CONSTANTS_H
diff --git a/PhysX_3.4/Source/GeomUtils/src/mesh/GuRTreeQueries.cpp b/PhysX_3.4/Source/GeomUtils/src/mesh/GuRTreeQueries.cpp
index 9d7bd57a..6cf130fd 100644
--- a/PhysX_3.4/Source/GeomUtils/src/mesh/GuRTreeQueries.cpp
+++ b/PhysX_3.4/Source/GeomUtils/src/mesh/GuRTreeQueries.cpp
@@ -56,6 +56,7 @@ General notes:
#include "PsVecMath.h"
#include "PxQueryReport.h" // for PxAgain
#include "PsBitUtils.h"
+#include "GuBVConstants.h"
//#define VERIFY_RTREE
#ifdef VERIFY_RTREE
@@ -169,15 +170,6 @@ void RTree::traverseAABB(const PxVec3& boxMin, const PxVec3& boxMax, const PxU32
} while (stackPtr > stack);
}
-namespace
-{
- const VecU32V signMask = U4LoadXYZW((PxU32(1)<<31), (PxU32(1)<<31), (PxU32(1)<<31), (PxU32(1)<<31));
- const Vec4V epsFloat4 = V4Load(1e-9f);
- const Vec4V zeroes = V4Zero();
- const Vec4V twos = V4Load(2.0f);
- const Vec4V epsInflateFloat4 = V4Load(1e-7f);
-}
-
/////////////////////////////////////////////////////////////////////////
template <int inflate>
void RTree::traverseRay(
diff --git a/PhysX_3.4/Source/GeomUtils/src/mesh/GuTriangleMesh.cpp b/PhysX_3.4/Source/GeomUtils/src/mesh/GuTriangleMesh.cpp
index be47d3e1..231bddc0 100644
--- a/PhysX_3.4/Source/GeomUtils/src/mesh/GuTriangleMesh.cpp
+++ b/PhysX_3.4/Source/GeomUtils/src/mesh/GuTriangleMesh.cpp
@@ -27,14 +27,12 @@
// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
-
#include "PsIntrinsics.h"
#include "GuMidphaseInterface.h"
#include "GuSerialize.h"
#include "GuMeshFactory.h"
#include "CmRenderOutput.h"
#include "PxVisualizationParameter.h"
-#include "GuConvexEdgeFlags.h"
#include "GuBox.h"
#include "PxMeshScale.h"
#include "CmUtils.h"
@@ -196,6 +194,15 @@ void Gu::TriangleMesh::importExtraData(PxDeserializationContext& context)
if(mAdjacencies)
mAdjacencies = context.readExtraData<PxU32, PX_SERIAL_ALIGN>(3*mNbTriangles);
+
+ mGRB_triIndices = NULL;
+ mGRB_triAdjacencies = NULL;
+ mGRB_vertValency = NULL;
+ mGRB_adjVertStart = NULL;
+ mGRB_adjVertices = NULL;
+ mGRB_meshAdjVerticiesTotal = 0;
+ mGRB_faceRemap = NULL;
+ mGRB_BV32Tree = NULL;
}
void Gu::TriangleMesh::onRefCountZero()
@@ -236,222 +243,4 @@ PxBounds3 Gu::TriangleMesh::refitBVH()
}
#endif
-#if PX_ENABLE_DEBUG_VISUALIZATION
-
-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 Cm::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(Cm::RenderOutput& out, const Gu::TriangleMesh& mesh, PxU32 nbTriangles, const PxU32* results, const Cm::Matrix34& absPose, const PxMat44& midt)
-{
- const PxU8* extraTrigData = mesh.getExtraTrigData();
- PX_ASSERT(extraTrigData);
-
- const PxVec3* vertices = mesh.getVerticesFast();
- const void* indices = mesh.getTrianglesFast();
-
- const PxU32 ecolor = PxU32(PxDebugColor::eARGB_YELLOW);
- 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 << midt << ecolor << Cm::RenderOutput::LINES << wp[0] << wp[1];
- }
- if(flags & Gu::ETD_CONVEX_EDGE_12)
- {
- out << midt << ecolor << Cm::RenderOutput::LINES << wp[1] << wp[2];
- }
- if(flags & Gu::ETD_CONVEX_EDGE_20)
- {
- out << midt << ecolor << Cm::RenderOutput::LINES << wp[0] << wp[2];
- }
- }
-}
-
-void Gu::TriangleMesh::debugVisualize(
- Cm::RenderOutput& out, const PxTransform& pose, const PxMeshScale& scaling, const PxBounds3& cullbox,
- const PxU64 mask, const PxReal fscale, const PxU32 numMaterials) const
-{
- PX_UNUSED(numMaterials);
-
- //bool cscale = !!(mask & ((PxU64)1 << PxVisualizationParameter::eCULL_BOX));
- const PxU64 cullBoxMask = PxU64(1) << PxVisualizationParameter::eCULL_BOX;
- bool cscale = ((mask & cullBoxMask) == cullBoxMask);
-
- const PxMat44 midt(PxIdentity);
- const Cm::Matrix34 absPose(PxMat33(pose.q) * scaling.toMat33(), pose.p);
-
- PxU32 nbTriangles = getNbTrianglesFast();
- const PxU32 nbVertices = getNbVerticesFast();
- const PxVec3* vertices = getVerticesFast();
- const void* indices = getTrianglesFast();
-
- const PxDebugColor::Enum colors[] =
- {
- 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,
- };
-
- const PxU32 colorCount = sizeof(colors)/sizeof(PxDebugColor::Enum);
-
- if(cscale)
- {
- 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
- PxU32* results = reinterpret_cast<PxU32*>(PX_ALLOC_TEMP(sizeof(PxU32)*nbTriangles, "tmp triangle indices"));
- LimitedResults limitedResults(results, nbTriangles, 0);
- Midphase::intersectBoxVsMesh(worldBox, *this, pose, scaling, &limitedResults);
- nbTriangles = limitedResults.mNbResults;
-
- if (fscale)
- {
- const PxU32 fcolor = PxU32(PxDebugColor::eARGB_DARKRED);
-
- for (PxU32 i=0; i<nbTriangles; i++)
- {
- const PxU32 index = results[i];
- PxVec3 wp[3];
- getTriangle(*this, index, wp, vertices, indices, absPose, has16BitIndices());
-
- 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 << midt << fcolor <<
- Cm::DebugArrow(center, normal * fscale);
- }
- }
-
- if (mask & (PxU64(1) << PxVisualizationParameter::eCOLLISION_SHAPES))
- {
- const PxU32 scolor = PxU32(PxDebugColor::eARGB_MAGENTA);
-
- 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++)
- {
- const PxU32 index = results[i];
- PxVec3 wp[3];
- getTriangle(*this, index, wp, vertices, indices, absPose, has16BitIndices());
- segments[0] = PxDebugLine(wp[0], wp[1], scolor);
- segments[1] = PxDebugLine(wp[1], wp[2], scolor);
- segments[2] = PxDebugLine(wp[2], wp[0], scolor);
- segments+=3;
- }
- }
-
- if ((mask & (PxU64(1) << PxVisualizationParameter::eCOLLISION_EDGES)) && mExtraTrigData)
- visualizeActiveEdges(out, *this, nbTriangles, results, absPose, midt);
-
- PX_FREE(results);
- }
- else
- {
- if (fscale)
- {
- const PxU32 fcolor = PxU32(PxDebugColor::eARGB_DARKRED);
-
- for (PxU32 i=0; i<nbTriangles; i++)
- {
- PxVec3 wp[3];
- getTriangle(*this, i, wp, vertices, indices, absPose, has16BitIndices());
-
- 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 << midt << fcolor <<
- Cm::DebugArrow(center, normal * fscale);
- }
- }
-
- if (mask & (PxU64(1) << PxVisualizationParameter::eCOLLISION_SHAPES))
- {
- PxU32 scolor = PxU32(PxDebugColor::eARGB_MAGENTA);
-
- out << midt << scolor; // PT: no need to output this for each segment!
-
- 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(*this, i, wp, transformed, indices, has16BitIndices());
- const PxU32 localMaterialIndex = getTriangleMaterialIndex(i);
- scolor = colors[localMaterialIndex % colorCount];
-
- segments[0] = PxDebugLine(wp[0], wp[1], scolor);
- segments[1] = PxDebugLine(wp[1], wp[2], scolor);
- segments[2] = PxDebugLine(wp[2], wp[0], scolor);
- segments+=3;
- }
-
- PX_FREE(transformed);
- }
-
- if ((mask & (PxU64(1) << PxVisualizationParameter::eCOLLISION_EDGES)) && mExtraTrigData)
- visualizeActiveEdges(out, *this, nbTriangles, NULL, absPose, midt);
- }
-}
-
-#endif // #if PX_ENABLE_DEBUG_VISUALIZATION
-
} // namespace physx
diff --git a/PhysX_3.4/Source/GeomUtils/src/mesh/GuTriangleMesh.h b/PhysX_3.4/Source/GeomUtils/src/mesh/GuTriangleMesh.h
index 854f43b5..57650671 100644
--- a/PhysX_3.4/Source/GeomUtils/src/mesh/GuTriangleMesh.h
+++ b/PhysX_3.4/Source/GeomUtils/src/mesh/GuTriangleMesh.h
@@ -166,19 +166,6 @@ protected:
//!< Set to 0xFFFFffff if no adjacent face
GuMeshFactory* mMeshFactory; // PT: changed to pointer for serialization
-
-#if PX_ENABLE_DEBUG_VISUALIZATION
-public:
- /**
- \brief Perform triangle mesh geometry debug visualization
-
- \param out Debug renderer.
- \param pose World position.
- */
- void debugVisualize( Cm::RenderOutput& out, const PxTransform& pose, const PxMeshScale& scaling, const PxBounds3& cullbox,
- const PxU64 mask, const PxReal fscale, const PxU32 numMaterials) const;
-#endif
-
public:
// GRB data -------------------------