Fix [#22564] Object name by object type
authorMatt Ebb <matt@mke3.net>
Sun, 27 Jun 2010 07:45:57 +0000 (07:45 +0000)
committerMatt Ebb <matt@mke3.net>
Sun, 27 Jun 2010 07:45:57 +0000 (07:45 +0000)
Restored auto-naming newly created objects by type, for Mesh, Lamp, Meta

source/blender/blenkernel/intern/object.c
source/blender/editors/curve/editcurve.c
source/blender/editors/mesh/editmesh_add.c
source/blender/editors/metaball/mball_edit.c
source/blender/editors/object/object_add.c

index 4e729ce4e9dc3a020ac2a994cdbd0079ccb9e6a0..61d81e461b6f17842a03cb9c154a68b1345d2d2a 100644 (file)
@@ -986,7 +986,7 @@ static char *get_obdata_defname(int type)
        case OB_MESH: return "Mesh";
        case OB_CURVE: return "Curve";
        case OB_SURF: return "Surf";
-       case OB_FONT: return "Font";
+       case OB_FONT: return "Text";
        case OB_MBALL: return "Mball";
        case OB_CAMERA: return "Camera";
        case OB_LAMP: return "Lamp";
index dad111432de658099f5706a26a8d5d2bd1b00cf0..186f3f20082df731c52c66e66285326f15cbc01b 100644 (file)
@@ -5219,8 +5219,8 @@ Nurb *add_nurbs_primitive(bContext *C, float mat[4][4], int type, int newname)
                        float tmp_vec[3] = {0.f, 0.f, 0.f};
                        
                        if(newname) {
-                               rename_id((ID *)obedit, "SurfDonut");
-                               rename_id((ID *)obedit->data, "SurfDonut");
+                               rename_id((ID *)obedit, "SurfTorus");
+                               rename_id((ID *)obedit->data, "SurfTorus");
                        }
 
                        xzproj= 1;
index a7a0a854f1b23571bd405f63545f40f469503cb0..6cdd1dff1fc3cf32a890846a56ff132893a0f12a 100644 (file)
@@ -1262,6 +1262,23 @@ static void make_prim(Object *obedit, int type, float mat[4][4], int tot, int se
 
 /* ********* add primitive operators ************* */
 
+static char *get_mesh_defname(int type)
+{
+       switch (type) {
+               case PRIM_PLANE: return "Plane";
+               case PRIM_CUBE: return "Cube";
+               case PRIM_CIRCLE: return "Circle";
+               case PRIM_CYLINDER: return "Tube";
+               case PRIM_CONE: return "Cone";
+               case PRIM_GRID: return "Grid";
+               case PRIM_UVSPHERE: return "Sphere";
+               case PRIM_ICOSPHERE: return "Icosphere";
+               case PRIM_MONKEY: return "Monkey";
+               default:
+                       return "Mesh";
+       }
+}
+
 static void make_prim_ext(bContext *C, float *loc, float *rot, int enter_editmode, unsigned int layer, 
                int type, int tot, int seg,
                int subdiv, float dia, float depth, int ext, int fill)
@@ -1274,6 +1291,9 @@ static void make_prim_ext(bContext *C, float *loc, float *rot, int enter_editmod
        if(obedit==NULL || obedit->type!=OB_MESH) {
                obedit= ED_object_add_type(C, OB_MESH, loc, rot, FALSE, layer);
                
+               rename_id((ID *)obedit, get_mesh_defname(type));
+               rename_id((ID *)obedit->data, get_mesh_defname(type));
+               
                /* create editmode */
                ED_object_enter_editmode(C, EM_DO_UNDO|EM_IGNORE_LAYER); /* rare cases the active layer is messed up */
                newob = 1;
index 62261c3c68f0624961db15f521ee8826f9cbafa9..2ffccff835dec37c7308cfde46fd0df748abd2df 100644 (file)
@@ -122,24 +122,39 @@ MetaElem *add_metaball_primitive(bContext *C, float mat[4][4], int type, int new
        case MB_BALL:
                ml->type = MB_BALL;
                ml->expx= ml->expy= ml->expz= 1.0;
+                       
+               rename_id((ID *)obedit, "Meta Ball");
+               rename_id((ID *)obedit->data, "Meta Ball");
                break;
        case MB_TUBE:
                ml->type = MB_TUBE;
                ml->expx= ml->expy= ml->expz= 1.0;
+                       
+               rename_id((ID *)obedit, "Meta Tube");
+               rename_id((ID *)obedit->data, "Meta Tube");
                break;
        case MB_PLANE:
                ml->type = MB_PLANE;
                ml->expx= ml->expy= ml->expz= 1.0;
+                       
+               rename_id((ID *)obedit, "Meta Plane");
+               rename_id((ID *)obedit->data, "Meta Plane");
                break;
        case MB_ELIPSOID:
                ml->type = MB_ELIPSOID;
                ml->expx= 1.2f;
                ml->expy= 0.8f;
                ml->expz= 1.0;
+               
+               rename_id((ID *)obedit, "Meta Ellipsoid");
+               rename_id((ID *)obedit->data, "Meta Ellipsoid");
                break;
        case MB_CUBE:
                ml->type = MB_CUBE;
                ml->expx= ml->expy= ml->expz= 1.0;
+                       
+               rename_id((ID *)obedit, "Meta Cube");
+               rename_id((ID *)obedit->data, "Meta Cube");
                break;
        default:
                break;
index ee0fd2b47e903d4ae71a3fb59df95ece5a484523..92256d5e613b193ee56395df66f3e759819cf9ba 100644 (file)
@@ -671,6 +671,19 @@ void OBJECT_OT_armature_add(wmOperatorType *ot)
        ED_object_add_generic_props(ot, TRUE);
 }
 
+static char *get_lamp_defname(int type)
+{
+       switch (type) {
+               case LA_LOCAL: return "Point";
+               case LA_SUN: return "Sun";
+               case LA_SPOT: return "Spot";
+               case LA_HEMI: return "Hemi";
+               case LA_AREA: return "Area";
+               default:
+                       return "Lamp";
+       }
+}
+
 static int object_lamp_add_exec(bContext *C, wmOperator *op)
 {
        Object *ob;
@@ -687,6 +700,9 @@ static int object_lamp_add_exec(bContext *C, wmOperator *op)
        if(ob && ob->data)
                ((Lamp*)ob->data)->type= type;
        
+       rename_id((ID *)ob, get_lamp_defname(type));
+       rename_id((ID *)ob->data, get_lamp_defname(type));
+       
        return OPERATOR_FINISHED;
 }