Fix #28865: Draw_bounds_type does not display Polyhedron or Capsule types
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 4 Nov 2011 15:53:34 +0000 (15:53 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 4 Nov 2011 15:53:34 +0000 (15:53 +0000)
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.

source/blender/blenkernel/BKE_blender.h
source/blender/blenloader/intern/readfile.c
source/blender/editors/space_view3d/drawobject.c
source/blender/makesdna/DNA_object_types.h
source/blender/makesrna/intern/rna_object.c
source/gameengine/Converter/BL_BlenderDataConversion.cpp

index 71771b6077d44a93350ae4373bc9667a45299985..9b28f083a24b7fc266cba1654d066f5a07e3a55c 100644 (file)
@@ -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
index ea8e8f30d76fe1366a1686fab52cb55e6fb50787..678d0e1406f4ebbbc521cd59f909b1d91a69a607 100644 (file)
@@ -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! */
 
index 593537f82d06632512194a344b0eb76a4cbd102c..6a8e850a4eacff35b7db63d47f323f64b7878763 100644 (file)
        ((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) {
index 3e17d7f494214e0934b98cee24d9b0bac607f2f8..d158f227df5aa2cd946674d1f3cf0a3433925593 100644 (file)
@@ -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 */
index bc050f3a90254f3aa648b983b6c5dbceb5b0eba8..7e2700629ad37b8bcb213ed0ef6b846861d59056 100644 (file)
@@ -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[] = {
index ca37b06d12e785b564d4b08c6540336fd174ad7c..779d794cc100094bab4ed5c0293916dbf7dfdab0 100644 (file)
@@ -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;