[Bf-blender-cvs] [af9eedc626a] soc-2019-adaptive-cloth: Initial steps to let modifier have changing vertices

ishbosamiya noreply at git.blender.org
Fri May 31 11:21:33 CEST 2019


Commit: af9eedc626a45d0f7d2a4bc28497570fde113562
Author: ishbosamiya
Date:   Fri May 31 01:05:12 2019 +0530
Branches: soc-2019-adaptive-cloth
https://developer.blender.org/rBaf9eedc626a45d0f7d2a4bc28497570fde113562

Initial steps to let modifier have changing vertices

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

M	source/blender/modifiers/intern/MOD_cloth.c

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

diff --git a/source/blender/modifiers/intern/MOD_cloth.c b/source/blender/modifiers/intern/MOD_cloth.c
index 35bf98037d8..679fa84df2d 100644
--- a/source/blender/modifiers/intern/MOD_cloth.c
+++ b/source/blender/modifiers/intern/MOD_cloth.c
@@ -134,6 +134,21 @@ static void deformVerts(ModifierData *md,
   BKE_id_free(NULL, mesh_src);
 }
 
+static Mesh *applyModifier(ModifierData *md, const ModifierEvalContext *ctx, Mesh *mesh)
+{
+  Mesh *result;
+  int numVerts;
+  float(*deformedVerts)[3] = BKE_mesh_vertexCos_get(mesh, &numVerts);
+
+  BKE_id_copy_ex(NULL, &mesh->id, (ID **)&result, LIB_ID_COPY_LOCALIZE);
+  deformVerts(md, ctx, result, deformedVerts, numVerts);
+  BKE_mesh_apply_vert_coords(result, deformedVerts);
+
+  MEM_freeN(deformedVerts);
+
+  return result;
+}
+
 static void updateDepsgraph(ModifierData *md, const ModifierUpdateDepsgraphContext *ctx)
 {
   ClothModifierData *clmd = (ClothModifierData *)md;
@@ -268,17 +283,17 @@ ModifierTypeInfo modifierType_Cloth = {
     /* name */ "Cloth",
     /* structName */ "ClothModifierData",
     /* structSize */ sizeof(ClothModifierData),
-    /* type */ eModifierTypeType_OnlyDeform,
+    /* type */ eModifierTypeType_Nonconstructive,
     /* flags */ eModifierTypeFlag_AcceptsMesh | eModifierTypeFlag_UsesPointCache |
         eModifierTypeFlag_Single,
 
     /* copyData */ copyData,
 
-    /* deformVerts */ deformVerts,
+    /* deformVerts */ NULL,
     /* deformMatrices */ NULL,
     /* deformVertsEM */ NULL,
     /* deformMatricesEM */ NULL,
-    /* applyModifier */ NULL,
+    /* applyModifier */ applyModifier,
 
     /* initData */ initData,
     /* requiredDataMask */ requiredDataMask,



More information about the Bf-blender-cvs mailing list