Patch [#32246] (Bugfix): UV editor -> "Proportional edit" together with "constrain...
authorDaniel Genrich <daniel.genrich@gmx.net>
Mon, 6 Aug 2012 13:40:29 +0000 (13:40 +0000)
committerDaniel Genrich <daniel.genrich@gmx.net>
Mon, 6 Aug 2012 13:40:29 +0000 (13:40 +0000)
Patch reviewed by Campbell Barton. Thanks!

source/blender/editors/transform/transform.c
source/blender/editors/transform/transform.h
source/blender/editors/transform/transform_conversions.c

index acda6c3d399ec9b84bbe0a3a7f7210548c0f644b..0b23b65f2509c81b319236fc935cc024c66a9a0d 100644 (file)
@@ -2932,6 +2932,14 @@ int Resize(TransInfo *t, const int mval[2])
                
                for (i = 0, td = t->data; i < t->total; i++, td++)
                        ElementResize(t, td, mat);
+
+               /* In proportional edit it can happen that */
+               /* vertices in the radius of the brush end */
+               /* outside the clipping area               */
+               /* XXX HACK - dg */
+               if(t->flag & (T_PROP_EDIT | T_PROP_CONNECTED)) {
+                       clipUVData(t);
+               }
        }
        
        recalcData(t);
@@ -3787,9 +3795,18 @@ int Translation(TransInfo *t, const int UNUSED(mval[2]))
        applyTranslation(t, t->values);
 
        /* evil hack - redo translation if clipping needed */
-       if (t->flag & T_CLIP_UV && clipUVTransform(t, t->values, 0))
+       if (t->flag & T_CLIP_UV && clipUVTransform(t, t->values, 0)) {
                applyTranslation(t, t->values);
 
+               /* In proportional edit it can happen that */
+               /* vertices in the radius of the brush end */
+               /* outside the clipping area               */
+               /* XXX HACK - dg */
+               if(t->flag & (T_PROP_EDIT | T_PROP_CONNECTED)) {
+                       clipUVData(t);
+               }
+       }
+
        recalcData(t);
 
        ED_area_headerprint(t->sa, str);
index 1585fb1ad6b07f8926ba62c84959b5fc1b9a375e..8a7148aad9553ff641069a94d49d16b9c7b29844 100644 (file)
@@ -562,6 +562,7 @@ void remake_graph_transdata(TransInfo *t, struct ListBase *anim_data);
 void flushTransUVs(TransInfo *t);
 void flushTransParticles(TransInfo *t);
 int clipUVTransform(TransInfo *t, float *vec, int resize);
+void clipUVData(TransInfo *t);
 void flushTransNodes(TransInfo *t);
 void flushTransSeq(TransInfo *t);
 void flushTransTracking(TransInfo *t);
index 0fdd873624853b811575cb71e675a47a093ad2a4..f5d9612e8327e67dd2b03196b74bf0cb3bd47488 100644 (file)
@@ -2494,6 +2494,26 @@ int clipUVTransform(TransInfo *t, float *vec, int resize)
        return (clipx || clipy);
 }
 
+void clipUVData(TransInfo *t)
+{
+       TransData *td = NULL;
+       int a;
+       float aspx, aspy;
+
+       ED_space_image_get_uv_aspect(t->sa->spacedata.first, &aspx, &aspy);
+
+       for (a = 0, td = t->data; a < t->total; a++, td++) {
+               if (td->flag & TD_NOACTION)
+                       break;
+
+               if ((td->flag & TD_SKIP) || (!td->loc))
+                       continue;
+
+               td->loc[0] = MIN2(MAX2(0.0f, td->loc[0]), aspx);
+               td->loc[1] = MIN2(MAX2(0.0f, td->loc[1]), aspy);
+       }
+}
+
 /* ********************* ANIMATION EDITORS (GENERAL) ************************* */
 
 /* This function tests if a point is on the "mouse" side of the cursor/frame-marking */