Fix #28865: Draw_bounds_type does not display Polyhedron or Capsule types

Separate DNA properties for bounding box used for bounding box display
in 3d viewport and bounding box used for collision detection in game engine.

Bumped subversion for proper updating old files to new system, but it
need more complex testing.
This commit is contained in:
Sergey Sharybin 2011-11-04 15:53:34 +00:00
parent ac47da5d6b
commit 77934cfaed
6 changed files with 37 additions and 19 deletions

@ -42,7 +42,7 @@ extern "C" {
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 260
#define BLENDER_SUBVERSION 0
#define BLENDER_SUBVERSION 1
#define BLENDER_MINVERSION 250
#define BLENDER_MINSUBVERSION 0

@ -12157,8 +12157,13 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
/* put compatibility code here until next subversion bump */
{
if (main->versionfile < 260 || (main->versionfile == 260 && main->subversionfile < 1)){
Object *ob;
for (ob= main->object.first; ob; ob= ob->id.next) {
ob->collision_boundtype= ob->boundtype;
}
{
Camera *cam;
for(cam= main->camera.first; cam; cam= cam->id.next) {
@ -12171,6 +12176,11 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
}
}
/* put compatibility code here until next subversion bump */
{
}
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
/* WATCH IT 2!: Userdef struct init has to be in editors/interface/resources.c! */

@ -107,7 +107,7 @@
((vd->drawtype==OB_TEXTURE && dt>OB_SOLID) || \
(vd->drawtype==OB_SOLID && vd->flag2 & V3D_SOLID_TEX))
static void draw_bounding_volume(Scene *scene, Object *ob);
static void draw_bounding_volume(Scene *scene, Object *ob, short type);
static void drawcube_size(float size);
static void drawcircle_size(float size);
@ -2703,7 +2703,7 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
if(dt==OB_BOUNDBOX) {
if((v3d->flag2 & V3D_RENDER_OVERRIDE && v3d->drawtype >= OB_WIRE)==0)
draw_bounding_volume(scene, ob);
draw_bounding_volume(scene, ob, ob->boundtype);
}
else if(hasHaloMat || (totface==0 && totedge==0)) {
glPointSize(1.5);
@ -5508,7 +5508,7 @@ static void draw_bb_quadric(BoundBox *bb, short type)
gluDeleteQuadric(qobj);
}
static void draw_bounding_volume(Scene *scene, Object *ob)
static void draw_bounding_volume(Scene *scene, Object *ob, short type)
{
BoundBox *bb= NULL;
@ -5534,8 +5534,8 @@ static void draw_bounding_volume(Scene *scene, Object *ob)
if(bb==NULL) return;
if(ob->boundtype==OB_BOUND_BOX) draw_box(bb->vec);
else draw_bb_quadric(bb, ob->boundtype);
if(type==OB_BOUND_BOX) draw_box(bb->vec);
else draw_bb_quadric(bb, type);
}
@ -6101,7 +6101,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
}
else if(dt==OB_BOUNDBOX) {
if((v3d->flag2 & V3D_RENDER_OVERRIDE && v3d->drawtype >= OB_WIRE)==0)
draw_bounding_volume(scene, ob);
draw_bounding_volume(scene, ob, ob->boundtype);
}
else if(ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb))
empty_object= drawDispList(scene, v3d, rv3d, base, dt);
@ -6117,7 +6117,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
}
else if(dt==OB_BOUNDBOX) {
if((v3d->flag2 & V3D_RENDER_OVERRIDE && v3d->drawtype >= OB_WIRE)==0)
draw_bounding_volume(scene, ob);
draw_bounding_volume(scene, ob, ob->boundtype);
}
else if(ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) {
empty_object= drawDispList(scene, v3d, rv3d, base, dt);
@ -6134,7 +6134,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
drawmball(scene, v3d, rv3d, base, dt);
else if(dt==OB_BOUNDBOX) {
if((v3d->flag2 & V3D_RENDER_OVERRIDE && v3d->drawtype >= OB_WIRE)==0)
draw_bounding_volume(scene, ob);
draw_bounding_volume(scene, ob, ob->boundtype);
}
else
empty_object= drawmball(scene, v3d, rv3d, base, dt);
@ -6376,6 +6376,14 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
}
}
if(ob->gameflag & OB_BOUNDS) {
if(ob->boundtype!=ob->collision_boundtype || (dtx & OB_BOUNDBOX)==0) {
setlinestyle(2);
draw_bounding_volume(scene, ob, ob->collision_boundtype);
setlinestyle(0);
}
}
/* draw extra: after normal draw because of makeDispList */
if(dtx && (G.f & G_RENDER_OGL)==0) {
@ -6383,8 +6391,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
drawaxes(1.0f, OB_ARROWS);
}
if(dtx & OB_BOUNDBOX) {
if((v3d->flag2 & V3D_RENDER_OVERRIDE)==0)
draw_bounding_volume(scene, ob);
draw_bounding_volume(scene, ob, ob->boundtype);
}
if(dtx & OB_TEXSPACE) drawtexspace(ob);
if(dtx & OB_DRAWNAME) {

@ -265,7 +265,9 @@ typedef struct Object {
ListBase *duplilist; /* for temporary dupli list storage, only for use by RNA API */
float ima_ofs[2]; /* offset for image empties */
char pad3[8];
short collision_boundtype; /* bounding box type used for collision */
char pad3[6];
} Object;
/* Warning, this is not used anymore because hooks are now modifiers */

@ -948,10 +948,10 @@ static void rna_GameObjectSettings_physics_type_set(PointerRNA *ptr, int value)
if (ob->type == OB_MESH) {
/* this is needed to refresh the derived meshes draw func */
DAG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
WM_main_add_notifier(NC_OBJECT|ND_DRAW, ptr->id.data);
}
}
WM_main_add_notifier(NC_OBJECT|ND_DRAW, ptr->id.data);
}
static PointerRNA rna_Object_active_particle_system_get(PointerRNA *ptr)
@ -1532,9 +1532,10 @@ static void rna_def_object_game_settings(BlenderRNA *brna)
prop= RNA_def_property(srna, "use_collision_bounds", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "gameflag", OB_BOUNDS);
RNA_def_property_ui_text(prop, "Use Collision Bounds", "Specify a collision bounds type other than the default");
RNA_def_property_update(prop, NC_OBJECT|ND_DRAW, NULL);
prop= RNA_def_property(srna, "collision_bounds_type", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "boundtype");
RNA_def_property_enum_sdna(prop, NULL, "collision_boundtype");
RNA_def_property_enum_items(prop, collision_bounds_items);
RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Object_collision_bounds_itemf");
RNA_def_property_ui_text(prop, "Collision Bounds", "Select the collision type");
@ -1803,8 +1804,6 @@ static void rna_def_object(BlenderRNA *brna)
{OB_BOUND_SPHERE, "SPHERE", 0, "Sphere", "Draw bounds as sphere"},
{OB_BOUND_CYLINDER, "CYLINDER", 0, "Cylinder", "Draw bounds as cylinder"},
{OB_BOUND_CONE, "CONE", 0, "Cone", "Draw bounds as cone"},
{OB_BOUND_TRIANGLE_MESH, "POLYHEDRON", 0, "Polyhedron", "Draw bounds as polyhedron"},
{OB_BOUND_CAPSULE, "CAPSULE", 0, "Capsule", "Draw bounds as capsule"},
{0, NULL, 0, NULL, NULL}};
static EnumPropertyItem dupli_items[] = {

@ -1579,7 +1579,7 @@ void BL_CreatePhysicsObjectNew(KX_GameObject* gameobj,
my_get_local_bounds(blenderobject,dm,objprop.m_boundobject.box.m_center,bb.m_extends);
if (blenderobject->gameflag & OB_BOUNDS)
{
switch (blenderobject->boundtype)
switch (blenderobject->collision_boundtype)
{
case OB_BOUND_BOX:
objprop.m_boundclass = KX_BOUNDBOX;