Commit: c4e8d74563e234e6a2cb6ce77f42452b5577fe38
Author: Campbell Barton
Date:   Tue Feb 10 02:38:21 2015 +1100
Branches: master
https://developer.blender.org/rBc4e8d74563e234e6a2cb6ce77f42452b5577fe38

Fix T43498: New curves fails /w radius & rotation

Scaling matrix assumed no rotation,
also remove unused apply_diameter arg.

===================================================================

M       source/blender/editors/curve/editcurve_add.c
M       source/blender/editors/include/ED_object.h
M       source/blender/editors/mesh/editmesh_add.c
M       source/blender/editors/object/object_add.c

===================================================================

diff --git a/source/blender/editors/curve/editcurve_add.c 
b/source/blender/editors/curve/editcurve_add.c
index c9a961d..4e08ada 100644
--- a/source/blender/editors/curve/editcurve_add.c
+++ b/source/blender/editors/curve/editcurve_add.c
@@ -479,7 +479,7 @@ static int curvesurf_prim_add(bContext *C, wmOperator *op, 
int type, int isSurf)
        unsigned int layer;
        float dia;
        float loc[3], rot[3];
-       float mat[4][4];
+       float mat[4][4], scale_mat[4][4];
 
        WM_operator_view3d_unit_defaults(C, op);
 
@@ -529,11 +529,10 @@ static int curvesurf_prim_add(bContext *C, wmOperator 
*op, int type, int isSurf)
        if (newob && enter_editmode)
                ED_undo_push(C, "Enter Editmode");
 
-       ED_object_new_primitive_matrix(C, obedit, loc, rot, mat, false);
+       ED_object_new_primitive_matrix(C, obedit, loc, rot, mat);
        dia = RNA_float_get(op->ptr, "radius");
-       mat[0][0] *= dia;
-       mat[1][1] *= dia;
-       mat[2][2] *= dia;
+       scale_m4_fl(scale_mat, dia);
+       mul_m4_m4m4(mat, scale_mat, mat);
 
        nu = add_nurbs_primitive(C, obedit, mat, type, newob);
        editnurb = object_editcurve_get(obedit);
diff --git a/source/blender/editors/include/ED_object.h 
b/source/blender/editors/include/ED_object.h
index 900da3e..ccdde39 100644
--- a/source/blender/editors/include/ED_object.h
+++ b/source/blender/editors/include/ED_object.h
@@ -141,9 +141,9 @@ bool ED_object_editmode_load(struct Object *obedit);
 void ED_object_location_from_view(struct bContext *C, float loc[3]);
 void ED_object_rotation_from_view(struct bContext *C, float rot[3], const char 
align_axis);
 void ED_object_base_init_transform(struct bContext *C, struct Base *base, 
const float loc[3], const float rot[3]);
-float ED_object_new_primitive_matrix(struct bContext *C, struct Object *editob,
-                                     const float loc[3], const float rot[3], 
float primmat[4][4],
-                                     bool apply_diameter);
+float ED_object_new_primitive_matrix(
+        struct bContext *C, struct Object *editob,
+        const float loc[3], const float rot[3], float primmat[4][4]);
 
 void ED_object_add_unit_props(struct wmOperatorType *ot);
 void ED_object_add_generic_props(struct wmOperatorType *ot, bool do_editmode);
diff --git a/source/blender/editors/mesh/editmesh_add.c 
b/source/blender/editors/mesh/editmesh_add.c
index b288a02..a2160df 100644
--- a/source/blender/editors/mesh/editmesh_add.c
+++ b/source/blender/editors/mesh/editmesh_add.c
@@ -32,6 +32,7 @@
 #include "DNA_object_types.h"
 #include "DNA_scene_types.h"
 
+#include "BLI_math.h"
 
 #include "BLF_translation.h"
 
@@ -71,7 +72,7 @@ static Object *make_prim_init(bContext *C, const char *idname,
                *was_editmode = true;
        }
 
-       *dia = ED_object_new_primitive_matrix(C, obedit, loc, rot, mat, false);
+       *dia = ED_object_new_primitive_matrix(C, obedit, loc, rot, mat);
 
        return obedit;
 }
@@ -421,7 +422,9 @@ static int add_primitive_monkey_exec(bContext *C, 
wmOperator *op)
 {
        Object *obedit;
        BMEditMesh *em;
-       float loc[3], rot[3], mat[4][4], dia;
+       float mat[4][4], scale_mat[4][4];
+       float loc[3], rot[3];
+       float dia;
        bool enter_editmode;
        unsigned int layer;
        bool was_editmode;
@@ -431,9 +434,8 @@ static int add_primitive_monkey_exec(bContext *C, 
wmOperator *op)
 
        obedit = make_prim_init(C, CTX_DATA_(BLF_I18NCONTEXT_ID_MESH, 
"Suzanne"), &dia, mat, &was_editmode, loc, rot, layer);
        dia = RNA_float_get(op->ptr, "radius");
-       mat[0][0] *= dia;
-       mat[1][1] *= dia;
-       mat[2][2] *= dia;
+       scale_m4_fl(scale_mat, dia);
+       mul_m4_m4m4(mat, scale_mat, mat);
 
        em = BKE_editmesh_from_object(obedit);
 
diff --git a/source/blender/editors/object/object_add.c 
b/source/blender/editors/object/object_add.c
index 2fde095..1180c08 100644
--- a/source/blender/editors/object/object_add.c
+++ b/source/blender/editors/object/object_add.c
@@ -218,9 +218,9 @@ void ED_object_base_init_transform(bContext *C, Base *base, 
const float loc[3],
 
 /* Uses context to figure out transform for primitive.
  * Returns standard diameter. */
-float ED_object_new_primitive_matrix(bContext *C, Object *obedit,
-                                     const float loc[3], const float rot[3], 
float primmat[4][4],
-                                     bool apply_diameter)
+float ED_object_new_primitive_matrix(
+        bContext *C, Object *obedit,
+        const float loc[3], const float rot[3], float primmat[4][4])
 {
        Scene *scene = CTX_data_scene(C);
        View3D *v3d = CTX_wm_view3d(C);
@@ -245,13 +245,6 @@ float ED_object_new_primitive_matrix(bContext *C, Object 
*obedit,
 
        {
                const float dia = v3d ? ED_view3d_grid_scale(scene, v3d, NULL) 
: ED_scene_grid_scale(scene, NULL);
-
-               if (apply_diameter) {
-                       primmat[0][0] *= dia;
-                       primmat[1][1] *= dia;
-                       primmat[2][2] *= dia;
-               }
-
                return dia;
        }
 
@@ -515,7 +508,7 @@ static int effector_add_exec(bContext *C, wmOperator *op)
                cu = ob->data;
                cu->flag |= CU_PATH | CU_3D;
                ED_object_editmode_enter(C, 0);
-               ED_object_new_primitive_matrix(C, ob, loc, rot, mat, false);
+               ED_object_new_primitive_matrix(C, ob, loc, rot, mat);
                BLI_addtail(&cu->editnurb->nurbs, add_nurbs_primitive(C, ob, 
mat, CU_NURBS | CU_PRIM_PATH, dia));
                if (!enter_editmode)
                        ED_object_editmode_exit(C, EM_FREEDATA);
@@ -638,7 +631,7 @@ static int object_metaball_add_exec(bContext *C, wmOperator 
*op)
                DAG_id_tag_update(&obedit->id, OB_RECALC_DATA);
        }
 
-       ED_object_new_primitive_matrix(C, obedit, loc, rot, mat, false);
+       ED_object_new_primitive_matrix(C, obedit, loc, rot, mat);
        dia = RNA_float_get(op->ptr, "radius");
 
        add_metaball_primitive(C, obedit, mat, dia, RNA_enum_get(op->ptr, 
"type"));

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to