diff options
Diffstat (limited to 'source/blender/modifiers')
44 files changed, 203 insertions, 216 deletions
diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c index 15ad361a262..43f650e025c 100644 --- a/source/blender/modifiers/intern/MOD_armature.c +++ b/source/blender/modifiers/intern/MOD_armature.c @@ -125,7 +125,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte DEG_add_object_relation(ctx->node, amd->object, DEG_OB_COMP_TRANSFORM, "Armature Modifier"); } - DEG_add_modifier_to_transform_relation(ctx->node, "Armature Modifier"); + DEG_add_depends_on_transform_relation(ctx->node, "Armature Modifier"); } static void deformVerts(ModifierData *md, @@ -211,8 +211,7 @@ static void deformMatrices(ModifierData *md, int verts_num) { ArmatureModifierData *amd = (ArmatureModifierData *)md; - Mesh *mesh_src = MOD_deform_mesh_eval_get( - ctx->object, NULL, mesh, NULL, verts_num, false, false); + Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false); BKE_armature_deform_coords_with_mesh(amd->object, ctx->object, diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c index 569b0fd0fda..b29b34436ca 100644 --- a/source/blender/modifiers/intern/MOD_array.c +++ b/source/blender/modifiers/intern/MOD_array.c @@ -93,7 +93,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte } if (need_transform_dependency) { - DEG_add_modifier_to_transform_relation(ctx->node, "Array Modifier"); + DEG_add_depends_on_transform_relation(ctx->node, "Array Modifier"); } } diff --git a/source/blender/modifiers/intern/MOD_boolean.cc b/source/blender/modifiers/intern/MOD_boolean.cc index aa64c1f83bc..685338cf351 100644 --- a/source/blender/modifiers/intern/MOD_boolean.cc +++ b/source/blender/modifiers/intern/MOD_boolean.cc @@ -117,7 +117,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte DEG_add_collection_geometry_relation(ctx->node, col, "Boolean Modifier"); } /* We need own transformation as well. */ - DEG_add_modifier_to_transform_relation(ctx->node, "Boolean Modifier"); + DEG_add_depends_on_transform_relation(ctx->node, "Boolean Modifier"); } static Mesh *get_quick_mesh( diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.c index 9aaf7fead36..e17a612376d 100644 --- a/source/blender/modifiers/intern/MOD_cast.c +++ b/source/blender/modifiers/intern/MOD_cast.c @@ -87,7 +87,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte CastModifierData *cmd = (CastModifierData *)md; if (cmd->object != NULL) { DEG_add_object_relation(ctx->node, cmd->object, DEG_OB_COMP_TRANSFORM, "Cast Modifier"); - DEG_add_modifier_to_transform_relation(ctx->node, "Cast Modifier"); + DEG_add_depends_on_transform_relation(ctx->node, "Cast Modifier"); } } @@ -467,7 +467,7 @@ static void deformVerts(ModifierData *md, if (ctx->object->type == OB_MESH && cmd->defgrp_name[0] != '\0') { /* mesh_src is only needed for vgroups. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false); } if (cmd->type == MOD_CAST_TYPE_CUBOID) { @@ -493,15 +493,14 @@ static void deformVertsEM(ModifierData *md, Mesh *mesh_src = NULL; if (cmd->defgrp_name[0] != '\0') { - mesh_src = MOD_deform_mesh_eval_get( - ctx->object, editData, mesh, NULL, verts_num, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, verts_num, false); } if (mesh && mesh->runtime.wrapper_type == ME_WRAPPER_TYPE_MDATA) { BLI_assert(mesh->totvert == verts_num); } - /* TODO(Campbell): use edit-mode data only (remove this line). */ + /* TODO(@campbellbarton): use edit-mode data only (remove this line). */ if (mesh_src != NULL) { BKE_mesh_wrapper_ensure_mdata(mesh_src); } diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c index cc0bd87d614..11bbe8dc83e 100644 --- a/source/blender/modifiers/intern/MOD_cloth.c +++ b/source/blender/modifiers/intern/MOD_cloth.c @@ -94,7 +94,7 @@ static void deformVerts(ModifierData *md, } if (mesh == NULL) { - mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, NULL, NULL, verts_num, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, NULL, NULL, verts_num, false); } else { /* Not possible to use get_mesh() in this case as we'll modify its vertices @@ -144,7 +144,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte DEG_add_forcefield_relations( ctx->node, ctx->object, clmd->sim_parms->effector_weights, true, 0, "Cloth Field"); } - DEG_add_modifier_to_transform_relation(ctx->node, "Cloth Modifier"); + DEG_add_depends_on_transform_relation(ctx->node, "Cloth Modifier"); } static void requiredDataMask(Object *UNUSED(ob), diff --git a/source/blender/modifiers/intern/MOD_collision.c b/source/blender/modifiers/intern/MOD_collision.c index 74cb4ac700a..42a8ba804ed 100644 --- a/source/blender/modifiers/intern/MOD_collision.c +++ b/source/blender/modifiers/intern/MOD_collision.c @@ -107,7 +107,7 @@ static void deformVerts(ModifierData *md, } if (mesh == NULL) { - mesh_src = MOD_deform_mesh_eval_get(ob, NULL, NULL, NULL, verts_num, false, false); + mesh_src = MOD_deform_mesh_eval_get(ob, NULL, NULL, NULL, verts_num, false); } else { /* Not possible to use get_mesh() in this case as we'll modify its vertices @@ -236,7 +236,7 @@ static void deformVerts(ModifierData *md, static void updateDepsgraph(ModifierData *UNUSED(md), const ModifierUpdateDepsgraphContext *ctx) { - DEG_add_modifier_to_transform_relation(ctx->node, "Collision Modifier"); + DEG_add_depends_on_transform_relation(ctx->node, "Collision Modifier"); } static void panel_draw(const bContext *UNUSED(C), Panel *panel) diff --git a/source/blender/modifiers/intern/MOD_correctivesmooth.c b/source/blender/modifiers/intern/MOD_correctivesmooth.c index 2beb1be6749..4df0479372f 100644 --- a/source/blender/modifiers/intern/MOD_correctivesmooth.c +++ b/source/blender/modifiers/intern/MOD_correctivesmooth.c @@ -729,8 +729,7 @@ static void deformVerts(ModifierData *md, float (*vertexCos)[3], int verts_num) { - Mesh *mesh_src = MOD_deform_mesh_eval_get( - ctx->object, NULL, mesh, NULL, verts_num, false, false); + Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false); correctivesmooth_modifier_do( md, ctx->depsgraph, ctx->object, mesh_src, vertexCos, (uint)verts_num, NULL); @@ -747,10 +746,9 @@ static void deformVertsEM(ModifierData *md, float (*vertexCos)[3], int verts_num) { - Mesh *mesh_src = MOD_deform_mesh_eval_get( - ctx->object, editData, mesh, NULL, verts_num, false, false); + Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, verts_num, false); - /* TODO(Campbell): use edit-mode data only (remove this line). */ + /* TODO(@campbellbarton): use edit-mode data only (remove this line). */ if (mesh_src != NULL) { BKE_mesh_wrapper_ensure_mdata(mesh_src); } diff --git a/source/blender/modifiers/intern/MOD_curve.c b/source/blender/modifiers/intern/MOD_curve.c index 48a59f4d949..af639915bd8 100644 --- a/source/blender/modifiers/intern/MOD_curve.c +++ b/source/blender/modifiers/intern/MOD_curve.c @@ -97,7 +97,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte DEG_add_special_eval_flag(ctx->node, &cmd->object->id, DAG_EVAL_NEED_CURVE_PATH); } - DEG_add_modifier_to_transform_relation(ctx->node, "Curve Modifier"); + DEG_add_depends_on_transform_relation(ctx->node, "Curve Modifier"); } static void deformVerts(ModifierData *md, @@ -111,7 +111,7 @@ static void deformVerts(ModifierData *md, if (ctx->object->type == OB_MESH && cmd->name[0] != '\0') { /* mesh_src is only needed for vgroups. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false); } struct MDeformVert *dvert = NULL; diff --git a/source/blender/modifiers/intern/MOD_datatransfer.c b/source/blender/modifiers/intern/MOD_datatransfer.c index e9f1cf47e38..7590318c52b 100644 --- a/source/blender/modifiers/intern/MOD_datatransfer.c +++ b/source/blender/modifiers/intern/MOD_datatransfer.c @@ -129,7 +129,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte if (dtmd->flags & MOD_DATATRANSFER_OBSRC_TRANSFORM) { DEG_add_object_relation( ctx->node, dtmd->ob_source, DEG_OB_COMP_TRANSFORM, "DataTransfer Modifier"); - DEG_add_modifier_to_transform_relation(ctx->node, "DataTransfer Modifier"); + DEG_add_depends_on_transform_relation(ctx->node, "DataTransfer Modifier"); } } } @@ -211,7 +211,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * dtmd->defgrp_name, invert_vgroup, &reports)) { - result->runtime.is_original = false; + result->runtime.is_original_bmesh = false; } if (BKE_reports_contain(&reports, RPT_ERROR)) { diff --git a/source/blender/modifiers/intern/MOD_decimate.c b/source/blender/modifiers/intern/MOD_decimate.c index 3df4fbcbea8..55d9d148d10 100644 --- a/source/blender/modifiers/intern/MOD_decimate.c +++ b/source/blender/modifiers/intern/MOD_decimate.c @@ -201,11 +201,12 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * updateFaceCount(ctx, dmd, bm->totface); - result = BKE_mesh_from_bmesh_for_eval_nomain(bm, NULL, mesh); /* make sure we never alloc'd these */ BLI_assert(bm->vtoolflagpool == NULL && bm->etoolflagpool == NULL && bm->ftoolflagpool == NULL); BLI_assert(bm->vtable == NULL && bm->etable == NULL && bm->ftable == NULL); + result = BKE_mesh_from_bmesh_for_eval_nomain(bm, NULL, mesh); + BM_mesh_free(bm); #ifdef USE_TIMEIT diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c index 5289fc42e21..367809953b6 100644 --- a/source/blender/modifiers/intern/MOD_displace.c +++ b/source/blender/modifiers/intern/MOD_displace.c @@ -142,7 +142,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte } if (need_transform_relation) { - DEG_add_modifier_to_transform_relation(ctx->node, "Displace Modifier"); + DEG_add_depends_on_transform_relation(ctx->node, "Displace Modifier"); } } @@ -372,8 +372,7 @@ static void deformVerts(ModifierData *md, float (*vertexCos)[3], int verts_num) { - Mesh *mesh_src = MOD_deform_mesh_eval_get( - ctx->object, NULL, mesh, NULL, verts_num, false, false); + Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false); displaceModifier_do((DisplaceModifierData *)md, ctx, mesh_src, vertexCos, verts_num); @@ -389,10 +388,9 @@ static void deformVertsEM(ModifierData *md, float (*vertexCos)[3], int verts_num) { - Mesh *mesh_src = MOD_deform_mesh_eval_get( - ctx->object, editData, mesh, NULL, verts_num, false, false); + Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, verts_num, false); - /* TODO(Campbell): use edit-mode data only (remove this line). */ + /* TODO(@campbellbarton): use edit-mode data only (remove this line). */ if (mesh_src != NULL) { BKE_mesh_wrapper_ensure_mdata(mesh_src); } diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c index ff0616fd288..e243c32173d 100644 --- a/source/blender/modifiers/intern/MOD_explode.c +++ b/source/blender/modifiers/intern/MOD_explode.c @@ -742,7 +742,7 @@ static Mesh *cutEdges(ExplodeModifierData *emd, Mesh *mesh) /* override original facepa (original pointer is saved in caller function) */ - /* TODO(campbell): `(totfsplit * 2)` over allocation is used since the quads are + /* TODO(@campbellbarton): `(totfsplit * 2)` over allocation is used since the quads are * later interpreted as tri's, for this to work right I think we probably * have to stop using tessface. */ diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c index 3c4e6b0d90f..979a08483e1 100644 --- a/source/blender/modifiers/intern/MOD_hook.c +++ b/source/blender/modifiers/intern/MOD_hook.c @@ -122,7 +122,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte DEG_add_object_relation(ctx->node, hmd->object, DEG_OB_COMP_TRANSFORM, "Hook Modifier"); } /* We need own transformation as well. */ - DEG_add_modifier_to_transform_relation(ctx->node, "Hook Modifier"); + DEG_add_depends_on_transform_relation(ctx->node, "Hook Modifier"); } struct HookData_cb { @@ -430,8 +430,7 @@ static void deformVerts(struct ModifierData *md, int verts_num) { HookModifierData *hmd = (HookModifierData *)md; - Mesh *mesh_src = MOD_deform_mesh_eval_get( - ctx->object, NULL, mesh, NULL, verts_num, false, false); + Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false); deformVerts_do(hmd, ctx, ctx->object, mesh_src, NULL, vertexCos, verts_num); diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.c b/source/blender/modifiers/intern/MOD_laplaciandeform.c index e29098eb218..6333eb699b3 100644 --- a/source/blender/modifiers/intern/MOD_laplaciandeform.c +++ b/source/blender/modifiers/intern/MOD_laplaciandeform.c @@ -764,8 +764,7 @@ static void deformVerts(ModifierData *md, float (*vertexCos)[3], int verts_num) { - Mesh *mesh_src = MOD_deform_mesh_eval_get( - ctx->object, NULL, mesh, NULL, verts_num, false, false); + Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false); LaplacianDeformModifier_do( (LaplacianDeformModifierData *)md, ctx->object, mesh_src, vertexCos, verts_num); @@ -782,10 +781,9 @@ static void deformVertsEM(ModifierData *md, float (*vertexCos)[3], int verts_num) { - Mesh *mesh_src = MOD_deform_mesh_eval_get( - ctx->object, editData, mesh, NULL, verts_num, false, false); + Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, verts_num, false); - /* TODO(Campbell): use edit-mode data only (remove this line). */ + /* TODO(@campbellbarton): use edit-mode data only (remove this line). */ if (mesh_src != NULL) { BKE_mesh_wrapper_ensure_mdata(mesh_src); } diff --git a/source/blender/modifiers/intern/MOD_laplaciansmooth.c b/source/blender/modifiers/intern/MOD_laplaciansmooth.c index 2cce0c14e4c..c42f7b33919 100644 --- a/source/blender/modifiers/intern/MOD_laplaciansmooth.c +++ b/source/blender/modifiers/intern/MOD_laplaciansmooth.c @@ -535,7 +535,7 @@ static void deformVerts(ModifierData *md, return; } - mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false); laplaciansmoothModifier_do( (LaplacianSmoothModifierData *)md, ctx->object, mesh_src, vertexCos, verts_num); @@ -558,9 +558,9 @@ static void deformVertsEM(ModifierData *md, return; } - mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, verts_num, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, verts_num, false); - /* TODO(Campbell): use edit-mode data only (remove this line). */ + /* TODO(@campbellbarton): use edit-mode data only (remove this line). */ if (mesh_src != NULL) { BKE_mesh_wrapper_ensure_mdata(mesh_src); } diff --git a/source/blender/modifiers/intern/MOD_lattice.c b/source/blender/modifiers/intern/MOD_lattice.c index 0e1994eed36..81b60b660c6 100644 --- a/source/blender/modifiers/intern/MOD_lattice.c +++ b/source/blender/modifiers/intern/MOD_lattice.c @@ -87,7 +87,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte DEG_add_object_relation(ctx->node, lmd->object, DEG_OB_COMP_GEOMETRY, "Lattice Modifier"); DEG_add_object_relation(ctx->node, lmd->object, DEG_OB_COMP_TRANSFORM, "Lattice Modifier"); } - DEG_add_modifier_to_transform_relation(ctx->node, "Lattice Modifier"); + DEG_add_depends_on_transform_relation(ctx->node, "Lattice Modifier"); } static void deformVerts(ModifierData *md, @@ -98,7 +98,7 @@ static void deformVerts(ModifierData *md, { LatticeModifierData *lmd = (LatticeModifierData *)md; struct Mesh *mesh_src = MOD_deform_mesh_eval_get( - ctx->object, NULL, mesh, NULL, verts_num, false, false); + ctx->object, NULL, mesh, NULL, verts_num, false); MOD_previous_vcos_store(md, vertexCos); /* if next modifier needs original vertices */ diff --git a/source/blender/modifiers/intern/MOD_mask.cc b/source/blender/modifiers/intern/MOD_mask.cc index fac3ea36537..e48a949baf4 100644 --- a/source/blender/modifiers/intern/MOD_mask.cc +++ b/source/blender/modifiers/intern/MOD_mask.cc @@ -86,7 +86,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte /* TODO(sergey): Is it a proper relation here? */ DEG_add_object_relation(ctx->node, mmd->ob_arm, DEG_OB_COMP_TRANSFORM, "Mask Modifier"); arm->flag |= ARM_HAS_VIZ_DEPS; - DEG_add_modifier_to_transform_relation(ctx->node, "Mask Modifier"); + DEG_add_depends_on_transform_relation(ctx->node, "Mask Modifier"); } } diff --git a/source/blender/modifiers/intern/MOD_mesh_to_volume.cc b/source/blender/modifiers/intern/MOD_mesh_to_volume.cc index 9ac410eb3de..0471beadcc1 100644 --- a/source/blender/modifiers/intern/MOD_mesh_to_volume.cc +++ b/source/blender/modifiers/intern/MOD_mesh_to_volume.cc @@ -60,7 +60,7 @@ static void initData(ModifierData *md) static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx) { MeshToVolumeModifierData *mvmd = reinterpret_cast<MeshToVolumeModifierData *>(md); - DEG_add_modifier_to_transform_relation(ctx->node, "Mesh to Volume Modifier"); + DEG_add_depends_on_transform_relation(ctx->node, "Mesh to Volume Modifier"); if (mvmd->object) { DEG_add_object_relation( ctx->node, mvmd->object, DEG_OB_COMP_GEOMETRY, "Mesh to Volume Modifier"); diff --git a/source/blender/modifiers/intern/MOD_meshcache.c b/source/blender/modifiers/intern/MOD_meshcache.c index 8dfdd07ace9..3e81f987da3 100644 --- a/source/blender/modifiers/intern/MOD_meshcache.c +++ b/source/blender/modifiers/intern/MOD_meshcache.c @@ -297,7 +297,7 @@ static void deformVerts(ModifierData *md, if (ctx->object->type == OB_MESH && mcmd->defgrp_name[0] != '\0') { /* `mesh_src` is only needed for vertex groups. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false); } meshcache_do(mcmd, scene, ctx->object, mesh_src, vertexCos, verts_num); @@ -320,8 +320,7 @@ static void deformVertsEM(ModifierData *md, if (ctx->object->type == OB_MESH && mcmd->defgrp_name[0] != '\0') { /* `mesh_src` is only needed for vertex groups. */ - mesh_src = MOD_deform_mesh_eval_get( - ctx->object, editData, mesh, NULL, verts_num, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, verts_num, false); } if (mesh_src != NULL) { BKE_mesh_wrapper_ensure_mdata(mesh_src); diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c index 334f5d75279..d1df86b1010 100644 --- a/source/blender/modifiers/intern/MOD_meshdeform.c +++ b/source/blender/modifiers/intern/MOD_meshdeform.c @@ -160,7 +160,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte DEG_add_object_relation(ctx->node, mmd->object, DEG_OB_COMP_GEOMETRY, "Mesh Deform Modifier"); } /* We need own transformation as well. */ - DEG_add_modifier_to_transform_relation(ctx->node, "Mesh Deform Modifier"); + DEG_add_depends_on_transform_relation(ctx->node, "Mesh Deform Modifier"); } static float meshdeform_dynamic_bind(MeshDeformModifierData *mmd, float (*dco)[3], float vec[3]) @@ -444,8 +444,7 @@ static void deformVerts(ModifierData *md, float (*vertexCos)[3], int verts_num) { - Mesh *mesh_src = MOD_deform_mesh_eval_get( - ctx->object, NULL, mesh, NULL, verts_num, false, false); + Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false); MOD_previous_vcos_store(md, vertexCos); /* if next modifier needs original vertices */ @@ -463,10 +462,9 @@ static void deformVertsEM(ModifierData *md, float (*vertexCos)[3], int verts_num) { - Mesh *mesh_src = MOD_deform_mesh_eval_get( - ctx->object, editData, mesh, NULL, verts_num, false, false); + Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, verts_num, false); - /* TODO(Campbell): use edit-mode data only (remove this line). */ + /* TODO(@campbellbarton): use edit-mode data only (remove this line). */ if (mesh_src != NULL) { BKE_mesh_wrapper_ensure_mdata(mesh_src); } diff --git a/source/blender/modifiers/intern/MOD_mirror.c b/source/blender/modifiers/intern/MOD_mirror.c index 5f095a72dca..f1a36c04453 100644 --- a/source/blender/modifiers/intern/MOD_mirror.c +++ b/source/blender/modifiers/intern/MOD_mirror.c @@ -62,7 +62,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte MirrorModifierData *mmd = (MirrorModifierData *)md; if (mmd->mirror_ob != NULL) { DEG_add_object_relation(ctx->node, mmd->mirror_ob, DEG_OB_COMP_TRANSFORM, "Mirror Modifier"); - DEG_add_modifier_to_transform_relation(ctx->node, "Mirror Modifier"); + DEG_add_depends_on_transform_relation(ctx->node, "Mirror Modifier"); } } diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc index 223e4b757b7..9c95561904a 100644 --- a/source/blender/modifiers/intern/MOD_nodes.cc +++ b/source/blender/modifiers/intern/MOD_nodes.cc @@ -40,7 +40,7 @@ #include "BKE_geometry_fields.hh" #include "BKE_geometry_set_instances.hh" #include "BKE_global.h" -#include "BKE_idprop.h" +#include "BKE_idprop.hh" #include "BKE_lib_id.h" #include "BKE_lib_query.h" #include "BKE_main.h" @@ -307,7 +307,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte } if (needs_own_transform_relation) { - DEG_add_modifier_to_transform_relation(ctx->node, "Nodes Modifier"); + DEG_add_depends_on_transform_relation(ctx->node, "Nodes Modifier"); } } @@ -416,15 +416,16 @@ static bool input_has_attribute_toggle(const bNodeTree &node_tree, const int soc return field_interface.inputs[socket_index] != InputSocketFieldType::None; } -static IDProperty *id_property_create_from_socket(const bNodeSocket &socket) +static std::unique_ptr<IDProperty, blender::bke::idprop::IDPropertyDeleter> +id_property_create_from_socket(const bNodeSocket &socket) { + using namespace blender; switch (socket.type) { case SOCK_FLOAT: { - bNodeSocketValueFloat *value = (bNodeSocketValueFloat *)socket.default_value; - IDPropertyTemplate idprop = {0}; - idprop.f = value->value; - IDProperty *property = IDP_New(IDP_FLOAT, &idprop, socket.identifier); - IDPropertyUIDataFloat *ui_data = (IDPropertyUIDataFloat *)IDP_ui_data_ensure(property); + const bNodeSocketValueFloat *value = static_cast<const bNodeSocketValueFloat *>( + socket.default_value); + auto property = bke::idprop::create(socket.identifier, value->value); + IDPropertyUIDataFloat *ui_data = (IDPropertyUIDataFloat *)IDP_ui_data_ensure(property.get()); ui_data->base.rna_subtype = value->subtype; ui_data->min = ui_data->soft_min = (double)value->min; ui_data->max = ui_data->soft_max = (double)value->max; @@ -432,11 +433,10 @@ static IDProperty *id_property_create_from_socket(const bNodeSocket &socket) return property; } case SOCK_INT: { - bNodeSocketValueInt *value = (bNodeSocketValueInt *)socket.default_value; - IDPropertyTemplate idprop = {0}; - idprop.i = value->value; - IDProperty *property = IDP_New(IDP_INT, &idprop, socket.identifier); - IDPropertyUIDataInt *ui_data = (IDPropertyUIDataInt *)IDP_ui_data_ensure(property); + const bNodeSocketValueInt *value = static_cast<const bNodeSocketValueInt *>( + socket.default_value); + auto property = bke::idprop::create(socket.identifier, value->value); + IDPropertyUIDataInt *ui_data = (IDPropertyUIDataInt *)IDP_ui_data_ensure(property.get()); ui_data->base.rna_subtype = value->subtype; ui_data->min = ui_data->soft_min = value->min; ui_data->max = ui_data->soft_max = value->max; @@ -444,13 +444,11 @@ static IDProperty *id_property_create_from_socket(const bNodeSocket &socket) return property; } case SOCK_VECTOR: { - bNodeSocketValueVector *value = (bNodeSocketValueVector *)socket.default_value; - IDPropertyTemplate idprop = {0}; - idprop.array.len = 3; - idprop.array.type = IDP_FLOAT; - IDProperty *property = IDP_New(IDP_ARRAY, &idprop, socket.identifier); - copy_v3_v3((float *)IDP_Array(property), value->value); - IDPropertyUIDataFloat *ui_data = (IDPropertyUIDataFloat *)IDP_ui_data_ensure(property); + const bNodeSocketValueVector *value = static_cast<const bNodeSocketValueVector *>( + socket.default_value); + auto property = bke::idprop::create( + socket.identifier, Span<float>{value->value[0], value->value[1], value->value[2]}); + IDPropertyUIDataFloat *ui_data = (IDPropertyUIDataFloat *)IDP_ui_data_ensure(property.get()); ui_data->base.rna_subtype = value->subtype; ui_data->min = ui_data->soft_min = (double)value->min; ui_data->max = ui_data->soft_max = (double)value->max; @@ -462,13 +460,12 @@ static IDProperty *id_property_create_from_socket(const bNodeSocket &socket) return property; } case SOCK_RGBA: { - bNodeSocketValueRGBA *value = (bNodeSocketValueRGBA *)socket.default_value; - IDPropertyTemplate idprop = {0}; - idprop.array.len = 4; - idprop.array.type = IDP_FLOAT; - IDProperty *property = IDP_New(IDP_ARRAY, &idprop, socket.identifier); - copy_v4_v4((float *)IDP_Array(property), value->value); - IDPropertyUIDataFloat *ui_data = (IDPropertyUIDataFloat *)IDP_ui_data_ensure(property); + const bNodeSocketValueRGBA *value = static_cast<const bNodeSocketValueRGBA *>( + socket.default_value); + auto property = bke::idprop::create( + socket.identifier, + Span<float>{value->value[0], value->value[1], value->value[2], value->value[3]}); + IDPropertyUIDataFloat *ui_data = (IDPropertyUIDataFloat *)IDP_ui_data_ensure(property.get()); ui_data->base.rna_subtype = PROP_COLOR; ui_data->default_array = (double *)MEM_mallocN(sizeof(double[4]), __func__); ui_data->default_array_len = 4; @@ -482,53 +479,48 @@ static IDProperty *id_property_create_from_socket(const bNodeSocket &socket) return property; } case SOCK_BOOLEAN: { - bNodeSocketValueBoolean *value = (bNodeSocketValueBoolean *)socket.default_value; - IDPropertyTemplate idprop = {0}; - idprop.i = value->value != 0; - IDProperty *property = IDP_New(IDP_INT, &idprop, socket.identifier); - IDPropertyUIDataInt *ui_data = (IDPropertyUIDataInt *)IDP_ui_data_ensure(property); + const bNodeSocketValueBoolean *value = static_cast<const bNodeSocketValueBoolean *>( + socket.default_value); + auto property = bke::idprop::create(socket.identifier, int(value->value)); + IDPropertyUIDataInt *ui_data = (IDPropertyUIDataInt *)IDP_ui_data_ensure(property.get()); ui_data->min = ui_data->soft_min = 0; ui_data->max = ui_data->soft_max = 1; ui_data->default_value = value->value != 0; return property; } case SOCK_STRING: { - bNodeSocketValueString *value = (bNodeSocketValueString *)socket.default_value; - IDProperty *property = IDP_NewString( - value->value, socket.identifier, BLI_strnlen(value->value, sizeof(value->value)) + 1); - IDPropertyUIDataString *ui_data = (IDPropertyUIDataString *)IDP_ui_data_ensure(property); + const bNodeSocketValueString *value = static_cast<const bNodeSocketValueString *>( + socket.default_value); + auto property = bke::idprop::create(socket.identifier, value->value); + IDPropertyUIDataString *ui_data = (IDPropertyUIDataString *)IDP_ui_data_ensure( + property.get()); ui_data->default_value = BLI_strdup(value->value); return property; } case SOCK_OBJECT: { - bNodeSocketValueObject *value = (bNodeSocketValueObject *)socket.default_value; - IDPropertyTemplate idprop = {0}; - idprop.id = (ID *)value->value; - return IDP_New(IDP_ID, &idprop, socket.identifier); + const bNodeSocketValueObject *value = static_cast<const bNodeSocketValueObject *>( + socket.default_value); + return bke::idprop::create(socket.identifier, reinterpret_cast<ID *>(value->value)); } case SOCK_COLLECTION: { - bNodeSocketValueCollection *value = (bNodeSocketValueCollection *)socket.default_value; - IDPropertyTemplate idprop = {0}; - idprop.id = (ID *)value->value; - return IDP_New(IDP_ID, &idprop, socket.identifier); + const bNodeSocketValueCollection *value = static_cast<const bNodeSocketValueCollection *>( + socket.default_value); + return bke::idprop::create(socket.identifier, reinterpret_cast<ID *>(value->value)); } case SOCK_TEXTURE: { - bNodeSocketValueTexture *value = (bNodeSocketValueTexture *)socket.default_value; - IDPropertyTemplate idprop = {0}; - idprop.id = (ID *)value->value; - return IDP_New(IDP_ID, &idprop, socket.identifier); + const bNodeSocketValueTexture *value = static_cast<const bNodeSocketValueTexture *>( + socket.default_value); + return bke::idprop::create(socket.identifier, reinterpret_cast<ID *>(value->value)); } case SOCK_IMAGE: { - bNodeSocketValueImage *value = (bNodeSocketValueImage *)socket.default_value; - IDPropertyTemplate idprop = {0}; - idprop.id = (ID *)value->value; - return IDP_New(IDP_ID, &idprop, socket.identifier); + const bNodeSocketValueImage *value = static_cast<const bNodeSocketValueImage *>( + socket.default_value); + return bke::idprop::create(socket.identifier, reinterpret_cast<ID *>(value->value)); } case SOCK_MATERIAL: { - bNodeSocketValueMaterial *value = (bNodeSocketValueMaterial *)socket.default_value; - IDPropertyTemplate idprop = {0}; - idprop.id = (ID *)value->value; - return IDP_New(IDP_ID, &idprop, socket.identifier); + const bNodeSocketValueMaterial *value = static_cast<const bNodeSocketValueMaterial *>( + socket.default_value); + return bke::idprop::create(socket.identifier, reinterpret_cast<ID *>(value->value)); } } return nullptr; @@ -658,7 +650,7 @@ void MOD_nodes_update_interface(Object *object, NodesModifierData *nmd) int socket_index; LISTBASE_FOREACH_INDEX (bNodeSocket *, socket, &nmd->node_group->inputs, socket_index) { - IDProperty *new_prop = id_property_create_from_socket(*socket); + IDProperty *new_prop = id_property_create_from_socket(*socket).release(); if (new_prop == nullptr) { /* Out of the set of supported input sockets, only * geometry sockets aren't added to the modifier. */ diff --git a/source/blender/modifiers/intern/MOD_nodes_evaluator.cc b/source/blender/modifiers/intern/MOD_nodes_evaluator.cc index e43d2b4ad85..5cf4e21ea68 100644 --- a/source/blender/modifiers/intern/MOD_nodes_evaluator.cc +++ b/source/blender/modifiers/intern/MOD_nodes_evaluator.cc @@ -1863,6 +1863,7 @@ bool NodeParamsProvider::lazy_require_input(StringRef identifier) void NodeParamsProvider::set_input_unused(StringRef identifier) { + BLI_assert(node_supports_laziness(this->dnode)); const DInputSocket socket = this->dnode.input_by_identifier(identifier); BLI_assert(socket); diff --git a/source/blender/modifiers/intern/MOD_normal_edit.c b/source/blender/modifiers/intern/MOD_normal_edit.c index 09bc9546325..5a92aac6cda 100644 --- a/source/blender/modifiers/intern/MOD_normal_edit.c +++ b/source/blender/modifiers/intern/MOD_normal_edit.c @@ -616,7 +616,7 @@ static Mesh *normalEditModifier_do(NormalEditModifierData *enmd, MEM_SAFE_FREE(loopnors); - result->runtime.is_original = false; + result->runtime.is_original_bmesh = false; return result; } @@ -670,7 +670,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte NormalEditModifierData *enmd = (NormalEditModifierData *)md; if (enmd->target) { DEG_add_object_relation(ctx->node, enmd->target, DEG_OB_COMP_TRANSFORM, "NormalEdit Modifier"); - DEG_add_modifier_to_transform_relation(ctx->node, "NormalEdit Modifier"); + DEG_add_depends_on_transform_relation(ctx->node, "NormalEdit Modifier"); } } diff --git a/source/blender/modifiers/intern/MOD_particlesystem.cc b/source/blender/modifiers/intern/MOD_particlesystem.cc index 7f7465947f9..0c04c6fc062 100644 --- a/source/blender/modifiers/intern/MOD_particlesystem.cc +++ b/source/blender/modifiers/intern/MOD_particlesystem.cc @@ -119,8 +119,7 @@ static void deformVerts(ModifierData *md, } if (mesh_src == nullptr) { - mesh_src = MOD_deform_mesh_eval_get( - ctx->object, nullptr, nullptr, vertexCos, verts_num, false, true); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, nullptr, nullptr, vertexCos, verts_num, true); if (mesh_src == nullptr) { return; } diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c index 9588b9acd3b..6095be48f8f 100644 --- a/source/blender/modifiers/intern/MOD_screw.c +++ b/source/blender/modifiers/intern/MOD_screw.c @@ -52,13 +52,18 @@ static void initData(ModifierData *md) #include "BLI_strict_flags.h" -/* used for gathering edge connectivity */ +/** Used for gathering edge connectivity. */ typedef struct ScrewVertConnect { - float dist; /* distance from the center axis */ - float co[3]; /* location relative to the transformed axis */ - float no[3]; /* calc normal of the vertex */ - uint v[2]; /* 2 verts on either side of this one */ - MEdge *e[2]; /* edges on either side, a bit of a waste since each edge ref's 2 edges */ + /** Distance from the center axis. */ + float dist_sq; + /** Location relative to the transformed axis. */ + float co[3]; + /** Calc normal of the vertex. */ + float no[3]; + /** 2 verts on either side of this one. */ + uint v[2]; + /** Edges on either side, a bit of a waste since each edge ref's 2 edges. */ + MEdge *e[2]; char flag; } ScrewVertConnect; @@ -270,18 +275,18 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * axis_vec[ltmd->axis] = 1.0f; if (ob_axis != NULL) { - /* calc the matrix relative to the axis object */ + /* Calculate the matrix relative to the axis object. */ invert_m4_m4(mtx_tmp_a, ctx->object->obmat); copy_m4_m4(mtx_tx_inv, ob_axis->obmat); mul_m4_m4m4(mtx_tx, mtx_tmp_a, mtx_tx_inv); - /* calc the axis vec */ + /* Calculate the axis vector. */ mul_mat3_m4_v3(mtx_tx, axis_vec); /* only rotation component */ normalize_v3(axis_vec); /* screw */ if (ltmd->flag & MOD_SCREW_OBJECT_OFFSET) { - /* find the offset along this axis relative to this objects matrix */ + /* Find the offset along this axis relative to this objects matrix. */ float totlen = len_v3(mtx_tx[3]); if (totlen != 0.0f) { @@ -330,7 +335,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * else { axis_char = (char)(axis_char + ltmd->axis); /* 'X' + axis */ - /* useful to be able to use the axis vec in some cases still */ + /* Useful to be able to use the axis vector in some cases still. */ zero_v3(axis_vec); axis_vec[ltmd->axis] = 1.0f; } @@ -441,7 +446,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * med_new->crease = med_orig->crease; med_new->flag = med_orig->flag & ~ME_LOOSEEDGE; - /* Tag mvert as not loose. */ + /* Tag #MVert as not loose. */ BLI_BITMAP_ENABLE(vert_tag, med_orig->v1); BLI_BITMAP_ENABLE(vert_tag, med_orig->v2); } @@ -481,8 +486,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * if (ltmd->flag & MOD_SCREW_NORMAL_CALC) { - /* - * Normal Calculation (for face flipping) + /* Normal Calculation (for face flipping) * Sort edge verts for correct face flipping * NOT REALLY NEEDED but face flipping is nice. */ @@ -490,19 +494,19 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * * * Since we are only ordering the edges here it can avoid mallocing the * extra space by abusing the vert array before its filled with new verts. - * The new array for vert_connect must be at least sizeof(ScrewVertConnect) * totvert - * and the size of our resulting meshes array is sizeof(MVert) * totvert * 3 - * so its safe to use the second 2 thirds of MVert the array for vert_connect, - * just make sure ScrewVertConnect struct is no more than twice as big as MVert, + * The new array for vert_connect must be at least `sizeof(ScrewVertConnect) * totvert` + * and the size of our resulting meshes array is `sizeof(MVert) * totvert * 3` + * so its safe to use the second 2 thirds of #MVert the array for vert_connect, + * just make sure #ScrewVertConnect struct is no more than twice as big as #MVert, * at the moment there is no chance of that being a problem, - * unless MVert becomes half its current size. + * unless #MVert becomes half its current size. * * once the edges are ordered, vert_connect is not needed and it can be used for verts * - * This makes the modifier faster with one less alloc. + * This makes the modifier faster with one less allocate. */ - vert_connect = MEM_malloc_arrayN(totvert, sizeof(ScrewVertConnect), "ScrewVertConnect"); + vert_connect = MEM_malloc_arrayN(totvert, sizeof(ScrewVertConnect), __func__); /* skip the first slice of verts. */ // vert_connect = (ScrewVertConnect *) &medge_new[totvert]; vc = vert_connect; @@ -512,7 +516,8 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * if (!totedge) { for (i = 0; i < totvert; i++, mv_orig++, mv_new++) { copy_v3_v3(mv_new->co, mv_orig->co); - normalize_v3_v3(vc->no, mv_new->co); /* no edges- this is really a dummy normal */ + /* No edges: this is really a dummy normal. */ + normalize_v3_v3(vc->no, mv_new->co); } } else { @@ -533,11 +538,11 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * vc->v[0] = vc->v[1] = SV_UNUSED; mul_m4_v3(mtx_tx, vc->co); - /* length in 2d, don't sqrt because this is only for comparison */ - vc->dist = vc->co[other_axis_1] * vc->co[other_axis_1] + - vc->co[other_axis_2] * vc->co[other_axis_2]; + /* Length in 2D, don't `sqrt` because this is only for comparison. */ + vc->dist_sq = vc->co[other_axis_1] * vc->co[other_axis_1] + + vc->co[other_axis_2] * vc->co[other_axis_2]; - // printf("location %f %f %f -- %f\n", vc->co[0], vc->co[1], vc->co[2], vc->dist); + // printf("location %f %f %f -- %f\n", vc->co[0], vc->co[1], vc->co[2], vc->dist_sq); } } else { @@ -550,11 +555,11 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * vc->e[0] = vc->e[1] = NULL; vc->v[0] = vc->v[1] = SV_UNUSED; - /* length in 2d, don't sqrt because this is only for comparison */ - vc->dist = vc->co[other_axis_1] * vc->co[other_axis_1] + - vc->co[other_axis_2] * vc->co[other_axis_2]; + /* Length in 2D, don't sqrt because this is only for comparison. */ + vc->dist_sq = vc->co[other_axis_1] * vc->co[other_axis_1] + + vc->co[other_axis_2] * vc->co[other_axis_2]; - // printf("location %f %f %f -- %f\n", vc->co[0], vc->co[1], vc->co[2], vc->dist); + // printf("location %f %f %f -- %f\n", vc->co[0], vc->co[1], vc->co[2], vc->dist_sq); } } @@ -622,9 +627,9 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * } lt_iter.v_poin->flag = 1; vc_tot_linked++; - // printf("Testing 2 floats %f : %f\n", fl, lt_iter.v_poin->dist); - if (fl <= lt_iter.v_poin->dist) { - fl = lt_iter.v_poin->dist; + // printf("Testing 2 floats %f : %f\n", fl, lt_iter.v_poin->dist_sq); + if (fl <= lt_iter.v_poin->dist_sq) { + fl = lt_iter.v_poin->dist_sq; v_best = lt_iter.v; // printf("\t\t\tVERT BEST: %i\n", v_best); } @@ -1148,7 +1153,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte ScrewModifierData *ltmd = (ScrewModifierData *)md; if (ltmd->ob_axis != NULL) { DEG_add_object_relation(ctx->node, ltmd->ob_axis, DEG_OB_COMP_TRANSFORM, "Screw Modifier"); - DEG_add_modifier_to_transform_relation(ctx->node, "Screw Modifier"); + DEG_add_depends_on_transform_relation(ctx->node, "Screw Modifier"); } } diff --git a/source/blender/modifiers/intern/MOD_shrinkwrap.c b/source/blender/modifiers/intern/MOD_shrinkwrap.c index be12dc6639b..4a927d92956 100644 --- a/source/blender/modifiers/intern/MOD_shrinkwrap.c +++ b/source/blender/modifiers/intern/MOD_shrinkwrap.c @@ -108,7 +108,7 @@ static void deformVerts(ModifierData *md, (swmd->shrinkType == MOD_SHRINKWRAP_PROJECT)) { /* mesh_src is needed for vgroups, but also used as ShrinkwrapCalcData.vert when projecting. * Avoid time-consuming mesh conversion for curves when not projecting. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false); } struct MDeformVert *dvert = NULL; @@ -135,11 +135,10 @@ static void deformVertsEM(ModifierData *md, Mesh *mesh_src = NULL; if ((swmd->vgroup_name[0] != '\0') || (swmd->shrinkType == MOD_SHRINKWRAP_PROJECT)) { - mesh_src = MOD_deform_mesh_eval_get( - ctx->object, editData, mesh, NULL, verts_num, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, verts_num, false); } - /* TODO(Campbell): use edit-mode data only (remove this line). */ + /* TODO(@campbellbarton): use edit-mode data only (remove this line). */ if (mesh_src != NULL) { BKE_mesh_wrapper_ensure_mdata(mesh_src); } @@ -186,7 +185,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte DEG_add_special_eval_flag(ctx->node, &smd->auxTarget->id, DAG_EVAL_NEED_SHRINKWRAP_BOUNDARY); } } - DEG_add_modifier_to_transform_relation(ctx->node, "Shrinkwrap Modifier"); + DEG_add_depends_on_transform_relation(ctx->node, "Shrinkwrap Modifier"); } static bool dependsOnNormals(ModifierData *md) diff --git a/source/blender/modifiers/intern/MOD_simpledeform.c b/source/blender/modifiers/intern/MOD_simpledeform.c index 9f1d0cd36c4..1fc4f11bc66 100644 --- a/source/blender/modifiers/intern/MOD_simpledeform.c +++ b/source/blender/modifiers/intern/MOD_simpledeform.c @@ -438,7 +438,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte if (smd->origin != NULL) { DEG_add_object_relation( ctx->node, smd->origin, DEG_OB_COMP_TRANSFORM, "SimpleDeform Modifier"); - DEG_add_modifier_to_transform_relation(ctx->node, "SimpleDeform Modifier"); + DEG_add_depends_on_transform_relation(ctx->node, "SimpleDeform Modifier"); } } @@ -453,7 +453,7 @@ static void deformVerts(ModifierData *md, if (ctx->object->type == OB_MESH && sdmd->vgroup_name[0] != '\0') { /* mesh_src is only needed for vgroups. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false); } SimpleDeformModifier_do(sdmd, ctx, ctx->object, mesh_src, vertexCos, verts_num); @@ -475,11 +475,10 @@ static void deformVertsEM(ModifierData *md, if (ctx->object->type == OB_MESH && sdmd->vgroup_name[0] != '\0') { /* mesh_src is only needed for vgroups. */ - mesh_src = MOD_deform_mesh_eval_get( - ctx->object, editData, mesh, NULL, verts_num, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, verts_num, false); } - /* TODO(Campbell): use edit-mode data only (remove this line). */ + /* TODO(@campbellbarton): use edit-mode data only (remove this line). */ if (mesh_src != NULL) { BKE_mesh_wrapper_ensure_mdata(mesh_src); } diff --git a/source/blender/modifiers/intern/MOD_smooth.c b/source/blender/modifiers/intern/MOD_smooth.c index c868c47cb90..6dd3d491283 100644 --- a/source/blender/modifiers/intern/MOD_smooth.c +++ b/source/blender/modifiers/intern/MOD_smooth.c @@ -190,7 +190,7 @@ static void deformVerts(ModifierData *md, Mesh *mesh_src = NULL; /* mesh_src is needed for vgroups, and taking edges into account. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false); smoothModifier_do(smd, ctx->object, mesh_src, vertexCos, verts_num); @@ -210,9 +210,9 @@ static void deformVertsEM(ModifierData *md, Mesh *mesh_src = NULL; /* mesh_src is needed for vgroups, and taking edges into account. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, verts_num, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, verts_num, false); - /* TODO(campbell): use edit-mode data only (remove this line). */ + /* TODO(@campbellbarton): use edit-mode data only (remove this line). */ BKE_mesh_wrapper_ensure_mdata(mesh_src); smoothModifier_do(smd, ctx->object, mesh_src, vertexCos, verts_num); diff --git a/source/blender/modifiers/intern/MOD_softbody.c b/source/blender/modifiers/intern/MOD_softbody.c index a49f2609641..ecff6d80893 100644 --- a/source/blender/modifiers/intern/MOD_softbody.c +++ b/source/blender/modifiers/intern/MOD_softbody.c @@ -66,7 +66,7 @@ static void updateDepsgraph(ModifierData *UNUSED(md), const ModifierUpdateDepsgr ctx->node, ctx->object, ctx->object->soft->effector_weights, true, 0, "Softbody Field"); } /* We need own transformation as well. */ - DEG_add_modifier_to_transform_relation(ctx->node, "SoftBody Modifier"); + DEG_add_depends_on_transform_relation(ctx->node, "SoftBody Modifier"); } static void panel_draw(const bContext *UNUSED(C), Panel *panel) diff --git a/source/blender/modifiers/intern/MOD_solidify_extrude.c b/source/blender/modifiers/intern/MOD_solidify_extrude.c index 80af23054e4..47277577d3e 100644 --- a/source/blender/modifiers/intern/MOD_solidify_extrude.c +++ b/source/blender/modifiers/intern/MOD_solidify_extrude.c @@ -53,7 +53,13 @@ BLI_INLINE bool edgeref_is_init(const EdgeFaceRef *edge_ref) * \param poly_nors: Precalculated face normals. * \param r_vert_nors: Return vert normals. */ -static void mesh_calc_hq_normal(Mesh *mesh, const float (*poly_nors)[3], float (*r_vert_nors)[3]) +static void mesh_calc_hq_normal(Mesh *mesh, + const float (*poly_nors)[3], + float (*r_vert_nors)[3], +#ifdef USE_NONMANIFOLD_WORKAROUND + BLI_bitmap *edge_tmp_tag +#endif +) { int i, verts_num, edges_num, polys_num; MPoly *mpoly, *mp; @@ -103,7 +109,7 @@ static void mesh_calc_hq_normal(Mesh *mesh, const float (*poly_nors)[3], float ( /* 3+ faces using an edge, we can't handle this usefully */ edge_ref->p1 = edge_ref->p2 = -1; #ifdef USE_NONMANIFOLD_WORKAROUND - medge[ml->e].flag |= ME_EDGE_TMP_TAG; + BLI_BITMAP_ENABLE(edge_tmp_tag, ml->e); #endif } /* --- done --- */ @@ -319,9 +325,20 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex BLI_assert(newEdges == 0); } +#ifdef USE_NONMANIFOLD_WORKAROUND + BLI_bitmap *edge_tmp_tag = BLI_BITMAP_NEW(mesh->totedge, __func__); +#endif + if (smd->flag & MOD_SOLIDIFY_NORMAL_CALC) { vert_nors = MEM_calloc_arrayN(verts_num, sizeof(float[3]), "mod_solid_vno_hq"); - mesh_calc_hq_normal(mesh, poly_nors, vert_nors); + mesh_calc_hq_normal(mesh, + poly_nors, + vert_nors +#ifdef USE_NONMANIFOLD_WORKAROUND + , + edge_tmp_tag +#endif + ); } result = BKE_mesh_new_nomain_from_template(mesh, @@ -740,8 +757,8 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex #ifdef USE_NONMANIFOLD_WORKAROUND /* skip 3+ face user edges */ if ((check_non_manifold == false) || - LIKELY(((orig_medge[ml[i_curr].e].flag & ME_EDGE_TMP_TAG) == 0) && - ((orig_medge[ml[i_next].e].flag & ME_EDGE_TMP_TAG) == 0))) { + LIKELY(!BLI_BITMAP_TEST(edge_tmp_tag, ml[i_curr].e) && + !BLI_BITMAP_TEST(edge_tmp_tag, ml[i_next].e))) { vert_angles[vidx] += shell_v3v3_normalized_to_dist(vert_nors[vidx], poly_nors[i]) * angle; } @@ -949,6 +966,10 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex MEM_freeN(vert_angles); } +#ifdef USE_NONMANIFOLD_WORKAROUND + MEM_SAFE_FREE(edge_tmp_tag); +#endif + if (vert_nors) { MEM_freeN(vert_nors); } @@ -999,9 +1020,9 @@ Mesh *MOD_solidify_extrude_modifyMesh(ModifierData *md, const ModifierEvalContex if (do_rim) { uint i; - /* NOTE(campbell): Unfortunately re-calculate the normals for the new edge faces is necessary. - * This could be done in many ways, but probably the quickest way - * is to calculate the average normals for side faces only. + /* NOTE(@campbellbarton): Unfortunately re-calculate the normals for the new edge + * faces is necessary. This could be done in many ways, but probably the quickest + * way is to calculate the average normals for side faces only. * Then blend them with the normals of the edge verts. * * At the moment its easiest to allocate an entire array for every vertex, diff --git a/source/blender/modifiers/intern/MOD_surface.c b/source/blender/modifiers/intern/MOD_surface.c index 8cfe3b35949..3e5a577a806 100644 --- a/source/blender/modifiers/intern/MOD_surface.c +++ b/source/blender/modifiers/intern/MOD_surface.c @@ -114,7 +114,7 @@ static void deformVerts(ModifierData *md, surmd->mesh = (Mesh *)BKE_id_copy_ex(NULL, (ID *)mesh, NULL, LIB_ID_COPY_LOCALIZE); } else { - surmd->mesh = MOD_deform_mesh_eval_get(ctx->object, NULL, NULL, NULL, verts_num, false, false); + surmd->mesh = MOD_deform_mesh_eval_get(ctx->object, NULL, NULL, NULL, verts_num, false); } if (!ctx->object->pd) { diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c index ad19ecf5720..3c0842a6e93 100644 --- a/source/blender/modifiers/intern/MOD_surfacedeform.c +++ b/source/blender/modifiers/intern/MOD_surfacedeform.c @@ -215,8 +215,7 @@ static void freeData(ModifierData *md) MEM_SAFE_FREE(smd->verts[i].binds[j].vert_inds); MEM_SAFE_FREE(smd->verts[i].binds[j].vert_weights); } - - MEM_SAFE_FREE(smd->verts[i].binds); + MEM_freeN(smd->verts[i].binds); } } @@ -1578,7 +1577,7 @@ static void deformVerts(ModifierData *md, if (smd->defgrp_name[0] != '\0') { /* Only need to use mesh_src when a vgroup is used. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false); } surfacedeformModifier_do(md, ctx, vertexCos, verts_num, ctx->object, mesh_src); @@ -1600,7 +1599,7 @@ static void deformVertsEM(ModifierData *md, if (smd->defgrp_name[0] != '\0') { /* Only need to use mesh_src when a vgroup is used. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, em, mesh, NULL, verts_num, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, em, mesh, NULL, verts_num, false); } surfacedeformModifier_do(md, ctx, vertexCos, verts_num, ctx->object, mesh_src); diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c index 575182a846b..fc17ddffa87 100644 --- a/source/blender/modifiers/intern/MOD_util.c +++ b/source/blender/modifiers/intern/MOD_util.c @@ -169,7 +169,6 @@ Mesh *MOD_deform_mesh_eval_get(Object *ob, Mesh *mesh, const float (*vertexCos)[3], const int verts_num, - const bool use_normals, const bool use_orco) { if (mesh != NULL) { @@ -217,14 +216,6 @@ Mesh *MOD_deform_mesh_eval_get(Object *ob, } } - /* TODO: Remove this "use_normals" argument, since the caller should retrieve normals afterwards - * if necessary. */ - if (use_normals) { - if (LIKELY(mesh)) { - BKE_mesh_vertex_normals_ensure(mesh); - } - } - if (mesh && mesh->runtime.wrapper_type == ME_WRAPPER_TYPE_MDATA) { BLI_assert(mesh->totvert == verts_num); } diff --git a/source/blender/modifiers/intern/MOD_util.h b/source/blender/modifiers/intern/MOD_util.h index b3b75898557..b675c11b370 100644 --- a/source/blender/modifiers/intern/MOD_util.h +++ b/source/blender/modifiers/intern/MOD_util.h @@ -42,7 +42,6 @@ struct Mesh *MOD_deform_mesh_eval_get(struct Object *ob, struct Mesh *mesh, const float (*vertexCos)[3], int verts_num, - bool use_normals, bool use_orco); void MOD_get_vgroup(struct Object *ob, diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c index 0474d3e47e6..4646ba41a74 100644 --- a/source/blender/modifiers/intern/MOD_uvproject.c +++ b/source/blender/modifiers/intern/MOD_uvproject.c @@ -80,7 +80,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte } } if (do_add_own_transform) { - DEG_add_modifier_to_transform_relation(ctx->node, "UV Project Modifier"); + DEG_add_depends_on_transform_relation(ctx->node, "UV Project Modifier"); } } @@ -284,7 +284,7 @@ static Mesh *uvprojectModifier_do(UVProjectModifierData *umd, } } - mesh->runtime.is_original = false; + mesh->runtime.is_original_bmesh = false; return mesh; } diff --git a/source/blender/modifiers/intern/MOD_uvwarp.c b/source/blender/modifiers/intern/MOD_uvwarp.c index c33b25c38e3..0439f92ac57 100644 --- a/source/blender/modifiers/intern/MOD_uvwarp.c +++ b/source/blender/modifiers/intern/MOD_uvwarp.c @@ -220,7 +220,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * settings.use_threading = (polys_num > 1000); BLI_task_parallel_range(0, polys_num, &data, uv_warp_compute, &settings); - mesh->runtime.is_original = false; + mesh->runtime.is_original_bmesh = false; return mesh; } @@ -242,7 +242,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte MOD_depsgraph_update_object_bone_relation( ctx->node, umd->object_dst, umd->bone_dst, "UVWarp Modifier"); - DEG_add_modifier_to_transform_relation(ctx->node, "UVWarp Modifier"); + DEG_add_depends_on_transform_relation(ctx->node, "UVWarp Modifier"); } static void panel_draw(const bContext *UNUSED(C), Panel *panel) diff --git a/source/blender/modifiers/intern/MOD_volume_to_mesh.cc b/source/blender/modifiers/intern/MOD_volume_to_mesh.cc index 3292f73137a..215436e4a8d 100644 --- a/source/blender/modifiers/intern/MOD_volume_to_mesh.cc +++ b/source/blender/modifiers/intern/MOD_volume_to_mesh.cc @@ -62,7 +62,7 @@ static void initData(ModifierData *md) static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx) { VolumeToMeshModifierData *vmmd = reinterpret_cast<VolumeToMeshModifierData *>(md); - DEG_add_modifier_to_transform_relation(ctx->node, "Volume to Mesh Modifier"); + DEG_add_depends_on_transform_relation(ctx->node, "Volume to Mesh Modifier"); if (vmmd->object) { DEG_add_object_relation( ctx->node, vmmd->object, DEG_OB_COMP_GEOMETRY, "Volume to Mesh Modifier"); diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c index afdc230a877..0968d0646a5 100644 --- a/source/blender/modifiers/intern/MOD_warp.c +++ b/source/blender/modifiers/intern/MOD_warp.c @@ -171,7 +171,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte } if (need_transform_relation) { - DEG_add_modifier_to_transform_relation(ctx->node, "Warp Modifier"); + DEG_add_depends_on_transform_relation(ctx->node, "Warp Modifier"); } } @@ -348,7 +348,7 @@ static void deformVerts(ModifierData *md, if (wmd->defgrp_name[0] != '\0' || wmd->texture != NULL) { /* mesh_src is only needed for vgroups and textures. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false); } warpModifier_do(wmd, ctx, mesh_src, vertexCos, verts_num); @@ -370,10 +370,10 @@ static void deformVertsEM(ModifierData *md, if (wmd->defgrp_name[0] != '\0' || wmd->texture != NULL) { /* mesh_src is only needed for vgroups and textures. */ - mesh_src = MOD_deform_mesh_eval_get(ctx->object, em, mesh, NULL, verts_num, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, em, mesh, NULL, verts_num, false); } - /* TODO(Campbell): use edit-mode data only (remove this line). */ + /* TODO(@campbellbarton): use edit-mode data only (remove this line). */ if (mesh_src != NULL) { BKE_mesh_wrapper_ensure_mdata(mesh_src); } diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c index ba7fb3fa1ba..9647f47c6e0 100644 --- a/source/blender/modifiers/intern/MOD_wave.c +++ b/source/blender/modifiers/intern/MOD_wave.c @@ -98,7 +98,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte } if (need_transform_relation) { - DEG_add_modifier_to_transform_relation(ctx->node, "Wave Modifier"); + DEG_add_depends_on_transform_relation(ctx->node, "Wave Modifier"); } } @@ -302,11 +302,10 @@ static void deformVerts(ModifierData *md, Mesh *mesh_src = NULL; if (wmd->flag & MOD_WAVE_NORM) { - mesh_src = MOD_deform_mesh_eval_get( - ctx->object, NULL, mesh, vertexCos, verts_num, true, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, vertexCos, verts_num, false); } else if (wmd->texture != NULL || wmd->defgrp_name[0] != '\0') { - mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, verts_num, false); } waveModifier_do(wmd, ctx, ctx->object, mesh_src, vertexCos, verts_num); @@ -327,19 +326,13 @@ static void deformVertsEM(ModifierData *md, Mesh *mesh_src = NULL; if (wmd->flag & MOD_WAVE_NORM) { - /* NOTE(@campbellbarton): don't request normals here because `use_normals == false` - * because #BKE_mesh_wrapper_ensure_mdata has not run yet. - * While this could be supported the argument is documented to be removed, - * so pass false here and let the normals be created when requested. */ - mesh_src = MOD_deform_mesh_eval_get( - ctx->object, editData, mesh, vertexCos, verts_num, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, vertexCos, verts_num, false); } else if (wmd->texture != NULL || wmd->defgrp_name[0] != '\0') { - mesh_src = MOD_deform_mesh_eval_get( - ctx->object, editData, mesh, NULL, verts_num, false, false); + mesh_src = MOD_deform_mesh_eval_get(ctx->object, editData, mesh, NULL, verts_num, false); } - /* TODO(Campbell): use edit-mode data only (remove this line). */ + /* TODO(@campbellbarton): use edit-mode data only (remove this line). */ if (mesh_src != NULL) { BKE_mesh_wrapper_ensure_mdata(mesh_src); } diff --git a/source/blender/modifiers/intern/MOD_weighted_normal.c b/source/blender/modifiers/intern/MOD_weighted_normal.c index af992c00097..039497b725b 100644 --- a/source/blender/modifiers/intern/MOD_weighted_normal.c +++ b/source/blender/modifiers/intern/MOD_weighted_normal.c @@ -660,7 +660,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * MEM_SAFE_FREE(wn_data.mode_pair); MEM_SAFE_FREE(wn_data.items_data); - result->runtime.is_original = false; + result->runtime.is_original_bmesh = false; return result; } diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c index 22f326d326e..2a509ddf220 100644 --- a/source/blender/modifiers/intern/MOD_weightvgedit.c +++ b/source/blender/modifiers/intern/MOD_weightvgedit.c @@ -139,7 +139,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte } if (need_transform_relation) { - DEG_add_modifier_to_transform_relation(ctx->node, "WeightVGEdit Modifier"); + DEG_add_depends_on_transform_relation(ctx->node, "WeightVGEdit Modifier"); } } @@ -287,7 +287,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * MEM_freeN(new_w); MEM_freeN(dw); - mesh->runtime.is_original = false; + mesh->runtime.is_original_bmesh = false; /* Return the vgroup-modified mesh. */ return mesh; diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c index 49088d42a5e..aa648eaec97 100644 --- a/source/blender/modifiers/intern/MOD_weightvgmix.c +++ b/source/blender/modifiers/intern/MOD_weightvgmix.c @@ -187,7 +187,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte } if (need_transform_relation) { - DEG_add_modifier_to_transform_relation(ctx->node, "WeightVGMix Modifier"); + DEG_add_depends_on_transform_relation(ctx->node, "WeightVGMix Modifier"); } } @@ -444,7 +444,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * MEM_freeN(dw2); MEM_SAFE_FREE(indices); - mesh->runtime.is_original = false; + mesh->runtime.is_original_bmesh = false; /* Return the vgroup-modified mesh. */ return mesh; diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c index b68d36366fd..df2b494199e 100644 --- a/source/blender/modifiers/intern/MOD_weightvgproximity.c +++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c @@ -401,7 +401,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte } if (need_transform_relation) { - DEG_add_modifier_to_transform_relation(ctx->node, "WeightVGProximity Modifier"); + DEG_add_depends_on_transform_relation(ctx->node, "WeightVGProximity Modifier"); } } @@ -640,7 +640,7 @@ static Mesh *modifyMesh(ModifierData *md, const ModifierEvalContext *ctx, Mesh * TIMEIT_END(perf); #endif - mesh->runtime.is_original = false; + mesh->runtime.is_original_bmesh = false; /* Return the vgroup-modified mesh. */ return mesh; |