[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [19945] trunk/blender/source/blender/src/ imagepaint.c: [#18628] stuck triangle when projection painting -- 2.49RC1

Campbell Barton ideasman42 at gmail.com
Mon Apr 27 16:22:02 CEST 2009


Revision: 19945
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=19945
Author:   campbellbarton
Date:     2009-04-27 16:22:02 +0200 (Mon, 27 Apr 2009)

Log Message:
-----------
[#18628] stuck triangle when projection painting -- 2.49RC1

Increasing the tolerance when making intersection comparisons fixed this.
There is also a problem where a pixel aligned quad would get a diagonal line down the face. offset the pixel locations a little to avoid this (crappy I know but will fix most cases).

Modified Paths:
--------------
    trunk/blender/source/blender/src/imagepaint.c

Modified: trunk/blender/source/blender/src/imagepaint.c
===================================================================
--- trunk/blender/source/blender/src/imagepaint.c	2009-04-27 13:55:38 UTC (rev 19944)
+++ trunk/blender/source/blender/src/imagepaint.c	2009-04-27 14:22:02 UTC (rev 19945)
@@ -186,7 +186,7 @@
 // #define PROJ_BUCKET_CLONE_INIT	1<<1
 
 /* used for testing doubles, if a point is on a line etc */
-#define PROJ_GEOM_TOLERANCE 0.0002f
+#define PROJ_GEOM_TOLERANCE 0.00075f
 
 /* vert flags */
 #define PROJ_VERT_CULL 1
@@ -2315,9 +2315,20 @@
 	/* Use tf_uv_pxoffset instead of tf->uv so we can offset the UV half a pixel
 	 * this is done so we can avoid offseting all the pixels by 0.5 which causes
 	 * problems when wrapping negative coords */
-	xhalfpx = 0.5f / ibuf_xf;
-	yhalfpx = 0.5f / ibuf_yf;
+	xhalfpx = (0.5f+   (PROJ_GEOM_TOLERANCE/3.0f)   ) / ibuf_xf;
+	yhalfpx = (0.5f+   (PROJ_GEOM_TOLERANCE/4.0f)   ) / ibuf_yf;
 	
+	/* Note about (PROJ_GEOM_TOLERANCE/x) above...
+	  Needed to add this offset since UV coords are often quads aligned to pixels.
+	  In this case pixels can be exactly between 2 triangles causing nasty
+	  artifacts.
+	  
+	  This workaround can be removed and painting will still work on most cases
+	  but since the first thing most people try is painting onto a quad- better make it work.
+	 */
+
+
+
 	tf_uv_pxoffset[0][0] = tf->uv[0][0] - xhalfpx;
 	tf_uv_pxoffset[0][1] = tf->uv[0][1] - yhalfpx;
 





More information about the Bf-blender-cvs mailing list