[Bf-blender-cvs] [8e95544] master: Yet another commit to get rid of missing faces in fill brushes.

Antony Riakiotakis noreply at git.blender.org
Fri Feb 20 15:11:39 CET 2015


Commit: 8e955449a80ee7a3663ab0df259303691812ecf3
Author: Antony Riakiotakis
Date:   Fri Feb 20 15:11:12 2015 +0100
Branches: master
https://developer.blender.org/rB8e955449a80ee7a3663ab0df259303691812ecf3

Yet another commit to get rid of missing faces in fill brushes.

We are now guarding against some divisions by small values.
There are still issues here but they are not on boundary faces
anymore so they must be related to some other issue such as
the triangle intersection test.

===================================================================

M	source/blender/editors/sculpt_paint/paint_image_proj.c

===================================================================

diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index cd72849..b6de446 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -2004,24 +2004,32 @@ static bool line_rect_clip(
         float uv[2], bool is_ortho)
 {
 	float min = FLT_MAX, tmp;
-	if ((l1[0] - rect->xmin) * (l2[0] - rect->xmin) < 0) {
-		tmp = rect->xmin;
-		min = min_ff((tmp - l1[0]) / (l2[0] - l1[0]), min);
-	}
-	else if ((l1[0] - rect->xmax) * (l2[0] - rect->xmax) < 0) {
-		tmp = rect->xmax;
-		min = min_ff((tmp - l1[0]) / (l2[0] - l1[0]), min);
-	}
-	if ((l1[1] - rect->ymin) * (l2[1] - rect->ymin) < 0) {
-		tmp = rect->ymin;
-		min = min_ff((tmp - l1[1]) / (l2[1] - l1[1]), min);
+	float xlen = l2[0] - l1[0];
+	float ylen = l2[1] - l1[1];
+
+	/* 0.1 might seem too much, but remember, this is pixels! */
+	if (xlen > 0.1f) {
+		if ((l1[0] - rect->xmin) * (l2[0] - rect->xmin) <= 0) {
+			tmp = rect->xmin;
+			min = min_ff((tmp - l1[0]) / xlen, min);
+		}
+		else if ((l1[0] - rect->xmax) * (l2[0] - rect->xmax) < 0) {
+			tmp = rect->xmax;
+			min = min_ff((tmp - l1[0]) / xlen, min);
+		}
 	}
-	else if ((l1[1] - rect->ymax) * (l2[1] - rect->ymax) < 0) {
-		tmp = rect->ymax;
-		min = min_ff((tmp - l1[1]) / (l2[1] - l1[1]), min);
+
+	if (ylen > 0.1f) {
+		if ((l1[1] - rect->ymin) * (l2[1] - rect->ymin) <= 0) {
+			tmp = rect->ymin;
+			min = min_ff((tmp - l1[1]) / ylen, min);
+		}
+		else if ((l1[1] - rect->ymax) * (l2[1] - rect->ymax) < 0) {
+			tmp = rect->ymax;
+			min = min_ff((tmp - l1[1]) / ylen, min);
+		}
 	}
-	
-	/* it's rare but it can happen if l1 == l2 */
+
 	if (min == FLT_MAX)
 		return false;
 
@@ -2085,7 +2093,7 @@ static void project_bucket_clip_face(
 		int flag;
 		
 		(*tot) = 0;
-		
+
 		if (cull)
 			return;




More information about the Bf-blender-cvs mailing list