Revision: 35448
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35448
Author:   campbellbarton
Date:     2011-03-10 08:51:41 +0000 (Thu, 10 Mar 2011)
Log Message:
-----------
fix [#26406] Projection Paint, Occlussion Problem with Intersections in 
perspective mode.

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-03-10 06:06:55 UTC (rev 35447)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_image.c     
2011-03-10 08:51:41 UTC (rev 35448)
@@ -512,8 +512,34 @@
 
 static float VecZDepthPersp(float pt[2], float v1[3], float v2[3], float 
v3[3], float w[3])
 {
+       float wtot_inv, wtot;
+       float w_tmp[3];
+
        barycentric_weights_v2_persp(v1, v2, v3, pt, w);
-       return (v1[2]*w[0]) + (v2[2]*w[1]) + (v3[2]*w[2]);
+       /* for the depth we need the weights to match what
+        * barycentric_weights_v2 would return, in this case its easiest just to
+        * undo the 4th axis division and make it unit-sum
+        *
+        * don't call barycentric_weights_v2() becaue our callers expect 'w'
+        * to be weighted from the perspective */
+       w_tmp[0]= w[0] * v1[3];
+       w_tmp[1]= w[1] * v2[3];
+       w_tmp[2]= w[2] * v3[3];
+
+       wtot = w_tmp[0]+w_tmp[1]+w_tmp[2];
+
+       if (wtot != 0.0f) {
+               wtot_inv = 1.0f/wtot;
+
+               w_tmp[0] = w_tmp[0]*wtot_inv;
+               w_tmp[1] = w_tmp[1]*wtot_inv;
+               w_tmp[2] = w_tmp[2]*wtot_inv;
+       }
+       else /* dummy values for zero area face */
+               w_tmp[0] = w_tmp[1] = w_tmp[2] = 1.0f/3.0f;
+       /* done mimicing barycentric_weights_v2() */
+
+       return (v1[2]*w_tmp[0]) + (v2[2]*w_tmp[1]) + (v3[2]*w_tmp[2]);
 }
 
 

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to