diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2018-05-24 17:40:08 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2018-05-24 17:43:21 +0300 |
commit | e8c8ff4f86c276e4dca884ff1a411fcbbf003fed (patch) | |
tree | 484745e65e0eb2559c62be0a7581c3102d8cb84b /source | |
parent | 10e43c0aef38647d8904e758e36261c9ac0b6460 (diff) |
Fix all modifiers that depended on BKE_modifier_get_evaluated_mesh_from_object
This fix applying the following modifiers:
* Boolean (working already)
* Array
* Mesh Deform
* Surface Deform
* Vertex Weight Proximity
This function was to return evaluated mesh. So it should get the evaluated
object at all times. So in this case it makes more sense to simply pass the
depsgraph (or in this case the ModifierEvalContext that contains both the
depsgraph and the flag.
Solution discussed with Bastien Montagne.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/BKE_modifier.h | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/modifier.c | 10 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/shrinkwrap.c | 4 | ||||
-rw-r--r-- | source/blender/editors/physics/particle_edit.c | 6 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_modifier_types.h | 1 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_array.c | 4 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_boolean.c | 5 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_meshdeform.c | 12 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_surfacedeform.c | 16 | ||||
-rw-r--r-- | source/blender/modifiers/intern/MOD_weightvgproximity.c | 2 |
10 files changed, 41 insertions, 23 deletions
diff --git a/source/blender/blenkernel/BKE_modifier.h b/source/blender/blenkernel/BKE_modifier.h index ab00b8174b5..c8d50793e76 100644 --- a/source/blender/blenkernel/BKE_modifier.h +++ b/source/blender/blenkernel/BKE_modifier.h @@ -557,7 +557,9 @@ struct DerivedMesh *modifier_applyModifierEM_DM_deprecated( struct ModifierData *md, const struct ModifierEvalContext *ctx, struct BMEditMesh *editData, struct DerivedMesh *dm); -struct Mesh *BKE_modifier_get_evaluated_mesh_from_object(struct Object *ob, const ModifierApplyFlag flag); +struct Mesh *BKE_modifier_get_evaluated_mesh_from_object( + const struct ModifierEvalContext *ctx, + struct Object *ob); #endif diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index c43a2e3b8ec..6201010d2aa 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -74,6 +74,7 @@ /* end */ #include "DEG_depsgraph.h" +#include "DEG_depsgraph_query.h" #include "MOD_modifiertypes.h" @@ -1213,13 +1214,16 @@ struct DerivedMesh *modifier_applyModifierEM_DM_deprecated(struct ModifierData * /** Get evaluated mesh for other object, which is used as an operand for the modifier, * i.e. second operand for boolean modifier. */ -Mesh *BKE_modifier_get_evaluated_mesh_from_object(Object *ob, const ModifierApplyFlag flag) +Mesh *BKE_modifier_get_evaluated_mesh_from_object(const ModifierEvalContext *ctx, Object *ob) { + const ModifierApplyFlag flag = ctx->flag; + Object *ob_eval = DEG_get_evaluated_object(ctx->depsgraph, ob); + if (flag & MOD_APPLY_RENDER) { /* TODO(sergey): Use proper derived render in the future. */ - return ob->mesh_evaluated; + return ob_eval->mesh_evaluated; } else { - return ob->mesh_evaluated; + return ob_eval->mesh_evaluated; } } diff --git a/source/blender/blenkernel/intern/shrinkwrap.c b/source/blender/blenkernel/intern/shrinkwrap.c index 8e8bf395f38..3d3130486cb 100644 --- a/source/blender/blenkernel/intern/shrinkwrap.c +++ b/source/blender/blenkernel/intern/shrinkwrap.c @@ -414,7 +414,7 @@ static void shrinkwrap_calc_normal_projection(ShrinkwrapCalcData *calc, const Mo } if (calc->smd->auxTarget) { - auxMesh = BKE_modifier_get_evaluated_mesh_from_object(calc->smd->auxTarget, ctx->flag); + auxMesh = BKE_modifier_get_evaluated_mesh_from_object(ctx, calc->smd->auxTarget); if (!auxMesh) return; BLI_SPACE_TRANSFORM_SETUP(&local2aux, calc->ob, calc->smd->auxTarget); @@ -625,7 +625,7 @@ void shrinkwrapModifier_deform(ShrinkwrapModifierData *smd, Object *ob, Mesh *me if (smd->target) { - calc.target = BKE_modifier_get_evaluated_mesh_from_object(smd->target, ctx->flag); + calc.target = BKE_modifier_get_evaluated_mesh_from_object(ctx, smd->target); /* TODO there might be several "bugs" on non-uniform scales matrixs * because it will no longer be nearest surface, not sphere projection diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index 7fc3cb8863f..5210ff76491 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -428,7 +428,11 @@ static void PE_set_view3d_data(bContext *C, PEData *data) static bool PE_create_shape_tree(PEData *data, Object *shapeob) { - Mesh *mesh = BKE_modifier_get_evaluated_mesh_from_object(shapeob, 0); + ModifierEvalContext ctx = { + .depsgraph = data->depsgraph, + .flag = 0, + }; + Mesh *mesh = BKE_modifier_get_evaluated_mesh_from_object(&ctx, shapeob); memset(&data->shape_bvh, 0, sizeof(data->shape_bvh)); diff --git a/source/blender/makesdna/DNA_modifier_types.h b/source/blender/makesdna/DNA_modifier_types.h index 7faf1cfe193..4371172f236 100644 --- a/source/blender/makesdna/DNA_modifier_types.h +++ b/source/blender/makesdna/DNA_modifier_types.h @@ -1614,6 +1614,7 @@ typedef struct SDefVert { typedef struct SurfaceDeformModifierData { ModifierData modifier; + struct Depsgraph *depsgraph; struct Object *target; /* bind target object */ SDefVert *verts; /* vertex bind data */ float falloff; diff --git a/source/blender/modifiers/intern/MOD_array.c b/source/blender/modifiers/intern/MOD_array.c index 4a67b8318bb..e74d9087427 100644 --- a/source/blender/modifiers/intern/MOD_array.c +++ b/source/blender/modifiers/intern/MOD_array.c @@ -390,7 +390,7 @@ static Mesh *arrayModifier_doArray( vgroup_start_cap_remap = BKE_object_defgroup_index_map_create( amd->start_cap, ctx->object, &vgroup_start_cap_remap_len); - start_cap_mesh = BKE_modifier_get_evaluated_mesh_from_object(amd->start_cap, ctx->flag); + start_cap_mesh = BKE_modifier_get_evaluated_mesh_from_object(ctx, amd->start_cap); if (start_cap_mesh) { start_cap_nverts = start_cap_mesh->totvert; start_cap_nedges = start_cap_mesh->totedge; @@ -402,7 +402,7 @@ static Mesh *arrayModifier_doArray( vgroup_end_cap_remap = BKE_object_defgroup_index_map_create( amd->end_cap, ctx->object, &vgroup_end_cap_remap_len); - end_cap_mesh = BKE_modifier_get_evaluated_mesh_from_object(amd->end_cap, ctx->flag); + end_cap_mesh = BKE_modifier_get_evaluated_mesh_from_object(ctx, amd->end_cap); if (end_cap_mesh) { end_cap_nverts = end_cap_mesh->totvert; end_cap_nedges = end_cap_mesh->totedge; diff --git a/source/blender/modifiers/intern/MOD_boolean.c b/source/blender/modifiers/intern/MOD_boolean.c index 29c322ae469..73d1388d88f 100644 --- a/source/blender/modifiers/intern/MOD_boolean.c +++ b/source/blender/modifiers/intern/MOD_boolean.c @@ -175,12 +175,11 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes if (!bmd->object) return mesh; - Object *other_eval = DEG_get_evaluated_object(ctx->depsgraph, bmd->object); - mesh_other = BKE_modifier_get_evaluated_mesh_from_object(other_eval, ctx->flag); - + mesh_other = BKE_modifier_get_evaluated_mesh_from_object(ctx, bmd->object); if (mesh_other) { Mesh *result; Object *object_eval = DEG_get_evaluated_object(ctx->depsgraph, ctx->object); + Object *other_eval = DEG_get_evaluated_object(ctx->depsgraph, bmd->object); /* when one of objects is empty (has got no faces) we could speed up * calculation a bit returning one of objects' derived meshes (or empty one) diff --git a/source/blender/modifiers/intern/MOD_meshdeform.c b/source/blender/modifiers/intern/MOD_meshdeform.c index 94adb3d9ebc..48653856178 100644 --- a/source/blender/modifiers/intern/MOD_meshdeform.c +++ b/source/blender/modifiers/intern/MOD_meshdeform.c @@ -275,7 +275,7 @@ static void meshdeform_vert_task( } static void meshdeformModifier_do( - ModifierData *md, Object *ob, Mesh *mesh, + ModifierData *md, Depsgraph *depsgraph, Object *ob, Mesh *mesh, float (*vertexCos)[3], int numVerts) { MeshDeformModifierData *mmd = (MeshDeformModifierData *) md; @@ -307,7 +307,11 @@ static void meshdeformModifier_do( free_cagemesh = true; } else { - cagemesh = BKE_modifier_get_evaluated_mesh_from_object(ob, md->mode & eModifierMode_Render ? MOD_APPLY_RENDER : 0); + ModifierEvalContext ctx = { + .depsgraph = depsgraph, + .flag = md->mode & eModifierMode_Render ? MOD_APPLY_RENDER : 0, + }; + cagemesh = BKE_modifier_get_evaluated_mesh_from_object(&ctx, ob); } /* if we don't have one computed, use derivedmesh from data @@ -421,7 +425,7 @@ static void deformVerts( modifier_vgroup_cache(md, vertexCos); /* if next modifier needs original vertices */ - meshdeformModifier_do(md, ctx->object, mesh_src, vertexCos, numVerts); + meshdeformModifier_do(md, ctx->depsgraph, ctx->object, mesh_src, vertexCos, numVerts); if (mesh_src && mesh_src != mesh) { BKE_id_free(NULL, mesh_src); @@ -437,7 +441,7 @@ static void deformVertsEM( { Mesh *mesh_src = get_mesh(ctx->object, NULL, mesh, NULL, false, false); - meshdeformModifier_do(md, ctx->object, mesh_src, vertexCos, numVerts); + meshdeformModifier_do(md, ctx->depsgraph, ctx->object, mesh_src, vertexCos, numVerts); if (mesh_src && mesh_src != mesh) { BKE_id_free(NULL, mesh_src); diff --git a/source/blender/modifiers/intern/MOD_surfacedeform.c b/source/blender/modifiers/intern/MOD_surfacedeform.c index ab0b31812b2..f03ae73e2bb 100644 --- a/source/blender/modifiers/intern/MOD_surfacedeform.c +++ b/source/blender/modifiers/intern/MOD_surfacedeform.c @@ -1041,7 +1041,7 @@ static bool surfacedeformBind( return data.success == 1; } -static Mesh *surfacedeform_get_mesh(SurfaceDeformModifierData *smd, bool *r_needsfree) +static Mesh *surfacedeform_get_mesh(Depsgraph *depsgraph, SurfaceDeformModifierData *smd, bool *r_needsfree) { Mesh *mesh; @@ -1052,8 +1052,11 @@ static Mesh *surfacedeform_get_mesh(SurfaceDeformModifierData *smd, bool *r_need *r_needsfree = true; } else { - mesh = BKE_modifier_get_evaluated_mesh_from_object( - smd->target, smd->modifier.mode & eModifierMode_Render ? MOD_APPLY_RENDER : 0); + ModifierEvalContext ctx = { + .depsgraph = depsgraph, + .flag = smd->modifier.mode & eModifierMode_Render ? MOD_APPLY_RENDER : 0, + }; + mesh = BKE_modifier_get_evaluated_mesh_from_object(&ctx, smd->target); *r_needsfree = false; } @@ -1124,6 +1127,7 @@ static void deformVert( static void surfacedeformModifier_do( ModifierData *md, + const ModifierEvalContext *ctx, float (*vertexCos)[3], unsigned int numverts, Object *ob) { SurfaceDeformModifierData *smd = (SurfaceDeformModifierData *)md; @@ -1137,7 +1141,7 @@ static void surfacedeformModifier_do( return; } - target = surfacedeform_get_mesh(smd, &free_target); + target = surfacedeform_get_mesh(ctx->depsgraph, smd, &free_target); if (!target) { modifier_setError(md, "No valid target mesh"); return; @@ -1204,7 +1208,7 @@ static void deformVerts( Mesh *UNUSED(mesh), float (*vertexCos)[3], int numVerts) { - surfacedeformModifier_do(md, vertexCos, numVerts, ctx->object); + surfacedeformModifier_do(md, ctx, vertexCos, numVerts, ctx->object); } static void deformVertsEM( @@ -1213,7 +1217,7 @@ static void deformVertsEM( Mesh *UNUSED(mesh), float (*vertexCos)[3], int numVerts) { - surfacedeformModifier_do(md, vertexCos, numVerts, ctx->object); + surfacedeformModifier_do(md, ctx, vertexCos, numVerts, ctx->object); } static bool isDisabled(ModifierData *md, int UNUSED(useRenderParams)) diff --git a/source/blender/modifiers/intern/MOD_weightvgproximity.c b/source/blender/modifiers/intern/MOD_weightvgproximity.c index 64133222c1e..9e77e0d3794 100644 --- a/source/blender/modifiers/intern/MOD_weightvgproximity.c +++ b/source/blender/modifiers/intern/MOD_weightvgproximity.c @@ -506,7 +506,7 @@ static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mes const bool use_trgt_faces = (wmd->proximity_flags & MOD_WVG_PROXIMITY_GEOM_FACES) != 0; if (use_trgt_verts || use_trgt_edges || use_trgt_faces) { - Mesh *target_mesh = BKE_modifier_get_evaluated_mesh_from_object(obr, ctx->flag); + Mesh *target_mesh = BKE_modifier_get_evaluated_mesh_from_object(ctx, obr); /* We must check that we do have a valid target_mesh! */ if (target_mesh != NULL) { |