diff options
author | Alexander Pinzon Fernandez <apinzonf@gmail.com> | 2013-12-11 20:10:22 +0400 |
---|---|---|
committer | Alexander Pinzon Fernandez <apinzonf@gmail.com> | 2013-12-11 20:10:22 +0400 |
commit | 2658a3c1b44717f497f187a38000c804eb37bbba (patch) | |
tree | ee55c673feabced8b6ec8bf9a8aa4d82a3cda3db /source/blender/editors/curve | |
parent | 4005cb1c6a63a217df0e887c741beee2c1359301 (diff) | |
parent | 09b859d03f0ee138c4273ef8460e91d9888387a1 (diff) |
Merge branch 'master' into soc-2013-sketch_meshsoc-2013-sketch_mesh
Conflicts:
release/scripts/addons
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/writefile.c
source/blender/editors/object/object_modifier.c
source/blender/makesrna/intern/rna_modifier.c
source/blender/modifiers/intern/MOD_laplaciandeform.c
Diffstat (limited to 'source/blender/editors/curve')
-rw-r--r-- | source/blender/editors/curve/curve_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/curve/curve_ops.c | 2 | ||||
-rw-r--r-- | source/blender/editors/curve/editcurve.c | 93 | ||||
-rw-r--r-- | source/blender/editors/curve/editfont.c | 3 |
4 files changed, 82 insertions, 18 deletions
diff --git a/source/blender/editors/curve/curve_intern.h b/source/blender/editors/curve/curve_intern.h index da8f86580f6..3ee83c20852 100644 --- a/source/blender/editors/curve/curve_intern.h +++ b/source/blender/editors/curve/curve_intern.h @@ -118,6 +118,8 @@ void CURVE_OT_vertex_add(struct wmOperatorType *ot); void CURVE_OT_extrude(struct wmOperatorType *ot); void CURVE_OT_cyclic_toggle(struct wmOperatorType *ot); +void CURVE_OT_match_texture_space(struct wmOperatorType *ot); + /* helper functions */ void ed_editnurb_translate_flag(struct ListBase *editnurb, short flag, const float vec[3]); bool ed_editnurb_extrude_flag(struct EditNurb *editnurb, short flag); diff --git a/source/blender/editors/curve/curve_ops.c b/source/blender/editors/curve/curve_ops.c index 1cf194e02c4..e978b81523f 100644 --- a/source/blender/editors/curve/curve_ops.c +++ b/source/blender/editors/curve/curve_ops.c @@ -137,6 +137,8 @@ void ED_operatortypes_curve(void) WM_operatortype_append(CURVE_OT_vertex_add); WM_operatortype_append(CURVE_OT_extrude); WM_operatortype_append(CURVE_OT_cyclic_toggle); + + WM_operatortype_append(CURVE_OT_match_texture_space); } void ED_operatormacros_curve(void) diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index f576440fe92..caa06eb15d0 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -47,6 +47,7 @@ #include "BKE_context.h" #include "BKE_curve.h" #include "BKE_depsgraph.h" +#include "BKE_displist.h" #include "BKE_fcurve.h" #include "BKE_global.h" #include "BKE_key.h" @@ -2307,11 +2308,12 @@ static int smooth_exec(bContext *C, wmOperator *UNUSED(op)) BezTriple *bezt, *beztOrig; BPoint *bp, *bpOrig; float val, newval, offset; - int a, i, change = 0; + int a, i; + bool changed = false; for (nu = editnurb->first; nu; nu = nu->next) { if (nu->bezt) { - change = 0; + changed = false; beztOrig = MEM_dupallocN(nu->bezt); for (bezt = &nu->bezt[1], a = 1; a < nu->pntsu - 1; a++, bezt++) { if (bezt->f2 & SELECT) { @@ -2324,12 +2326,13 @@ static int smooth_exec(bContext *C, wmOperator *UNUSED(op)) bezt->vec[0][i] += offset; bezt->vec[2][i] += offset; } - change = 1; + changed = true; } } MEM_freeN(beztOrig); - if (change) + if (changed) { BKE_nurb_handles_calc(nu); + } } else if (nu->bp) { bpOrig = MEM_dupallocN(nu->bp); @@ -3568,7 +3571,7 @@ static int set_spline_type_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; - bool change = false; + bool changed = false; const bool use_handles = RNA_boolean_get(op->ptr, "use_handles"); const int type = RNA_enum_get(op->ptr, "type"); @@ -3582,11 +3585,11 @@ static int set_spline_type_exec(bContext *C, wmOperator *op) if (BKE_nurb_type_convert(nu, type, use_handles) == false) BKE_report(op->reports, RPT_ERROR, "No conversion possible"); else - change = true; + changed = true; } } - if (change) { + if (changed) { if (ED_curve_updateAnimPaths(obedit->data)) WM_event_add_notifier(C, NC_OBJECT | ND_KEYS, obedit); @@ -4364,7 +4367,7 @@ bool ed_editnurb_spin(float viewmat[4][4], Object *obedit, const float axis[3], Curve *cu = (Curve *)obedit->data; ListBase *editnurb = object_editcurve_get(obedit); Nurb *nu; - float si, phi, n[3], q[4], cmat[3][3], tmat[3][3], imat[3][3]; + float cmat[3][3], tmat[3][3], imat[3][3]; float bmat[3][3], rotmat[3][3], scalemat1[3][3], scalemat2[3][3]; float persmat[3][3], persinv[3][3]; bool ok, changed = false; @@ -4377,15 +4380,7 @@ bool ed_editnurb_spin(float viewmat[4][4], Object *obedit, const float axis[3], copy_m3_m4(bmat, obedit->obmat); invert_m3_m3(imat, bmat); - normalize_v3_v3(n, axis); - /* TODO - use math func */ - phi = M_PI / 8.0; - q[0] = cos(phi); - si = sin(phi); - q[1] = n[0] * si; - q[2] = n[1] * si; - q[3] = n[2] * si; - quat_to_mat3(cmat, q); + axis_angle_to_mat3(cmat, axis, M_PI / 4.0); mul_m3_m3m3(tmat, cmat, bmat); mul_m3_m3m3(rotmat, imat, tmat); @@ -6367,7 +6362,7 @@ static int curve_delete_exec(bContext *C, wmOperator *op) Object *obedit = CTX_data_edit_object(C); Curve *cu = (Curve *)obedit->data; eCurveElem_Types type = RNA_enum_get(op->ptr, "type"); - int retval; + int retval = OPERATOR_CANCELLED; if (type == CURVE_VERTEX) retval = curve_delete_vertices(obedit); else if (type == CURVE_SEGMENT) retval = curve_delete_segments(obedit, false); @@ -6813,3 +6808,65 @@ int ED_curve_actSelection(Curve *cu, float center[3]) return 1; } + +/******************** Match texture space operator ***********************/ + +static int match_texture_space_poll(bContext *C) +{ + Object *object = CTX_data_active_object(C); + + return object && ELEM3(object->type, OB_CURVE, OB_SURF, OB_FONT); +} + +static int match_texture_space_exec(bContext *C, wmOperator *UNUSED(op)) +{ + Scene *scene = CTX_data_scene(C); + Object *object = CTX_data_active_object(C); + Curve *curve = (Curve *) object->data; + float min[3], max[3], size[3], loc[3]; + int a; + + if (ELEM(NULL, object->curve_cache, object->curve_cache->disp.first)) { + BKE_displist_make_curveTypes(scene, object, FALSE); + } + + INIT_MINMAX(min, max); + BKE_displist_minmax(&object->curve_cache->disp, min, max); + + mid_v3_v3v3(loc, min, max); + + size[0] = (max[0] - min[0]) / 2.0f; + size[1] = (max[1] - min[1]) / 2.0f; + size[2] = (max[2] - min[2]) / 2.0f; + + for (a = 0; a < 3; a++) { + if (size[a] == 0.0f) size[a] = 1.0f; + else if (size[a] > 0.0f && size[a] < 0.00001f) size[a] = 0.00001f; + else if (size[a] < 0.0f && size[a] > -0.00001f) size[a] = -0.00001f; + } + + copy_v3_v3(curve->loc, loc); + copy_v3_v3(curve->size, size); + zero_v3(curve->rot); + + curve->texflag &= ~CU_AUTOSPACE; + + WM_event_add_notifier(C, NC_GEOM | ND_DATA, curve); + + return OPERATOR_FINISHED; +} + +void CURVE_OT_match_texture_space(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Match Texture Space"; + ot->idname = "CURVE_OT_match_texture_space"; + ot->description = "Match texture space to object's bounding box"; + + /* api callbacks */ + ot->exec = match_texture_space_exec; + ot->poll = match_texture_space_poll; + + /* flags */ + ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; +} diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index 8f536575a28..baedc7ecf25 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -780,6 +780,9 @@ static int paste_selection(Object *obedit, ReportList *reports) /* Verify that the copy buffer => [copy buffer len] + cu->len < MAXTEXT */ if (cu->len + len <= MAXTEXT) { + + kill_selection(obedit, 0); + if (len) { int size = (cu->len * sizeof(wchar_t)) - (cu->pos * sizeof(wchar_t)) + sizeof(wchar_t); memmove(ef->textbuf + cu->pos + len, ef->textbuf + cu->pos, size); |