[Bf-blender-cvs] [716af6a4701] master: Modifier: apply modifier now works for lattice

Erik Abrahamsson noreply at git.blender.org
Tue Oct 27 03:29:51 CET 2020


Commit: 716af6a4701fe4d6a664deb77b2fafe88bcd1708
Author: Erik Abrahamsson
Date:   Tue Oct 27 13:27:08 2020 +1100
Branches: master
https://developer.blender.org/rB716af6a4701fe4d6a664deb77b2fafe88bcd1708

Modifier: apply modifier now works for lattice

Ref D9337

===================================================================

M	source/blender/editors/object/object_modifier.c

===================================================================

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");



More information about the Bf-blender-cvs mailing list