Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/transform/transform_generics.c
| Show First 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | |||||
| #include "BKE_nla.h" | #include "BKE_nla.h" | ||||
| #include "BKE_context.h" | #include "BKE_context.h" | ||||
| #include "BKE_paint.h" | #include "BKE_paint.h" | ||||
| #include "BKE_sequencer.h" | #include "BKE_sequencer.h" | ||||
| #include "BKE_editmesh.h" | #include "BKE_editmesh.h" | ||||
| #include "BKE_tracking.h" | #include "BKE_tracking.h" | ||||
| #include "BKE_mask.h" | #include "BKE_mask.h" | ||||
| #include "BKE_workspace.h" | #include "BKE_workspace.h" | ||||
| #include "BKE_layer.h" | |||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| #include "ED_anim_api.h" | #include "ED_anim_api.h" | ||||
| #include "ED_armature.h" | #include "ED_armature.h" | ||||
| #include "ED_image.h" | #include "ED_image.h" | ||||
| #include "ED_keyframing.h" | #include "ED_keyframing.h" | ||||
| #include "ED_markers.h" | #include "ED_markers.h" | ||||
| Show All 29 Lines | else { | ||||
| copy_v3_v3(vec, t->viewinv[2]); | copy_v3_v3(vec, t->viewinv[2]); | ||||
| } | } | ||||
| normalize_v3(vec); | normalize_v3(vec); | ||||
| } | } | ||||
| /* ************************** GENERICS **************************** */ | /* ************************** GENERICS **************************** */ | ||||
| static void clipMirrorModifier(TransInfo *t, Object *ob) | static void clipMirrorModifier(TransInfo *t) | ||||
| { | { | ||||
| FOREACH_TRANS_DATA_CONTAINER (t, tc) { | |||||
| Object *ob = tc->obedit; | |||||
| ModifierData *md = ob->modifiers.first; | ModifierData *md = ob->modifiers.first; | ||||
| float tolerance[3] = {0.0f, 0.0f, 0.0f}; | float tolerance[3] = {0.0f, 0.0f, 0.0f}; | ||||
| int axis = 0; | int axis = 0; | ||||
| for (; md; md = md->next) { | for (; md; md = md->next) { | ||||
| if ((md->type == eModifierType_Mirror) && (md->mode & eModifierMode_Realtime)) { | if ((md->type == eModifierType_Mirror) && (md->mode & eModifierMode_Realtime)) { | ||||
| MirrorModifierData *mmd = (MirrorModifierData *) md; | MirrorModifierData *mmd = (MirrorModifierData *) md; | ||||
| Show All 9 Lines | if ((md->type == eModifierType_Mirror) && (md->mode & eModifierMode_Realtime)) { | ||||
| } | } | ||||
| if (mmd->flag & MOD_MIR_AXIS_Z) { | if (mmd->flag & MOD_MIR_AXIS_Z) { | ||||
| axis |= 4; | axis |= 4; | ||||
| tolerance[2] = mmd->tolerance; | tolerance[2] = mmd->tolerance; | ||||
| } | } | ||||
| if (axis) { | if (axis) { | ||||
| float mtx[4][4], imtx[4][4]; | float mtx[4][4], imtx[4][4]; | ||||
| int i; | int i; | ||||
| TransData *td = t->data; | |||||
| if (mmd->mirror_ob) { | if (mmd->mirror_ob) { | ||||
| float obinv[4][4]; | float obinv[4][4]; | ||||
| invert_m4_m4(obinv, mmd->mirror_ob->obmat); | invert_m4_m4(obinv, mmd->mirror_ob->obmat); | ||||
| mul_m4_m4m4(mtx, obinv, ob->obmat); | mul_m4_m4m4(mtx, obinv, ob->obmat); | ||||
| invert_m4_m4(imtx, mtx); | invert_m4_m4(imtx, mtx); | ||||
| } | } | ||||
| for (i = 0; i < t->total; i++, td++) { | TransData *td = tc->data; | ||||
| for (i = 0; i < tc->data_len; i++, td++) { | |||||
| int clip; | int clip; | ||||
| float loc[3], iloc[3]; | float loc[3], iloc[3]; | ||||
| if (td->flag & TD_NOACTION) | if (td->flag & TD_NOACTION) | ||||
| break; | break; | ||||
| if (td->loc == NULL) | if (td->loc == NULL) | ||||
| break; | break; | ||||
| ▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | if ((md->type == eModifierType_Mirror) && (md->mode & eModifierMode_Realtime)) { | ||||
| copy_v3_v3(td->loc, loc); | copy_v3_v3(td->loc, loc); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| } | } | ||||
| /* assumes obedit set to mesh object */ | /* assumes obedit set to mesh object */ | ||||
| static void editbmesh_apply_to_mirror(TransInfo *t) | static void editbmesh_apply_to_mirror(TransInfo *t) | ||||
| { | { | ||||
| TransData *td = t->data; | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | |||||
| BMVert *eve; | BMVert *eve; | ||||
| int i; | int i; | ||||
| for (i = 0; i < t->total; i++, td++) { | for (i = 0; i < tc->data_len; i++, td++) { | ||||
| if (td->flag & TD_NOACTION) | if (td->flag & TD_NOACTION) | ||||
| break; | break; | ||||
| if (td->loc == NULL) | if (td->loc == NULL) | ||||
| break; | break; | ||||
| if (td->flag & TD_SKIP) | if (td->flag & TD_SKIP) | ||||
| continue; | continue; | ||||
| eve = td->extra; | eve = td->extra; | ||||
| if (eve) { | if (eve) { | ||||
| eve->co[0] = -td->loc[0]; | eve->co[0] = -td->loc[0]; | ||||
| eve->co[1] = td->loc[1]; | eve->co[1] = td->loc[1]; | ||||
| eve->co[2] = td->loc[2]; | eve->co[2] = td->loc[2]; | ||||
| } | } | ||||
| if (td->flag & TD_MIRROR_EDGE) { | if (td->flag & TD_MIRROR_EDGE) { | ||||
| td->loc[0] = 0; | td->loc[0] = 0; | ||||
| } | } | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| } | } | ||||
| /* for the realtime animation recording feature, handle overlapping data */ | /* for the realtime animation recording feature, handle overlapping data */ | ||||
| static void animrecord_check_state(Scene *scene, ID *id, wmTimer *animtimer) | static void animrecord_check_state(Scene *scene, ID *id, wmTimer *animtimer) | ||||
| { | { | ||||
| ScreenAnimData *sad = (animtimer) ? animtimer->customdata : NULL; | ScreenAnimData *sad = (animtimer) ? animtimer->customdata : NULL; | ||||
| /* sanity checks */ | /* sanity checks */ | ||||
| ▲ Show 20 Lines • Show All 166 Lines • ▼ Show 20 Lines | |||||
| /* helper for recalcData() - for NLA Editor transforms */ | /* helper for recalcData() - for NLA Editor transforms */ | ||||
| static void recalcData_nla(TransInfo *t) | static void recalcData_nla(TransInfo *t) | ||||
| { | { | ||||
| TransDataNla *tdn = t->custom.type.data; | TransDataNla *tdn = t->custom.type.data; | ||||
| SpaceNla *snla = (SpaceNla *)t->sa->spacedata.first; | SpaceNla *snla = (SpaceNla *)t->sa->spacedata.first; | ||||
| Scene *scene = t->scene; | Scene *scene = t->scene; | ||||
| double secf = FPS; | double secf = FPS; | ||||
| int i; | int i; | ||||
| TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t); | |||||
| /* for each strip we've got, perform some additional validation of the values that got set before | /* for each strip we've got, perform some additional validation of the values that got set before | ||||
| * using RNA to set the value (which does some special operations when setting these values to make | * using RNA to set the value (which does some special operations when setting these values to make | ||||
| * sure that everything works ok) | * sure that everything works ok) | ||||
| */ | */ | ||||
| for (i = 0; i < t->total; i++, tdn++) { | for (i = 0; i < tc->data_len; i++, tdn++) { | ||||
| NlaStrip *strip = tdn->strip; | NlaStrip *strip = tdn->strip; | ||||
| PointerRNA strip_ptr; | PointerRNA strip_ptr; | ||||
| short pExceeded, nExceeded, iter; | short pExceeded, nExceeded, iter; | ||||
| int delta_y1, delta_y2; | int delta_y1, delta_y2; | ||||
| /* if this tdn has no handles, that means it is just a dummy that should be skipped */ | /* if this tdn has no handles, that means it is just a dummy that should be skipped */ | ||||
| if (tdn->handle == 0) | if (tdn->handle == 0) | ||||
| continue; | continue; | ||||
| ▲ Show 20 Lines • Show All 200 Lines • ▼ Show 20 Lines | |||||
| static void recalcData_image(TransInfo *t) | static void recalcData_image(TransInfo *t) | ||||
| { | { | ||||
| if (t->options & CTX_MASK) { | if (t->options & CTX_MASK) { | ||||
| recalcData_mask_common(t); | recalcData_mask_common(t); | ||||
| } | } | ||||
| else if (t->options & CTX_PAINT_CURVE) { | else if (t->options & CTX_PAINT_CURVE) { | ||||
| flushTransPaintCurve(t); | flushTransPaintCurve(t); | ||||
| } | } | ||||
| else if (t->obedit && t->obedit->type == OB_MESH) { | else if ((t->flag & T_EDIT) && t->obedit_type == OB_MESH) { | ||||
| SpaceImage *sima = t->sa->spacedata.first; | SpaceImage *sima = t->sa->spacedata.first; | ||||
| flushTransUVs(t); | flushTransUVs(t); | ||||
| if (sima->flag & SI_LIVE_UNWRAP) | if (sima->flag & SI_LIVE_UNWRAP) | ||||
| ED_uvedit_live_unwrap_re_solve(); | ED_uvedit_live_unwrap_re_solve(); | ||||
| DEG_id_tag_update(t->obedit->data, 0); | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| if (tc->data_len) { | |||||
| DEG_id_tag_update(tc->obedit->data, 0); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| /* helper for recalcData() - for Movie Clip transforms */ | /* helper for recalcData() - for Movie Clip transforms */ | ||||
| static void recalcData_spaceclip(TransInfo *t) | static void recalcData_spaceclip(TransInfo *t) | ||||
| { | { | ||||
| SpaceClip *sc = t->sa->spacedata.first; | SpaceClip *sc = t->sa->spacedata.first; | ||||
| Show All 38 Lines | static void recalcData_spaceclip(TransInfo *t) | ||||
| } | } | ||||
| } | } | ||||
| /* helper for recalcData() - for object transforms, typically in the 3D view */ | /* helper for recalcData() - for object transforms, typically in the 3D view */ | ||||
| static void recalcData_objects(TransInfo *t) | static void recalcData_objects(TransInfo *t) | ||||
| { | { | ||||
| Base *base = t->view_layer->basact; | Base *base = t->view_layer->basact; | ||||
| if (t->obedit) { | if (t->obedit_type != -1) { | ||||
| if (ELEM(t->obedit->type, OB_CURVE, OB_SURF)) { | if (ELEM(t->obedit_type, OB_CURVE, OB_SURF)) { | ||||
| Curve *cu = t->obedit->data; | |||||
| ListBase *nurbs = BKE_curve_editNurbs_get(cu); | |||||
| Nurb *nu = nurbs->first; | |||||
| if (t->state != TRANS_CANCEL) { | if (t->state != TRANS_CANCEL) { | ||||
| clipMirrorModifier(t, t->obedit); | clipMirrorModifier(t); | ||||
| applyProject(t); | applyProject(t); | ||||
| } | } | ||||
| DEG_id_tag_update(t->obedit->data, 0); /* sets recalc flags */ | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| Curve *cu = tc->obedit->data; | |||||
| ListBase *nurbs = BKE_curve_editNurbs_get(cu); | |||||
| Nurb *nu = nurbs->first; | |||||
| DEG_id_tag_update(tc->obedit->data, 0); /* sets recalc flags */ | |||||
| if (t->state == TRANS_CANCEL) { | if (t->state == TRANS_CANCEL) { | ||||
| while (nu) { | while (nu) { | ||||
| BKE_nurb_handles_calc(nu); /* Cant do testhandlesNurb here, it messes up the h1 and h2 flags */ | BKE_nurb_handles_calc(nu); /* Cant do testhandlesNurb here, it messes up the h1 and h2 flags */ | ||||
| nu = nu->next; | nu = nu->next; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* Normal updating */ | /* Normal updating */ | ||||
| while (nu) { | while (nu) { | ||||
| BKE_nurb_test2D(nu); | BKE_nurb_test2D(nu); | ||||
| BKE_nurb_handles_calc(nu); | BKE_nurb_handles_calc(nu); | ||||
| nu = nu->next; | nu = nu->next; | ||||
| } | } | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| } | } | ||||
| else if (t->obedit->type == OB_LATTICE) { | else if (t->obedit_type == OB_LATTICE) { | ||||
| Lattice *la = t->obedit->data; | |||||
| if (t->state != TRANS_CANCEL) { | if (t->state != TRANS_CANCEL) { | ||||
| applyProject(t); | applyProject(t); | ||||
| } | } | ||||
| DEG_id_tag_update(t->obedit->data, 0); /* sets recalc flags */ | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| Lattice *la = tc->obedit->data; | |||||
| if (la->editlatt->latt->flag & LT_OUTSIDE) outside_lattice(la->editlatt->latt); | DEG_id_tag_update(tc->obedit->data, 0); /* sets recalc flags */ | ||||
| if (la->editlatt->latt->flag & LT_OUTSIDE) { | |||||
| outside_lattice(la->editlatt->latt); | |||||
| } | |||||
| } // FIXME(indent) | |||||
| } | } | ||||
| else if (t->obedit->type == OB_MESH) { | else if (t->obedit_type == OB_MESH) { | ||||
| BMEditMesh *em = BKE_editmesh_from_object(t->obedit); | |||||
| /* mirror modifier clipping? */ | /* mirror modifier clipping? */ | ||||
| if (t->state != TRANS_CANCEL) { | if (t->state != TRANS_CANCEL) { | ||||
| /* apply clipping after so we never project past the clip plane [#25423] */ | /* apply clipping after so we never project past the clip plane [#25423] */ | ||||
| applyProject(t); | applyProject(t); | ||||
| clipMirrorModifier(t, t->obedit); | clipMirrorModifier(t); | ||||
| } | } | ||||
| if ((t->options & CTX_NO_MIRROR) == 0 && (t->flag & T_MIRROR)) | if ((t->options & CTX_NO_MIRROR) == 0 && (t->flag & T_MIRROR)) | ||||
| editbmesh_apply_to_mirror(t); | editbmesh_apply_to_mirror(t); | ||||
| if (t->mode == TFM_EDGE_SLIDE) { | if (t->mode == TFM_EDGE_SLIDE) { | ||||
| projectEdgeSlideData(t, false); | projectEdgeSlideData(t, false); | ||||
| } | } | ||||
| else if (t->mode == TFM_VERT_SLIDE) { | else if (t->mode == TFM_VERT_SLIDE) { | ||||
| projectVertSlideData(t, false); | projectVertSlideData(t, false); | ||||
| } | } | ||||
| DEG_id_tag_update(t->obedit->data, 0); /* sets recalc flags */ | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| DEG_id_tag_update(tc->obedit->data, 0); /* sets recalc flags */ | |||||
| BMEditMesh *em = BKE_editmesh_from_object(tc->obedit); | |||||
| EDBM_mesh_normals_update(em); | EDBM_mesh_normals_update(em); | ||||
| BKE_editmesh_tessface_calc(em); | BKE_editmesh_tessface_calc(em); | ||||
| } // FIXME(indent) | |||||
| } | } | ||||
| else if (t->obedit->type == OB_ARMATURE) { /* no recalc flag, does pose */ | else if (t->obedit_type == OB_ARMATURE) { /* no recalc flag, does pose */ | ||||
| bArmature *arm = t->obedit->data; | |||||
| ListBase *edbo = arm->edbo; | |||||
| EditBone *ebo, *ebo_parent; | |||||
| TransData *td = t->data; | |||||
| int i; | |||||
| if (t->state != TRANS_CANCEL) { | if (t->state != TRANS_CANCEL) { | ||||
| applyProject(t); | applyProject(t); | ||||
| } | } | ||||
| FOREACH_TRANS_DATA_CONTAINER (t, tc) { | |||||
| bArmature *arm = tc->obedit->data; | |||||
| ListBase *edbo = arm->edbo; | |||||
| EditBone *ebo, *ebo_parent; | |||||
| TransData *td = tc->data; | |||||
| int i; | |||||
| /* Ensure all bones are correctly adjusted */ | /* Ensure all bones are correctly adjusted */ | ||||
| for (ebo = edbo->first; ebo; ebo = ebo->next) { | for (ebo = edbo->first; ebo; ebo = ebo->next) { | ||||
| ebo_parent = (ebo->flag & BONE_CONNECTED) ? ebo->parent : NULL; | ebo_parent = (ebo->flag & BONE_CONNECTED) ? ebo->parent : NULL; | ||||
| if (ebo_parent) { | if (ebo_parent) { | ||||
| /* If this bone has a parent tip that has been moved */ | /* If this bone has a parent tip that has been moved */ | ||||
| if (ebo_parent->flag & BONE_TIPSEL) { | if (ebo_parent->flag & BONE_TIPSEL) { | ||||
| copy_v3_v3(ebo->head, ebo_parent->tail); | copy_v3_v3(ebo->head, ebo_parent->tail); | ||||
| if (t->mode == TFM_BONE_ENVELOPE) ebo->rad_head = ebo_parent->rad_tail; | if (t->mode == TFM_BONE_ENVELOPE) ebo->rad_head = ebo_parent->rad_tail; | ||||
| } | } | ||||
| /* If this bone has a parent tip that has NOT been moved */ | /* If this bone has a parent tip that has NOT been moved */ | ||||
| else { | else { | ||||
| Show All 23 Lines | else if (t->obedit_type == OB_ARMATURE) { /* no recalc flag, does pose */ | ||||
| if (ebo_parent) { | if (ebo_parent) { | ||||
| ebo_parent->rad_tail = ebo->rad_head; | ebo_parent->rad_tail = ebo->rad_head; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (!ELEM(t->mode, TFM_BONE_ROLL, TFM_BONE_ENVELOPE, TFM_BONE_ENVELOPE_DIST, TFM_BONESIZE)) { | if (!ELEM(t->mode, TFM_BONE_ROLL, TFM_BONE_ENVELOPE, TFM_BONE_ENVELOPE_DIST, TFM_BONESIZE)) { | ||||
| /* fix roll */ | /* fix roll */ | ||||
| for (i = 0; i < t->total; i++, td++) { | for (i = 0; i < tc->data_len; i++, td++) { | ||||
| if (td->extra) { | if (td->extra) { | ||||
| float vec[3], up_axis[3]; | float vec[3], up_axis[3]; | ||||
| float qrot[4]; | float qrot[4]; | ||||
| float roll; | float roll; | ||||
| ebo = td->extra; | ebo = td->extra; | ||||
| if (t->state == TRANS_CANCEL) { | if (t->state == TRANS_CANCEL) { | ||||
| Show All 10 Lines | else if (t->obedit_type == OB_ARMATURE) { /* no recalc flag, does pose */ | ||||
| /* roll has a tendency to flip in certain orientations - [#34283], [#33974] */ | /* roll has a tendency to flip in certain orientations - [#34283], [#33974] */ | ||||
| roll = ED_armature_ebone_roll_to_vector(ebo, up_axis, false); | roll = ED_armature_ebone_roll_to_vector(ebo, up_axis, false); | ||||
| ebo->roll = angle_compat_rad(roll, td->ival); | ebo->roll = angle_compat_rad(roll, td->ival); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (arm->flag & ARM_MIRROR_EDIT) { | if (arm->flag & ARM_MIRROR_EDIT) { | ||||
| if (t->state != TRANS_CANCEL) | if (t->state != TRANS_CANCEL) { | ||||
| ED_armature_edit_transform_mirror_update(t->obedit); | ED_armature_edit_transform_mirror_update(tc->obedit); | ||||
| else | } | ||||
| restoreBones(t); | else { | ||||
| restoreBones(tc); | |||||
| } | } | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| } | |||||
| else { | else { | ||||
| if (t->state != TRANS_CANCEL) { | if (t->state != TRANS_CANCEL) { | ||||
| applyProject(t); | applyProject(t); | ||||
| } | } | ||||
| DEG_id_tag_update(t->obedit->data, 0); /* sets recalc flags */ | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| if (tc->data_len) { | |||||
| DEG_id_tag_update(tc->obedit->data, 0); /* sets recalc flags */ | |||||
| } | |||||
| } // FIXME(indent) | |||||
| } | } | ||||
| } | } | ||||
| else if ((t->flag & T_POSE) && t->poseobj) { | else if (t->flag & T_POSE) { | ||||
| Object *ob = t->poseobj; | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| Object *ob = tc->poseobj; | |||||
| bArmature *arm = ob->data; | bArmature *arm = ob->data; | ||||
| /* if animtimer is running, and the object already has animation data, | /* if animtimer is running, and the object already has animation data, | ||||
| * check if the auto-record feature means that we should record 'samples' | * check if the auto-record feature means that we should record 'samples' | ||||
| * (i.e. uneditable animation values) | * (i.e. uneditable animation values) | ||||
| * | * | ||||
| * context is needed for keying set poll() functions. | * context is needed for keying set poll() functions. | ||||
| */ | */ | ||||
| // TODO: autokeyframe calls need some setting to specify to add samples (FPoints) instead of keyframes? | // TODO: autokeyframe calls need some setting to specify to add samples (FPoints) instead of keyframes? | ||||
| if ((t->animtimer) && (t->context) && IS_AUTOKEY_ON(t->scene)) { | if ((t->animtimer) && (t->context) && IS_AUTOKEY_ON(t->scene)) { | ||||
| int targetless_ik = (t->flag & T_AUTOIK); // XXX this currently doesn't work, since flags aren't set yet! | int targetless_ik = (t->flag & T_AUTOIK); // XXX this currently doesn't work, since flags aren't set yet! | ||||
| animrecord_check_state(t->scene, &ob->id, t->animtimer); | animrecord_check_state(t->scene, &ob->id, t->animtimer); | ||||
| autokeyframe_pose_cb_func(t->context, t->scene, (View3D *)t->view, ob, t->mode, targetless_ik); | autokeyframe_pose_cb_func(t->context, t->scene, (View3D *)t->view, ob, t->mode, targetless_ik); | ||||
| } | } | ||||
| /* old optimize trick... this enforces to bypass the depgraph */ | /* old optimize trick... this enforces to bypass the depgraph */ | ||||
| if (!(arm->flag & ARM_DELAYDEFORM)) { | if (!(arm->flag & ARM_DELAYDEFORM)) { | ||||
| DEG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sets recalc flags */ | DEG_id_tag_update(&ob->id, OB_RECALC_DATA); /* sets recalc flags */ | ||||
| /* transformation of pose may affect IK tree, make sure it is rebuilt */ | /* transformation of pose may affect IK tree, make sure it is rebuilt */ | ||||
| BIK_clear_data(ob->pose); | BIK_clear_data(ob->pose); | ||||
| } | } | ||||
| else | else | ||||
| BKE_pose_where_is(&t->eval_ctx, t->scene, ob); | BKE_pose_where_is(&t->eval_ctx, t->scene, ob); | ||||
| } // FIXME(indent) | |||||
| } | } | ||||
| else if (base && (base->object->mode & OB_MODE_PARTICLE_EDIT) && | else if (base && (base->object->mode & OB_MODE_PARTICLE_EDIT) && | ||||
| PE_get_current(t->scene, base->object)) | PE_get_current(t->scene, base->object)) | ||||
| { | { | ||||
| if (t->state != TRANS_CANCEL) { | if (t->state != TRANS_CANCEL) { | ||||
| applyProject(t); | applyProject(t); | ||||
| } | } | ||||
| flushTransParticles(t); | flushTransParticles(t); | ||||
| } | } | ||||
| else { | else { | ||||
| int i; | int i; | ||||
| if (t->state != TRANS_CANCEL) { | if (t->state != TRANS_CANCEL) { | ||||
| applyProject(t); | applyProject(t); | ||||
| } | } | ||||
| for (i = 0; i < t->total; i++) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = t->data + i; | TransData *td = tc->data; | ||||
| for (i = 0; i < tc->data_len; i++, td++) { | |||||
| Object *ob = td->ob; | Object *ob = td->ob; | ||||
| if (td->flag & TD_NOACTION) | if (td->flag & TD_NOACTION) | ||||
| break; | break; | ||||
| if (td->flag & TD_SKIP) | if (td->flag & TD_SKIP) | ||||
| continue; | continue; | ||||
| Show All 10 Lines | for (i = 0; i < tc->data_len; i++, td++) { | ||||
| /* sets recalc flags fully, instead of flushing existing ones | /* sets recalc flags fully, instead of flushing existing ones | ||||
| * otherwise proxies don't function correctly | * otherwise proxies don't function correctly | ||||
| */ | */ | ||||
| DEG_id_tag_update(&ob->id, OB_RECALC_OB); | DEG_id_tag_update(&ob->id, OB_RECALC_OB); | ||||
| if (t->flag & T_TEXTURE) | if (t->flag & T_TEXTURE) | ||||
| DEG_id_tag_update(&ob->id, OB_RECALC_DATA); | DEG_id_tag_update(&ob->id, OB_RECALC_DATA); | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| } | } | ||||
| } | } | ||||
| /* helper for recalcData() - for sequencer transforms */ | /* helper for recalcData() - for sequencer transforms */ | ||||
| static void recalcData_sequencer(TransInfo *t) | static void recalcData_sequencer(TransInfo *t) | ||||
| { | { | ||||
| TransData *td; | TransData *td; | ||||
| int a; | int a; | ||||
| Sequence *seq_prev = NULL; | Sequence *seq_prev = NULL; | ||||
| for (a = 0, td = t->data; a < t->total; a++, td++) { | TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t); | ||||
| for (a = 0, td = tc->data; a < tc->data_len; a++, td++) { | |||||
| TransDataSeq *tdsq = (TransDataSeq *) td->extra; | TransDataSeq *tdsq = (TransDataSeq *) td->extra; | ||||
| Sequence *seq = tdsq->seq; | Sequence *seq = tdsq->seq; | ||||
| if (seq != seq_prev) { | if (seq != seq_prev) { | ||||
| if (BKE_sequence_tx_fullupdate_test(seq)) { | if (BKE_sequence_tx_fullupdate_test(seq)) { | ||||
| /* A few effect strip types need a complete recache on transform. */ | /* A few effect strip types need a complete recache on transform. */ | ||||
| BKE_sequence_invalidate_cache(t->scene, seq); | BKE_sequence_invalidate_cache(t->scene, seq); | ||||
| } | } | ||||
| else { | else { | ||||
| BKE_sequence_invalidate_dependent(t->scene, seq); | BKE_sequence_invalidate_dependent(t->scene, seq); | ||||
| } | } | ||||
| } | } | ||||
| seq_prev = seq; | seq_prev = seq; | ||||
| } | } | ||||
| BKE_sequencer_preprocessed_cache_cleanup(); | BKE_sequencer_preprocessed_cache_cleanup(); | ||||
| flushTransSeq(t); | flushTransSeq(t); | ||||
| } | } | ||||
| /* force recalculation of triangles during transformation */ | /* force recalculation of triangles during transformation */ | ||||
| static void recalcData_gpencil_strokes(TransInfo *t) | static void recalcData_gpencil_strokes(TransInfo *t) | ||||
| { | { | ||||
| TransData *td = t->data; | TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t); | ||||
| for (int i = 0; i < t->total; i++, td++) { | |||||
| TransData *td = tc->data; | |||||
| for (int i = 0; i < tc->data_len; i++, td++) { | |||||
| bGPDstroke *gps = td->extra; | bGPDstroke *gps = td->extra; | ||||
| if (gps != NULL) { | if (gps != NULL) { | ||||
| gps->flag |= GP_STROKE_RECALC_CACHES; | gps->flag |= GP_STROKE_RECALC_CACHES; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| /* called for updating while transform acts, once per redraw */ | /* called for updating while transform acts, once per redraw */ | ||||
| ▲ Show 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | void drawLine(TransInfo *t, const float center[3], const float dir[3], char axis, short options) | ||||
| } | } | ||||
| } | } | ||||
| /** | /** | ||||
| * Free data before switching to another mode. | * Free data before switching to another mode. | ||||
| */ | */ | ||||
| void resetTransModal(TransInfo *t) | void resetTransModal(TransInfo *t) | ||||
| { | { | ||||
| FOREACH_TRANS_DATA_CONTAINER (t, tc) { | |||||
| if (t->mode == TFM_EDGE_SLIDE) { | if (t->mode == TFM_EDGE_SLIDE) { | ||||
| freeEdgeSlideVerts(t, &t->custom.mode); | freeEdgeSlideVerts(t, tc, &tc->custom.mode); | ||||
| } | } | ||||
| else if (t->mode == TFM_VERT_SLIDE) { | else if (t->mode == TFM_VERT_SLIDE) { | ||||
| freeVertSlideVerts(t, &t->custom.mode); | freeVertSlideVerts(t, tc, &tc->custom.mode); | ||||
| } | |||||
| else { | |||||
| /* no need to keep looping... */ | |||||
| break; | |||||
| } | } | ||||
| } // FIXME(indent) | |||||
| } | } | ||||
| void resetTransRestrictions(TransInfo *t) | void resetTransRestrictions(TransInfo *t) | ||||
| { | { | ||||
| t->flag &= ~T_ALL_RESTRICTIONS; | t->flag &= ~T_ALL_RESTRICTIONS; | ||||
| } | } | ||||
| static int initTransInfo_edit_pet_to_flag(const int proportional) | static int initTransInfo_edit_pet_to_flag(const int proportional) | ||||
| { | { | ||||
| switch (proportional) { | switch (proportional) { | ||||
| case PROP_EDIT_ON: | case PROP_EDIT_ON: | ||||
| return T_PROP_EDIT; | return T_PROP_EDIT; | ||||
| case PROP_EDIT_CONNECTED: | case PROP_EDIT_CONNECTED: | ||||
| return T_PROP_EDIT | T_PROP_CONNECTED; | return T_PROP_EDIT | T_PROP_CONNECTED; | ||||
| case PROP_EDIT_PROJECTED: | case PROP_EDIT_PROJECTED: | ||||
| return T_PROP_EDIT | T_PROP_PROJECTED; | return T_PROP_EDIT | T_PROP_PROJECTED; | ||||
| default: | default: | ||||
| return 0; | return 0; | ||||
| } | } | ||||
| } | } | ||||
| void initTransDataContainers_FromObjectData(TransInfo *t) | |||||
| { | |||||
| const eObjectMode object_mode = OBACT(t->view_layer) ? OBACT(t->view_layer)->mode : OB_MODE_OBJECT; | |||||
| const short object_type = OBACT(t->view_layer) ? OBACT(t->view_layer)->type : -1; | |||||
| if ((object_mode & OB_MODE_EDIT) || | |||||
| ((object_mode & OB_MODE_POSE) && (object_type == OB_ARMATURE))) | |||||
| { | |||||
| if (t->data_container) { | |||||
| MEM_freeN(t->data_container); | |||||
| } | |||||
| uint objects_len; | |||||
| Object **objects = BKE_view_layer_array_from_objects_in_mode( | |||||
| t->view_layer, &objects_len, { | |||||
| .object_mode = object_mode, | |||||
| .no_dup_data = true}); | |||||
| t->data_container = MEM_callocN(sizeof(*t->data_container) * objects_len, __func__); | |||||
| t->data_container_len = objects_len; | |||||
| for (int i = 0; i < objects_len; i++) { | |||||
| TransDataContainer *tc = &t->data_container[i]; | |||||
| if (object_mode & OB_MODE_EDIT) { | |||||
| tc->obedit = objects[i]; | |||||
| copy_m3_m4(tc->obedit_mat, tc->obedit->obmat); | |||||
| normalize_m3(tc->obedit_mat); | |||||
| } | |||||
| else if (object_mode & OB_MODE_POSE) { | |||||
| tc->poseobj = objects[i]; | |||||
| } | |||||
| } | |||||
| MEM_freeN(objects); | |||||
| } | |||||
| } | |||||
| /** | /** | ||||
| * Setup internal data, mouse, vectors | * Setup internal data, mouse, vectors | ||||
| * | * | ||||
| * \note \a op and \a event can be NULL | * \note \a op and \a event can be NULL | ||||
| * | * | ||||
| * \see #saveTransform does the reverse. | * \see #saveTransform does the reverse. | ||||
| */ | */ | ||||
| void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *event) | void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *event) | ||||
| { | { | ||||
| CTX_data_eval_ctx(C, &t->eval_ctx); | CTX_data_eval_ctx(C, &t->eval_ctx); | ||||
| Depsgraph *depsgraph = CTX_data_depsgraph(C); | Depsgraph *depsgraph = CTX_data_depsgraph(C); | ||||
| Scene *sce = CTX_data_scene(C); | Scene *sce = CTX_data_scene(C); | ||||
| ViewLayer *view_layer = CTX_data_view_layer(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); | ToolSettings *ts = CTX_data_tool_settings(C); | ||||
| ARegion *ar = CTX_wm_region(C); | ARegion *ar = CTX_wm_region(C); | ||||
| ScrArea *sa = CTX_wm_area(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); | bGPdata *gpd = CTX_data_gpencil_data(C); | ||||
| RenderEngineType *engine_type = CTX_data_engine_type(C); | RenderEngineType *engine_type = CTX_data_engine_type(C); | ||||
| PropertyRNA *prop; | PropertyRNA *prop; | ||||
| t->depsgraph = depsgraph; | t->depsgraph = depsgraph; | ||||
| t->scene = sce; | t->scene = sce; | ||||
| t->view_layer = view_layer; | t->view_layer = view_layer; | ||||
| t->engine_type = engine_type; | t->engine_type = engine_type; | ||||
| t->sa = sa; | t->sa = sa; | ||||
| t->ar = ar; | t->ar = ar; | ||||
| t->obedit = obedit; | |||||
| t->settings = ts; | t->settings = ts; | ||||
| t->reports = op ? op->reports : NULL; | t->reports = op ? op->reports : NULL; | ||||
| if (obedit) { | |||||
| copy_m3_m4(t->obedit_mat, obedit->obmat); | |||||
| normalize_m3(t->obedit_mat); | |||||
| } | |||||
| t->data = NULL; | |||||
| t->ext = NULL; | |||||
| t->helpline = HLP_NONE; | t->helpline = HLP_NONE; | ||||
| t->flag = 0; | t->flag = 0; | ||||
| t->obedit_type = (object_mode == OB_MODE_EDIT) ? object_type : -1; | |||||
| /* Many kinds of transform only use a single handle. */ | |||||
| if (t->data_container == NULL) { | |||||
| t->data_container = MEM_callocN(sizeof(*t->data_container), __func__); | |||||
| t->data_container_len = 1; | |||||
| } | |||||
| t->redraw = TREDRAW_HARD; /* redraw first time */ | t->redraw = TREDRAW_HARD; /* redraw first time */ | ||||
| if (event) { | if (event) { | ||||
| t->mouse.imval[0] = event->mval[0]; | t->mouse.imval[0] = event->mval[0]; | ||||
| t->mouse.imval[1] = event->mval[1]; | t->mouse.imval[1] = event->mval[1]; | ||||
| } | } | ||||
| else { | else { | ||||
| t->mouse.imval[0] = 0; | t->mouse.imval[0] = 0; | ||||
| t->mouse.imval[1] = 0; | t->mouse.imval[1] = 0; | ||||
| } | } | ||||
| t->con.imval[0] = t->mouse.imval[0]; | t->con.imval[0] = t->mouse.imval[0]; | ||||
| t->con.imval[1] = t->mouse.imval[1]; | t->con.imval[1] = t->mouse.imval[1]; | ||||
| t->mval[0] = t->mouse.imval[0]; | t->mval[0] = t->mouse.imval[0]; | ||||
| t->mval[1] = t->mouse.imval[1]; | t->mval[1] = t->mouse.imval[1]; | ||||
| t->transform = NULL; | t->transform = NULL; | ||||
| t->handleEvent = NULL; | t->handleEvent = NULL; | ||||
| t->total = 0; | t->data_len_all = 0; | ||||
| t->val = 0.0f; | t->val = 0.0f; | ||||
| zero_v3(t->vec); | zero_v3(t->vec); | ||||
| zero_v3(t->center); | |||||
| zero_v3(t->center_global); | zero_v3(t->center_global); | ||||
| unit_m3(t->mat); | unit_m3(t->mat); | ||||
| /* if there's an event, we're modal */ | /* if there's an event, we're modal */ | ||||
| if (event) { | if (event) { | ||||
| t->flag |= T_MODAL; | t->flag |= T_MODAL; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | if (t->spacetype == SPACE_VIEW3D) { | ||||
| t->custom_orientation = BKE_workspace_transform_orientation_find( | t->custom_orientation = BKE_workspace_transform_orientation_find( | ||||
| CTX_wm_workspace(C), v3d->custom_orientation_index); | CTX_wm_workspace(C), v3d->custom_orientation_index); | ||||
| /* exceptional case */ | /* exceptional case */ | ||||
| if (t->around == V3D_AROUND_LOCAL_ORIGINS) { | if (t->around == V3D_AROUND_LOCAL_ORIGINS) { | ||||
| if (ELEM(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL)) { | if (ELEM(t->mode, TFM_ROTATION, TFM_RESIZE, TFM_TRACKBALL)) { | ||||
| const bool use_island = transdata_check_local_islands(t, t->around); | 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; | 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); | Paint *p = BKE_paint_get_active_from_context(C); | ||||
| if (p && p->brush && (p->brush->flag & BRUSH_CURVE)) { | if (p && p->brush && (p->brush->flag & BRUSH_CURVE)) { | ||||
| t->options |= CTX_PAINT_CURVE; | t->options |= CTX_PAINT_CURVE; | ||||
| } | } | ||||
| } | } | ||||
| /* initialize UV transform from */ | /* initialize UV transform from */ | ||||
| if (op && ((prop = RNA_struct_find_property(op->ptr, "correct_uv")))) { | if (op && ((prop = RNA_struct_find_property(op->ptr, "correct_uv")))) { | ||||
| Show All 12 Lines | void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *event) | ||||
| } | } | ||||
| else if (t->spacetype == SPACE_IMAGE) { | else if (t->spacetype == SPACE_IMAGE) { | ||||
| SpaceImage *sima = sa->spacedata.first; | SpaceImage *sima = sa->spacedata.first; | ||||
| // XXX for now, get View2D from the active region | // XXX for now, get View2D from the active region | ||||
| t->view = &ar->v2d; | t->view = &ar->v2d; | ||||
| t->around = sima->around; | t->around = sima->around; | ||||
| if (ED_space_image_show_uvedit(sima, t->obedit)) { | if (ED_space_image_show_uvedit(sima, OBACT(t->view_layer))) { | ||||
| /* UV transform */ | /* UV transform */ | ||||
| } | } | ||||
| else if (sima->mode == SI_MODE_MASK) { | else if (sima->mode == SI_MODE_MASK) { | ||||
| t->options |= CTX_MASK; | t->options |= CTX_MASK; | ||||
| } | } | ||||
| else if (sima->mode == SI_MODE_PAINT) { | else if (sima->mode == SI_MODE_PAINT) { | ||||
| Paint *p = &sce->toolsettings->imapaint.paint; | Paint *p = &sce->toolsettings->imapaint.paint; | ||||
| if (p->brush && (p->brush->flag & BRUSH_CURVE)) { | if (p->brush && (p->brush->flag & BRUSH_CURVE)) { | ||||
| ▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | void initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *event) | ||||
| { | { | ||||
| if (RNA_property_boolean_get(op->ptr, prop)) { | if (RNA_property_boolean_get(op->ptr, prop)) { | ||||
| t->flag |= T_MIRROR; | t->flag |= T_MIRROR; | ||||
| t->mirror = 1; | t->mirror = 1; | ||||
| } | } | ||||
| } | } | ||||
| // Need stuff to take it from edit mesh or whatnot here | // Need stuff to take it from edit mesh or whatnot here | ||||
| else if (t->spacetype == SPACE_VIEW3D) { | else if (t->spacetype == SPACE_VIEW3D) { | ||||
| if (t->obedit && t->obedit->type == OB_MESH && (((Mesh *)t->obedit->data)->editflag & ME_EDIT_MIRROR_X)) { | /* TODO(campbell): xform, get mirror from each object. */ | ||||
| if (t->obedit_type == OB_MESH && (((Mesh *)OBACT(t->view_layer)->data)->editflag & ME_EDIT_MIRROR_X)) { | |||||
| t->flag |= T_MIRROR; | t->flag |= T_MIRROR; | ||||
| t->mirror = 1; | t->mirror = 1; | ||||
| } | } | ||||
| } | } | ||||
| /* setting PET flag only if property exist in operator. Otherwise, assume it's not supported */ | /* setting PET flag only if property exist in operator. Otherwise, assume it's not supported */ | ||||
| if (op && (prop = RNA_struct_find_property(op->ptr, "proportional"))) { | if (op && (prop = RNA_struct_find_property(op->ptr, "proportional"))) { | ||||
| if (RNA_property_is_set(op->ptr, prop)) { | if (RNA_property_is_set(op->ptr, prop)) { | ||||
| t->flag |= initTransInfo_edit_pet_to_flag(RNA_property_enum_get(op->ptr, prop)); | t->flag |= initTransInfo_edit_pet_to_flag(RNA_property_enum_get(op->ptr, prop)); | ||||
| } | } | ||||
| else { | else { | ||||
| /* use settings from scene only if modal */ | /* use settings from scene only if modal */ | ||||
| if (t->flag & T_MODAL) { | if (t->flag & T_MODAL) { | ||||
| if ((t->options & CTX_NO_PET) == 0) { | if ((t->options & CTX_NO_PET) == 0) { | ||||
| if (t->spacetype == SPACE_IPO) { | if (t->spacetype == SPACE_IPO) { | ||||
| t->flag |= initTransInfo_edit_pet_to_flag(ts->proportional_fcurve); | t->flag |= initTransInfo_edit_pet_to_flag(ts->proportional_fcurve); | ||||
| } | } | ||||
| else if (t->spacetype == SPACE_ACTION) { | else if (t->spacetype == SPACE_ACTION) { | ||||
| t->flag |= initTransInfo_edit_pet_to_flag(ts->proportional_action); | t->flag |= initTransInfo_edit_pet_to_flag(ts->proportional_action); | ||||
| } | } | ||||
| else if (t->obedit) { | else if (t->obedit_type != -1) { | ||||
| t->flag |= initTransInfo_edit_pet_to_flag(ts->proportional); | t->flag |= initTransInfo_edit_pet_to_flag(ts->proportional); | ||||
| } | } | ||||
| else if (t->options & CTX_GPENCIL_STROKES) { | else if (t->options & CTX_GPENCIL_STROKES) { | ||||
| t->flag |= initTransInfo_edit_pet_to_flag(ts->proportional); | t->flag |= initTransInfo_edit_pet_to_flag(ts->proportional); | ||||
| } | } | ||||
| else if (t->options & CTX_MASK) { | else if (t->options & CTX_MASK) { | ||||
| if (ts->proportional_mask) { | if (ts->proportional_mask) { | ||||
| t->flag |= T_PROP_EDIT; | t->flag |= T_PROP_EDIT; | ||||
| if (ts->proportional == PROP_EDIT_CONNECTED) { | if (ts->proportional == PROP_EDIT_CONNECTED) { | ||||
| t->flag |= T_PROP_CONNECTED; | t->flag |= T_PROP_CONNECTED; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else if (t->obedit == NULL && ts->proportional_objects) { | else if ((t->obedit_type == -1) && ts->proportional_objects) { | ||||
| t->flag |= T_PROP_EDIT; | t->flag |= T_PROP_EDIT; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (op && ((prop = RNA_struct_find_property(op->ptr, "proportional_size")) && | if (op && ((prop = RNA_struct_find_property(op->ptr, "proportional_size")) && | ||||
| RNA_property_is_set(op->ptr, prop))) | RNA_property_is_set(op->ptr, prop))) | ||||
| Show All 29 Lines | #if 0 | ||||
| if (t->flag & T_PROP_EDIT) { | if (t->flag & T_PROP_EDIT) { | ||||
| t->flag &= ~T_MIRROR; | t->flag &= ~T_MIRROR; | ||||
| } | } | ||||
| #endif | #endif | ||||
| setTransformViewAspect(t, t->aspect); | setTransformViewAspect(t, t->aspect); | ||||
| if (op && (prop = RNA_struct_find_property(op->ptr, "center_override")) && RNA_property_is_set(op->ptr, prop)) { | if (op && (prop = RNA_struct_find_property(op->ptr, "center_override")) && RNA_property_is_set(op->ptr, prop)) { | ||||
| RNA_property_float_get_array(op->ptr, prop, t->center); | RNA_property_float_get_array(op->ptr, prop, t->center_global); | ||||
| mul_v3_v3(t->center, t->aspect); | mul_v3_v3(t->center_global, t->aspect); | ||||
| t->flag |= T_OVERRIDE_CENTER; | t->flag |= T_OVERRIDE_CENTER; | ||||
| } | } | ||||
| setTransformViewMatrices(t); | setTransformViewMatrices(t); | ||||
| initNumInput(&t->num); | initNumInput(&t->num); | ||||
| } | } | ||||
| static void freeTransCustomDataContainer(TransInfo *t, TransDataContainer *tc, TransCustomDataContainer *tcdc) | |||||
| { | |||||
| TransCustomData *custom_data = &tcdc->first_elem; | |||||
| for (int i = 0; i < TRANS_CUSTOM_DATA_ELEM_MAX; i++, custom_data++) { | |||||
| if (custom_data->free_cb) { | |||||
| /* Can take over freeing t->data and data_2d etc... */ | |||||
| custom_data->free_cb(t, tc, custom_data); | |||||
| BLI_assert(custom_data->data == NULL); | |||||
| } | |||||
| else if ((custom_data->data != NULL) && custom_data->use_free) { | |||||
| MEM_freeN(custom_data->data); | |||||
| custom_data->data = NULL; | |||||
| } | |||||
| } | |||||
| } | |||||
| /* Here I would suggest only TransInfo related issues, like free data & reset vars. Not redraws */ | /* Here I would suggest only TransInfo related issues, like free data & reset vars. Not redraws */ | ||||
| void postTrans(bContext *C, TransInfo *t) | void postTrans(bContext *C, TransInfo *t) | ||||
| { | { | ||||
| TransData *td; | |||||
| if (t->draw_handle_view) | if (t->draw_handle_view) | ||||
| ED_region_draw_cb_exit(t->ar->type, t->draw_handle_view); | ED_region_draw_cb_exit(t->ar->type, t->draw_handle_view); | ||||
| if (t->draw_handle_apply) | if (t->draw_handle_apply) | ||||
| ED_region_draw_cb_exit(t->ar->type, t->draw_handle_apply); | ED_region_draw_cb_exit(t->ar->type, t->draw_handle_apply); | ||||
| if (t->draw_handle_pixel) | if (t->draw_handle_pixel) | ||||
| ED_region_draw_cb_exit(t->ar->type, t->draw_handle_pixel); | ED_region_draw_cb_exit(t->ar->type, t->draw_handle_pixel); | ||||
| if (t->draw_handle_cursor) | if (t->draw_handle_cursor) | ||||
| WM_paint_cursor_end(CTX_wm_manager(C), t->draw_handle_cursor); | WM_paint_cursor_end(CTX_wm_manager(C), t->draw_handle_cursor); | ||||
| /* Free all custom-data */ | /* Free all custom-data */ | ||||
| { | freeTransCustomDataContainer(t, NULL, &t->custom); | ||||
| TransCustomData *custom_data = &t->custom.first_elem; | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| for (int i = 0; i < TRANS_CUSTOM_DATA_ELEM_MAX; i++, custom_data++) { | freeTransCustomDataContainer(t, tc, &tc->custom); | ||||
| if (custom_data->free_cb) { | |||||
| /* Can take over freeing t->data and data2d etc... */ | |||||
| custom_data->free_cb(t, custom_data); | |||||
| BLI_assert(custom_data->data == NULL); | |||||
| } | |||||
| else if ((custom_data->data != NULL) && custom_data->use_free) { | |||||
| MEM_freeN(custom_data->data); | |||||
| custom_data->data = NULL; | |||||
| } | |||||
| } | |||||
| } | } | ||||
| /* postTrans can be called when nothing is selected, so data is NULL already */ | /* postTrans can be called when nothing is selected, so data is NULL already */ | ||||
| if (t->data) { | if (t->data_len_all != 0) { | ||||
| FOREACH_TRANS_DATA_CONTAINER (t, tc) { | |||||
| /* free data malloced per trans-data */ | /* free data malloced per trans-data */ | ||||
| if ((t->obedit && ELEM(t->obedit->type, OB_CURVE, OB_SURF)) || | if (ELEM(t->obedit_type, OB_CURVE, OB_SURF) || | ||||
| (t->spacetype == SPACE_IPO)) | (t->spacetype == SPACE_IPO)) | ||||
| { | { | ||||
| int a; | TransData *td = tc->data; | ||||
| for (a = 0, td = t->data; a < t->total; a++, td++) { | for (int a = 0; a < tc->data_len; a++, td++) { | ||||
| if (td->flag & TD_BEZTRIPLE) { | if (td->flag & TD_BEZTRIPLE) { | ||||
| MEM_freeN(td->hdata); | MEM_freeN(td->hdata); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| MEM_freeN(t->data); | MEM_freeN(tc->data); | ||||
| MEM_SAFE_FREE(tc->data_ext); | |||||
| MEM_SAFE_FREE(tc->data_2d); | |||||
| } | |||||
| } | } | ||||
| BLI_freelistN(&t->tsnap.points); | MEM_SAFE_FREE(t->data_container); | ||||
| t->data_container = NULL; | |||||
| if (t->ext) MEM_freeN(t->ext); | BLI_freelistN(&t->tsnap.points); | ||||
| if (t->data2d) { | |||||
| MEM_freeN(t->data2d); | |||||
| t->data2d = NULL; | |||||
| } | |||||
| if (t->spacetype == SPACE_IMAGE) { | if (t->spacetype == SPACE_IMAGE) { | ||||
| if (t->options & (CTX_MASK | CTX_PAINT_CURVE)) { | if (t->options & (CTX_MASK | CTX_PAINT_CURVE)) { | ||||
| /* pass */ | /* pass */ | ||||
| } | } | ||||
| else { | else { | ||||
| SpaceImage *sima = t->sa->spacedata.first; | SpaceImage *sima = t->sa->spacedata.first; | ||||
| if (sima->flag & SI_LIVE_UNWRAP) | if (sima->flag & SI_LIVE_UNWRAP) | ||||
| ED_uvedit_live_unwrap_end(t->state == TRANS_CANCEL); | ED_uvedit_live_unwrap_end(t->state == TRANS_CANCEL); | ||||
| Show All 11 Lines | if (t->mouse.data) { | ||||
| MEM_freeN(t->mouse.data); | MEM_freeN(t->mouse.data); | ||||
| } | } | ||||
| freeSnapping(t); | freeSnapping(t); | ||||
| } | } | ||||
| void applyTransObjects(TransInfo *t) | void applyTransObjects(TransInfo *t) | ||||
| { | { | ||||
| TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_SINGLE(t); | |||||
| TransData *td; | TransData *td; | ||||
| for (td = t->data; td < t->data + t->total; td++) { | for (td = tc->data; td < tc->data + tc->data_len; td++) { | ||||
| copy_v3_v3(td->iloc, td->loc); | copy_v3_v3(td->iloc, td->loc); | ||||
| if (td->ext->rot) { | if (td->ext->rot) { | ||||
| copy_v3_v3(td->ext->irot, td->ext->rot); | copy_v3_v3(td->ext->irot, td->ext->rot); | ||||
| } | } | ||||
| if (td->ext->size) { | if (td->ext->size) { | ||||
| copy_v3_v3(td->ext->isize, td->ext->size); | copy_v3_v3(td->ext->isize, td->ext->size); | ||||
| } | } | ||||
| } | } | ||||
| Show All 32 Lines | static void restoreElement(TransData *td) | ||||
| if (td->flag & TD_BEZTRIPLE) { | if (td->flag & TD_BEZTRIPLE) { | ||||
| *(td->hdata->h1) = td->hdata->ih1; | *(td->hdata->h1) = td->hdata->ih1; | ||||
| *(td->hdata->h2) = td->hdata->ih2; | *(td->hdata->h2) = td->hdata->ih2; | ||||
| } | } | ||||
| } | } | ||||
| void restoreTransObjects(TransInfo *t) | void restoreTransObjects(TransInfo *t) | ||||
| { | { | ||||
| FOREACH_TRANS_DATA_CONTAINER (t, tc) { | |||||
| TransData *td; | TransData *td; | ||||
| TransData2D *td2d; | TransData2D *td2d; | ||||
| for (td = t->data; td < t->data + t->total; td++) { | for (td = tc->data; td < tc->data + tc->data_len; td++) { | ||||
| restoreElement(td); | restoreElement(td); | ||||
| } | } | ||||
| for (td2d = t->data2d; t->data2d && td2d < t->data2d + t->total; td2d++) { | for (td2d = tc->data_2d; tc->data_2d && td2d < tc->data_2d + tc->data_len; td2d++) { | ||||
| if (td2d->h1) { | if (td2d->h1) { | ||||
| td2d->h1[0] = td2d->ih1[0]; | td2d->h1[0] = td2d->ih1[0]; | ||||
| td2d->h1[1] = td2d->ih1[1]; | td2d->h1[1] = td2d->ih1[1]; | ||||
| } | } | ||||
| if (td2d->h2) { | if (td2d->h2) { | ||||
| td2d->h2[0] = td2d->ih2[0]; | td2d->h2[0] = td2d->ih2[0]; | ||||
| td2d->h2[1] = td2d->ih2[1]; | td2d->h2[1] = td2d->ih2[1]; | ||||
| } | } | ||||
| } | } | ||||
| unit_m3(t->mat); | unit_m3(t->mat); | ||||
| } // FIXME(indent) | |||||
| recalcData(t); | recalcData(t); | ||||
| } | } | ||||
| void calculateCenter2D(TransInfo *t) | void calculateCenter2D(TransInfo *t) | ||||
| { | { | ||||
| BLI_assert(!is_zero_v3(t->aspect)); | BLI_assert(!is_zero_v3(t->aspect)); | ||||
| projectFloatView(t, t->center_global, t->center2d); | |||||
| if (t->flag & (T_EDIT | T_POSE)) { | |||||
| Object *ob = t->obedit ? t->obedit : t->poseobj; | |||||
| float vec[3]; | |||||
| copy_v3_v3(vec, t->center); | |||||
| mul_m4_v3(ob->obmat, vec); | |||||
| projectFloatView(t, vec, t->center2d); | |||||
| } | |||||
| else { | |||||
| projectFloatView(t, t->center, t->center2d); | |||||
| } | |||||
| } | } | ||||
| void calculateCenterGlobal( | void calculateCenterLocal( | ||||
| TransInfo *t, const float center_local[3], | TransInfo *t, const float center_global[3]) | ||||
| float r_center_global[3]) | |||||
| { | { | ||||
| /* setting constraint center */ | /* setting constraint center */ | ||||
| /* note, init functions may over-ride t->center */ | /* note, init functions may over-ride t->center */ | ||||
| if (t->flag & (T_EDIT | T_POSE)) { | if (t->flag & (T_EDIT | T_POSE)) { | ||||
| Object *ob = t->obedit ? t->obedit : t->poseobj; | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| mul_v3_m4v3(r_center_global, ob->obmat, center_local); | float obinv[4][4]; | ||||
| Object *ob = tc->obedit ? tc->obedit : tc->poseobj; | |||||
| invert_m4_m4(obinv, ob->obmat); | |||||
| mul_v3_m4v3(tc->center_local, obinv, center_global); | |||||
| } | |||||
| } | } | ||||
| else { | else { | ||||
| copy_v3_v3(r_center_global, center_local); | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| copy_v3_v3(tc->center_local, center_global); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| void calculateCenterCursor(TransInfo *t, float r_center[3]) | void calculateCenterCursor(TransInfo *t, float r_center[3]) | ||||
| { | { | ||||
| const float *cursor; | const float *cursor; | ||||
| cursor = ED_view3d_cursor3d_get(t->scene, t->view); | cursor = ED_view3d_cursor3d_get(t->scene, t->view); | ||||
| copy_v3_v3(r_center, cursor); | copy_v3_v3(r_center, cursor); | ||||
| /* If edit or pose mode, move cursor in local space */ | /* If edit or pose mode, move cursor in local space */ | ||||
| if (t->flag & (T_EDIT | T_POSE)) { | if (t->options & CTX_PAINT_CURVE) { | ||||
| Object *ob = t->obedit ? t->obedit : t->poseobj; | |||||
| float mat[3][3], imat[3][3]; | |||||
| sub_v3_v3v3(r_center, r_center, ob->obmat[3]); | |||||
| copy_m3_m4(mat, ob->obmat); | |||||
| invert_m3_m3(imat, mat); | |||||
| mul_m3_v3(imat, r_center); | |||||
| } | |||||
| else if (t->options & CTX_PAINT_CURVE) { | |||||
| if (ED_view3d_project_float_global(t->ar, cursor, r_center, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK) { | if (ED_view3d_project_float_global(t->ar, cursor, r_center, V3D_PROJ_TEST_NOP) != V3D_PROJ_RET_OK) { | ||||
| r_center[0] = t->ar->winx / 2.0f; | r_center[0] = t->ar->winx / 2.0f; | ||||
| r_center[1] = t->ar->winy / 2.0f; | r_center[1] = t->ar->winy / 2.0f; | ||||
| } | } | ||||
| r_center[2] = 0.0f; | r_center[2] = 0.0f; | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | else { | ||||
| r_center[1] = sipo->cursorVal; | r_center[1] = sipo->cursorVal; | ||||
| } | } | ||||
| } | } | ||||
| void calculateCenterMedian(TransInfo *t, float r_center[3]) | void calculateCenterMedian(TransInfo *t, float r_center[3]) | ||||
| { | { | ||||
| float partial[3] = {0.0f, 0.0f, 0.0f}; | float partial[3] = {0.0f, 0.0f, 0.0f}; | ||||
| int total = 0; | int total = 0; | ||||
| int i; | |||||
| for (i = 0; i < t->total; i++) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| if (t->data[i].flag & TD_SELECTED) { | Object *ob_xform = tc->obedit ? tc->obedit : tc->poseobj; | ||||
| if (!(t->data[i].flag & TD_NOCENTER)) { | int i; | ||||
| add_v3_v3(partial, t->data[i].center); | for (i = 0; i < tc->data_len; i++) { | ||||
| if (tc->data[i].flag & TD_SELECTED) { | |||||
| if (!(tc->data[i].flag & TD_NOCENTER)) { | |||||
| if (ob_xform) { | |||||
| float v[3]; | |||||
| mul_v3_m4v3(v, ob_xform->obmat, tc->data[i].center); | |||||
| add_v3_v3(partial, v); | |||||
| } | |||||
| else { | |||||
| add_v3_v3(partial, tc->data[i].center); | |||||
| } | |||||
| total++; | total++; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| if (total) { | if (total) { | ||||
| mul_v3_fl(partial, 1.0f / (float)total); | mul_v3_fl(partial, 1.0f / (float)total); | ||||
| } | } | ||||
| copy_v3_v3(r_center, partial); | copy_v3_v3(r_center, partial); | ||||
| } | } | ||||
| void calculateCenterBound(TransInfo *t, float r_center[3]) | void calculateCenterBound(TransInfo *t, float r_center[3]) | ||||
| { | { | ||||
| float max[3]; | float max[3]; | ||||
| float min[3]; | float min[3]; | ||||
| int i; | int i; | ||||
| for (i = 0; i < t->total; i++) { | bool is_first = true; | ||||
| if (i) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| if (t->data[i].flag & TD_SELECTED) { | Object *ob_xform = tc->obedit ? tc->obedit : tc->poseobj; | ||||
| if (!(t->data[i].flag & TD_NOCENTER)) | for (i = 0; i < tc->data_len; i++) { | ||||
| minmax_v3v3_v3(min, max, t->data[i].center); | if (is_first == false) { | ||||
| if (tc->data[i].flag & TD_SELECTED) { | |||||
| if (!(tc->data[i].flag & TD_NOCENTER)) { | |||||
| if (ob_xform) { | |||||
| float v[3]; | |||||
| mul_v3_m4v3(v, ob_xform->obmat, tc->data[i].center); | |||||
| minmax_v3v3_v3(min, max, v); | |||||
| } | } | ||||
| else { | |||||
| minmax_v3v3_v3(min, max, tc->data[i].center); | |||||
| } | |||||
| } | |||||
| } | |||||
| is_first = false; | |||||
| } | } | ||||
| else { | else { | ||||
| copy_v3_v3(max, t->data[i].center); | copy_v3_v3(max, tc->data[i].center); | ||||
| copy_v3_v3(min, t->data[i].center); | copy_v3_v3(min, tc->data[i].center); | ||||
| } | } | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| mid_v3_v3v3(r_center, min, max); | mid_v3_v3v3(r_center, min, max); | ||||
| } | } | ||||
| /** | /** | ||||
| * \param select_only only get active center from data being transformed. | * \param select_only only get active center from data being transformed. | ||||
| */ | */ | ||||
| bool calculateCenterActive(TransInfo *t, bool select_only, float r_center[3]) | bool calculateCenterActive(TransInfo *t, bool select_only, float r_center[3]) | ||||
| { | { | ||||
| TransDataContainer *tc = TRANS_DATA_CONTAINER_FIRST_OK(t); | |||||
| bool ok = false; | bool ok = false; | ||||
| if (t->obedit) { | if (tc->obedit) { | ||||
| if (ED_object_editmode_calc_active_center(t->obedit, select_only, r_center)) { | if (ED_object_editmode_calc_active_center(tc->obedit, select_only, r_center)) { | ||||
| mul_m4_v3(tc->obedit->obmat, r_center); | |||||
| ok = true; | ok = true; | ||||
| } | } | ||||
| } | } | ||||
| else if (t->flag & T_POSE) { | else if (t->flag & T_POSE) { | ||||
| ViewLayer *view_layer = t->view_layer; | ViewLayer *view_layer = t->view_layer; | ||||
| Object *ob = OBACT(view_layer); | Object *ob = OBACT(view_layer); | ||||
| if (ob) { | if (ob) { | ||||
| bPoseChannel *pchan = BKE_pose_channel_active(ob); | bPoseChannel *pchan = BKE_pose_channel_active(ob); | ||||
| if (pchan && (!select_only || (pchan->bone->flag & BONE_SELECTED))) { | if (pchan && (!select_only || (pchan->bone->flag & BONE_SELECTED))) { | ||||
| copy_v3_v3(r_center, pchan->pose_head); | copy_v3_v3(r_center, pchan->pose_head); | ||||
| mul_m4_v3(tc->obedit->obmat, r_center); | |||||
| ok = true; | ok = true; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else if (t->options & CTX_PAINT_CURVE) { | else if (t->options & CTX_PAINT_CURVE) { | ||||
| Paint *p = BKE_paint_get_active(t->scene, t->view_layer); | Paint *p = BKE_paint_get_active(t->scene, t->view_layer); | ||||
| Brush *br = p->brush; | Brush *br = p->brush; | ||||
| PaintCurve *pc = br->paint_curve; | PaintCurve *pc = br->paint_curve; | ||||
| ▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | case V3D_AROUND_ACTIVE: | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| void calculateCenter(TransInfo *t) | void calculateCenter(TransInfo *t) | ||||
| { | { | ||||
| if ((t->flag & T_OVERRIDE_CENTER) == 0) { | if ((t->flag & T_OVERRIDE_CENTER) == 0) { | ||||
| calculateCenter_FromAround(t, t->around, t->center); | calculateCenter_FromAround(t, t->around, t->center_global); | ||||
| } | } | ||||
| calculateCenterGlobal(t, t->center, t->center_global); | calculateCenterLocal(t, t->center_global); | ||||
| /* avoid calculating again */ | /* avoid calculating again */ | ||||
| { | { | ||||
| TransCenterData *cd = &t->center_cache[t->around]; | TransCenterData *cd = &t->center_cache[t->around]; | ||||
| copy_v3_v3(cd->local, t->center); | |||||
| copy_v3_v3(cd->global, t->center_global); | copy_v3_v3(cd->global, t->center_global); | ||||
| cd->is_set = true; | cd->is_set = true; | ||||
| } | } | ||||
| calculateCenter2D(t); | calculateCenter2D(t); | ||||
| /* for panning from cameraview */ | /* for panning from cameraview */ | ||||
| if ((t->flag & T_OBJECT) && (t->flag & T_OVERRIDE_CENTER) == 0) { | if ((t->flag & T_OBJECT) && (t->flag & T_OVERRIDE_CENTER) == 0) { | ||||
| if (t->spacetype == SPACE_VIEW3D && t->ar && t->ar->regiontype == RGN_TYPE_WINDOW) { | if (t->spacetype == SPACE_VIEW3D && t->ar && t->ar->regiontype == RGN_TYPE_WINDOW) { | ||||
| if (t->flag & T_CAMERA) { | if (t->flag & T_CAMERA) { | ||||
| float axis[3]; | float axis[3]; | ||||
| /* persinv is nasty, use viewinv instead, always right */ | /* persinv is nasty, use viewinv instead, always right */ | ||||
| copy_v3_v3(axis, t->viewinv[2]); | copy_v3_v3(axis, t->viewinv[2]); | ||||
| normalize_v3(axis); | normalize_v3(axis); | ||||
| /* 6.0 = 6 grid units */ | /* 6.0 = 6 grid units */ | ||||
| axis[0] = t->center[0] - 6.0f * axis[0]; | axis[0] = t->center_global[0] - 6.0f * axis[0]; | ||||
| axis[1] = t->center[1] - 6.0f * axis[1]; | axis[1] = t->center_global[1] - 6.0f * axis[1]; | ||||
| axis[2] = t->center[2] - 6.0f * axis[2]; | axis[2] = t->center_global[2] - 6.0f * axis[2]; | ||||
| projectFloatView(t, axis, t->center2d); | projectFloatView(t, axis, t->center2d); | ||||
| /* rotate only needs correct 2d center, grab needs ED_view3d_calc_zfac() value */ | /* rotate only needs correct 2d center, grab needs ED_view3d_calc_zfac() value */ | ||||
| if (t->mode == TFM_TRANSLATION) { | if (t->mode == TFM_TRANSLATION) { | ||||
| copy_v3_v3(t->center, axis); | copy_v3_v3(t->center_global, axis); | ||||
| copy_v3_v3(t->center_global, t->center); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| if (t->spacetype == SPACE_VIEW3D) { | if (t->spacetype == SPACE_VIEW3D) { | ||||
| /* ED_view3d_calc_zfac() defines a factor for perspective depth correction, used in ED_view3d_win_to_delta() */ | /* ED_view3d_calc_zfac() defines a factor for perspective depth correction, used in ED_view3d_win_to_delta() */ | ||||
| Show All 17 Lines | |||||
| /** | /** | ||||
| * Lazy initialize transform center data, when we need to access center values from other types. | * Lazy initialize transform center data, when we need to access center values from other types. | ||||
| */ | */ | ||||
| const TransCenterData *transformCenter_from_type(TransInfo *t, int around) | const TransCenterData *transformCenter_from_type(TransInfo *t, int around) | ||||
| { | { | ||||
| BLI_assert(around <= V3D_AROUND_ACTIVE); | BLI_assert(around <= V3D_AROUND_ACTIVE); | ||||
| TransCenterData *cd = &t->center_cache[around]; | TransCenterData *cd = &t->center_cache[around]; | ||||
| if (cd->is_set == false) { | if (cd->is_set == false) { | ||||
| calculateCenter_FromAround(t, around, cd->local); | calculateCenter_FromAround(t, around, cd->global); | ||||
| calculateCenterGlobal(t, cd->local, cd->global); | |||||
| cd->is_set = true; | cd->is_set = true; | ||||
| } | } | ||||
| return cd; | return cd; | ||||
| } | } | ||||
| void calculatePropRatio(TransInfo *t) | void calculatePropRatio(TransInfo *t) | ||||
| { | { | ||||
| TransData *td = t->data; | |||||
| int i; | int i; | ||||
| float dist; | float dist; | ||||
| const bool connected = (t->flag & T_PROP_CONNECTED) != 0; | const bool connected = (t->flag & T_PROP_CONNECTED) != 0; | ||||
| t->proptext[0] = '\0'; | t->proptext[0] = '\0'; | ||||
| if (t->flag & T_PROP_EDIT) { | if (t->flag & T_PROP_EDIT) { | ||||
| const char *pet_id = NULL; | const char *pet_id = NULL; | ||||
| for (i = 0; i < t->total; i++, td++) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | |||||
| for (i = 0; i < tc->data_len; i++, td++) { | |||||
| if (td->flag & TD_SELECTED) { | if (td->flag & TD_SELECTED) { | ||||
| td->factor = 1.0f; | td->factor = 1.0f; | ||||
| } | } | ||||
| else if (t->flag & T_MIRROR && td->loc[0] * t->mirror < -0.00001f) { | else if (t->flag & T_MIRROR && td->loc[0] * t->mirror < -0.00001f) { | ||||
| td->flag |= TD_SKIP; | td->flag |= TD_SKIP; | ||||
| td->factor = 0.0f; | td->factor = 0.0f; | ||||
| restoreElement(td); | restoreElement(td); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | for (i = 0; i < tc->data_len; i++, td++) { | ||||
| td->factor = dist * (2.0f - dist); | td->factor = dist * (2.0f - dist); | ||||
| break; | break; | ||||
| default: | default: | ||||
| td->factor = 1; | td->factor = 1; | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } // FIXME(indent) | |||||
| switch (t->prop_mode) { | switch (t->prop_mode) { | ||||
| case PROP_SHARP: | case PROP_SHARP: | ||||
| pet_id = N_("(Sharp)"); | pet_id = N_("(Sharp)"); | ||||
| break; | break; | ||||
| case PROP_SMOOTH: | case PROP_SMOOTH: | ||||
| pet_id = N_("(Smooth)"); | pet_id = N_("(Smooth)"); | ||||
| break; | break; | ||||
| case PROP_ROOT: | case PROP_ROOT: | ||||
| Show All 18 Lines | switch (t->prop_mode) { | ||||
| break; | break; | ||||
| } | } | ||||
| if (pet_id) { | if (pet_id) { | ||||
| BLI_strncpy(t->proptext, IFACE_(pet_id), sizeof(t->proptext)); | BLI_strncpy(t->proptext, IFACE_(pet_id), sizeof(t->proptext)); | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| for (i = 0; i < t->total; i++, td++) { | FOREACH_TRANS_DATA_CONTAINER (t, tc) { | ||||
| TransData *td = tc->data; | |||||
| for (i = 0; i < tc->data_len; i++, td++) { | |||||
| td->factor = 1.0; | td->factor = 1.0; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | |||||
| /** | /** | ||||
| * Rotate an element, low level code, ignore protected channels. | * Rotate an element, low level code, ignore protected channels. | ||||
| * (use for objects or pose-bones) | * (use for objects or pose-bones) | ||||
| * Similar to #ElementRotation. | * Similar to #ElementRotation. | ||||
| */ | */ | ||||
| void transform_data_ext_rotate(TransData *td, float mat[3][3], bool use_drot) | void transform_data_ext_rotate(TransData *td, float mat[3][3], bool use_drot) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 99 Lines • Show Last 20 Lines | |||||