[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58109] trunk/blender/source/blender/ editors/sculpt_paint/paint_image_proj.c: fix [#36039] Texture paint bug with face selection on subdivided object

Campbell Barton ideasman42 at gmail.com
Tue Jul 9 10:17:15 CEST 2013


Revision: 58109
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58109
Author:   campbellbarton
Date:     2013-07-09 08:17:14 +0000 (Tue, 09 Jul 2013)
Log Message:
-----------
fix [#36039] Texture paint bug with face selection on subdivided object
original patch by Antony Riakiotakis, made some edits to only check origindex when needed.

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

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c	2013-07-09 07:50:16 UTC (rev 58108)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_image_proj.c	2013-07-09 08:17:14 UTC (rev 58109)
@@ -245,7 +245,8 @@
 	float normal_angle_inner;
 	float normal_angle_range;       /* difference between normal_angle and normal_angle_inner, for easy access */
 
-	short is_ortho;
+	bool do_face_sel;               /* quick access to (me->editflag & ME_EDIT_PAINT_FACE_SEL) */
+	bool is_ortho;
 	bool do_masking;              /* use masking during painting. Some operations such as airbrush may disable */
 	bool is_texbrush;              /* only to avoid running  */
 	bool is_maskbrush;            /* mask brush is applied before masking */
@@ -2809,11 +2810,13 @@
 	Image *tpage_last = NULL, *tpage;
 
 	/* Face vars */
+	MPoly *mpoly_orig;
 	MFace *mf;
 	MTFace *tf;
 
 	int a, i; /* generic looping vars */
 	int image_index = -1, face_index;
+	int *mpoly_origindex;
 	MVert *mv;
 
 	MemArena *arena; /* at the moment this is just ps->arena_mt[0], but use this to show were not multithreading */
@@ -2827,6 +2830,8 @@
 	if (ps->source == PROJ_SRC_VIEW)
 		ED_view3d_clipping_local(ps->rv3d, ps->ob->obmat);  /* faster clipping lookups */
 
+	ps->do_face_sel = ((((Mesh *)ps->ob->data)->editflag & ME_EDIT_PAINT_FACE_SEL) != 0);
+
 	/* paint onto the derived mesh */
 
 	/* Workaround for subsurf selection, try the display mesh first */
@@ -2835,12 +2840,17 @@
 		ps->dm = mesh_create_derived_render(ps->scene, ps->ob, ps->scene->customdata_mask | CD_MASK_MTFACE);
 		ps->dm_release = TRUE;
 	}
-	else if (ps->ob->derivedFinal && CustomData_has_layer(&ps->ob->derivedFinal->faceData, CD_MTFACE)) {
+	else if (ps->ob->derivedFinal &&
+	         CustomData_has_layer(&ps->ob->derivedFinal->faceData, CD_MTFACE) &&
+	         (ps->do_face_sel == false || CustomData_has_layer(&ps->ob->derivedFinal->polyData, CD_ORIGINDEX)))
+	{
 		ps->dm = ps->ob->derivedFinal;
 		ps->dm_release = FALSE;
 	}
 	else {
-		ps->dm = mesh_get_derived_final(ps->scene, ps->ob, ps->scene->customdata_mask | CD_MASK_MTFACE);
+		ps->dm = mesh_get_derived_final(
+		             ps->scene, ps->ob,
+		             ps->scene->customdata_mask | CD_MASK_MTFACE | (ps->do_face_sel ? CD_ORIGINDEX : 0));
 		ps->dm_release = TRUE;
 	}
 
@@ -2860,6 +2870,15 @@
 	ps->dm_totvert = ps->dm->getNumVerts(ps->dm);
 	ps->dm_totface = ps->dm->getNumTessFaces(ps->dm);
 
+	if (ps->do_face_sel) {
+		mpoly_orig = ((Mesh *)ps->ob->data)->mpoly;
+		mpoly_origindex = ps->dm->getPolyDataArray(ps->dm, CD_ORIGINDEX);
+	}
+	else {
+		mpoly_orig = NULL;
+		mpoly_origindex = NULL;
+	}
+
 	/* use clone mtface? */
 
 
@@ -3129,8 +3148,8 @@
 		}
 	}
 
-
 	for (face_index = 0, tf = ps->dm_mtface, mf = ps->dm_mface; face_index < ps->dm_totface; mf++, tf++, face_index++) {
+		bool is_face_sel;
 
 #ifndef PROJ_DEBUG_NOSEAMBLEED
 		/* add face user if we have bleed enabled, set the UV seam flags later */
@@ -3145,10 +3164,21 @@
 		}
 #endif
 
-		tpage = project_paint_face_image(ps, ps->dm_mtface, face_index);
+		if (ps->do_face_sel) {
+			int orig_index;
+			if (mpoly_origindex && ((orig_index = mpoly_origindex[face_index])) != ORIGINDEX_NONE) {
+				MPoly *mp = mpoly_orig + orig_index;
+				is_face_sel = ((mp->flag & ME_FACE_SEL) != 0);
+			}
+			else {
+				is_face_sel = ((mf->flag & ME_FACE_SEL) != 0);
+			}
+		}
+		else {
+			is_face_sel = true;
+		}
 
-		if (tpage && ((((Mesh *)ps->ob->data)->editflag & ME_EDIT_PAINT_FACE_SEL) == 0 || mf->flag & ME_FACE_SEL)) {
-
+		if (is_face_sel && (tpage = project_paint_face_image(ps, ps->dm_mtface, face_index))) {
 			float *v1coSS, *v2coSS, *v3coSS, *v4coSS = NULL;
 
 			v1coSS = ps->screenCoords[mf->v1];




More information about the Bf-blender-cvs mailing list