Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Abrahamsson <erik85>2020-10-27 05:27:08 +0300
committerCampbell Barton <ideasman42@gmail.com>2020-10-27 05:27:08 +0300
commit716af6a4701fe4d6a664deb77b2fafe88bcd1708 (patch)
tree2817a4f66b3dfeb923af9ca9d0b0cebcab7065c5
parent527f8b32b32187f754e5b176db6377736f9cb8ff (diff)
Modifier: apply modifier now works for lattice
Ref D9337
-rw-r--r--source/blender/editors/object/object_modifier.c20
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");