2023-08-11 15:35:45 +08:00
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
#define EXPORT_API __declspec(dllexport)
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
//<2F><>c# ʹ<><CAB9> <20><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>dllimport
|
|
|
|
|
|
|
|
|
|
#ifdef __linux__
|
|
|
|
|
#define EXPORT_API __attribute__((visibility ("default")))
|
|
|
|
|
#endif
|
|
|
|
|
|
2023-08-22 18:25:34 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define CALL _cdecl
|
2023-08-11 10:55:58 +08:00
|
|
|
|
|
|
|
|
|
#include "physxABIStruct.hpp";
|
2023-08-22 18:25:34 +08:00
|
|
|
|
|
2023-08-11 10:55:58 +08:00
|
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
|
{
|
2023-08-22 18:25:34 +08:00
|
|
|
|
physx::PxDefaultAllocator gAllocator;
|
|
|
|
|
physx::PxDefaultErrorCallback gErrorCallback;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EXPORT_API physx_PxFoundation_Pod* CALL physx_create_foundation()
|
2023-08-11 10:55:58 +08:00
|
|
|
|
{
|
2023-08-22 18:25:34 +08:00
|
|
|
|
physx::PxFoundation* return_val = PxCreateFoundation(PX_PHYSICS_VERSION, gAllocator, gErrorCallback);
|
|
|
|
|
auto return_val_pod = reinterpret_cast<physx_PxFoundation_Pod*>(return_val);
|
|
|
|
|
return return_val_pod;
|
2023-08-11 10:55:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//// fixme[tolsson]: this might be iffy on Windows with DLLs if we have multiple packages
|
|
|
|
|
//// linking against the raw interface
|
|
|
|
|
//physx::PxAllocatorCallback* CALL get_default_allocator()
|
|
|
|
|
//{
|
|
|
|
|
// return &gAllocator;
|
|
|
|
|
//}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API physx_PxPvd_Pod* CALL phys_PxCreatePvd(physx_PxFoundation_Pod* foundation_pod) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxFoundation& foundation = reinterpret_cast<physx::PxFoundation&>(*foundation_pod);
|
2023-08-22 18:25:34 +08:00
|
|
|
|
physx::PxPvd* return_val = nullptr;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return_val = PxCreatePvd(foundation);
|
|
|
|
|
|
|
|
|
|
auto return_val_pod = reinterpret_cast<physx_PxPvd_Pod*>(return_val);
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
catch (const std::exception&)
|
|
|
|
|
{
|
|
|
|
|
if (return_val == nullptr)
|
|
|
|
|
{
|
|
|
|
|
printf("hello world");
|
|
|
|
|
}
|
|
|
|
|
printf("phys_PxCreatePvd error\n");
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 10:55:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-08-22 18:25:34 +08:00
|
|
|
|
EXPORT_API physx_PxPhysics_Pod* CALL physx_create_physics(physx_PxFoundation_Pod* foundation)
|
|
|
|
|
{
|
|
|
|
|
physx::PxFoundation& foundation1 = reinterpret_cast<physx::PxFoundation&>(*foundation);
|
|
|
|
|
physx::PxPhysics* return_val = PxCreatePhysics(PX_PHYSICS_VERSION, foundation1, physx::PxTolerancesScale(), true, nullptr, nullptr);
|
2023-08-11 10:55:58 +08:00
|
|
|
|
auto return_val_pod = reinterpret_cast<physx_PxPhysics_Pod*>(return_val);
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-22 18:25:34 +08:00
|
|
|
|
EXPORT_API physx_PxPhysics_Pod* CALL phys_PxCreatePhysics(uint32_t version, physx_PxFoundation_Pod* foundation_pod, physx_PxTolerancesScale_Pod const* scale_pod, bool trackOutstandingAllocations, physx_PxPvd_Pod* pvd_pod, physx_PxOmniPvd_Pod* omniPvd_pod) {
|
|
|
|
|
|
|
|
|
|
physx::PxFoundation& foundation = reinterpret_cast<physx::PxFoundation&>(*foundation_pod);
|
|
|
|
|
physx::PxTolerancesScale const& scale = reinterpret_cast<physx::PxTolerancesScale const&>(*scale_pod);
|
|
|
|
|
physx::PxPvd* pvd = reinterpret_cast<physx::PxPvd*>(pvd_pod);
|
|
|
|
|
physx::PxOmniPvd* omniPvd = reinterpret_cast<physx::PxOmniPvd*>(omniPvd_pod);
|
|
|
|
|
physx::PxPhysics* return_val = PxCreatePhysics(version, foundation, scale, trackOutstandingAllocations, pvd, omniPvd);
|
|
|
|
|
auto return_val_pod = reinterpret_cast<physx_PxPhysics_Pod*>(return_val);
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
//return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 10:55:58 +08:00
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API physx_PxDefaultCpuDispatcher_Pod* CALL phys_PxDefaultCpuDispatcherCreate(uint32_t numThreads, uint32_t* affinityMasks, int32_t mode_pod, uint32_t yieldProcessorCount) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
auto mode = static_cast<physx::PxDefaultCpuDispatcherWaitForWorkMode::Enum>(mode_pod);
|
|
|
|
|
physx::PxDefaultCpuDispatcher* return_val = PxDefaultCpuDispatcherCreate(numThreads, affinityMasks, mode, yieldProcessorCount);
|
|
|
|
|
auto return_val_pod = reinterpret_cast<physx_PxDefaultCpuDispatcher_Pod*>(return_val);
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API physx_PxMaterial_Pod* CALL PxPhysics_createMaterial_mut(physx_PxPhysics_Pod* self__pod, float staticFriction, float dynamicFriction, float restitution) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxPhysics* self_ = reinterpret_cast<physx::PxPhysics*>(self__pod);
|
|
|
|
|
physx::PxMaterial* return_val = self_->createMaterial(staticFriction, dynamicFriction, restitution);
|
|
|
|
|
auto return_val_pod = reinterpret_cast<physx_PxMaterial_Pod*>(return_val);
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API physx_PxPvdTransport_Pod* CALL phys_PxDefaultPvdSocketTransportCreate(char const* host, int32_t port, uint32_t timeoutInMilliseconds) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxPvdTransport* return_val = physx::PxDefaultPvdSocketTransportCreate(host, port, timeoutInMilliseconds);
|
|
|
|
|
auto return_val_pod = reinterpret_cast<physx_PxPvdTransport_Pod*>(return_val);
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API bool CALL PxPvd_connect_mut(physx_PxPvd_Pod* self__pod, physx_PxPvdTransport_Pod* transport_pod, uint8_t flags_pod) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxPvd* self_ = reinterpret_cast<physx::PxPvd*>(self__pod);
|
|
|
|
|
physx::PxPvdTransport& transport = reinterpret_cast<physx::PxPvdTransport&>(*transport_pod);
|
|
|
|
|
auto flags = physx::PxPvdInstrumentationFlags(flags_pod);
|
|
|
|
|
bool return_val = self_->connect(transport, flags);
|
|
|
|
|
return return_val;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API physx_PxTolerancesScale_Pod const* CALL PxPhysics_getTolerancesScale(physx_PxPhysics_Pod const* self__pod) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxPhysics const* self_ = reinterpret_cast<physx::PxPhysics const*>(self__pod);
|
|
|
|
|
physx::PxTolerancesScale const& return_val = self_->getTolerancesScale();
|
|
|
|
|
auto return_val_pod = reinterpret_cast<physx_PxTolerancesScale_Pod const*>(&return_val);
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API physx_PxSceneDesc_Pod CALL PxSceneDesc_new(physx_PxTolerancesScale_Pod const* scale_pod) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxTolerancesScale const& scale = reinterpret_cast<physx::PxTolerancesScale const&>(*scale_pod);
|
|
|
|
|
physx::PxSceneDesc return_val(scale);
|
|
|
|
|
physx_PxSceneDesc_Pod return_val_pod;
|
|
|
|
|
memcpy(&return_val_pod, &return_val, sizeof(return_val_pod));
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API physx_PxScene_Pod* CALL PxPhysics_createScene_mut(physx_PxPhysics_Pod* self__pod, physx_PxSceneDesc_Pod const* sceneDesc_pod) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxPhysics* self_ = reinterpret_cast<physx::PxPhysics*>(self__pod);
|
|
|
|
|
physx::PxSceneDesc const& sceneDesc = reinterpret_cast<physx::PxSceneDesc const&>(*sceneDesc_pod);
|
|
|
|
|
physx::PxScene* return_val = self_->createScene(sceneDesc);
|
|
|
|
|
auto return_val_pod = reinterpret_cast<physx_PxScene_Pod*>(return_val);
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API bool CALL PxScene_addActor_mut(physx_PxScene_Pod* self__pod, physx_PxActor_Pod* actor_pod, physx_PxBVH_Pod const* bvh_pod) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxScene* self_ = reinterpret_cast<physx::PxScene*>(self__pod);
|
|
|
|
|
physx::PxActor& actor = reinterpret_cast<physx::PxActor&>(*actor_pod);
|
|
|
|
|
physx::PxBVH const* bvh = reinterpret_cast<physx::PxBVH const*>(bvh_pod);
|
|
|
|
|
bool return_val = self_->addActor(actor, bvh);
|
|
|
|
|
return return_val;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API physx_PxSphereGeometry_Pod CALL PxSphereGeometry_new(float ir) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxSphereGeometry return_val(ir);
|
|
|
|
|
physx_PxSphereGeometry_Pod return_val_pod;
|
2023-08-22 18:25:34 +08:00
|
|
|
|
|
2023-08-11 10:55:58 +08:00
|
|
|
|
memcpy(&return_val_pod, &return_val, sizeof(return_val_pod));
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-22 18:25:34 +08:00
|
|
|
|
EXPORT_API physx_PxSphereGeometry_Pod CALL PxSphereGeometry_new_pointer(float ir) {
|
|
|
|
|
physx::PxSphereGeometry return_val(ir);
|
|
|
|
|
physx_PxSphereGeometry_Pod return_val_pod;
|
|
|
|
|
|
|
|
|
|
memcpy(&return_val_pod, &return_val, sizeof(return_val_pod));
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API bool CALL PxSphereGeometry_isValid(physx_PxSphereGeometry_Pod const* self__pod) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxSphereGeometry const* self_ = reinterpret_cast<physx::PxSphereGeometry const*>(self__pod);
|
|
|
|
|
bool return_val = self_->isValid();
|
|
|
|
|
return return_val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API void CALL PxScene_lockWrite_mut(physx_PxScene_Pod* self__pod, char const* file, uint32_t line) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxScene* self_ = reinterpret_cast<physx::PxScene*>(self__pod);
|
|
|
|
|
self_->lockWrite(file, line);
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API void CALL PxScene_unlockWrite_mut(physx_PxScene_Pod* self__pod) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxScene* self_ = reinterpret_cast<physx::PxScene*>(self__pod);
|
|
|
|
|
self_->unlockWrite();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API physx_PxTransform_Pod CALL PxTransform_new_2(int32_t anon_param0_pod) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
auto anon_param0 = static_cast<physx::PxIDENTITY>(anon_param0_pod);
|
|
|
|
|
physx::PxTransform return_val(anon_param0);
|
|
|
|
|
physx_PxTransform_Pod return_val_pod;
|
|
|
|
|
memcpy(&return_val_pod, &return_val, sizeof(return_val_pod));
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-08-22 18:25:34 +08:00
|
|
|
|
EXPORT_API physx_PxRigidDynamic_Pod* CALL phys_PxCreateDynamic(physx_PxPhysics_Pod* sdk_pod, physx_PxTransform_Pod const* transform_pod,
|
|
|
|
|
physx_PxGeometry_Pod const* geometry_pod, physx_PxMaterial_Pod* material_pod, float density, physx_PxTransform_Pod const* shapeOffset_pod)
|
|
|
|
|
{
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxPhysics& sdk = reinterpret_cast<physx::PxPhysics&>(*sdk_pod);
|
|
|
|
|
physx::PxTransform const& transform = reinterpret_cast<physx::PxTransform const&>(*transform_pod);
|
2023-08-22 18:25:34 +08:00
|
|
|
|
physx::PxGeometry const& geometry = reinterpret_cast<physx::PxGeometry const &>(*geometry_pod);
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxMaterial& material = reinterpret_cast<physx::PxMaterial&>(*material_pod);
|
|
|
|
|
physx::PxTransform const& shapeOffset = reinterpret_cast<physx::PxTransform const&>(*shapeOffset_pod);
|
|
|
|
|
physx::PxRigidDynamic* return_val = PxCreateDynamic(sdk, transform, geometry, material, density, shapeOffset);
|
|
|
|
|
auto return_val_pod = reinterpret_cast<physx_PxRigidDynamic_Pod*>(return_val);
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API physx_PxRigidDynamic_Pod* CALL phys_PxCreateDynamic_1(physx_PxPhysics_Pod* sdk_pod, physx_PxTransform_Pod const* transform_pod, physx_PxShape_Pod* shape_pod, float density) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxPhysics& sdk = reinterpret_cast<physx::PxPhysics&>(*sdk_pod);
|
|
|
|
|
physx::PxTransform const& transform = reinterpret_cast<physx::PxTransform const&>(*transform_pod);
|
|
|
|
|
physx::PxShape& shape = reinterpret_cast<physx::PxShape&>(*shape_pod);
|
|
|
|
|
physx::PxRigidDynamic* return_val = PxCreateDynamic(sdk, transform, shape, density);
|
|
|
|
|
auto return_val_pod = reinterpret_cast<physx_PxRigidDynamic_Pod*>(return_val);
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API void CALL PxActor_setActorFlag_mut(physx_PxActor_Pod* self__pod, int32_t flag_pod, bool value) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxActor* self_ = reinterpret_cast<physx::PxActor*>(self__pod);
|
|
|
|
|
auto flag = static_cast<physx::PxActorFlag::Enum>(flag_pod);
|
|
|
|
|
self_->setActorFlag(flag, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API bool CALL PxRigidBodyExt_updateMassAndInertia_1(physx_PxRigidBody_Pod* body_pod, float density, physx_PxVec3_Pod const* massLocalPose_pod, bool includeNonSimShapes) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxRigidBody& body = reinterpret_cast<physx::PxRigidBody&>(*body_pod);
|
|
|
|
|
physx::PxVec3 const* massLocalPose = reinterpret_cast<physx::PxVec3 const*>(massLocalPose_pod);
|
|
|
|
|
bool return_val = physx::PxRigidBodyExt::updateMassAndInertia(body, density, massLocalPose, includeNonSimShapes);
|
|
|
|
|
return return_val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API void CALL PxRigidBody_setRigidBodyFlag_mut(physx_PxRigidBody_Pod* self__pod, int32_t flag_pod, bool value) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxRigidBody* self_ = reinterpret_cast<physx::PxRigidBody*>(self__pod);
|
|
|
|
|
auto flag = static_cast<physx::PxRigidBodyFlag::Enum>(flag_pod);
|
|
|
|
|
self_->setRigidBodyFlag(flag, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API void CALL PxShape_setName_mut(physx_PxShape_Pod* self__pod, char const* name) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxShape* self_ = reinterpret_cast<physx::PxShape*>(self__pod);
|
|
|
|
|
self_->setName(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API bool CALL PxRigidActor_attachShape_mut(physx_PxRigidActor_Pod* self__pod, physx_PxShape_Pod* shape_pod) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxRigidActor* self_ = reinterpret_cast<physx::PxRigidActor*>(self__pod);
|
|
|
|
|
physx::PxShape& shape = reinterpret_cast<physx::PxShape&>(*shape_pod);
|
|
|
|
|
bool return_val = self_->attachShape(shape);
|
|
|
|
|
return return_val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API void CALL PxRigidActor_detachShape_mut(physx_PxRigidActor_Pod* self__pod, physx_PxShape_Pod* shape_pod, bool wakeOnLostTouch) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxRigidActor* self_ = reinterpret_cast<physx::PxRigidActor*>(self__pod);
|
|
|
|
|
physx::PxShape& shape = reinterpret_cast<physx::PxShape&>(*shape_pod);
|
|
|
|
|
self_->detachShape(shape, wakeOnLostTouch);
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API uint32_t CALL PxRigidActor_getShapes(physx_PxRigidActor_Pod const* self__pod, physx_PxShape_Pod** userBuffer_pod, uint32_t bufferSize, uint32_t startIndex) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxRigidActor const* self_ = reinterpret_cast<physx::PxRigidActor const*>(self__pod);
|
|
|
|
|
physx::PxShape** userBuffer = reinterpret_cast<physx::PxShape**>(userBuffer_pod);
|
|
|
|
|
uint32_t return_val = self_->getShapes(userBuffer, bufferSize, startIndex);
|
|
|
|
|
return return_val;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API void CALL PxShape_setSimulationFilterData_mut(physx_PxShape_Pod* self__pod, physx_PxFilterData_Pod const* data_pod) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxShape* self_ = reinterpret_cast<physx::PxShape*>(self__pod);
|
|
|
|
|
physx::PxFilterData const& data = reinterpret_cast<physx::PxFilterData const&>(*data_pod);
|
|
|
|
|
self_->setSimulationFilterData(data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API uint32_t CALL PxRigidActor_getNbShapes(physx_PxRigidActor_Pod const* self__pod) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxRigidActor const* self_ = reinterpret_cast<physx::PxRigidActor const*>(self__pod);
|
|
|
|
|
uint32_t return_val = self_->getNbShapes();
|
|
|
|
|
return return_val;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API void CALL PxRigidActor_release_mut(physx_PxRigidActor_Pod* self__pod) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxRigidActor* self_ = reinterpret_cast<physx::PxRigidActor*>(self__pod);
|
|
|
|
|
self_->release();
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API char const* CALL PxShape_getName(physx_PxShape_Pod const* self__pod) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxShape const* self_ = reinterpret_cast<physx::PxShape const*>(self__pod);
|
|
|
|
|
char const* return_val = self_->getName();
|
|
|
|
|
return return_val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API void CALL PxRigidDynamic_setLinearVelocity_mut(physx_PxRigidDynamic_Pod* self__pod, physx_PxVec3_Pod const* linVel_pod, bool autowake) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxRigidDynamic* self_ = reinterpret_cast<physx::PxRigidDynamic*>(self__pod);
|
|
|
|
|
physx::PxVec3 const& linVel = reinterpret_cast<physx::PxVec3 const&>(*linVel_pod);
|
|
|
|
|
self_->setLinearVelocity(linVel, autowake);
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API void CALL PxRigidBody_setLinearDamping_mut(physx_PxRigidBody_Pod* self__pod, float linDamp) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxRigidBody* self_ = reinterpret_cast<physx::PxRigidBody*>(self__pod);
|
|
|
|
|
self_->setLinearDamping(linDamp);
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API void CALL PxRigidDynamic_setContactReportThreshold_mut(physx_PxRigidDynamic_Pod* self__pod, float threshold) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxRigidDynamic* self_ = reinterpret_cast<physx::PxRigidDynamic*>(self__pod);
|
|
|
|
|
self_->setContactReportThreshold(threshold);
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API float CALL PxRigidBody_getLinearDamping(physx_PxRigidBody_Pod const* self__pod) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxRigidBody const* self_ = reinterpret_cast<physx::PxRigidBody const*>(self__pod);
|
|
|
|
|
float return_val = self_->getLinearDamping();
|
|
|
|
|
return return_val;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API void CALL PxRigidBody_setAngularDamping_mut(physx_PxRigidBody_Pod* self__pod, float angDamp) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxRigidBody* self_ = reinterpret_cast<physx::PxRigidBody*>(self__pod);
|
|
|
|
|
self_->setAngularDamping(angDamp);
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API float CALL PxRigidBody_getAngularDamping(physx_PxRigidBody_Pod const* self__pod) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxRigidBody const* self_ = reinterpret_cast<physx::PxRigidBody const*>(self__pod);
|
|
|
|
|
float return_val = self_->getAngularDamping();
|
|
|
|
|
return return_val;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API void CALL PxShape_setFlag_mut(physx_PxShape_Pod* self__pod, int32_t flag_pod, bool value) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxShape* self_ = reinterpret_cast<physx::PxShape*>(self__pod);
|
|
|
|
|
auto flag = static_cast<physx::PxShapeFlag::Enum>(flag_pod);
|
|
|
|
|
self_->setFlag(flag, value);
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API void CALL PxShape_setFlags_mut(physx_PxShape_Pod* self__pod, uint8_t inFlags_pod) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxShape* self_ = reinterpret_cast<physx::PxShape*>(self__pod);
|
|
|
|
|
auto inFlags = physx::PxShapeFlags(inFlags_pod);
|
|
|
|
|
self_->setFlags(inFlags);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API physx_PxVec3_Pod CALL PxVec3_getNormalized(physx_PxVec3_Pod const* self__pod) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxVec3 const* self_ = reinterpret_cast<physx::PxVec3 const*>(self__pod);
|
|
|
|
|
physx::PxVec3 return_val = self_->getNormalized();
|
|
|
|
|
physx_PxVec3_Pod return_val_pod;
|
|
|
|
|
memcpy(&return_val_pod, &return_val, sizeof(return_val_pod));
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API bool CALL PxSceneQueryExt_raycastAny(physx_PxScene_Pod const* scene_pod, physx_PxVec3_Pod const* origin_pod, physx_PxVec3_Pod const* unitDir_pod, float distance, physx_PxQueryHit_Pod* hit_pod, physx_PxQueryFilterData_Pod const* filterData_pod, physx_PxQueryFilterCallback_Pod* filterCall_pod, physx_PxQueryCache_Pod const* cache_pod) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxScene const& scene = reinterpret_cast<physx::PxScene const&>(*scene_pod);
|
|
|
|
|
physx::PxVec3 const& origin = reinterpret_cast<physx::PxVec3 const&>(*origin_pod);
|
|
|
|
|
physx::PxVec3 const& unitDir = reinterpret_cast<physx::PxVec3 const&>(*unitDir_pod);
|
|
|
|
|
physx::PxQueryHit& hit = reinterpret_cast<physx::PxQueryHit&>(*hit_pod);
|
|
|
|
|
physx::PxQueryFilterData const& filterData = reinterpret_cast<physx::PxQueryFilterData const&>(*filterData_pod);
|
|
|
|
|
physx::PxQueryFilterCallback* filterCall = reinterpret_cast<physx::PxQueryFilterCallback*>(filterCall_pod);
|
|
|
|
|
physx::PxQueryCache const* cache = reinterpret_cast<physx::PxQueryCache const*>(cache_pod);
|
|
|
|
|
bool return_val = physx::PxSceneQueryExt::raycastAny(scene, origin, unitDir, distance, hit, filterData, filterCall, cache);
|
|
|
|
|
return return_val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API bool CALL PxSceneQueryExt_raycastSingle(physx_PxScene_Pod const* scene_pod, physx_PxVec3_Pod const* origin_pod, physx_PxVec3_Pod const* unitDir_pod, float distance, uint16_t outputFlags_pod,
|
|
|
|
|
physx_PxRaycastHit_Pod* hit_pod, physx_PxQueryFilterData_Pod const* filterData_pod, physx_PxQueryFilterCallback_Pod* filterCall_pod, physx_PxQueryCache_Pod const* cache_pod)
|
|
|
|
|
{
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxScene const& scene = reinterpret_cast<physx::PxScene const&>(*scene_pod);
|
|
|
|
|
physx::PxVec3 const& origin = reinterpret_cast<physx::PxVec3 const&>(*origin_pod);
|
|
|
|
|
physx::PxVec3 const& unitDir = reinterpret_cast<physx::PxVec3 const&>(*unitDir_pod);
|
|
|
|
|
auto outputFlags = physx::PxHitFlags(outputFlags_pod);
|
|
|
|
|
physx::PxRaycastHit& hit = reinterpret_cast<physx::PxRaycastHit&>(*hit_pod);
|
|
|
|
|
physx::PxQueryFilterData const& filterData = reinterpret_cast<physx::PxQueryFilterData const&>(*filterData_pod);
|
|
|
|
|
physx::PxQueryFilterCallback* filterCall = reinterpret_cast<physx::PxQueryFilterCallback*>(filterCall_pod);
|
|
|
|
|
|
|
|
|
|
//physx::PxQueryFilterCallback* filterCall = preFilter1;
|
|
|
|
|
physx::PxQueryCache const* cache = reinterpret_cast<physx::PxQueryCache const*>(cache_pod);
|
|
|
|
|
bool return_val = physx::PxSceneQueryExt::raycastSingle(scene, origin, unitDir, distance, outputFlags, hit, filterData, filterCall, cache);
|
|
|
|
|
return return_val;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API int32_t CALL PxSceneQueryExt_raycastMultiple(physx_PxScene_Pod const* scene_pod, physx_PxVec3_Pod const* origin_pod, physx_PxVec3_Pod const* unitDir_pod,
|
|
|
|
|
float distance, uint16_t outputFlags_pod, physx_PxRaycastHit_Pod* hitBuffer_pod, uint32_t hitBufferSize, bool* blockingHit_pod,
|
|
|
|
|
physx_PxQueryFilterData_Pod const* filterData_pod, physx_PxQueryFilterCallback_Pod* filterCall_pod, physx_PxQueryCache_Pod const* cache_pod)
|
|
|
|
|
{
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxScene const& scene = reinterpret_cast<physx::PxScene const&>(*scene_pod);
|
|
|
|
|
physx::PxVec3 const& origin = reinterpret_cast<physx::PxVec3 const&>(*origin_pod);
|
|
|
|
|
physx::PxVec3 const& unitDir = reinterpret_cast<physx::PxVec3 const&>(*unitDir_pod);
|
|
|
|
|
auto outputFlags = physx::PxHitFlags(outputFlags_pod);
|
|
|
|
|
physx::PxRaycastHit* hitBuffer = reinterpret_cast<physx::PxRaycastHit*>(hitBuffer_pod);
|
|
|
|
|
bool& blockingHit = *blockingHit_pod;
|
|
|
|
|
physx::PxQueryFilterData const& filterData = reinterpret_cast<physx::PxQueryFilterData const&>(*filterData_pod);
|
|
|
|
|
physx::PxQueryFilterCallback* filterCall = reinterpret_cast<physx::PxQueryFilterCallback*>(filterCall_pod);
|
|
|
|
|
physx::PxQueryCache const* cache = reinterpret_cast<physx::PxQueryCache const*>(cache_pod);
|
|
|
|
|
int32_t return_val = physx::PxSceneQueryExt::raycastMultiple(scene, origin, unitDir, distance, outputFlags, hitBuffer, hitBufferSize, blockingHit, filterData, filterCall, cache);
|
|
|
|
|
return return_val;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API bool CALL PxSceneQueryExt_sweepAny(physx_PxScene_Pod const* scene_pod, physx_PxGeometry_Pod const* geometry_pod,
|
|
|
|
|
physx_PxTransform_Pod const* pose_pod, physx_PxVec3_Pod const* unitDir_pod, float distance, uint16_t queryFlags_pod, physx_PxQueryHit_Pod* hit_pod,
|
|
|
|
|
physx_PxQueryFilterData_Pod const* filterData_pod, physx_PxQueryFilterCallback_Pod* filterCall_pod, physx_PxQueryCache_Pod const* cache_pod, float inflation)
|
|
|
|
|
{
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxScene const& scene = reinterpret_cast<physx::PxScene const&>(*scene_pod);
|
|
|
|
|
physx::PxGeometry const& geometry = reinterpret_cast<physx::PxGeometry const&>(*geometry_pod);
|
|
|
|
|
physx::PxTransform const& pose = reinterpret_cast<physx::PxTransform const&>(*pose_pod);
|
|
|
|
|
physx::PxVec3 const& unitDir = reinterpret_cast<physx::PxVec3 const&>(*unitDir_pod);
|
|
|
|
|
auto queryFlags = physx::PxHitFlags(queryFlags_pod);
|
|
|
|
|
physx::PxQueryHit& hit = reinterpret_cast<physx::PxQueryHit&>(*hit_pod);
|
|
|
|
|
physx::PxQueryFilterData const& filterData = reinterpret_cast<physx::PxQueryFilterData const&>(*filterData_pod);
|
|
|
|
|
physx::PxQueryFilterCallback* filterCall = reinterpret_cast<physx::PxQueryFilterCallback*>(filterCall_pod);
|
|
|
|
|
physx::PxQueryCache const* cache = reinterpret_cast<physx::PxQueryCache const*>(cache_pod);
|
|
|
|
|
bool return_val = physx::PxSceneQueryExt::sweepAny(scene, geometry, pose, unitDir, distance, queryFlags, hit, filterData, filterCall, cache, inflation);
|
|
|
|
|
return return_val;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API bool CALL PxSceneQueryExt_sweepSingle(physx_PxScene_Pod const* scene_pod, physx_PxGeometry_Pod const* geometry_pod, physx_PxTransform_Pod const* pose_pod,
|
|
|
|
|
physx_PxVec3_Pod const* unitDir_pod, float distance, uint16_t outputFlags_pod, physx_PxSweepHit_Pod* hit_pod, physx_PxQueryFilterData_Pod const* filterData_pod,
|
|
|
|
|
physx_PxQueryFilterCallback_Pod* filterCall_pod, physx_PxQueryCache_Pod const* cache_pod, float inflation)
|
|
|
|
|
{
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxScene const& scene = reinterpret_cast<physx::PxScene const&>(*scene_pod);
|
|
|
|
|
physx::PxGeometry const& geometry = reinterpret_cast<physx::PxGeometry const&>(*geometry_pod);
|
|
|
|
|
physx::PxTransform const& pose = reinterpret_cast<physx::PxTransform const&>(*pose_pod);
|
|
|
|
|
physx::PxVec3 const& unitDir = reinterpret_cast<physx::PxVec3 const&>(*unitDir_pod);
|
|
|
|
|
auto outputFlags = physx::PxHitFlags(outputFlags_pod);
|
|
|
|
|
physx::PxSweepHit& hit = reinterpret_cast<physx::PxSweepHit&>(*hit_pod);
|
|
|
|
|
physx::PxQueryFilterData const& filterData = reinterpret_cast<physx::PxQueryFilterData const&>(*filterData_pod);
|
|
|
|
|
physx::PxQueryFilterCallback* filterCall = reinterpret_cast<physx::PxQueryFilterCallback*>(filterCall_pod);
|
|
|
|
|
physx::PxQueryCache const* cache = reinterpret_cast<physx::PxQueryCache const*>(cache_pod);
|
|
|
|
|
bool return_val = physx::PxSceneQueryExt::sweepSingle(scene, geometry, pose, unitDir, distance, outputFlags, hit, filterData, filterCall, cache, inflation);
|
|
|
|
|
return return_val;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API int32_t CALL PxSceneQueryExt_sweepMultiple(physx_PxScene_Pod const* scene_pod, physx_PxGeometry_Pod const* geometry_pod, physx_PxTransform_Pod const* pose_pod,
|
|
|
|
|
physx_PxVec3_Pod const* unitDir_pod, float distance, uint16_t outputFlags_pod, physx_PxSweepHit_Pod* hitBuffer_pod, uint32_t hitBufferSize, bool* blockingHit_pod,
|
|
|
|
|
physx_PxQueryFilterData_Pod const* filterData_pod, physx_PxQueryFilterCallback_Pod* filterCall_pod, physx_PxQueryCache_Pod const* cache_pod, float inflation)
|
|
|
|
|
{
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxScene const& scene = reinterpret_cast<physx::PxScene const&>(*scene_pod);
|
|
|
|
|
physx::PxGeometry const& geometry = reinterpret_cast<physx::PxGeometry const&>(*geometry_pod);
|
|
|
|
|
physx::PxTransform const& pose = reinterpret_cast<physx::PxTransform const&>(*pose_pod);
|
|
|
|
|
physx::PxVec3 const& unitDir = reinterpret_cast<physx::PxVec3 const&>(*unitDir_pod);
|
|
|
|
|
auto outputFlags = physx::PxHitFlags(outputFlags_pod);
|
|
|
|
|
physx::PxSweepHit* hitBuffer = reinterpret_cast<physx::PxSweepHit*>(hitBuffer_pod);
|
|
|
|
|
bool& blockingHit = *blockingHit_pod;
|
|
|
|
|
physx::PxQueryFilterData const& filterData = reinterpret_cast<physx::PxQueryFilterData const&>(*filterData_pod);
|
|
|
|
|
physx::PxQueryFilterCallback* filterCall = reinterpret_cast<physx::PxQueryFilterCallback*>(filterCall_pod);
|
|
|
|
|
physx::PxQueryCache const* cache = reinterpret_cast<physx::PxQueryCache const*>(cache_pod);
|
|
|
|
|
int32_t return_val = physx::PxSceneQueryExt::sweepMultiple(scene, geometry, pose, unitDir, distance, outputFlags, hitBuffer, hitBufferSize, blockingHit, filterData, filterCall, cache, inflation);
|
|
|
|
|
return return_val;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API int32_t CALL PxSceneQueryExt_overlapMultiple(physx_PxScene_Pod const* scene_pod, physx_PxGeometry_Pod const* geometry_pod, physx_PxTransform_Pod const* pose_pod,
|
|
|
|
|
physx_PxOverlapHit_Pod* hitBuffer_pod, uint32_t hitBufferSize, physx_PxQueryFilterData_Pod const* filterData_pod, physx_PxQueryFilterCallback_Pod* filterCall_pod)
|
|
|
|
|
{
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxScene const& scene = reinterpret_cast<physx::PxScene const&>(*scene_pod);
|
|
|
|
|
physx::PxGeometry const& geometry = reinterpret_cast<physx::PxGeometry const&>(*geometry_pod);
|
|
|
|
|
physx::PxTransform const& pose = reinterpret_cast<physx::PxTransform const&>(*pose_pod);
|
|
|
|
|
physx::PxOverlapHit* hitBuffer = reinterpret_cast<physx::PxOverlapHit*>(hitBuffer_pod);
|
|
|
|
|
physx::PxQueryFilterData const& filterData = reinterpret_cast<physx::PxQueryFilterData const&>(*filterData_pod);
|
|
|
|
|
physx::PxQueryFilterCallback* filterCall = reinterpret_cast<physx::PxQueryFilterCallback*>(filterCall_pod);
|
|
|
|
|
int32_t return_val = physx::PxSceneQueryExt::overlapMultiple(scene, geometry, pose, hitBuffer, hitBufferSize, filterData, filterCall);
|
|
|
|
|
return return_val;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API bool CALL PxSceneQueryExt_overlapAny(physx_PxScene_Pod const* scene_pod, physx_PxGeometry_Pod const* geometry_pod,
|
|
|
|
|
physx_PxTransform_Pod const* pose_pod, physx_PxOverlapHit_Pod* hit_pod, physx_PxQueryFilterData_Pod const* filterData_pod, physx_PxQueryFilterCallback_Pod* filterCall_pod)
|
|
|
|
|
{
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxScene const& scene = reinterpret_cast<physx::PxScene const&>(*scene_pod);
|
|
|
|
|
physx::PxGeometry const& geometry = reinterpret_cast<physx::PxGeometry const&>(*geometry_pod);
|
|
|
|
|
physx::PxTransform const& pose = reinterpret_cast<physx::PxTransform const&>(*pose_pod);
|
|
|
|
|
physx::PxOverlapHit& hit = reinterpret_cast<physx::PxOverlapHit&>(*hit_pod);
|
|
|
|
|
physx::PxQueryFilterData const& filterData = reinterpret_cast<physx::PxQueryFilterData const&>(*filterData_pod);
|
|
|
|
|
physx::PxQueryFilterCallback* filterCall = reinterpret_cast<physx::PxQueryFilterCallback*>(filterCall_pod);
|
|
|
|
|
bool return_val = physx::PxSceneQueryExt::overlapAny(scene, geometry, pose, hit, filterData, filterCall);
|
|
|
|
|
return return_val;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API physx_PxFilterData_Pod CALL PxFilterData_new(int32_t anon_param0_pod) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
auto anon_param0 = static_cast<physx::PxEMPTY>(anon_param0_pod);
|
|
|
|
|
physx::PxFilterData return_val(anon_param0);
|
|
|
|
|
physx_PxFilterData_Pod return_val_pod;
|
|
|
|
|
memcpy(&return_val_pod, &return_val, sizeof(return_val_pod));
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API physx_PxFilterData_Pod CALL PxFilterData_new_1() {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxFilterData return_val;
|
|
|
|
|
physx_PxFilterData_Pod return_val_pod;
|
|
|
|
|
memcpy(&return_val_pod, &return_val, sizeof(return_val_pod));
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API physx_PxQueryFilterData_Pod CALL PxQueryFilterData_new() {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxQueryFilterData return_val;
|
|
|
|
|
physx_PxQueryFilterData_Pod return_val_pod;
|
|
|
|
|
memcpy(&return_val_pod, &return_val, sizeof(return_val_pod));
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API physx_PxQueryFilterData_Pod CALL PxQueryFilterData_new_1(physx_PxFilterData_Pod const* fd_pod, uint16_t f_pod) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxFilterData const& fd = reinterpret_cast<physx::PxFilterData const&>(*fd_pod);
|
|
|
|
|
auto f = physx::PxQueryFlags(f_pod);
|
|
|
|
|
physx::PxQueryFilterData return_val(fd, f);
|
|
|
|
|
physx_PxQueryFilterData_Pod return_val_pod;
|
|
|
|
|
memcpy(&return_val_pod, &return_val, sizeof(return_val_pod));
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API physx_PxQueryFilterData_Pod CALL PxQueryFilterData_new_2(uint16_t f_pod) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
auto f = physx::PxQueryFlags(f_pod);
|
|
|
|
|
physx::PxQueryFilterData return_val(f);
|
|
|
|
|
physx_PxQueryFilterData_Pod return_val_pod;
|
|
|
|
|
memcpy(&return_val_pod, &return_val, sizeof(return_val_pod));
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API bool CALL PxScene_simulate_mut(physx_PxScene_Pod* self__pod, float elapsedTime, physx_PxBaseTask_Pod* completionTask_pod, void* scratchMemBlock, uint32_t scratchMemBlockSize, bool controlSimulation) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxScene* self_ = reinterpret_cast<physx::PxScene*>(self__pod);
|
|
|
|
|
physx::PxBaseTask* completionTask = reinterpret_cast<physx::PxBaseTask*>(completionTask_pod);
|
|
|
|
|
bool return_val = self_->simulate(elapsedTime, completionTask, scratchMemBlock, scratchMemBlockSize, controlSimulation);
|
|
|
|
|
return return_val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API bool CALL PxScene_fetchResults_mut(physx_PxScene_Pod* self__pod, bool block, uint32_t* errorState) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxScene* self_ = reinterpret_cast<physx::PxScene*>(self__pod);
|
|
|
|
|
bool return_val = self_->fetchResults(block, errorState);
|
|
|
|
|
return return_val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-08-18 17:08:30 +08:00
|
|
|
|
EXPORT_API physx_PxPvdSceneClient_Pod* CALL PxScene_getScenePvdClient_mut(physx_PxScene_Pod* self__pod) {
|
|
|
|
|
physx::PxScene* self_ = reinterpret_cast<physx::PxScene*>(self__pod);
|
|
|
|
|
physx::PxPvdSceneClient* return_val = self_->getScenePvdClient();
|
|
|
|
|
auto return_val_pod = reinterpret_cast<physx_PxPvdSceneClient_Pod*>(return_val);
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EXPORT_API physx_PxPlane_Pod CALL PxPlane_new_1(float nx, float ny, float nz, float distance) {
|
|
|
|
|
physx::PxPlane return_val(nx, ny, nz, distance);
|
|
|
|
|
physx_PxPlane_Pod return_val_pod;
|
|
|
|
|
memcpy(&return_val_pod, &return_val, sizeof(return_val_pod));
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EXPORT_API physx_PxRigidStatic_Pod* CALL phys_PxCreatePlane(physx_PxPhysics_Pod* sdk_pod, physx_PxPlane_Pod const* plane_pod, physx_PxMaterial_Pod* material_pod) {
|
|
|
|
|
physx::PxPhysics& sdk = reinterpret_cast<physx::PxPhysics&>(*sdk_pod);
|
|
|
|
|
physx::PxPlane const& plane = reinterpret_cast<physx::PxPlane const&>(*plane_pod);
|
|
|
|
|
physx::PxMaterial& material = reinterpret_cast<physx::PxMaterial&>(*material_pod);
|
|
|
|
|
physx::PxRigidStatic* return_val = PxCreatePlane(sdk, plane, material);
|
|
|
|
|
auto return_val_pod = reinterpret_cast<physx_PxRigidStatic_Pod*>(return_val);
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EXPORT_API void CALL PxPvdSceneClient_setScenePvdFlag_mut(physx_PxPvdSceneClient_Pod* self__pod, int32_t flag_pod, bool value) {
|
|
|
|
|
physx::PxPvdSceneClient* self_ = reinterpret_cast<physx::PxPvdSceneClient*>(self__pod);
|
|
|
|
|
auto flag = static_cast<physx::PxPvdSceneFlag::Enum>(flag_pod);
|
|
|
|
|
self_->setScenePvdFlag(flag, value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EXPORT_API physx_PxQuat_Pod CALL PxQuat_new() {
|
|
|
|
|
physx::PxQuat return_val;
|
|
|
|
|
physx_PxQuat_Pod return_val_pod;
|
|
|
|
|
memcpy(&return_val_pod, &return_val, sizeof(return_val_pod));
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EXPORT_API physx_PxQuat_Pod CALL PxQuat_new_1(int32_t anon_param0_pod) {
|
|
|
|
|
auto anon_param0 = static_cast<physx::PxIDENTITY>(anon_param0_pod);
|
|
|
|
|
physx::PxQuat return_val(anon_param0);
|
|
|
|
|
physx_PxQuat_Pod return_val_pod;
|
|
|
|
|
memcpy(&return_val_pod, &return_val, sizeof(return_val_pod));
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EXPORT_API physx_PxQuat_Pod CALL PxQuat_new_2(float r) {
|
|
|
|
|
physx::PxQuat return_val(r);
|
|
|
|
|
physx_PxQuat_Pod return_val_pod;
|
|
|
|
|
memcpy(&return_val_pod, &return_val, sizeof(return_val_pod));
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EXPORT_API physx_PxQuat_Pod CALL PxQuat_new_3(float nx, float ny, float nz, float nw) {
|
|
|
|
|
physx::PxQuat return_val(nx, ny, nz, nw);
|
|
|
|
|
physx_PxQuat_Pod return_val_pod;
|
|
|
|
|
memcpy(&return_val_pod, &return_val, sizeof(return_val_pod));
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EXPORT_API physx_PxQuat_Pod CALL PxQuat_new_4(float angleRadians, physx_PxVec3_Pod const* unitAxis_pod) {
|
|
|
|
|
physx::PxVec3 const& unitAxis = reinterpret_cast<physx::PxVec3 const&>(*unitAxis_pod);
|
|
|
|
|
physx::PxQuat return_val(angleRadians, unitAxis);
|
|
|
|
|
physx_PxQuat_Pod return_val_pod;
|
|
|
|
|
memcpy(&return_val_pod, &return_val, sizeof(return_val_pod));
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-22 18:25:34 +08:00
|
|
|
|
EXPORT_API physx_PxTolerancesScale_Pod CALL PxTolerancesScale_new(float defaultLength, float defaultSpeed) {
|
|
|
|
|
physx::PxTolerancesScale return_val(defaultLength, defaultSpeed);
|
|
|
|
|
physx_PxTolerancesScale_Pod return_val_pod;
|
|
|
|
|
memcpy(&return_val_pod, &return_val, sizeof(return_val_pod));
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
2023-08-18 17:08:30 +08:00
|
|
|
|
|
|
|
|
|
//EXPORT_API bool CALL phys_PxInitExtensions(physx_PxPhysics_Pod* physics_pod, physx_PxPvd_Pod* pvd_pod) {
|
|
|
|
|
// physx::PxPhysics& physics = reinterpret_cast<physx::PxPhysics&>(*physics_pod);
|
|
|
|
|
// physx::PxPvd* pvd = reinterpret_cast<physx::PxPvd*>(pvd_pod);
|
|
|
|
|
// bool return_val = PxInitExtensions(physics, pvd);
|
|
|
|
|
// return return_val;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//EXPORT_API void CALL phys_PxCloseExtensions() {
|
|
|
|
|
// PxCloseExtensions();
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
2023-08-11 10:55:58 +08:00
|
|
|
|
////<2F><><EFBFBD>ߺ<EFBFBD><DFBA><EFBFBD>
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API physx_PxVec3_Pod CALL PxVec3_new() {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxVec3 return_val;
|
|
|
|
|
physx_PxVec3_Pod return_val_pod;
|
|
|
|
|
memcpy(&return_val_pod, &return_val, sizeof(return_val_pod));
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API physx_PxVec3_Pod CALL PxVec3_new_1(int32_t anon_param0_pod) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
auto anon_param0 = static_cast<physx::PxZERO>(anon_param0_pod);
|
|
|
|
|
physx::PxVec3 return_val(anon_param0);
|
|
|
|
|
physx_PxVec3_Pod return_val_pod;
|
|
|
|
|
memcpy(&return_val_pod, &return_val, sizeof(return_val_pod));
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API physx_PxVec3_Pod CALL PxVec3_new_2(float a) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxVec3 return_val(a);
|
|
|
|
|
physx_PxVec3_Pod return_val_pod;
|
|
|
|
|
memcpy(&return_val_pod, &return_val, sizeof(return_val_pod));
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API physx_PxVec3_Pod CALL PxVec3_new_3(float nx, float ny, float nz) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxVec3 return_val(nx, ny, nz);
|
|
|
|
|
physx_PxVec3_Pod return_val_pod;
|
|
|
|
|
memcpy(&return_val_pod, &return_val, sizeof(return_val_pod));
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API bool CALL PxVec3_isZero(physx_PxVec3_Pod const* self__pod) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxVec3 const* self_ = reinterpret_cast<physx::PxVec3 const*>(self__pod);
|
|
|
|
|
bool return_val = self_->isZero();
|
|
|
|
|
return return_val;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API bool CALL PxVec3_isFinite(physx_PxVec3_Pod const* self__pod) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxVec3 const* self_ = reinterpret_cast<physx::PxVec3 const*>(self__pod);
|
|
|
|
|
bool return_val = self_->isFinite();
|
|
|
|
|
return return_val;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API bool CALL PxVec3_isNormalized(physx_PxVec3_Pod const* self__pod) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxVec3 const* self_ = reinterpret_cast<physx::PxVec3 const*>(self__pod);
|
|
|
|
|
bool return_val = self_->isNormalized();
|
|
|
|
|
return return_val;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API float CALL PxVec3_magnitudeSquared(physx_PxVec3_Pod const* self__pod) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxVec3 const* self_ = reinterpret_cast<physx::PxVec3 const*>(self__pod);
|
|
|
|
|
float return_val = self_->magnitudeSquared();
|
|
|
|
|
return return_val;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API float CALL PxVec3_magnitude(physx_PxVec3_Pod const* self__pod) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxVec3 const* self_ = reinterpret_cast<physx::PxVec3 const*>(self__pod);
|
|
|
|
|
float return_val = self_->magnitude();
|
|
|
|
|
return return_val;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API bool CALL phys_PxFilterObjectIsTrigger(uint32_t attr) {
|
2023-08-11 10:55:58 +08:00
|
|
|
|
bool return_val = physx::PxFilterObjectIsTrigger(attr);
|
|
|
|
|
return return_val;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//<2F>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>ʵ<EFBFBD><CAB5>
|
|
|
|
|
struct FilterShaderCallbackInfo
|
|
|
|
|
{
|
|
|
|
|
physx::PxFilterObjectAttributes attributes0;
|
|
|
|
|
physx::PxFilterObjectAttributes attributes1;
|
|
|
|
|
physx::PxFilterData filterData0;
|
|
|
|
|
physx::PxFilterData filterData1;
|
|
|
|
|
physx::PxPairFlags* pairFlags;
|
|
|
|
|
const void* constantBlock;
|
|
|
|
|
physx::PxU32 constantBlockSize;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef void (*CollisionCallback)(void*, physx::PxContactPairHeader const*, physx::PxContactPair const*, physx::PxU32);
|
|
|
|
|
typedef physx::PxU16(*SimulationShaderFilter)(FilterShaderCallbackInfo*);
|
|
|
|
|
|
|
|
|
|
struct FilterCallbackData {
|
|
|
|
|
SimulationShaderFilter filter;
|
|
|
|
|
bool call_default_filter_shader_first;
|
|
|
|
|
};
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API physx::PxFilterFlags CALL FilterShaderTrampoline(physx::PxFilterObjectAttributes attributes0,
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxFilterData filterData0,
|
|
|
|
|
physx::PxFilterObjectAttributes attributes1,
|
|
|
|
|
physx::PxFilterData filterData1,
|
|
|
|
|
physx::PxPairFlags& pairFlags,
|
|
|
|
|
const void* constantBlock,
|
|
|
|
|
physx::PxU32 constantBlockSize)
|
|
|
|
|
{
|
|
|
|
|
const FilterCallbackData* data = static_cast<const FilterCallbackData*>(constantBlock);
|
|
|
|
|
|
|
|
|
|
if (data->call_default_filter_shader_first) {
|
|
|
|
|
// Let the default handler set the pair flags, but ignore the collision filtering
|
2023-08-22 18:25:34 +08:00
|
|
|
|
return PxDefaultSimulationFilterShader(attributes0, filterData0, attributes1, filterData1, pairFlags, constantBlock,
|
2023-08-11 10:55:58 +08:00
|
|
|
|
constantBlockSize);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get the filter shader from the constant block
|
|
|
|
|
SimulationShaderFilter shaderfilter = data->filter;
|
|
|
|
|
|
|
|
|
|
// This is a bit expensive since we're putting things on the stack but with LTO this should optimize OK,
|
|
|
|
|
// and I was having issues with corrupted values when passing by value
|
|
|
|
|
FilterShaderCallbackInfo info{ attributes0, attributes1, filterData0, filterData1, &pairFlags, nullptr, 0 };
|
|
|
|
|
|
|
|
|
|
// We return a u16 since PxFilterFlags is a complex type and C++ wants it to be returned on the stack,
|
|
|
|
|
// but Rust thinks it's simple due to the codegen and wants to return it in EAX.
|
2023-08-22 18:25:34 +08:00
|
|
|
|
//pairFlags = physx::PxPairFlag::eSOLVE_CONTACT |
|
|
|
|
|
// physx::PxPairFlag::eDETECT_DISCRETE_CONTACT |
|
|
|
|
|
// physx::PxPairFlag::eNOTIFY_TOUCH_FOUND |
|
|
|
|
|
// physx::PxPairFlag::eNOTIFY_TOUCH_LOST |
|
|
|
|
|
// physx::PxPairFlag::eNOTIFY_CONTACT_POINTS;
|
|
|
|
|
//return (physx::PxFilterFlags)0x4;
|
|
|
|
|
//printf("%d ");
|
2023-08-11 10:55:58 +08:00
|
|
|
|
return physx::PxFilterFlags{ shaderfilter(&info) };
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-22 18:25:34 +08:00
|
|
|
|
using PairFoundCallback = physx::PxFilterFlags(*)(physx::PxU32, physx::PxFilterObjectAttributes, physx::PxFilterData, const physx::PxActor*, const physx::PxShape*,
|
|
|
|
|
physx::PxFilterObjectAttributes, physx::PxFilterData, const physx::PxActor*, const physx::PxShape*, physx::PxPairFlags*);
|
|
|
|
|
using PairLostCallback = void (*)(physx::PxU32, physx::PxFilterObjectAttributes, physx::PxFilterData, physx::PxFilterObjectAttributes, physx::PxFilterData, bool);
|
|
|
|
|
using StatusChangeCallback = bool (*)(physx::PxU32*, physx::PxPairFlags*, physx::PxFilterFlags*);
|
2023-08-11 10:55:58 +08:00
|
|
|
|
|
|
|
|
|
struct SimuliationFilterCallBackInfo {
|
|
|
|
|
// Callback for pairFound
|
|
|
|
|
PairFoundCallback pairFoundCallback = nullptr;
|
|
|
|
|
PairLostCallback pairLostCallback = nullptr;
|
|
|
|
|
StatusChangeCallback statusChangeCallback = nullptr;
|
|
|
|
|
};
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
class SimulationFilterCallBackTrampoline : public physx::PxSimulationFilterCallback
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
SimulationFilterCallBackTrampoline(const SimuliationFilterCallBackInfo* callbacks) : mCallbacks(*callbacks) {}
|
|
|
|
|
|
|
|
|
|
// Collisions
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ܴ<EFBFBD><DCB4><EFBFBD>bug
|
2023-08-22 18:25:34 +08:00
|
|
|
|
physx::PxFilterFlags pairFound(physx::PxU32 pairID,
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxFilterObjectAttributes attributes0, physx::PxFilterData filterData0, const physx::PxActor* a0, const physx::PxShape* s0,
|
|
|
|
|
physx::PxFilterObjectAttributes attributes1, physx::PxFilterData filterData1, const physx::PxActor* a1, const physx::PxShape* s1,
|
2023-08-22 18:25:34 +08:00
|
|
|
|
physx::PxPairFlags& pairFlags)
|
2023-08-11 10:55:58 +08:00
|
|
|
|
{
|
|
|
|
|
if (mCallbacks.pairFoundCallback) {
|
|
|
|
|
return mCallbacks.pairFoundCallback(pairID,
|
|
|
|
|
attributes0, filterData0, a0, s0,
|
|
|
|
|
attributes1, filterData1, a1, s1,
|
2023-08-22 18:25:34 +08:00
|
|
|
|
&pairFlags);
|
2023-08-11 10:55:58 +08:00
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
return physx::PxFilterFlag::eDEFAULT;
|
|
|
|
|
}
|
2023-08-22 18:25:34 +08:00
|
|
|
|
|
2023-08-11 10:55:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-08-22 18:25:34 +08:00
|
|
|
|
|
2023-08-11 10:55:58 +08:00
|
|
|
|
// Triggers
|
2023-08-22 18:25:34 +08:00
|
|
|
|
void pairLost(physx::PxU32 pairID,
|
2023-08-11 10:55:58 +08:00
|
|
|
|
physx::PxFilterObjectAttributes attributes0, physx::PxFilterData filterData0,
|
|
|
|
|
physx::PxFilterObjectAttributes attributes1, physx::PxFilterData filterData1,
|
2023-08-22 18:25:34 +08:00
|
|
|
|
bool objectRemoved)
|
2023-08-11 10:55:58 +08:00
|
|
|
|
{
|
|
|
|
|
if (mCallbacks.pairLostCallback) {
|
|
|
|
|
mCallbacks.pairLostCallback(pairID, attributes0, filterData0,
|
|
|
|
|
attributes1, filterData1, objectRemoved);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Constraint breaks
|
2023-08-22 18:25:34 +08:00
|
|
|
|
bool statusChange(physx::PxU32& pairID, physx::PxPairFlags& pairFlags, physx::PxFilterFlags& filterFlags)
|
2023-08-11 10:55:58 +08:00
|
|
|
|
{
|
|
|
|
|
if (mCallbacks.statusChangeCallback) {
|
2023-08-22 18:25:34 +08:00
|
|
|
|
return mCallbacks.statusChangeCallback(&pairID, &pairFlags, &filterFlags);
|
2023-08-11 10:55:58 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SimuliationFilterCallBackInfo mCallbacks;
|
|
|
|
|
};
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
using CollisionCallback = void (*)(void*, physx::PxContactPairHeader const*, physx::PxContactPair const*, physx::PxU32);
|
|
|
|
|
using TriggerCallback = void (*)(void*, physx::PxTriggerPair const*, physx::PxU32);
|
|
|
|
|
using ConstraintBreakCallback = void (*)(void*, physx::PxConstraintInfo const*, physx::PxU32);
|
|
|
|
|
using WakeSleepCallback = void (*)(void*, physx::PxActor** const, physx::PxU32, bool);
|
|
|
|
|
using AdvanceCallback = void (*)(void*, const physx::PxRigidBody* const*, const physx::PxTransform* const, physx::PxU32);
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
struct SimulationEventCallbackInfo {
|
|
|
|
|
// Callback for collision events.
|
|
|
|
|
CollisionCallback collisionCallback = nullptr;
|
|
|
|
|
void* collisionUserData = nullptr;
|
|
|
|
|
// Callback for trigger shape events (an object entered or left a trigger shape).
|
|
|
|
|
TriggerCallback triggerCallback = nullptr;
|
|
|
|
|
void* triggerUserData = nullptr;
|
|
|
|
|
// Callback for when a constraint breaks (such as a joint with a force limit)
|
|
|
|
|
ConstraintBreakCallback constraintBreakCallback = nullptr;
|
|
|
|
|
void* constraintBreakUserData = nullptr;
|
|
|
|
|
// Callback for when an object falls asleep or is awoken.
|
|
|
|
|
WakeSleepCallback wakeSleepCallback = nullptr;
|
|
|
|
|
void* wakeSleepUserData = nullptr;
|
|
|
|
|
// Callback to get the next pose early for objects (if flagged with eENABLE_POSE_INTEGRATION_PREVIEW).
|
|
|
|
|
AdvanceCallback advanceCallback = nullptr;
|
|
|
|
|
void* advanceUserData = nullptr;
|
|
|
|
|
};
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
class SimulationEventTrampoline : public physx::PxSimulationEventCallback
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
SimulationEventTrampoline(const SimulationEventCallbackInfo* callbacks) : mCallbacks(*callbacks) {}
|
|
|
|
|
|
|
|
|
|
// Collisions
|
|
|
|
|
void onContact(const physx::PxContactPairHeader& pairHeader, const physx::PxContactPair* pairs, physx::PxU32 nbPairs) override {
|
|
|
|
|
if (mCallbacks.collisionCallback) {
|
|
|
|
|
mCallbacks.collisionCallback(mCallbacks.collisionUserData, &pairHeader, pairs, nbPairs);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Triggers
|
|
|
|
|
void onTrigger(physx::PxTriggerPair* pairs, physx::PxU32 count) override {
|
|
|
|
|
if (mCallbacks.triggerCallback) {
|
|
|
|
|
mCallbacks.triggerCallback(mCallbacks.triggerUserData, pairs, count);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Constraint breaks
|
|
|
|
|
void onConstraintBreak(physx::PxConstraintInfo* constraints, physx::PxU32 count) override {
|
|
|
|
|
if (mCallbacks.constraintBreakCallback) {
|
|
|
|
|
mCallbacks.constraintBreakCallback(mCallbacks.constraintBreakUserData, constraints, count);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Wake/Sleep (combined for convenience)
|
|
|
|
|
void onWake(physx::PxActor** actors, physx::PxU32 count) override {
|
|
|
|
|
if (mCallbacks.wakeSleepCallback) {
|
|
|
|
|
mCallbacks.wakeSleepCallback(mCallbacks.wakeSleepUserData, actors, count, true);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void onSleep(physx::PxActor** actors, physx::PxU32 count) override {
|
|
|
|
|
if (mCallbacks.wakeSleepCallback) {
|
|
|
|
|
mCallbacks.wakeSleepCallback(mCallbacks.wakeSleepUserData, actors, count, false);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Advance
|
|
|
|
|
void onAdvance(const physx::PxRigidBody* const* bodyBuffer, const physx::PxTransform* poseBuffer, const physx::PxU32 count) override {
|
|
|
|
|
if (mCallbacks.advanceCallback) {
|
|
|
|
|
mCallbacks.advanceCallback(mCallbacks.advanceUserData, bodyBuffer, poseBuffer, count);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SimulationEventCallbackInfo mCallbacks;
|
|
|
|
|
};
|
|
|
|
|
//
|
|
|
|
|
class RaycastFilterCallback : public physx::PxQueryFilterCallback
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
explicit RaycastFilterCallback(physx::PxRigidActor* actor) : mActor(actor) {}
|
|
|
|
|
|
|
|
|
|
physx::PxRigidActor* mActor;
|
|
|
|
|
|
|
|
|
|
virtual physx::PxQueryHitType::Enum preFilter(const physx::PxFilterData&, const physx::PxShape* shape,
|
|
|
|
|
const physx::PxRigidActor* actor, physx::PxHitFlags&)
|
|
|
|
|
{
|
|
|
|
|
if (mActor == actor)
|
|
|
|
|
{
|
|
|
|
|
return physx::PxQueryHitType::eNONE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return physx::PxQueryHitType::eBLOCK;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual physx::PxQueryHitType::Enum postFilter(const physx::PxFilterData& filterData, const physx::PxQueryHit& hit, const physx::PxShape* shape,
|
|
|
|
|
const physx::PxRigidActor* actor)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return physx::PxQueryHitType::eNONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef physx::PxQueryHitType::Enum(*RaycastHitCallback)(const physx::PxRigidActor* actor, const physx::PxFilterData* filterData, const physx::PxShape* shape, physx::PxU32 hitFlags, const void* userData);
|
|
|
|
|
typedef physx::PxQueryHitType::Enum(*PostFilterCallback)(const physx::PxFilterData* filterData, const physx::PxQueryHit* hit, const void* userData);
|
|
|
|
|
|
|
|
|
|
physx::PxQueryHitType::Enum sanitize_hit_type(uint32_t hit_type) {
|
|
|
|
|
switch (hit_type) {
|
|
|
|
|
case physx::PxQueryHitType::eNONE:
|
|
|
|
|
case physx::PxQueryHitType::eTOUCH:
|
|
|
|
|
case physx::PxQueryHitType::eBLOCK: return (physx::PxQueryHitType::Enum)hit_type;
|
|
|
|
|
default: return physx::PxQueryHitType::eNONE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
class RaycastFilterTrampoline : public physx::PxQueryFilterCallback
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
RaycastFilterTrampoline(RaycastHitCallback callback, const void* userdata)
|
|
|
|
|
: mCallback(callback), mUserData(userdata) {}
|
|
|
|
|
|
|
|
|
|
RaycastHitCallback mCallback;
|
|
|
|
|
const void* mUserData;
|
|
|
|
|
|
|
|
|
|
virtual physx::PxQueryHitType::Enum preFilter(const physx::PxFilterData& filterData, const physx::PxShape* shape, const physx::PxRigidActor* actor, physx::PxHitFlags& hitFlags)
|
|
|
|
|
{
|
|
|
|
|
return sanitize_hit_type(mCallback(actor, &filterData, shape, (uint32_t)hitFlags, mUserData));
|
|
|
|
|
}
|
|
|
|
|
virtual physx::PxQueryHitType::Enum postFilter(const physx::PxFilterData& filterData, const physx::PxQueryHit& hit,
|
|
|
|
|
const physx::PxShape* shape, const physx::PxRigidActor* actor)
|
|
|
|
|
{
|
|
|
|
|
return physx::PxQueryHitType::eNONE;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
class RaycastFilterPrePostTrampoline : public physx::PxQueryFilterCallback
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
RaycastFilterPrePostTrampoline(RaycastHitCallback preFilter, PostFilterCallback postFilter, const void* userdata)
|
|
|
|
|
: mPreFilter(preFilter), mPostFilter(postFilter), mUserData(userdata) {}
|
|
|
|
|
|
|
|
|
|
RaycastHitCallback mPreFilter;
|
|
|
|
|
PostFilterCallback mPostFilter;
|
|
|
|
|
|
|
|
|
|
const void* mUserData;
|
|
|
|
|
|
|
|
|
|
virtual physx::PxQueryHitType::Enum preFilter(const physx::PxFilterData& filterData, const physx::PxShape* shape, const physx::PxRigidActor* actor, physx::PxHitFlags& hitFlags)
|
|
|
|
|
{
|
|
|
|
|
if (mPreFilter == nullptr)
|
|
|
|
|
{
|
|
|
|
|
return physx::PxQueryHitType::eNONE;
|
|
|
|
|
}
|
|
|
|
|
return sanitize_hit_type(mPreFilter(actor, &filterData, shape, (uint32_t)hitFlags, mUserData));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual physx::PxQueryHitType::Enum postFilter(const physx::PxFilterData& filterData, const physx::PxQueryHit& hit,
|
|
|
|
|
const physx::PxShape* shape, const physx::PxRigidActor* actor)
|
|
|
|
|
{
|
|
|
|
|
if (mPostFilter == nullptr)
|
|
|
|
|
{
|
|
|
|
|
return physx::PxQueryHitType::eNONE;
|
|
|
|
|
}
|
|
|
|
|
return sanitize_hit_type(mPostFilter(&filterData, &hit, mUserData));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef physx::PxAgain(*RaycastHitProcessTouchesCallback)(const physx::PxRaycastHit* buffer, physx::PxU32 nbHits, void* userdata);
|
|
|
|
|
typedef physx::PxAgain(*SweepHitProcessTouchesCallback)(const physx::PxSweepHit* buffer, physx::PxU32 nbHits, void* userdata);
|
|
|
|
|
typedef physx::PxAgain(*OverlapHitProcessTouchesCallback)(const physx::PxOverlapHit* buffer, physx::PxU32 nbHits, void* userdata);
|
|
|
|
|
typedef void (*HitFinalizeQueryCallback)(void* userdata);
|
|
|
|
|
//
|
|
|
|
|
class RaycastHitCallbackTrampoline : public physx::PxRaycastCallback
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
RaycastHitCallbackTrampoline(
|
|
|
|
|
RaycastHitProcessTouchesCallback processTouchesCallback,
|
|
|
|
|
HitFinalizeQueryCallback finalizeQueryCallback,
|
|
|
|
|
physx::PxRaycastHit* touchesBuffer,
|
|
|
|
|
physx::PxU32 numTouches,
|
|
|
|
|
void* userdata)
|
|
|
|
|
: physx::PxRaycastCallback(touchesBuffer, numTouches),
|
|
|
|
|
mProcessTouchesCallback(processTouchesCallback),
|
|
|
|
|
mFinalizeQueryCallback(finalizeQueryCallback),
|
|
|
|
|
mUserData(userdata) {}
|
|
|
|
|
|
|
|
|
|
RaycastHitProcessTouchesCallback mProcessTouchesCallback;
|
|
|
|
|
HitFinalizeQueryCallback mFinalizeQueryCallback;
|
|
|
|
|
void* mUserData;
|
|
|
|
|
|
|
|
|
|
physx::PxAgain processTouches(const physx::PxRaycastHit* buffer, physx::PxU32 nbHits) override
|
|
|
|
|
{
|
|
|
|
|
return mProcessTouchesCallback(buffer, nbHits, mUserData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void finalizeQuery() override
|
|
|
|
|
{
|
|
|
|
|
mFinalizeQueryCallback(mUserData);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
//
|
|
|
|
|
class SweepHitCallbackTrampoline : public physx::PxSweepCallback
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
SweepHitCallbackTrampoline(
|
|
|
|
|
SweepHitProcessTouchesCallback processTouchesCallback,
|
|
|
|
|
HitFinalizeQueryCallback finalizeQueryCallback,
|
|
|
|
|
physx::PxSweepHit* touchesBuffer,
|
|
|
|
|
physx::PxU32 numTouches,
|
|
|
|
|
void* userdata)
|
|
|
|
|
: physx::PxSweepCallback(touchesBuffer, numTouches),
|
|
|
|
|
mProcessTouchesCallback(processTouchesCallback),
|
|
|
|
|
mFinalizeQueryCallback(finalizeQueryCallback),
|
|
|
|
|
mUserData(userdata) {}
|
|
|
|
|
|
|
|
|
|
SweepHitProcessTouchesCallback mProcessTouchesCallback;
|
|
|
|
|
HitFinalizeQueryCallback mFinalizeQueryCallback;
|
|
|
|
|
void* mUserData;
|
|
|
|
|
|
|
|
|
|
physx::PxAgain processTouches(const physx::PxSweepHit* buffer, physx::PxU32 nbHits) override
|
|
|
|
|
{
|
|
|
|
|
return mProcessTouchesCallback(buffer, nbHits, mUserData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void finalizeQuery() override
|
|
|
|
|
{
|
|
|
|
|
mFinalizeQueryCallback(mUserData);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
//
|
|
|
|
|
class OverlapHitCallbackTrampoline : public physx::PxOverlapCallback
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
OverlapHitCallbackTrampoline(
|
|
|
|
|
OverlapHitProcessTouchesCallback processTouchesCallback,
|
|
|
|
|
HitFinalizeQueryCallback finalizeQueryCallback,
|
|
|
|
|
physx::PxOverlapHit* touchesBuffer,
|
|
|
|
|
physx::PxU32 numTouches,
|
|
|
|
|
void* userdata)
|
|
|
|
|
: physx::PxOverlapCallback(touchesBuffer, numTouches),
|
|
|
|
|
mProcessTouchesCallback(processTouchesCallback),
|
|
|
|
|
mFinalizeQueryCallback(finalizeQueryCallback),
|
|
|
|
|
mUserData(userdata) {}
|
|
|
|
|
|
|
|
|
|
OverlapHitProcessTouchesCallback mProcessTouchesCallback;
|
|
|
|
|
HitFinalizeQueryCallback mFinalizeQueryCallback;
|
|
|
|
|
void* mUserData;
|
|
|
|
|
|
|
|
|
|
physx::PxAgain processTouches(const physx::PxOverlapHit* buffer, physx::PxU32 nbHits) override
|
|
|
|
|
{
|
|
|
|
|
return mProcessTouchesCallback(buffer, nbHits, mUserData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void finalizeQuery() override
|
|
|
|
|
{
|
|
|
|
|
mFinalizeQueryCallback(mUserData);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef void* (*AllocCallback)(uint64_t size, const char* typeName, const char* filename, int line, void* userdata);
|
|
|
|
|
typedef void (*DeallocCallback)(void* ptr, void* userdata);
|
|
|
|
|
|
|
|
|
|
class CustomAllocatorTrampoline : public physx::PxAllocatorCallback {
|
|
|
|
|
public:
|
|
|
|
|
CustomAllocatorTrampoline(AllocCallback allocCb, DeallocCallback deallocCb, void* userdata)
|
|
|
|
|
: mAllocCallback(allocCb), mDeallocCallback(deallocCb), mUserData(userdata) {}
|
|
|
|
|
|
|
|
|
|
void* allocate(size_t size, const char* typeName, const char* filename, int line)
|
|
|
|
|
{
|
|
|
|
|
return mAllocCallback((uint64_t)size, typeName, filename, line, mUserData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void deallocate(void* ptr)
|
|
|
|
|
{
|
|
|
|
|
mDeallocCallback(ptr, mUserData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
AllocCallback mAllocCallback;
|
|
|
|
|
DeallocCallback mDeallocCallback;
|
|
|
|
|
public:
|
|
|
|
|
void* mUserData;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef void* (*ZoneStartCallback)(const char* typeName, bool detached, uint64_t context, void* userdata);
|
|
|
|
|
typedef void (*ZoneEndCallback)(void* profilerData, const char* typeName, bool detached, uint64_t context, void* userdata);
|
|
|
|
|
|
|
|
|
|
class CustomProfilerTrampoline : public physx::PxProfilerCallback {
|
|
|
|
|
public:
|
|
|
|
|
CustomProfilerTrampoline(ZoneStartCallback startCb, ZoneEndCallback endCb, void* userdata)
|
|
|
|
|
: mStartCallback(startCb), mEndCallback(endCb), mUserData(userdata) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void* zoneStart(const char* eventName, bool detached, uint64_t contextId) override
|
|
|
|
|
{
|
|
|
|
|
return mStartCallback(eventName, detached, contextId, mUserData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void zoneEnd(void* profilerData, const char* eventName, bool detached, uint64_t contextId) override
|
|
|
|
|
{
|
|
|
|
|
return mEndCallback(profilerData, eventName, detached, contextId, mUserData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
ZoneStartCallback mStartCallback;
|
|
|
|
|
ZoneEndCallback mEndCallback;
|
|
|
|
|
public:
|
|
|
|
|
void* mUserData;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
using ErrorCallback = void (*)(int code, const char* message, const char* file, int line, void* userdata);
|
|
|
|
|
|
|
|
|
|
class ErrorTrampoline : public physx::PxErrorCallback {
|
|
|
|
|
public:
|
|
|
|
|
ErrorTrampoline(ErrorCallback errorCb, void* userdata)
|
|
|
|
|
: mErrorCallback(errorCb), mUserdata(userdata)
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
void reportError(physx::PxErrorCode::Enum code, const char* message, const char* file, int line) override {
|
|
|
|
|
mErrorCallback(code, message, file, line, mUserdata);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
ErrorCallback mErrorCallback = nullptr;
|
|
|
|
|
void* mUserdata = nullptr;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//using AssertHandler = void (*)(const char* expr, const char* file, int line, bool* should_ignore, void* userdata);
|
|
|
|
|
|
|
|
|
|
//class AssertTrampoline : public physx::PxAssertHandler {
|
|
|
|
|
//public:
|
|
|
|
|
// AssertTrampoline(AssertHandler onAssert, void* userdata)
|
|
|
|
|
// : mAssertHandler(onAssert), mUserdata(userdata)
|
|
|
|
|
// {}
|
|
|
|
|
//
|
|
|
|
|
// virtual void operator()(const char* exp, const char* file, int line, bool& ignore) override final {
|
|
|
|
|
// mAssertHandler(exp, file, line, &ignore, mUserdata);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
//private:
|
|
|
|
|
// AssertHandler mAssertHandler = nullptr;
|
|
|
|
|
// void* mUserdata = nullptr;
|
|
|
|
|
//};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// fixme[tolsson]: this might be iffy on Windows with DLLs if we have multiple packages
|
|
|
|
|
// linking against the raw interface
|
|
|
|
|
//physx::PxErrorCallback* get_default_error_callback()
|
|
|
|
|
//{
|
|
|
|
|
// return &gErrorCallback;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API physx::PxQueryFilterCallback* CALL create_raycast_filter_callback(physx::PxRigidActor* actor_to_ignore)
|
2023-08-11 10:55:58 +08:00
|
|
|
|
{
|
|
|
|
|
return new RaycastFilterCallback(actor_to_ignore);
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API physx::PxQueryFilterCallback* CALL create_raycast_filter_callback_func(RaycastHitCallback callback, void* userData)
|
2023-08-11 10:55:58 +08:00
|
|
|
|
{
|
|
|
|
|
return new RaycastFilterTrampoline(callback, userData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API physx::PxQueryFilterCallback* CALL create_pre_and_post_raycast_filter_callback_func(RaycastHitCallback preFilter, PostFilterCallback postFilter, void* userData)
|
2023-08-11 10:55:58 +08:00
|
|
|
|
{
|
|
|
|
|
return new RaycastFilterPrePostTrampoline(preFilter, postFilter, userData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API physx::PxRaycastCallback* create_raycast_callback(
|
2023-08-11 10:55:58 +08:00
|
|
|
|
RaycastHitProcessTouchesCallback process_touches_callback,
|
|
|
|
|
HitFinalizeQueryCallback finalize_query_callback,
|
|
|
|
|
physx::PxRaycastHit* touchesBuffer,
|
|
|
|
|
physx::PxU32 numTouches,
|
2023-08-11 15:35:45 +08:00
|
|
|
|
void* userdata )
|
|
|
|
|
{
|
2023-08-11 10:55:58 +08:00
|
|
|
|
return new RaycastHitCallbackTrampoline(
|
|
|
|
|
process_touches_callback, finalize_query_callback, touchesBuffer, numTouches, userdata);
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API void CALL delete_raycast_callback(physx::PxRaycastCallback* callback)
|
2023-08-11 10:55:58 +08:00
|
|
|
|
{
|
|
|
|
|
delete callback;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API void CALL delete_sweep_callback(physx::PxSweepCallback* callback)
|
2023-08-11 10:55:58 +08:00
|
|
|
|
{
|
|
|
|
|
delete callback;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API void CALL delete_overlap_callback(physx::PxOverlapCallback* callback)
|
2023-08-11 10:55:58 +08:00
|
|
|
|
{
|
|
|
|
|
delete callback;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API physx::PxSweepCallback* CALL create_sweep_callback(
|
2023-08-11 10:55:58 +08:00
|
|
|
|
SweepHitProcessTouchesCallback process_touches_callback,
|
|
|
|
|
HitFinalizeQueryCallback finalize_query_callback,
|
|
|
|
|
physx::PxSweepHit* touchesBuffer,
|
|
|
|
|
physx::PxU32 numTouches,
|
2023-08-11 15:35:45 +08:00
|
|
|
|
void* userdata )
|
|
|
|
|
{
|
2023-08-11 10:55:58 +08:00
|
|
|
|
return new SweepHitCallbackTrampoline(
|
|
|
|
|
process_touches_callback, finalize_query_callback, touchesBuffer, numTouches, userdata
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API physx::PxOverlapCallback* CALL create_overlap_callback(
|
2023-08-11 10:55:58 +08:00
|
|
|
|
OverlapHitProcessTouchesCallback process_touches_callback,
|
|
|
|
|
HitFinalizeQueryCallback finalize_query_callback,
|
|
|
|
|
physx::PxOverlapHit* touchesBuffer,
|
|
|
|
|
physx::PxU32 numTouches,
|
2023-08-11 15:35:45 +08:00
|
|
|
|
void* userdata)
|
|
|
|
|
{
|
2023-08-11 10:55:58 +08:00
|
|
|
|
return new OverlapHitCallbackTrampoline(
|
|
|
|
|
process_touches_callback, finalize_query_callback, touchesBuffer, numTouches, userdata
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API physx::PxAllocatorCallback* CALL create_alloc_callback(
|
2023-08-11 10:55:58 +08:00
|
|
|
|
AllocCallback alloc_callback,
|
|
|
|
|
DeallocCallback dealloc_callback,
|
2023-08-11 15:35:45 +08:00
|
|
|
|
void* userdata)
|
|
|
|
|
{
|
2023-08-11 10:55:58 +08:00
|
|
|
|
return new CustomAllocatorTrampoline(alloc_callback, dealloc_callback, userdata);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void* CALL get_alloc_callback_user_data(physx::PxAllocatorCallback* allocator) {
|
|
|
|
|
CustomAllocatorTrampoline* trampoline = static_cast<CustomAllocatorTrampoline*>(allocator);
|
|
|
|
|
return trampoline->mUserData;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API physx::PxProfilerCallback* CALL create_profiler_callback(
|
2023-08-11 10:55:58 +08:00
|
|
|
|
ZoneStartCallback zone_start_callback,
|
|
|
|
|
ZoneEndCallback zone_end_callback,
|
2023-08-11 15:35:45 +08:00
|
|
|
|
void* userdata)
|
|
|
|
|
{
|
2023-08-11 10:55:58 +08:00
|
|
|
|
return new CustomProfilerTrampoline(zone_start_callback, zone_end_callback, userdata);
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API physx::PxErrorCallback* CALL create_error_callback(
|
2023-08-11 10:55:58 +08:00
|
|
|
|
ErrorCallback error_callback,
|
2023-08-11 15:35:45 +08:00
|
|
|
|
void* userdata)
|
|
|
|
|
{
|
2023-08-11 10:55:58 +08:00
|
|
|
|
return new ErrorTrampoline(error_callback, userdata);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//physx::PxAssertHandler* create_assert_handler( AssertHandler on_assert,void* userdata )
|
|
|
|
|
//{
|
|
|
|
|
// return new AssertTrampoline(on_assert, userdata);
|
|
|
|
|
//}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API void* CALL get_default_simulation_filter_shader()
|
2023-08-11 10:55:58 +08:00
|
|
|
|
{
|
|
|
|
|
return (void*)physx::PxDefaultSimulationFilterShader;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API physx::PxSimulationFilterCallback* CALL create_simulation_filter_callbacks(const SimuliationFilterCallBackInfo* callbacks)
|
2023-08-11 10:55:58 +08:00
|
|
|
|
{
|
|
|
|
|
SimulationFilterCallBackTrampoline* trampoline = new SimulationFilterCallBackTrampoline(callbacks);
|
|
|
|
|
return static_cast<physx::PxSimulationFilterCallback*>(trampoline);
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API void CALL destroy_simulation_filter_callbacks(physx::PxSimulationFilterCallback* callback)
|
2023-08-11 10:55:58 +08:00
|
|
|
|
{
|
|
|
|
|
SimulationFilterCallBackTrampoline* trampoline = static_cast<SimulationFilterCallBackTrampoline*>(callback);
|
|
|
|
|
delete trampoline;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API physx::PxSimulationEventCallback* CALL create_simulation_event_callbacks(const SimulationEventCallbackInfo* callbacks)
|
2023-08-11 10:55:58 +08:00
|
|
|
|
{
|
|
|
|
|
SimulationEventTrampoline* trampoline = new SimulationEventTrampoline(callbacks);
|
|
|
|
|
return static_cast<physx::PxSimulationEventCallback*>(trampoline);
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API SimulationEventCallbackInfo* CALL get_simulation_event_info(physx::PxSimulationEventCallback* callback)
|
2023-08-11 10:55:58 +08:00
|
|
|
|
{
|
|
|
|
|
SimulationEventTrampoline* trampoline = static_cast<SimulationEventTrampoline*>(callback);
|
|
|
|
|
return &trampoline->mCallbacks;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API void CALL destroy_simulation_event_callbacks(physx::PxSimulationEventCallback* callback)
|
2023-08-11 10:55:58 +08:00
|
|
|
|
{
|
|
|
|
|
SimulationEventTrampoline* trampoline = static_cast<SimulationEventTrampoline*>(callback);
|
|
|
|
|
delete trampoline;
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-11 15:35:45 +08:00
|
|
|
|
EXPORT_API void CALL enable_custom_filter_shader(physx::PxSceneDesc* desc, SimulationShaderFilter filter, uint32_t call_default_filter_shader_first)
|
2023-08-11 10:55:58 +08:00
|
|
|
|
{
|
|
|
|
|
/* Note: This is a workaround to PhysX copying the filter data */
|
|
|
|
|
static FilterCallbackData filterShaderData = {
|
|
|
|
|
filter,
|
|
|
|
|
call_default_filter_shader_first != 0
|
|
|
|
|
};
|
|
|
|
|
desc->filterShader = FilterShaderTrampoline;
|
|
|
|
|
// printf("Setting pointer to %p\n", filter);
|
|
|
|
|
desc->filterShaderData = (void*)&filterShaderData;
|
|
|
|
|
desc->filterShaderDataSize = sizeof(FilterCallbackData);
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-22 18:25:34 +08:00
|
|
|
|
|
|
|
|
|
EXPORT_API int32_t CALL PxGeometryHolder_getType(physx_PxGeometryHolder_Pod const* self__pod) {
|
|
|
|
|
physx::PxGeometryHolder const* self_ = reinterpret_cast<physx::PxGeometryHolder const*>(self__pod);
|
|
|
|
|
physx::PxGeometryType::Enum return_val = self_->getType();
|
|
|
|
|
int32_t return_val_pod;
|
|
|
|
|
memcpy(&return_val_pod, &return_val, sizeof(return_val_pod));
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EXPORT_API physx_PxGeometry_Pod* CALL PxGeometryHolder_any_mut(physx_PxGeometryHolder_Pod* self__pod) {
|
|
|
|
|
physx::PxGeometryHolder* self_ = reinterpret_cast<physx::PxGeometryHolder*>(self__pod);
|
|
|
|
|
physx::PxGeometry& return_val = self_->any();
|
|
|
|
|
auto return_val_pod = reinterpret_cast<physx_PxGeometry_Pod*>(&return_val);
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EXPORT_API physx_PxGeometry_Pod const* CALL PxGeometryHolder_any(physx_PxGeometryHolder_Pod const* self__pod) {
|
|
|
|
|
physx::PxGeometryHolder const* self_ = reinterpret_cast<physx::PxGeometryHolder const*>(self__pod);
|
|
|
|
|
physx::PxGeometry const& return_val = self_->any();
|
|
|
|
|
auto return_val_pod = reinterpret_cast<physx_PxGeometry_Pod const*>(&return_val);
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EXPORT_API physx_PxSphereGeometry_Pod* CALL PxGeometryHolder_sphere_mut(physx_PxGeometryHolder_Pod* self__pod) {
|
|
|
|
|
physx::PxGeometryHolder* self_ = reinterpret_cast<physx::PxGeometryHolder*>(self__pod);
|
|
|
|
|
physx::PxSphereGeometry& return_val = self_->sphere();
|
|
|
|
|
auto return_val_pod = reinterpret_cast<physx_PxSphereGeometry_Pod*>(&return_val);
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EXPORT_API physx_PxSphereGeometry_Pod const* CALL PxGeometryHolder_sphere(physx_PxGeometryHolder_Pod const* self__pod) {
|
|
|
|
|
physx::PxGeometryHolder const* self_ = reinterpret_cast<physx::PxGeometryHolder const*>(self__pod);
|
|
|
|
|
physx::PxSphereGeometry const& return_val = self_->sphere();
|
|
|
|
|
auto return_val_pod = reinterpret_cast<physx_PxSphereGeometry_Pod const*>(&return_val);
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EXPORT_API physx_PxPlaneGeometry_Pod* CALL PxGeometryHolder_plane_mut(physx_PxGeometryHolder_Pod* self__pod) {
|
|
|
|
|
physx::PxGeometryHolder* self_ = reinterpret_cast<physx::PxGeometryHolder*>(self__pod);
|
|
|
|
|
physx::PxPlaneGeometry& return_val = self_->plane();
|
|
|
|
|
auto return_val_pod = reinterpret_cast<physx_PxPlaneGeometry_Pod*>(&return_val);
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EXPORT_API physx_PxPlaneGeometry_Pod const* CALL PxGeometryHolder_plane(physx_PxGeometryHolder_Pod const* self__pod) {
|
|
|
|
|
physx::PxGeometryHolder const* self_ = reinterpret_cast<physx::PxGeometryHolder const*>(self__pod);
|
|
|
|
|
physx::PxPlaneGeometry const& return_val = self_->plane();
|
|
|
|
|
auto return_val_pod = reinterpret_cast<physx_PxPlaneGeometry_Pod const*>(&return_val);
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EXPORT_API physx_PxCapsuleGeometry_Pod* CALL PxGeometryHolder_capsule_mut(physx_PxGeometryHolder_Pod* self__pod) {
|
|
|
|
|
physx::PxGeometryHolder* self_ = reinterpret_cast<physx::PxGeometryHolder*>(self__pod);
|
|
|
|
|
physx::PxCapsuleGeometry& return_val = self_->capsule();
|
|
|
|
|
auto return_val_pod = reinterpret_cast<physx_PxCapsuleGeometry_Pod*>(&return_val);
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EXPORT_API physx_PxCapsuleGeometry_Pod const* CALL PxGeometryHolder_capsule(physx_PxGeometryHolder_Pod const* self__pod) {
|
|
|
|
|
physx::PxGeometryHolder const* self_ = reinterpret_cast<physx::PxGeometryHolder const*>(self__pod);
|
|
|
|
|
physx::PxCapsuleGeometry const& return_val = self_->capsule();
|
|
|
|
|
auto return_val_pod = reinterpret_cast<physx_PxCapsuleGeometry_Pod const*>(&return_val);
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EXPORT_API physx_PxBoxGeometry_Pod* CALL PxGeometryHolder_box_mut(physx_PxGeometryHolder_Pod* self__pod) {
|
|
|
|
|
physx::PxGeometryHolder* self_ = reinterpret_cast<physx::PxGeometryHolder*>(self__pod);
|
|
|
|
|
physx::PxBoxGeometry& return_val = self_->box();
|
|
|
|
|
auto return_val_pod = reinterpret_cast<physx_PxBoxGeometry_Pod*>(&return_val);
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EXPORT_API physx_PxBoxGeometry_Pod const* CALL PxGeometryHolder_box(physx_PxGeometryHolder_Pod const* self__pod) {
|
|
|
|
|
physx::PxGeometryHolder const* self_ = reinterpret_cast<physx::PxGeometryHolder const*>(self__pod);
|
|
|
|
|
physx::PxBoxGeometry const& return_val = self_->box();
|
|
|
|
|
auto return_val_pod = reinterpret_cast<physx_PxBoxGeometry_Pod const*>(&return_val);
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EXPORT_API void CALL PxGeometryHolder_storeAny_mut(physx_PxGeometryHolder_Pod* self__pod, physx_PxGeometry_Pod const* geometry_pod) {
|
|
|
|
|
physx::PxGeometryHolder* self_ = reinterpret_cast<physx::PxGeometryHolder*>(self__pod);
|
|
|
|
|
physx::PxGeometry const& geometry = reinterpret_cast<physx::PxGeometry const&>(*geometry_pod);
|
|
|
|
|
self_->storeAny(geometry);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EXPORT_API physx_PxGeometryHolder_Pod CALL PxGeometryHolder_new() {
|
|
|
|
|
physx::PxGeometryHolder return_val;
|
|
|
|
|
physx_PxGeometryHolder_Pod return_val_pod;
|
|
|
|
|
memcpy(&return_val_pod, &return_val, sizeof(return_val_pod));
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
EXPORT_API physx_PxGeometryHolder_Pod CALL PxGeometryHolder_new_1(physx_PxGeometry_Pod const* geometry_pod) {
|
|
|
|
|
physx::PxGeometry const& geometry = reinterpret_cast<physx::PxGeometry const&>(*geometry_pod);
|
|
|
|
|
physx::PxGeometryHolder return_val(geometry);
|
|
|
|
|
physx_PxGeometryHolder_Pod return_val_pod;
|
|
|
|
|
memcpy(&return_val_pod, &return_val, sizeof(return_val_pod));
|
|
|
|
|
return return_val_pod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-08-11 10:55:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|