Hello guys I have been trying to get the vertices of static meshes uses a snippet the Rama had posted but it seem that I can’t access PxTriangleMesh.h properly which seems to caused a few undefines. I have include PhsyX to the build.cs and everything seems fine but I think it may have to do with including “PhysicsEngine/BodySetup.h”. This is a really annoying issue can you guys help me out?
#include "Alpha.h"
#include "ObjectDebug.h"
#define PX_WINDOWS 1
//~~~ PhysX ~~~
#include "PhysicsEngine/BodySetup.h"
#include "ThirdParty/PhysX/PhysX-3.3/include/geometry/PxTriangleMesh.h"
#include "ThirdParty/PhysX/PhysX-3.3/Include/foundation/PxSimpleTypes.h"
#include "PhysicsPublic.h"
#include "PhysXIncludes.h"
//~~~~~~~~~~
bool AObjectDebug::GetStaticMeshVertexLocations(UStaticMeshComponent* Comp, TArray<FVector>& VertexPositions)
{
if (!Comp)
return false;
if (!Comp->IsValidLowLevel())
return false;
//Component Transform
FTransform RV_Transform = Comp->GetComponentTransform();
//Body Setup valid?
UBodySetup* BodySetup = Comp->GetBodySetup();
if (!BodySetup || !BodySetup->IsValidLowLevel())
return false;
//array as of 4.9
for (PxTriangleMesh* EachTriMesh : BodySetup->TriMeshes)
{
if (!EachTriMesh)
return false;
//Number of vertices
PxU32 VertexCount = EachTriMesh->getNbVertices();
//Vertex array
const PxVec3* Vertices = EachTriMesh->getVertices();
//For each vertex, transform the position to match the component Transform
for (PxU32 v = 0; v < VertexCount; v++)
{
VertexPositions.Add(RV_Transform.TransformPosition(P2UVector(Vertices[v])));
}
}
return true;
}