svn merge -r40000:40179 https://svn.blender.org/svnroot/bf-blender/trunk/blender
[blender.git] / source / blender / editors / space_view3d / drawobject.c
index 2da0cfc..81848b2 100644 (file)
@@ -1712,7 +1712,45 @@ void mesh_foreachScreenVert(ViewContext *vc, void (*func)(void *userData, EditVe
 
        dm->release(dm);
 }
+/*Jason */
+static void mesh_obmode_foreachScreenVert__mapFunc(void *userData, int index, float *co, float *UNUSED(no_f), short *UNUSED(no_s))
+{
+       struct { void (*func)(void *userData, MVert *mv, int x, int y, int index); void *userData; ViewContext vc; int clipVerts; } *data = userData;
+       Mesh *me = data->vc.obact->data;
+       MVert *mv = me->mvert+index;
+       //MVert *dmv = CDDM_get_verts(data->vc.obact->derivedFinal)+index;
+       //MVert *mv = CDDM_get_verts(data->vc.obact->derivedFinal)+index;
+       if ((mv->flag & ME_HIDE)==0) {
+               short s[2]= {IS_CLIPPED, 0};
+
+               if (data->clipVerts) {
+                       view3d_project_short_clip(data->vc.ar, co, s, 1);
+               } else {
+                       view3d_project_short_noclip(data->vc.ar, co, s);
+               }
 
+               if (s[0]!=IS_CLIPPED)
+                       data->func(data->userData, mv, s[0], s[1], index);
+       }
+}
+/*Jason*/
+void mesh_obmode_foreachScreenVert(ViewContext *vc, void (*func)(void *userData, MVert *mv, int x, int y, int index), void *userData, int clipVerts)
+{
+       struct { void (*func)(void *userData, MVert *mv, int x, int y, int index); void *userData; ViewContext vc; int clipVerts; } data;
+       DerivedMesh *dm = mesh_get_derived_final(vc->scene, vc->obact, CD_MASK_BAREMESH);
+
+       data.vc= *vc;
+       data.func = func;
+       data.userData = userData;
+       data.clipVerts = clipVerts;
+       
+       if(clipVerts)
+               ED_view3d_local_clipping(vc->rv3d, vc->obact->obmat); /* for local clipping lookups */
+
+       dm->foreachMappedVert(dm, mesh_obmode_foreachScreenVert__mapFunc, &data);
+
+       dm->release(dm);
+}
 static void mesh_foreachScreenEdge__mapFunc(void *userData, int index, float *v0co, float *v1co)
 {
        struct { void (*func)(void *userData, EditEdge *eed, int x0, int y0, int x1, int y1, int index); void *userData; ViewContext vc; int clipVerts; } *data = userData;
@@ -2897,7 +2935,13 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
                        bglPolygonOffset(rv3d->dist, 0.0);
                }
        }
-
+       // Jason
+       if(paint_vertsel_test(ob) && dm->drawSelectedVerts) {
+               glColor3f(0.0f, 0.0f, 0.0f);
+               glPointSize(UI_GetThemeValuef(TH_VERTEX_SIZE));
+               dm->drawSelectedVerts(dm);
+               glPointSize(1.0f);
+       }
        dm->release(dm);
 }
 
@@ -6480,6 +6524,29 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
 }
 
 /* ***************** BACKBUF SEL (BBS) ********* */
+/* Jason */
+static void bbs_obmode_mesh_verts__mapFunc(void *userData, int index, float *co, float *UNUSED(no_f), short *UNUSED(no_s))
+{
+       // TODO: support hidden vertices
+       int offset = (intptr_t) userData;
+       //EditVert *eve = EM_get_vert_for_index(index);
+
+       //if (eve->h==0) {
+       WM_set_framebuffer_index_color(offset+index);
+       bglVertex3fv(co);
+       //}
+}
+/* Jason */
+static void bbs_obmode_mesh_verts(Scene* scene, Object *ob, DerivedMesh *dm, int offset)
+{
+       Mesh *me = (Mesh*)ob->data;
+
+       glPointSize( UI_GetThemeValuef(TH_VERTEX_SIZE) );
+       bglBegin(GL_POINTS);
+       dm->foreachMappedVert(dm, bbs_obmode_mesh_verts__mapFunc, (void*)(intptr_t) offset);
+       bglEnd();
+       glPointSize(1.0);
+}
 
 static void bbs_mesh_verts__mapFunc(void *userData, int index, float *co, float *UNUSED(no_f), short *UNUSED(no_s))
 {
@@ -6578,7 +6645,18 @@ static int bbs_mesh_solid_hide__setDrawOpts(void *userData, int index, int *UNUS
                return 0;
        }
 }
+/* Jason */
+// must have called WM_set_framebuffer_index_color beforehand
+static int bbs_mesh_solid_hide2__setDrawOpts(void *userData, int index, int *UNUSED(drawSmooth_r))
+{
+       Mesh *me = userData;
 
+       if (!(me->mface[index].flag&ME_HIDE)) {
+               return 1;
+       } else {
+               return 0;
+       }
+}
 static void bbs_mesh_solid(Scene *scene, Object *ob)
 {
        DerivedMesh *dm = mesh_get_derived_final(scene, ob, scene->customdata_mask);
@@ -6637,7 +6715,22 @@ void draw_object_backbufsel(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec
                        EM_free_index_arrays();
                }
                else {
-                       bbs_mesh_solid(scene, ob);
+                       Mesh *me= ob->data;
+                       if(me->editflag & ME_EDIT_VERT_SEL) {
+                               DerivedMesh *dm = mesh_get_derived_final(scene, ob, scene->customdata_mask);
+                               WM_set_framebuffer_index_color(me->totvert+2);
+                               glColor3ub(0, 0, 0);
+
+                               dm->drawMappedFaces(dm, bbs_mesh_solid_hide2__setDrawOpts, me, 0, GPU_enable_material, NULL);
+
+                               
+                               bbs_obmode_mesh_verts(scene, ob, dm, 1);
+                               em_vertoffs = me->totvert+1;
+                               dm->release(dm);
+                       }
+                       else {
+                               bbs_mesh_solid(scene, ob);
+                       }
                }
                break;
        case OB_CURVE: