-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCPxPhysics.cpp
More file actions
executable file
·58 lines (48 loc) · 1.87 KB
/
CPxPhysics.cpp
File metadata and controls
executable file
·58 lines (48 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include <PxPhysicsAPI.h>
#include "CPxPhysics.h"
#include "CPxTransformHelpers.h"
#include "CPxDefaultAllocator.h"
CPxPhysics CPxCreatePhysics(CPxFoundation cfoundation, CPxTolerancesScale cscale, bool trackOutstandingAllocations, CPxPvd* cpvd)
{
physx::PxTolerancesScale tolerances;
tolerances.length = cscale.length;
tolerances.speed = cscale.speed;
CPxPhysics cpPhysics{};
if (cpvd != NULL) {
cpPhysics.obj = PxCreatePhysics(PX_PHYSICS_VERSION, *static_cast<physx::PxFoundation*>(cfoundation.obj), tolerances, trackOutstandingAllocations, static_cast<physx::PxPvd*>(cpvd->obj));
}
else {
cpPhysics.obj = PxCreatePhysics(PX_PHYSICS_VERSION, *static_cast<physx::PxFoundation*>(cfoundation.obj), tolerances, trackOutstandingAllocations);
}
return cpPhysics;
}
CPxScene CPxPhysics_createScene(CPxPhysics cp, CPxSceneDesc csd)
{
CPxScene cs{};
cs.scratchBuffer = NULL;
cs.scratchBufferSize = 0;
cs.obj = static_cast<physx::PxPhysics*>(cp.obj)->createScene(*static_cast<physx::PxSceneDesc*>(csd.obj));
return cs;
}
CPxMaterial CPxPhysics_createMaterial(CPxPhysics cp, CPxReal staticFriction, CPxReal dynamicFriction, CPxReal restitution)
{
CPxMaterial cm{};
cm.obj = static_cast<physx::PxPhysics*>(cp.obj)->createMaterial(staticFriction, dynamicFriction, restitution);
return cm;
}
CPxRigidDynamic CPxPhysics_createRigidDynamic(CPxPhysics cp, CPxTransform* ctr)
{
CPxRigidDynamic crd{};
crd.obj = static_cast<physx::PxPhysics*>(cp.obj)->createRigidDynamic(CPxTransform_toPxTransform(*ctr));
return crd;
}
CPxRigidStatic CPxPhysics_createRigidStatic(CPxPhysics cp, CPxTransform* ctr)
{
CPxRigidStatic crs{};
crs.obj = static_cast<physx::PxPhysics*>(cp.obj)->createRigidStatic(CPxTransform_toPxTransform(*ctr));
return crs;
}
void CPxPhysics_release(CPxPhysics cpp)
{
static_cast<physx::PxPhysics*>(cpp.obj)->release();
}