Added a new Python slot "UvCalculate", moved Archimap and "UVs from adjacent" into it.

Removed 1/2 1/4 1/8 uv mapping options.
made re-evaluating the py-scripts dir use the wait cursor (could take a while at times)
This commit is contained in:
Campbell Barton 2006-12-12 04:18:45 +00:00
parent 9a169f2633
commit 97b6a65c74
7 changed files with 64 additions and 75 deletions

@ -3,7 +3,7 @@
""" Registration info for Blender menus: <- these words are ignored """ Registration info for Blender menus: <- these words are ignored
Name: 'ArchiMap UV Projection Unwrapper' Name: 'ArchiMap UV Projection Unwrapper'
Blender: 240 Blender: 240
Group: 'UV' Group: 'UvCalculation'
Tooltip: 'ArchiMap UV Unwrap mesh faces for all select mesh objects' Tooltip: 'ArchiMap UV Unwrap mesh faces for all select mesh objects'
""" """

@ -2,7 +2,7 @@
""" """
Name: 'UVs from adjacent' Name: 'UVs from adjacent'
Blender: 241 Blender: 241
Group: 'UV' Group: 'UvCalculation'
Tooltip: 'Assign UVs to selected faces from surrounding unselected faces.' Tooltip: 'Assign UVs to selected faces from surrounding unselected faces.'
""" """
__author__ = "Campbell Barton" __author__ = "Campbell Barton"

@ -653,14 +653,8 @@ enum {
B_UVAUTO_WINDOW, B_UVAUTO_WINDOW,
B_UVAUTO_CUBE, B_UVAUTO_CUBE,
B_UVAUTO_CUBESIZE, B_UVAUTO_CUBESIZE,
B_UVAUTO_STD1, B_UVAUTO_RESET,
B_UVAUTO_STD2, B_UVAUTO_BOUNDS,
B_UVAUTO_STD4,
B_UVAUTO_STD8,
B_UVAUTO_BOUNDS1,
B_UVAUTO_BOUNDS2,
B_UVAUTO_BOUNDS4,
B_UVAUTO_BOUNDS8,
B_UVAUTO_TOP, B_UVAUTO_TOP,
B_UVAUTO_FACE, B_UVAUTO_FACE,
B_UVAUTO_OBJECT, B_UVAUTO_OBJECT,

@ -103,6 +103,8 @@ static int bpymenu_group_atoi( char *str )
return PYMENU_WEIGHTPAINT; return PYMENU_WEIGHTPAINT;
else if( !strcmp( str, "VertexPaint" ) ) else if( !strcmp( str, "VertexPaint" ) )
return PYMENU_VERTEXPAINT; return PYMENU_VERTEXPAINT;
else if( !strcmp( str, "UvCalculation" ) )
return PYMENU_UVCALCULATION;
/* "Misc" or an inexistent group name: use misc */ /* "Misc" or an inexistent group name: use misc */
else else
return PYMENU_MISC; return PYMENU_MISC;
@ -168,6 +170,9 @@ char *BPyMenu_group_itoa( short menugroup )
case PYMENU_VERTEXPAINT: case PYMENU_VERTEXPAINT:
return "VertexPaint"; return "VertexPaint";
break; break;
case PYMENU_UVCALCULATION:
return "UvCalculation";
break;
case PYMENU_MISC: case PYMENU_MISC:
return "Misc"; return "Misc";
break; break;

@ -99,6 +99,7 @@ typedef enum {
PYMENU_FACESELECT, PYMENU_FACESELECT,
PYMENU_WEIGHTPAINT, PYMENU_WEIGHTPAINT,
PYMENU_VERTEXPAINT, PYMENU_VERTEXPAINT,
PYMENU_UVCALCULATION,
PYMENU_HELP,/*Main Help menu items - prob best to leave for 'official' ones*/ PYMENU_HELP,/*Main Help menu items - prob best to leave for 'official' ones*/
PYMENU_HELPSYSTEM,/* Resources, troubleshooting, system tools */ PYMENU_HELPSYSTEM,/* Resources, troubleshooting, system tools */
PYMENU_HELPWEBSITES,/* Help -> Websites submenu */ PYMENU_HELPWEBSITES,/* Help -> Websites submenu */

@ -94,20 +94,17 @@
#include "BDR_unwrapper.h" #include "BDR_unwrapper.h"
#include "BPY_extern.h"
#include "BPY_menus.h"
/* Pupmenu codes: */ /* Pupmenu codes: */
#define UV_CUBE_MAPPING 2 #define UV_CUBE_MAPPING 2
#define UV_CYL_MAPPING 3 #define UV_CYL_MAPPING 3
#define UV_SPHERE_MAPPING 4 #define UV_SPHERE_MAPPING 4
#define UV_BOUNDS8_MAPPING 68 #define UV_BOUNDS_MAPPING 5
#define UV_BOUNDS4_MAPPING 65 #define UV_RESET_MAPPING 6
#define UV_BOUNDS2_MAPPING 66 #define UV_WINDOW_MAPPING 7
#define UV_BOUNDS1_MAPPING 67 #define UV_UNWRAP_MAPPING 8
#define UV_STD8_MAPPING 131
#define UV_STD4_MAPPING 130
#define UV_STD2_MAPPING 129
#define UV_STD1_MAPPING 128
#define UV_WINDOW_MAPPING 5
#define UV_UNWRAP_MAPPING 6
#define UV_CYL_EX 32 #define UV_CYL_EX 32
#define UV_SPHERE_EX 34 #define UV_SPHERE_EX 34
@ -363,16 +360,7 @@ void calculate_uv_map(unsigned short mapmode)
if(me->totface==0) return; if(me->totface==0) return;
switch(mapmode) { switch(mapmode) {
case B_UVAUTO_BOUNDS1: case B_UVAUTO_BOUNDS:
case B_UVAUTO_BOUNDS2:
case B_UVAUTO_BOUNDS4:
case B_UVAUTO_BOUNDS8:
switch(mapmode) {
case B_UVAUTO_BOUNDS2: fac = 0.5; break;
case B_UVAUTO_BOUNDS4: fac = 0.25; break;
case B_UVAUTO_BOUNDS8: fac = 0.125; break;
}
min[0]= min[1]= 10000000.0; min[0]= min[1]= 10000000.0;
max[0]= max[1]= -10000000.0; max[0]= max[1]= -10000000.0;
@ -402,7 +390,7 @@ void calculate_uv_map(unsigned short mapmode)
if(mface->v4) b= 3; else b= 2; if(mface->v4) b= 3; else b= 2;
for(; b>=0; b--) { for(; b>=0; b--) {
tface->uv[b][0]= ((tface->uv[b][0]-min[0])*fac)/dx; tface->uv[b][0]= ((tface->uv[b][0]-min[0])*fac)/dx;
tface->uv[b][1]= 1.0-fac+((tface->uv[b][1]-min[1])*fac)/dy; tface->uv[b][1]= 1.0-fac+((tface->uv[b][1]-min[1])/* *fac */)/dy;
} }
} }
} }
@ -425,20 +413,11 @@ void calculate_uv_map(unsigned short mapmode)
} }
break; break;
case B_UVAUTO_STD8: case B_UVAUTO_RESET:
case B_UVAUTO_STD4:
case B_UVAUTO_STD2:
case B_UVAUTO_STD1:
switch(mapmode) {
case B_UVAUTO_STD8: fac = 0.125; break;
case B_UVAUTO_STD4: fac = 0.25; break;
case B_UVAUTO_STD2: fac = 0.5; break;
}
tface= me->mtface; tface= me->mtface;
for(a=0; a<me->totface; a++, tface++) for(a=0; a<me->totface; a++, tface++)
if(tface->flag & TF_SELECT) if(tface->flag & TF_SELECT)
default_uv(tface->uv, fac); default_uv(tface->uv, 1.0);
break; break;
case B_UVAUTO_CYLINDER: case B_UVAUTO_CYLINDER:
@ -1386,23 +1365,41 @@ void face_borderselect()
void uv_autocalc_tface() void uv_autocalc_tface()
{ {
short mode; short mode, i=0, has_pymenu=0; /* pymenu must be bigger then UV_*_MAPPING */
mode= pupmenu(MENUTITLE("UV Calculation") BPyMenu *pym;
MENUSTRING("Cube Projection", UV_CUBE_MAPPING) "|" char menu_number[3];
MENUSTRING("Cylinder from View", UV_CYL_MAPPING) "|"
MENUSTRING("Sphere from View", UV_SPHERE_MAPPING) "|"
MENUSTRING("Unwrap", UV_UNWRAP_MAPPING) "|"
MENUSTRING("Project From View", UV_WINDOW_MAPPING) "|"
MENUSTRING("Project from View 1/1", UV_BOUNDS1_MAPPING) "|"
MENUSTRING("Project from View 1/2", UV_BOUNDS2_MAPPING) "|"
MENUSTRING("Project from View 1/4", UV_BOUNDS4_MAPPING) "|"
MENUSTRING("Project from View 1/8", UV_BOUNDS8_MAPPING) "|"
MENUSTRING("Reset 1/1", UV_STD1_MAPPING) "|"
MENUSTRING("Reset 1/2", UV_STD2_MAPPING) "|"
MENUSTRING("Reset 1/4", UV_STD4_MAPPING) "|"
MENUSTRING("Reset 1/8", UV_STD8_MAPPING) );
/* uvmenu, will add python items */
char uvmenu[4096]=MENUTITLE("UV Calculation")
MENUSTRING("Cube Projection", UV_CUBE_MAPPING) "|"
MENUSTRING("Cylinder from View", UV_CYL_MAPPING) "|"
MENUSTRING("Sphere from View", UV_SPHERE_MAPPING) "|"
MENUSTRING("Unwrap (LSCM)", UV_UNWRAP_MAPPING) "|"
MENUSTRING("Project From View", UV_WINDOW_MAPPING) "|"
MENUSTRING("Project from View (bounds)",UV_BOUNDS_MAPPING) "|"
MENUSTRING("Reset", UV_RESET_MAPPING);
/* note that we account for the 10 previous entries with i+10: */
for (pym = BPyMenuTable[PYMENU_UVCALCULATION]; pym; pym = pym->next, i++) {
if (!has_pymenu) {
strcat(uvmenu, "|%l");
has_pymenu = 1;
}
strcat(uvmenu, "|");
strcat(uvmenu, pym->name);
strcat(uvmenu, " %x");
sprintf(menu_number, "%d", i+10);
strcat(uvmenu, menu_number);
}
mode= pupmenu(uvmenu);
if (mode >= 10) {
BPY_menu_do_python(PYMENU_UVCALCULATION, mode - 10);
return;
}
switch(mode) { switch(mode) {
case UV_CUBE_MAPPING: case UV_CUBE_MAPPING:
@ -1411,22 +1408,10 @@ void uv_autocalc_tface()
calculate_uv_map(B_UVAUTO_CYLINDER); break; calculate_uv_map(B_UVAUTO_CYLINDER); break;
case UV_SPHERE_MAPPING: case UV_SPHERE_MAPPING:
calculate_uv_map(B_UVAUTO_SPHERE); break; calculate_uv_map(B_UVAUTO_SPHERE); break;
case UV_BOUNDS8_MAPPING: case UV_BOUNDS_MAPPING:
calculate_uv_map(B_UVAUTO_BOUNDS8); break; calculate_uv_map(B_UVAUTO_BOUNDS); break;
case UV_BOUNDS4_MAPPING: case UV_RESET_MAPPING:
calculate_uv_map(B_UVAUTO_BOUNDS4); break; calculate_uv_map(B_UVAUTO_RESET); break;
case UV_BOUNDS2_MAPPING:
calculate_uv_map(B_UVAUTO_BOUNDS2); break;
case UV_BOUNDS1_MAPPING:
calculate_uv_map(B_UVAUTO_BOUNDS1); break;
case UV_STD8_MAPPING:
calculate_uv_map(B_UVAUTO_STD8); break;
case UV_STD4_MAPPING:
calculate_uv_map(B_UVAUTO_STD4); break;
case UV_STD2_MAPPING:
calculate_uv_map(B_UVAUTO_STD2); break;
case UV_STD1_MAPPING:
calculate_uv_map(B_UVAUTO_STD1); break;
case UV_WINDOW_MAPPING: case UV_WINDOW_MAPPING:
calculate_uv_map(B_UVAUTO_WINDOW); break; calculate_uv_map(B_UVAUTO_WINDOW); break;
case UV_UNWRAP_MAPPING: case UV_UNWRAP_MAPPING:

@ -1413,9 +1413,13 @@ void do_global_buttons(unsigned short event)
break; break;
case B_PYMENUEVAL: /* is button from space.c *info* */ case B_PYMENUEVAL: /* is button from space.c *info* */
waitcursor( 1 ); /* can take some time */
BPyMenu_RemoveAllEntries(); /* free old data */ BPyMenu_RemoveAllEntries(); /* free old data */
if (BPyMenu_Init(1) == -1) /* re-eval scripts registration in menus */ if (BPyMenu_Init(1) == -1) { /* re-eval scripts registration in menus */
waitcursor( 0 );
error("Invalid scripts dir: check console"); error("Invalid scripts dir: check console");
}
waitcursor( 0 );
break; break;
case B_PYTHONDIRFILESEL: /* is button from space.c *info* */ case B_PYTHONDIRFILESEL: /* is button from space.c *info* */
if(curarea->spacetype==SPACE_INFO) { if(curarea->spacetype==SPACE_INFO) {