Mesh: Add utility to calculate deform modifier up to index
authorSergey Sharybin <sergey.vfx@gmail.com>
Tue, 17 Mar 2020 14:28:24 +0000 (15:28 +0100)
committerSergey Sharybin <sergey.vfx@gmail.com>
Tue, 17 Mar 2020 15:41:43 +0000 (16:41 +0100)
Intention is to be used to create mesh at the state which is an input
to the multires modifier.

source/blender/blenkernel/BKE_mesh_runtime.h
source/blender/blenkernel/intern/DerivedMesh.c

index fdddafcc71f4891c82f9404ace539ac4d61010ca..bdf7692b89b722e60c9f96a2f62902837859eb9b 100644 (file)
@@ -87,6 +87,12 @@ struct Mesh *mesh_create_eval_final_view(struct Depsgraph *depsgraph,
                                          struct Object *ob,
                                          const struct CustomData_MeshMasks *dataMask);
 
+struct Mesh *mesh_create_eval_final_view_index(struct Depsgraph *depsgraph,
+                                               struct Scene *scene,
+                                               struct Object *ob,
+                                               const struct CustomData_MeshMasks *dataMask,
+                                               int index);
+
 struct Mesh *mesh_create_eval_no_deform(struct Depsgraph *depsgraph,
                                         struct Scene *scene,
                                         struct Object *ob,
index 5feb51534e9f0e26e5ad84af1c0b942e3bd63fb9..2db48e1fb13ee37ec9e8c8607e9f9acab7a4a5f5 100644 (file)
@@ -2013,6 +2013,27 @@ Mesh *mesh_create_eval_final_view(Depsgraph *depsgraph,
   return final;
 }
 
+Mesh *mesh_create_eval_final_view_index(Depsgraph *depsgraph,
+                                        Scene *scene,
+                                        Object *ob,
+                                        const CustomData_MeshMasks *dataMask,
+                                        int index)
+{
+  Mesh *final;
+
+  /* XXX hack
+   * psys modifier updates particle state when called during dupli-list generation,
+   * which can lead to wrong transforms. This disables particle system modifier execution.
+   */
+  ob->transflag |= OB_NO_PSYS_UPDATE;
+
+  mesh_calc_modifiers(depsgraph, scene, ob, 1, false, dataMask, index, false, false, NULL, &final);
+
+  ob->transflag &= ~OB_NO_PSYS_UPDATE;
+
+  return final;
+}
+
 Mesh *mesh_create_eval_no_deform(Depsgraph *depsgraph,
                                  Scene *scene,
                                  Object *ob,