Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-01-06 12:32:25 +0300
committerCampbell Barton <ideasman42@gmail.com>2011-01-06 12:32:25 +0300
commit28e689b9aa0f716fa021a3185cb446a2fa69ec59 (patch)
tree9772fb477057e70af31c37abb4c4a51037ef3699 /source/blender
parent3ecacb56544a26738c9581ac8c082c0101d64ba4 (diff)
bugfix [#25498] Projection paint clone tool leaves seams
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenlib/BLI_math_geom.h3
-rw-r--r--source/blender/blenlib/intern/math_geom.c13
-rw-r--r--source/blender/editors/sculpt_paint/paint_image.c31
3 files changed, 34 insertions, 13 deletions
diff --git a/source/blender/blenlib/BLI_math_geom.h b/source/blender/blenlib/BLI_math_geom.h
index 3c2c6312f4d..f8a4ee48c6f 100644
--- a/source/blender/blenlib/BLI_math_geom.h
+++ b/source/blender/blenlib/BLI_math_geom.h
@@ -58,7 +58,8 @@ float dist_to_line_v2(float p[2], float l1[2], float l2[2]);
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 ********************************/
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index 605f3ad785e..2a420b78fda 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -1030,7 +1030,7 @@ int isect_aabb_aabb_v3(float min1[3], float max1[3], float min2[3], float max2[3
/* 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 @@ float closest_to_line_v3(float cp[3],float p[3], float l1[3], float l2[3])
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])
diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index c4bf3a20235..bbfa909b807 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -1140,6 +1140,7 @@ static void project_face_seams_init(const ProjPaintState *ps, const int face_ind
/* 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 @@ static float lambda_cp_line2(const float p[2], const float l1[2], const float l2
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 @@ static int line_clip_rect2f(
/* 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,7 +1670,7 @@ static void scale_tri(float insetCos[4][3], float *origCos[4], const float inset
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)
{
@@ -2497,26 +2500,32 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i
/* 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
}