Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2007-09-25 07:31:12 +0400
committerCampbell Barton <ideasman42@gmail.com>2007-09-25 07:31:12 +0400
commit2c0db4d707f02f747496308565de0d902d55f5aa (patch)
tree21d6ece112cb1c14b5a4b85d50f2d3b9b3256246
parent3a5db1c40cce63fc97142ee6782d25299a8941a4 (diff)
made active vert/edge/face draw properly with modifiers applied and made their theme default white.
removed active face draw in Face/UV (which is now paint mask mode) mode.
-rw-r--r--source/blender/blenkernel/BKE_DerivedMesh.h18
-rw-r--r--source/blender/blenkernel/BKE_blender.h2
-rw-r--r--source/blender/blenkernel/intern/DerivedMesh.c24
-rw-r--r--source/blender/blenkernel/intern/subsurf_ccg.c95
-rw-r--r--source/blender/include/BDR_editface.h2
-rw-r--r--source/blender/makesdna/DNA_userdef_types.h2
-rw-r--r--source/blender/python/api2_2x/windowTheme.c5
-rw-r--r--source/blender/src/drawimage.c92
-rw-r--r--source/blender/src/drawmesh.c27
-rw-r--r--source/blender/src/drawobject.c300
-rw-r--r--source/blender/src/editface.c20
-rw-r--r--source/blender/src/resources.c2
-rw-r--r--source/blender/src/usiblender.c6
13 files changed, 303 insertions, 292 deletions
diff --git a/source/blender/blenkernel/BKE_DerivedMesh.h b/source/blender/blenkernel/BKE_DerivedMesh.h
index 4a19bfb9249..c710e16ad1a 100644
--- a/source/blender/blenkernel/BKE_DerivedMesh.h
+++ b/source/blender/blenkernel/BKE_DerivedMesh.h
@@ -435,5 +435,23 @@ void weight_to_rgb(float input, float *fr, float *fg, float *fb);
/* determines required DerivedMesh data according to view and edit modes */
CustomDataMask get_viewedit_datamask();
+/* repeate this pattern
+ X000X000
+ 00000000
+ 00X000X0
+ 00000000 */
+
+#define DM_FACE_STIPPLE \
+{ \
+ 136,136,136,136,0,0,0,0,34,34,34,34,0,0,0,0, \
+ 136,136,136,136,0,0,0,0,34,34,34,34,0,0,0,0, \
+ 136,136,136,136,0,0,0,0,34,34,34,34,0,0,0,0, \
+ 136,136,136,136,0,0,0,0,34,34,34,34,0,0,0,0, \
+ 136,136,136,136,0,0,0,0,34,34,34,34,0,0,0,0, \
+ 136,136,136,136,0,0,0,0,34,34,34,34,0,0,0,0, \
+ 136,136,136,136,0,0,0,0,34,34,34,34,0,0,0,0, \
+ 136,136,136,136,0,0,0,0,34,34,34,34,0,0,0,0 \
+}
+
#endif
diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h
index 0a202dfadc3..c79076b4e68 100644
--- a/source/blender/blenkernel/BKE_blender.h
+++ b/source/blender/blenkernel/BKE_blender.h
@@ -44,7 +44,7 @@ struct ListBase;
struct MemFile;
#define BLENDER_VERSION 245
-#define BLENDER_SUBVERSION 2
+#define BLENDER_SUBVERSION 3
#define BLENDER_MINVERSION 240
#define BLENDER_MINSUBVERSION 0
diff --git a/source/blender/blenkernel/intern/DerivedMesh.c b/source/blender/blenkernel/intern/DerivedMesh.c
index ff98f6f642e..299bbc10241 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -633,9 +633,10 @@ static void emDM_foreachMappedFaceCenter(DerivedMesh *dm, void (*func)(void *use
}
static void emDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int useColors)
{
+ GLubyte act_face_stipple[32*32/8] = DM_FACE_STIPPLE;
EditMeshDerivedMesh *emdm= (EditMeshDerivedMesh*) dm;
EditFace *efa;
- int i;
+ int i, draw;
if (emdm->vertexCos) {
EditVert *eve;
@@ -645,7 +646,13 @@ static void emDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us
for (i=0,efa= emdm->em->faces.first; efa; i++,efa= efa->next) {
int drawSmooth = (efa->flag & ME_SMOOTH);
- if(!setDrawOptions || setDrawOptions(userData, i, &drawSmooth)) {
+ draw = setDrawOptions==NULL ? 1 : setDrawOptions(userData, i, &drawSmooth);
+ if(draw) {
+ if (draw==2) { /* enabled with stipple */
+ glEnable(GL_POLYGON_STIPPLE);
+ glPolygonStipple(act_face_stipple);
+ }
+
glShadeModel(drawSmooth?GL_SMOOTH:GL_FLAT);
glBegin(efa->v4?GL_QUADS:GL_TRIANGLES);
@@ -668,12 +675,20 @@ static void emDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us
}
}
glEnd();
+
+ if (draw==2)
+ glDisable(GL_POLYGON_STIPPLE);
}
}
} else {
for (i=0,efa= emdm->em->faces.first; efa; i++,efa= efa->next) {
int drawSmooth = (efa->flag & ME_SMOOTH);
- if(!setDrawOptions || setDrawOptions(userData, i, &drawSmooth)) {
+ draw = setDrawOptions==NULL ? 1 : setDrawOptions(userData, i, &drawSmooth);
+ if(draw) {
+ if (draw==2) { /* enabled with stipple */
+ glEnable(GL_POLYGON_STIPPLE);
+ glPolygonStipple(act_face_stipple);
+ }
glShadeModel(drawSmooth?GL_SMOOTH:GL_FLAT);
glBegin(efa->v4?GL_QUADS:GL_TRIANGLES);
@@ -696,6 +711,9 @@ static void emDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *us
}
}
glEnd();
+
+ if (draw==2)
+ glDisable(GL_POLYGON_STIPPLE);
}
}
}
diff --git a/source/blender/blenkernel/intern/subsurf_ccg.c b/source/blender/blenkernel/intern/subsurf_ccg.c
index 646157991bb..0b1563beced 100644
--- a/source/blender/blenkernel/intern/subsurf_ccg.c
+++ b/source/blender/blenkernel/intern/subsurf_ccg.c
@@ -1908,6 +1908,7 @@ static void ccgDM_drawUVEdges(DerivedMesh *dm)
}
static void ccgDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *userData, int index, int *drawSmooth_r), void *userData, int useColors) {
+ GLubyte act_face_stipple[32*32/8] = DM_FACE_STIPPLE;
CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
CCGSubSurf *ss = ccgdm->ss;
CCGFaceIterator *fi = ccgSubSurf_getFaceIterator(ss);
@@ -1924,51 +1925,63 @@ static void ccgDM_drawMappedFaces(DerivedMesh *dm, int (*setDrawOptions)(void *u
if(faceFlags) drawSmooth = (faceFlags[origIndex*4] & ME_SMOOTH);
else drawSmooth = 1;
-
- if (index!=-1 && (!setDrawOptions || setDrawOptions(userData, index, &drawSmooth))) {
- for (S=0; S<numVerts; S++) {
- VertData *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
- if (drawSmooth) {
- glShadeModel(GL_SMOOTH);
- for (y=0; y<gridSize-1; y++) {
- glBegin(GL_QUAD_STRIP);
- for (x=0; x<gridSize; x++) {
- VertData *a = &faceGridData[(y+0)*gridSize + x];
- VertData *b = &faceGridData[(y+1)*gridSize + x];
-
- glNormal3fv(a->no);
- glVertex3fv(a->co);
- glNormal3fv(b->no);
- glVertex3fv(b->co);
+
+ if (index!=-1) {
+ int draw;
+ draw = setDrawOptions==NULL ? 1 : setDrawOptions(userData, index, &drawSmooth);
+
+ if (draw) {
+ if (draw==2) {
+ glEnable(GL_POLYGON_STIPPLE);
+ glPolygonStipple(act_face_stipple);
+ }
+
+ for (S=0; S<numVerts; S++) {
+ VertData *faceGridData = ccgSubSurf_getFaceGridDataArray(ss, f, S);
+ if (drawSmooth) {
+ glShadeModel(GL_SMOOTH);
+ for (y=0; y<gridSize-1; y++) {
+ glBegin(GL_QUAD_STRIP);
+ for (x=0; x<gridSize; x++) {
+ VertData *a = &faceGridData[(y+0)*gridSize + x];
+ VertData *b = &faceGridData[(y+1)*gridSize + x];
+
+ glNormal3fv(a->no);
+ glVertex3fv(a->co);
+ glNormal3fv(b->no);
+ glVertex3fv(b->co);
+ }
+ glEnd();
}
- glEnd();
- }
- } else {
- glShadeModel(GL_FLAT);
- glBegin(GL_QUADS);
- for (y=0; y<gridSize-1; y++) {
- for (x=0; x<gridSize-1; x++) {
- float *a = faceGridData[(y+0)*gridSize + x].co;
- float *b = faceGridData[(y+0)*gridSize + x + 1].co;
- float *c = faceGridData[(y+1)*gridSize + x + 1].co;
- float *d = faceGridData[(y+1)*gridSize + x].co;
- float a_cX = c[0]-a[0], a_cY = c[1]-a[1], a_cZ = c[2]-a[2];
- float b_dX = d[0]-b[0], b_dY = d[1]-b[1], b_dZ = d[2]-b[2];
- float no[3];
-
- no[0] = b_dY*a_cZ - b_dZ*a_cY;
- no[1] = b_dZ*a_cX - b_dX*a_cZ;
- no[2] = b_dX*a_cY - b_dY*a_cX;
- glNormal3fv(no);
-
- glVertex3fv(d);
- glVertex3fv(c);
- glVertex3fv(b);
- glVertex3fv(a);
+ } else {
+ glShadeModel(GL_FLAT);
+ glBegin(GL_QUADS);
+ for (y=0; y<gridSize-1; y++) {
+ for (x=0; x<gridSize-1; x++) {
+ float *a = faceGridData[(y+0)*gridSize + x].co;
+ float *b = faceGridData[(y+0)*gridSize + x + 1].co;
+ float *c = faceGridData[(y+1)*gridSize + x + 1].co;
+ float *d = faceGridData[(y+1)*gridSize + x].co;
+ float a_cX = c[0]-a[0], a_cY = c[1]-a[1], a_cZ = c[2]-a[2];
+ float b_dX = d[0]-b[0], b_dY = d[1]-b[1], b_dZ = d[2]-b[2];
+ float no[3];
+
+ no[0] = b_dY*a_cZ - b_dZ*a_cY;
+ no[1] = b_dZ*a_cX - b_dX*a_cZ;
+ no[2] = b_dX*a_cY - b_dY*a_cX;
+ glNormal3fv(no);
+
+ glVertex3fv(d);
+ glVertex3fv(c);
+ glVertex3fv(b);
+ glVertex3fv(a);
+ }
}
+ glEnd();
}
- glEnd();
}
+ if (draw==2)
+ glDisable(GL_POLYGON_STIPPLE);
}
}
}
diff --git a/source/blender/include/BDR_editface.h b/source/blender/include/BDR_editface.h
index b8d4393170c..72b0e7352da 100644
--- a/source/blender/include/BDR_editface.h
+++ b/source/blender/include/BDR_editface.h
@@ -38,7 +38,7 @@ struct EditFace;
struct Mesh;
struct MCol;
-struct MTFace *get_active_mtface(struct EditFace **efa, struct MCol **mcol, short partsel);
+struct MTFace *get_active_mtface(struct EditFace **efa, struct MCol **mcol, short sloppy);
void calculate_uv_map(unsigned short mapmode);
void default_uv(float uv[][2], float size);
void make_tfaces(struct Mesh *me);
diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h
index 945fe5e00d3..5860ca13a5d 100644
--- a/source/blender/makesdna/DNA_userdef_types.h
+++ b/source/blender/makesdna/DNA_userdef_types.h
@@ -101,7 +101,7 @@ typedef struct ThemeSpace {
char movie[4], image[4], scene[4], audio[4]; // for sequence editor
char effect[4], plugin[4], transition[4], meta[4];
- char bpad1[4];
+ char editmesh_active[4];
} ThemeSpace;
diff --git a/source/blender/python/api2_2x/windowTheme.c b/source/blender/python/api2_2x/windowTheme.c
index 182a147e86d..6a27d59436e 100644
--- a/source/blender/python/api2_2x/windowTheme.c
+++ b/source/blender/python/api2_2x/windowTheme.c
@@ -172,6 +172,7 @@ static PyObject *ThemeSpace_getAttr( BPy_ThemeSpace * self, char *name )
ELSEIF_TSP_RGBA( edge_select )
ELSEIF_TSP_RGBA( edge_seam )
ELSEIF_TSP_RGBA( edge_sharp )
+ ELSEIF_TSP_RGBA( editmesh_active )
ELSEIF_TSP_RGBA( edge_facesel )
ELSEIF_TSP_RGBA( face )
ELSEIF_TSP_RGBA( face_select )
@@ -199,13 +200,13 @@ static PyObject *ThemeSpace_getAttr( BPy_ThemeSpace * self, char *name )
else if( !strcmp( name, "facedot_size" ) )
attrib = Py_BuildValue( "i", tsp->facedot_size );
else if( !strcmp( name, "__members__" ) )
- attrib = Py_BuildValue("[sssssssssssssssssssssssssssssssssssssssssssssss]", "theme",
+ attrib = Py_BuildValue("[ssssssssssssssssssssssssssssssssssssssssssssssss]", "theme",
"back", "text", "text_hi", "header",
"panel", "shade1", "shade2", "hilite",
"grid", "wire", "select", "lamp", "active",
"group", "group_active",
"transform", "vertex", "vertex_select",
- "edge", "edge_select", "edge_seam", "edge_sharp",
+ "edge", "edge_select", "edge_seam", "edge_sharp", "editmesh_active",
"edge_facesel", "face", "face_select",
"face_dot", "normal", "bone_solid", "bone_pose",
"strip", "strip_select",
diff --git a/source/blender/src/drawimage.c b/source/blender/src/drawimage.c
index 4c1333d0ce2..b95452b0342 100644
--- a/source/blender/src/drawimage.c
+++ b/source/blender/src/drawimage.c
@@ -453,7 +453,7 @@ void draw_uvs_sima(void)
{
MTFace *tface,*activetface = NULL;
EditMesh *em = G.editMesh;
- EditFace *efa;
+ EditFace *efa, *efa_act;
char col1[4], col2[4];
float pointsize;
@@ -511,6 +511,8 @@ void draw_uvs_sima(void)
}
}
+ activetface = get_active_mtface(&efa_act, NULL, 0); /* will be set to NULL if hidden */
+
/* draw transparent faces */
if(G.f & G_DRAWFACES) {
BIF_GetThemeColor4ubv(TH_FACE, col1);
@@ -520,7 +522,10 @@ void draw_uvs_sima(void)
for (efa= em->faces.first; efa; efa= efa->next) {
tface= CustomData_em_get(&em->fdata, efa->data, CD_MTFACE);
+
if (SIMA_FACEDRAW_CHECK(efa, tface)) {
+ efa->tmp.p = tface;
+ if (tface==activetface) continue; /* important the temp pointer is set above */
if( SIMA_FACESEL_CHECK(efa, tface) )
glColor4ubv((GLubyte *)col2);
else
@@ -532,8 +537,10 @@ void draw_uvs_sima(void)
glVertex2fv(tface->uv[2]);
if(efa->v4) glVertex2fv(tface->uv[3]);
glEnd();
- efa->tmp.p = tface;
+
} else {
+ if (tface == activetface)
+ activetface= NULL;
efa->tmp.p = NULL;
}
}
@@ -544,12 +551,32 @@ void draw_uvs_sima(void)
if (SIMA_FACEDRAW_CHECK(efa, tface)) {
efa->tmp.p = tface;
} else {
+ if (tface == activetface)
+ activetface= NULL;
efa->tmp.p = NULL;
}
}
glDisable(GL_BLEND);
}
-
+
+ if (activetface) {
+ GLubyte act_face_stipple[32*32/8] = DM_FACE_STIPPLE;
+
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ BIF_ThemeColor4(TH_EDITMESH_ACTIVE);
+ glEnable(GL_POLYGON_STIPPLE);
+ glPolygonStipple(act_face_stipple);
+ glBegin(efa_act->v4?GL_QUADS:GL_TRIANGLES);
+ glVertex2fv(activetface->uv[0]);
+ glVertex2fv(activetface->uv[1]);
+ glVertex2fv(activetface->uv[2]);
+ if(efa_act->v4) glVertex2fv(activetface->uv[3]);
+ glEnd();
+ glDisable(GL_POLYGON_STIPPLE);
+ glDisable(GL_BLEND);
+ }
+
if (G.sima->flag & SI_SMOOTH_UV) {
glEnable( GL_LINE_SMOOTH );
glEnable(GL_BLEND);
@@ -661,41 +688,38 @@ void draw_uvs_sima(void)
/* draw active face edges */
- /* colors: R=u G=v */
- activetface = get_active_mtface(&efa, NULL, 0);
+
if (activetface) {
- setlinestyle(2);
- tface=activetface;
- cpack(0x0);
- glBegin(GL_LINE_LOOP);
- glVertex2fv(tface->uv[0]);
- glVertex2fv(tface->uv[1]);
- glVertex2fv(tface->uv[2]);
- if(efa->v4) glVertex2fv(tface->uv[3]);
- glEnd();
-
- cpack(0xFF00);
- glBegin(GL_LINE_STRIP);
- glVertex2fv(tface->uv[0]);
- glVertex2fv(tface->uv[1]);
- glEnd();
-
- cpack(0xFF);
- glBegin(GL_LINE_STRIP);
- glVertex2fv(tface->uv[0]);
- if(efa->v4) glVertex2fv(tface->uv[3]);
- else glVertex2fv(tface->uv[2]);
- glEnd();
+
+
+
+
+
+
+
+
+
+
+
+
+
+
- cpack(0xFFFFFF);
- glBegin(GL_LINE_STRIP);
- glVertex2fv(tface->uv[1]);
- glVertex2fv(tface->uv[2]);
- if(efa->v4) glVertex2fv(tface->uv[3]);
- glEnd();
- setlinestyle(0);
+
+
+
+
+
+
+
+
+
+
+
+
+
}
/* unselected uv's */
diff --git a/source/blender/src/drawmesh.c b/source/blender/src/drawmesh.c
index 0c8132b3469..7fe53e3c19a 100644
--- a/source/blender/src/drawmesh.c
+++ b/source/blender/src/drawmesh.c
@@ -597,10 +597,6 @@ void update_realtime_textures()
enum {
eEdge_Visible = (1<<0),
eEdge_Select = (1<<1),
- eEdge_Active = (1<<2),
- eEdge_SelectAndActive = (1<<3),
- eEdge_ActiveFirst = (1<<4),
- eEdge_ActiveLast = (1<<5)
};
/* Creates a hash of edges to flags indicating
@@ -634,10 +630,6 @@ EdgeHash *get_tface_mesh_marked_edge_info(Mesh *me)
if (!(mf->flag&ME_HIDE)) {
unsigned int flags = eEdge_Visible;
if (mf->flag&ME_FACE_SEL) flags |= eEdge_Select;
- if (i==me->act_face) {
- flags |= eEdge_Active;
- if (mf->flag&ME_FACE_SEL) flags |= eEdge_SelectAndActive;
- }
get_marked_edge_info__orFlags(eh, mf->v1, mf->v2, flags);
get_marked_edge_info__orFlags(eh, mf->v2, mf->v3, flags);
@@ -647,11 +639,6 @@ EdgeHash *get_tface_mesh_marked_edge_info(Mesh *me)
} else {
get_marked_edge_info__orFlags(eh, mf->v3, mf->v1, flags);
}
-
- if (i==me->act_face) {
- get_marked_edge_info__orFlags(eh, mf->v1, mf->v2, eEdge_ActiveFirst);
- get_marked_edge_info__orFlags(eh, mf->v1, mf->v4?mf->v4:mf->v3, eEdge_ActiveLast);
- }
}
}
}
@@ -708,17 +695,7 @@ static int draw_tfaces3D__setActiveOpts(void *userData, int index)
MEdge *med = &data->me->medge[index];
unsigned long flags = (long) BLI_edgehash_lookup(data->eh, med->v1, med->v2);
- if (flags & eEdge_Active) {
- if (flags & eEdge_ActiveLast) {
- glColor3ub(255, 0, 0);
- } else if (flags & eEdge_ActiveFirst) {
- glColor3ub(0, 255, 0);
- } else if (flags & eEdge_SelectAndActive) {
- glColor3ub(255, 255, 0);
- } else {
- glColor3ub(255, 0, 255);
- }
-
+ if (flags & eEdge_Select) {
return 1;
} else {
return 0;
@@ -1040,7 +1017,7 @@ static int draw_tface_mapped__set_draw(void *userData, int index)
static int draw_em_tf_mapped__set_draw(void *userData, int index)
{
EditMesh *em = userData;
- EditFace *efa = EM_get_face_for_index(index);
+ EditFace *efa = EM_get_face_for_index(index), *efa_act = userData;
MTFace *tface;
MCol *mcol;
int matnr;
diff --git a/source/blender/src/drawobject.c b/source/blender/src/drawobject.c
index 109600b6104..8e4fc6c72ac 100644
--- a/source/blender/src/drawobject.c
+++ b/source/blender/src/drawobject.c
@@ -1450,17 +1450,39 @@ static void draw_dm_vert_normals(DerivedMesh *dm) {
/* Draw verts with color set based on selection */
static void draw_dm_verts__mapFunc(void *userData, int index, float *co, float *no_f, short *no_s)
{
+ struct { int sel; EditVert *eve_act; } * data = userData;
EditVert *eve = EM_get_vert_for_index(index);
- int sel = *((int*) userData);
- if (eve->h==0 && (eve->f&SELECT)==sel) {
- bglVertex3fv(co);
+ if (eve->h==0 && (eve->f&SELECT)==data->sel) {
+ /* draw active larger - need to stop/start point drawing for this :/ */
+ if (eve==data->eve_act) {
+ float size = BIF_GetThemeValuef(TH_VERTEX_SIZE);
+ unsigned char col[3];
+ BIF_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, (char *)col);
+ glColor4ubv(col);
+
+ bglEnd();
+ glPointSize(size+3);
+ bglBegin(GL_POINTS);
+
+ bglVertex3fv(co);
+
+ bglEnd();
+ glPointSize(size);
+ bglBegin(GL_POINTS);
+ } else {
+ bglVertex3fv(co);
+ }
}
}
-static void draw_dm_verts(DerivedMesh *dm, int sel)
+static void draw_dm_verts(DerivedMesh *dm, int sel, EditVert *eve_act)
{
+ struct { int sel; EditVert *eve_act; } data;
+ data.sel = sel;
+ data.eve_act = eve_act;
+
bglBegin(GL_POINTS);
- dm->foreachMappedVert(dm, draw_dm_verts__mapFunc, &sel);
+ dm->foreachMappedVert(dm, draw_dm_verts__mapFunc, &data);
bglEnd();
}
@@ -1468,25 +1490,38 @@ 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, *col;
+ //unsigned char **cols = userData, *col;
+ struct { unsigned char *baseCol, *selCol, *actCol; EditEdge *eed_act; } * data = userData;
+ unsigned char *col;
if (eed->h==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);
+ if (eed==data->eed_act) {
+ glColor4ubv(data->actCol);
+ } else {
+ if (eed->f&SELECT) {
+ col = data->selCol;
+ } else {
+ col = data->baseCol;
+ }
+ /* 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;
}
}
-static void draw_dm_edges_sel(DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol)
+static void draw_dm_edges_sel(DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol, unsigned char *actCol, EditEdge *eed_act)
{
- unsigned char *cols[2];
- cols[0] = baseCol;
- cols[1] = selCol;
- dm->drawMappedEdges(dm, draw_dm_edges_sel__setDrawOptions, cols);
+ struct { unsigned char *baseCol, *selCol, *actCol; EditEdge *eed_act; } data;
+
+ data.baseCol = baseCol;
+ data.selCol = selCol;
+ data.actCol = actCol;
+ data.eed_act = eed_act;
+ dm->drawMappedEdges(dm, draw_dm_edges_sel__setDrawOptions, &data);
}
/* Draw edges */
@@ -1549,25 +1584,38 @@ static void draw_dm_edges_sharp(DerivedMesh *dm)
}
- /* Draw faces with color set based on selection */
+ /* Draw faces with color set based on selection
+ * return 2 for the active face so it renders with stipple enabled */
static int draw_dm_faces_sel__setDrawOptions(void *userData, int index, int *drawSmooth_r)
{
+ struct { unsigned char *cols[3]; EditFace *efa_act; } * data = userData;
EditFace *efa = EM_get_face_for_index(index);
- unsigned char **cols = userData;
-
+ unsigned char *col;
+
if (efa->h==0) {
- glColor4ubv(cols[(efa->f&SELECT)?1:0]);
- return 1;
- } else {
- return 0;
+ if (efa == data->efa_act) {
+ glColor4ubv(data->cols[2]);
+ return 2; /* stipple */
+ } else {
+ col = data->cols[(efa->f&SELECT)?1:0];
+ if (col[3]==0) return 0;
+ glColor4ubv(col);
+ return 1;
+ }
}
+ return 0;
}
-static void draw_dm_faces_sel(DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol)
+
+/* also draws the active face */
+static void draw_dm_faces_sel(DerivedMesh *dm, unsigned char *baseCol, unsigned char *selCol, unsigned char *actCol, EditFace *efa_act)
{
- unsigned char *cols[2];
- cols[0] = baseCol;
- cols[1] = selCol;
- dm->drawMappedFaces(dm, draw_dm_faces_sel__setDrawOptions, cols, 0);
+ struct { unsigned char *cols[3]; EditFace *efa_act; } data;
+ data.cols[0] = baseCol;
+ data.cols[1] = selCol;
+ data.cols[2] = actCol;
+ data.efa_act = efa_act;
+
+ dm->drawMappedFaces(dm, draw_dm_faces_sel__setDrawOptions, &data, 0);
}
static int draw_dm_creases__setDrawOptions(void *userData, int index)
@@ -1597,7 +1645,7 @@ static void draw_dm_creases(DerivedMesh *dm)
/* EditMesh drawing routines*/
-static void draw_em_fancy_verts(EditMesh *em, DerivedMesh *cageDM)
+static void draw_em_fancy_verts(EditMesh *em, DerivedMesh *cageDM, EditVert *eve_act)
{
int sel;
@@ -1633,7 +1681,7 @@ static void draw_em_fancy_verts(EditMesh *em, DerivedMesh *cageDM)
if(G.scene->selectmode & SCE_SELECT_VERTEX) {
glPointSize(size);
glColor4ubv((GLubyte *)col);
- draw_dm_verts(cageDM, sel);
+ draw_dm_verts(cageDM, sel, eve_act);
}
if( (G.scene->selectmode & SCE_SELECT_FACE) &&
@@ -1655,19 +1703,20 @@ static void draw_em_fancy_verts(EditMesh *em, DerivedMesh *cageDM)
glPointSize(1.0);
}
-static void draw_em_fancy_edges(DerivedMesh *cageDM, short sel_only)
+static void draw_em_fancy_edges(DerivedMesh *cageDM, short sel_only, EditEdge *eed_act)
{
int pass;
- unsigned char wire[4], sel[4];
+ unsigned char wireCol[4], selCol[4], actCol[4];
/* since this function does transparant... */
- BIF_GetThemeColor3ubv(TH_EDGE_SELECT, (char *)sel);
- BIF_GetThemeColor3ubv(TH_WIRE, (char *)wire);
+ BIF_GetThemeColor3ubv(TH_EDGE_SELECT, (char *)selCol);
+ BIF_GetThemeColor3ubv(TH_WIRE, (char *)wireCol);
+ BIF_GetThemeColor3ubv(TH_EDITMESH_ACTIVE, (char *)actCol);
/* 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;
+ wireCol[3] = 0;
for (pass=0; pass<2; pass++) {
/* show wires in transparant when no zbuf clipping for select */
@@ -1675,31 +1724,31 @@ static void draw_em_fancy_edges(DerivedMesh *cageDM, short sel_only)
if (G.vd->zbuf && (G.vd->flag & V3D_ZBUF_SELECT)==0) {
glEnable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
- sel[3] = 85;
- if (!sel_only) wire[3] = 85;
+ selCol[3] = 85;
+ if (!sel_only) wireCol[3] = 85;
} else {
continue;
}
} else {
- sel[3] = 255;
- if (!sel_only) wire[3] = 255;
+ selCol[3] = 255;
+ if (!sel_only) wireCol[3] = 255;
}
if(G.scene->selectmode == SCE_SELECT_FACE) {
- draw_dm_edges_sel(cageDM, wire, sel);
+ draw_dm_edges_sel(cageDM, wireCol, selCol, actCol, eed_act);
}
else if( (G.f & G_DRAWEDGES) || (G.scene->selectmode & SCE_SELECT_EDGE) ) {
if(cageDM->drawMappedEdgesInterp && (G.scene->selectmode & SCE_SELECT_VERTEX)) {
glShadeModel(GL_SMOOTH);
- draw_dm_edges_sel_interp(cageDM, wire, sel);
+ draw_dm_edges_sel_interp(cageDM, wireCol, selCol);
glShadeModel(GL_FLAT);
} else {
- draw_dm_edges_sel(cageDM, wire, sel);
+ draw_dm_edges_sel(cageDM, wireCol, selCol, actCol, eed_act);
}
}
else {
if (!sel_only) {
- glColor4ubv(wire);
+ glColor4ubv(wireCol);
draw_dm_edges(cageDM);
}
}
@@ -1955,7 +2004,21 @@ static int draw_em_fancy__setFaceOpts(void *userData, int index, int *drawSmooth
static void draw_em_fancy(Object *ob, EditMesh *em, DerivedMesh *cageDM, DerivedMesh *finalDM, int dt)
{
Mesh *me = ob->data;
-
+ EditFace *efa_act = NULL;
+ EditEdge *eed_act = NULL;
+ EditVert *eve_act = NULL;
+
+ if (G.editMesh->selected.last) {
+ EditSelection *ese = G.editMesh->selected.last;
+ if ( ese->type == EDITFACE ) {
+ efa_act = (EditFace *)ese->data;
+ } else if ( ese->type == EDITEDGE ) {
+ eed_act = (EditEdge *)ese->data;
+ } else if ( ese->type == EDITVERT ) {
+ eve_act = (EditVert *)ese->data;
+ }
+ }
+
EM_init_index_arrays(1, 1, 1);
if(dt>OB_WIRE) {
@@ -1990,18 +2053,35 @@ static void draw_em_fancy(Object *ob, EditMesh *em, DerivedMesh *cageDM, Derived
}
if((G.f & (G_DRAWFACES)) || FACESEL_PAINT_TEST) { /* transp faces */
- unsigned char col1[4], col2[4];
+ unsigned char col1[4], col2[4], col3[4];
BIF_GetThemeColor4ubv(TH_FACE, (char *)col1);
BIF_GetThemeColor4ubv(TH_FACE_SELECT, (char *)col2);
+ BIF_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, (char *)col3);
+
+ glEnable(GL_BLEND);
+ glDepthMask(0); // disable write in zbuffer, needed for nice transp
+
+ draw_dm_faces_sel(cageDM, col1, col2, col3, efa_act);
+
+ glDisable(GL_BLEND);
+ glDepthMask(1); // restore write in zbuffer
+ } else if (efa_act) {
+ /* even if draw faces is off it would be nice to draw the stipple face
+ * Make all other faces zero alpha except for the active
+ * */
+ unsigned char col1[4], col2[4], col3[4];
+ col1[3] = col2[3] = 0; /* dont draw */
+ BIF_GetThemeColor4ubv(TH_EDITMESH_ACTIVE, (char *)col3);
glEnable(GL_BLEND);
glDepthMask(0); // disable write in zbuffer, needed for nice transp
- draw_dm_faces_sel(cageDM, col1, col2);
+ draw_dm_faces_sel(cageDM, col1, col2, col3, efa_act);
glDisable(GL_BLEND);
glDepthMask(1); // restore write in zbuffer
+
}
/* here starts all fancy draw-extra over */
@@ -2012,7 +2092,7 @@ static void draw_em_fancy(Object *ob, EditMesh *em, DerivedMesh *cageDM, Derived
/* 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);
+ draw_em_fancy_edges(cageDM, 1, eed_act);
} else {
if(G.f & G_DRAWSEAMS) {
@@ -2039,12 +2119,12 @@ static void draw_em_fancy(Object *ob, EditMesh *em, DerivedMesh *cageDM, Derived
draw_dm_creases(cageDM);
}
- draw_em_fancy_edges(cageDM, 0);
+ draw_em_fancy_edges(cageDM, 0, eed_act);
}
if(ob==G.obedit) {
retopo_matrix_update(G.vd);
- draw_em_fancy_verts(em, cageDM);
+ draw_em_fancy_verts(em, cageDM, eve_act);
if(G.f & G_DRAWNORMALS) {
BIF_ThemeColor(TH_NORMAL);
@@ -2061,128 +2141,6 @@ static void draw_em_fancy(Object *ob, EditMesh *em, DerivedMesh *cageDM, Derived
if(em->vnode && (G.f & G_DRAW_VERSE_DEBUG))
draw_verse_debug(ob, em);
#endif
-
- /* 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;
-
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glDepthMask(0);
- glColor4ubv(act_col);
- glPointSize(size);
-
- glBegin(GL_POINTS);
- glVertex3fv(ev->co);
- glEnd();
-
- glPointSize(1.0);
-
- glDisable(GL_BLEND);
- glDepthMask(1);
-
- } else if(ese->type == EDITEDGE && ((EditEdge *)ese->data)->h==0) {
- EditEdge *eed = (EditEdge*)ese->data;
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glDepthMask(0);
- glColor4ubv(act_col);
-
- glLineWidth(2.0);
-
- glBegin(GL_LINES);
- glVertex3fv(eed->v1->co);
- glVertex3fv(eed->v2->co);
- glEnd();
-
- glLineWidth(1.0);
-
- glDisable(GL_BLEND);
- glDepthMask(1);
-
-
- } else if(ese->type == EDITFACE && ((EditFace *)ese->data)->h==0) {
- EditFace *efa = (EditFace*)ese->data;
-
- /* repeate this pattern
- X000X000
- 00000000
- 00X000X0
- 00000000 */
-
- GLubyte stipplepattern[32*32/8] = {
- 136,136,136,136,0,0,0,0,34,34,34,34,0,0,0,0,
- 136,136,136,136,0,0,0,0,34,34,34,34,0,0,0,0,
- 136,136,136,136,0,0,0,0,34,34,34,34,0,0,0,0,
- 136,136,136,136,0,0,0,0,34,34,34,34,0,0,0,0,
- 136,136,136,136,0,0,0,0,34,34,34,34,0,0,0,0,
- 136,136,136,136,0,0,0,0,34,34,34,34,0,0,0,0,
- 136,136,136,136,0,0,0,0,34,34,34,34,0,0,0,0,
- 136,136,136,136,0,0,0,0,34,34,34,34,0,0,0,0
- };
-
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- glDepthMask(0);
- glColor4ubv(act_col);
-
- glEnable(GL_POLYGON_STIPPLE);
- glPolygonStipple(stipplepattern);
-
- glDisable(GL_LIGHTING);
- if (((EditFace*)ese->data)->v4) {
- glBegin(GL_QUADS);
- glVertex3fv(efa->v1->co);
- glVertex3fv(efa->v2->co);
- glVertex3fv(efa->v3->co);
- glVertex3fv(efa->v4->co);
- glEnd();
- } else {
- glBegin(GL_TRIANGLES);
- glVertex3fv(efa->v1->co);
- glVertex3fv(efa->v2->co);
- glVertex3fv(efa->v3->co);
- glEnd();
- }
- glDisable(GL_POLYGON_STIPPLE);
-
-
- if (G.vd->drawtype==OB_TEXTURE) {
- glBegin(GL_LINES);
- glColor4ub(0, 255,0, 128);
- glVertex3fv(efa->v1->co);
- glVertex3fv(efa->v2->co);
-
- glColor4ub(0, 0, 255,128);
- glVertex3fv(efa->v2->co);
- glVertex3fv(efa->v3->co);
-
-
- glColor4ub(255, 255,0, 128);
- if (efa->v4) {
- glVertex3fv(efa->v3->co);
- glVertex3fv(efa->v4->co);
-
- glColor4ub(255, 0, 0, 128);
- glVertex3fv(efa->v4->co);
- glVertex3fv(efa->v1->co);
- } else {
- glVertex3fv(efa->v3->co);
- glVertex3fv(efa->v1->co);
- }
- glEnd();
- }
-
- glDisable(GL_BLEND);
- glDepthMask(1);
- }
- }
}
if(dt>OB_WIRE) {
diff --git a/source/blender/src/editface.c b/source/blender/src/editface.c
index f5ce9128790..d3af5cc47e8 100644
--- a/source/blender/src/editface.c
+++ b/source/blender/src/editface.c
@@ -560,21 +560,23 @@ void calculate_uv_map(unsigned short mapmode)
allqueue(REDRAWIMAGE, 0);
}
-MTFace *get_active_mtface(EditFace **act_efa, MCol **mcol, short partsel)
+/* last_sel, use em->act_face otherwise get the last selected face in the editselections
+ * at the moment, last_sel is mainly useful for gaking sure the space image dosnt flicker */
+MTFace *get_active_mtface(EditFace **act_efa, MCol **mcol, short sloppy)
{
EditMesh *em = G.editMesh;
EditFace *efa = NULL;
- EditFace *efa_vertsel = NULL; /* use this if one of the faces verts are selected */
EditSelection *ese;
if(!EM_texFaceCheck())
return NULL;
/* first check the active face */
- if (em->act_face) {
+ if (sloppy && em->act_face) {
efa = em->act_face;
} else {
- for (ese = em->selected.last; ese; ese=ese->prev){
+ ese = em->selected.last;
+ for (; ese; ese=ese->prev){
if(ese->type == EDITFACE) {
efa = (EditFace *)ese->data;
@@ -584,21 +586,13 @@ MTFace *get_active_mtface(EditFace **act_efa, MCol **mcol, short partsel)
}
}
- if (!efa) {
+ if (sloppy && !efa) {
for (efa= em->faces.first; efa; efa= efa->next) {
if (efa->f & SELECT)
break;
-
- /* use a face that has 1 vert selected as a last resort
- * This is so selecting verts in editmode does not always make the UV window flicker */
- if (partsel && ((efa->v1->f & SELECT) || (efa->v2->f & SELECT) || (efa->v3->f & SELECT) || (efa->v4 && efa->v4->f & SELECT)))
- efa_vertsel = efa;
}
}
- if (partsel && !efa)
- efa= efa_vertsel;
-
if (efa) {
if (mcol) {
if (CustomData_has_layer(&em->fdata, CD_MCOL))
diff --git a/source/blender/src/resources.c b/source/blender/src/resources.c
index a018fff927c..125c80093a8 100644
--- a/source/blender/src/resources.c
+++ b/source/blender/src/resources.c
@@ -252,6 +252,8 @@ char *BIF_ThemeGetColorPtr(bTheme *btheme, int spacetype, int colorid)
cp= ts->edge_seam; break;
case TH_EDGE_SHARP:
cp= ts->edge_sharp; break;
+ case TH_EDITMESH_ACTIVE:
+ cp= ts->editmesh_active; break;
case TH_EDGE_FACESEL:
cp= ts->edge_facesel; break;
case TH_FACE:
diff --git a/source/blender/src/usiblender.c b/source/blender/src/usiblender.c
index 18df27b21cb..8f43742fe28 100644
--- a/source/blender/src/usiblender.c
+++ b/source/blender/src/usiblender.c
@@ -360,6 +360,12 @@ static void init_userdef_file(void)
/* set default number of recently-used files (if not set) */
if (U.recent_files == 0) U.recent_files = 10;
}
+ if (G.main->versionfile < 245 || (G.main->versionfile == 245 && G.main->subversionfile < 3)) {
+ bTheme *btheme;
+ for(btheme= U.themes.first; btheme; btheme= btheme->next) {
+ SETCOL(btheme->tv3d.editmesh_active, 255, 255, 255, 128);
+ }
+ }
/* GL Texture Garbage Collection (variable abused above!) */
if (U.textimeout == 0) {