Fix T86968: Last UV factor in cyclic strokes

The UV factor of the last point of a cyclic stroke was using the factor of
the first point leading to unwanted scaling artifacts.

The fix sets the uv factor of the last point to the currect value (last UV
factor + length between last and first point).

Reviewed By: antoniov, fclem

Maniphest Tasks: T86968

Differential Revision: https://developer.blender.org/D10850
This commit is contained in:
Falk David 2021-04-21 12:16:16 +02:00
parent d17bff849d
commit 183e3f6bb9
Notes: blender-bot 2023-02-14 04:56:36 +01:00
Referenced by issue #86968, [GP] Alpha artifact & inconsistent scaling using stroke texture.
1 changed files with 8 additions and 1 deletions

View File

@ -348,7 +348,14 @@ static void gpencil_buffer_add_stroke(gpStrokeVert *verts,
}
/* Draw line to first point to complete the loop for cyclic strokes. */
if (is_cyclic) {
gpencil_buffer_add_point(verts, cols, gps, &pts[0], v++, false);
gpencil_buffer_add_point(verts, cols, gps, &pts[0], v, false);
/* UV factor needs to be adjusted for the last point to not be equal to the UV factor of the
* first point. It should be the factor of the last point plus the distance from the last point
* to the first.
*/
gpStrokeVert *vert = &verts[v];
vert->u_stroke = verts[v - 1].u_stroke + len_v3v3(&pts[pts_len - 1].x, &pts[0].x);
v++;
}
/* Last adjacency point (not drawn). */
adj_idx = (is_cyclic) ? 1 : max_ii(0, pts_len - 2);