[Bf-blender-cvs] [07b52c9fb68] soc-2021-adaptive-cloth: adaptive_cloth: run BKE_cloth_remesh() when remesh flag is on

ishbosamiya noreply at git.blender.org
Mon Jun 14 14:31:58 CEST 2021


Commit: 07b52c9fb6862d224b8ab661d7aa4c05c24e574a
Author: ishbosamiya
Date:   Fri Jun 11 21:19:39 2021 +0530
Branches: soc-2021-adaptive-cloth
https://developer.blender.org/rB07b52c9fb6862d224b8ab661d7aa4c05c24e574a

adaptive_cloth: run BKE_cloth_remesh() when remesh flag is on

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

A	source/blender/blenkernel/BKE_cloth_remesh.hh
M	source/blender/blenkernel/CMakeLists.txt
M	source/blender/blenkernel/intern/cloth.c
A	source/blender/blenkernel/intern/cloth_remesh.cc

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

diff --git a/source/blender/blenkernel/BKE_cloth_remesh.hh b/source/blender/blenkernel/BKE_cloth_remesh.hh
new file mode 100644
index 00000000000..5927ae2537a
--- /dev/null
+++ b/source/blender/blenkernel/BKE_cloth_remesh.hh
@@ -0,0 +1,44 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) Blender Foundation.
+ * All rights reserved.
+ */
+
+#pragma once
+
+/** \file
+ * \ingroup bke
+ */
+
+/******************************************************************************
+ * reference http://graphics.berkeley.edu/papers/Narain-AAR-2012-11/index.html
+ ******************************************************************************/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct ClothModifierData;
+struct Mesh;
+struct Object;
+
+void BKE_cloth_remesh(const struct Object *ob,
+                      struct ClothModifierData *clmd,
+                      struct Mesh *r_mesh);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index 021d7e15814..112c1ccd164 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -99,6 +99,7 @@ set(SRC
   intern/camera.c
   intern/cdderivedmesh.c
   intern/cloth.c
+  intern/cloth_remesh.cc
   intern/collection.c
   intern/collision.c
   intern/colorband.c
@@ -313,6 +314,7 @@ set(SRC
   BKE_ccg.h
   BKE_cdderivedmesh.h
   BKE_cloth.h
+  BKE_cloth_remesh.hh
   BKE_collection.h
   BKE_collision.h
   BKE_colorband.h
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index 99dcdd21d83..3a9631aef1a 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -40,6 +40,7 @@
 
 #include "BKE_bvhutils.h"
 #include "BKE_cloth.h"
+#include "BKE_cloth_remesh.hh"
 #include "BKE_effect.h"
 #include "BKE_global.h"
 #include "BKE_mesh.h"
@@ -316,7 +317,14 @@ static int do_step_cloth(
 
   // printf ( "%f\n", ( float ) tval() );
 
-  cloth_to_object(ob, clmd, r_mesh);
+  if (clmd->sim_parms->flags & CLOTH_SIMSETTINGS_FLAG_REMESH) {
+    /* In case remeshing is enabled, the remeshing function would update `r_mesh` */
+    BKE_cloth_remesh(ob, clmd, r_mesh);
+  }
+  else {
+    /* if remeshing is off, need to update `r_mesh` from clmd->clothObject */
+    cloth_to_object(ob, clmd, r_mesh);
+  }
 
   return ret;
 }
diff --git a/source/blender/blenkernel/intern/cloth_remesh.cc b/source/blender/blenkernel/intern/cloth_remesh.cc
new file mode 100644
index 00000000000..abb42ed2978
--- /dev/null
+++ b/source/blender/blenkernel/intern/cloth_remesh.cc
@@ -0,0 +1,38 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) Blender Foundation
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup bke
+ */
+
+#include "DNA_cloth_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_object_types.h"
+
+#include "BLI_utildefines.h"
+
+#include "BKE_cloth_remesh.hh"
+
+#include <cstdio>
+
+void BKE_cloth_remesh(const Object *UNUSED(ob),
+                      ClothModifierData *UNUSED(clmd),
+                      Mesh *UNUSED(r_mesh))
+{
+}



More information about the Bf-blender-cvs mailing list