diff options
| author | Sheikh Dawood Abdul Ajees <[email protected]> | 2018-01-26 19:43:03 -0600 |
|---|---|---|
| committer | Sheikh Dawood Abdul Ajees <[email protected]> | 2018-01-26 19:43:03 -0600 |
| commit | b6db9a56548cd1c41bee309e721d76ea2c9320da (patch) | |
| tree | 1f0436b187db50c21e576b4f4d491530113c91bc /PhysX_3.4/Source/GeomUtils/src/mesh | |
| parent | PhysX 3.4.1, APEX 1.4.1 Release @23307153 (diff) | |
| download | physx-3.4-b6db9a56548cd1c41bee309e721d76ea2c9320da.tar.xz physx-3.4-b6db9a56548cd1c41bee309e721d76ea2c9320da.zip | |
PhysX 3.4, APEX 1.4 patch release @23472123
Diffstat (limited to 'PhysX_3.4/Source/GeomUtils/src/mesh')
| -rw-r--r-- | PhysX_3.4/Source/GeomUtils/src/mesh/GuBV32.cpp | 9 | ||||
| -rw-r--r-- | PhysX_3.4/Source/GeomUtils/src/mesh/GuBV32.h | 2 | ||||
| -rw-r--r-- | PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4.cpp | 71 | ||||
| -rw-r--r-- | PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4.h | 2 | ||||
| -rw-r--r-- | PhysX_3.4/Source/GeomUtils/src/mesh/GuMeshData.h | 3 | ||||
| -rw-r--r-- | PhysX_3.4/Source/GeomUtils/src/mesh/GuRTree.cpp | 47 | ||||
| -rw-r--r-- | PhysX_3.4/Source/GeomUtils/src/mesh/GuRTree.h | 5 |
7 files changed, 65 insertions, 74 deletions
diff --git a/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV32.cpp b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV32.cpp index f81da1b5..5a6682b1 100644 --- a/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV32.cpp +++ b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV32.cpp @@ -114,10 +114,9 @@ void BV32Tree::importExtraData(PxDeserializationContext& context) } //~PX_SERIALIZATION -bool BV32Tree::load(PxInputStream& stream, PxU32 meshVersion) +bool BV32Tree::load(PxInputStream& stream, bool mismatch_) { PX_ASSERT(!mUserAllocated); - PX_UNUSED(meshVersion); release(); @@ -126,9 +125,9 @@ bool BV32Tree::load(PxInputStream& stream, PxU32 meshVersion) if (a != 'B' || b != 'V' || c != '3' || d != '2') return false; - const PxU32 version = 1; - const bool mismatch = (shdfnd::littleEndian() == 1); - if (readDword(mismatch, stream) != version) + bool mismatch; + PxU32 fileVersion; + if(!readBigEndianVersionNumber(stream, mismatch_, fileVersion, mismatch)) return false; mLocalBounds.mCenter.x = readFloat(mismatch, stream); diff --git a/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV32.h b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV32.h index 051dc6be..45e1e88a 100644 --- a/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV32.h +++ b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV32.h @@ -117,7 +117,7 @@ namespace physx PX_PHYSX_COMMON_API BV32Tree(SourceMesh* meshInterface, const PxBounds3& localBounds); PX_PHYSX_COMMON_API ~BV32Tree(); - bool load(PxInputStream& stream, PxU32 meshVersion); // converts to proper endian at load time + bool load(PxInputStream& stream, bool mismatch); void calculateLeafNode(BV32Data& node); void createSOAformatNode(BV32DataPacked& packedData, const BV32Data& node, const PxU32 childOffset, PxU32& currentIndex, PxU32& nbPackedNodes); diff --git a/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4.cpp b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4.cpp index a4e90824..57acd0c7 100644 --- a/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4.cpp +++ b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4.cpp @@ -205,10 +205,17 @@ void BV4Tree::importExtraData(PxDeserializationContext& context) } //~PX_SERIALIZATION -bool BV4Tree::load(PxInputStream& stream, PxU32 meshVersion) +#ifdef GU_BV4_QUANTIZED_TREE + static const PxU32 BVDataPackedNb = sizeof(BVDataPacked)/sizeof(PxU16); + PX_COMPILE_TIME_ASSERT(BVDataPackedNb * sizeof(PxU16) == sizeof(BVDataPacked)); +#else + static const PxU32 BVDataPackedNb = sizeof(BVDataPacked)/sizeof(float); + PX_COMPILE_TIME_ASSERT(BVDataPackedNb * sizeof(float) == sizeof(BVDataPacked)); +#endif + +bool BV4Tree::load(PxInputStream& stream, bool mismatch_) { PX_ASSERT(!mUserAllocated); - PX_UNUSED(meshVersion); release(); @@ -217,25 +224,19 @@ bool BV4Tree::load(PxInputStream& stream, PxU32 meshVersion) if(a!='B' || b!='V' || c!='4' || d!=' ') return false; - const PxU32 version = 1; - const bool mismatch = (shdfnd::littleEndian() == 1); - if(readDword(mismatch, stream) != version) + bool mismatch; + PxU32 fileVersion; + if(!readBigEndianVersionNumber(stream, mismatch_, fileVersion, mismatch)) return false; - mLocalBounds.mCenter.x = readFloat(mismatch, stream); - mLocalBounds.mCenter.y = readFloat(mismatch, stream); - mLocalBounds.mCenter.z = readFloat(mismatch, stream); + readFloatBuffer(&mLocalBounds.mCenter.x, 3, mismatch, stream); mLocalBounds.mExtentsMagnitude = readFloat(mismatch, stream); mInitData = readDword(mismatch, stream); #ifdef GU_BV4_QUANTIZED_TREE - mCenterOrMinCoeff.x = readFloat(mismatch, stream); - mCenterOrMinCoeff.y = readFloat(mismatch, stream); - mCenterOrMinCoeff.z = readFloat(mismatch, stream); - mExtentsOrMaxCoeff.x = readFloat(mismatch, stream); - mExtentsOrMaxCoeff.y = readFloat(mismatch, stream); - mExtentsOrMaxCoeff.z = readFloat(mismatch, stream); + readFloatBuffer(&mCenterOrMinCoeff.x, 3, mismatch, stream); + readFloatBuffer(&mExtentsOrMaxCoeff.x, 3, mismatch, stream); #endif const PxU32 nbNodes = readDword(mismatch, stream); mNbNodes = nbNodes; @@ -250,15 +251,47 @@ bool BV4Tree::load(PxInputStream& stream, PxU32 meshVersion) mNodes = nodes; Cm::markSerializedMem(nodes, sizeof(BVDataPacked)*nbNodes); - for(PxU32 i=0;i<nbNodes;i++) + if(1) + { +#ifdef GU_BV4_QUANTIZED_TREE + readWordBuffer(&nodes[0].mAABB.mData[0].mExtents, BVDataPackedNb * nbNodes, false, stream); +#else + readFloatBuffer(&nodes[0].mAABB.mCenter.x, BVDataPackedNb * nbNodes, false, stream); +#endif + if(mismatch) + { + for(PxU32 i=0;i<nbNodes;i++) + { + BVDataPacked& node = nodes[i]; + for(PxU32 j=0;j<3;j++) + { +#ifdef GU_BV4_QUANTIZED_TREE + flip(node.mAABB.mData[j].mExtents); + flip(node.mAABB.mData[j].mCenter); +#else + flip(node.mAABB.mExtents[j]); + flip(node.mAABB.mCenter[j]); +#endif + } + flip(node.mData); + } + } + + + } + else { - BVDataPacked& node = nodes[i]; + // PT: initial slower code is like this: + for(PxU32 i=0;i<nbNodes;i++) + { + BVDataPacked& node = nodes[i]; #ifdef GU_BV4_QUANTIZED_TREE - readWordBuffer(&node.mAABB.mData[0].mExtents, 6, mismatch, stream); + readWordBuffer(&node.mAABB.mData[0].mExtents, 6, mismatch, stream); #else - readFloatBuffer(&node.mAABB.mCenter.x, 6, mismatch, stream); + readFloatBuffer(&node.mAABB.mCenter.x, 6, mismatch, stream); #endif - node.mData = readDword(mismatch, stream); + node.mData = readDword(mismatch, stream); + } } } else mNodes = NULL; diff --git a/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4.h b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4.h index d9083cc6..c6d02c1f 100644 --- a/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4.h +++ b/PhysX_3.4/Source/GeomUtils/src/mesh/GuBV4.h @@ -226,7 +226,7 @@ namespace Gu PX_PHYSX_COMMON_API BV4Tree(SourceMesh* meshInterface, const PxBounds3& localBounds); PX_PHYSX_COMMON_API ~BV4Tree(); - bool load(PxInputStream& stream, PxU32 meshVersion); // converts to proper endian at load time + bool load(PxInputStream& stream, bool mismatch); void reset(); void operator = (BV4Tree& v); diff --git a/PhysX_3.4/Source/GeomUtils/src/mesh/GuMeshData.h b/PhysX_3.4/Source/GeomUtils/src/mesh/GuMeshData.h index e7af8aee..fe92c4af 100644 --- a/PhysX_3.4/Source/GeomUtils/src/mesh/GuMeshData.h +++ b/PhysX_3.4/Source/GeomUtils/src/mesh/GuMeshData.h @@ -43,9 +43,6 @@ namespace physx { - -#define RTREE_COOK_VERSION 1 - namespace Gu { // 1: support stackless collision trees for non-recursive collision queries diff --git a/PhysX_3.4/Source/GeomUtils/src/mesh/GuRTree.cpp b/PhysX_3.4/Source/GeomUtils/src/mesh/GuRTree.cpp index ff9f6cd3..f43c1c3e 100644 --- a/PhysX_3.4/Source/GeomUtils/src/mesh/GuRTree.cpp +++ b/PhysX_3.4/Source/GeomUtils/src/mesh/GuRTree.cpp @@ -59,41 +59,7 @@ namespace physx namespace Gu { ///////////////////////////////////////////////////////////////////////// -PxU32 RTree::mVersion = 1; - -bool RTree::save(PxOutputStream& stream) const -{ - // save the RTree root structure followed immediately by RTreePage pages to an output stream - bool mismatch = (Ps::littleEndian() == 1); - writeChunk('R', 'T', 'R', 'E', stream); - writeDword(mVersion, mismatch, stream); - writeFloatBuffer(&mBoundsMin.x, 4, mismatch, stream); - writeFloatBuffer(&mBoundsMax.x, 4, mismatch, stream); - writeFloatBuffer(&mInvDiagonal.x, 4, mismatch, stream); - writeFloatBuffer(&mDiagonalScaler.x, 4, mismatch, stream); - writeDword(mPageSize, mismatch, stream); - writeDword(mNumRootPages, mismatch, stream); - writeDword(mNumLevels, mismatch, stream); - writeDword(mTotalNodes, mismatch, stream); - writeDword(mTotalPages, mismatch, stream); - PxU32 unused = 0; // backwards compatibility - writeDword(unused, mismatch, stream); - for (PxU32 j = 0; j < mTotalPages; j++) - { - writeFloatBuffer(mPages[j].minx, RTREE_N, mismatch, stream); - writeFloatBuffer(mPages[j].miny, RTREE_N, mismatch, stream); - writeFloatBuffer(mPages[j].minz, RTREE_N, mismatch, stream); - writeFloatBuffer(mPages[j].maxx, RTREE_N, mismatch, stream); - writeFloatBuffer(mPages[j].maxy, RTREE_N, mismatch, stream); - writeFloatBuffer(mPages[j].maxz, RTREE_N, mismatch, stream); - WriteDwordBuffer(mPages[j].ptrs, RTREE_N, mismatch, stream); - } - - return true; -} - -///////////////////////////////////////////////////////////////////////// -bool RTree::load(PxInputStream& stream, PxU32 meshVersion) +bool RTree::load(PxInputStream& stream, PxU32 meshVersion, bool mismatch_) // PT: 'meshVersion' is the PX_MESH_VERSION from cooked file { PX_UNUSED(meshVersion); @@ -104,8 +70,9 @@ bool RTree::load(PxInputStream& stream, PxU32 meshVersion) if(a!='R' || b!='T' || c!='R' || d!='E') return false; - bool mismatch = (Ps::littleEndian() == 1); - if(readDword(mismatch, stream) != mVersion) + bool mismatch; + PxU32 fileVersion; + if(!readBigEndianVersionNumber(stream, mismatch_, fileVersion, mismatch)) return false; readFloatBuffer(&mBoundsMin.x, 4, mismatch, stream); @@ -118,10 +85,9 @@ bool RTree::load(PxInputStream& stream, PxU32 meshVersion) mTotalNodes = readDword(mismatch, stream); mTotalPages = readDword(mismatch, stream); PxU32 unused = readDword(mismatch, stream); PX_UNUSED(unused); // backwards compatibility - mPages = static_cast<RTreePage*>( - Ps::AlignedAllocator<128>().allocate(sizeof(RTreePage)*mTotalPages, __FILE__, __LINE__)); + mPages = static_cast<RTreePage*>(Ps::AlignedAllocator<128>().allocate(sizeof(RTreePage)*mTotalPages, __FILE__, __LINE__)); Cm::markSerializedMem(mPages, sizeof(RTreePage)*mTotalPages); - for (PxU32 j = 0; j < mTotalPages; j++) + for(PxU32 j=0; j<mTotalPages; j++) { readFloatBuffer(mPages[j].minx, RTREE_N, mismatch, stream); readFloatBuffer(mPages[j].miny, RTREE_N, mismatch, stream); @@ -131,7 +97,6 @@ bool RTree::load(PxInputStream& stream, PxU32 meshVersion) readFloatBuffer(mPages[j].maxz, RTREE_N, mismatch, stream); ReadDwordBuffer(mPages[j].ptrs, RTREE_N, mismatch, stream); } - return true; } diff --git a/PhysX_3.4/Source/GeomUtils/src/mesh/GuRTree.h b/PhysX_3.4/Source/GeomUtils/src/mesh/GuRTree.h index 19004952..a14bfee5 100644 --- a/PhysX_3.4/Source/GeomUtils/src/mesh/GuRTree.h +++ b/PhysX_3.4/Source/GeomUtils/src/mesh/GuRTree.h @@ -138,8 +138,7 @@ namespace Gu { ~RTree() { release(); } PX_INLINE void release(); - bool save(PxOutputStream& stream) const; // always saves as big endian - bool load(PxInputStream& stream, PxU32 meshVersion); // converts to proper endian at load time + bool load(PxInputStream& stream, PxU32 meshVersion, bool mismatch); //////////////////////////////////////////////////////////////////////////// // QUERIES @@ -216,8 +215,6 @@ namespace Gu { PxU32 mFlags; enum { USER_ALLOCATED = 0x1, IS_EDGE_SET = 0x2 }; RTreePage* mPages; - static PxU32 mVersion; - protected: typedef PxU32 NodeHandle; #if PX_ENABLE_DYNAMIC_MESH_RTREE |