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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-06-20 17:24:07 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-06-20 17:24:07 +0400
commit70212510438fdb1494892b8f75b59cd018b47d5b (patch)
tree03bcd1a63db2a66001c619c3eb293f3c57ef69b1 /source
parent8d6e5e2feeecdcff4d4b0d3651043ca561af2cb4 (diff)
transform: 2d option for proportional editmode,
Uses for view orientation for distance calculation, can give nicer results when you dont want twisting caused by changes in depth.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/transform/transform.c21
-rw-r--r--source/blender/editors/transform/transform.h2
-rw-r--r--source/blender/editors/transform/transform_conversions.c24
-rw-r--r--source/blender/editors/transform/transform_generics.c30
-rw-r--r--source/blender/makesdna/DNA_scene_types.h3
-rw-r--r--source/blender/makesrna/intern/rna_scene.c2
6 files changed, 56 insertions, 26 deletions
diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c
index 7a8d4c6750e..ca31a4a98de 100644
--- a/source/blender/editors/transform/transform.c
+++ b/source/blender/editors/transform/transform.c
@@ -1736,12 +1736,15 @@ void saveTransform(bContext *C, TransInfo *t, wmOperator *op)
}
/* convert flag to enum */
- switch (t->flag & (T_PROP_EDIT | T_PROP_CONNECTED)) {
+ switch (t->flag & T_PROP_EDIT_ALL) {
+ case T_PROP_EDIT:
+ proportional = PROP_EDIT_ON;
+ break;
case (T_PROP_EDIT | T_PROP_CONNECTED):
proportional = PROP_EDIT_CONNECTED;
break;
- case T_PROP_EDIT:
- proportional = PROP_EDIT_ON;
+ case (T_PROP_EDIT | T_PROP_PROJECTED):
+ proportional = PROP_EDIT_PROJECTED;
break;
default:
proportional = PROP_EDIT_OFF;
@@ -2945,7 +2948,7 @@ static void headerResize(TransInfo *t, float vec[3], char *str)
}
}
- if (t->flag & (T_PROP_EDIT | T_PROP_CONNECTED)) {
+ if (t->flag & T_PROP_EDIT_ALL) {
ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_(" Proportional size: %.2f"), t->prop_size);
}
}
@@ -3143,7 +3146,7 @@ int Resize(TransInfo *t, const int mval[2])
/* vertices in the radius of the brush end */
/* outside the clipping area */
/* XXX HACK - dg */
- if (t->flag & (T_PROP_EDIT | T_PROP_CONNECTED)) {
+ if (t->flag & T_PROP_EDIT_ALL) {
clipUVData(t);
}
}
@@ -3663,7 +3666,7 @@ int Rotation(TransInfo *t, const int UNUSED(mval[2]))
RAD2DEGF(final), t->con.text, t->proptext);
}
- if (t->flag & (T_PROP_EDIT | T_PROP_CONNECTED)) {
+ if (t->flag & T_PROP_EDIT_ALL) {
ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_(" Proportional size: %.2f"), t->prop_size);
}
@@ -3764,7 +3767,7 @@ int Trackball(TransInfo *t, const int UNUSED(mval[2]))
RAD2DEGF(phi[0]), RAD2DEGF(phi[1]), t->proptext);
}
- if (t->flag & (T_PROP_EDIT | T_PROP_CONNECTED)) {
+ if (t->flag & T_PROP_EDIT_ALL) {
ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_(" Proportional size: %.2f"), t->prop_size);
}
@@ -3912,7 +3915,7 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str)
}
}
- if (t->flag & (T_PROP_EDIT | T_PROP_CONNECTED)) {
+ if (t->flag & T_PROP_EDIT_ALL) {
ofs += BLI_snprintf(str + ofs, MAX_INFO_LEN - ofs, IFACE_(" Proportional size: %.2f"), t->prop_size);
}
}
@@ -4019,7 +4022,7 @@ int Translation(TransInfo *t, const int UNUSED(mval[2]))
/* vertices in the radius of the brush end */
/* outside the clipping area */
/* XXX HACK - dg */
- if (t->flag & (T_PROP_EDIT | T_PROP_CONNECTED)) {
+ if (t->flag & T_PROP_EDIT_ALL) {
clipUVData(t);
}
}
diff --git a/source/blender/editors/transform/transform.h b/source/blender/editors/transform/transform.h
index 2cef3209b4e..53ecfe3a685 100644
--- a/source/blender/editors/transform/transform.h
+++ b/source/blender/editors/transform/transform.h
@@ -394,6 +394,8 @@ typedef struct TransInfo {
#define T_PROP_EDIT (1 << 11)
#define T_PROP_CONNECTED (1 << 12)
+#define T_PROP_PROJECTED (1 << 25)
+#define T_PROP_EDIT_ALL (T_PROP_EDIT | T_PROP_CONNECTED | T_PROP_PROJECTED)
#define T_V3D_ALIGN (1 << 14)
/* for 2d views like uv or ipo */
diff --git a/source/blender/editors/transform/transform_conversions.c b/source/blender/editors/transform/transform_conversions.c
index d1b57e2e402..2a982517d3e 100644
--- a/source/blender/editors/transform/transform_conversions.c
+++ b/source/blender/editors/transform/transform_conversions.c
@@ -201,6 +201,17 @@ static void set_prop_dist(TransInfo *t, const bool with_dist)
TransData *tob;
int a;
+ float _proj_vec[3];
+ const float *proj_vec = NULL;
+
+ if (t->flag & T_PROP_PROJECTED) {
+ if (t->spacetype == SPACE_VIEW3D && t->ar && t->ar->regiontype == RGN_TYPE_WINDOW) {
+ RegionView3D *rv3d = t->ar->regiondata;
+ normalize_v3_v3(_proj_vec, rv3d->viewinv[2]);
+ proj_vec = _proj_vec;
+ }
+ }
+
for (a = 0, tob = t->data; a < t->total; a++, tob++) {
tob->rdist = 0.0f; // init, it was mallocced
@@ -216,6 +227,13 @@ static void set_prop_dist(TransInfo *t, const bool with_dist)
if (td->flag & TD_SELECTED) {
sub_v3_v3v3(vec, tob->center, td->center);
mul_m3_v3(tob->mtx, vec);
+
+ if (proj_vec) {
+ float vec_p[3];
+ project_v3_v3v3(vec_p, vec, proj_vec);
+ sub_v3_v3(vec, vec_p);
+ }
+
dist = len_squared_v3(vec);
if ((tob->rdist == -1.0f) || (dist < (tob->rdist * tob->rdist))) {
tob->rdist = sqrtf(dist);
@@ -989,7 +1007,7 @@ static void createTransPose(TransInfo *t, Object *ob)
t->poseobj = ob; /* we also allow non-active objects to be transformed, in weightpaint */
/* disable PET, its not usable in pose mode yet [#32444] */
- t->flag &= ~(T_PROP_EDIT | T_PROP_CONNECTED);
+ t->flag &= ~T_PROP_EDIT_ALL;
/* init trans data */
td = t->data = MEM_callocN(t->total * sizeof(TransData), "TransPoseBone");
@@ -2013,7 +2031,7 @@ static void createTransEditVerts(TransInfo *t)
float mtx[3][3], smtx[3][3], (*defmats)[3][3] = NULL, (*defcos)[3] = NULL;
float *dists = NULL;
int count = 0, countsel = 0, a, totleft;
- int propmode = (t->flag & T_PROP_EDIT) ? (t->flag & (T_PROP_EDIT | T_PROP_CONNECTED)) : 0;
+ int propmode = (t->flag & T_PROP_EDIT) ? (t->flag & T_PROP_EDIT_ALL) : 0;
int mirror = 0;
char *selstate = NULL;
short selectmode = ts->selectmode;
@@ -5827,7 +5845,7 @@ static void createTransNodeData(bContext *UNUSED(C), TransInfo *t)
}
/* nodes dont support PET and probably never will */
- t->flag &= ~(T_PROP_EDIT | T_PROP_CONNECTED);
+ t->flag &= ~T_PROP_EDIT_ALL;
/* set transform flags on nodes */
for (node = snode->edittree->nodes.first; node; node = node->next) {
diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c
index 369b5a82a84..3e4316b1277 100644
--- a/source/blender/editors/transform/transform_generics.c
+++ b/source/blender/editors/transform/transform_generics.c
@@ -1023,6 +1023,20 @@ void resetTransRestrictions(TransInfo *t)
t->flag &= ~T_ALL_RESTRICTIONS;
}
+static int initTransInfo_edit_pet_to_flag(const int proportional)
+{
+ switch (proportional) {
+ case PROP_EDIT_ON:
+ return T_PROP_EDIT;
+ case PROP_EDIT_CONNECTED:
+ return T_PROP_EDIT | T_PROP_CONNECTED;
+ case PROP_EDIT_PROJECTED:
+ return T_PROP_EDIT | T_PROP_PROJECTED;
+ default:
+ return 0;
+ }
+}
+
/* the *op can be NULL */
int initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *event)
{
@@ -1245,24 +1259,14 @@ int initTransInfo(bContext *C, TransInfo *t, wmOperator *op, const wmEvent *even
/* 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 (RNA_property_is_set(op->ptr, prop)) {
- switch (RNA_property_enum_get(op->ptr, prop)) {
- case PROP_EDIT_CONNECTED:
- t->flag |= T_PROP_CONNECTED;
- case PROP_EDIT_ON:
- t->flag |= T_PROP_EDIT;
- break;
- }
+ t->flag |= initTransInfo_edit_pet_to_flag(RNA_property_enum_get(op->ptr, prop));
}
else {
/* use settings from scene only if modal */
if (t->flag & T_MODAL) {
if ((t->options & CTX_NO_PET) == 0) {
- if (t->obedit && ts->proportional != PROP_EDIT_OFF) {
- t->flag |= T_PROP_EDIT;
-
- if (ts->proportional == PROP_EDIT_CONNECTED) {
- t->flag |= T_PROP_CONNECTED;
- }
+ if (t->obedit) {
+ t->flag |= initTransInfo_edit_pet_to_flag(ts->proportional);
}
else if (t->options & CTX_MASK) {
if (ts->proportional_mask) {
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index bc911f9addc..e08ecf6dff8 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1501,7 +1501,8 @@ typedef struct Scene {
/* toolsettings->proportional */
#define PROP_EDIT_OFF 0
#define PROP_EDIT_ON 1
-#define PROP_EDIT_CONNECTED 2
+#define PROP_EDIT_CONNECTED 2
+#define PROP_EDIT_PROJECTED 3
/* toolsettings->weightuser */
enum {
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 44eee642081..0c3f4aa073b 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -120,6 +120,8 @@ EnumPropertyItem proportional_falloff_curve_only_items[] = {
EnumPropertyItem proportional_editing_items[] = {
{PROP_EDIT_OFF, "DISABLED", ICON_PROP_OFF, "Disable", "Proportional Editing disabled"},
{PROP_EDIT_ON, "ENABLED", ICON_PROP_ON, "Enable", "Proportional Editing enabled"},
+ {PROP_EDIT_PROJECTED, "PROJECTED", ICON_PROP_ON, "Projected (2D)",
+ "Proportional Editing using screen space locations"},
{PROP_EDIT_CONNECTED, "CONNECTED", ICON_PROP_CON, "Connected",
"Proportional Editing using connected geometry only"},
{0, NULL, 0, NULL, NULL}