Skip to content

Commit

Permalink
UPBGE: Implement physics empty shape.
Browse files Browse the repository at this point in the history
An empty shape might be usefull for compound shape
were the parent must not have its own shape. In this
case the empty shape is used.
  • Loading branch information
panzergame committed Aug 31, 2017
1 parent 0ba9897 commit 9d101f5
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions source/blender/makesdna/DNA_object_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ enum {
OB_BOUND_CONVEX_HULL = 5,
/* OB_BOUND_DYN_MESH = 6, */ /*UNUSED*/
OB_BOUND_CAPSULE = 7,
OB_BOUND_EMPTY = 8,
};

/* lod flags */
Expand Down
2 changes: 2 additions & 0 deletions source/blender/makesrna/intern/rna_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ static EnumPropertyItem collision_bounds_items[] = {
{OB_BOUND_CONVEX_HULL, "CONVEX_HULL", ICON_MESH_ICOSPHERE, "Convex Hull", ""},
{OB_BOUND_TRIANGLE_MESH, "TRIANGLE_MESH", ICON_MESH_MONKEY, "Triangle Mesh", ""},
{OB_BOUND_CAPSULE, "CAPSULE", ICON_MESH_CAPSULE, "Capsule", ""},
{OB_BOUND_EMPTY, "Empty", ICON_EMPTY_DATA, "Empty", ""},
/*{OB_DYN_MESH, "DYNAMIC_MESH", 0, "Dynamic Mesh", ""}, */
{0, NULL, 0, NULL, NULL}
};
Expand Down Expand Up @@ -504,6 +505,7 @@ static EnumPropertyItem *rna_Object_collision_bounds_itemf(bContext *UNUSED(C),
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_items_add_value(&item, &totitem, collision_bounds_items, OB_BOUND_EMPTY);
}

RNA_enum_item_end(&item, &totitem);
Expand Down
6 changes: 6 additions & 0 deletions source/gameengine/Physics/Bullet/CcdPhysicsController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2556,6 +2556,12 @@ btCollisionShape *CcdShapeConstructionInfo::CreateBulletShape(btScalar margin, b
collisionShape = compoundShape;
}
break;
case PHY_SHAPE_EMPTY:
{
collisionShape = new btEmptyShape();
collisionShape->setMargin(margin);
break;
}
}
return collisionShape;
}
Expand Down
6 changes: 6 additions & 0 deletions source/gameengine/Physics/Bullet/CcdPhysicsEnvironment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2930,6 +2930,12 @@ void CcdPhysicsEnvironment::ConvertObject(BL_BlenderSceneConverter& converter, K

break;
}
case OB_BOUND_EMPTY:
{
shapeInfo->m_shapeType = PHY_SHAPE_EMPTY;
bm = shapeInfo->CreateBulletShape(ci.m_margin);
break;
}
}

if (!bm) {
Expand Down
1 change: 1 addition & 0 deletions source/gameengine/Physics/Common/PHY_DynamicTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ typedef enum PHY_ShapeType {
PHY_SHAPE_MESH,
PHY_SHAPE_POLYTOPE,
PHY_SHAPE_COMPOUND,
PHY_SHAPE_EMPTY,
PHY_SHAPE_PROXY
} PHY_ShapeType;

Expand Down

0 comments on commit 9d101f5

Please sign in to comment.