display active vertex in weight paint mode. also correct NULL free.
authorCampbell Barton <ideasman42@gmail.com>
Sat, 15 Jun 2013 11:02:36 +0000 (11:02 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 15 Jun 2013 11:02:36 +0000 (11:02 +0000)
source/blender/blenkernel/intern/mesh.c
source/blender/editors/space_view3d/drawobject.c

index 0ef92ca75a3386e75b0838d2cc14649f47996727..7d728aad9cd77bb0f1da266e71b2556985a4df1b 100644 (file)
@@ -3774,8 +3774,10 @@ void BKE_mesh_do_versions_cd_flag_init(Mesh *mesh)
 
 void BKE_mesh_mselect_clear(Mesh *me)
 {
-       MEM_freeN(me->mselect);
-       me->mselect = NULL;
+       if (me->mselect) {
+               MEM_freeN(me->mselect);
+               me->mselect = NULL;
+       }
        me->totselect = 0;
 }
 
index 2c67802d9491425a8fe19a0fcee9357ef9b88825..1fee3dcb0d0738e1f59c931b4e4b73ee6dc5214f 100644 (file)
@@ -1942,20 +1942,25 @@ static void drawlattice(Scene *scene, View3D *v3d, Object *ob)
 /* ***************** ******************** */
 
 /*  draw callback */
+
+typedef struct drawDMVertSel_userData {
+       MVert *mvert;
+       int active;
+       unsigned char *col[3];  /* (base, sel, act) */
+       char sel_prev;
+} drawDMVertSel_userData;
+
 static void drawSelectedVertices__mapFunc(void *userData, int index, const float co[3],
                                           const float UNUSED(no_f[3]), const short UNUSED(no_s[3]))
 {
-       MVert *mv = &((MVert *)userData)[index];
+       drawDMVertSel_userData *data = userData;
+       MVert *mv = &data->mvert[index];
 
        if (!(mv->flag & ME_HIDE)) {
-               const char sel = mv->flag & SELECT;
-
-               /* TODO define selected color */
-               if (sel) {
-                       glColor3f(1.0f, 1.0f, 0.0f);
-               }
-               else {
-                       glColor3f(0.0f, 0.0f, 0.0f);
+               const char sel = (index == data->active) ? 2 : (mv->flag & SELECT);
+               if (sel != data->sel_prev) {
+                       glColor3ubv(data->col[sel]);
+                       data->sel_prev = sel;
                }
 
                glVertex3fv(co);
@@ -1964,8 +1969,23 @@ static void drawSelectedVertices__mapFunc(void *userData, int index, const float
 
 static void drawSelectedVertices(DerivedMesh *dm, Mesh *me)
 {
+       drawDMVertSel_userData data;
+
+       /* TODO define selected color */
+       unsigned char base_col[3] = {0x0, 0x0, 0x0};
+       unsigned char sel_col[3] = {0xd8, 0xd8, 0x0};
+       unsigned char act_col[3] = {0xff, 0xff, 0xff};
+
+       data.mvert = me->mvert;
+       data.active = BKE_mesh_mselect_active_get(me, ME_VSEL);
+       data.sel_prev = 0xff;
+
+       data.col[0] = base_col;
+       data.col[1] = sel_col;
+       data.col[2] = act_col;
+
        glBegin(GL_POINTS);
-       dm->foreachMappedVert(dm, drawSelectedVertices__mapFunc, me->mvert);
+       dm->foreachMappedVert(dm, drawSelectedVertices__mapFunc, &data);
        glEnd();
 }