diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2020-02-27 16:37:25 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2020-02-28 12:12:08 +0300 |
commit | 4c4d36c25e46fdf82b3639d8bffee66c7bbb9dbd (patch) | |
tree | 1578fac83505bfda70e2f2c9c89c8717cec3b4c2 /source/blender/blenkernel/intern | |
parent | 9cac5fa681c55edcf6e856e59e07e90e2ae25965 (diff) |
Subdiv: Correct corner passed to foreach_loop callback
Was affecting quad faces. where 0 was always passed for inner
loops and a wrong one for boundary ones.
In the current code this change shouldn't cause any difference
since the corner index is ignored in the actual callback, but
it is required to have his fixed for an upcoming changes.
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r-- | source/blender/blenkernel/intern/subdiv_foreach.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/source/blender/blenkernel/intern/subdiv_foreach.c b/source/blender/blenkernel/intern/subdiv_foreach.c index 37e47cc5b10..884b8d74790 100644 --- a/source/blender/blenkernel/intern/subdiv_foreach.c +++ b/source/blender/blenkernel/intern/subdiv_foreach.c @@ -1103,6 +1103,23 @@ static void subdiv_foreach_loops_of_poly(SubdivForeachTaskContext *ctx, e3); } +static int subdiv_foreach_loops_corner_index(const float u, + const float v, + const float du, + const float dv) +{ + if (u + du <= 0.5f && v + dv <= 0.5f) { + return 0; + } + else if (u >= 0.5f && v + dv <= 0.5f) { + return 1; + } + else if (u >= 0.5f && v >= 0.5f) { + return 2; + } + return 3; +} + static void subdiv_foreach_loops_regular(SubdivForeachTaskContext *ctx, void *tls, const MPoly *coarse_poly) @@ -1146,12 +1163,13 @@ static void subdiv_foreach_loops_regular(SubdivForeachTaskContext *ctx, const int e1 = e0 + ptex_inner_resolution; const int e2 = e0 + (2 * ptex_inner_resolution - 1); const int e3 = e0 + ptex_inner_resolution - 1; + subdiv_foreach_loops_of_poly(ctx, tls, subdiv_loop_index, ptex_face_index, coarse_poly_index, - 0, + subdiv_foreach_loops_corner_index(u, v, du, dv), 0, v0, e0, @@ -1265,12 +1283,16 @@ static void subdiv_foreach_loops_regular(SubdivForeachTaskContext *ctx, else { e2 = start_edge_index + e2_offset + e2_stride * (i - 1); } + + const float loop_u = u + delta_u * i; + const float loop_v = v + delta_v * i; + subdiv_foreach_loops_of_poly(ctx, tls, subdiv_loop_index, ptex_face_index, coarse_poly_index, - corner, + subdiv_foreach_loops_corner_index(loop_u, loop_v, du, dv), corner, v0, e0, @@ -1280,8 +1302,8 @@ static void subdiv_foreach_loops_regular(SubdivForeachTaskContext *ctx, e2, v3, e3, - u + delta_u * i, - v + delta_v * i, + loop_u, + loop_v, du, dv); v0 = v1; |