[Bf-blender-cvs] [1a1185b5997] soc-2021-adaptive-cloth: adaptive_cloth: cloth: prev_frame_mesh is invalid if frame incorrect

ishbosamiya noreply at git.blender.org
Sun Aug 22 17:23:39 CEST 2021


Commit: 1a1185b59976fa946d3f2497351e672b788e859f
Author: ishbosamiya
Date:   Thu Aug 12 22:28:14 2021 +0530
Branches: soc-2021-adaptive-cloth
https://developer.blender.org/rB1a1185b59976fa946d3f2497351e672b788e859f

adaptive_cloth: cloth: prev_frame_mesh is invalid if frame incorrect

When current frame (framenr) is not immediately following the
last_frame stored, the `prev_frame_mesh` is invalid and must be
deleted. When remesh is on, even the clothObject is invalid, so delete
that as well.

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

M	source/blender/blenkernel/intern/cloth.c

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

diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 0985c7c1d1d..d8dfc88aece 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -358,6 +358,22 @@ Mesh *clothModifier_do(
   BKE_ptcache_id_time(&pid, scene, framenr, &startframe, &endframe, &timescale);
   clmd->sim_parms->timescale = timescale * clmd->sim_parms->time_scale;
 
+  /* If it is not the exact next frame, previous frame mesh is no
+   * longer valid */
+  if (clmd->clothObject) {
+    if (framenr != clmd->clothObject->last_frame + 1) {
+      if (clmd->prev_frame_mesh) {
+        BKE_mesh_eval_delete(clmd->prev_frame_mesh);
+        clmd->prev_frame_mesh = NULL;
+      }
+      if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_REMESH) {
+        /* Need to also reset the modifier if remesh is on since the
+         * clothObject has invalid information */
+        cloth_free_modifier(clmd);
+      }
+    }
+  }
+
   if (clmd->clothObject) {
     printf("mesh->totvert: %d clmd->clothObject->mvert_num: %u\n",
            mesh->totvert,



More information about the Bf-blender-cvs mailing list