physx 5.x fix
This commit is contained in:
parent
a168f51fbd
commit
48405abaff
@ -11,8 +11,10 @@ PxDefaultAllocator Physics::s_default_allocator_cb;
|
|||||||
|
|
||||||
PxFoundation* Physics::s_foundation = nullptr;
|
PxFoundation* Physics::s_foundation = nullptr;
|
||||||
PxPhysics* Physics::s_physics = nullptr;
|
PxPhysics* Physics::s_physics = nullptr;
|
||||||
PxCooking* Physics::s_cooking = nullptr;
|
//PxCooking* Physics::s_cooking = nullptr;
|
||||||
PxPvd* Physics::s_pvd = nullptr;
|
PxPvd* Physics::s_pvd = nullptr;
|
||||||
|
PxTolerancesScale Physics::s_scale;
|
||||||
|
PxCookingParams Physics::s_cooking_params(s_scale);
|
||||||
|
|
||||||
void Physics::Init() {
|
void Physics::Init() {
|
||||||
// PHYSX init
|
// PHYSX init
|
||||||
@ -29,29 +31,36 @@ void Physics::Init() {
|
|||||||
//PxPvdTransport* transport = PxDefaultPvdSocketTransportCreate("localhost", 5425, 10);
|
//PxPvdTransport* transport = PxDefaultPvdSocketTransportCreate("localhost", 5425, 10);
|
||||||
//mPvd->connect(*transport, PxPvdInstrumentationFlag::eALL);
|
//mPvd->connect(*transport, PxPvdInstrumentationFlag::eALL);
|
||||||
|
|
||||||
PxTolerancesScale scale;
|
//PxTolerancesScale scale;
|
||||||
|
|
||||||
s_physics = PxCreatePhysics(PX_PHYSICS_VERSION, *s_foundation, scale, recordMemoryAllocations, nullptr);
|
s_physics = PxCreatePhysics(PX_PHYSICS_VERSION, *s_foundation, s_scale, recordMemoryAllocations, nullptr);
|
||||||
if (!s_physics)
|
if (!s_physics)
|
||||||
Throw("(PX) PxCreatePhysics failed!");
|
Throw("(PX) PxCreatePhysics failed!");
|
||||||
|
|
||||||
s_cooking = PxCreateCooking(PX_PHYSICS_VERSION, *s_foundation, PxCookingParams(scale));
|
//s_cooking = PxCreateCooking(PX_PHYSICS_VERSION, *s_foundation, PxCookingParams(scale));
|
||||||
if (!s_cooking)
|
//if (!s_cooking)
|
||||||
Throw("(PX) PxCreateCooking failed!");
|
// Throw("(PX) PxCreateCooking failed!");
|
||||||
|
|
||||||
PxCookingParams params(scale);
|
//PxCookingParams params(scale);
|
||||||
s_cooking->setParams(params);
|
//s_cooking->setParams(params);
|
||||||
|
|
||||||
|
PxInitVehicleSDK(*s_physics);
|
||||||
|
PxVehicleSetBasisVectors(PxVec3(0, 1, 0), PxVec3(0, 0, 1));
|
||||||
|
PxVehicleSetUpdateMode(PxVehicleUpdateMode::eVELOCITY_CHANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Physics::Close() {
|
void Physics::Close() {
|
||||||
if (s_cooking)
|
PxCloseVehicleSDK();
|
||||||
s_cooking->release();
|
|
||||||
|
//if (s_cooking)
|
||||||
|
// s_cooking->release();
|
||||||
|
|
||||||
if (s_physics)
|
if (s_physics)
|
||||||
s_physics->release();
|
s_physics->release();
|
||||||
|
|
||||||
if (s_foundation)
|
if (s_foundation)
|
||||||
s_foundation->release();
|
s_foundation->release();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PhysicsScene::PhysicsScene() {
|
PhysicsScene::PhysicsScene() {
|
||||||
@ -178,14 +187,24 @@ PhysicsTriangleMesh::PhysicsTriangleMesh(const std::string& path) {
|
|||||||
mesh_desc.triangles.stride = 3 * sizeof(PxU32);
|
mesh_desc.triangles.stride = 3 * sizeof(PxU32);
|
||||||
mesh_desc.triangles.data = mia3.indices_ptr;
|
mesh_desc.triangles.data = mia3.indices_ptr;
|
||||||
|
|
||||||
#ifdef _DEBUG
|
//#ifdef _DEBUG
|
||||||
// mesh should be validated before cooked without the mesh cleaning
|
// // mesh should be validated before cooked without the mesh cleaning
|
||||||
bool res = Physics::GetCooking()->validateTriangleMesh(mesh_desc);
|
// bool res = Physics::GetCooking()->validateTriangleMesh(mesh_desc);
|
||||||
PX_ASSERT(res);
|
// PX_ASSERT(res);
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
m_mesh = Physics::GetCooking()->createTriangleMesh(mesh_desc, Physics::GetPhysics()->getPhysicsInsertionCallback());
|
//m_mesh = Physics::GetCooking()->createTriangleMesh(mesh_desc, Physics::GetPhysics()->getPhysicsInsertionCallback());
|
||||||
}
|
//PxCookTriangleMesh(Physics::GetCookingParams(), mesh_desc, Physics::GetPhysics()->getPhysicsInsertionCallback());
|
||||||
|
|
||||||
|
PxDefaultMemoryOutputStream writeBuffer;
|
||||||
|
PxTriangleMeshCookingResult::Enum result;
|
||||||
|
bool status = PxCookTriangleMesh(Physics::GetCookingParams(), mesh_desc, writeBuffer, &result);
|
||||||
|
if (!status)
|
||||||
|
Throw("Cant cook triangle mesh");
|
||||||
|
|
||||||
|
PxDefaultMemoryInputData readBuffer(writeBuffer.getData(), writeBuffer.getSize());
|
||||||
|
m_mesh = Physics::GetPhysics()->createTriangleMesh(readBuffer);
|
||||||
|
};
|
||||||
|
|
||||||
PhysicsTriangleMesh::~PhysicsTriangleMesh() {
|
PhysicsTriangleMesh::~PhysicsTriangleMesh() {
|
||||||
m_mesh->release();
|
m_mesh->release();
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <PxPhysics.h>
|
#include <physx/PxPhysics.h>
|
||||||
#include <PxFoundation.h>
|
//#include <physx/PxFoundation.h>
|
||||||
#include <PxConfig.h>
|
#include <physx/PxConfig.h>
|
||||||
#include <PxPhysicsAPI.h>
|
#include <physx/PxPhysicsAPI.h>
|
||||||
#include <PxFiltering.h>
|
#include <physx/PxFiltering.h>
|
||||||
#include "tsr.hpp"
|
#include "tsr.hpp"
|
||||||
#include "assets.hpp"
|
#include "assets.hpp"
|
||||||
#include "renderer.hpp"
|
#include "renderer.hpp"
|
||||||
@ -18,14 +18,18 @@ namespace TSR {
|
|||||||
|
|
||||||
static PxFoundation* s_foundation;
|
static PxFoundation* s_foundation;
|
||||||
static PxPhysics* s_physics;
|
static PxPhysics* s_physics;
|
||||||
static PxCooking* s_cooking;
|
//static PxCooking* s_cooking;
|
||||||
static PxPvd* s_pvd;
|
static PxPvd* s_pvd;
|
||||||
|
|
||||||
|
static PxTolerancesScale s_scale;
|
||||||
|
static PxCookingParams s_cooking_params;
|
||||||
public:
|
public:
|
||||||
static void Init();
|
static void Init();
|
||||||
static void Close();
|
static void Close();
|
||||||
|
|
||||||
static PxPhysics* GetPhysics() { return s_physics; }
|
static PxPhysics* GetPhysics() { return s_physics; }
|
||||||
static PxCooking* GetCooking() { return s_cooking; }
|
static const PxCookingParams& GetCookingParams() { return s_cooking_params; }
|
||||||
|
//static PxCooking* GetCooking() { return s_cooking; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class PhysicsScene {
|
class PhysicsScene {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user