[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [35367] trunk/blender/source/blender/ editors/sculpt_paint/sculpt.c: Final step for texture nodes/ threading issue fix: make needed

Sergey Sharybin g.ulairi at gmail.com
Sat Mar 5 18:47:25 CET 2011


Revision: 35367
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35367
Author:   nazgul
Date:     2011-03-05 17:47:24 +0000 (Sat, 05 Mar 2011)
Log Message:
-----------
Final step for texture nodes/threading issue fix: make needed
initialization on sculpt brush stroke init and free used resources
when stroke is finished.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/sculpt_paint/sculpt.c

Modified: trunk/blender/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/sculpt.c	2011-03-05 17:04:30 UTC (rev 35366)
+++ trunk/blender/source/blender/editors/sculpt_paint/sculpt.c	2011-03-05 17:47:24 UTC (rev 35367)
@@ -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 @@
 	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,12 +3294,8 @@
 	}
 
 	view3d_operator_needs_opengl(C);
+	sculpt_brush_init_tex(sd, ss);
 
-	/* 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_update_mesh_elements(scene, ob, brush->sculpt_tool == SCULPT_TOOL_SMOOTH);
 
 	return 1;
@@ -3439,6 +3451,15 @@
 	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 @@
 
 		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)




More information about the Bf-blender-cvs mailing list