forked from bartvdbraak/blender
BGE patch #22623 applied: new bound type: Capsule.
This commit is contained in:
parent
76918e6f90
commit
ad70072009
@ -402,6 +402,7 @@ extern Object workob;
|
||||
#define OB_BOUND_POLYH 4
|
||||
#define OB_BOUND_POLYT 5
|
||||
#define OB_BOUND_DYN_MESH 6
|
||||
#define OB_BOUND_CAPSULE 7
|
||||
|
||||
|
||||
/* **************** BASE ********************* */
|
||||
@ -564,4 +565,3 @@ typedef enum ObjectMode {
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -76,6 +76,7 @@ static EnumPropertyItem collision_bounds_items[] = {
|
||||
{OB_BOUND_CONE, "CONE", 0, "Cone", ""},
|
||||
{OB_BOUND_POLYT, "CONVEX_HULL", 0, "Convex Hull", ""},
|
||||
{OB_BOUND_POLYH, "TRIANGLE_MESH", 0, "Triangle Mesh", ""},
|
||||
{OB_BOUND_CAPSULE, "CAPSULE", 0, "Capsule", ""},
|
||||
//{OB_DYN_MESH, "DYNAMIC_MESH", 0, "Dynamic Mesh", ""},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
|
||||
@ -384,6 +385,7 @@ static EnumPropertyItem *rna_Object_collision_bounds_itemf(bContext *C, PointerR
|
||||
RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_CYLINDER);
|
||||
RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_SPHERE);
|
||||
RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_BOX);
|
||||
RNA_enum_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_CAPSULE);
|
||||
}
|
||||
|
||||
RNA_enum_item_end(&item, &totitem);
|
||||
@ -1599,6 +1601,7 @@ static void rna_def_object(BlenderRNA *brna)
|
||||
{OB_BOUND_CYLINDER, "CYLINDER", 0, "Cylinder", ""},
|
||||
{OB_BOUND_CONE, "CONE", 0, "Cone", ""},
|
||||
{OB_BOUND_POLYH, "POLYHEDRON", 0, "Polyhedron", ""},
|
||||
{OB_BOUND_CAPSULE, "CAPSULE", 0, "Capsule", ""},
|
||||
{0, NULL, 0, NULL, NULL}};
|
||||
|
||||
static EnumPropertyItem dupli_items[] = {
|
||||
@ -2231,4 +2234,3 @@ void RNA_def_object(BlenderRNA *brna)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -1570,6 +1570,15 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj,
|
||||
objprop.m_boundobject.c.m_height = 2.f*bb.m_extends[2];
|
||||
break;
|
||||
}
|
||||
case OB_BOUND_CAPSULE:
|
||||
{
|
||||
objprop.m_boundclass = KX_BOUNDCAPSULE;
|
||||
objprop.m_boundobject.c.m_radius = MT_max(bb.m_extends[0], bb.m_extends[1]);
|
||||
objprop.m_boundobject.c.m_height = 2.f*(bb.m_extends[2]-objprop.m_boundobject.c.m_radius);
|
||||
if (objprop.m_boundobject.c.m_height < 0.f)
|
||||
objprop.m_boundobject.c.m_height = 0.f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,8 @@ typedef enum {
|
||||
KX_BOUNDCONE,
|
||||
KX_BOUNDMESH,
|
||||
KX_BOUNDPOLYTOPE,
|
||||
KX_BOUND_DYN_MESH
|
||||
KX_BOUND_DYN_MESH,
|
||||
KX_BOUNDCAPSULE
|
||||
} KX_BoundBoxClass;
|
||||
|
||||
struct KX_BoxBounds
|
||||
@ -168,4 +169,3 @@ bool KX_ReInstanceBulletShapeFromMesh(KX_GameObject *gameobj, KX_GameObject *fro
|
||||
|
||||
#endif
|
||||
#endif //KX_CONVERTPHYSICSOBJECTS
|
||||
|
||||
|
@ -184,6 +184,14 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
|
||||
bm = shapeInfo->CreateBulletShape(ci.m_margin);
|
||||
break;
|
||||
}
|
||||
case KX_BOUNDCAPSULE:
|
||||
{
|
||||
shapeInfo->m_radius = objprop->m_boundobject.c.m_radius;
|
||||
shapeInfo->m_height = objprop->m_boundobject.c.m_height;
|
||||
shapeInfo->m_shapeType = PHY_SHAPE_CAPSULE;
|
||||
bm = shapeInfo->CreateBulletShape(ci.m_margin);
|
||||
break;
|
||||
}
|
||||
case KX_BOUNDMESH:
|
||||
{
|
||||
// mesh shapes can be shared, check first if we already have a shape on that mesh
|
||||
@ -553,4 +561,4 @@ bool KX_ReInstanceBulletShapeFromMesh(KX_GameObject *gameobj, KX_GameObject *fro
|
||||
spc->ReplaceControllerShape(bm);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -2027,6 +2027,11 @@ btCollisionShape* CcdShapeConstructionInfo::CreateBulletShape(btScalar margin, b
|
||||
collisionShape->setMargin(margin);
|
||||
break;
|
||||
|
||||
case PHY_SHAPE_CAPSULE:
|
||||
collisionShape = new btCapsuleShapeZ(m_radius, m_height);
|
||||
collisionShape->setMargin(margin);
|
||||
break;
|
||||
|
||||
case PHY_SHAPE_MESH:
|
||||
// Let's use the latest btScaledBvhTriangleMeshShape: it allows true sharing of
|
||||
// triangle mesh information between duplicates => drastic performance increase when
|
||||
@ -2162,4 +2167,3 @@ CcdShapeConstructionInfo::~CcdShapeConstructionInfo()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -138,6 +138,7 @@ typedef enum PHY_ShapeType {
|
||||
PHY_SHAPE_SPHERE,
|
||||
PHY_SHAPE_CYLINDER,
|
||||
PHY_SHAPE_CONE,
|
||||
PHY_SHAPE_CAPSULE,
|
||||
PHY_SHAPE_MESH,
|
||||
PHY_SHAPE_POLYTOPE,
|
||||
PHY_SHAPE_COMPOUND,
|
||||
@ -148,4 +149,3 @@ typedef enum PHY_ShapeType {
|
||||
typedef float PHY_Vector3[3];
|
||||
|
||||
#endif //__PHY_DYNAMIC_TYPES
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user