Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/transform/transform_convert.c')
-rw-r--r--source/blender/editors/transform/transform_convert.c194
1 files changed, 84 insertions, 110 deletions
diff --git a/source/blender/editors/transform/transform_convert.c b/source/blender/editors/transform/transform_convert.c
index 8496642185d..70004d27dfc 100644
--- a/source/blender/editors/transform/transform_convert.c
+++ b/source/blender/editors/transform/transform_convert.c
@@ -27,6 +27,7 @@
#include "MEM_guardedalloc.h"
#include "BLI_kdtree.h"
+#include "BLI_linklist_stack.h"
#include "BLI_listbase.h"
#include "BLI_math.h"
@@ -55,7 +56,6 @@
#include "DEG_depsgraph_build.h"
#include "transform.h"
-#include "transform_mode.h"
#include "transform_snap.h"
/* Own include. */
@@ -70,41 +70,21 @@ bool transform_mode_use_local_origins(const TransInfo *t)
* Transforming around ourselves is no use, fallback to individual origins,
* useful for curve/armatures.
*/
-void transform_around_single_fallback(TransInfo *t)
+void transform_around_single_fallback_ex(TransInfo *t, int data_len_all)
{
if ((ELEM(t->around, V3D_AROUND_CENTER_BOUNDS, V3D_AROUND_CENTER_MEDIAN, V3D_AROUND_ACTIVE)) &&
transform_mode_use_local_origins(t)) {
-
- bool is_data_single = false;
- if (t->data_len_all == 1) {
- is_data_single = true;
- }
- else if (t->data_len_all == 3) {
- if (t->obedit_type == OB_CURVE) {
- /* Special case check for curve, if we have a single curve bezier triple selected
- * treat */
- FOREACH_TRANS_DATA_CONTAINER (t, tc) {
- if (!tc->data_len) {
- continue;
- }
- if (tc->data_len == 3) {
- const TransData *td = tc->data;
- if ((td[0].flag | td[1].flag | td[2].flag) & TD_BEZTRIPLE) {
- if ((td[0].loc == td[1].loc) && (td[1].loc == td[2].loc)) {
- is_data_single = true;
- }
- }
- }
- break;
- }
- }
- }
- if (is_data_single) {
+ if (data_len_all == 1) {
t->around = V3D_AROUND_LOCAL_ORIGINS;
}
}
}
+void transform_around_single_fallback(TransInfo *t)
+{
+ transform_around_single_fallback_ex(t, t->data_len_all);
+}
+
/* -------------------------------------------------------------------- */
/** \name Proportional Editing
* \{ */
@@ -117,12 +97,10 @@ static int trans_data_compare_dist(const void *a, const void *b)
if (td_a->dist < td_b->dist) {
return -1;
}
- else if (td_a->dist > td_b->dist) {
+ if (td_a->dist > td_b->dist) {
return 1;
}
- else {
- return 0;
- }
+ return 0;
}
static int trans_data_compare_rdist(const void *a, const void *b)
@@ -133,12 +111,10 @@ static int trans_data_compare_rdist(const void *a, const void *b)
if (td_a->rdist < td_b->rdist) {
return -1;
}
- else if (td_a->rdist > td_b->rdist) {
+ if (td_a->rdist > td_b->rdist) {
return 1;
}
- else {
- return 0;
- }
+ return 0;
}
static void sort_trans_data_dist_container(const TransInfo *t, TransDataContainer *tc)
@@ -434,59 +410,66 @@ void transform_autoik_update(TransInfo *t, short mode)
/** \name Curve Surface
* \{ */
-void calc_distanceCurveVerts(TransData *head, TransData *tail)
+void calc_distanceCurveVerts(TransData *head, TransData *tail, bool cyclic)
{
- TransData *td, *td_near = NULL;
+ TransData *td;
+ BLI_LINKSTACK_DECLARE(queue, TransData *);
+ BLI_LINKSTACK_INIT(queue);
for (td = head; td <= tail; td++) {
if (td->flag & TD_SELECTED) {
- td_near = td;
td->dist = 0.0f;
+ BLI_LINKSTACK_PUSH(queue, td);
+ }
+ else {
+ td->dist = FLT_MAX;
+ }
+ }
+
+ while ((td = BLI_LINKSTACK_POP(queue))) {
+ float dist;
+ float vec[3];
+
+ TransData *next_td = NULL;
+
+ if (td + 1 <= tail) {
+ next_td = td + 1;
+ }
+ else if (cyclic) {
+ next_td = head;
}
- else if (td_near) {
- float dist;
- float vec[3];
- sub_v3_v3v3(vec, td_near->center, td->center);
+ if (next_td != NULL && !(next_td->flag & TD_NOTCONNECTED)) {
+ sub_v3_v3v3(vec, next_td->center, td->center);
mul_m3_v3(head->mtx, vec);
- dist = len_v3(vec);
+ dist = len_v3(vec) + td->dist;
- if (dist < (td - 1)->dist) {
- td->dist = (td - 1)->dist;
- }
- else {
- td->dist = dist;
+ if (dist < next_td->dist) {
+ next_td->dist = dist;
+ BLI_LINKSTACK_PUSH(queue, next_td);
}
}
- else {
- td->dist = FLT_MAX;
- td->flag |= TD_NOTCONNECTED;
+
+ next_td = NULL;
+
+ if (td - 1 >= head) {
+ next_td = td - 1;
}
- }
- td_near = NULL;
- for (td = tail; td >= head; td--) {
- if (td->flag & TD_SELECTED) {
- td_near = td;
- td->dist = 0.0f;
+ else if (cyclic) {
+ next_td = tail;
}
- else if (td_near) {
- float dist;
- float vec[3];
- sub_v3_v3v3(vec, td_near->center, td->center);
+ if (next_td != NULL && !(next_td->flag & TD_NOTCONNECTED)) {
+ sub_v3_v3v3(vec, next_td->center, td->center);
mul_m3_v3(head->mtx, vec);
- dist = len_v3(vec);
+ dist = len_v3(vec) + td->dist;
- if (td->flag & TD_NOTCONNECTED || dist < td->dist || (td + 1)->dist < td->dist) {
- td->flag &= ~TD_NOTCONNECTED;
- if (dist < (td + 1)->dist) {
- td->dist = (td + 1)->dist;
- }
- else {
- td->dist = dist;
- }
+ if (dist < next_td->dist) {
+ next_td->dist = dist;
+ BLI_LINKSTACK_PUSH(queue, next_td);
}
}
}
+ BLI_LINKSTACK_FREE(queue);
}
/* Utility function for getting the handle data from bezier's */
@@ -631,9 +614,7 @@ bool FrameOnMouseSide(char side, float frame, float cframe)
if (side == 'R') {
return (frame >= cframe);
}
- else {
- return (frame <= cframe);
- }
+ return (frame <= cframe);
}
/** \} */
@@ -691,7 +672,7 @@ void posttrans_fcurve_clean(FCurve *fcu, const int sel_flag, const bool use_hand
found = true;
break;
}
- else if (rk->frame < bezt->vec[1][0]) {
+ if (rk->frame < bezt->vec[1][0]) {
/* Terminate early if have passed the supposed insertion point? */
break;
}
@@ -717,11 +698,10 @@ void posttrans_fcurve_clean(FCurve *fcu, const int sel_flag, const bool use_hand
}
return;
}
- else {
- /* Compute the average values for each retained keyframe */
- LISTBASE_FOREACH (tRetainedKeyframe *, rk, &retained_keys) {
- rk->val = rk->val / (float)rk->tot_count;
- }
+
+ /* Compute the average values for each retained keyframe */
+ LISTBASE_FOREACH (tRetainedKeyframe *, rk, &retained_keys) {
+ rk->val = rk->val / (float)rk->tot_count;
}
/* 2) Delete all keyframes duplicating the "retained keys" found above
@@ -795,7 +775,7 @@ bool constraints_list_needinv(TransInfo *t, ListBase *list)
bConstraint *con;
/* loop through constraints, checking if there's one of the mentioned
- * constraints needing special crazyspace corrections
+ * constraints needing special crazy-space corrections
*/
if (list) {
for (con = list->first; con; con = con->next) {
@@ -946,13 +926,13 @@ int special_transform_moving(TransInfo *t)
if (t->spacetype == SPACE_SEQ) {
return G_TRANSFORM_SEQ;
}
- else if (t->spacetype == SPACE_GRAPH) {
+ if (t->spacetype == SPACE_GRAPH) {
return G_TRANSFORM_FCURVES;
}
- else if ((t->flag & T_EDIT) || (t->flag & T_POSE)) {
+ if ((t->flag & T_EDIT) || (t->flag & T_POSE)) {
return G_TRANSFORM_EDIT;
}
- else if (t->flag & (T_OBJECT | T_TEXTURE)) {
+ if (t->flag & (T_OBJECT | T_TEXTURE)) {
return G_TRANSFORM_OBJ;
}
@@ -1169,21 +1149,6 @@ void createTransData(bContext *C, TransInfo *t)
}
t->flag |= T_OBJECT;
-
- /* Check if we're transforming the camera from the camera */
- if ((t->spacetype == SPACE_VIEW3D) && (t->region->regiontype == RGN_TYPE_WINDOW)) {
- View3D *v3d = t->view;
- RegionView3D *rv3d = t->region->regiondata;
- if ((rv3d->persp == RV3D_CAMOB) && v3d->camera) {
- /* we could have a flag to easily check an object is being transformed */
- if (v3d->camera->id.tag & LIB_TAG_DOIT) {
- t->flag |= T_CAMERA;
- }
- }
- else if (v3d->ob_center && v3d->ob_center->id.tag & LIB_TAG_DOIT) {
- t->flag |= T_CAMERA;
- }
- }
convert_type = TC_OBJECT;
}
@@ -1196,6 +1161,7 @@ void createTransData(bContext *C, TransInfo *t)
break;
case TC_POSE:
createTransPose(t);
+ /* Disable PET, its not usable in pose mode yet [#32444] */
init_prop_edit = false;
break;
case TC_ARMATURE_VERTS:
@@ -1245,6 +1211,20 @@ void createTransData(bContext *C, TransInfo *t)
break;
case TC_OBJECT:
createTransObject(C, t);
+ /* Check if we're transforming the camera from the camera */
+ if ((t->spacetype == SPACE_VIEW3D) && (t->region->regiontype == RGN_TYPE_WINDOW)) {
+ View3D *v3d = t->view;
+ RegionView3D *rv3d = t->region->regiondata;
+ if ((rv3d->persp == RV3D_CAMOB) && v3d->camera) {
+ /* we could have a flag to easily check an object is being transformed */
+ if (v3d->camera->id.tag & LIB_TAG_DOIT) {
+ t->flag |= T_CAMERA;
+ }
+ }
+ else if (v3d->ob_center && v3d->ob_center->id.tag & LIB_TAG_DOIT) {
+ t->flag |= T_CAMERA;
+ }
+ }
break;
case TC_OBJECT_TEXSPACE:
createTransTexspace(t);
@@ -1298,6 +1278,9 @@ void createTransData(bContext *C, TransInfo *t)
set_prop_dist(t, false);
}
}
+ else if (convert_type == TC_MESH_UV && t->flag & T_PROP_CONNECTED) {
+ /* Already calculated by uv_set_connectivity_distance. */
+ }
else if (convert_type == TC_CURVE_VERTS && t->obedit_type == OB_CURVE) {
set_prop_dist(t, false);
}
@@ -1313,18 +1296,9 @@ void createTransData(bContext *C, TransInfo *t)
* and are still added into transform data. */
sort_trans_data_selected_first(t);
}
- }
-
- /* exception... hackish, we want bonesize to use bone orientation matrix (ton) */
- if (t->mode == TFM_BONESIZE) {
- t->flag &= ~(T_EDIT | T_POINTS);
- t->flag |= T_POSE;
- t->obedit_type = -1;
- t->data_type = TC_NONE;
- FOREACH_TRANS_DATA_CONTAINER (t, tc) {
- tc->poseobj = tc->obedit;
- tc->obedit = NULL;
+ if (!init_prop_edit) {
+ t->flag &= ~T_PROP_EDIT_ALL;
}
}