diff options
author | Erik Abrahamsson <erik85> | 2020-10-27 05:27:08 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-10-27 05:27:08 +0300 |
commit | 716af6a4701fe4d6a664deb77b2fafe88bcd1708 (patch) | |
tree | 2817a4f66b3dfeb923af9ca9d0b0cebcab7065c5 | |
parent | 527f8b32b32187f754e5b176db6377736f9cb8ff (diff) |
Modifier: apply modifier now works for lattice
Ref D9337
-rw-r--r-- | source/blender/editors/object/object_modifier.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index b8891b612c9..146e399a04d 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -31,6 +31,7 @@ #include "DNA_armature_types.h" #include "DNA_curve_types.h" #include "DNA_key_types.h" +#include "DNA_lattice_types.h" #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_object_force_types.h" @@ -798,6 +799,25 @@ static int modifier_apply_obdata( DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); } + else if (ob->type == OB_LATTICE) { + Object *object_eval = DEG_get_evaluated_object(depsgraph, ob); + Lattice *lattice = ob->data; + ModifierEvalContext mectx = {depsgraph, object_eval, 0}; + + if (ELEM(mti->type, eModifierTypeType_Constructive, eModifierTypeType_Nonconstructive)) { + BKE_report(reports, RPT_ERROR, "Constructive modifiers cannot be applied"); + return 0; + } + + int numVerts; + float(*vertexCos)[3] = BKE_lattice_vert_coords_alloc(lattice, &numVerts); + mti->deformVerts(md_eval, &mectx, NULL, vertexCos, numVerts); + BKE_lattice_vert_coords_apply(lattice, vertexCos); + + MEM_freeN(vertexCos); + + DEG_id_tag_update(&ob->id, ID_RECALC_GEOMETRY); + } else { /* TODO: implement for hair, pointclouds and volumes. */ BKE_report(reports, RPT_ERROR, "Cannot apply modifier for this object type"); |