diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenloader/intern/versioning_270.c | 16 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_modifier_types.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_modifier.c | 5 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_normal_edit.c | 22 |
4 files changed, 34 insertions, 11 deletions
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index 0ea4078a5cb..b7b6ace3c1a 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -1189,9 +1189,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) } } } - } - { for (Camera *camera = main->camera.first; camera != NULL; camera = camera->id.next) { if (camera->stereo.pole_merge_angle_from == 0.0f && camera->stereo.pole_merge_angle_to == 0.0f) @@ -1200,5 +1198,19 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main) camera->stereo.pole_merge_angle_to = DEG2RAD(75.0f); } } + + if (!DNA_struct_elem_find(fd->filesdna, "NormalEditModifierData", "float", "mix_limit")) { + Object *ob; + + for (ob = main->object.first; ob; ob = ob->id.next) { + ModifierData *md; + for (md = ob->modifiers.first; md; md = md->next) { + if (md->type == eModifierType_NormalEdit) { + NormalEditModifierData *nemd = (NormalEditModifierData *)md; + nemd->mix_limit = DEG2RADF(180.0f); + } + } + } + } } } diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index 457db70cd28..a58e995f1c6 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -1518,7 +1518,9 @@ typedef struct NormalEditModifierData { short mix_mode; char pad[2]; float mix_factor; + float mix_limit; float offset[3]; + float pad_f1; } NormalEditModifierData; /* NormalEditModifierData.mode */ diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 0c4b3ba485d..5a2113f3f95 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -4602,6 +4602,11 @@ static void rna_def_modifier_normaledit(BlenderRNA *brna) "How much of generated normals to mix with exiting ones", 0.0f, 1.0f); RNA_def_property_update(prop, 0, "rna_Modifier_update"); + prop = RNA_def_float(srna, "mix_limit", 1.0f, 0.0f, DEG2RADF(180.0f), "Max Angle", + "Maximum angle between old and new normals", 0.0f, DEG2RADF(180.0f)); + RNA_def_property_subtype(prop, PROP_ANGLE); + RNA_def_property_update(prop, 0, "rna_Modifier_update"); + prop = RNA_def_property(srna, "vertex_group", PROP_STRING, PROP_NONE); RNA_def_property_string_sdna(prop, NULL, "defgrp_name"); RNA_def_property_ui_text(prop, "Vertex Group", "Vertex group name for selecting/weighting the affected areas"); diff --git a/source/blender/modifiers/intern/MOD_normal_edit.c b/source/blender/modifiers/intern/MOD_normal_edit.c index 355dd6d6677..d386653d2c6 100644 --- a/source/blender/modifiers/intern/MOD_normal_edit.c +++ b/source/blender/modifiers/intern/MOD_normal_edit.c @@ -110,7 +110,7 @@ static void generate_vert_coordinates( /* Note this modifies nos_new in-place. */ static void mix_normals( const float mix_factor, MDeformVert *dvert, const int defgrp_index, const bool use_invert_vgroup, - const short mix_mode, + const float mix_limit, const short mix_mode, const int num_verts, MLoop *mloop, float (*nos_old)[3], float (*nos_new)[3], const int num_loops) { /* Mix with org normals... */ @@ -143,7 +143,9 @@ static void mix_normals( case MOD_NORMALEDIT_MIX_COPY: break; } - interp_v3_v3v3_slerp_safe(*no_new, *no_old, *no_new, fac); + + interp_v3_v3v3_slerp_safe(*no_new, *no_old, *no_new, + (mix_limit < M_PI) ? min_ff(fac, mix_limit / angle_v3v3(*no_new, *no_old)) : fac); } MEM_SAFE_FREE(facs); @@ -186,7 +188,7 @@ static bool polygons_check_flip( static void normalEditModifier_do_radial( NormalEditModifierData *smd, Object *ob, DerivedMesh *dm, short (*clnors)[2], float (*loopnors)[3], float (*polynors)[3], - const short mix_mode, const float mix_factor, + const short mix_mode, const float mix_factor, const float mix_limit, MDeformVert *dvert, const int defgrp_index, const bool use_invert_vgroup, MVert *mvert, const int num_verts, MEdge *medge, const int num_edges, MLoop *mloop, const int num_loops, MPoly *mpoly, const int num_polys) @@ -265,7 +267,7 @@ static void normalEditModifier_do_radial( if (loopnors) { mix_normals(mix_factor, dvert, defgrp_index, use_invert_vgroup, - mix_mode, num_verts, mloop, loopnors, nos, num_loops); + mix_limit, mix_mode, num_verts, mloop, loopnors, nos, num_loops); } if (polygons_check_flip(mloop, nos, dm->getLoopDataLayout(dm), mpoly, polynors, num_polys)) { @@ -283,7 +285,7 @@ static void normalEditModifier_do_radial( static void normalEditModifier_do_directional( NormalEditModifierData *smd, Object *ob, DerivedMesh *dm, short (*clnors)[2], float (*loopnors)[3], float (*polynors)[3], - const short mix_mode, const float mix_factor, + const short mix_mode, const float mix_factor, const float mix_limit, MDeformVert *dvert, const int defgrp_index, const bool use_invert_vgroup, MVert *mvert, const int num_verts, MEdge *medge, const int num_edges, MLoop *mloop, const int num_loops, MPoly *mpoly, const int num_polys) @@ -342,7 +344,7 @@ static void normalEditModifier_do_directional( if (loopnors) { mix_normals(mix_factor, dvert, defgrp_index, use_invert_vgroup, - mix_mode, num_verts, mloop, loopnors, nos, num_loops); + mix_limit, mix_mode, num_verts, mloop, loopnors, nos, num_loops); } if (polygons_check_flip(mloop, nos, dm->getLoopDataLayout(dm), mpoly, polynors, num_polys)) { @@ -384,7 +386,8 @@ static DerivedMesh *normalEditModifier_do(NormalEditModifierData *smd, Object *o const bool use_invert_vgroup = ((smd->flag & MOD_NORMALEDIT_INVERT_VGROUP) != 0); const bool use_current_clnors = !((smd->mix_mode == MOD_NORMALEDIT_MIX_COPY) && (smd->mix_factor == 1.0f) && - (smd->defgrp_name[0] == '\0')); + (smd->defgrp_name[0] == '\0') && + (smd->mix_limit == M_PI)); int defgrp_index; MDeformVert *dvert; @@ -439,13 +442,13 @@ static DerivedMesh *normalEditModifier_do(NormalEditModifierData *smd, Object *o if (smd->mode == MOD_NORMALEDIT_MODE_RADIAL) { normalEditModifier_do_radial( smd, ob, dm, clnors, loopnors, polynors, - smd->mix_mode, smd->mix_factor, dvert, defgrp_index, use_invert_vgroup, + smd->mix_mode, smd->mix_factor, smd->mix_limit, dvert, defgrp_index, use_invert_vgroup, mvert, num_verts, medge, num_edges, mloop, num_loops, mpoly, num_polys); } else if (smd->mode == MOD_NORMALEDIT_MODE_DIRECTIONAL) { normalEditModifier_do_directional( smd, ob, dm, clnors, loopnors, polynors, - smd->mix_mode, smd->mix_factor, dvert, defgrp_index, use_invert_vgroup, + smd->mix_mode, smd->mix_factor, smd->mix_limit, dvert, defgrp_index, use_invert_vgroup, mvert, num_verts, medge, num_edges, mloop, num_loops, mpoly, num_polys); } @@ -464,6 +467,7 @@ static void initData(ModifierData *md) smd->mix_mode = MOD_NORMALEDIT_MIX_COPY; smd->mix_factor = 1.0f; + smd->mix_limit = M_PI; } static void copyData(ModifierData *md, ModifierData *target) |