73 lines
1.8 KiB
C++
73 lines
1.8 KiB
C++
#pragma once
|
|
#include <physx/PxPhysics.h>
|
|
//#include <physx/PxFoundation.h>
|
|
#include <physx/PxConfig.h>
|
|
#include <physx/PxPhysicsAPI.h>
|
|
#include <physx/PxFiltering.h>
|
|
#include "tsr.hpp"
|
|
#include "assets.hpp"
|
|
#include "renderer.hpp"
|
|
|
|
namespace TSR {
|
|
using namespace physx;
|
|
|
|
class Physics {
|
|
|
|
static PxDefaultErrorCallback s_default_error_cb;
|
|
static PxDefaultAllocator s_default_allocator_cb;
|
|
|
|
static PxFoundation* s_foundation;
|
|
static PxPhysics* s_physics;
|
|
//static PxCooking* s_cooking;
|
|
static PxPvd* s_pvd;
|
|
|
|
static PxTolerancesScale s_scale;
|
|
static PxCookingParams s_cooking_params;
|
|
public:
|
|
static void Init();
|
|
static void Close();
|
|
|
|
static PxPhysics* GetPhysics() { return s_physics; }
|
|
static const PxCookingParams& GetCookingParams() { return s_cooking_params; }
|
|
//static PxCooking* GetCooking() { return s_cooking; }
|
|
};
|
|
|
|
class PhysicsScene {
|
|
PxDefaultCpuDispatcher* m_cpu_dispatcher;
|
|
PxScene* m_scene;
|
|
PxControllerManager* m_cct_manager;
|
|
|
|
public:
|
|
PhysicsScene();
|
|
~PhysicsScene();
|
|
|
|
PxScene* GetScene() { return m_scene; }
|
|
PxControllerManager* GetCCTManager() { return m_cct_manager; }
|
|
|
|
void StepSimulation(float time);
|
|
|
|
void EnableDebug(bool enable);
|
|
void DrawDebug(Renderer& renderer);
|
|
};
|
|
|
|
class PhysicsMaterial : public Asset {
|
|
PxMaterial* m_material;
|
|
|
|
public:
|
|
PhysicsMaterial(const std::string& path);
|
|
~PhysicsMaterial();
|
|
|
|
PxMaterial* Get() const { return m_material; }
|
|
};
|
|
|
|
class PhysicsTriangleMesh : public Asset {
|
|
PxTriangleMesh* m_mesh;
|
|
|
|
public:
|
|
PhysicsTriangleMesh(const std::string& path);
|
|
~PhysicsTriangleMesh();
|
|
|
|
PxTriangleMesh* Get() const { return m_mesh; }
|
|
};
|
|
|
|
} |