diff options
| author | sschirm <[email protected]> | 2016-12-23 14:20:36 +0100 |
|---|---|---|
| committer | sschirm <[email protected]> | 2016-12-23 14:56:17 +0100 |
| commit | ef6937e69e8ee3f409cf9d460d5ad300a65d5924 (patch) | |
| tree | 710426e8daa605551ce3f34b581897011101c30f /PhysX_3.4/Source/GeomUtils/src/mesh | |
| parent | Initial commit: (diff) | |
| download | physx-3.4-ef6937e69e8ee3f409cf9d460d5ad300a65d5924.tar.xz physx-3.4-ef6937e69e8ee3f409cf9d460d5ad300a65d5924.zip | |
PhysX 3.4 / APEX 1.4 release candidate @21506124
Diffstat (limited to 'PhysX_3.4/Source/GeomUtils/src/mesh')
8 files changed, 60 insertions, 254 deletions
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/mesh/GuBVConstants.h b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBVConstants.h new file mode 100644 index 00000000..052b3d24 --- /dev/null +++ b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBVConstants.h @@ -0,0 +1,44 @@ +// This code contains NVIDIA Confidential Information and is disclosed to you +// under a form of NVIDIA software license agreement provided separately to you. +// +// Notice +// NVIDIA Corporation and its licensors retain all intellectual property and +// proprietary rights in and to this software and related documentation and +// any modifications thereto. Any use, reproduction, disclosure, or +// distribution of this software and related documentation without an express +// license agreement from NVIDIA Corporation is strictly prohibited. +// +// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES +// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO +// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT, +// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. +// +// Information and code furnished is believed to be accurate and reliable. +// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such +// information or for any infringement of patents or other rights of third parties that may +// result from its use. No license is granted by implication or otherwise under any patent +// or patent rights of NVIDIA Corporation. Details are subject to change without notice. +// This code supersedes and replaces all information previously supplied. +// NVIDIA Corporation products are not authorized for use as critical +// components in life support devices or systems without express written approval of +// NVIDIA Corporation. +// +// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved. +// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved. +// Copyright (c) 2001-2004 NovodeX AG. All rights reserved. + +#ifndef GU_BV_CONSTANTS_H +#define GU_BV_CONSTANTS_H + +#include "PsVecMath.h" + +namespace +{ + 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 // 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 ------------------------- |