-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCPxRigidActorExt.cpp
More file actions
executable file
·49 lines (43 loc) · 1.86 KB
/
CPxRigidActorExt.cpp
File metadata and controls
executable file
·49 lines (43 loc) · 1.86 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
#include "PxPhysicsAPI.h"
#include "CPxRigidActorExt.h"
CPxInline CPxShape DoCreateExclusiveShape(const CPxRigidActor& actor, const physx::PxGeometry& geometry, const CPxMaterial& material, const CPxShapeFlags& shapeFlags)
{
CPxShape cShape;
cShape.obj = physx::PxRigidActorExt::createExclusiveShape(
*static_cast<physx::PxRigidActor*>(actor.obj),
geometry,
*static_cast<physx::PxMaterial*>(material.obj),
static_cast<physx::PxShapeFlags>(shapeFlags)
);
return cShape;
}
CPxShape createExclusiveShape(CPxRigidActor actor, CPxGeometry geometry, CPxMaterial material, CPxShapeFlags shapeFlags)
{
switch (geometry.type)
{
case CPxGeometryType_eSPHERE:
return DoCreateExclusiveShape(actor, physx::PxSphereGeometry(static_cast<CPxSphereGeometry*>(geometry.obj)->radius), material, shapeFlags);
case CPxGeometryType_ePLANE:
return DoCreateExclusiveShape(actor, physx::PxPlaneGeometry(), material, shapeFlags);
case CPxGeometryType_eCAPSULE:
{
CPxCapsuleGeometry* ccg = static_cast<CPxCapsuleGeometry*>(geometry.obj);
return DoCreateExclusiveShape(actor, physx::PxCapsuleGeometry(ccg->radius, ccg->halfHeight), material, shapeFlags);
}
case CPxGeometryType_eBOX:
{
CPxBoxGeometry* cbg = static_cast<CPxBoxGeometry*>(geometry.obj);
return DoCreateExclusiveShape(actor, physx::PxBoxGeometry(cbg->hx, cbg->hy, cbg->hz), material, shapeFlags);
}
break;
/*case CPxGeometryType_eCONVEXMESH:
break;
case CPxGeometryType_eTRIANGLEMESH:
break;
case CPxGeometryType_eHEIGHTFIELD:
break;*/
}
//NOTE: This is an invalid cast and will crash physx, with an error saying something like 'unknown shape type'.
//We do it here intentionally because the user passed an invalid shape type (or one we don't handle yet)
return DoCreateExclusiveShape(actor, *static_cast<physx::PxGeometry*>(geometry.obj), material, shapeFlags);
}