-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCExtSimpleFactory.cpp
More file actions
executable file
·60 lines (54 loc) · 2.07 KB
/
CExtSimpleFactory.cpp
File metadata and controls
executable file
·60 lines (54 loc) · 2.07 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
59
60
#include <PxPhysicsAPI.h>
#include "CExtSimpleFactory.h"
#include "CPxTransformHelpers.h"
#include "CPxDefaultAllocator.h"
CPxInline physx::PxRigidDynamic* DoPxCreateDynamic(CPxPhysics& sdk, const CPxTransform& transform, const physx::PxGeometry& geometry, CPxMaterial& material, CPxReal density, const CPxTransform *shapeOffset)
{
if (shapeOffset == NULL)
{
return physx::PxCreateDynamic(*static_cast<physx::PxPhysics*>(sdk.obj),
CPxTransform_toPxTransform(transform),
geometry,
*static_cast<physx::PxMaterial*>(material.obj),
physx::PxReal(density));
}
return physx::PxCreateDynamic(*static_cast<physx::PxPhysics*>(sdk.obj),
CPxTransform_toPxTransform(transform),
geometry,
*static_cast<physx::PxMaterial*>(material.obj),
physx::PxReal(density),
CPxTransform_toPxTransform(*shapeOffset));
}
CPxRigidDynamic CPxCreateDynamic(CPxPhysics sdk, CPxTransform* transform, CPxGeometry geometry, CPxMaterial material, CPxReal density, CPxTransform* shapeOffset)
{
CPxRigidDynamic crd = {0};
switch (geometry.type)
{
case CPxGeometryType_eSPHERE:
crd.obj = DoPxCreateDynamic(sdk, *transform, physx::PxSphereGeometry(static_cast<CPxSphereGeometry*>(geometry.obj)->radius), material, density, shapeOffset);
break;
case CPxGeometryType_ePLANE:
crd.obj = DoPxCreateDynamic(sdk, *transform, physx::PxPlaneGeometry(), material, density, shapeOffset);
break;
case CPxGeometryType_eCAPSULE:
{
CPxCapsuleGeometry* ccg = static_cast<CPxCapsuleGeometry*>(geometry.obj);
crd.obj = DoPxCreateDynamic(sdk, *transform, physx::PxCapsuleGeometry(ccg->radius, ccg->halfHeight), material, density, shapeOffset);
}
break;
case CPxGeometryType_eBOX:
{
CPxBoxGeometry* cbg = static_cast<CPxBoxGeometry*>(geometry.obj);
crd.obj = DoPxCreateDynamic(sdk, *transform, physx::PxBoxGeometry(cbg->hx, cbg->hy, cbg->hz), material, density, shapeOffset);
}
break;
// @TODO
/*case CPxGeometryType_eCONVEXMESH:
break;
case CPxGeometryType_eTRIANGLEMESH:
break;
case CPxGeometryType_eHEIGHTFIELD:
break;*/
}
return crd;
}