diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-03-05 20:47:24 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-03-05 20:47:24 +0300 |
commit | a2b128aa359627cc1b6d464148cb3fbc30fd32b0 (patch) | |
tree | e833ea129911dada43f625cf1d13030a21b304f5 /source/blender | |
parent | 7fb14d9138783d67494c448cce074d3eecccb95d (diff) |
Final step for texture nodes/threading issue fix: make needed
initialization on sculpt brush stroke init and free used resources
when stroke is finished.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt.c | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 62f180e9066..4f4d6b2ef11 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -64,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" @@ -3264,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); @@ -3278,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); @@ -3439,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); @@ -3488,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) |