aboutsummaryrefslogtreecommitdiff
path: root/PhysX_3.4/Source/PhysXCooking/src
diff options
context:
space:
mode:
authorsschirm <[email protected]>2016-12-23 14:20:36 +0100
committersschirm <[email protected]>2016-12-23 14:56:17 +0100
commitef6937e69e8ee3f409cf9d460d5ad300a65d5924 (patch)
tree710426e8daa605551ce3f34b581897011101c30f /PhysX_3.4/Source/PhysXCooking/src
parentInitial commit: (diff)
downloadphysx-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/PhysXCooking/src')
-rw-r--r--PhysX_3.4/Source/PhysXCooking/src/Cooking.cpp5
-rw-r--r--PhysX_3.4/Source/PhysXCooking/src/MeshCleaner.cpp3
-rw-r--r--PhysX_3.4/Source/PhysXCooking/src/convex/ConvexHullBuilder.cpp11
-rw-r--r--PhysX_3.4/Source/PhysXCooking/src/convex/ConvexHullBuilder.h2
-rw-r--r--PhysX_3.4/Source/PhysXCooking/src/convex/ConvexMeshBuilder.cpp4
-rw-r--r--PhysX_3.4/Source/PhysXCooking/src/convex/ConvexMeshBuilder.h2
-rw-r--r--PhysX_3.4/Source/PhysXCooking/src/mesh/RTreeCooking.cpp7
7 files changed, 22 insertions, 12 deletions
diff --git a/PhysX_3.4/Source/PhysXCooking/src/Cooking.cpp b/PhysX_3.4/Source/PhysXCooking/src/Cooking.cpp
index e793b48f..5bd1aadd 100644
--- a/PhysX_3.4/Source/PhysXCooking/src/Cooking.cpp
+++ b/PhysX_3.4/Source/PhysXCooking/src/Cooking.cpp
@@ -335,8 +335,10 @@ PxConvexMesh* Cooking::createConvexMesh(const PxConvexMeshDesc& desc, PxPhysicsI
}
// copy the constructed data into the new mesh
+
+ PxU32 nb = 0;
Gu::ConvexHullData meshData;
- meshBuilder.copy(meshData);
+ meshBuilder.copy(meshData, nb);
// insert into physics
Gu::ConvexMesh* convexMesh = static_cast<Gu::ConvexMesh*>(insertionCallback.buildObjectFromData(PxConcreteType::eCONVEX_MESH, &meshData));
@@ -347,6 +349,7 @@ PxConvexMesh* Cooking::createConvexMesh(const PxConvexMeshDesc& desc, PxPhysicsI
return NULL;
}
+ convexMesh->setNb(nb);
convexMesh->setMass(meshBuilder.getMass());
convexMesh->setInertia(meshBuilder.getInertia());
if(meshBuilder.getBigConvexData())
diff --git a/PhysX_3.4/Source/PhysXCooking/src/MeshCleaner.cpp b/PhysX_3.4/Source/PhysXCooking/src/MeshCleaner.cpp
index 0f4b6f67..9314e09d 100644
--- a/PhysX_3.4/Source/PhysXCooking/src/MeshCleaner.cpp
+++ b/PhysX_3.4/Source/PhysXCooking/src/MeshCleaner.cpp
@@ -28,6 +28,7 @@
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "foundation/PxVec3.h"
+#include "foundation/PxMemory.h"
#include "MeshCleaner.h"
#include "PsAllocator.h"
#include "PsBitUtils.h"
@@ -98,7 +99,7 @@ MeshCleaner::MeshCleaner(PxU32 nbVerts, const PxVec3* srcVerts, PxU32 nbTris, co
}
else
{
- memcpy(cleanVerts, srcVerts, nbVerts*sizeof(PxVec3));
+ PxMemCopy(cleanVerts, srcVerts, nbVerts*sizeof(PxVec3));
}
const PxU32 maxNbElems = PxMax(nbTris, nbVerts);
diff --git a/PhysX_3.4/Source/PhysXCooking/src/convex/ConvexHullBuilder.cpp b/PhysX_3.4/Source/PhysXCooking/src/convex/ConvexHullBuilder.cpp
index 3b9c3ac6..c9c8c678 100644
--- a/PhysX_3.4/Source/PhysXCooking/src/convex/ConvexHullBuilder.cpp
+++ b/PhysX_3.4/Source/PhysXCooking/src/convex/ConvexHullBuilder.cpp
@@ -422,16 +422,21 @@ bool ConvexHullBuilder::save(PxOutputStream& stream, bool platformMismatch) cons
}
//////////////////////////////////////////////////////////////////////////
-bool ConvexHullBuilder::copy(ConvexHullData& hullData)
+bool ConvexHullBuilder::copy(ConvexHullData& hullData, PxU32& mNb)
{
// set the numbers
hullData.mNbHullVertices = mHull->mNbHullVertices;
- hullData.mNbEdges = mHull->mNbEdges;
+ PxU16 hasGRBData = PxU16(mBuildGRBData);
+ hasGRBData = PxU16(hasGRBData << 15);
+ PX_ASSERT(mHull->mNbEdges <((1 << 15) - 1));
+ hullData.mNbEdges = PxU16(mHull->mNbEdges | hasGRBData);;
hullData.mNbPolygons = Ps::to8(computeNbPolygons());
PxU32 nb = 0;
for (PxU32 i = 0; i < mHull->mNbPolygons; i++)
nb += mHullDataPolygons[i].mNbVerts;
+ mNb = nb;
+
PxU32 bytesNeeded = Gu::computeBufferSize(hullData, nb);
// allocate the memory first.
@@ -462,7 +467,7 @@ bool ConvexHullBuilder::copy(ConvexHullData& hullData)
PxMemCopy(hullData.mPolygons, mHullDataPolygons , hullData.mNbPolygons*sizeof(Gu::HullPolygonData));
PxMemCopy(dataVertexData8, mHullDataVertexData8, nb);
PxMemCopy(dataFacesByEdges8,mHullDataFacesByEdges8, PxU32(mHull->mNbEdges * 2));
- if (hullData.mNbEdges.isBitSet())
+ if (mBuildGRBData)
PxMemCopy(dataEdges, mEdges, PxU32(mHull->mNbEdges * 2) * sizeof(PxU16));
PxMemCopy(dataFacesByVertices8, mHullDataFacesByVertices8, PxU32(mHull->mNbHullVertices * 3));
return true;
diff --git a/PhysX_3.4/Source/PhysXCooking/src/convex/ConvexHullBuilder.h b/PhysX_3.4/Source/PhysXCooking/src/convex/ConvexHullBuilder.h
index a3d57202..a00c0506 100644
--- a/PhysX_3.4/Source/PhysXCooking/src/convex/ConvexHullBuilder.h
+++ b/PhysX_3.4/Source/PhysXCooking/src/convex/ConvexHullBuilder.h
@@ -60,7 +60,7 @@ namespace physx
const PxHullPolygon* hullPolygons, PxU32 gaussMapVertexLimit, bool doValidation = true, bool userPolygons = false);
bool save(PxOutputStream& stream, bool platformMismatch) const;
- bool copy(Gu::ConvexHullData& hullData);
+ bool copy(Gu::ConvexHullData& hullData, PxU32& nb);
bool createEdgeList(bool doValidation, PxU32 nbEdges, bool prepareBigHullData);
bool checkHullPolygons() const;
diff --git a/PhysX_3.4/Source/PhysXCooking/src/convex/ConvexMeshBuilder.cpp b/PhysX_3.4/Source/PhysXCooking/src/convex/ConvexMeshBuilder.cpp
index 5fb356c3..540d838d 100644
--- a/PhysX_3.4/Source/PhysXCooking/src/convex/ConvexMeshBuilder.cpp
+++ b/PhysX_3.4/Source/PhysXCooking/src/convex/ConvexMeshBuilder.cpp
@@ -154,10 +154,10 @@ bool ConvexMeshBuilder::save(PxOutputStream& stream, bool platformMismatch) cons
//////////////////////////////////////////////////////////////////////////
// instead of saving the data into stream, we copy the mesh data
// into internal Gu::ConvexMesh.
-bool ConvexMeshBuilder::copy(Gu::ConvexHullData& hullData)
+bool ConvexMeshBuilder::copy(Gu::ConvexHullData& hullData, PxU32& nb)
{
// hull builder data copy
- hullBuilder.copy(hullData);
+ hullBuilder.copy(hullData, nb);
// mass props
hullData.mAABB = mHullData.mAABB;
diff --git a/PhysX_3.4/Source/PhysXCooking/src/convex/ConvexMeshBuilder.h b/PhysX_3.4/Source/PhysXCooking/src/convex/ConvexMeshBuilder.h
index 57e0ca97..9d584c95 100644
--- a/PhysX_3.4/Source/PhysXCooking/src/convex/ConvexMeshBuilder.h
+++ b/PhysX_3.4/Source/PhysXCooking/src/convex/ConvexMeshBuilder.h
@@ -53,7 +53,7 @@ namespace physx
bool save(PxOutputStream& stream, bool platformMismatch) const;
// copy the convex mesh into internal convex mesh, which can be directly used then
- bool copy(Gu::ConvexHullData& convexData);
+ bool copy(Gu::ConvexHullData& convexData, PxU32& nb);
// loads the convex mesh from given polygons
bool loadConvexHull(const PxConvexMeshDesc&, PxU32 gaussMapVertexLimit, bool userPolygons);
diff --git a/PhysX_3.4/Source/PhysXCooking/src/mesh/RTreeCooking.cpp b/PhysX_3.4/Source/PhysXCooking/src/mesh/RTreeCooking.cpp
index 08ab1a1b..faa56b70 100644
--- a/PhysX_3.4/Source/PhysXCooking/src/mesh/RTreeCooking.cpp
+++ b/PhysX_3.4/Source/PhysXCooking/src/mesh/RTreeCooking.cpp
@@ -28,6 +28,7 @@
// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
#include "foundation/PxBounds3.h"
+#include "foundation/PxMemory.h"
#include "CmPhysXCommon.h"
#include "RTreeCooking.h"
#include "PsSort.h"
@@ -748,9 +749,9 @@ static void buildFromBounds(
if(hint == PxMeshCookingHint::eSIM_PERFORMANCE) // use high quality SAH build
{
Array<PxU32> xRanks(numBounds), yRanks(numBounds), zRanks(numBounds), xOrder(numBounds), yOrder(numBounds), zOrder(numBounds);
- memcpy(xOrder.begin(), permute.begin(), sizeof(xOrder[0])*numBounds);
- memcpy(yOrder.begin(), permute.begin(), sizeof(yOrder[0])*numBounds);
- memcpy(zOrder.begin(), permute.begin(), sizeof(zOrder[0])*numBounds);
+ PxMemCopy(xOrder.begin(), permute.begin(), sizeof(xOrder[0])*numBounds);
+ PxMemCopy(yOrder.begin(), permute.begin(), sizeof(yOrder[0])*numBounds);
+ PxMemCopy(zOrder.begin(), permute.begin(), sizeof(zOrder[0])*numBounds);
// sort by shuffling the permutation, precompute sorted ranks for x,y,z-orders
Ps::sort(xOrder.begin(), xOrder.size(), SortBoundsPredicate(0, allBounds));
for(PxU32 i = 0; i < numBounds; i++) xRanks[xOrder[i]] = i;