diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2018-03-09 17:19:24 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2018-03-09 17:22:25 +0300 |
commit | 970d16b6695bfe6cf08a660f6a1f531ab99c623e (patch) | |
tree | 390bc676b08fc8b1177eb1790e98175ddf3d407b /source/blender/modifiers/intern/MOD_weighted_normal.c | |
parent | 93ef006e3c2a0526550819d8bf4dcbe95016a350 (diff) |
Fix broken 'is vertex in vgroup' check.
Also, better to avoid binary XOR on booleans, you never know how those
are actually stored internally (or how they were generated), and may get
surprising results depending on compiler etc., though with modern
compilers I’d expect this to be safe now?
Diffstat (limited to 'source/blender/modifiers/intern/MOD_weighted_normal.c')
-rw-r--r-- | source/blender/modifiers/intern/MOD_weighted_normal.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/source/blender/modifiers/intern/MOD_weighted_normal.c b/source/blender/modifiers/intern/MOD_weighted_normal.c index 478f3e43eff..847d42ba2bc 100644 --- a/source/blender/modifiers/intern/MOD_weighted_normal.c +++ b/source/blender/modifiers/intern/MOD_weighted_normal.c @@ -32,6 +32,7 @@ #include "DNA_scene_types.h" #include "BKE_cdderivedmesh.h" +#include "BKE_deform.h" #include "BKE_mesh.h" #include "BLI_math.h" @@ -243,9 +244,9 @@ static void apply_weights_vertex_normal( for (; ml_index < ml_index_end; ml_index++) { const int mv_index = mloop[ml_index].v; - const bool vert_of_group = has_vgroup && dvert[mv_index].dw != NULL && dvert[mv_index].dw->def_nr == defgrp_index; + const bool vert_of_group = has_vgroup && defvert_find_index(&dvert[mv_index], defgrp_index) != NULL; - if ((vert_of_group ^ use_invert_vgroup) || !dvert) { + if (!has_vgroup || (vert_of_group && !use_invert_vgroup) || (!vert_of_group && use_invert_vgroup)) { if (use_face_influence && !check_strength(poly_strength[mp_index], &curr_vert_strength[mv_index], &curr_vert_val[mv_index], &vert_loops_count[mv_index], &vert_normals[mv_index])) @@ -281,9 +282,9 @@ static void apply_weights_vertex_normal( float wnor[3]; const int ml_index = mode_pair[i].index; const int mv_index = mloop[ml_index].v; - const bool vert_of_group = has_vgroup && dvert[mv_index].dw != NULL && dvert[mv_index].dw->def_nr == defgrp_index; + const bool vert_of_group = has_vgroup && defvert_find_index(&dvert[mv_index], defgrp_index) != NULL; - if ((vert_of_group ^ use_invert_vgroup) || !dvert) { + if (!has_vgroup || (vert_of_group && !use_invert_vgroup) || (!vert_of_group && use_invert_vgroup)) { if (use_face_influence && !check_strength(poly_strength[loop_to_poly[ml_index]], &curr_vert_strength[mv_index], &curr_vert_val[mv_index], &vert_loops_count[mv_index], &vert_normals[mv_index])) |