From 0b24ca19ff30175f74185da412e3d05bd73ee36e Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sun, 23 Sep 2007 22:02:18 +0000 Subject: bugfix - running scriptlinks did not initialize the armature weakref dict, thanks for finding caedes! this bug is in 2.45 but can work around by setting it manually --- import sys as pysys try: pysys.modules['__main__'].__arm_weakrefs except: pysys.modules['__main__'].__arm_weakrefs = {} --- changed how draw modes work - when displaying textured meshes in editmode, only draw selected edges when "Edge Draw" is not enabled. this makes it easy to see the texture/mapping without edges getting in the way. This means editmode can draw like UV/Face mode did when "Draw Edges" was disabled. Also made the active vert/edge/face color themeable, still need to set the default to somthing other then pink. --- source/blender/blenkernel/BKE_utildefines.h | 1 + source/blender/include/BIF_resources.h | 1 + source/blender/python/BPY_interface.c | 7 ++- source/blender/src/drawobject.c | 98 ++++++++++++++++++----------- source/blender/src/resources.c | 1 + source/blender/src/space.c | 2 +- 6 files changed, 70 insertions(+), 40 deletions(-) diff --git a/source/blender/blenkernel/BKE_utildefines.h b/source/blender/blenkernel/BKE_utildefines.h index 836e5b2f171..a30617a2f15 100644 --- a/source/blender/blenkernel/BKE_utildefines.h +++ b/source/blender/blenkernel/BKE_utildefines.h @@ -57,6 +57,7 @@ #define ELEM6(a, b, c, d, e, f, g) ( ELEM(a, b, c) || ELEM4(a, d, e, f, g) ) #define ELEM7(a, b, c, d, e, f, g, h) ( ELEM3(a, b, c, d) || ELEM4(a, e, f, g, h) ) #define ELEM8(a, b, c, d, e, f, g, h, i) ( ELEM4(a, b, c, d, e) || ELEM4(a, f, g, h, i) ) +#define ELEM9(a, b, c, d, e, f, g, h, i, j) ( ELEM4(a, b, c, d, e) || ELEM5(a, f, g, h, i, j) ) /* string compare */ #define STREQ(str, a) ( strcmp((str), (a))==0 ) diff --git a/source/blender/include/BIF_resources.h b/source/blender/include/BIF_resources.h index 60f9972be31..e63e84efcbd 100644 --- a/source/blender/include/BIF_resources.h +++ b/source/blender/include/BIF_resources.h @@ -525,6 +525,7 @@ enum { TH_SEQ_META, TH_EDGE_SHARP, + TH_EDITMESH_ACTIVE, }; /* XXX WARNING: previous is saved in file, so do not change order! */ diff --git a/source/blender/python/BPY_interface.c b/source/blender/python/BPY_interface.c index 97d9f221ab9..28593f740be 100644 --- a/source/blender/python/BPY_interface.c +++ b/source/blender/python/BPY_interface.c @@ -1915,7 +1915,12 @@ void BPY_do_pyscript( ID * id, short event ) /* invalid scriptlinks (new .blend was just loaded), return */ if( during_slink < 0 ) return; - + + if( !setup_armature_weakrefs()){ + printf("Oops - weakref dict\n"); + return; + } + /* tell we're running a scriptlink. The sum also tells if this script * is running nested inside another. Blender.Load needs this info to * avoid trouble with invalid slink pointers. */ diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c index 47c2f9f82ae..109600b6104 100644 --- a/source/blender/src/drawobject.c +++ b/source/blender/src/drawobject.c @@ -1468,10 +1468,14 @@ static void draw_dm_verts(DerivedMesh *dm, int sel) static int draw_dm_edges_sel__setDrawOptions(void *userData, int index) { EditEdge *eed = EM_get_edge_for_index(index); - unsigned char **cols = userData; + unsigned char **cols = userData, *col; if (eed->h==0) { - glColor4ubv(cols[(eed->f&SELECT)?1:0]); + col = cols[(eed->f&SELECT)?1:0]; + /* no alpha, this is used so a transparent color can disable drawing unselected edges in editmode */ + if (col[3]==0) return 0; + + glColor4ubv(col); return 1; } else { return 0; @@ -1651,7 +1655,7 @@ static void draw_em_fancy_verts(EditMesh *em, DerivedMesh *cageDM) glPointSize(1.0); } -static void draw_em_fancy_edges(DerivedMesh *cageDM) +static void draw_em_fancy_edges(DerivedMesh *cageDM, short sel_only) { int pass; unsigned char wire[4], sel[4]; @@ -1659,6 +1663,11 @@ static void draw_em_fancy_edges(DerivedMesh *cageDM) /* since this function does transparant... */ BIF_GetThemeColor3ubv(TH_EDGE_SELECT, (char *)sel); BIF_GetThemeColor3ubv(TH_WIRE, (char *)wire); + + /* when sel only is used, dont render wire, only selected, this is used for + * textured draw mode when the 'edges' option is disabled */ + if (sel_only) + wire[3] = 0; for (pass=0; pass<2; pass++) { /* show wires in transparant when no zbuf clipping for select */ @@ -1666,13 +1675,14 @@ static void draw_em_fancy_edges(DerivedMesh *cageDM) if (G.vd->zbuf && (G.vd->flag & V3D_ZBUF_SELECT)==0) { glEnable(GL_BLEND); glDisable(GL_DEPTH_TEST); - - wire[3] = sel[3] = 85; + sel[3] = 85; + if (!sel_only) wire[3] = 85; } else { continue; } } else { - wire[3] = sel[3] = 255; + sel[3] = 255; + if (!sel_only) wire[3] = 255; } if(G.scene->selectmode == SCE_SELECT_FACE) { @@ -1688,8 +1698,10 @@ static void draw_em_fancy_edges(DerivedMesh *cageDM) } } else { - glColor4ubv(wire); - draw_dm_edges(cageDM); + if (!sel_only) { + glColor4ubv(wire); + draw_dm_edges(cageDM); + } } if (pass==0) { @@ -1993,33 +2005,42 @@ static void draw_em_fancy(Object *ob, EditMesh *em, DerivedMesh *cageDM, Derived } /* here starts all fancy draw-extra over */ - - if(G.f & G_DRAWSEAMS) { - BIF_ThemeColor(TH_EDGE_SEAM); - glLineWidth(2); - - draw_dm_edges_seams(cageDM); - - glColor3ub(0,0,0); - glLineWidth(1); - } + if( (G.f & G_DRAWEDGES)==0 && + ((G.vd->drawtype==OB_TEXTURE && dt>OB_SOLID) || + (G.vd->drawtype==OB_SOLID && G.vd->flag2 & V3D_SOLID_TEX)) + ) { + /* we are drawing textures and 'G_DRAWEDGES' is disabled, dont draw any edges */ + + /* only draw selected edges otherwise there is no way of telling if a face is selected */ + draw_em_fancy_edges(cageDM, 1); + + } else { + if(G.f & G_DRAWSEAMS) { + BIF_ThemeColor(TH_EDGE_SEAM); + glLineWidth(2); - if(G.f & G_DRAWSHARP) { - BIF_ThemeColor(TH_EDGE_SHARP); - glLineWidth(2); - - draw_dm_edges_sharp(cageDM); - - glColor3ub(0,0,0); - glLineWidth(1); - } - - if(G.f & G_DRAWCREASES) { - draw_dm_creases(cageDM); + draw_dm_edges_seams(cageDM); + + glColor3ub(0,0,0); + glLineWidth(1); + } + + if(G.f & G_DRAWSHARP) { + BIF_ThemeColor(TH_EDGE_SHARP); + glLineWidth(2); + + draw_dm_edges_sharp(cageDM); + + glColor3ub(0,0,0); + glLineWidth(1); + } + + if(G.f & G_DRAWCREASES) { + draw_dm_creases(cageDM); + } + + draw_em_fancy_edges(cageDM, 0); } - - draw_em_fancy_edges(cageDM); - if(ob==G.obedit) { retopo_matrix_update(G.vd); @@ -2043,8 +2064,10 @@ static void draw_em_fancy(Object *ob, EditMesh *em, DerivedMesh *cageDM, Derived /* Draw active editmode vertex edge of face (if any)*/ if (em->selected.last) { + unsigned char act_col[4]; EditSelection *ese = em->selected.last; - + BIF_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, (char *)act_col); + if( ese->type == EDITVERT && ((EditVert *)ese->data)->h==0) { EditVert *ev = (EditVert*)ese->data; float size = BIF_GetThemeValuef(TH_VERTEX_SIZE)*4; @@ -2052,7 +2075,7 @@ static void draw_em_fancy(Object *ob, EditMesh *em, DerivedMesh *cageDM, Derived glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDepthMask(0); - glColor4ub(255,255,255,64); + glColor4ubv(act_col); glPointSize(size); glBegin(GL_POINTS); @@ -2069,7 +2092,7 @@ static void draw_em_fancy(Object *ob, EditMesh *em, DerivedMesh *cageDM, Derived glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDepthMask(0); - glColor4ub(255,255,255,128); + glColor4ubv(act_col); glLineWidth(2.0); @@ -2107,7 +2130,7 @@ static void draw_em_fancy(Object *ob, EditMesh *em, DerivedMesh *cageDM, Derived glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDepthMask(0); - glColor4ub(255,255,255,64); + glColor4ubv(act_col); glEnable(GL_POLYGON_STIPPLE); glPolygonStipple(stipplepattern); @@ -2160,7 +2183,6 @@ static void draw_em_fancy(Object *ob, EditMesh *em, DerivedMesh *cageDM, Derived glDepthMask(1); } } - } if(dt>OB_WIRE) { diff --git a/source/blender/src/resources.c b/source/blender/src/resources.c index 526cbfab292..a018fff927c 100644 --- a/source/blender/src/resources.c +++ b/source/blender/src/resources.c @@ -599,6 +599,7 @@ char *BIF_ThemeColorsPup(int spacetype) str += sprintf(str, "Face Selected (transp) %%x%d|", TH_FACE_SELECT); str += sprintf(str, "Face Dot Selected %%x%d|", TH_FACE_DOT); str += sprintf(str, "Face Dot Size %%x%d|", TH_FACEDOT_SIZE); + str += sprintf(str, "Active Vert/Edge/Face %%x%d|", TH_EDITMESH_ACTIVE); str += sprintf(str, "Normal %%x%d|", TH_NORMAL); str += sprintf(str, "Bone Solid %%x%d|", TH_BONE_SOLID); str += sprintf(str, "Bone Pose %%x%d", TH_BONE_POSE); diff --git a/source/blender/src/space.c b/source/blender/src/space.c index 78b4af26d23..d4433e7d2fe 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -3131,7 +3131,7 @@ static void info_user_themebuts(uiBlock *block, short y1, short y2, short y3) } else { uiBlockBeginAlign(block); - if ELEM8(th_curcol, TH_PANEL, TH_LAMP, TH_FACE, TH_FACE_SELECT, TH_MENU_BACK, TH_MENU_HILITE, TH_MENU_ITEM, TH_NODE) { + if ELEM9(th_curcol, TH_PANEL, TH_LAMP, TH_FACE, TH_FACE_SELECT, TH_EDITMESH_ACTIVE, TH_MENU_BACK, TH_MENU_HILITE, TH_MENU_ITEM, TH_NODE) { uiDefButC(block, NUMSLI, B_UPDATE_THEME,"A ", 465,y3+25,200,20, col+3, 0.0, 255.0, B_THEMECOL, 0, ""); } uiDefButC(block, NUMSLI, B_UPDATE_THEME,"R ", 465,y3,200,20, col, 0.0, 255.0, B_THEMECOL, 0, ""); -- cgit v1.2.3