Fix #33040: baking selected to active could miss at pixels at the edge of faces

when there was a tiny mismatch between low and high poly models, maybe because
of float precision when editing the mesh. Added a small epsilon now to avoid this.
This commit is contained in:
Brecht Van Lommel
2012-11-02 13:36:26 +00:00
parent 40b3c3a4e6
commit 41cd2d8e84

View File

@@ -2377,9 +2377,27 @@ static void do_bake_shade(void *handle, int x, int y, float u, float v)
v3= vlr->v3->co;
}
/* renderco */
l= 1.0f-u-v;
/* shrink barycentric coordinates inwards slightly to avoid some issues
* where baking selected to active might just miss the other face at the
* near the edge of a face */
if (bs->actob) {
const float eps = 1.0f - 1e-4f;
float invsum;
u = (u - 0.5f)*eps + 0.5f;
v = (v - 0.5f)*eps + 0.5f;
l = (l - 0.5f)*eps + 0.5f;
invsum = 1.0f/(u + v + l);
u *= invsum;
v *= invsum;
l *= invsum;
}
/* renderco */
shi->co[0]= l*v3[0]+u*v1[0]+v*v2[0];
shi->co[1]= l*v3[1]+u*v1[1]+v*v2[1];
shi->co[2]= l*v3[2]+u*v1[2]+v*v2[2];