* Partial fix for bug [#19734] N panel's transform doesn't display the units
authorMatt Ebb <matt@mke3.net>
Wed, 4 Nov 2009 23:14:20 +0000 (23:14 +0000)
committerMatt Ebb <matt@mke3.net>
Wed, 4 Nov 2009 23:14:20 +0000 (23:14 +0000)
Converted the Object transform properties to use rna/rna buttons. This has the advantage of not only displaying/editing units, but also RMB menu, keyframing, drivers, etc too. Part of this was to convert 'Dimensions' to an rna property, converting to and from scale. This also allows you to set the object's dimensions via fcurves or python, but note that it's driving the object scale setting internally so if you animate both dimension and scale at the same time one will override the other (i don't expect many people to attempt this).

source/blender/editors/interface/interface_layout.c
source/blender/editors/space_view3d/view3d_buttons.c
source/blender/makesrna/intern/rna_object.c

index 5c7c1b1..53ccc25 100644 (file)
@@ -336,7 +336,7 @@ static void ui_layer_but_cb(bContext *C, void *arg_but, void *arg_index)
 }
 
 /* create buttons for an item with an RNA array */
-static void ui_item_array(uiLayout *layout, uiBlock *block, char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int len, int x, int y, int w, int h, int expand, int slider)
+static void ui_item_array(uiLayout *layout, uiBlock *block, char *name, int icon, PointerRNA *ptr, PropertyRNA *prop, int len, int x, int y, int w, int h, int expand, int slider, int toggle, int icon_only)
 {
        uiStyle *style= layout->root->style;
        uiBut *but;
@@ -420,7 +420,10 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, char *name, int icon
                                str[0]= RNA_property_array_item_char(prop, a);
 
                                if(str[0]) {
-                                       if(type == PROP_BOOLEAN) {
+                                       if (icon_only) {
+                                               str[0] = '\0';
+                                       }
+                                       else if(type == PROP_BOOLEAN) {
                                                str[1]= '\0';
                                        }
                                        else {
@@ -429,9 +432,11 @@ static void ui_item_array(uiLayout *layout, uiBlock *block, char *name, int icon
                                        }
                                }
 
-                               but= uiDefAutoButR(block, ptr, prop, a, str, 0, 0, 0, w, UI_UNIT_Y);
+                               but= uiDefAutoButR(block, ptr, prop, a, str, icon, 0, 0, w, UI_UNIT_Y);
                                if(slider && but->type==NUM)
                                        but->type= NUMSLI;
+                               if(toggle && but->type==OPTION)
+                                       but->type= TOG;
                        }
                }
                else if(ELEM(subtype, PROP_COLOR, PROP_RGB) && len == 4) {
@@ -909,7 +914,7 @@ void uiItemFullR(uiLayout *layout, char *name, int icon, PointerRNA *ptr, Proper
 
        /* array property */
        if(index == RNA_NO_INDEX && len > 0)
-               ui_item_array(layout, block, name, icon, ptr, prop, len, 0, 0, w, h, expand, slider);
+               ui_item_array(layout, block, name, icon, ptr, prop, len, 0, 0, w, h, expand, slider, toggle, icon_only);
        /* enum item */
        else if(type == PROP_ENUM && index == RNA_ENUM_VALUE) {
                char *identifier= (char*)RNA_property_identifier(prop);
index 276ce52..60856c7 100644 (file)
@@ -709,114 +709,7 @@ static void do_view3d_region_buttons(bContext *C, void *arg, int event)
        case B_OBJECTPANEL:
                DAG_id_flush_update(&ob->id, OB_RECALC_OB);
                break;
-               
-       case B_OBJECTPANELROT:
-               if(ob) {
-                       float eul[3];
-                       
-                       /* make a copy to eul[3], to allow TAB on buttons to work */
-                       eul[0]= M_PI*tfp->ob_eul[0]/180.0;
-                       eul[1]= M_PI*tfp->ob_eul[1]/180.0;
-                       eul[2]= M_PI*tfp->ob_eul[2]/180.0;
-                       
-                       if (ob->rotmode == ROT_MODE_AXISANGLE) {
-                               float quat[4];
-                               /* convert to axis-angle, passing through quats  */
-                               EulToQuat(eul, quat);
-                               QuatToAxisAngle(quat, ob->rotAxis, &ob->rotAngle);
-                       }
-                       else if (ob->rotmode == ROT_MODE_QUAT)
-                               EulToQuat(eul, ob->quat);
-                       else
-                               VecCopyf(ob->rot, eul);
-                               
-                       DAG_id_flush_update(&ob->id, OB_RECALC_OB);
-               }
-               break;
-
-       case B_OBJECTPANELSCALE:
-               if(ob) {
-
-                       /* link scale; figure out which axis changed */
-                       if (tfp->link_scale) {
-                               float ratio, tmp, max = 0.0;
-                               int axis;
-                               
-                               axis = 0;
-                               max = fabs(tfp->ob_scale[0] - ob->size[0]);
-                               tmp = fabs(tfp->ob_scale[1] - ob->size[1]);
-                               if (tmp > max) {
-                                       axis = 1;
-                                       max = tmp;
-                               }
-                               tmp = fabs(tfp->ob_scale[2] - ob->size[2]);
-                               if (tmp > max) {
-                                       axis = 2;
-                                       max = tmp;
-                               }
-                       
-                               if (ob->size[axis] != tfp->ob_scale[axis]) {
-                                       if (fabs(ob->size[axis]) > FLT_EPSILON) {
-                                               ratio = tfp->ob_scale[axis] / ob->size[axis];
-                                               ob->size[0] *= ratio;
-                                               ob->size[1] *= ratio;
-                                               ob->size[2] *= ratio;
-                                       }
-                               }
-                       }
-                       else {
-                               VECCOPY(ob->size, tfp->ob_scale);
-                               
-                       }
-                       DAG_id_flush_update(&ob->id, OB_RECALC_OB);
-               }
-               break;
 
-       case B_OBJECTPANELDIMS:
-               bb= object_get_boundbox(ob);
-               if(bb) {
-                       float old_dims[3], scale[3], ratio, len[3];
-                       int axis;
-
-                       Mat4ToSize(ob->obmat, scale);
-
-                       len[0] = bb->vec[4][0] - bb->vec[0][0];
-                       len[1] = bb->vec[2][1] - bb->vec[0][1];
-                       len[2] = bb->vec[1][2] - bb->vec[0][2];
-
-                       old_dims[0] = fabs(scale[0]) * len[0];
-                       old_dims[1] = fabs(scale[1]) * len[1];
-                       old_dims[2] = fabs(scale[2]) * len[2];
-
-                       /* for each axis changed */
-                       for (axis = 0; axis<3; axis++) {
-                               if (fabs(old_dims[axis] - tfp->ob_dims[axis]) > 0.0001) {
-                                       if (old_dims[axis] > 0.0) {
-                                               ratio = tfp->ob_dims[axis] / old_dims[axis]; 
-                                               if (tfp->link_scale) {
-                                                       ob->size[0] *= ratio;
-                                                       ob->size[1] *= ratio;
-                                                       ob->size[2] *= ratio;
-                                                       break;
-                                               }
-                                               else {
-                                                       ob->size[axis] *= ratio;
-                                               }
-                                       }
-                                       else {
-                                               if (len[axis] > 0) {
-                                                       ob->size[axis] = tfp->ob_dims[axis] / len[axis];
-                                               }
-                                       }
-                               }
-                       }
-                       
-                       /* prevent multiple B_OBJECTPANELDIMS events to keep scaling, cycling with TAB on buttons can cause that */
-                       VECCOPY(tfp->ob_dims, old_dims);
-                       
-                       DAG_id_flush_update(&ob->id, OB_RECALC_OB);
-               }
-               break;
        
        case B_OBJECTPANELMEDIAN:
                if(ob) {
@@ -1119,7 +1012,7 @@ static void view3d_panel_object(const bContext *C, Panel *pa)
        Object *ob= OBACT;
        TransformProperties *tfp;
        PointerRNA obptr;
-       uiLayout *col, *row;
+       uiLayout *col, *row, *split, *colsub;
        float lim;
        
        if(ob==NULL) return;
@@ -1160,117 +1053,61 @@ static void view3d_panel_object(const bContext *C, Panel *pa)
                v3d_posearmature_buts(col, v3d, ob, lim);
        }
        else {
-               BoundBox *bb = NULL;
-
-               uiLayoutAbsoluteBlock(col);
-
-               block= uiLayoutAbsoluteBlock(col);
-               uiDefBut(block, LABEL, 0, "Location:",                                                                          0, 300, 100, 20, 0, 0, 0, 0, 0, "");
-               uiBlockBeginAlign(block);       
-               uiDefButF(block, NUM, B_OBJECTPANEL, "X:",                                                                      0, 280, 120, 19, &(ob->loc[0]), -lim, lim, 100, 3, "");         
-               uiDefButF(block, NUM, B_OBJECTPANEL, "Y:",                                                                      0, 260, 120, 19, &(ob->loc[1]), -lim, lim, 100, 3, "");
-               uiDefButF(block, NUM, B_OBJECTPANEL, "Z:",                                                                      0, 240, 120, 19, &(ob->loc[2]), -lim, lim, 100, 3, "");
-               uiBlockEndAlign(block);
+               split = uiLayoutSplit(col, 0.8);
+               colsub = uiLayoutColumn(split, 1);
+               uiItemR(colsub, "Location", 0, &obptr, "location", 0);
+               colsub = uiLayoutColumn(split, 1);
+               uiItemL(colsub, "", 0);
+               uiItemR(colsub, "", ICON_LOCKED, &obptr, "lock_location", UI_ITEM_R_TOGGLE+UI_ITEM_R_ICON_ONLY);
                
-               uiBlockBeginAlign(block);
-               uiDefIconButBitS(block, ICONTOG, OB_LOCK_LOCX, B_REDR, ICON_UNLOCKED,           125, 280, 25, 19, &(ob->protectflag), 0, 0, 0, 0, "Protects X Location value from being Transformed");
-               uiDefIconButBitS(block, ICONTOG, OB_LOCK_LOCY, B_REDR, ICON_UNLOCKED,           125, 260, 25, 19, &(ob->protectflag), 0, 0, 0, 0, "Protects Y Location value from being Transformed");
-               uiDefIconButBitS(block, ICONTOG, OB_LOCK_LOCZ, B_REDR, ICON_UNLOCKED,           125, 240, 25, 19, &(ob->protectflag), 0, 0, 0, 0, "Protects Z Location value from being Transformed");
-               uiBlockEndAlign(block);
+               split = uiLayoutSplit(col, 0.8);
                
-               if (ob->rotmode == ROT_MODE_AXISANGLE) {
-                       float quat[4];
-                       /* convert to euler, passing through quats... */
-                       AxisAngleToQuat(quat, ob->rotAxis, ob->rotAngle);
-                       QuatToEul(quat, tfp->ob_eul);
+               switch(ob->rotmode) {
+                       case ROT_MODE_XYZ:
+                       case ROT_MODE_XZY:
+                       case ROT_MODE_YXZ:
+                       case ROT_MODE_YZX:
+                       case ROT_MODE_ZXY:
+                       case ROT_MODE_ZYX:
+                               colsub = uiLayoutColumn(split, 1);
+                               uiItemR(colsub, "Rotation", 0, &obptr, "rotation_euler", 0);
+                               colsub = uiLayoutColumn(split, 1);
+                               uiItemL(colsub, "", 0);
+                               uiItemR(colsub, "", ICON_LOCKED, &obptr, "lock_rotation", UI_ITEM_R_TOGGLE+UI_ITEM_R_ICON_ONLY);
+                               break;
+                       case ROT_MODE_QUAT:
+                               colsub = uiLayoutColumn(split, 1);
+                               uiItemR(colsub, "Rotation", 0, &obptr, "rotation_quaternion", 0);
+                               colsub = uiLayoutColumn(split, 1);
+                               uiItemR(colsub, "W", 0, &obptr, "lock_rotations_4d", UI_ITEM_R_TOGGLE);
+                               if (ob->protectflag & OB_LOCK_ROT4D)
+                                       uiItemR(colsub, "", ICON_LOCKED, &obptr, "lock_rotation_w", UI_ITEM_R_TOGGLE+UI_ITEM_R_ICON_ONLY);
+                               else
+                                       uiItemL(colsub, "", 0);
+                               uiItemR(colsub, "", ICON_LOCKED, &obptr, "lock_rotation", UI_ITEM_R_TOGGLE+UI_ITEM_R_ICON_ONLY);
+                               break;
+                       case ROT_MODE_AXISANGLE:
+                               colsub = uiLayoutColumn(split, 1);
+                               uiItemR(colsub, "Rotation", 0, &obptr, "rotation_axis_angle", 0);
+                               colsub = uiLayoutColumn(split, 1);
+                               uiItemR(colsub, "W", 0, &obptr, "lock_rotations_4d", UI_ITEM_R_TOGGLE);
+                               if (ob->protectflag & OB_LOCK_ROT4D)
+                                       uiItemR(colsub, "", ICON_LOCKED, &obptr, "lock_rotation_w", UI_ITEM_R_TOGGLE+UI_ITEM_R_ICON_ONLY);
+                               else
+                                       uiItemL(colsub, "", 0);
+                               uiItemR(colsub, "", ICON_LOCKED, &obptr, "lock_rotation", UI_ITEM_R_TOGGLE+UI_ITEM_R_ICON_ONLY);
+                               break;
                }
-               else if (ob->rotmode == ROT_MODE_QUAT)
-                       QuatToEul(ob->quat, tfp->ob_eul);
-               else
-                       VecCopyf(tfp->ob_eul, ob->rot);
-               tfp->ob_eul[0]*= 180.0/M_PI;
-               tfp->ob_eul[1]*= 180.0/M_PI;
-               tfp->ob_eul[2]*= 180.0/M_PI;
+               uiItemR(col, "", 0, &obptr, "rotation_mode", 0);
                
-               uiBlockBeginAlign(block);
-               if ((ob->parent) && (ob->partype == PARBONE)) {
-                       uiDefBut(block, LABEL, 0, "Rotation:",                                                                  0, 220, 100, 20, 0, 0, 0, 0, 0, "");
-                       uiBlockBeginAlign(block);
-                       uiDefButF(block, NUM, B_OBJECTPANELROT, "X:",                                                   0, 200, 120, 19, &(tfp->ob_eul[0]), -lim, lim, 1000, 3, "");
-                       uiDefButF(block, NUM, B_OBJECTPANELROT, "Y:",                                                   0, 180, 120, 19, &(tfp->ob_eul[1]), -lim, lim, 1000, 3, "");
-                       uiDefButF(block, NUM, B_OBJECTPANELROT, "Z:",                                                   0, 160, 120, 19, &(tfp->ob_eul[2]), -lim, lim, 1000, 3, "");
-                       uiBlockEndAlign(block);
-                       
-                       uiBlockBeginAlign(block);
-                       uiDefIconButBitS(block, ICONTOG, OB_LOCK_ROTX, B_REDR, ICON_UNLOCKED,   125, 200, 25, 19, &(ob->protectflag), 0, 0, 0, 0, "Protects X Rotation from being Transformed");
-                       uiDefIconButBitS(block, ICONTOG, OB_LOCK_ROTY, B_REDR, ICON_UNLOCKED,   125, 180, 25, 19, &(ob->protectflag), 0, 0, 0, 0, "Protects Y Rotation value from being Transformed");
-                       uiDefIconButBitS(block, ICONTOG, OB_LOCK_ROTZ, B_REDR, ICON_UNLOCKED,   125, 160, 25, 19, &(ob->protectflag), 0, 0, 0, 0, "Protects Z Rotation value from being Transformed");
-                       uiBlockEndAlign(block);
-
-               }
-               else {
-                       uiDefBut(block, LABEL, 0, "Rotation:",                                                                  0, 220, 100, 20, 0, 0, 0, 0, 0, "");
-                       uiBlockBeginAlign(block);
-                       uiDefButF(block, NUM, B_OBJECTPANELROT, "X:",                                                   0, 200, 120, 19, &(tfp->ob_eul[0]), -lim, lim, 1000, 3, "");                    
-                       uiDefButF(block, NUM, B_OBJECTPANELROT, "Y:",                                                   0, 180, 120, 19, &(tfp->ob_eul[1]), -lim, lim, 1000, 3, "");
-                       uiDefButF(block, NUM, B_OBJECTPANELROT, "Z:",                                                   0, 160, 120, 19, &(tfp->ob_eul[2]), -lim, lim, 1000, 3, "");
-                       uiBlockEndAlign(block);
-                       
-                       uiBlockBeginAlign(block);
-                       uiDefIconButBitS(block, ICONTOG, OB_LOCK_ROTX, B_REDR, ICON_UNLOCKED,   125, 200, 25, 19, &(ob->protectflag), 0, 0, 0, 0, "Protects X Rotation value from being Transformed");
-                       uiDefIconButBitS(block, ICONTOG, OB_LOCK_ROTY, B_REDR, ICON_UNLOCKED,   125, 180, 25, 19, &(ob->protectflag), 0, 0, 0, 0, "Protects Y Rotation value from being Transformed");
-                       uiDefIconButBitS(block, ICONTOG, OB_LOCK_ROTZ, B_REDR, ICON_UNLOCKED,   125, 160, 25, 19, &(ob->protectflag), 0, 0, 0, 0, "Protects Z Rotation value from being Transformed");
-                       uiBlockEndAlign(block);
-               }
-
-               tfp->ob_scale[0]= ob->size[0];
-               tfp->ob_scale[1]= ob->size[1];
-               tfp->ob_scale[2]= ob->size[2];
-
-               uiDefBut(block, LABEL, 0, "Scale:",                                                                                     0, 140, 100, 20, 0, 0, 0, 0, 0, "");
-               uiDefButS(block, OPTION, B_REDR, "Link",                                                                        60, 140, 50, 19, &(tfp->link_scale), 0, 1, 0, 0, "Scale values vary proportionally in all directions");
-               uiBlockBeginAlign(block);
-               uiDefButF(block, NUM, B_OBJECTPANELSCALE, "X:",                                                         0, 120, 120, 19, &(tfp->ob_scale[0]), -lim, lim, 10, 3, "");
-               uiDefButF(block, NUM, B_OBJECTPANELSCALE, "Y:",                                                         0, 100, 120, 19, &(tfp->ob_scale[1]), -lim, lim, 10, 3, "");
-               uiDefButF(block, NUM, B_OBJECTPANELSCALE, "Z:",                                                         0, 80, 120, 19, &(tfp->ob_scale[2]), -lim, lim, 10, 3, "");
-               uiBlockEndAlign(block);
-               
-               uiBlockBeginAlign(block);
-               uiDefIconButBitS(block, ICONTOG, OB_LOCK_SCALEX, B_REDR, ICON_UNLOCKED,         125, 120, 25, 19, &(ob->protectflag), 0, 0, 0, 0, "Protects X Scale value from being Transformed");
-               uiDefIconButBitS(block, ICONTOG, OB_LOCK_SCALEY, B_REDR, ICON_UNLOCKED,         125, 100, 25, 19, &(ob->protectflag), 0, 0, 0, 0, "Protects Y Scale value from being Transformed");
-               uiDefIconButBitS(block, ICONTOG, OB_LOCK_SCALEZ, B_REDR, ICON_UNLOCKED,         125, 80, 25, 19, &(ob->protectflag), 0, 0, 0, 0, "Protects Z Scale value from being Transformed");
+               split = uiLayoutSplit(col, 0.8);
+               colsub = uiLayoutColumn(split, 1);
+               uiItemR(colsub, "Scale", 0, &obptr, "scale", 0);
+               colsub = uiLayoutColumn(split, 1);
+               uiItemL(colsub, "", 0);
+               uiItemR(colsub, "", ICON_LOCKED, &obptr, "lock_scale", UI_ITEM_R_TOGGLE+UI_ITEM_R_ICON_ONLY);
                
-               
-
-               bb= object_get_boundbox(ob);
-               if (bb) {
-                       float scale[3];
-
-                       Mat4ToSize(ob->obmat, scale);
-
-                       tfp->ob_dims[0] = fabs(scale[0]) * (bb->vec[4][0] - bb->vec[0][0]);
-                       tfp->ob_dims[1] = fabs(scale[1]) * (bb->vec[2][1] - bb->vec[0][1]);
-                       tfp->ob_dims[2] = fabs(scale[2]) * (bb->vec[1][2] - bb->vec[0][2]);
-
-                       
-                       if ((ob->parent) && (ob->partype == PARBONE)) {
-                               uiDefBut(block, LABEL, 0, "Dimensions:",                        0, 60, 100, 20, 0, 0, 0, 0, 0, "");
-                               uiBlockBeginAlign(block);
-                               uiDefButF(block, NUM, B_OBJECTPANELDIMS, "X:",          0, 40, 150, 19, &(tfp->ob_dims[0]), 0.0, lim, 10, 3, "Manipulate X bounding box size");
-                               uiDefButF(block, NUM, B_OBJECTPANELDIMS, "Y:",          0, 20, 150, 19, &(tfp->ob_dims[1]), 0.0, lim, 10, 3, "Manipulate Y bounding box size");
-                               uiDefButF(block, NUM, B_OBJECTPANELDIMS, "Z:",          0, 0, 150, 19, &(tfp->ob_dims[2]), 0.0, lim, 10, 3, "Manipulate Z bounding box size");
-
-                       }
-                       else {
-                               uiDefBut(block, LABEL, 0, "Dimensions:",                        0, 60, 100, 20, 0, 0, 0, 0, 0, "");
-                               uiBlockBeginAlign(block);
-                               uiDefButF(block, NUM, B_OBJECTPANELDIMS, "X:",          0, 40, 150, 19, &(tfp->ob_dims[0]), 0.0, lim, 10, 3, "Manipulate X bounding box size");
-                               uiDefButF(block, NUM, B_OBJECTPANELDIMS, "Y:",          0, 20, 150, 19, &(tfp->ob_dims[1]), 0.0, lim, 10, 3, "Manipulate Y bounding box size");
-                               uiDefButF(block, NUM, B_OBJECTPANELDIMS, "Z:",          0, 0, 150, 19, &(tfp->ob_dims[2]), 0.0, lim, 10, 3, "Manipulate Z bounding box size");
-                       }
-
-                       uiBlockEndAlign(block);
-               }
+               uiItemR(col, "Dimensions", 0, &obptr, "dimensions", 0);
        }
 }
 
index 5b6cb16..ad1fdcb 100644 (file)
@@ -94,6 +94,7 @@ EnumPropertyItem object_type_items[] = {
 #include "BKE_depsgraph.h"
 #include "BKE_effect.h"
 #include "BKE_key.h"
+#include "BKE_object.h"
 #include "BKE_material.h"
 #include "BKE_mesh.h"
 #include "BKE_particle.h"
@@ -533,32 +534,47 @@ static void rna_Object_rotation_mode_set(PointerRNA *ptr, int value)
        ob->rotmode= value;
 }
 
-/* not called directly */
-static void rna_Object_scale_linked_set(Object *ob, float value, int axis)
+static void rna_Object_dimensions_get(PointerRNA *ptr, float *value)
 {
-       if(ob->size[axis]==0.0f || value==0.0f) {
-               ob->size[0]= ob->size[1]= ob->size[2]= value;
-       }
-       else {
-               VecMulf(ob->size, value / ob->size[axis]);
+       Object *ob= ptr->data;
+       BoundBox *bb = NULL;
+       
+       bb= object_get_boundbox(ob);
+       if (bb) {
+               float scale[3];
+               
+               Mat4ToSize(ob->obmat, scale);
+               
+               value[0] = fabs(scale[0]) * (bb->vec[4][0] - bb->vec[0][0]);
+               value[1] = fabs(scale[1]) * (bb->vec[2][1] - bb->vec[0][1]);
+               value[2] = fabs(scale[2]) * (bb->vec[1][2] - bb->vec[0][2]);
+       } else {
+               value[0] = value[1] = value[2] = 0.f;
        }
 }
 
-static void rna_Object_scale_x_linked_set(PointerRNA *ptr, float value)
+static void rna_Object_dimensions_set(PointerRNA *ptr, const float *value)
 {
-       rna_Object_scale_linked_set(ptr->data, value, 0);
-}
-static void rna_Object_scale_y_linked_set(PointerRNA *ptr, float value)
-{
-       rna_Object_scale_linked_set(ptr->data, value, 1);
-}
-static void rna_Object_scale_z_linked_set(PointerRNA *ptr, float value)
-{
-       rna_Object_scale_linked_set(ptr->data, value, 2);
+       Object *ob= ptr->data;
+       BoundBox *bb = NULL;
+       
+       bb= object_get_boundbox(ob);
+       if (bb) {
+               float scale[3], len[3];
+               
+               Mat4ToSize(ob->obmat, scale);
+               
+               len[0] = bb->vec[4][0] - bb->vec[0][0];
+               len[1] = bb->vec[2][1] - bb->vec[0][1];
+               len[2] = bb->vec[1][2] - bb->vec[0][2];
+               
+               ob->size[0] = value[0] / len[0];
+               ob->size[1] = value[1] / len[1];
+               ob->size[2] = value[2] / len[2];
+       }
 }
 
 
-
 static PointerRNA rna_MaterialSlot_material_get(PointerRNA *ptr)
 {
        Object *ob= (Object*)ptr->id.data;
@@ -1337,26 +1353,13 @@ static void rna_def_object(BlenderRNA *brna)
        RNA_def_property_float_sdna(prop, NULL, "size");
        RNA_def_property_ui_text(prop, "Scale", "Scaling of the object.");
        RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update");
-       
-       /* linked scale for the transform panel */
-       prop= RNA_def_property(srna, "scale_linked_x", PROP_FLOAT, PROP_NONE);
-       RNA_def_property_float_sdna(prop, NULL, "size[0]");
-       RNA_def_property_float_funcs(prop, NULL, "rna_Object_scale_x_linked_set", NULL);
-       RNA_def_property_ui_text(prop, "Scale X", "Scaling of the objects X axis.");
-       RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update");
-
-       prop= RNA_def_property(srna, "scale_linked_y", PROP_FLOAT, PROP_NONE);
-       RNA_def_property_float_sdna(prop, NULL, "size[1]");
-       RNA_def_property_float_funcs(prop, NULL, "rna_Object_scale_y_linked_set", NULL);
-       RNA_def_property_ui_text(prop, "Scale Y", "Scaling of the objects X axis.");
-       RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update");
 
-       prop= RNA_def_property(srna, "scale_linked_z", PROP_FLOAT, PROP_NONE);
-       RNA_def_property_float_sdna(prop, NULL, "size[2]");
-       RNA_def_property_float_funcs(prop, NULL, "rna_Object_scale_z_linked_set", NULL);
-       RNA_def_property_ui_text(prop, "Scale Z", "Scaling of the objects Z axis.");
+       prop= RNA_def_property(srna, "dimensions", PROP_FLOAT, PROP_XYZ|PROP_UNIT_LENGTH);
+       RNA_def_property_array(prop, 3);
+       RNA_def_property_float_funcs(prop, "rna_Object_dimensions_get", "rna_Object_dimensions_set", NULL);
+       RNA_def_property_ui_text(prop, "Dimensions", "Absolute bounding box dimensions of the object.");
        RNA_def_property_update(prop, NC_OBJECT|ND_TRANSFORM, "rna_Object_update");
-
+       
 
        /* delta transforms */
        prop= RNA_def_property(srna, "delta_location", PROP_FLOAT, PROP_TRANSLATION);