diff --git a/release/scripts/uv_archimap.py b/release/scripts/uv_archimap.py index 3310416ffa6..0deebbfb6ab 100644 --- a/release/scripts/uv_archimap.py +++ b/release/scripts/uv_archimap.py @@ -3,7 +3,7 @@ """ Registration info for Blender menus: <- these words are ignored Name: 'ArchiMap UV Projection Unwrapper' Blender: 240 -Group: 'UV' +Group: 'UvCalculation' Tooltip: 'ArchiMap UV Unwrap mesh faces for all select mesh objects' """ diff --git a/release/scripts/uv_from_adjacent.py b/release/scripts/uv_from_adjacent.py index 1cfbfc7f109..a4ae51ec7e4 100644 --- a/release/scripts/uv_from_adjacent.py +++ b/release/scripts/uv_from_adjacent.py @@ -2,7 +2,7 @@ """ Name: 'UVs from adjacent' Blender: 241 -Group: 'UV' +Group: 'UvCalculation' Tooltip: 'Assign UVs to selected faces from surrounding unselected faces.' """ __author__ = "Campbell Barton" diff --git a/source/blender/include/butspace.h b/source/blender/include/butspace.h index 1dbd61b980c..c82fa6faf08 100644 --- a/source/blender/include/butspace.h +++ b/source/blender/include/butspace.h @@ -653,14 +653,8 @@ enum { B_UVAUTO_WINDOW, B_UVAUTO_CUBE, B_UVAUTO_CUBESIZE, - B_UVAUTO_STD1, - B_UVAUTO_STD2, - B_UVAUTO_STD4, - B_UVAUTO_STD8, - B_UVAUTO_BOUNDS1, - B_UVAUTO_BOUNDS2, - B_UVAUTO_BOUNDS4, - B_UVAUTO_BOUNDS8, + B_UVAUTO_RESET, + B_UVAUTO_BOUNDS, B_UVAUTO_TOP, B_UVAUTO_FACE, B_UVAUTO_OBJECT, diff --git a/source/blender/python/BPY_menus.c b/source/blender/python/BPY_menus.c index 5d857293b88..11dfb4ad792 100644 --- a/source/blender/python/BPY_menus.c +++ b/source/blender/python/BPY_menus.c @@ -103,6 +103,8 @@ static int bpymenu_group_atoi( char *str ) return PYMENU_WEIGHTPAINT; else if( !strcmp( str, "VertexPaint" ) ) return PYMENU_VERTEXPAINT; + else if( !strcmp( str, "UvCalculation" ) ) + return PYMENU_UVCALCULATION; /* "Misc" or an inexistent group name: use misc */ else return PYMENU_MISC; @@ -168,6 +170,9 @@ char *BPyMenu_group_itoa( short menugroup ) case PYMENU_VERTEXPAINT: return "VertexPaint"; break; + case PYMENU_UVCALCULATION: + return "UvCalculation"; + break; case PYMENU_MISC: return "Misc"; break; diff --git a/source/blender/python/BPY_menus.h b/source/blender/python/BPY_menus.h index 4556928dade..d66f1acf1fc 100644 --- a/source/blender/python/BPY_menus.h +++ b/source/blender/python/BPY_menus.h @@ -99,6 +99,7 @@ typedef enum { PYMENU_FACESELECT, PYMENU_WEIGHTPAINT, PYMENU_VERTEXPAINT, + PYMENU_UVCALCULATION, PYMENU_HELP,/*Main Help menu items - prob best to leave for 'official' ones*/ PYMENU_HELPSYSTEM,/* Resources, troubleshooting, system tools */ PYMENU_HELPWEBSITES,/* Help -> Websites submenu */ diff --git a/source/blender/src/editface.c b/source/blender/src/editface.c index ba9174f0c4d..e0d5a403568 100644 --- a/source/blender/src/editface.c +++ b/source/blender/src/editface.c @@ -94,20 +94,17 @@ #include "BDR_unwrapper.h" +#include "BPY_extern.h" +#include "BPY_menus.h" + /* Pupmenu codes: */ #define UV_CUBE_MAPPING 2 #define UV_CYL_MAPPING 3 #define UV_SPHERE_MAPPING 4 -#define UV_BOUNDS8_MAPPING 68 -#define UV_BOUNDS4_MAPPING 65 -#define UV_BOUNDS2_MAPPING 66 -#define UV_BOUNDS1_MAPPING 67 -#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_BOUNDS_MAPPING 5 +#define UV_RESET_MAPPING 6 +#define UV_WINDOW_MAPPING 7 +#define UV_UNWRAP_MAPPING 8 #define UV_CYL_EX 32 #define UV_SPHERE_EX 34 @@ -363,16 +360,7 @@ void calculate_uv_map(unsigned short mapmode) if(me->totface==0) return; switch(mapmode) { - case B_UVAUTO_BOUNDS1: - 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; - } - + case B_UVAUTO_BOUNDS: min[0]= min[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; for(; b>=0; b--) { 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; - case B_UVAUTO_STD8: - 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; - } - + case B_UVAUTO_RESET: tface= me->mtface; for(a=0; atotface; a++, tface++) if(tface->flag & TF_SELECT) - default_uv(tface->uv, fac); + default_uv(tface->uv, 1.0); break; case B_UVAUTO_CYLINDER: @@ -1386,23 +1365,41 @@ void face_borderselect() void uv_autocalc_tface() { - short mode; - mode= pupmenu(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", 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) ); - + short mode, i=0, has_pymenu=0; /* pymenu must be bigger then UV_*_MAPPING */ + BPyMenu *pym; + char menu_number[3]; + /* 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) { case UV_CUBE_MAPPING: @@ -1411,22 +1408,10 @@ void uv_autocalc_tface() calculate_uv_map(B_UVAUTO_CYLINDER); break; case UV_SPHERE_MAPPING: calculate_uv_map(B_UVAUTO_SPHERE); break; - case UV_BOUNDS8_MAPPING: - calculate_uv_map(B_UVAUTO_BOUNDS8); break; - case UV_BOUNDS4_MAPPING: - calculate_uv_map(B_UVAUTO_BOUNDS4); 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_BOUNDS_MAPPING: + calculate_uv_map(B_UVAUTO_BOUNDS); break; + case UV_RESET_MAPPING: + calculate_uv_map(B_UVAUTO_RESET); break; case UV_WINDOW_MAPPING: calculate_uv_map(B_UVAUTO_WINDOW); break; case UV_UNWRAP_MAPPING: diff --git a/source/blender/src/headerbuttons.c b/source/blender/src/headerbuttons.c index 26169c89345..1837ae2e384 100644 --- a/source/blender/src/headerbuttons.c +++ b/source/blender/src/headerbuttons.c @@ -1413,9 +1413,13 @@ void do_global_buttons(unsigned short event) break; case B_PYMENUEVAL: /* is button from space.c *info* */ + waitcursor( 1 ); /* can take some time */ 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"); + } + waitcursor( 0 ); break; case B_PYTHONDIRFILESEL: /* is button from space.c *info* */ if(curarea->spacetype==SPACE_INFO) {