diff options
Diffstat (limited to 'source/blender/editors/sculpt_paint/sculpt.c')
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 7505fdb0ecf..4f4d6b2ef11 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -30,6 +30,11 @@ * */ +/** \file blender/editors/sculpt_paint/sculpt.c + * \ingroup edsculpt + */ + + #include "MEM_guardedalloc.h" #include "BLI_math.h" @@ -59,6 +64,7 @@ #include "BKE_paint.h" #include "BKE_report.h" #include "BKE_lattice.h" /* for armature_deform_verts */ +#include "BKE_node.h" #include "BIF_glutil.h" @@ -3259,6 +3265,21 @@ int sculpt_stroke_get_location(bContext *C, struct PaintStroke *stroke, float ou return srd.hit; } +static void sculpt_brush_init_tex(Sculpt *sd, SculptSession *ss) +{ + Brush *brush = paint_brush(&sd->paint); + MTex *mtex= &brush->mtex; + + /* init mtex nodes */ + if(mtex->tex && mtex->tex->nodetree) + ntreeBeginExecTree(mtex->tex->nodetree); /* has internal flag to detect it only does it once */ + + /* TODO: Shouldn't really have to do this at the start of every + stroke, but sculpt would need some sort of notification when + changes are made to the texture. */ + sculpt_update_tex(sd, ss); +} + static int sculpt_brush_stroke_init(bContext *C, ReportList *reports) { Scene *scene= CTX_data_scene(C); @@ -3273,11 +3294,7 @@ static int sculpt_brush_stroke_init(bContext *C, ReportList *reports) } view3d_operator_needs_opengl(C); - - /* TODO: Shouldn't really have to do this at the start of every - stroke, but sculpt would need some sort of notification when - changes are made to the texture. */ - sculpt_update_tex(sd, ss); + sculpt_brush_init_tex(sd, ss); sculpt_update_mesh_elements(scene, ob, brush->sculpt_tool == SCULPT_TOOL_SMOOTH); @@ -3434,6 +3451,15 @@ static void sculpt_stroke_update_step(bContext *C, struct PaintStroke *stroke, P sculpt_flush_update(C); } +static void sculpt_brush_exit_tex(Sculpt *sd) +{ + Brush *brush= paint_brush(&sd->paint); + MTex *mtex= &brush->mtex; + + if(mtex->tex && mtex->tex->nodetree) + ntreeEndExecTree(mtex->tex->nodetree); +} + static void sculpt_stroke_done(bContext *C, struct PaintStroke *unused) { Object *ob= CTX_data_active_object(C); @@ -3483,6 +3509,8 @@ static void sculpt_stroke_done(bContext *C, struct PaintStroke *unused) WM_event_add_notifier(C, NC_OBJECT|ND_DRAW, ob); } + + sculpt_brush_exit_tex(sd); } static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *event) @@ -3496,7 +3524,7 @@ static int sculpt_brush_stroke_invoke(bContext *C, wmOperator *op, wmEvent *even stroke = paint_stroke_new(C, sculpt_stroke_get_location, sculpt_stroke_test_start, sculpt_stroke_update_step, - sculpt_stroke_done); + sculpt_stroke_done, event->type); op->customdata = stroke; @@ -3526,7 +3554,7 @@ static int sculpt_brush_stroke_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; op->customdata = paint_stroke_new(C, sculpt_stroke_get_location, sculpt_stroke_test_start, - sculpt_stroke_update_step, sculpt_stroke_done); + sculpt_stroke_update_step, sculpt_stroke_done, 0); sculpt_update_cache_invariants(C, sd, ss, op, NULL); |