diff options
Diffstat (limited to 'source/blender/modifiers')
57 files changed, 213 insertions, 417 deletions
diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c index 4a474dde585..4cc780431d0 100644 --- a/source/blender/modifiers/intern/MOD_armature.c +++ b/source/blender/modifiers/intern/MOD_armature.c @@ -107,7 +107,7 @@ static void deformVerts( MOD_previous_vcos_store(md, vertexCos); /* if next modifier needs original vertices */ - armature_deform_verts(DEG_get_evaluated_object(ctx->depsgraph, amd->object), ctx->object, mesh, vertexCos, NULL, + armature_deform_verts(amd->object, ctx->object, mesh, vertexCos, NULL, numVerts, amd->deformflag, (float(*)[3])amd->prevCos, amd->defgrp_name, NULL); /* free cache */ @@ -126,7 +126,7 @@ static void deformVertsEM( MOD_previous_vcos_store(md, vertexCos); /* if next modifier needs original vertices */ - armature_deform_verts(DEG_get_evaluated_object(ctx->depsgraph, amd->object), ctx->object, mesh_src, vertexCos, NULL, + armature_deform_verts(amd->object, ctx->object, mesh_src, vertexCos, NULL, numVerts, amd->deformflag, (float(*)[3])amd->prevCos, amd->defgrp_name, NULL); /* free cache */ @@ -148,7 +148,7 @@ static void deformMatricesEM( ArmatureModifierData *amd = (ArmatureModifierData *) md; Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, em, mesh, NULL, numVerts, false, false); - armature_deform_verts(DEG_get_evaluated_object(ctx->depsgraph, amd->object), ctx->object, mesh_src, vertexCos, defMats, + armature_deform_verts(amd->object, ctx->object, mesh_src, vertexCos, defMats, numVerts, amd->deformflag, NULL, amd->defgrp_name, NULL); if (mesh_src != mesh) { @@ -163,7 +163,7 @@ static void deformMatrices( ArmatureModifierData *amd = (ArmatureModifierData *) md; Mesh *mesh_src = MOD_deform_mesh_eval_get(ctx->object, NULL, mesh, NULL, numVerts, false, false); - armature_deform_verts(DEG_get_evaluated_object(ctx->depsgraph, amd->object), ctx->object, mesh_src, vertexCos, defMats, + armature_deform_verts(amd->object, ctx->object, mesh_src, vertexCos, defMats, numVerts, amd->deformflag, NULL, amd->defgrp_name, NULL); if (mesh_src != mesh) { @@ -182,12 +182,6 @@ ModifierTypeInfo modifierType_Armature = { /* copyData */ copyData, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ deformVerts, /* deformMatrices */ deformMatrices, /* deformVertsEM */ deformVertsEM, @@ -204,4 +198,5 @@ ModifierTypeInfo modifierType_Armature = { /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c index 56567c79c6a..542c7665807 100644 --- a/source/blender/modifiers/intern/MOD_array.c +++ b/source/blender/modifiers/intern/MOD_array.c @@ -374,7 +374,7 @@ static Mesh *arrayModifier_doArray( count = amd->count; - Object *start_cap_ob = DEG_get_evaluated_object(ctx->depsgraph, amd->start_cap); + Object *start_cap_ob = amd->start_cap; if (start_cap_ob && start_cap_ob != ctx->object && start_cap_ob->type == OB_MESH) { vgroup_start_cap_remap = BKE_object_defgroup_index_map_create( start_cap_ob, ctx->object, &vgroup_start_cap_remap_len); @@ -387,7 +387,7 @@ static Mesh *arrayModifier_doArray( start_cap_npolys = start_cap_mesh->totpoly; } } - Object *end_cap_ob = DEG_get_evaluated_object(ctx->depsgraph, amd->end_cap); + Object *end_cap_ob = amd->end_cap; if (end_cap_ob && end_cap_ob != ctx->object && end_cap_ob->type == OB_MESH) { vgroup_end_cap_remap = BKE_object_defgroup_index_map_create( end_cap_ob, ctx->object, &vgroup_end_cap_remap_len); @@ -433,7 +433,7 @@ static Mesh *arrayModifier_doArray( else unit_m4(obinv); - mul_m4_series(result_mat, offset, obinv, DEG_get_evaluated_object(ctx->depsgraph, amd->offset_ob)->obmat); + mul_m4_series(result_mat, offset, obinv, amd->offset_ob->obmat); copy_m4_m4(offset, result_mat); } @@ -442,7 +442,7 @@ static Mesh *arrayModifier_doArray( offset_has_scale = !is_one_v3(scale); if (amd->fit_type == MOD_ARR_FITCURVE && amd->curve_ob != NULL) { - Object *curve_ob = DEG_get_evaluated_object(ctx->depsgraph, amd->curve_ob); + Object *curve_ob = amd->curve_ob; Curve *cu = curve_ob->data; if (cu) { CurveCache *curve_cache = curve_ob->runtime.curve_cache; @@ -755,12 +755,6 @@ ModifierTypeInfo modifierType_Array = { /* copyData */ modifier_copyData_generic, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -777,4 +771,5 @@ ModifierTypeInfo modifierType_Array = { /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c index 6e1dd9ed45d..567c74effe0 100644 --- a/source/blender/modifiers/intern/MOD_bevel.c +++ b/source/blender/modifiers/intern/MOD_bevel.c @@ -217,12 +217,6 @@ ModifierTypeInfo modifierType_Bevel = { /* copyData */ copyData, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -239,4 +233,5 @@ ModifierTypeInfo modifierType_Bevel = { /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c index a90ddde7946..8e3a19e524a 100644 --- a/source/blender/modifiers/intern/MOD_boolean.c +++ b/source/blender/modifiers/intern/MOD_boolean.c @@ -163,7 +163,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes return result; } - Object *other = DEG_get_evaluated_object(ctx->depsgraph, bmd->object); + Object *other = bmd->object; mesh_other = BKE_modifier_get_evaluated_mesh_from_evaluated_object(other, false); if (mesh_other) { Object *object = ctx->object; @@ -338,12 +338,6 @@ ModifierTypeInfo modifierType_Boolean = { /* copyData */ modifier_copyData_generic, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -360,4 +354,5 @@ ModifierTypeInfo modifierType_Boolean = { /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_build.c b/source/blender/modifiers/intern/MOD_build.c index e46c9aca5ce..01478c855bb 100644 --- a/source/blender/modifiers/intern/MOD_build.c +++ b/source/blender/modifiers/intern/MOD_build.c @@ -293,12 +293,6 @@ ModifierTypeInfo modifierType_Build = { /* copyData */ modifier_copyData_generic, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -315,4 +309,5 @@ ModifierTypeInfo modifierType_Build = { /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.c index f408a22aadf..b8917f58234 100644 --- a/source/blender/modifiers/intern/MOD_cast.c +++ b/source/blender/modifiers/intern/MOD_cast.c @@ -95,7 +95,7 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte } static void sphere_do( - CastModifierData *cmd, const ModifierEvalContext *ctx, + CastModifierData *cmd, const ModifierEvalContext *UNUSED(ctx), Object *ob, Mesh *mesh, float (*vertexCos)[3], int numVerts) { @@ -119,7 +119,7 @@ static void sphere_do( if (type == MOD_CAST_TYPE_CYLINDER) flag &= ~MOD_CAST_Z; - ctrl_ob = DEG_get_evaluated_object(ctx->depsgraph, cmd->object); + ctrl_ob = cmd->object; /* spherify's center is {0, 0, 0} (the ob's own center in its local * space), by default, but if the user defined a control object, @@ -217,7 +217,7 @@ static void sphere_do( } static void cuboid_do( - CastModifierData *cmd, const ModifierEvalContext *ctx, + CastModifierData *cmd, const ModifierEvalContext *UNUSED(ctx), Object *ob, Mesh *mesh, float (*vertexCos)[3], int numVerts) { @@ -236,7 +236,7 @@ static void cuboid_do( flag = cmd->flag; - ctrl_ob = DEG_get_evaluated_object(ctx->depsgraph, cmd->object); + ctrl_ob = cmd->object; /* now we check which options the user wants */ @@ -474,12 +474,6 @@ ModifierTypeInfo modifierType_Cast = { /* copyData */ modifier_copyData_generic, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ deformVerts, /* deformMatrices */ NULL, /* deformVertsEM */ deformVertsEM, @@ -496,4 +490,5 @@ ModifierTypeInfo modifierType_Cast = { /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c index 41f35faac1b..8bf9d50cda7 100644 --- a/source/blender/modifiers/intern/MOD_cloth.c +++ b/source/blender/modifiers/intern/MOD_cloth.c @@ -241,12 +241,6 @@ ModifierTypeInfo modifierType_Cloth = { /* copyData */ copyData, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ deformVerts, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -263,4 +257,5 @@ ModifierTypeInfo modifierType_Cloth = { /* foreachObjectLink */ NULL, /* foreachIDLink */ foreachIDLink, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_collision.c b/source/blender/modifiers/intern/MOD_collision.c index 3e1fa4954fa..2e56da6f100 100644 --- a/source/blender/modifiers/intern/MOD_collision.c +++ b/source/blender/modifiers/intern/MOD_collision.c @@ -240,6 +240,10 @@ static void deformVerts( } } +static void updateDepsgraph(ModifierData *UNUSED(md), const ModifierUpdateDepsgraphContext *ctx) +{ + DEG_add_modifier_to_transform_relation(ctx->node, "Collision Modifier"); +} ModifierTypeInfo modifierType_Collision = { /* name */ "Collision", @@ -251,12 +255,6 @@ ModifierTypeInfo modifierType_Collision = { /* copyData */ NULL, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ deformVerts, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -267,10 +265,11 @@ ModifierTypeInfo modifierType_Collision = { /* requiredDataMask */ NULL, /* freeData */ freeData, /* isDisabled */ NULL, - /* updateDepsgraph */ NULL, + /* updateDepsgraph */ updateDepsgraph, /* dependsOnTime */ dependsOnTime, /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_correctivesmooth.c b/source/blender/modifiers/intern/MOD_correctivesmooth.c index cc6177b9bc8..ac1c0d46d7b 100644 --- a/source/blender/modifiers/intern/MOD_correctivesmooth.c +++ b/source/blender/modifiers/intern/MOD_correctivesmooth.c @@ -743,12 +743,6 @@ ModifierTypeInfo modifierType_CorrectiveSmooth = { /* copyData */ copyData, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ deformVerts, /* deformMatrices */ NULL, /* deformVertsEM */ deformVertsEM, @@ -765,4 +759,5 @@ ModifierTypeInfo modifierType_CorrectiveSmooth = { /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_curve.c b/source/blender/modifiers/intern/MOD_curve.c index f3a5e280947..91cedda4f48 100644 --- a/source/blender/modifiers/intern/MOD_curve.c +++ b/source/blender/modifiers/intern/MOD_curve.c @@ -115,7 +115,7 @@ static void deformVerts( /* silly that defaxis and curve_deform_verts are off by 1 * but leave for now to save having to call do_versions */ - curve_deform_verts(DEG_get_evaluated_object(ctx->depsgraph, cmd->object), ctx->object, + curve_deform_verts(cmd->object, ctx->object, vertexCos, numVerts, dvert, defgrp_index, cmd->defaxis - 1); if (!ELEM(mesh_src, NULL, mesh)) { @@ -152,12 +152,6 @@ ModifierTypeInfo modifierType_Curve = { /* copyData */ modifier_copyData_generic, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ deformVerts, /* deformMatrices */ NULL, /* deformVertsEM */ deformVertsEM, @@ -174,4 +168,5 @@ ModifierTypeInfo modifierType_Curve = { /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_datatransfer.c b/source/blender/modifiers/intern/MOD_datatransfer.c index 3e461476eac..567af7bae09 100644 --- a/source/blender/modifiers/intern/MOD_datatransfer.c +++ b/source/blender/modifiers/intern/MOD_datatransfer.c @@ -122,6 +122,8 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte if (dtmd->ob_source != NULL) { CustomData_MeshMasks cddata_masks = {0}; BKE_object_data_transfer_dttypes_to_cdmask(dtmd->data_types, &cddata_masks); + BKE_mesh_remap_calc_source_cddata_masks_from_map_modes( + dtmd->vmap_mode, dtmd->emap_mode, dtmd->lmap_mode, dtmd->pmap_mode, &cddata_masks); DEG_add_object_relation(ctx->node, dtmd->ob_source, DEG_OB_COMP_GEOMETRY, "DataTransfer Modifier"); DEG_add_customdata_mask(ctx->node, dtmd->ob_source, &cddata_masks); @@ -158,7 +160,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes /* Only used to check wehther we are operating on org data or not... */ Mesh *me = ctx->object->data; - Object *ob_source = DEG_get_evaluated_object(ctx->depsgraph, dtmd->ob_source); + Object *ob_source = dtmd->ob_source; const bool invert_vgroup = (dtmd->flags & MOD_DATATRANSFER_INVERT_VGROUP) != 0; @@ -216,12 +218,6 @@ ModifierTypeInfo modifierType_DataTransfer = { /* copyData */ modifier_copyData_generic, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -238,4 +234,5 @@ ModifierTypeInfo modifierType_DataTransfer = { /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_decimate.c b/source/blender/modifiers/intern/MOD_decimate.c index 0ca6111c41a..40968f1173f 100644 --- a/source/blender/modifiers/intern/MOD_decimate.c +++ b/source/blender/modifiers/intern/MOD_decimate.c @@ -225,12 +225,6 @@ ModifierTypeInfo modifierType_Decimate = { /* copyData */ modifier_copyData_generic, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -247,4 +241,5 @@ ModifierTypeInfo modifierType_Decimate = { /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c index 87b25982d81..0060639970c 100644 --- a/source/blender/modifiers/intern/MOD_displace.c +++ b/source/blender/modifiers/intern/MOD_displace.c @@ -290,7 +290,7 @@ static void displaceModifier_do( mvert = mesh->mvert; MOD_get_vgroup(ob, mesh, dmd->defgrp_name, &dvert, &defgrp_index); - Tex *tex_target = (Tex *)DEG_get_evaluated_id(ctx->depsgraph, &dmd->texture->id); + Tex *tex_target = dmd->texture; if (tex_target != NULL) { tex_co = MEM_calloc_arrayN((size_t)numVerts, sizeof(*tex_co), "displaceModifier_do tex_co"); @@ -406,12 +406,6 @@ ModifierTypeInfo modifierType_Displace = { /* copyData */ modifier_copyData_generic, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ deformVerts, /* deformMatrices */ NULL, /* deformVertsEM */ deformVertsEM, @@ -428,4 +422,5 @@ ModifierTypeInfo modifierType_Displace = { /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ foreachIDLink, /* foreachTexLink */ foreachTexLink, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_dynamicpaint.c b/source/blender/modifiers/intern/MOD_dynamicpaint.c index b84e46e145c..badf3df6b1d 100644 --- a/source/blender/modifiers/intern/MOD_dynamicpaint.c +++ b/source/blender/modifiers/intern/MOD_dynamicpaint.c @@ -58,6 +58,15 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla dynamicPaint_Modifier_copy(pmd, tpmd, flag); } +static void freeRuntimeData(void *runtime_data_v) +{ + if (runtime_data_v == NULL) { + return; + } + DynamicPaintRuntime *runtime_data = (DynamicPaintRuntime *)runtime_data_v; + dynamicPaint_Modifier_free_runtime(runtime_data); +} + static void freeData(ModifierData *md) { DynamicPaintModifierData *pmd = (DynamicPaintModifierData *) md; @@ -170,12 +179,6 @@ ModifierTypeInfo modifierType_DynamicPaint = { /* copyData */ copyData, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -192,4 +195,5 @@ ModifierTypeInfo modifierType_DynamicPaint = { /* foreachObjectLink */ NULL, /* foreachIDLink */ foreachIDLink, /* foreachTexLink */ foreachTexLink, + /* freeRuntimeData */ freeRuntimeData, }; diff --git a/source/blender/modifiers/intern/MOD_edgesplit.c b/source/blender/modifiers/intern/MOD_edgesplit.c index a7b980494b3..751a70916ab 100644 --- a/source/blender/modifiers/intern/MOD_edgesplit.c +++ b/source/blender/modifiers/intern/MOD_edgesplit.c @@ -146,12 +146,6 @@ ModifierTypeInfo modifierType_EdgeSplit = { /* copyData */ modifier_copyData_generic, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -168,4 +162,5 @@ ModifierTypeInfo modifierType_EdgeSplit = { /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_explode.c b/source/blender/modifiers/intern/MOD_explode.c index 3a0449a4e52..a8a0b963bd8 100644 --- a/source/blender/modifiers/intern/MOD_explode.c +++ b/source/blender/modifiers/intern/MOD_explode.c @@ -94,7 +94,7 @@ static void createFacepa( MFace *fa = NULL, *mface = NULL; MVert *mvert = NULL; ParticleData *pa; - KDTree *tree; + KDTree_3d *tree; RNG *rng; float center[3], co[3]; int *facepa = NULL, *vertpa = NULL, totvert = 0, totface = 0, totpart = 0; @@ -138,12 +138,12 @@ static void createFacepa( } /* make tree of emitter locations */ - tree = BLI_kdtree_new(totpart); + tree = BLI_kdtree_3d_new(totpart); for (p = 0, pa = psys->particles; p < totpart; p++, pa++) { psys_particle_on_emitter(psmd, psys->part->from, pa->num, pa->num_dmcache, pa->fuv, pa->foffset, co, NULL, NULL, NULL, NULL); - BLI_kdtree_insert(tree, p, co); + BLI_kdtree_3d_insert(tree, p, co); } - BLI_kdtree_balance(tree); + BLI_kdtree_3d_balance(tree); /* set face-particle-indexes to nearest particle to face center */ for (i = 0, fa = mface; i < totface; i++, fa++) { @@ -157,7 +157,7 @@ static void createFacepa( mul_v3_fl(center, 1.0f / 3.0f); } - p = BLI_kdtree_find_nearest(tree, center, NULL); + p = BLI_kdtree_3d_find_nearest(tree, center, NULL); v1 = vertpa[fa->v1]; v2 = vertpa[fa->v2]; @@ -187,7 +187,7 @@ static void createFacepa( if (vertpa) { MEM_freeN(vertpa); } - BLI_kdtree_free(tree); + BLI_kdtree_3d_free(tree); BLI_rng_free(rng); } @@ -1084,12 +1084,6 @@ ModifierTypeInfo modifierType_Explode = { /* flags */ eModifierTypeFlag_AcceptsMesh, /* copyData */ copyData, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -1106,4 +1100,5 @@ ModifierTypeInfo modifierType_Explode = { /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_fluidsim.c b/source/blender/modifiers/intern/MOD_fluidsim.c index d4bac71f677..4377e04db84 100644 --- a/source/blender/modifiers/intern/MOD_fluidsim.c +++ b/source/blender/modifiers/intern/MOD_fluidsim.c @@ -138,12 +138,6 @@ ModifierTypeInfo modifierType_Fluidsim = { /* copyData */ copyData, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -160,4 +154,5 @@ ModifierTypeInfo modifierType_Fluidsim = { /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c index e911dbc4b5a..0c15f4caa23 100644 --- a/source/blender/modifiers/intern/MOD_hook.c +++ b/source/blender/modifiers/intern/MOD_hook.c @@ -248,11 +248,11 @@ static void hook_co_apply(struct HookData_cb *hd, const int j) } static void deformVerts_do( - HookModifierData *hmd, const ModifierEvalContext *ctx, + HookModifierData *hmd, const ModifierEvalContext *UNUSED(ctx), Object *ob, Mesh *mesh, float (*vertexCos)[3], int numVerts) { - Object *ob_target = DEG_get_evaluated_object(ctx->depsgraph, hmd->object); + Object *ob_target = hmd->object; bPoseChannel *pchan = BKE_pose_channel_find_name(ob_target->pose, hmd->subtarget); float dmat[4][4]; int i, *index_pt; @@ -386,12 +386,6 @@ ModifierTypeInfo modifierType_Hook = { eModifierTypeFlag_SupportsEditmode, /* copyData */ copyData, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ deformVerts, /* deformMatrices */ NULL, /* deformVertsEM */ deformVertsEM, @@ -408,4 +402,5 @@ ModifierTypeInfo modifierType_Hook = { /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.c b/source/blender/modifiers/intern/MOD_laplaciandeform.c index db76b0fd0c2..df0ef4a7404 100644 --- a/source/blender/modifiers/intern/MOD_laplaciandeform.c +++ b/source/blender/modifiers/intern/MOD_laplaciandeform.c @@ -771,12 +771,6 @@ ModifierTypeInfo modifierType_LaplacianDeform = { /* flags */ eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_SupportsEditmode, /* copyData */ copyData, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ deformVerts, /* deformMatrices */ NULL, /* deformVertsEM */ deformVertsEM, @@ -793,4 +787,5 @@ ModifierTypeInfo modifierType_LaplacianDeform = { /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_laplaciansmooth.c b/source/blender/modifiers/intern/MOD_laplaciansmooth.c index a6670f313ce..321dfd5dae1 100644 --- a/source/blender/modifiers/intern/MOD_laplaciansmooth.c +++ b/source/blender/modifiers/intern/MOD_laplaciansmooth.c @@ -535,12 +535,6 @@ ModifierTypeInfo modifierType_LaplacianSmooth = { /* copyData */ modifier_copyData_generic, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ deformVerts, /* deformMatrices */ NULL, /* deformVertsEM */ deformVertsEM, @@ -557,4 +551,5 @@ ModifierTypeInfo modifierType_LaplacianSmooth = { /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_lattice.c b/source/blender/modifiers/intern/MOD_lattice.c index 46a9c4f0a47..4715d2ab073 100644 --- a/source/blender/modifiers/intern/MOD_lattice.c +++ b/source/blender/modifiers/intern/MOD_lattice.c @@ -94,7 +94,7 @@ static void deformVerts( MOD_previous_vcos_store(md, vertexCos); /* if next modifier needs original vertices */ - lattice_deform_verts(DEG_get_evaluated_object(ctx->depsgraph, lmd->object), ctx->object, mesh_src, + lattice_deform_verts(lmd->object, ctx->object, mesh_src, vertexCos, numVerts, lmd->name, lmd->strength); if (!ELEM(mesh_src, NULL, mesh)) { @@ -127,12 +127,6 @@ ModifierTypeInfo modifierType_Lattice = { /* copyData */ modifier_copyData_generic, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ deformVerts, /* deformMatrices */ NULL, /* deformVertsEM */ deformVertsEM, @@ -149,4 +143,5 @@ ModifierTypeInfo modifierType_Lattice = { /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_mask.c b/source/blender/modifiers/intern/MOD_mask.c index 6d8317ffe77..efb299773ef 100644 --- a/source/blender/modifiers/intern/MOD_mask.c +++ b/source/blender/modifiers/intern/MOD_mask.c @@ -127,7 +127,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes /* if mode is to use selected armature bones, aggregate the bone groups */ if (mmd->mode == MOD_MASK_MODE_ARM) { /* --- using selected bones --- */ - Object *oba = DEG_get_evaluated_object(ctx->depsgraph, mmd->ob_arm); + Object *oba = mmd->ob_arm; bPoseChannel *pchan; bDeformGroup *def; bool *bone_select_array; @@ -357,12 +357,6 @@ ModifierTypeInfo modifierType_Mask = { /* copyData */ modifier_copyData_generic, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -379,4 +373,5 @@ ModifierTypeInfo modifierType_Mask = { /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_meshcache.c b/source/blender/modifiers/intern/MOD_meshcache.c index 0ecd56372c7..74172927c9d 100644 --- a/source/blender/modifiers/intern/MOD_meshcache.c +++ b/source/blender/modifiers/intern/MOD_meshcache.c @@ -294,12 +294,6 @@ ModifierTypeInfo modifierType_MeshCache = { /* copyData */ modifier_copyData_generic, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ deformVerts, /* deformMatrices */ NULL, /* deformVertsEM */ deformVertsEM, @@ -316,4 +310,5 @@ ModifierTypeInfo modifierType_MeshCache = { /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c index e59a6ae9add..310b05d4580 100644 --- a/source/blender/modifiers/intern/MOD_meshdeform.c +++ b/source/blender/modifiers/intern/MOD_meshdeform.c @@ -296,7 +296,7 @@ static void meshdeformModifier_do( * * We'll support this case once granular dependency graph is landed. */ - Object *ob_target = DEG_get_evaluated_object(ctx->depsgraph, mmd->object); + Object *ob_target = mmd->object; cagemesh = BKE_modifier_get_evaluated_mesh_from_evaluated_object(ob_target, false); #if 0 /* This shall not be needed if we always get evaluated target object... */ if (cagemesh == NULL && mmd->bindcagecos == NULL && ob == DEG_get_original_object(ob)) { @@ -508,12 +508,6 @@ ModifierTypeInfo modifierType_MeshDeform = { /* copyData */ copyData, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ deformVerts, /* deformMatrices */ NULL, /* deformVertsEM */ deformVertsEM, @@ -530,4 +524,5 @@ ModifierTypeInfo modifierType_MeshDeform = { /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_meshsequencecache.c b/source/blender/modifiers/intern/MOD_meshsequencecache.c index d17f343a1ec..3b092bc7a76 100644 --- a/source/blender/modifiers/intern/MOD_meshsequencecache.c +++ b/source/blender/modifiers/intern/MOD_meshsequencecache.c @@ -189,12 +189,6 @@ ModifierTypeInfo modifierType_MeshSequenceCache = { /* copyData */ copyData, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -211,4 +205,5 @@ ModifierTypeInfo modifierType_MeshSequenceCache = { /* foreachObjectLink */ NULL, /* foreachIDLink */ foreachIDLink, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_mirror.c b/source/blender/modifiers/intern/MOD_mirror.c index c46445471df..5fb4c66471f 100644 --- a/source/blender/modifiers/intern/MOD_mirror.c +++ b/source/blender/modifiers/intern/MOD_mirror.c @@ -130,7 +130,7 @@ static Mesh *doBiscetOnMirrorPlane( static Mesh *doMirrorOnAxis( MirrorModifierData *mmd, - const ModifierEvalContext *ctx, + const ModifierEvalContext *UNUSED(ctx), Object *ob, const Mesh *mesh, int axis) @@ -159,7 +159,7 @@ static Mesh *doMirrorOnAxis( unit_m4(mtx); mtx[axis][axis] = -1.0f; - Object *mirror_ob = DEG_get_evaluated_object(ctx->depsgraph, mmd->mirror_ob); + Object *mirror_ob = mmd->mirror_ob; if (mirror_ob != NULL) { float tmp[4][4]; float itmp[4][4]; @@ -432,12 +432,6 @@ ModifierTypeInfo modifierType_Mirror = { /* copyData */ modifier_copyData_generic, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -454,4 +448,5 @@ ModifierTypeInfo modifierType_Mirror = { /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_multires.c b/source/blender/modifiers/intern/MOD_multires.c index 7cd9dfa05aa..af17bd7d53c 100644 --- a/source/blender/modifiers/intern/MOD_multires.c +++ b/source/blender/modifiers/intern/MOD_multires.c @@ -24,6 +24,8 @@ #include <stddef.h> +#include "MEM_guardedalloc.h" + #include "BLI_utildefines.h" #include "DNA_mesh_types.h" @@ -44,6 +46,11 @@ #include "MOD_modifiertypes.h" +typedef struct MultiresRuntimeData { + /* Cached subdivision surface descriptor, with topology and settings. */ + struct Subdiv *subdiv; +} MultiresRuntimeData; + static void initData(ModifierData *md) { MultiresModifierData *mmd = (MultiresModifierData *)md; @@ -58,19 +65,36 @@ static void initData(ModifierData *md) static void copyData(const ModifierData *md_src, ModifierData *md_dst, const int flag) { - MultiresModifierData *mmd_dst = (MultiresModifierData *)md_dst; - modifier_copyData_generic(md_src, md_dst, flag); +} - mmd_dst->subdiv = NULL; +static void freeRuntimeData(void *runtime_data_v) +{ + if (runtime_data_v == NULL) { + return; + } + MultiresRuntimeData *runtime_data = (MultiresRuntimeData *)runtime_data_v; + if (runtime_data->subdiv != NULL) { + BKE_subdiv_free(runtime_data->subdiv); + } + MEM_freeN(runtime_data); } static void freeData(ModifierData *md) { MultiresModifierData *mmd = (MultiresModifierData *) md; - if (mmd->subdiv != NULL) { - BKE_subdiv_free(mmd->subdiv); + freeRuntimeData(mmd->modifier.runtime); +} + +static MultiresRuntimeData *multires_ensure_runtime(MultiresModifierData *mmd) +{ + MultiresRuntimeData *runtime_data = + (MultiresRuntimeData *)mmd->modifier.runtime; + if (runtime_data == NULL) { + runtime_data = MEM_callocN(sizeof(*runtime_data), "subsurf runtime"); + mmd->modifier.runtime = runtime_data; } + return runtime_data; } /* Main goal of this function is to give usable subdivision surface descriptor @@ -79,9 +103,11 @@ static Subdiv *subdiv_descriptor_ensure(MultiresModifierData *mmd, const SubdivSettings *subdiv_settings, const Mesh *mesh) { + MultiresRuntimeData *runtime_data = + (MultiresRuntimeData *)mmd->modifier.runtime; Subdiv *subdiv = BKE_subdiv_update_from_mesh( - mmd->subdiv, subdiv_settings, mesh); - mmd->subdiv = subdiv; + runtime_data->subdiv, subdiv_settings, mesh); + runtime_data->subdiv = subdiv; return subdiv; } @@ -99,7 +125,7 @@ static Mesh *multires_as_mesh(MultiresModifierData *mmd, Object *object = ctx->object; SubdivToMeshSettings mesh_settings; BKE_multires_subdiv_mesh_settings_init( - &mesh_settings, scene, object, mmd, use_render_params, ignore_simplify); + &mesh_settings, scene, object, mmd, use_render_params, ignore_simplify); if (mesh_settings.resolution < 3) { return result; } @@ -156,6 +182,7 @@ static Mesh *applyModifier(ModifierData *md, return result; } BKE_subdiv_settings_validate_for_mesh(&subdiv_settings, mesh); + MultiresRuntimeData *runtime_data = multires_ensure_runtime(mmd); Subdiv *subdiv = subdiv_descriptor_ensure(mmd, &subdiv_settings, mesh); if (subdiv == NULL) { /* Happens on bad topology, ut also on empty input mesh. */ @@ -180,13 +207,13 @@ static Mesh *applyModifier(ModifierData *md, /* NOTE: CCG becomes an owner of Subdiv descriptor, so can not share * this pointer. Not sure if it's needed, but might have a second look * on the ownership model here. */ - mmd->subdiv = NULL; + runtime_data->subdiv = NULL; // BKE_subdiv_stats_print(&subdiv->stats); } else { result = multires_as_mesh(mmd, ctx, mesh, subdiv); // BKE_subdiv_stats_print(&subdiv->stats); - if (subdiv != mmd->subdiv) { + if (subdiv != runtime_data->subdiv) { BKE_subdiv_free(subdiv); } } @@ -204,12 +231,6 @@ ModifierTypeInfo modifierType_Multires = { /* copyData */ copyData, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -226,4 +247,5 @@ ModifierTypeInfo modifierType_Multires = { /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ freeRuntimeData, }; diff --git a/source/blender/modifiers/intern/MOD_none.c b/source/blender/modifiers/intern/MOD_none.c index 781e52fc426..749c329b3b6 100644 --- a/source/blender/modifiers/intern/MOD_none.c +++ b/source/blender/modifiers/intern/MOD_none.c @@ -46,12 +46,6 @@ ModifierTypeInfo modifierType_None = { /* copyData */ NULL, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -68,4 +62,5 @@ ModifierTypeInfo modifierType_None = { /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_normal_edit.c b/source/blender/modifiers/intern/MOD_normal_edit.c index d838d203ed5..2a8bca895be 100644 --- a/source/blender/modifiers/intern/MOD_normal_edit.c +++ b/source/blender/modifiers/intern/MOD_normal_edit.c @@ -192,7 +192,7 @@ static bool polygons_check_flip( } static void normalEditModifier_do_radial( - NormalEditModifierData *enmd, const ModifierEvalContext *ctx, + NormalEditModifierData *enmd, const ModifierEvalContext *UNUSED(ctx), Object *ob, Mesh *mesh, short (*clnors)[2], float (*loopnors)[3], float (*polynors)[3], const short mix_mode, const float mix_factor, const float mix_limit, @@ -200,7 +200,7 @@ static void normalEditModifier_do_radial( MVert *mvert, const int num_verts, MEdge *medge, const int num_edges, MLoop *mloop, const int num_loops, MPoly *mpoly, const int num_polys) { - Object *ob_target = DEG_get_evaluated_object(ctx->depsgraph, enmd->target); + Object *ob_target = enmd->target; const bool do_polynors_fix = (enmd->flag & MOD_NORMALEDIT_NO_POLYNORS_FIX) == 0; int i; @@ -296,7 +296,7 @@ static void normalEditModifier_do_radial( } static void normalEditModifier_do_directional( - NormalEditModifierData *enmd, const ModifierEvalContext *ctx, + NormalEditModifierData *enmd, const ModifierEvalContext *UNUSED(ctx), Object *ob, Mesh *mesh, short (*clnors)[2], float (*loopnors)[3], float (*polynors)[3], const short mix_mode, const float mix_factor, const float mix_limit, @@ -304,7 +304,7 @@ static void normalEditModifier_do_directional( MVert *mvert, const int num_verts, MEdge *medge, const int num_edges, MLoop *mloop, const int num_loops, MPoly *mpoly, const int num_polys) { - Object *ob_target = DEG_get_evaluated_object(ctx->depsgraph, enmd->target); + Object *ob_target = enmd->target; const bool do_polynors_fix = (enmd->flag & MOD_NORMALEDIT_NO_POLYNORS_FIX) == 0; const bool use_parallel_normals = (enmd->flag & MOD_NORMALEDIT_USE_DIRECTION_PARALLEL) != 0; @@ -556,12 +556,6 @@ ModifierTypeInfo modifierType_NormalEdit = { /* copyData */ modifier_copyData_generic, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -578,4 +572,5 @@ ModifierTypeInfo modifierType_NormalEdit = { /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_ocean.c b/source/blender/modifiers/intern/MOD_ocean.c index 50ec32bd605..5379321239c 100644 --- a/source/blender/modifiers/intern/MOD_ocean.c +++ b/source/blender/modifiers/intern/MOD_ocean.c @@ -176,7 +176,6 @@ typedef struct GenerateOceanGeometryData { MVert *mverts; MPoly *mpolys; MLoop *mloops; - int *origindex; MLoopUV *mloopuvs; int res_x, res_y; @@ -230,9 +229,6 @@ static void generate_ocean_geometry_polygons( mp->totloop = 4; mp->flag |= ME_SMOOTH; - - /* generated geometry does not map to original faces */ - gogd->origindex[fi] = ORIGINDEX_NONE; } } @@ -299,8 +295,6 @@ static Mesh *generate_ocean_geometry(OceanModifierData *omd) gogd.mpolys = result->mpoly; gogd.mloops = result->mloop; - gogd.origindex = CustomData_get_layer(&result->pdata, CD_ORIGINDEX); - ParallelRangeSettings settings; BLI_parallel_range_settings_defaults(&settings); settings.use_threading = use_threading; @@ -503,12 +497,6 @@ ModifierTypeInfo modifierType_Ocean = { /* copyData */ copyData, /* deformMatrices_DM */ NULL, - /* deformVerts_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - - /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, /* deformMatricesEM */ NULL, @@ -524,4 +512,5 @@ ModifierTypeInfo modifierType_Ocean = { /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_particleinstance.c b/source/blender/modifiers/intern/MOD_particleinstance.c index a9d8db493b8..189255a7dd1 100644 --- a/source/blender/modifiers/intern/MOD_particleinstance.c +++ b/source/blender/modifiers/intern/MOD_particleinstance.c @@ -524,12 +524,6 @@ ModifierTypeInfo modifierType_ParticleInstance = { /* copyData */ modifier_copyData_generic, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -546,4 +540,5 @@ ModifierTypeInfo modifierType_ParticleInstance = { /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_particlesystem.c b/source/blender/modifiers/intern/MOD_particlesystem.c index 08a19506694..5b3e104072c 100644 --- a/source/blender/modifiers/intern/MOD_particlesystem.c +++ b/source/blender/modifiers/intern/MOD_particlesystem.c @@ -246,12 +246,6 @@ ModifierTypeInfo modifierType_ParticleSystem = { /* copyData */ copyData, - /* deformVerts_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ deformVerts, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -268,4 +262,5 @@ ModifierTypeInfo modifierType_ParticleSystem = { /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_remesh.c b/source/blender/modifiers/intern/MOD_remesh.c index 2ff82d863df..345ee6477ac 100644 --- a/source/blender/modifiers/intern/MOD_remesh.c +++ b/source/blender/modifiers/intern/MOD_remesh.c @@ -216,12 +216,6 @@ ModifierTypeInfo modifierType_Remesh = { /* copyData */ modifier_copyData_generic, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -237,4 +231,5 @@ ModifierTypeInfo modifierType_Remesh = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_screw.c b/source/blender/modifiers/intern/MOD_screw.c index 837b4d3d532..8e881fd09f0 100644 --- a/source/blender/modifiers/intern/MOD_screw.c +++ b/source/blender/modifiers/intern/MOD_screw.c @@ -236,7 +236,7 @@ static Mesh *applyModifier( MEdge *medge_orig, *med_orig, *med_new, *med_new_firstloop, *medge_new; MVert *mvert_new, *mvert_orig, *mv_orig, *mv_new, *mv_new_base; - Object *ob_axis = DEG_get_evaluated_object(ctx->depsgraph, ltmd->ob_axis); + Object *ob_axis = ltmd->ob_axis; ScrewVertConnect *vc, *vc_tmp, *vert_connect = NULL; @@ -1135,12 +1135,6 @@ ModifierTypeInfo modifierType_Screw = { /* copyData */ modifier_copyData_generic, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -1157,4 +1151,5 @@ ModifierTypeInfo modifierType_Screw = { /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_shapekey.c b/source/blender/modifiers/intern/MOD_shapekey.c index 3530ca21d34..dd5f53c408a 100644 --- a/source/blender/modifiers/intern/MOD_shapekey.c +++ b/source/blender/modifiers/intern/MOD_shapekey.c @@ -121,12 +121,6 @@ ModifierTypeInfo modifierType_ShapeKey = { /* copyData */ NULL, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ deformVerts, /* deformMatrices */ deformMatrices, /* deformVertsEM */ deformVertsEM, @@ -143,4 +137,5 @@ ModifierTypeInfo modifierType_ShapeKey = { /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_shrinkwrap.c b/source/blender/modifiers/intern/MOD_shrinkwrap.c index 7b33df5bf86..73e99738458 100644 --- a/source/blender/modifiers/intern/MOD_shrinkwrap.c +++ b/source/blender/modifiers/intern/MOD_shrinkwrap.c @@ -183,12 +183,6 @@ ModifierTypeInfo modifierType_Shrinkwrap = { /* copyData */ modifier_copyData_generic, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ deformVerts, /* deformMatrices */ NULL, /* deformVertsEM */ deformVertsEM, @@ -205,4 +199,5 @@ ModifierTypeInfo modifierType_Shrinkwrap = { /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_simpledeform.c b/source/blender/modifiers/intern/MOD_simpledeform.c index cc36cfbf9eb..0ebeb1cd761 100644 --- a/source/blender/modifiers/intern/MOD_simpledeform.c +++ b/source/blender/modifiers/intern/MOD_simpledeform.c @@ -178,7 +178,7 @@ static void simpleDeform_bend(const float factor, const int axis, const float dc /* simple deform modifier */ static void SimpleDeformModifier_do( - SimpleDeformModifierData *smd, const ModifierEvalContext *ctx, + SimpleDeformModifierData *smd, const ModifierEvalContext *UNUSED(ctx), struct Object *ob, struct Mesh *mesh, float (*vertexCos)[3], int numVerts) { @@ -222,7 +222,7 @@ static void SimpleDeformModifier_do( /* Calculate matrixs do convert between coordinate spaces */ if (smd->origin != NULL) { transf = &tmp_transf; - BLI_SPACE_TRANSFORM_SETUP(transf, ob, DEG_get_evaluated_object(ctx->depsgraph, smd->origin)); + BLI_SPACE_TRANSFORM_SETUP(transf, ob, smd->origin); } /* Update limits if needed */ @@ -429,12 +429,6 @@ ModifierTypeInfo modifierType_SimpleDeform = { /* copyData */ modifier_copyData_generic, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ deformVerts, /* deformMatrices */ NULL, /* deformVertsEM */ deformVertsEM, @@ -451,4 +445,5 @@ ModifierTypeInfo modifierType_SimpleDeform = { /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_skin.c b/source/blender/modifiers/intern/MOD_skin.c index 7ba7882d0d0..dab2d72133b 100644 --- a/source/blender/modifiers/intern/MOD_skin.c +++ b/source/blender/modifiers/intern/MOD_skin.c @@ -1940,12 +1940,6 @@ ModifierTypeInfo modifierType_Skin = { /* copyData */ modifier_copyData_generic, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -1961,4 +1955,5 @@ ModifierTypeInfo modifierType_Skin = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_smoke.c b/source/blender/modifiers/intern/MOD_smoke.c index 905e8a18e1b..8a0a8e227ae 100644 --- a/source/blender/modifiers/intern/MOD_smoke.c +++ b/source/blender/modifiers/intern/MOD_smoke.c @@ -165,12 +165,6 @@ ModifierTypeInfo modifierType_Smoke = { /* copyData */ copyData, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -187,4 +181,5 @@ ModifierTypeInfo modifierType_Smoke = { /* foreachObjectLink */ NULL, /* foreachIDLink */ foreachIDLink, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_smooth.c b/source/blender/modifiers/intern/MOD_smooth.c index 2b9339842fa..685a4837d32 100644 --- a/source/blender/modifiers/intern/MOD_smooth.c +++ b/source/blender/modifiers/intern/MOD_smooth.c @@ -244,12 +244,6 @@ ModifierTypeInfo modifierType_Smooth = { /* copyData */ modifier_copyData_generic, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ deformVerts, /* deformMatrices */ NULL, /* deformVertsEM */ deformVertsEM, @@ -266,4 +260,5 @@ ModifierTypeInfo modifierType_Smooth = { /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_softbody.c b/source/blender/modifiers/intern/MOD_softbody.c index 868b42bc241..2ff50ee3977 100644 --- a/source/blender/modifiers/intern/MOD_softbody.c +++ b/source/blender/modifiers/intern/MOD_softbody.c @@ -76,12 +76,6 @@ ModifierTypeInfo modifierType_Softbody = { /* copyData */ NULL, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ deformVerts, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -98,4 +92,5 @@ ModifierTypeInfo modifierType_Softbody = { /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_solidify.c b/source/blender/modifiers/intern/MOD_solidify.c index e449403eb70..e8a7d8217ed 100644 --- a/source/blender/modifiers/intern/MOD_solidify.c +++ b/source/blender/modifiers/intern/MOD_solidify.c @@ -768,15 +768,17 @@ static Mesh *applyModifier( /* add faces & edges */ origindex_edge = CustomData_get_layer(&result->edata, CD_ORIGINDEX); - BLI_assert((numEdges == 0) || (origindex_edge != NULL)); + orig_ed = (origindex_edge) ? &origindex_edge[(numEdges * stride) + newEdges] : NULL; ed = &medge[(numEdges * stride) + newEdges]; /* start after copied edges */ - orig_ed = &origindex_edge[(numEdges * stride) + newEdges]; - for (i = 0; i < rimVerts; i++, ed++, orig_ed++) { + for (i = 0; i < rimVerts; i++, ed++) { ed->v1 = new_vert_arr[i]; ed->v2 = (do_shell ? new_vert_arr[i] : i) + numVerts; ed->flag |= ME_EDGEDRAW | ME_EDGERENDER; - *orig_ed = ORIGINDEX_NONE; + if (orig_ed) { + *orig_ed = ORIGINDEX_NONE; + orig_ed++; + } if (crease_rim) { ed->crease = crease_rim; @@ -848,8 +850,10 @@ static Mesh *applyModifier( ml[j++].e = (numEdges * stride) + old_vert_arr[ed->v2] + newEdges; } - origindex_edge[ml[j - 3].e] = ORIGINDEX_NONE; - origindex_edge[ml[j - 1].e] = ORIGINDEX_NONE; + if (origindex_edge) { + origindex_edge[ml[j - 3].e] = ORIGINDEX_NONE; + origindex_edge[ml[j - 1].e] = ORIGINDEX_NONE; + } /* use the next material index if option enabled */ if (mat_ofs_rim) { @@ -953,12 +957,6 @@ ModifierTypeInfo modifierType_Solidify = { /* copyData */ modifier_copyData_generic, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -975,4 +973,5 @@ ModifierTypeInfo modifierType_Solidify = { /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_subsurf.c b/source/blender/modifiers/intern/MOD_subsurf.c index 1899faa3583..40c9e5c3b1b 100644 --- a/source/blender/modifiers/intern/MOD_subsurf.c +++ b/source/blender/modifiers/intern/MOD_subsurf.c @@ -24,6 +24,8 @@ #include <stddef.h> +#include "MEM_guardedalloc.h" + #include "BLI_utildefines.h" #include "DNA_object_types.h" @@ -44,6 +46,11 @@ #include "intern/CCGSubSurf.h" +typedef struct SubsurfRuntimeData { + /* Cached subdivision surface descriptor, with topology and settings. */ + struct Subdiv *subdiv; +} SubsurfRuntimeData; + static void initData(ModifierData *md) { SubsurfModifierData *smd = (SubsurfModifierData *) md; @@ -64,7 +71,18 @@ static void copyData(const ModifierData *md, ModifierData *target, const int fla modifier_copyData_generic(md, target, flag); tsmd->emCache = tsmd->mCache = NULL; - tsmd->subdiv = NULL; +} + +static void freeRuntimeData(void *runtime_data_v) +{ + if (runtime_data_v == NULL) { + return; + } + SubsurfRuntimeData *runtime_data = (SubsurfRuntimeData *)runtime_data_v; + if (runtime_data->subdiv != NULL) { + BKE_subdiv_free(runtime_data->subdiv); + } + MEM_freeN(runtime_data); } static void freeData(ModifierData *md) @@ -79,9 +97,7 @@ static void freeData(ModifierData *md) ccgSubSurf_free(smd->emCache); smd->emCache = NULL; } - if (smd->subdiv != NULL) { - BKE_subdiv_free(smd->subdiv); - } + freeRuntimeData(smd->modifier.runtime); } static bool isDisabled(const Scene *scene, ModifierData *md, bool useRenderParams) @@ -121,9 +137,11 @@ static Subdiv *subdiv_descriptor_ensure(SubsurfModifierData *smd, const SubdivSettings *subdiv_settings, const Mesh *mesh) { + SubsurfRuntimeData *runtime_data = + (SubsurfRuntimeData *)smd->modifier.runtime; Subdiv *subdiv = BKE_subdiv_update_from_mesh( - smd->subdiv, subdiv_settings, mesh); - smd->subdiv = subdiv; + runtime_data->subdiv, subdiv_settings, mesh); + runtime_data->subdiv = subdiv; return subdiv; } @@ -181,6 +199,17 @@ static Mesh *subdiv_as_ccg(SubsurfModifierData *smd, return result; } +static SubsurfRuntimeData *subsurf_ensure_runtime(SubsurfModifierData *smd) +{ + SubsurfRuntimeData *runtime_data = + (SubsurfRuntimeData *)smd->modifier.runtime; + if (runtime_data == NULL) { + runtime_data = MEM_callocN(sizeof(*runtime_data), "subsurf runtime"); + smd->modifier.runtime = runtime_data; + } + return runtime_data; +} + /* Modifier itself. */ static Mesh *applyModifier(ModifierData *md, @@ -195,6 +224,7 @@ static Mesh *applyModifier(ModifierData *md, return result; } BKE_subdiv_settings_validate_for_mesh(&subdiv_settings, mesh); + SubsurfRuntimeData *runtime_data = subsurf_ensure_runtime(smd); Subdiv *subdiv = subdiv_descriptor_ensure(smd, &subdiv_settings, mesh); if (subdiv == NULL) { /* Happens on bad topology, but also on empty input mesh. */ @@ -209,7 +239,7 @@ static Mesh *applyModifier(ModifierData *md, result = subdiv_as_ccg(smd, ctx, mesh, subdiv); } // BKE_subdiv_stats_print(&subdiv->stats); - if (subdiv != smd->subdiv) { + if (subdiv != runtime_data->subdiv) { BKE_subdiv_free(subdiv); } return result; @@ -228,12 +258,6 @@ ModifierTypeInfo modifierType_Subsurf = { /* copyData */ copyData, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -250,4 +274,5 @@ ModifierTypeInfo modifierType_Subsurf = { /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ freeRuntimeData, }; diff --git a/source/blender/modifiers/intern/MOD_surface.c b/source/blender/modifiers/intern/MOD_surface.c index ee3c99bef85..c0fbb4d9ac3 100644 --- a/source/blender/modifiers/intern/MOD_surface.c +++ b/source/blender/modifiers/intern/MOD_surface.c @@ -195,12 +195,6 @@ ModifierTypeInfo modifierType_Surface = { /* copyData */ copyData, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ deformVerts, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -217,4 +211,5 @@ ModifierTypeInfo modifierType_Surface = { /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c index 554545077fa..44307b4271e 100644 --- a/source/blender/modifiers/intern/MOD_surfacedeform.c +++ b/source/blender/modifiers/intern/MOD_surfacedeform.c @@ -1124,7 +1124,7 @@ static void deformVert( static void surfacedeformModifier_do( ModifierData *md, - const ModifierEvalContext *ctx, + const ModifierEvalContext *UNUSED(ctx), float (*vertexCos)[3], unsigned int numverts, Object *ob) { SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md; @@ -1147,7 +1147,7 @@ static void surfacedeformModifier_do( return; } - Object *ob_target = DEG_get_evaluated_object(ctx->depsgraph, smd->target); + Object *ob_target = smd->target; target = BKE_modifier_get_evaluated_mesh_from_evaluated_object(ob_target, false); #if 0 /* Should not be needed anymore since we always get that mesh from eval object ? */ if (target == NULL && smd->verts == NULL && ob == DEG_get_original_object(ob)) { @@ -1256,12 +1256,6 @@ ModifierTypeInfo modifierType_SurfaceDeform = { /* copyData */ copyData, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ deformVerts, /* deformMatrices */ NULL, /* deformVertsEM */ deformVertsEM, @@ -1278,4 +1272,5 @@ ModifierTypeInfo modifierType_SurfaceDeform = { /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_triangulate.c b/source/blender/modifiers/intern/MOD_triangulate.c index 802bde21b5c..0b4de9c8d17 100644 --- a/source/blender/modifiers/intern/MOD_triangulate.c +++ b/source/blender/modifiers/intern/MOD_triangulate.c @@ -34,7 +34,7 @@ #include "MOD_modifiertypes.h" -static Mesh *triangulate_mesh(Mesh *mesh, const int quad_method, const int ngon_method, const int flag) +static Mesh *triangulate_mesh(Mesh *mesh, const int quad_method, const int ngon_method, const int min_vertices, const int flag) { Mesh *result; BMesh *bm; @@ -59,7 +59,7 @@ static Mesh *triangulate_mesh(Mesh *mesh, const int quad_method, const int ngon_ .cd_mask_extra = cddata_masks, })); - BM_mesh_triangulate(bm, quad_method, ngon_method, false, NULL, NULL, NULL); + BM_mesh_triangulate(bm, quad_method, ngon_method, min_vertices, false, NULL, NULL, NULL); result = BKE_mesh_from_bmesh_for_eval_nomain(bm, &cddata_masks); BM_mesh_free(bm); @@ -98,6 +98,7 @@ static void initData(ModifierData *md) md->mode |= eModifierMode_Editmode; tmd->quad_method = MOD_TRIANGULATE_QUAD_SHORTEDGE; tmd->ngon_method = MOD_TRIANGULATE_NGON_BEAUTY; + tmd->min_vertices = 4; } static Mesh *applyModifier( @@ -107,7 +108,7 @@ static Mesh *applyModifier( { TriangulateModifierData *tmd = (TriangulateModifierData *)md; Mesh *result; - if (!(result = triangulate_mesh(mesh, tmd->quad_method, tmd->ngon_method, tmd->flag))) { + if (!(result = triangulate_mesh(mesh, tmd->quad_method, tmd->ngon_method, tmd->min_vertices, tmd->flag))) { return mesh; } @@ -127,12 +128,6 @@ ModifierTypeInfo modifierType_Triangulate = { /* copyData */ modifier_copyData_generic, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -148,4 +143,5 @@ ModifierTypeInfo modifierType_Triangulate = { /* dependsOnNormals */ NULL, /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_util.c b/source/blender/modifiers/intern/MOD_util.c index 941fcf6cf9a..2d4a3dc1778 100644 --- a/source/blender/modifiers/intern/MOD_util.c +++ b/source/blender/modifiers/intern/MOD_util.c @@ -59,7 +59,7 @@ void MOD_init_texture(MappingInfoModifierData *dmd, const ModifierEvalContext *ctx) { - Tex *tex = (Tex *)DEG_get_evaluated_id(ctx->depsgraph, &dmd->texture->id); + Tex *tex = dmd->texture; if (tex == NULL) { return; @@ -74,7 +74,7 @@ void MOD_init_texture(MappingInfoModifierData *dmd, const ModifierEvalContext *c /** \param cos: may be NULL, in which case we use directly mesh vertices' coordinates. */ void MOD_get_texture_coords( MappingInfoModifierData *dmd, - const ModifierEvalContext *ctx, + const ModifierEvalContext *UNUSED(ctx), Object *ob, Mesh *mesh, float (*cos)[3], @@ -87,7 +87,7 @@ void MOD_get_texture_coords( if (texmapping == MOD_DISP_MAP_OBJECT) { if (dmd->map_object != NULL) { - Object *map_object = DEG_get_evaluated_object(ctx->depsgraph, dmd->map_object); + Object *map_object = dmd->map_object; invert_m4_m4(mapob_imat, map_object->obmat); } else {/* if there is no map object, default to local */ diff --git a/source/blender/modifiers/intern/MOD_uvproject.c b/source/blender/modifiers/intern/MOD_uvproject.c index 26c7ec7ed13..06cd7a80494 100644 --- a/source/blender/modifiers/intern/MOD_uvproject.c +++ b/source/blender/modifiers/intern/MOD_uvproject.c @@ -109,7 +109,7 @@ typedef struct Projector { static Mesh *uvprojectModifier_do( UVProjectModifierData *umd, - const ModifierEvalContext *ctx, + const ModifierEvalContext *UNUSED(ctx), Object *ob, Mesh *mesh) { float (*coords)[3], (*co)[3]; @@ -128,7 +128,7 @@ static Mesh *uvprojectModifier_do( for (i = 0; i < umd->num_projectors; ++i) { if (umd->projectors[i] != NULL) { - projectors[num_projectors++].ob = DEG_get_evaluated_object(ctx->depsgraph, umd->projectors[i]); + projectors[num_projectors++].ob = umd->projectors[i]; } } @@ -323,12 +323,6 @@ ModifierTypeInfo modifierType_UVProject = { /* copyData */ modifier_copyData_generic, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -345,4 +339,5 @@ ModifierTypeInfo modifierType_UVProject = { /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ foreachIDLink, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_uvwarp.c b/source/blender/modifiers/intern/MOD_uvwarp.c index d4f17b742f1..a850bb34111 100644 --- a/source/blender/modifiers/intern/MOD_uvwarp.c +++ b/source/blender/modifiers/intern/MOD_uvwarp.c @@ -161,8 +161,8 @@ static Mesh *applyModifier( } /* make sure anything moving UVs is available */ - matrix_from_obj_pchan(mat_src, DEG_get_evaluated_object(ctx->depsgraph, umd->object_src), umd->bone_src); - matrix_from_obj_pchan(mat_dst, DEG_get_evaluated_object(ctx->depsgraph, umd->object_dst), umd->bone_dst); + matrix_from_obj_pchan(mat_src, umd->object_src, umd->bone_src); + matrix_from_obj_pchan(mat_dst, umd->object_dst, umd->bone_dst); invert_m4_m4(imat_dst, mat_dst); mul_m4_m4m4(warp_mat, imat_dst, mat_src); @@ -255,12 +255,6 @@ ModifierTypeInfo modifierType_UVWarp = { /* copyData */ modifier_copyData_generic, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -277,4 +271,5 @@ ModifierTypeInfo modifierType_UVWarp = { /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c index adda5df61ea..30bd391ef84 100644 --- a/source/blender/modifiers/intern/MOD_warp.c +++ b/source/blender/modifiers/intern/MOD_warp.c @@ -189,8 +189,8 @@ static void warpModifier_do( invert_m4_m4(obinv, ob->obmat); - mul_m4_m4m4(mat_from, obinv, DEG_get_evaluated_object(ctx->depsgraph, wmd->object_from)->obmat); - mul_m4_m4m4(mat_to, obinv, DEG_get_evaluated_object(ctx->depsgraph, wmd->object_to)->obmat); + mul_m4_m4m4(mat_from, obinv, wmd->object_from->obmat); + mul_m4_m4m4(mat_to, obinv, wmd->object_to->obmat); invert_m4_m4(tmat, mat_from); // swap? mul_m4_m4m4(mat_final, tmat, mat_to); @@ -211,7 +211,7 @@ static void warpModifier_do( } weight = strength; - Tex *tex_target = (Tex *)DEG_get_evaluated_id(ctx->depsgraph, &wmd->texture->id); + Tex *tex_target = wmd->texture; if (mesh != NULL && tex_target != NULL) { tex_co = MEM_malloc_arrayN(numVerts, sizeof(*tex_co), "warpModifier_do tex_co"); MOD_get_texture_coords((MappingInfoModifierData *)wmd, ctx, ob, mesh, vertexCos, tex_co); @@ -357,12 +357,6 @@ ModifierTypeInfo modifierType_Warp = { eModifierTypeFlag_SupportsEditmode, /* copyData */ copyData, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ deformVerts, /* deformMatrices */ NULL, /* deformVertsEM */ deformVertsEM, @@ -379,4 +373,5 @@ ModifierTypeInfo modifierType_Warp = { /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ foreachIDLink, /* foreachTexLink */ foreachTexLink, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c index 80ac323c82f..d5c372a2809 100644 --- a/source/blender/modifiers/intern/MOD_wave.c +++ b/source/blender/modifiers/intern/MOD_wave.c @@ -167,7 +167,7 @@ static void waveModifier_do( float mat[4][4]; /* get the control object's location in local coordinates */ invert_m4_m4(ob->imat, ob->obmat); - mul_m4_m4m4(mat, ob->imat, DEG_get_evaluated_object(ctx->depsgraph, wmd->objectcenter)->obmat); + mul_m4_m4m4(mat, ob->imat, wmd->objectcenter->obmat); wmd->startx = mat[3][0]; wmd->starty = mat[3][1]; @@ -191,7 +191,7 @@ static void waveModifier_do( } } - Tex *tex_target = (Tex *)DEG_get_evaluated_id(ctx->depsgraph, &wmd->texture->id); + Tex *tex_target = wmd->texture; if (mesh != NULL && tex_target != NULL) { tex_co = MEM_malloc_arrayN(numVerts, sizeof(*tex_co), "waveModifier_do tex_co"); MOD_get_texture_coords((MappingInfoModifierData *)wmd, ctx, ob, mesh, vertexCos, tex_co); @@ -357,12 +357,6 @@ ModifierTypeInfo modifierType_Wave = { /* copyData */ modifier_copyData_generic, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ deformVerts, /* deformMatrices */ NULL, /* deformVertsEM */ deformVertsEM, @@ -379,4 +373,5 @@ ModifierTypeInfo modifierType_Wave = { /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ foreachIDLink, /* foreachTexLink */ foreachTexLink, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_weighted_normal.c b/source/blender/modifiers/intern/MOD_weighted_normal.c index 9eda072b7d3..98b2117e5a3 100644 --- a/source/blender/modifiers/intern/MOD_weighted_normal.c +++ b/source/blender/modifiers/intern/MOD_weighted_normal.c @@ -537,7 +537,6 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes const bool has_clnors = clnors != NULL; if (!clnors) { clnors = CustomData_add_layer(ldata, CD_CUSTOMLOOPNORMAL, CD_CALLOC, NULL, numLoops); - clnors = CustomData_get_layer(ldata, CD_CUSTOMLOOPNORMAL); } MDeformVert *dvert; @@ -634,12 +633,6 @@ ModifierTypeInfo modifierType_WeightedNormal = { /* copyData */ modifier_copyData_generic, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -656,4 +649,5 @@ ModifierTypeInfo modifierType_WeightedNormal = { /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.c b/source/blender/modifiers/intern/MOD_weightvg_util.c index 85cf3102733..d0631a0c30b 100644 --- a/source/blender/modifiers/intern/MOD_weightvg_util.c +++ b/source/blender/modifiers/intern/MOD_weightvg_util.c @@ -127,7 +127,6 @@ void weightvg_do_mask( /* If we want to mask vgroup weights from a texture. */ if (texture != NULL) { - texture = (Tex *)DEG_get_evaluated_id(ctx->depsgraph, &texture->id); /* The texture coordinates. */ float (*tex_co)[3]; /* See mapping note below... */ diff --git a/source/blender/modifiers/intern/MOD_weightvgedit.c b/source/blender/modifiers/intern/MOD_weightvgedit.c index 32d058e5659..17ccd67dfc9 100644 --- a/source/blender/modifiers/intern/MOD_weightvgedit.c +++ b/source/blender/modifiers/intern/MOD_weightvgedit.c @@ -279,12 +279,6 @@ ModifierTypeInfo modifierType_WeightVGEdit = { /* copyData */ copyData, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -301,4 +295,5 @@ ModifierTypeInfo modifierType_WeightVGEdit = { /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ foreachIDLink, /* foreachTexLink */ foreachTexLink, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_weightvgmix.c b/source/blender/modifiers/intern/MOD_weightvgmix.c index 495d235b406..0894d30cfc1 100644 --- a/source/blender/modifiers/intern/MOD_weightvgmix.c +++ b/source/blender/modifiers/intern/MOD_weightvgmix.c @@ -392,12 +392,6 @@ ModifierTypeInfo modifierType_WeightVGMix = { /* copyData */ modifier_copyData_generic, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -414,4 +408,5 @@ ModifierTypeInfo modifierType_WeightVGMix = { /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ foreachIDLink, /* foreachTexLink */ foreachTexLink, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c index 2e2e4fe963d..89ba5395775 100644 --- a/source/blender/modifiers/intern/MOD_weightvgproximity.c +++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c @@ -338,7 +338,9 @@ static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphConte WeightVGProximityModifierData *wmd = (WeightVGProximityModifierData *)md; if (wmd->proximity_ob_target != NULL) { DEG_add_object_relation(ctx->node, wmd->proximity_ob_target, DEG_OB_COMP_TRANSFORM, "WeightVGProximity Modifier"); - DEG_add_object_relation(ctx->node, wmd->proximity_ob_target, DEG_OB_COMP_GEOMETRY, "WeightVGProximity Modifier"); + if (wmd->proximity_ob_target->data != NULL && wmd->proximity_mode == MOD_WVG_PROXIMITY_GEOMETRY) { + DEG_add_object_relation(ctx->node, wmd->proximity_ob_target, DEG_OB_COMP_GEOMETRY, "WeightVGProximity Modifier"); + } } if (wmd->mask_tex_map_obj != NULL && wmd->mask_tex_mapping == MOD_DISP_MAP_OBJECT) { DEG_add_object_relation(ctx->node, wmd->mask_tex_map_obj, DEG_OB_COMP_TRANSFORM, "WeightVGProximity Modifier"); @@ -396,7 +398,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes } /* Get our target object. */ - obr = DEG_get_evaluated_object(ctx->depsgraph, wmd->proximity_ob_target); + obr = wmd->proximity_ob_target; if (obr == NULL) { return mesh; } @@ -564,12 +566,6 @@ ModifierTypeInfo modifierType_WeightVGProximity = { /* copyData */ modifier_copyData_generic, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -586,4 +582,5 @@ ModifierTypeInfo modifierType_WeightVGProximity = { /* foreachObjectLink */ foreachObjectLink, /* foreachIDLink */ foreachIDLink, /* foreachTexLink */ foreachTexLink, + /* freeRuntimeData */ NULL, }; diff --git a/source/blender/modifiers/intern/MOD_wireframe.c b/source/blender/modifiers/intern/MOD_wireframe.c index 2f70ab16cf8..74ab0ac3d8c 100644 --- a/source/blender/modifiers/intern/MOD_wireframe.c +++ b/source/blender/modifiers/intern/MOD_wireframe.c @@ -115,12 +115,6 @@ ModifierTypeInfo modifierType_Wireframe = { /* copyData */ modifier_copyData_generic, - /* deformVerts_DM */ NULL, - /* deformMatrices_DM */ NULL, - /* deformVertsEM_DM */ NULL, - /* deformMatricesEM_DM*/NULL, - /* applyModifier_DM */ NULL, - /* deformVerts */ NULL, /* deformMatrices */ NULL, /* deformVertsEM */ NULL, @@ -137,4 +131,5 @@ ModifierTypeInfo modifierType_Wireframe = { /* foreachObjectLink */ NULL, /* foreachIDLink */ NULL, /* foreachTexLink */ NULL, + /* freeRuntimeData */ NULL, }; |