diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-01-16 03:13:12 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2012-01-16 03:13:12 +0400 |
commit | e0df491d1e465588cc018c6f6d00f72739b71516 (patch) | |
tree | fe4cbcdaa4633545bbc817c28eb780b551e5ac05 /source/blender/editors/transform | |
parent | 76a211d80947a453f594e4cf0a1e0acc6786eddf (diff) | |
parent | 23806a2b7d50082d70a0e4ecab22aafb8433708a (diff) |
Merged changes in the trunk up to revision 43404.
Conflicts resolved:
source/blender/python/SConscript
Diffstat (limited to 'source/blender/editors/transform')
8 files changed, 87 insertions, 61 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index 1029888df23..1e1f6e4279e 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -1403,18 +1403,21 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op) if (t->flag & T_MODAL) { /* save settings if not set in operator */ - if (RNA_struct_find_property(op->ptr, "proportional") && !RNA_property_is_set(op->ptr, "proportional")) { + if ( (prop = RNA_struct_find_property(op->ptr, "proportional")) && !RNA_property_is_set(op->ptr, prop)) + { if (t->obedit) ts->proportional = proportional; else ts->proportional_objects = (proportional != PROP_EDIT_OFF); } - if (RNA_struct_find_property(op->ptr, "proportional_size") && !RNA_property_is_set(op->ptr, "proportional_size")) { + if ( (prop = RNA_struct_find_property(op->ptr, "proportional_size")) && !RNA_property_is_set(op->ptr, prop)) + { ts->proportional_size = t->prop_size; } - - if (RNA_struct_find_property(op->ptr, "proportional_edit_falloff") && !RNA_property_is_set(op->ptr, "proportional_edit_falloff")) { + + if ( (prop = RNA_struct_find_property(op->ptr, "proportional_edit_falloff")) && !RNA_property_is_set(op->ptr, prop)) + { ts->prop_mode = t->prop_mode; } @@ -1425,8 +1428,9 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op) ts->snap_flag &= ~SCE_SNAP; } - if(t->spacetype == SPACE_VIEW3D) { - if (RNA_struct_find_property(op->ptr, "constraint_orientation") && !RNA_property_is_set(op->ptr, "constraint_orientation")) { + if (t->spacetype == SPACE_VIEW3D) { + if ( (prop = RNA_struct_find_property(op->ptr, "constraint_orientation")) && !RNA_property_is_set(op->ptr, prop)) + { View3D *v3d = t->view; v3d->twmode = t->current_orientation; @@ -1441,17 +1445,17 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op) RNA_float_set(op->ptr, "proportional_size", t->prop_size); } - if (RNA_struct_find_property(op->ptr, "axis")) + if ((prop = RNA_struct_find_property(op->ptr, "axis"))) { - RNA_float_set_array(op->ptr, "axis", t->axis); + RNA_property_float_set_array(op->ptr, prop, t->axis); } - if (RNA_struct_find_property(op->ptr, "mirror")) + if ((prop = RNA_struct_find_property(op->ptr, "mirror"))) { - RNA_boolean_set(op->ptr, "mirror", t->flag & T_MIRROR); + RNA_property_boolean_set(op->ptr, prop, t->flag & T_MIRROR); } - if (RNA_struct_find_property(op->ptr, "constraint_axis")) + if ((prop = RNA_struct_find_property(op->ptr, "constraint_axis"))) { /* constraint orientation can be global, event if user selects something else * so use the orientation in the constraint if set @@ -1475,7 +1479,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op) } } - RNA_boolean_set_array(op->ptr, "constraint_axis", constraint_axis); + RNA_property_boolean_set_array(op->ptr, prop, constraint_axis); } } @@ -1483,6 +1487,7 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op) int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int mode) { int options = 0; + PropertyRNA *prop; t->context = C; @@ -1490,9 +1495,12 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int t->state = TRANS_STARTING; - if(RNA_struct_find_property(op->ptr, "texture_space")) - if(RNA_boolean_get(op->ptr, "texture_space")) + if ( (prop = RNA_struct_find_property(op->ptr, "texture_space")) && RNA_property_is_set(op->ptr, prop)) + { + if(RNA_property_boolean_get(op->ptr, prop)) { options |= CTX_TEXTURE; + } + } t->options = options; @@ -1699,10 +1707,9 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int /* overwrite initial values if operator supplied a non-null vector */ - if (RNA_property_is_set(op->ptr, "value")) + if ( (prop = RNA_struct_find_property(op->ptr, "value")) && RNA_property_is_set(op->ptr, prop)) { float values[4]= {0}; /* incase value isn't length 4, avoid uninitialized memory */ - PropertyRNA *prop= RNA_struct_find_property(op->ptr, "value"); if(RNA_property_array_check(prop)) { RNA_float_get_array(op->ptr, "value", values); @@ -1716,19 +1723,19 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int } /* Transformation axis from operator */ - if (RNA_struct_find_property(op->ptr, "axis") && RNA_property_is_set(op->ptr, "axis")) + if ((prop = RNA_struct_find_property(op->ptr, "axis")) && RNA_property_is_set(op->ptr, prop)) { - RNA_float_get_array(op->ptr, "axis", t->axis); + RNA_property_float_get_array(op->ptr, prop, t->axis); normalize_v3(t->axis); copy_v3_v3(t->axis_orig, t->axis); } /* Constraint init from operator */ - if (RNA_struct_find_property(op->ptr, "constraint_axis") && RNA_property_is_set(op->ptr, "constraint_axis")) + if ((prop = RNA_struct_find_property(op->ptr, "constraint_axis")) && RNA_property_is_set(op->ptr, prop)) { int constraint_axis[3]; - RNA_boolean_get_array(op->ptr, "constraint_axis", constraint_axis); + RNA_property_boolean_get_array(op->ptr, prop, constraint_axis); if (constraint_axis[0] || constraint_axis[1] || constraint_axis[2]) { @@ -2559,9 +2566,9 @@ static void headerResize(TransInfo *t, float vec[3], char *str) outputNumInput(&(t->num), tvec); } else { - sprintf(&tvec[0], "%.4f", vec[0]); - sprintf(&tvec[20], "%.4f", vec[1]); - sprintf(&tvec[40], "%.4f", vec[2]); + BLI_snprintf(&tvec[0], 20, "%.4f", vec[0]); + BLI_snprintf(&tvec[20], 20, "%.4f", vec[1]); + BLI_snprintf(&tvec[40], 20, "%.4f", vec[2]); } if (t->con.mode & CON_APPLY) { @@ -2632,7 +2639,7 @@ static void ElementResize(TransInfo *t, TransData *td, float mat[3][3]) /* local constraint shouldn't alter center */ if ((t->around == V3D_LOCAL) && ( (t->flag & (T_OBJECT|T_POSE)) || - ((t->flag & T_EDIT) && (t->settings->selectmode & SCE_SELECT_FACE)) || + ((t->flag & T_EDIT) && (t->settings->selectmode & (SCE_SELECT_EDGE|SCE_SELECT_FACE))) || (t->obedit && t->obedit->type == OB_ARMATURE)) ) { @@ -2919,7 +2926,7 @@ static void ElementRotation(TransInfo *t, TransData *td, float mat[3][3], short /* local constraint shouldn't alter center */ if (around == V3D_LOCAL) { if ( (t->flag & (T_OBJECT|T_POSE)) || - (t->settings->selectmode & SCE_SELECT_FACE) || + (t->settings->selectmode & (SCE_SELECT_EDGE|SCE_SELECT_FACE)) || (t->obedit && t->obedit->type == OB_ARMATURE)) { center = td->center; diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h index 2233aeda92e..aab7dda0e86 100644 --- a/source/blender/editors/transform/transform.h +++ b/source/blender/editors/transform/transform.h @@ -281,7 +281,7 @@ typedef struct TransInfo { char *undostr; /* if set, uses this string for undo */ float spacemtx[3][3]; /* orientation matrix of the current space */ - char spacename[32]; /* name of the current space */ + char spacename[64]; /* name of the current space, MAX_NAME */ struct Object *poseobj; /* if t->flag & T_POSE, this denotes pose object */ diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index b88e57e1861..bd34477c13f 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -59,6 +59,7 @@ #include "BLI_math.h" #include "BLI_utildefines.h" +#include "BLI_string.h" //#include "blendef.h" // @@ -552,7 +553,7 @@ static void applyObjectConstraintRot(TransInfo *t, TransData *td, float vec[3], void setConstraint(TransInfo *t, float space[3][3], int mode, const char text[]) { - strncpy(t->con.text + 1, text, 48); + BLI_strncpy(t->con.text + 1, text, sizeof(t->con.text) - 1); copy_m3_m3(t->con.mtx, space); t->con.mode = mode; getConstraintMatrix(t); @@ -579,7 +580,7 @@ void setLocalConstraint(TransInfo *t, int mode, const char text[]) setConstraint(t, t->data->axismtx, mode, text); } else { - strncpy(t->con.text + 1, text, 48); + BLI_strncpy(t->con.text + 1, text, sizeof(t->con.text) - 1); copy_m3_m3(t->con.mtx, t->data->axismtx); t->con.mode = mode; getConstraintMatrix(t); @@ -598,7 +599,7 @@ void setLocalConstraint(TransInfo *t, int mode, const char text[]) /* Set the constraint according to the user defined orientation - ftext is a format string passed to sprintf. It will add the name of + ftext is a format string passed to BLI_snprintf. It will add the name of the orientation where %s is (logically). */ void setUserConstraint(TransInfo *t, short orientation, int mode, const char ftext[]) @@ -609,28 +610,28 @@ void setUserConstraint(TransInfo *t, short orientation, int mode, const char fte case V3D_MANIP_GLOBAL: { float mtx[3][3]= MAT3_UNITY; - sprintf(text, ftext, "global"); + BLI_snprintf(text, sizeof(text), ftext, "global"); setConstraint(t, mtx, mode, text); } break; case V3D_MANIP_LOCAL: - sprintf(text, ftext, "local"); + BLI_snprintf(text, sizeof(text), ftext, "local"); setLocalConstraint(t, mode, text); break; case V3D_MANIP_NORMAL: - sprintf(text, ftext, "normal"); + BLI_snprintf(text, sizeof(text), ftext, "normal"); setConstraint(t, t->spacemtx, mode, text); break; case V3D_MANIP_VIEW: - sprintf(text, ftext, "view"); + BLI_snprintf(text, sizeof(text), ftext, "view"); setConstraint(t, t->spacemtx, mode, text); break; case V3D_MANIP_GIMBAL: - sprintf(text, ftext, "gimbal"); + BLI_snprintf(text, sizeof(text), ftext, "gimbal"); setConstraint(t, t->spacemtx, mode, text); break; default: /* V3D_MANIP_CUSTOM */ - sprintf(text, ftext, t->spacename); + BLI_snprintf(text, sizeof(text), ftext, t->spacename); setConstraint(t, t->spacemtx, mode, text); break; } @@ -874,11 +875,11 @@ static void setNearestAxis2d(TransInfo *t) /* no correction needed... just use whichever one is lower */ if ( abs(t->mval[0]-t->con.imval[0]) < abs(t->mval[1]-t->con.imval[1]) ) { t->con.mode |= CON_AXIS1; - sprintf(t->con.text, " along Y axis"); + BLI_snprintf(t->con.text, sizeof(t->con.text), " along Y axis"); } else { t->con.mode |= CON_AXIS0; - sprintf(t->con.text, " along X axis"); + BLI_snprintf(t->con.text, sizeof(t->con.text), " along X axis"); } } @@ -929,31 +930,31 @@ static void setNearestAxis3d(TransInfo *t) if (len[0] <= len[1] && len[0] <= len[2]) { if (t->modifiers & MOD_CONSTRAINT_PLANE) { t->con.mode |= (CON_AXIS1|CON_AXIS2); - sprintf(t->con.text, " locking %s X axis", t->spacename); + BLI_snprintf(t->con.text, sizeof(t->con.text), " locking %s X axis", t->spacename); } else { t->con.mode |= CON_AXIS0; - sprintf(t->con.text, " along %s X axis", t->spacename); + BLI_snprintf(t->con.text, sizeof(t->con.text), " along %s X axis", t->spacename); } } else if (len[1] <= len[0] && len[1] <= len[2]) { if (t->modifiers & MOD_CONSTRAINT_PLANE) { t->con.mode |= (CON_AXIS0|CON_AXIS2); - sprintf(t->con.text, " locking %s Y axis", t->spacename); + BLI_snprintf(t->con.text, sizeof(t->con.text), " locking %s Y axis", t->spacename); } else { t->con.mode |= CON_AXIS1; - sprintf(t->con.text, " along %s Y axis", t->spacename); + BLI_snprintf(t->con.text, sizeof(t->con.text), " along %s Y axis", t->spacename); } } else if (len[2] <= len[1] && len[2] <= len[0]) { if (t->modifiers & MOD_CONSTRAINT_PLANE) { t->con.mode |= (CON_AXIS0|CON_AXIS1); - sprintf(t->con.text, " locking %s Z axis", t->spacename); + BLI_snprintf(t->con.text, sizeof(t->con.text), " locking %s Z axis", t->spacename); } else { t->con.mode |= CON_AXIS2; - sprintf(t->con.text, " along %s Z axis", t->spacename); + BLI_snprintf(t->con.text, sizeof(t->con.text), " along %s Z axis", t->spacename); } } } diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index bc7514b4c9a..44dc909314a 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -1926,6 +1926,19 @@ static void get_face_center(float *cent, EditMesh *em, EditVert *eve) } } +static void get_edge_center(float *cent, EditMesh *em, EditVert *eve) +{ + EditEdge *eed; + + for(eed= em->edges.first; eed; eed= eed->next) + if(eed->f & SELECT) + if(eed->v1==eve || eed->v2==eve) + break; + if(eed) { + mid_v3_v3v3(cent, eed->v1->co, eed->v2->co); + } +} + /* way to overwrite what data is edited with transform * static void VertsToTransData(TransData *td, EditVert *eve, BakeKey *key) */ static void VertsToTransData(TransInfo *t, TransData *td, EditMesh *em, EditVert *eve) @@ -1937,8 +1950,12 @@ static void VertsToTransData(TransInfo *t, TransData *td, EditMesh *em, EditVert td->loc = eve->co; copy_v3_v3(td->center, td->loc); - if(t->around==V3D_LOCAL && (em->selectmode & SCE_SELECT_FACE)) - get_face_center(td->center, em, eve); + if(t->around==V3D_LOCAL) { + if(em->selectmode & SCE_SELECT_FACE) + get_face_center(td->center, em, eve); + else if(em->selectmode & SCE_SELECT_EDGE) + get_edge_center(td->center, em, eve); + } copy_v3_v3(td->iloc, td->loc); // Setting normals diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index f6aca0336be..fff683b1ef6 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1077,7 +1077,7 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) if(v3d->flag & V3D_ALIGN) t->flag |= T_V3D_ALIGN; t->around = v3d->around; - if (op && RNA_struct_find_property(op->ptr, "constraint_orientation") && RNA_property_is_set(op->ptr, "constraint_orientation")) + if (op && RNA_struct_find_property(op->ptr, "constraint_orientation") && RNA_struct_property_is_set(op->ptr, "constraint_orientation")) { t->current_orientation = RNA_enum_get(op->ptr, "constraint_orientation"); @@ -1100,7 +1100,7 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) /* initialize UV transform from */ if (op && RNA_struct_find_property(op->ptr, "correct_uv")) { - if(RNA_property_is_set(op->ptr, "correct_uv")) { + if(RNA_struct_property_is_set(op->ptr, "correct_uv")) { if(RNA_boolean_get(op->ptr, "correct_uv")) { t->settings->uvcalc_flag |= UVCALC_TRANSFORM_CORRECT; } @@ -1146,7 +1146,7 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) t->around = V3D_CENTER; } - if (op && RNA_property_is_set(op->ptr, "release_confirm")) + if (op && RNA_struct_property_is_set(op->ptr, "release_confirm")) { if (RNA_boolean_get(op->ptr, "release_confirm")) { @@ -1161,7 +1161,7 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) } } - if (op && RNA_struct_find_property(op->ptr, "mirror") && RNA_property_is_set(op->ptr, "mirror")) + if (op && RNA_struct_find_property(op->ptr, "mirror") && RNA_struct_property_is_set(op->ptr, "mirror")) { if (RNA_boolean_get(op->ptr, "mirror")) { @@ -1182,7 +1182,7 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) /* setting PET flag only if property exist in operator. Otherwise, assume it's not supported */ if (op && RNA_struct_find_property(op->ptr, "proportional")) { - if (RNA_property_is_set(op->ptr, "proportional")) + if (RNA_struct_property_is_set(op->ptr, "proportional")) { switch(RNA_enum_get(op->ptr, "proportional")) { @@ -1215,7 +1215,7 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) } } - if (op && RNA_struct_find_property(op->ptr, "proportional_size") && RNA_property_is_set(op->ptr, "proportional_size")) + if (op && RNA_struct_find_property(op->ptr, "proportional_size") && RNA_struct_property_is_set(op->ptr, "proportional_size")) { t->prop_size = RNA_float_get(op->ptr, "proportional_size"); } @@ -1232,7 +1232,7 @@ int initTransInfo (bContext *C, TransInfo *t, wmOperator *op, wmEvent *event) t->prop_size = 1.0f; } - if (op && RNA_struct_find_property(op->ptr, "proportional_edit_falloff") && RNA_property_is_set(op->ptr, "proportional_edit_falloff")) + if (op && RNA_struct_find_property(op->ptr, "proportional_edit_falloff") && RNA_struct_property_is_set(op->ptr, "proportional_edit_falloff")) { t->prop_mode = RNA_enum_get(op->ptr, "proportional_edit_falloff"); } diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c index 90f95bea696..b7aba109cdd 100644 --- a/source/blender/editors/transform/transform_ops.c +++ b/source/blender/editors/transform/transform_ops.c @@ -268,7 +268,7 @@ static void TRANSFORM_OT_delete_orientation(struct wmOperatorType *ot) static int create_orientation_exec(bContext *C, wmOperator *op) { - char name[36]; + char name[MAX_NAME]; int use = RNA_boolean_get(op->ptr, "use"); int overwrite = RNA_boolean_get(op->ptr, "overwrite"); @@ -301,7 +301,7 @@ static void TRANSFORM_OT_create_orientation(struct wmOperatorType *ot) ot->poll = ED_operator_areaactive; ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO; - RNA_def_string(ot->srna, "name", "", 35, "Name", "Text to insert at the cursor position"); + RNA_def_string(ot->srna, "name", "", MAX_NAME, "Name", "Text to insert at the cursor position"); RNA_def_boolean(ot->srna, "use", 0, "Use after creation", "Select orientation after its creation"); RNA_def_boolean(ot->srna, "overwrite", 0, "Overwrite previous", "Overwrite previously created orientation with same name"); } @@ -429,7 +429,7 @@ static int transform_invoke(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_CANCELLED; } - if(RNA_property_is_set(op->ptr, "value")) { + if(RNA_struct_property_is_set(op->ptr, "value")) { return transform_exec(C, op); } else { diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index 3aa155fc8bb..8a9249f78e5 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -145,7 +145,7 @@ TransformOrientation *createObjectSpace(bContext *C, ReportList *UNUSED(reports) /* use object name if no name is given */ if (name[0] == 0) { - strncpy(name, ob->id.name+2, 35); + strncpy(name, ob->id.name+2, MAX_ID_NAME-2); } return addMatrixSpace(C, mat, name, overwrite); @@ -289,7 +289,7 @@ TransformOrientation* addMatrixSpace(bContext *C, float mat[3][3], char name[], { ts = MEM_callocN(sizeof(TransformOrientation), "UserTransSpace from matrix"); BLI_addtail(transform_spaces, ts); - strncpy(ts->name, name, 35); + strncpy(ts->name, name, sizeof(ts->name)); } /* copy matrix into transform space */ @@ -422,10 +422,11 @@ const char * BIF_menustringTransformOrientation(const bContext *C, const char *t TransformOrientation *ts; int i = V3D_MANIP_CUSTOM; char *str_menu, *p; + const int elem_size = MAX_NAME + 4; title = IFACE_(title); - str_menu = MEM_callocN(strlen(menu) + strlen(title) + 1 + 40 * BIF_countTransformOrientation(C), TIP_("UserTransSpace from matrix")); + str_menu = MEM_callocN(strlen(menu) + strlen(title) + 1 + elem_size * BIF_countTransformOrientation(C), TIP_("UserTransSpace from matrix")); p = str_menu; p += sprintf(str_menu, "%s", title); diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index ed3e949c8a0..d079bd41c10 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -445,18 +445,18 @@ void initSnapping(TransInfo *t, wmOperator *op) resetSnapping(t); /* if snap property exists */ - if (op && RNA_struct_find_property(op->ptr, "snap") && RNA_property_is_set(op->ptr, "snap")) + if (op && RNA_struct_find_property(op->ptr, "snap") && RNA_struct_property_is_set(op->ptr, "snap")) { if (RNA_boolean_get(op->ptr, "snap")) { t->modifiers |= MOD_SNAP; - if (RNA_property_is_set(op->ptr, "snap_target")) + if (RNA_struct_property_is_set(op->ptr, "snap_target")) { snap_target = RNA_enum_get(op->ptr, "snap_target"); } - if (RNA_property_is_set(op->ptr, "snap_point")) + if (RNA_struct_property_is_set(op->ptr, "snap_point")) { RNA_float_get_array(op->ptr, "snap_point", t->tsnap.snapPoint); t->tsnap.status |= SNAP_FORCED|POINT_INIT; |