Added "Pack Charts" function in the UV editor, using Campbell's new box

packing code.
This commit is contained in:
2007-03-22 20:32:20 +00:00
parent 8aafed560a
commit 5219812f55
5 changed files with 31 additions and 3 deletions

View 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);

View 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, "");

View 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;

View 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);

View 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;