diff options
Diffstat (limited to 'source/blender/editors/transform/transform_conversions.c')
-rw-r--r-- | source/blender/editors/transform/transform_conversions.c | 152 |
1 files changed, 102 insertions, 50 deletions
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c index 869cccd0c94..ce41aa85da1 100644 --- a/source/blender/editors/transform/transform_conversions.c +++ b/source/blender/editors/transform/transform_conversions.c @@ -997,14 +997,16 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan) data = con->data; if (data->tar == NULL || (data->tar->type == OB_ARMATURE && data->subtarget[0] == '\0')) { - /* make reference to constraint to base things off later (if it's the last targetless constraint encountered) */ + /* make reference to constraint to base things off later + * (if it's the last targetless constraint encountered) */ targetless = (bKinematicConstraint *)con->data; /* but, if this is a targetless IK, we make it auto anyway (for the children loop) */ if (con->enforce != 0.0f) { data->flag |= CONSTRAINT_IK_AUTO; - /* if no chain length has been specified, just make things obey standard rotation locks too */ + /* if no chain length has been specified, + * just make things obey standard rotation locks too */ if (data->rootbone == 0) { for (; pchan; pchan = pchan->parent) { /* here, we set ik-settings for bone from pchan->protectflag */ @@ -1025,7 +1027,10 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan) } con = BKE_constraint_add_for_pose(NULL, pchan, "TempConstraint", CONSTRAINT_TYPE_KINEMATIC); - pchan->constflag |= (PCHAN_HAS_IK | PCHAN_HAS_TARGET); /* for draw, but also for detecting while pose solving */ + + /* for draw, but also for detecting while pose solving */ + pchan->constflag |= (PCHAN_HAS_IK | PCHAN_HAS_TARGET); + data = con->data; if (targetless) { /* if exists, use values from last targetless (but disabled) IK-constraint as base */ @@ -1035,7 +1040,10 @@ static short pose_grab_with_ik_add(bPoseChannel *pchan) data->flag = CONSTRAINT_IK_TIP; data->flag |= CONSTRAINT_IK_TEMP | CONSTRAINT_IK_AUTO | CONSTRAINT_IK_POS; copy_v3_v3(data->grabtarget, pchan->pose_tail); - data->rootbone = 0; /* watch-it! has to be 0 here, since we're still on the same bone for the first time through the loop [#25885] */ + + /* watch-it! has to be 0 here, since we're still on the + * same bone for the first time through the loop T25885. */ + data->rootbone = 0; /* we only include bones that are part of a continual connected chain */ do { @@ -1096,7 +1104,8 @@ static short pose_grab_with_ik(Main *bmain, Object *ob) arm = ob->data; - /* Rule: allow multiple Bones (but they must be selected, and only one ik-solver per chain should get added) */ + /* Rule: allow multiple Bones + * (but they must be selected, and only one ik-solver per chain should get added) */ for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) { if (pchan->bone->layer & arm->layer) { if (pchan->bone->flag & BONE_SELECTED) { @@ -1856,7 +1865,8 @@ static void createTransCurveVerts(TransInfo *t) else td->flag = 0; td->ext = NULL; - if (t->mode == TFM_CURVE_SHRINKFATTEN) { /* || t->mode==TFM_RESIZE) {*/ /* TODO - make points scale */ + /* TODO - make points scale */ + if (t->mode == TFM_CURVE_SHRINKFATTEN) { /* || t->mode==TFM_RESIZE) {*/ td->val = &(bezt->radius); td->ival = bezt->radius; } @@ -1876,7 +1886,8 @@ static void createTransCurveVerts(TransInfo *t) if ((bezt_tx & SEL_F1) == 0 && (bezt_tx & SEL_F3) == 0) /* If the middle is selected but the sides arnt, this is needed */ - if (hdata == NULL) { /* if the handle was not saved by the previous handle */ + if (hdata == NULL) { + /* if the handle was not saved by the previous handle */ hdata = initTransDataCurveHandles(td, bezt); } @@ -1900,7 +1911,8 @@ static void createTransCurveVerts(TransInfo *t) td->ext = NULL; td->val = NULL; - if (hdata == NULL) { /* if the handle was not saved by the previous handle */ + if (hdata == NULL) { + /* if the handle was not saved by the previous handle */ hdata = initTransDataCurveHandles(td, bezt); } @@ -1927,7 +1939,8 @@ static void createTransCurveVerts(TransInfo *t) /* TODO - in the case of tilt and radius we can also avoid allocating the initTransDataCurveHandles * but for now just don't change handle types */ if (ELEM(t->mode, TFM_CURVE_SHRINKFATTEN, TFM_TILT, TFM_DUMMY) == 0) { - /* sets the handles based on their selection, do this after the data is copied to the TransData */ + /* sets the handles based on their selection, + * do this after the data is copied to the TransData */ BKE_nurb_handles_test(nu, !hide_handles); } } @@ -2455,7 +2468,8 @@ static struct TransIslandData *editmesh_islands_info_calc( vert_map = MEM_mallocN(sizeof(*vert_map) * bm->totvert, __func__); /* we shouldn't need this, but with incorrect selection flushing - * its possible we have a selected vertex that's not in a face, for now best not crash in that case. */ + * its possible we have a selected vertex that's not in a face, + * for now best not crash in that case. */ copy_vn_i(vert_map, bm->totvert, -1); BM_mesh_elem_table_ensure(bm, htype); @@ -2667,10 +2681,12 @@ static void createTransEditVerts(TransInfo *t) int island_info_tot; int *island_vert_map = NULL; - /* Snap rotation along normal needs a common axis for whole islands, otherwise one get random crazy results, - * see T59104. However, we do not want to use the island center for the pivot/translation reference... */ + /* Snap rotation along normal needs a common axis for whole islands, + * otherwise one get random crazy results, see T59104. + * However, we do not want to use the island center for the pivot/translation reference. */ const bool is_snap_rotate = ((t->mode == TFM_TRANSLATION) && - /* There is not guarantee that snapping is initialized yet at this point... */ + /* There is not guarantee that snapping + * is initialized yet at this point... */ (usingSnappingNormal(t) || (t->settings->snap_flag & SCE_SNAP_ROTATE) != 0) && (t->around != V3D_AROUND_LOCAL_ORIGINS)); /* Even for translation this is needed because of island-orientation, see: T51651. */ @@ -2969,7 +2985,8 @@ BLI_INLINE void trans_update_seq(Scene *sce, Sequence *seq, int old_start, int s void flushTransSeq(TransInfo *t) { - ListBase *seqbasep = BKE_sequencer_editing_get(t->scene, false)->seqbasep; /* Editing null check already done */ + /* Editing null check already done */ + ListBase *seqbasep = BKE_sequencer_editing_get(t->scene, false)->seqbasep; int a, new_frame; TransData *td = NULL; @@ -2996,11 +3013,15 @@ void flushTransSeq(TransInfo *t) switch (tdsq->sel_flag) { case SELECT: #ifdef SEQ_TX_NESTED_METAS - if ((seq->depth != 0 || BKE_sequence_tx_test(seq))) /* for meta's, their children move */ + if ((seq->depth != 0 || BKE_sequence_tx_test(seq))) { + /* for meta's, their children move */ seq->start = new_frame - tdsq->start_offset; + } #else - if (seq->type != SEQ_TYPE_META && (seq->depth != 0 || seq_tx_test(seq))) /* for meta's, their children move */ + if (seq->type != SEQ_TYPE_META && (seq->depth != 0 || seq_tx_test(seq))) { + /* for meta's, their children move */ seq->start = new_frame - tdsq->start_offset; + } #endif if (seq->depth == 0) { seq->machine = round_fl_to_int(td2d->loc[1]); @@ -3010,12 +3031,16 @@ void flushTransSeq(TransInfo *t) case SEQ_LEFTSEL: /* no vertical transform */ BKE_sequence_tx_set_final_left(seq, new_frame); BKE_sequence_tx_handle_xlimits(seq, tdsq->flag & SEQ_LEFTSEL, tdsq->flag & SEQ_RIGHTSEL); - BKE_sequence_single_fix(seq); /* todo - move this into aftertrans update? - old seq tx needed it anyway */ + + /* todo - move this into aftertrans update? - old seq tx needed it anyway */ + BKE_sequence_single_fix(seq); break; case SEQ_RIGHTSEL: /* no vertical transform */ BKE_sequence_tx_set_final_right(seq, new_frame); BKE_sequence_tx_handle_xlimits(seq, tdsq->flag & SEQ_LEFTSEL, tdsq->flag & SEQ_RIGHTSEL); - BKE_sequence_single_fix(seq); /* todo - move this into aftertrans update? - old seq tx needed it anyway */ + + /* todo - move this into aftertrans update? - old seq tx needed it anyway */ + BKE_sequence_single_fix(seq); break; } @@ -3042,8 +3067,8 @@ void flushTransSeq(TransInfo *t) trans_update_seq(t->scene, seq_prev, old_start_prev, sel_flag_prev); } - - if (ELEM(t->mode, TFM_SEQ_SLIDE, TFM_TIME_TRANSLATE)) { /* originally TFM_TIME_EXTEND, transform changes */ + /* originally TFM_TIME_EXTEND, transform changes */ + if (ELEM(t->mode, TFM_SEQ_SLIDE, TFM_TIME_TRANSLATE)) { /* Special annoying case here, need to calc metas with TFM_TIME_EXTEND only */ /* calc all meta's then effects [#27953] */ @@ -3575,7 +3600,8 @@ static void createTransNlaData(bContext *C, TransInfo *t) td++; } if (FrameOnMouseSide(t->frame_side, strip->end, (float)CFRA)) { - /* if tdn is already holding the start handle, then we're doing both, otherwise, only end */ + /* if tdn is already holding the start handle, + * then we're doing both, otherwise, only end */ tdn->handle = (tdn->handle) ? 2 : 1; /* now, link the transform data up to this data */ @@ -3994,7 +4020,8 @@ static TransData *ActionFCurveToTransData(TransData *td, TransData2D **td2dv, FC for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) { /* only add selected keyframes (for now, proportional edit is not enabled) */ - if (is_prop_edit || (bezt->f2 & SELECT)) { /* note this MUST match count_fcurve_keys(), so can't use BEZT_ISSEL_ANY() macro */ + if (is_prop_edit || (bezt->f2 & SELECT)) { /* note this MUST match count_fcurve_keys(), + * so can't use BEZT_ISSEL_ANY() macro */ /* only add if on the right 'side' of the current frame */ if (FrameOnMouseSide(side, bezt->vec[1][0], cfra)) { TimeToTransData(td, bezt->vec[1], adt, ypos); @@ -4647,7 +4674,8 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) unit_scale = ANIM_unit_mapping_get_factor(ac.scene, ale->id, ale->key_data, anim_map_flag, &offset); - /* only include BezTriples whose 'keyframe' occurs on the same side of the current frame as mouse (if applicable) */ + /* only include BezTriples whose 'keyframe' occurs on the same side + * of the current frame as mouse (if applicable) */ for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) { if (FrameOnMouseSide(t->frame_side, bezt->vec[1][0], cfra)) { const bool sel2 = (bezt->f2 & SELECT) != 0; @@ -4751,7 +4779,8 @@ static void createTransGraphEditData(bContext *C, TransInfo *t) else cfra = (float)CFRA; - /* only include BezTriples whose 'keyframe' occurs on the same side of the current frame as mouse (if applicable) */ + /* only include BezTriples whose 'keyframe' occurs on the + * same side of the current frame as mouse (if applicable) */ for (i = 0, bezt = fcu->bezt; i < fcu->totvert; i++, bezt++) { if (FrameOnMouseSide(t->frame_side, bezt->vec[1][0], cfra)) { const bool sel2 = (bezt->f2 & SELECT) != 0; @@ -5014,7 +5043,9 @@ void flushTransGraphData(TransInfo *t) a < tc->data_len; a++, td++, td2d++, tdg++) { - AnimData *adt = (AnimData *)td->extra; /* pointers to relevant AnimData blocks are stored in the td->extra pointers */ + /* pointers to relevant AnimData blocks are stored in the td->extra pointers */ + AnimData *adt = (AnimData *)td->extra; + float inv_unit_scale = 1.0f / tdg->unit_scale; /* handle snapping for time values @@ -5434,8 +5465,8 @@ static void freeSeqData(TransInfo *t, TransDataContainer *tc, TransCustomData *c } } else { - /* Tag seq with a non zero value, - * used by BKE_sequence_base_shuffle_time to identify the ones to shuffle */ + /* Tag seq with a non zero value, used by + * BKE_sequence_base_shuffle_time to identify the ones to shuffle */ if (seq->depth == 0) { seq->tmp = (void *)1; } @@ -5707,7 +5738,8 @@ static void ObjectToTransData(TransInfo *t, TransData *td, Object *ob) float rot[3][3], scale[3]; float ctime = BKE_scene_frame_get(scene); - /* only use rigid body transform if simulation is running, avoids problems with initial setup of rigid bodies */ + /* only use rigid body transform if simulation is running, + * avoids problems with initial setup of rigid bodies */ if (BKE_rigidbody_check_sim_running(scene->rigidbody_world, ctime)) { /* save original object transform */ @@ -6555,9 +6587,11 @@ void special_aftertrans_update(bContext *C, TransInfo *t) FCurve *fcu = (FCurve *)ale->key_data; /* 3 cases here for curve cleanups: - * 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done - * 2) canceled == 0 -> user confirmed the transform, so duplicates should be removed - * 3) canceled + duplicate -> user canceled the transform, but we made duplicates, so get rid of these + * 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done + * 2) canceled == 0 -> user confirmed the transform, + * so duplicates should be removed + * 3) canceled + duplicate -> user canceled the transform, + * but we made duplicates, so get rid of these */ if ((saction->flag & SACTION_NOTRANSKEYCULL) == 0 && ((canceled == 0) || (duplicate)) ) @@ -6586,9 +6620,11 @@ void special_aftertrans_update(bContext *C, TransInfo *t) } /* 3 cases here for curve cleanups: - * 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done - * 2) canceled == 0 -> user confirmed the transform, so duplicates should be removed - * 3) canceled + duplicate -> user canceled the transform, but we made duplicates, so get rid of these + * 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done + * 2) canceled == 0 -> user confirmed the transform, + * so duplicates should be removed. + * 3) canceled + duplicate -> user canceled the transform, + * but we made duplicates, so get rid of these. */ if ((saction->flag & SACTION_NOTRANSKEYCULL) == 0 && ((canceled == 0) || (duplicate))) @@ -6599,9 +6635,11 @@ void special_aftertrans_update(bContext *C, TransInfo *t) else if (ac.datatype == ANIMCONT_GPENCIL) { /* remove duplicate frames and also make sure points are in order! */ /* 3 cases here for curve cleanups: - * 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done - * 2) canceled == 0 -> user confirmed the transform, so duplicates should be removed - * 3) canceled + duplicate -> user canceled the transform, but we made duplicates, so get rid of these + * 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done + * 2) canceled == 0 -> user confirmed the transform, + * so duplicates should be removed + * 3) canceled + duplicate -> user canceled the transform, + * but we made duplicates, so get rid of these */ if ((saction->flag & SACTION_NOTRANSKEYCULL) == 0 && ((canceled == 0) || (duplicate))) @@ -6687,9 +6725,11 @@ void special_aftertrans_update(bContext *C, TransInfo *t) FCurve *fcu = (FCurve *)ale->key_data; /* 3 cases here for curve cleanups: - * 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done - * 2) canceled == 0 -> user confirmed the transform, so duplicates should be removed - * 3) canceled + duplicate -> user canceled the transform, but we made duplicates, so get rid of these + * 1) NOTRANSKEYCULL on -> cleanup of duplicates shouldn't be done + * 2) canceled == 0 -> user confirmed the transform, + * so duplicates should be removed + * 3) canceled + duplicate -> user canceled the transform, + * but we made duplicates, so get rid of these */ if ((sipo->flag & SIPO_NOTRANSKEYCULL) == 0 && ((canceled == 0) || (duplicate))) @@ -6761,7 +6801,8 @@ void special_aftertrans_update(bContext *C, TransInfo *t) } else if (t->flag & T_POSE && (t->mode == TFM_BONESIZE)) { /* Handle the exception where for TFM_BONESIZE in edit mode we pretend to be - * in pose mode (to use bone orientation matrix), in that case we don't do operations like autokeyframing. */ + * in pose mode (to use bone orientation matrix), + * in that case we don't do operations like autokeyframing. */ FOREACH_TRANS_DATA_CONTAINER (t, tc) { ob = tc->poseobj; DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); @@ -6806,7 +6847,8 @@ void special_aftertrans_update(bContext *C, TransInfo *t) if (t->mode == TFM_TRANSLATION) pose_grab_with_ik_clear(bmain, ob); - /* automatic inserting of keys and unkeyed tagging - only if transform wasn't canceled (or TFM_DUMMY) */ + /* automatic inserting of keys and unkeyed tagging - + * only if transform wasn't canceled (or TFM_DUMMY) */ if (!canceled && (t->mode != TFM_DUMMY)) { autokeyframe_pose(C, t->scene, ob, t->mode, targetless_ik); DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); @@ -6871,8 +6913,10 @@ void special_aftertrans_update(bContext *C, TransInfo *t) /* flag object caches as outdated */ BKE_ptcache_ids_from_object(&pidlist, ob, t->scene, MAX_DUPLI_RECUR); for (pid = pidlist.first; pid; pid = pid->next) { - if (pid->type != PTCACHE_TYPE_PARTICLES) /* particles don't need reset on geometry change */ + if (pid->type != PTCACHE_TYPE_PARTICLES) { + /* particles don't need reset on geometry change */ pid->cache->flag |= PTCACHE_OUTDATED; + } } BLI_freelistN(&pidlist); @@ -6989,7 +7033,8 @@ static void createTransObject(bContext *C, TransInfo *t) for (base = view_layer->object_bases.first; base; base = base->next) { Object *ob = base->object; - /* if base is not selected, not a parent of selection or not a child of selection and it is editable */ + /* if base is not selected, not a parent of selection + * or not a child of selection and it is editable */ if ((ob->flag & (BA_TRANSFORM_CHILD | BA_TRANSFORM_PARENT)) == 0 && (base->flag & BASE_SELECTED) == 0 && BASE_EDITABLE(v3d, base)) @@ -8450,7 +8495,8 @@ static void createTransGPencil(bContext *C, TransInfo *t) if (point_ok) { copy_v3_v3(td->iloc, &pt->x); /* only copy center in local origins. - * This allows get interesting effects also when move using proportional editing */ + * This allows get interesting effects also when move + * using proportional editing */ if ((gps->flag & GP_STROKE_SELECT) && (ts->transform_pivot_point == V3D_AROUND_LOCAL_ORIGINS)) { @@ -8492,7 +8538,8 @@ static void createTransGPencil(bContext *C, TransInfo *t) copy_m3_m4(td->mtx, diff_mat); /* display position */ copy_m3_m4(td->axismtx, diff_mat); /* axis orientation */ - /* Triangulation must be calculated again, so save the stroke for recalc function */ + /* Triangulation must be calculated again, + * so save the stroke for recalc function */ td->extra = gps; /* save pointer to object */ @@ -8647,7 +8694,8 @@ void createTransData(bContext *C, TransInfo *t) if (t->data_len_all && (t->flag & T_PROP_EDIT)) { sort_trans_data(t); // makes selected become first in array - //set_prop_dist(t, false); /* don't do that, distance has been set in createTransActionData already */ + /* don't do that, distance has been set in createTransActionData already */ + //set_prop_dist(t, false); sort_trans_data_dist(t); } } @@ -8662,7 +8710,7 @@ void createTransData(bContext *C, TransInfo *t) t->flag |= T_POINTS | T_2D_EDIT; t->obedit_type = -1; - t->num.flag |= NUM_NO_FRACTION; /* sequencer has no use for floating point transformations */ + t->num.flag |= NUM_NO_FRACTION; /* sequencer has no use for floating point trasnform */ createTransSeqData(C, t); countAndCleanTransDataContainer(t); } @@ -8674,8 +8722,12 @@ void createTransData(bContext *C, TransInfo *t) countAndCleanTransDataContainer(t); if (t->data_len_all && (t->flag & T_PROP_EDIT)) { - sort_trans_data(t); // makes selected become first in array - set_prop_dist(t, false); /* don't do that, distance has been set in createTransGraphEditData already */ + /* makes selected become first in array */ + sort_trans_data(t); + + /* don't do that, distance has been set in createTransGraphEditData already */ + set_prop_dist(t, false); + sort_trans_data_dist(t); } } |