[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34124] trunk/blender/source/blender: bugfix [#25498] Projection paint clone tool leaves seams
Campbell Barton
ideasman42 at gmail.com
Thu Jan 6 10:32:26 CET 2011
Revision: 34124
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=34124
Author: campbellbarton
Date: 2011-01-06 10:32:25 +0100 (Thu, 06 Jan 2011)
Log Message:
-----------
bugfix [#25498] Projection paint clone tool leaves seams
Modified Paths:
--------------
trunk/blender/source/blender/blenlib/BLI_math_geom.h
trunk/blender/source/blender/blenlib/intern/math_geom.c
trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
Modified: trunk/blender/source/blender/blenlib/BLI_math_geom.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_math_geom.h 2011-01-06 05:45:41 UTC (rev 34123)
+++ trunk/blender/source/blender/blenlib/BLI_math_geom.h 2011-01-06 09:32:25 UTC (rev 34124)
@@ -58,7 +58,8 @@
float dist_to_line_segment_v2(float p[2], float l1[2], float l2[2]);
float dist_to_line_segment_v3(float p[3], float l1[3], float l2[3]);
-float closest_to_line_v3(float r[3], float p[3], float l1[3], float l2[3]);
+float closest_to_line_v3(float r[3], const float p[3], const float l1[3], const float l2[3]);
+float closest_to_line_v2(float r[2], const float p[2], const float l1[2], const float l2[2]);
void closest_to_line_segment_v3(float r[3], float p[3], float l1[3], float l2[3]);
/******************************* Intersection ********************************/
Modified: trunk/blender/source/blender/blenlib/intern/math_geom.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/math_geom.c 2011-01-06 05:45:41 UTC (rev 34123)
+++ trunk/blender/source/blender/blenlib/intern/math_geom.c 2011-01-06 09:32:25 UTC (rev 34124)
@@ -1030,7 +1030,7 @@
/* find closest point to p on line through l1,l2 and return lambda,
* where (0 <= lambda <= 1) when cp is in the line segement l1,l2
*/
-float closest_to_line_v3(float cp[3],float p[3], float l1[3], float l2[3])
+float closest_to_line_v3(float cp[3], const float p[3], const float l1[3], const float l2[3])
{
float h[3],u[3],lambda;
sub_v3_v3v3(u, l2, l1);
@@ -1042,6 +1042,17 @@
return lambda;
}
+float closest_to_line_v2(float cp[2],const float p[2], const float l1[2], const float l2[2])
+{
+ float h[2],u[2],lambda;
+ sub_v2_v2v2(u, l2, l1);
+ sub_v2_v2v2(h, p, l1);
+ lambda =dot_v2v2(u,h)/dot_v2v2(u,u);
+ cp[0] = l1[0] + u[0] * lambda;
+ cp[1] = l1[1] + u[1] * lambda;
+ return lambda;
+}
+
#if 0
/* little sister we only need to know lambda */
static float lambda_cp_line(float p[3], float l1[3], float l2[3])
Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_image.c 2011-01-06 05:45:41 UTC (rev 34123)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_image.c 2011-01-06 09:32:25 UTC (rev 34124)
@@ -1140,6 +1140,7 @@
/* TODO - move to arithb.c */
/* little sister we only need to know lambda */
+#ifndef PROJ_DEBUG_NOSEAMBLEED
static float lambda_cp_line2(const float p[2], const float l1[2], const float l2[2])
{
float h[2], u[2];
@@ -1152,6 +1153,7 @@
return(dot_v2v2(u, h)/dot_v2v2(u, u));
}
+#endif // PROJ_DEBUG_NOSEAMBLEED
/* Converts a UV location to a 3D screenspace location
@@ -1624,6 +1626,7 @@
/* scale the quad & tri about its center
* scaling by PROJ_FACE_SCALE_SEAM (0.99x) is used for getting fake UV pixel coords that are on the
* edge of the face but slightly inside it occlusion tests dont return hits on adjacent faces */
+#ifndef PROJ_DEBUG_NOSEAMBLEED
static void scale_quad(float insetCos[4][3], float *origCos[4], const float inset)
{
float cent[3];
@@ -1667,8 +1670,8 @@
add_v3_v3(insetCos[1], cent);
add_v3_v3(insetCos[2], cent);
}
+#endif //PROJ_DEBUG_NOSEAMBLEED
-
static float Vec2Lenf_nosqrt(const float *v1, const float *v2)
{
float x, y;
@@ -2497,26 +2500,32 @@
/* Only bother calculating the weights if we intersect */
if (ps->do_mask_normal || ps->dm_mtface_clone) {
-#if 0
- /* This is not QUITE correct since UV is not inside the UV's but good enough for seams */
+#if 1
+ /* get the UV on the line since we want to copy the pixels from there for bleeding */
+ float uv_close[2];
+ float fac= closest_to_line_v2(uv_close, uv, tf_uv_pxoffset[fidx1], tf_uv_pxoffset[fidx2]);
+ if (fac < 0.0f) copy_v2_v2(uv_close, tf_uv_pxoffset[fidx1]);
+ else if (fac > 1.0f) copy_v2_v2(uv_close, tf_uv_pxoffset[fidx2]);
+
if (side) {
- barycentric_weights_v2(tf_uv_pxoffset[0], tf_uv_pxoffset[2], tf_uv_pxoffset[3], uv, w);
+ barycentric_weights_v2(tf_uv_pxoffset[0], tf_uv_pxoffset[2], tf_uv_pxoffset[3], uv_close, w);
}
else {
- barycentric_weights_v2(tf_uv_pxoffset[0], tf_uv_pxoffset[1], tf_uv_pxoffset[2], uv, w);
+ barycentric_weights_v2(tf_uv_pxoffset[0], tf_uv_pxoffset[1], tf_uv_pxoffset[2], uv_close, w);
}
-#endif
-#if 1
+#else /* this is buggy with quads, dont use for now */
+
/* Cheat, we know where we are along the edge so work out the weights from that */
fac = fac1 + (fac * (fac2-fac1));
+
w[0]=w[1]=w[2]= 0.0;
if (side) {
- w[fidx1?fidx1-1:0] = fac;
- w[fidx2?fidx2-1:0] = 1.0f-fac;
+ w[fidx1?fidx1-1:0] = 1.0f-fac;
+ w[fidx2?fidx2-1:0] = fac;
}
else {
- w[fidx1] = fac;
- w[fidx2] = 1.0f-fac;
+ w[fidx1] = 1.0f-fac;
+ w[fidx2] = fac;
}
#endif
}
More information about the Bf-blender-cvs
mailing list