diff options
author | Antony Riakiotakis <kalast@gmail.com> | 2015-07-30 15:43:58 +0300 |
---|---|---|
committer | Antony Riakiotakis <kalast@gmail.com> | 2015-07-30 15:43:58 +0300 |
commit | 2ec00ea0c1be1ace7cd0c7b68e43cc8e87dd07c7 (patch) | |
tree | bcea6f830039d7ef67dcd1a9a95b767d2af19958 /source/blender/blenkernel/intern/multires.c | |
parent | 9d335d29c775939b22dffedc303ecce9fec4e52f (diff) |
Move tangents and baking to looptris:
Notes:
* Code in rendering and in game engine will still convert
tangents to a tessface representation. Added code that
takes care of tangent layer only, might be removed
when BGE and rendering goes full mlooptri mode.
* Baking should work discovered some dead code while
I was working on the patch, also tangents are broken
when baking from multires (also in master), but those
are separate issues that can be fixed later.
This should fix T45491 as well
Diffstat (limited to 'source/blender/blenkernel/intern/multires.c')
-rw-r--r-- | source/blender/blenkernel/intern/multires.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/multires.c b/source/blender/blenkernel/intern/multires.c index 0c984c38b8e..9ef5b697079 100644 --- a/source/blender/blenkernel/intern/multires.c +++ b/source/blender/blenkernel/intern/multires.c @@ -2338,12 +2338,12 @@ void multires_topology_changed(Mesh *me) /***************** Multires interpolation stuff *****************/ /* Find per-corner coordinate with given per-face UV coord */ -int mdisp_rot_face_to_crn(const int corners, const int face_side, const float u, const float v, float *x, float *y) +int mdisp_rot_face_to_crn(struct MVert *UNUSED(mvert), struct MPoly *mpoly, struct MLoop *UNUSED(mloop), const struct MLoopTri *UNUSED(lt), const int face_side, const float u, const float v, float *x, float *y) { const float offset = face_side * 0.5f - 0.5f; int S = 0; - if (corners == 4) { + if (mpoly->totloop == 4) { if (u <= offset && v <= offset) S = 0; else if (u > offset && v <= offset) S = 1; else if (u > offset && v > offset) S = 2; @@ -2366,7 +2366,7 @@ int mdisp_rot_face_to_crn(const int corners, const int face_side, const float u, *y = v - offset; } } - else { + else if (mpoly->totloop == 3) { int grid_size = offset; float w = (face_side - 1) - u - v; float W1, W2; @@ -2381,6 +2381,30 @@ int mdisp_rot_face_to_crn(const int corners, const int face_side, const float u, *x = (1 - (2 * W1) / (1 - W2)) * grid_size; *y = (1 - (2 * W2) / (1 - W1)) * grid_size; } + else { + /* the complicated ngon case: find the actual coordinate from + * the barycentric coordinates and finally find the closest vertex + * should work reliably for convex cases only but better than nothing */ + +#if 0 + int minS, i; + float mindist = FLT_MAX; + + for (i = 0; i < mpoly->totloop; i++) { + float len = len_v3v3(NULL, mvert[mloop[mpoly->loopstart + i].v].co); + if (len < mindist) { + mindist = len; + minS = i; + } + } + S = minS; +#endif + /* temp not implemented yet and also not working properly in current master. + * (was worked around by subdividing once) */ + S = 0; + *x = 0; + *y = 0; + } return S; } |