[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [42055] trunk/blender/source/blender/ editors/sculpt_paint/paint_image.c: fix for [#29355] clone-brush in texture paint

Campbell Barton ideasman42 at gmail.com
Tue Nov 22 12:37:17 CET 2011


Revision: 42055
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=42055
Author:   campbellbarton
Date:     2011-11-22 11:37:17 +0000 (Tue, 22 Nov 2011)
Log Message:
-----------
fix for [#29355] clone-brush in texture paint

but was caused by cycles code, noticed it was also doing a render engine string lookup & flag check per pixel (tsk tsk), result is now cached.

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

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_image.c	2011-11-22 10:42:48 UTC (rev 42054)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_image.c	2011-11-22 11:37:17 UTC (rev 42055)
@@ -300,6 +300,7 @@
 	short do_occlude;			/* Use raytraced occlusion? - ortherwise will paint right through to the back*/
 	short do_backfacecull;	/* ignore faces with normals pointing away, skips a lot of raycasts if your normals are correctly flipped */
 	short do_mask_normal;			/* mask out pixels based on their normals */
+	short do_new_shading_nodes;     /* cache scene_use_new_shading_nodes value */
 	float normal_angle;				/* what angle to mask at*/
 	float normal_angle_inner;
 	float normal_angle_range;		/* difference between normal_angle and normal_angle_inner, for easy access */
@@ -518,17 +519,16 @@
 	return ima;
 }
 
-static Image *project_paint_face_image(const ProjPaintState *ps, int face_index)
+static Image *project_paint_face_image(const ProjPaintState *ps, MTFace *dm_mtface, int face_index)
 {
 	Image *ima;
 
-	if(scene_use_new_shading_nodes(ps->scene)) {
+	if(ps->do_new_shading_nodes) { /* cached scene_use_new_shading_nodes result */
 		MFace *mf = ps->dm_mface+face_index;
 		ED_object_get_active_image(ps->ob, mf->mat_nr, &ima, NULL, NULL);
 	}
 	else {
-		MTFace *tf = ps->dm_mtface+face_index;
-		ima = tf->tpage;
+		ima = dm_mtface[face_index].tpage;
 	}
 
 	return ima;
@@ -725,7 +725,7 @@
 		interp_v2_v2v2v2(uv, tf->uv[0], tf->uv[2], tf->uv[3], w);
 	}
 
-	ima = project_paint_face_image(ps, face_index);
+	ima = project_paint_face_image(ps, ps->dm_mtface, face_index);
 	ibuf = ima->ibufs.first; /* we must have got the imbuf before getting here */
 	if (!ibuf) return 0;
 	
@@ -1091,8 +1091,8 @@
 			
 			/* Only need to check if 'i2_fidx' is valid because we know i1_fidx is the same vert on both faces */
 			if (i2_fidx != -1) {
-				Image *tpage = project_paint_face_image(ps, face_index);
-				Image *orig_tpage = project_paint_face_image(ps, orig_face);
+				Image *tpage = project_paint_face_image(ps, ps->dm_mtface, face_index);
+				Image *orig_tpage = project_paint_face_image(ps, ps->dm_mtface, orig_face);
 
 				/* This IS an adjacent face!, now lets check if the UVs are ok */
 				tf = ps->dm_mtface + face_index;
@@ -1349,7 +1349,7 @@
 	if (ps->do_layer_stencil) {
 		/* another UV layers image is masking this one's */
 		ImBuf *ibuf_other;
-		Image *other_tpage = project_paint_face_image(ps, face_index);
+		Image *other_tpage = project_paint_face_image(ps, ps->dm_mtface_stencil, face_index);
 		const MTFace *tf_other = ps->dm_mtface_stencil + face_index;
 		
 		if (other_tpage && (ibuf_other = BKE_image_get_ibuf(other_tpage, NULL))) {
@@ -1506,7 +1506,7 @@
 	if (ps->tool==PAINT_TOOL_CLONE) {
 		if (ps->dm_mtface_clone) {
 			ImBuf *ibuf_other;
-			Image *other_tpage = project_paint_face_image(ps, face_index);
+			Image *other_tpage = project_paint_face_image(ps, ps->dm_mtface_clone, face_index);
 			const MTFace *tf_other = ps->dm_mtface_clone + face_index;
 			
 			if (other_tpage && (ibuf_other = BKE_image_get_ibuf(other_tpage, NULL))) {
@@ -2746,7 +2746,7 @@
 			face_index = GET_INT_FROM_POINTER(node->link);
 				
 			/* Image context switching */
-			tpage = project_paint_face_image(ps, face_index);
+			tpage = project_paint_face_image(ps, ps->dm_mtface, face_index);
 			if (tpage_last != tpage) {
 				tpage_last = tpage;
 
@@ -3249,7 +3249,7 @@
 		}
 #endif
 		
-		tpage = project_paint_face_image(ps, face_index);
+		tpage = project_paint_face_image(ps, ps->dm_mtface, face_index);
 
 		if (tpage && ((((Mesh *)ps->ob->data)->editflag & ME_EDIT_PAINT_MASK)==0 || mf->flag & ME_FACE_SEL)) {
 			
@@ -4714,6 +4714,7 @@
 	ps->do_backfacecull = (settings->imapaint.flag & IMAGEPAINT_PROJECT_BACKFACE) ? 0 : 1;
 	ps->do_occlude = (settings->imapaint.flag & IMAGEPAINT_PROJECT_XRAY) ? 0 : 1;
 	ps->do_mask_normal = (settings->imapaint.flag & IMAGEPAINT_PROJECT_FLAT) ? 0 : 1;
+	ps->do_new_shading_nodes = scene_use_new_shading_nodes(scene); /* only cache the value */
 
 	if (ps->tool == PAINT_TOOL_CLONE)
 		ps->do_layer_clone = (settings->imapaint.flag & IMAGEPAINT_PROJECT_LAYER_CLONE);




More information about the Bf-blender-cvs mailing list