Optional margin for packing UV islands and the 'Pack Islands' menu item. Useful for...
authorCampbell Barton <ideasman42@gmail.com>
Wed, 15 Apr 2009 18:20:19 +0000 (18:20 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 15 Apr 2009 18:20:19 +0000 (18:20 +0000)
source/blender/makesdna/DNA_scene_types.h
source/blender/src/buttons_editing.c
source/blender/src/parametrizer.c
source/blender/src/parametrizer.h
source/blender/src/unwrapper.c

index bf5b2ad3df54e048c1710c975f673727d665be4f..d26bdd469f6164a644e59aba231428d2602a00b5 100644 (file)
@@ -412,6 +412,8 @@ typedef struct ToolSettings {
        short unwrapper;
        float uvcalc_radius;
        float uvcalc_cubesize;
+       float uvcalc_margin;
+       float pad;
        short uvcalc_mapdir;
        short uvcalc_mapalign;
        short uvcalc_flag;
index 2ec30bfa864e93418bba85d358916ff694747765..779909ec713f1b5b2a23bfb43a4bf85dc9649966 100644 (file)
@@ -6622,7 +6622,10 @@ static void editing_panel_mesh_uvautocalculation(void)
        uiDefButBitS(block, TOGN, UVCALC_NO_ASPECT_CORRECT, B_NOP, "Image Aspect",100,row,200,butH,&G.scene->toolsettings->uvcalc_flag, 0, 0, 0, 0,  "Scale the UV Unwrapping to correct for the current images aspect ratio");
 
        row-= butHB+butS;       
-               uiDefButBitS(block, TOG, UVCALC_TRANSFORM_CORRECT, B_NOP, "Transform Correction",100,row,200,butH,&G.scene->toolsettings->uvcalc_flag, 0, 0, 0, 0,  "Correct for UV distortion while transforming, (only works with edge slide now)");
+       uiDefButBitS(block, TOG, UVCALC_TRANSFORM_CORRECT, B_NOP, "Transform Correction",100,row,200,butH,&G.scene->toolsettings->uvcalc_flag, 0, 0, 0, 0,  "Correct for UV distortion while transforming, (only works with edge slide now)");
+       
+       row-= butHB+butS;       
+       uiDefButF(block, NUM,B_NOP ,"Pack Margin:",100,row,200,butH, &G.scene->toolsettings->uvcalc_margin, 0.0, 1.0, 10, 2, "Add a margin between UV islands when unwrapping or with 'Pack Islands' in the UV window");
 
        row= 180;
        
index 1cf796d86bcc6b3f8c11f6eb36cb330a3ae69d31..654113f5f0c89d2082f071c79dfa4d1ef3f97d56 100644 (file)
@@ -4125,8 +4125,8 @@ void param_smooth_area(ParamHandle *handle)
        }
 }
  
-void param_pack(ParamHandle *handle)
-{
+void param_pack(ParamHandle *handle, float margin)
+{      
        /* box packing variables */
        boxPack *boxarray, *box;
        float tot_width, tot_height, scale;
@@ -4158,13 +4158,13 @@ void param_pack(ParamHandle *handle)
                
                p_chart_uv_bbox(chart, trans, chart->u.pack.size);
                
-               trans[0] = -trans[0];
-               trans[1] = -trans[1];
+               trans[0] = -(trans[0] - margin);
+               trans[1] = -(trans[1] - margin);
                
                p_chart_uv_translate(chart, trans);
                
-               box->w =  chart->u.pack.size[0] + trans[0];
-               box->h =  chart->u.pack.size[1] + trans[1];
+               box->w =  (chart->u.pack.size[0] + trans[0]) + margin*2;
+               box->h =  (chart->u.pack.size[1] + trans[1]) + margin*2;
                box->index = i; /* warning this index skips PCHART_NOPACK boxes */
        }
        
index c468b8d62c557511db5c53e1bcb6416959be562a..f1454ee3865ce2043b298cefe03bdbed42c90936 100644 (file)
@@ -73,7 +73,7 @@ void param_smooth_area(ParamHandle *handle);
 
 /* Packing */
 
-void param_pack(ParamHandle *handle);
+void param_pack(ParamHandle *handle, float margin);
 
 /* Average area for all charts */
 
index 612e068c6cade9f80c78fd6bbd26b56e7e642ddf..fadc087df656be245feff9b68ebd171d0df7f676 100644 (file)
@@ -327,7 +327,7 @@ void unwrap_lscm(short seamcut)
        param_lscm_solve(handle);
        param_lscm_end(handle);
        
-       param_pack(handle);
+       param_pack(handle, G.scene->toolsettings->uvcalc_margin);
 
        param_flush(handle);
 
@@ -442,7 +442,7 @@ void pack_charts_tface_uv(void)
        if(!EM_texFaceCheck()) return;
 
        handle = construct_param_handle(em, 1, 0, 1);
-       param_pack(handle);
+       param_pack(handle, G.scene->toolsettings->uvcalc_margin);
        param_flush(handle);
        param_delete(handle);