Added "Pack Charts" function in the UV editor, using Campbell's new box
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Thu, 22 Mar 2007 20:32:20 +0000 (20:32 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Thu, 22 Mar 2007 20:32:20 +0000 (20:32 +0000)
packing code.

source/blender/include/BDR_unwrapper.h
source/blender/src/header_image.c
source/blender/src/parametrizer.c
source/blender/src/space.c
source/blender/src/unwrapper.c

index f83c8aa3f8cff67d16071f845c5ed764970c747d..6a2b54409c372cc32870474dac66276bfad00d0e 100644 (file)
@@ -40,6 +40,7 @@ void select_linked_tfaces_with_seams(int mode, struct Mesh *me, unsigned int ind
 
 void unwrap_lscm(short seamcut); /* unwrap faces selected in 3d view */
 void minimize_stretch_tface_uv(void); /* optimize faces selected in uv editor */
+void pack_charts_tface_uv(void);
 
 /* for live mode: no undo pushes, caching for quicky re-unwrap */
 void unwrap_lscm_live_begin(void);
index 2fad10f0e39cf597f74008e72644856c7ad61127..4222fa24c3a7956a7566c6786a6373430032294d 100644 (file)
@@ -998,6 +998,9 @@ static void do_image_uvsmenu(void *arg, int event)
        case 12:
                minimize_stretch_tface_uv();
                break;
+       case 13:
+               pack_charts_tface_uv();
+               break;
        }
 }
 
@@ -1030,13 +1033,14 @@ static uiBlock *image_uvsmenu(void *arg_unused)
 
        uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");        
 
+       uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Pack Charts|Ctrl P", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 13, "");
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Minimize Stretch|Ctrl V", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 12, "");
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Limit Stitch...|Shift V", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 3, "");
        uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Stitch|V", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 4, "");
-       uiDefIconTextBlockBut(block, image_uvs_transformmenu, NULL, ICON_RIGHTARROW_THIN, "Transform", 0, yco-=20, 120, 19, "");
 
        uiDefBut(block, SEPR, 0, "",                            0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
        
+       uiDefIconTextBlockBut(block, image_uvs_transformmenu, NULL, ICON_RIGHTARROW_THIN, "Transform", 0, yco-=20, 120, 19, "");
        uiDefIconTextBlockBut(block, image_uvs_mirrormenu, NULL, ICON_RIGHTARROW_THIN, "Mirror", 0, yco-=20, 120, 19, "");
        uiDefIconTextBlockBut(block, image_uvs_weldalignmenu, NULL, ICON_RIGHTARROW_THIN, "Weld/Align", 0, yco-=20, 120, 19, "");
        
index d47925a97cd2327a47c91bc965e4aead7f3f9169..8c3ac6394f9f08be5db00a327859c47bf976c0f5 100644 (file)
@@ -4136,7 +4136,7 @@ void param_pack(ParamHandle *handle)
        if (tot_height>tot_width)
                scale = 1.0/tot_height;
        else
-               scale = 1.0/tot_height;
+               scale = 1.0/tot_width;
        
        for (i = 0; i < phandle->ncharts-unpacked; i++) {
                box = boxarray+i;
index 8404e9974862040a4935f1deae51f05c4af1dde3..9e3cb9a6520ecd1ce3e85df794431e8f7c32ea8a 100644 (file)
@@ -4745,7 +4745,9 @@ static void winqreadimagespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                break;
                        case PKEY:
                                if(G.f & G_FACESELECT) {
-                                       if(G.qual==LR_SHIFTKEY)
+                                       if(G.qual==LR_CTRLKEY)
+                                               pack_charts_tface_uv();
+                                       else if(G.qual==LR_SHIFTKEY)
                                                select_pinned_tface_uv();
                                        else if(G.qual==LR_ALTKEY)
                                                pin_tface_uv(0);
index b0716b81b91a881bbd81f080b9f0c090c79ac01e..3b6d3eaf91a7b47d4544fe3547319d78bc1fd60b 100644 (file)
@@ -398,6 +398,27 @@ void minimize_stretch_tface_uv(void)
        allqueue(REDRAWIMAGE, 0);
 }
 
+void pack_charts_tface_uv(void)
+{
+       Mesh *me;
+       ParamHandle *handle;
+       
+       me = get_mesh(OBACT);
+       if(me==0 || me->mtface==0) return;
+
+       handle = construct_param_handle(me, 1, 0, 1);
+       param_pack(handle);
+       param_flush(handle);
+       param_delete(handle);
+
+       BIF_undo_push("UV pack charts");
+
+       object_uvs_changed(OBACT);
+
+       allqueue(REDRAWVIEW3D, 0);
+       allqueue(REDRAWIMAGE, 0);
+}
+
 /* LSCM live mode */
 
 static ParamHandle *liveHandle = NULL;