Commit: 9dd308630736139e7774662b485dd03100f64c9e Author: Campbell Barton Date: Wed Apr 11 08:30:39 2018 +0200 Branches: temp-object-multi-mode https://developer.blender.org/rB9dd308630736139e7774662b485dd03100f64c9e
Fixes for transform (prepare pose-mode mulit-object support) =================================================================== M source/blender/editors/transform/transform_conversions.c M source/blender/editors/transform/transform_generics.c =================================================================== diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 731be078cbd..1d1dcebbd64 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -1069,21 +1069,27 @@ static short pose_grab_with_ik(Object *ob) } -/* only called with pose mode active object now */ +/** + * When objects array is NULL, use 't->thand' as is. + */ static void createTransPose(TransInfo *t, Object **objects, uint objects_len) { - /* TODO(campbell): xform, properly handle pose mode errors across many meshes. */ - if (t->thand) { - MEM_freeN(t->thand); + if (objects != NULL) { + if (t->thand) { + MEM_freeN(t->thand); + } + t->thand = MEM_callocN(sizeof(*t->thand) * objects_len, __func__); + t->thand_len = objects_len; + int th_index; + FOREACH_THAND_INDEX (t, th, th_index) { + th->poseobj = objects[th_index]; + } } - t->thand = MEM_callocN(sizeof(*t->thand) * objects_len, __func__); - t->thand_len = objects_len; t->total_all_handle = 0; - int th_index; - FOREACH_THAND_INDEX (t, th, th_index) { - Object *ob = objects[th_index]; + FOREACH_THAND (t, th) { + Object *ob = th->poseobj; bArmature *arm; bPoseChannel *pchan; @@ -8461,10 +8467,7 @@ void createTransData(bContext *C, TransInfo *t) else if (ob && (ob->mode & OB_MODE_POSE)) { // XXX this is currently limited to active armature only... // XXX active-layer checking isn't done as that should probably be checked through context instead - Object *objects[1]; - objects[0] = ob; - uint objects_len = 1; - createTransPose(t, objects, objects_len); + createTransPose(t, NULL, 0); } else if (ob && (ob->mode & OB_MODE_WEIGHT_PAINT) && !(t->options & CTX_PAINT_CURVE)) { /* important that ob_armature can be set even when its not selected [#23412] diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index 5315f6e4c4c..22ac1f58d6c 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1165,11 +1165,12 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve Depsgraph *depsgraph = CTX_data_depsgraph(C); Scene *sce = CTX_data_scene(C); ViewLayer *view_layer = CTX_data_view_layer(C); + const eObjectMode object_mode = OBACT(view_layer) ? OBACT(view_layer)->mode : OB_MODE_OBJECT; + const short object_type = OBACT(view_layer) ? OBACT(view_layer)->type : -1; ToolSettings *ts = CTX_data_tool_settings(C); ARegion *ar = CTX_wm_region(C); ScrArea *sa = CTX_wm_area(C); - Object *obedit = CTX_data_edit_object(C); - Object *ob = CTX_data_active_object(C); + bGPdata *gpd = CTX_data_gpencil_data(C); RenderEngineType *engine_type = CTX_data_engine_type(C); PropertyRNA *prop; @@ -1183,35 +1184,47 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve t->settings = ts; t->reports = op ? op->reports : NULL; - if (t->thand == NULL) { - t->thand = MEM_callocN(sizeof(*t->thand), __func__); - t->thand_len = 1; - } - t->helpline = HLP_NONE; t->flag = 0; + + t->obedit_type = -1; - if (CTX_data_edit_object(C) /* || pose mode .. etc. */) { + if (((object_mode & OB_MODE_EDIT) && (object_type == OB_MESH)) || + ((object_mode & OB_MODE_POSE) && (object_type == OB_ARMATURE))) + { uint objects_len; Object **objects = BKE_view_layer_array_from_objects_in_mode( t->view_layer, &objects_len, - .object_mode = OB_MODE_EDIT, + .object_mode = object_mode, .no_dupe_data = true); t->thand = MEM_callocN(sizeof(*t->thand) * objects_len, __func__); t->thand_len = objects_len; for (int i = 0; i < objects_len; i++) { TransHandle *th = &t->thand[i]; - th->obedit = objects[i]; - copy_m3_m4(th->obedit_mat, obedit->obmat); - normalize_m3(th->obedit_mat); + if (object_mode & OB_MODE_EDIT) { + th->obedit = objects[i]; + copy_m3_m4(th->obedit_mat, th->obedit->obmat); + normalize_m3(th->obedit_mat); + } + else if (object_mode & OB_MODE_POSE) { + th->poseobj = objects[i]; + } + } + if (object_mode & OB_MODE_EDIT) { + t->flag |= T_EDIT; + t->obedit_type = objects[0]->type; + } + else if (object_mode & OB_MODE_POSE) { + t->flag |= T_POSE; } - t->obedit_type = objects[0]->type; - t->flag |= T_EDIT; } - else { - t->obedit_type = -1; + + /* Many kinds of transform only use a single handle. */ + if (t->thand == NULL) { + t->thand = MEM_callocN(sizeof(*t->thand), __func__); + t->thand_len = 1; } t->redraw = TREDRAW_HARD; /* redraw first time */ @@ -1324,13 +1337,13 @@ void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *eve if (ELEM(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL)) { const bool use_island = transdata_check_local_islands(t, t->around); - if (obedit && !use_island) { + if ((t->obedit_type != -1) && !use_island) { t->options |= CTX_NO_PET; } } } - if (ob && ob->mode & OB_MODE_ALL_PAINT) { + if (object_mode & OB_MODE_ALL_PAINT) { Paint *p = BKE_paint_get_active_from_context(C); if (p && p->brush && (p->brush->flag & BRUSH_CURVE)) { t->options |= CTX_PAINT_CURVE; _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs