Commit: 5c5ee7c228946f07e9e36a436e32d8f2b9b1f108
Author: Nathan Vollmer
Date:   Sun May 22 21:42:51 2016 -0600
Branches: soc-2016-pbvh-painting
https://developer.blender.org/rB5c5ee7c228946f07e9e36a436e32d8f2b9b1f108

Added initial PBVH creation for weight painting on toggle. PBVH is visible 
using gui debug number 14.

===================================================================

M       source/blender/blenkernel/intern/DerivedMesh.c
M       source/blender/editors/sculpt_paint/paint_vertex.c
M       source/blender/editors/space_view3d/drawobject.c

===================================================================

diff --git a/source/blender/blenkernel/intern/DerivedMesh.c 
b/source/blender/blenkernel/intern/DerivedMesh.c
index 1bfc3d9..cb779d8 100644
--- a/source/blender/blenkernel/intern/DerivedMesh.c
+++ b/source/blender/blenkernel/intern/DerivedMesh.c
@@ -2587,7 +2587,7 @@ static void mesh_build_data(
        ob->lastDataMask = dataMask;
        ob->lastNeedMapping = need_mapping;
 
-       if ((ob->mode & OB_MODE_SCULPT) && ob->sculpt) {
+       if (ob->mode & (OB_MODE_SCULPT | OB_MODE_WEIGHT_PAINT) && ob->sculpt) {
                /* create PBVH immediately (would be created on the fly too,
                 * but this avoids waiting on first stroke) */
 
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c 
b/source/blender/editors/sculpt_paint/paint_vertex.c
index 15ab4ca..8bd3b8d 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -1725,6 +1725,16 @@ static void do_weight_paint_vertex(
        }
 }
 
+
+/**** Toggle operator for turning vertex paint mode on or off     /
+/       copied from sculpt.c                                  ****/
+static void vertex_paint_init_session(Scene *scene, Object *ob)
+{
+       ob->sculpt = MEM_callocN(sizeof(SculptSession), "sculpt session");
+
+       BKE_sculpt_update_mesh_elements(scene, scene->toolsettings->sculpt, ob, 
0, false);
+}
+
 /* *************** set wpaint operator ****************** */
 
 /**
@@ -1787,6 +1797,12 @@ static int wpaint_mode_toggle_exec(bContext *C, 
wmOperator *op)
 
        WM_event_add_notifier(C, NC_SCENE | ND_MODE, scene);
 
+       /* Create vertex/weight paint mode session data */
+       if (ob->sculpt)
+               BKE_sculptsession_free(ob);
+
+       vertex_paint_init_session(scene, ob);
+
        return OPERATOR_FINISHED;
 }
 
@@ -2116,8 +2132,9 @@ static void wpaint_stroke_update_step(bContext *C, struct 
PaintStroke *stroke, P
        Brush *brush = BKE_paint_brush(&wp->paint);
        struct WPaintData *wpd = paint_stroke_mode_data(stroke);
        ViewContext *vc;
-       Object *ob;
+       Object *ob = CTX_data_active_object(C);
        Mesh *me;
+       
        float mat[4][4];
        float paintweight;
        int *indexar;
diff --git a/source/blender/editors/space_view3d/drawobject.c 
b/source/blender/editors/space_view3d/drawobject.c
index 65f1f37..6870e3f 100644
--- a/source/blender/editors/space_view3d/drawobject.c
+++ b/source/blender/editors/space_view3d/drawobject.c
@@ -4160,6 +4160,9 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, 
View3D *v3d, RegionView3D
        else if (dt == OB_PAINT) {
                draw_mesh_paint(v3d, rv3d, ob, dm, draw_flags);
 
+               /* For drawing the PBVH */
+               dm->drawFacesSolid(dm, NULL, 0, GPU_object_material_bind);
+
                /* since we already draw wire as wp guide, don't draw over the 
top */
                draw_wire = OBDRAW_WIRE_OFF;
        }

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to