Refactor engine to support double-precision vectors

This commit is contained in:
Wojtek Figat
2022-06-13 00:40:32 +02:00
parent f82e370392
commit a881c90b2e
744 changed files with 19062 additions and 12467 deletions

View File

@@ -552,7 +552,7 @@ bool CollisionCooking::CookConvexMesh(CookingInput& input, BytesContainer& outpu
// Init options
PxConvexMeshDesc desc;
desc.points.count = input.VertexCount;
desc.points.stride = sizeof(Vector3);
desc.points.stride = sizeof(Float3);
desc.points.data = input.VertexData;
desc.flags = PxConvexFlag::eCOMPUTE_CONVEX;
if (input.ConvexVertexLimit == 0)
@@ -595,7 +595,7 @@ bool CollisionCooking::CookTriangleMesh(CookingInput& input, BytesContainer& out
// Init options
PxTriangleMeshDesc desc;
desc.points.count = input.VertexCount;
desc.points.stride = sizeof(Vector3);
desc.points.stride = sizeof(Float3);
desc.points.data = input.VertexData;
desc.triangles.count = input.IndexCount / 3;
desc.triangles.stride = 3 * (input.Is16bitIndexData ? sizeof(uint16) : sizeof(uint32));
@@ -1740,7 +1740,7 @@ Vector3 PhysicsBackend::GetRigidDynamicActorCenterOfMass(void* actor)
return P2C(actorPhysX->getCMassLocalPose().p);
}
void PhysicsBackend::SetRigidDynamicActorCenterOfMassOffset(void* actor, const Vector3& value)
void PhysicsBackend::SetRigidDynamicActorCenterOfMassOffset(void* actor, const Float3& value)
{
auto actorPhysX = (PxRigidDynamic*)actor;
auto pose = actorPhysX->getCMassLocalPose();
@@ -2860,7 +2860,7 @@ void* PhysicsBackend::CreateHeightField(byte* data, int32 dataSize)
return heightField;
}
void PhysicsBackend::GetConvexMeshTriangles(void* contextMesh, Array<Vector3, HeapAllocation>& vertexBuffer, Array<int, HeapAllocation>& indexBuffer)
void PhysicsBackend::GetConvexMeshTriangles(void* contextMesh, Array<Float3, HeapAllocation>& vertexBuffer, Array<int, HeapAllocation>& indexBuffer)
{
auto contextMeshPhysX = (PxConvexMesh*)contextMesh;
uint32 numIndices = 0;
@@ -2899,7 +2899,7 @@ void PhysicsBackend::GetConvexMeshTriangles(void* contextMesh, Array<Vector3, He
}
}
void PhysicsBackend::GetTriangleMeshTriangles(void* triangleMesh, Array<Vector3>& vertexBuffer, Array<int32, HeapAllocation>& indexBuffer)
void PhysicsBackend::GetTriangleMeshTriangles(void* triangleMesh, Array<Float3>& vertexBuffer, Array<int32, HeapAllocation>& indexBuffer)
{
auto triangleMeshPhysX = (PxTriangleMesh*)triangleMesh;
uint32 numVertices = triangleMeshPhysX->getNbVertices();

View File

@@ -64,52 +64,95 @@ using namespace physx;
#define RELEASE_PHYSX(x) if(x) { (x)->release(); x = nullptr; }
inline PxVec2& C2P(const Vector2& v)
#if USE_LARGE_WORLDS
inline PxVec2 C2P(const Vector2& v)
{
return PxVec2((float)v.X, (float)v.Y);
}
inline PxVec3 C2P(const Vector3& v)
{
return PxVec3((float)v.X, (float)v.Y, (float)v.Z);
}
inline PxVec4 C2P(const Vector4& v)
{
return PxVec4((float)v.X, (float)v.Y, (float)v.Z, (float)v.W);
}
inline PxBounds3 C2P(const BoundingBox& v)
{
return PxBounds3(C2P(v.Minimum), C2P(v.Maximum));
}
inline Vector2 P2C(const PxVec2& v)
{
return Vector2(v.x, v.y);
}
inline Vector3 P2C(const PxVec3& v)
{
return Vector3(v.x, v.y, v.z);
}
inline Vector4 P2C(const PxVec4& v)
{
return Vector4(v.x, v.y, v.z, v.w);
}
inline BoundingBox P2C(const PxBounds3& v)
{
return BoundingBox(P2C(v.minimum), P2C(v.maximum));
}
inline Vector3 P2C(const PxExtendedVec3& v)
{
#ifdef PX_BIG_WORLDS
return *(Vector3*)&v;
#else
return Vector3(v.x, v.y, v.z);
#endif
}
#else
inline PxVec2 C2P(const Vector2& v)
{
return *(PxVec2*)&v;
}
inline PxVec3& C2P(const Vector3& v)
inline PxVec3 C2P(const Vector3& v)
{
return *(PxVec3*)&v;
}
inline PxVec4& C2P(const Vector4& v)
inline PxVec4 C2P(const Vector4& v)
{
return *(PxVec4*)&v;
}
inline PxQuat& C2P(const Quaternion& v)
{
return *(PxQuat*)&v;
}
inline PxBounds3& C2P(const BoundingBox& v)
inline PxBounds3 C2P(const BoundingBox& v)
{
return *(PxBounds3*)&v;
}
inline Vector2& P2C(const PxVec2& v)
inline Vector2 P2C(const PxVec2& v)
{
return *(Vector2*)&v;
}
inline Vector3& P2C(const PxVec3& v)
inline Vector3 P2C(const PxVec3& v)
{
return *(Vector3*)&v;
}
inline Vector4& P2C(const PxVec4& v)
inline Vector4 P2C(const PxVec4& v)
{
return *(Vector4*)&v;
}
inline Quaternion& P2C(const PxQuat& v)
{
return *(Quaternion*)&v;
}
inline BoundingBox& P2C(const PxBounds3& v)
inline BoundingBox P2C(const PxBounds3& v)
{
return *(BoundingBox*)&v;
}
@@ -123,6 +166,18 @@ inline Vector3 P2C(const PxExtendedVec3& v)
#endif
}
#endif
inline PxQuat& C2P(const Quaternion& v)
{
return *(PxQuat*)&v;
}
inline Quaternion& P2C(const PxQuat& v)
{
return *(Quaternion*)&v;
}
inline float M2ToCm2(float v)
{
return v * (100.0f * 100.0f);