diff options
author | Matt Ebb <matt@mke3.net> | 2010-01-12 04:50:34 +0300 |
---|---|---|
committer | Matt Ebb <matt@mke3.net> | 2010-01-12 04:50:34 +0300 |
commit | e6c61acb68927519d869d150444e1a58798976d3 (patch) | |
tree | e45a8f5180cb09235916dbd9f4e5bdd0755cf999 /source/blender/editors/object | |
parent | 44068d96aa16f7561dfec224776bb16b7f694551 (diff) |
Fix [#20644] new curve sets itself to the origin, but the pivot to the cursor
+ Cleaned up the nurbs spin operator and gave it properties rather than
relying on context
Diffstat (limited to 'source/blender/editors/object')
-rw-r--r-- | source/blender/editors/object/object_add.c | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/source/blender/editors/object/object_add.c b/source/blender/editors/object/object_add.c index 28ddf07fe8e..9740a1cba01 100644 --- a/source/blender/editors/object/object_add.c +++ b/source/blender/editors/object/object_add.c @@ -143,6 +143,35 @@ void ED_object_base_init_transform(bContext *C, Base *base, float *loc, float *r where_is_object(scene, ob); } +/* uses context to figure out transform for primitive */ +/* returns standard diameter */ +float ED_object_new_primitive_matrix(bContext *C, float *loc, float *rot, float primmat[][4]) +{ + Object *obedit= CTX_data_edit_object(C); + View3D *v3d =CTX_wm_view3d(C); + float mat[3][3], rmat[3][3], cmat[3][3], imat[3][3]; + + unit_m4(primmat); + + eul_to_mat3(rmat, rot); + invert_m3(rmat); + + /* inverse transform for initial rotation and object */ + copy_m3_m4(mat, obedit->obmat); + mul_m3_m3m3(cmat, rmat, mat); + invert_m3_m3(imat, cmat); + copy_m4_m3(primmat, imat); + + /* center */ + VECCOPY(primmat[3], loc); + VECSUB(primmat[3], primmat[3], obedit->obmat[3]); + invert_m3_m3(imat, mat); + mul_m3_v3(imat, primmat[3]); + + if(v3d) return v3d->grid; + return 1.0f; +} + /********************* Add Object Operator ********************/ void add_object_draw(Scene *scene, View3D *v3d, int type) /* for toolbox or menus, only non-editmode stuff */ @@ -297,6 +326,7 @@ static Object *effector_add_type(bContext *C, wmOperator *op, int type) Object *ob; int enter_editmode; float loc[3], rot[3]; + float mat[4][4]; object_add_generic_invoke_options(C, op); ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode); @@ -307,7 +337,8 @@ static Object *effector_add_type(bContext *C, wmOperator *op, int type) ((Curve*)ob->data)->flag |= CU_PATH|CU_3D; ED_object_enter_editmode(C, 0); - BLI_addtail(curve_get_editcurve(ob), add_nurbs_primitive(C, CU_NURBS|CU_PRIM_PATH, 1)); + ED_object_new_primitive_matrix(C, loc, rot, mat); + BLI_addtail(curve_get_editcurve(ob), add_nurbs_primitive(C, mat, CU_NURBS|CU_PRIM_PATH, 1)); if(!enter_editmode) ED_object_exit_editmode(C, EM_FREEDATA|EM_DO_UNDO); @@ -424,6 +455,7 @@ static int object_add_curve_exec(bContext *C, wmOperator *op) int newob= 0, type= RNA_enum_get(op->ptr, "type"); int enter_editmode; float loc[3], rot[3]; + float mat[4][4]; object_add_generic_invoke_options(C, op); // XXX these props don't get set right when only exec() is called ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode); @@ -437,7 +469,9 @@ static int object_add_curve_exec(bContext *C, wmOperator *op) } else DAG_id_flush_update(&obedit->id, OB_RECALC_DATA); - nu= add_nurbs_primitive(C, type, newob); + ED_object_new_primitive_matrix(C, loc, rot, mat); + + nu= add_nurbs_primitive(C, mat, type, newob); editnurb= curve_get_editcurve(obedit); BLI_addtail(editnurb, nu); @@ -509,6 +543,7 @@ static int object_add_surface_exec(bContext *C, wmOperator *op) int newob= 0; int enter_editmode; float loc[3], rot[3]; + float mat[4][4]; object_add_generic_invoke_options(C, op); // XXX these props don't get set right when only exec() is called ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode); @@ -519,7 +554,9 @@ static int object_add_surface_exec(bContext *C, wmOperator *op) } else DAG_id_flush_update(&obedit->id, OB_RECALC_DATA); - nu= add_nurbs_primitive(C, RNA_enum_get(op->ptr, "type"), newob); + ED_object_new_primitive_matrix(C, loc, rot, mat); + + nu= add_nurbs_primitive(C, mat, RNA_enum_get(op->ptr, "type"), newob); editnurb= curve_get_editcurve(obedit); BLI_addtail(editnurb, nu); @@ -570,6 +607,7 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op) int newob= 0; int enter_editmode; float loc[3], rot[3]; + float mat[4][4]; object_add_generic_invoke_options(C, op); // XXX these props don't get set right when only exec() is called ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode); @@ -580,7 +618,9 @@ static int object_metaball_add_exec(bContext *C, wmOperator *op) } else DAG_id_flush_update(&obedit->id, OB_RECALC_DATA); - elem= (MetaElem*)add_metaball_primitive(C, RNA_enum_get(op->ptr, "type"), newob); + ED_object_new_primitive_matrix(C, loc, rot, mat); + + elem= (MetaElem*)add_metaball_primitive(C, mat, RNA_enum_get(op->ptr, "type"), newob); mball= (MetaBall*)obedit->data; BLI_addtail(mball->editelems, elem); @@ -732,6 +772,7 @@ static int object_lamp_add_exec(bContext *C, wmOperator *op) int enter_editmode; float loc[3], rot[3]; + object_add_generic_invoke_options(C, op); ED_object_add_generic_get_opts(op, loc, rot, &enter_editmode); ob= ED_object_add_type(C, OB_LAMP, loc, rot, FALSE); |