aboutsummaryrefslogtreecommitdiff
path: root/PhysX_3.4/Source/PhysXCooking/src
diff options
context:
space:
mode:
authorSheikh Dawood Abdul Ajees <[email protected]>2018-01-26 19:43:03 -0600
committerSheikh Dawood Abdul Ajees <[email protected]>2018-01-26 19:43:03 -0600
commitb6db9a56548cd1c41bee309e721d76ea2c9320da (patch)
tree1f0436b187db50c21e576b4f4d491530113c91bc /PhysX_3.4/Source/PhysXCooking/src
parentPhysX 3.4.1, APEX 1.4.1 Release @23307153 (diff)
downloadphysx-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/PhysXCooking/src')
-rw-r--r--PhysX_3.4/Source/PhysXCooking/src/Cooking.cpp2
-rw-r--r--PhysX_3.4/Source/PhysXCooking/src/mesh/RTreeCooking.cpp16
-rw-r--r--PhysX_3.4/Source/PhysXCooking/src/mesh/TriangleMeshBuilder.cpp53
-rw-r--r--PhysX_3.4/Source/PhysXCooking/src/mesh/TriangleMeshBuilder.h20
4 files changed, 49 insertions, 42 deletions
diff --git a/PhysX_3.4/Source/PhysXCooking/src/Cooking.cpp b/PhysX_3.4/Source/PhysXCooking/src/Cooking.cpp
index fe580659..b53884da 100644
--- a/PhysX_3.4/Source/PhysXCooking/src/Cooking.cpp
+++ b/PhysX_3.4/Source/PhysXCooking/src/Cooking.cpp
@@ -75,7 +75,7 @@ const PxCookingParams& Cooking::getParams() const
bool Cooking::platformMismatch() const
{
// Get current endianness (the one for the platform where cooking is performed)
- PxI8 currentEndian = Ps::littleEndian();
+ const PxI8 currentEndian = Ps::littleEndian();
bool mismatch = true;
switch(mParams.targetPlatform)
diff --git a/PhysX_3.4/Source/PhysXCooking/src/mesh/RTreeCooking.cpp b/PhysX_3.4/Source/PhysXCooking/src/mesh/RTreeCooking.cpp
index db225a5a..005df847 100644
--- a/PhysX_3.4/Source/PhysXCooking/src/mesh/RTreeCooking.cpp
+++ b/PhysX_3.4/Source/PhysXCooking/src/mesh/RTreeCooking.cpp
@@ -359,19 +359,19 @@ struct SubSortSAH
xOrder(xOrder_), yOrder(yOrder_), zOrder(zOrder_),
xRanks(xRanks_), yRanks(yRanks_), zRanks(zRanks_), nbTotalBounds(numBounds)
{
- metricL = new PxF32[numBounds];
- metricR = new PxF32[numBounds];
- tempPermute = new PxU32[numBounds*2+1];
- tempRanks = new PxU32[numBounds];
+ metricL = reinterpret_cast<PxF32*>(PX_ALLOC(sizeof(PxF32)*numBounds, PX_DEBUG_EXP("metricL")));
+ metricR = reinterpret_cast<PxF32*>(PX_ALLOC(sizeof(PxF32)*numBounds, PX_DEBUG_EXP("metricR")));
+ tempPermute = reinterpret_cast<PxU32*>(PX_ALLOC(sizeof(PxU32)*(numBounds*2+1), PX_DEBUG_EXP("tempPermute")));
+ tempRanks = reinterpret_cast<PxU32*>(PX_ALLOC(sizeof(PxU32)*numBounds, PX_DEBUG_EXP("tempRanks")));
iTradeOff = PxMin<PxU32>( PxU32(PxMax<PxReal>(0.0f, sizePerfTradeOff01)*NTRADEOFF), NTRADEOFF-1 );
}
~SubSortSAH() // release temporarily used memory
{
- delete [] metricL; metricL = NULL;
- delete [] metricR; metricR = NULL;
- delete [] tempPermute; tempPermute = NULL;
- delete [] tempRanks; tempRanks = NULL;
+ PX_FREE_AND_RESET(metricL);
+ PX_FREE_AND_RESET(metricR);
+ PX_FREE_AND_RESET(tempPermute);
+ PX_FREE_AND_RESET(tempRanks);
}
////////////////////////////////////////////////////////////////////
diff --git a/PhysX_3.4/Source/PhysXCooking/src/mesh/TriangleMeshBuilder.cpp b/PhysX_3.4/Source/PhysXCooking/src/mesh/TriangleMeshBuilder.cpp
index 47ad7996..0ec8d4a8 100644
--- a/PhysX_3.4/Source/PhysXCooking/src/mesh/TriangleMeshBuilder.cpp
+++ b/PhysX_3.4/Source/PhysXCooking/src/mesh/TriangleMeshBuilder.cpp
@@ -897,8 +897,7 @@ bool TriangleMeshBuilder::save(PxOutputStream& stream, bool platformMismatch, co
writeIntBuffer(mMeshData.mAdjacencies, mMeshData.mNbTriangles*3, platformMismatch, stream);
// Export midphase structure
- saveMidPhaseStructure(stream);
-
+ saveMidPhaseStructure(stream, platformMismatch);
// Export local bounds
writeFloat(mMeshData.mGeomEpsilon, platformMismatch, stream);
@@ -949,7 +948,7 @@ bool TriangleMeshBuilder::save(PxOutputStream& stream, bool platformMismatch, co
//Export GPU midphase structure
BV32Tree* bv32Tree = reinterpret_cast<BV32Tree*>(mMeshData.mGRB_BV32Tree);
- BV32TriangleMeshBuilder::saveMidPhaseStructure(bv32Tree, stream);
+ BV32TriangleMeshBuilder::saveMidPhaseStructure(bv32Tree, stream, platformMismatch);
}
// End of GRB write ----------------------------------------------------------
@@ -1216,13 +1215,17 @@ void BV4TriangleMeshBuilder::createMidPhaseStructure()
mData.mMeshInterface.releaseRemap();
}
-void BV4TriangleMeshBuilder::saveMidPhaseStructure(PxOutputStream& stream) const
+void BV4TriangleMeshBuilder::saveMidPhaseStructure(PxOutputStream& stream, bool mismatch) const
{
- const PxU32 version = 1;
+ // PT: in version 1 we defined "mismatch" as:
+ // const bool mismatch = (littleEndian() == 1);
+ // i.e. the data was *always* saved to file in big-endian format no matter what.
+ // In version>1 we now do the same as for other structures in the SDK: the data is
+ // exported either as little or big-endian depending on the passed parameter.
+ const PxU32 bv4StructureVersion = 2;
- const bool mismatch = (littleEndian() == 1);
writeChunk('B', 'V', '4', ' ', stream);
- writeDword(version, mismatch, stream);
+ writeDword(bv4StructureVersion, mismatch, stream);
writeFloat(mData.mBV4Tree.mLocalBounds.mCenter.x, mismatch, stream);
writeFloat(mData.mBV4Tree.mLocalBounds.mCenter.y, mismatch, stream);
@@ -1290,16 +1293,19 @@ void BV32TriangleMeshBuilder::createMidPhaseStructure(const PxCookingParams& par
}
meshInterface.releaseRemap();
-
}
-void BV32TriangleMeshBuilder::saveMidPhaseStructure(Gu::BV32Tree* bv32Tree, PxOutputStream& stream)
+void BV32TriangleMeshBuilder::saveMidPhaseStructure(Gu::BV32Tree* bv32Tree, PxOutputStream& stream, bool mismatch)
{
- const PxU32 version = 1;
+ // PT: in version 1 we defined "mismatch" as:
+ // const bool mismatch = (littleEndian() == 1);
+ // i.e. the data was *always* saved to file in big-endian format no matter what.
+ // In version>1 we now do the same as for other structures in the SDK: the data is
+ // exported either as little or big-endian depending on the passed parameter.
+ const PxU32 bv32StructureVersion = 2;
- const bool mismatch = (littleEndian() == 1);
writeChunk('B', 'V', '3', '2', stream);
- writeDword(version, mismatch, stream);
+ writeDword(bv32StructureVersion, mismatch, stream);
writeFloat(bv32Tree->mLocalBounds.mCenter.x, mismatch, stream);
writeFloat(bv32Tree->mLocalBounds.mCenter.y, mismatch, stream);
@@ -1319,8 +1325,7 @@ void BV32TriangleMeshBuilder::saveMidPhaseStructure(Gu::BV32Tree* bv32Tree, PxOu
writeDword(node.mNbNodes, mismatch, stream);
WriteDwordBuffer(node.mData, node.mNbNodes, mismatch, stream);
writeFloatBuffer(&node.mCenter[0].x, nbElements, mismatch, stream);
- writeFloatBuffer(&node.mExtents[0].x, nbElements, mismatch, stream);
-
+ writeFloatBuffer(&node.mExtents[0].x, nbElements, mismatch, stream);
}
}
@@ -1377,12 +1382,20 @@ void RTreeTriangleMeshBuilder::createMidPhaseStructure()
remapTopology(resultPermute.begin());
}
-static void saveRTreeData(PxOutputStream& stream, const RTree& d)
+void RTreeTriangleMeshBuilder::saveMidPhaseStructure(PxOutputStream& stream, bool mismatch) const
{
+ // PT: in version 1 we defined "mismatch" as:
+ // const bool mismatch = (littleEndian() == 1);
+ // i.e. the data was *always* saved to file in big-endian format no matter what.
+ // In version>1 we now do the same as for other structures in the SDK: the data is
+ // exported either as little or big-endian depending on the passed parameter.
+ const PxU32 rtreeStructureVersion = 2;
+
// save the RTree root structure followed immediately by RTreePage pages to an output stream
- const bool mismatch = (littleEndian() == 1);
writeChunk('R', 'T', 'R', 'E', stream);
- writeDword(RTREE_COOK_VERSION, mismatch, stream);
+
+ writeDword(rtreeStructureVersion, mismatch, stream);
+ const RTree& d = mData.mRTree;
writeFloatBuffer(&d.mBoundsMin.x, 4, mismatch, stream);
writeFloatBuffer(&d.mBoundsMax.x, 4, mismatch, stream);
writeFloatBuffer(&d.mInvDiagonal.x, 4, mismatch, stream);
@@ -1405,12 +1418,6 @@ static void saveRTreeData(PxOutputStream& stream, const RTree& d)
}
}
-void RTreeTriangleMeshBuilder::saveMidPhaseStructure(PxOutputStream& stream) const
-{
- // Export RTree
- saveRTreeData(stream, mData.mRTree);
-}
-
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
diff --git a/PhysX_3.4/Source/PhysXCooking/src/mesh/TriangleMeshBuilder.h b/PhysX_3.4/Source/PhysXCooking/src/mesh/TriangleMeshBuilder.h
index 39092b19..be830d8d 100644
--- a/PhysX_3.4/Source/PhysXCooking/src/mesh/TriangleMeshBuilder.h
+++ b/PhysX_3.4/Source/PhysXCooking/src/mesh/TriangleMeshBuilder.h
@@ -51,7 +51,7 @@ namespace physx
// Called by base code when midphase structure should be built
virtual void createMidPhaseStructure() = 0;
// Called by base code when midphase structure should be saved
- virtual void saveMidPhaseStructure(PxOutputStream& stream) const = 0;
+ virtual void saveMidPhaseStructure(PxOutputStream& stream, bool mismatch) const = 0;
// Called by base code when mesh index format has changed and the change should be reflected in midphase structure
virtual void onMeshIndexFormatChange() {}
@@ -64,13 +64,13 @@ namespace physx
void createGRBMidPhaseAndData(const PxU32 originalTriangleCount);
void createGRBData();
- bool loadFromDesc(const PxTriangleMeshDesc&, PxTriangleMeshCookingResult::Enum* condition ,bool validate = false);
+ bool loadFromDesc(const PxTriangleMeshDesc&, PxTriangleMeshCookingResult::Enum* condition, bool validate = false);
bool save(PxOutputStream& stream, bool platformMismatch, const PxCookingParams& params) const;
void checkMeshIndicesSize();
PX_FORCE_INLINE Gu::TriangleMeshData& getMeshData() { return mMeshData; }
protected:
void computeLocalBounds();
- bool importMesh(const PxTriangleMeshDesc& desc, const PxCookingParams& params, PxTriangleMeshCookingResult::Enum* condition ,bool validate = false);
+ bool importMesh(const PxTriangleMeshDesc& desc, const PxCookingParams& params, PxTriangleMeshCookingResult::Enum* condition, bool validate = false);
TriangleMeshBuilder& operator=(const TriangleMeshBuilder&);
Gu::EdgeListBuilder* edgeList;
@@ -87,9 +87,9 @@ namespace physx
RTreeTriangleMeshBuilder(const PxCookingParams& params);
virtual ~RTreeTriangleMeshBuilder();
- virtual PxMeshMidPhase::Enum getMidphaseID() const { return PxMeshMidPhase::eBVH33; }
+ virtual PxMeshMidPhase::Enum getMidphaseID() const { return PxMeshMidPhase::eBVH33; }
virtual void createMidPhaseStructure();
- virtual void saveMidPhaseStructure(PxOutputStream& stream) const;
+ virtual void saveMidPhaseStructure(PxOutputStream& stream, bool mismatch) const;
Gu::RTreeTriangleData mData;
};
@@ -100,19 +100,19 @@ namespace physx
BV4TriangleMeshBuilder(const PxCookingParams& params);
virtual ~BV4TriangleMeshBuilder();
- virtual PxMeshMidPhase::Enum getMidphaseID() const { return PxMeshMidPhase::eBVH34; }
+ virtual PxMeshMidPhase::Enum getMidphaseID() const { return PxMeshMidPhase::eBVH34; }
virtual void createMidPhaseStructure();
- virtual void saveMidPhaseStructure(PxOutputStream& stream) const;
+ virtual void saveMidPhaseStructure(PxOutputStream& stream, bool mismatch) const;
virtual void onMeshIndexFormatChange();
- Gu::BV4TriangleData mData;
+ Gu::BV4TriangleData mData;
};
class BV32TriangleMeshBuilder
{
public:
- static void createMidPhaseStructure(const PxCookingParams& params, Gu::TriangleMeshData& meshData, Gu::BV32Tree& bv32Tree);
- static void saveMidPhaseStructure(Gu::BV32Tree* tree, PxOutputStream& stream);
+ static void createMidPhaseStructure(const PxCookingParams& params, Gu::TriangleMeshData& meshData, Gu::BV32Tree& bv32Tree);
+ static void saveMidPhaseStructure(Gu::BV32Tree* tree, PxOutputStream& stream, bool mismatch);
};
}