[Bf-blender-cvs] [b2b6d2c7643] soc-2019-adaptive-cloth: Removed Cloth Cache System

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


Commit: b2b6d2c7643fa7abed17a4af6152d40fab262750
Author: ishbosamiya
Date:   Tue May 28 00:06:07 2019 +0530
Branches: soc-2019-adaptive-cloth
https://developer.blender.org/rBb2b6d2c7643fa7abed17a4af6152d40fab262750

Removed Cloth Cache System

This has been done to minimize the possible areas of bugs when adding the remeshing steps, current point cache system may not be compatible.

Python file for the UI has cache related lines commented.
C files has a macro in BKE_cloth.h which can be set to 1 to enable caching again.

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

M	release/scripts/startup/bl_ui/properties_physics_cloth.py
M	source/blender/blenkernel/BKE_cloth.h
M	source/blender/blenkernel/intern/cloth.c
M	source/blender/blenkernel/intern/pointcache.c
M	source/blender/modifiers/intern/MOD_cloth.c

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

diff --git a/release/scripts/startup/bl_ui/properties_physics_cloth.py b/release/scripts/startup/bl_ui/properties_physics_cloth.py
index 7463f10185d..92c4f1aae63 100644
--- a/release/scripts/startup/bl_ui/properties_physics_cloth.py
+++ b/release/scripts/startup/bl_ui/properties_physics_cloth.py
@@ -24,13 +24,12 @@ from bpy.types import (
 from bl_ui.utils import PresetPanel
 
 from .properties_physics_common import (
-    point_cache_ui,
+#point_cache_ui,
     effector_weights_ui,
 )
 
-
-def cloth_panel_enabled(md):
-    return md.point_cache.is_baked is False
+#def cloth_panel_enabled(md):
+#return md.point_cache.is_baked is False
 
 
 class CLOTH_PT_presets(PresetPanel, Panel):
@@ -65,7 +64,7 @@ class PHYSICS_PT_cloth(PhysicButtonsPanel, Panel):
         md = context.cloth
         cloth = md.settings
 
-        layout.active = cloth_panel_enabled(md)
+#layout.active = cloth_panel_enabled(md)
 
         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=True)
 
@@ -87,7 +86,7 @@ class PHYSICS_PT_cloth_physical_properties(PhysicButtonsPanel, Panel):
         md = context.cloth
         cloth = md.settings
 
-        layout.active = cloth_panel_enabled(md)
+#layout.active = cloth_panel_enabled(md)
 
         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=True)
 
@@ -111,7 +110,7 @@ class PHYSICS_PT_cloth_stiffness(PhysicButtonsPanel, Panel):
         md = context.cloth
         cloth = md.settings
 
-        layout.active = cloth_panel_enabled(md)
+#layout.active = cloth_panel_enabled(md)
 
         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=True)
 
@@ -142,7 +141,7 @@ class PHYSICS_PT_cloth_damping(PhysicButtonsPanel, Panel):
         md = context.cloth
         cloth = md.settings
 
-        layout.active = cloth_panel_enabled(md)
+#layout.active = cloth_panel_enabled(md)
 
         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=True)
 
@@ -160,16 +159,15 @@ class PHYSICS_PT_cloth_damping(PhysicButtonsPanel, Panel):
         col = flow.column()
         col.prop(cloth, "bending_damping", text="Bending")
 
+#class PHYSICS_PT_cloth_cache(PhysicButtonsPanel, Panel):
+#bl_label = "Cache"
+#bl_parent_id = 'PHYSICS_PT_cloth'
+#bl_options = {'DEFAULT_CLOSED' }
+#COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH' }
 
-class PHYSICS_PT_cloth_cache(PhysicButtonsPanel, Panel):
-    bl_label = "Cache"
-    bl_parent_id = 'PHYSICS_PT_cloth'
-    bl_options = {'DEFAULT_CLOSED'}
-    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
-
-    def draw(self, context):
-        md = context.cloth
-        point_cache_ui(self, md.point_cache, cloth_panel_enabled(md), 'CLOTH')
+#def draw(self, context):
+#md = context.cloth
+#point_cache_ui(self, md.point_cache, cloth_panel_enabled(md), 'CLOTH')
 
 
 class PHYSICS_PT_cloth_shape(PhysicButtonsPanel, Panel):
@@ -186,7 +184,7 @@ class PHYSICS_PT_cloth_shape(PhysicButtonsPanel, Panel):
         ob = context.object
         cloth = md.settings
 
-        layout.active = cloth_panel_enabled(md)
+#layout.active = cloth_panel_enabled(md)
 
         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=True)
 
@@ -235,7 +233,7 @@ class PHYSICS_PT_cloth_collision(PhysicButtonsPanel, Panel):
         cloth = context.cloth.collision_settings
         md = context.cloth
 
-        layout.active = (cloth.use_collision or cloth.use_self_collision) and cloth_panel_enabled(md)
+        layout.active = (cloth.use_collision or cloth.use_self_collision)# and cloth_panel_enabled(md)
 
         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=True)
 
@@ -251,7 +249,7 @@ class PHYSICS_PT_cloth_object_collision(PhysicButtonsPanel, Panel):
     def draw_header(self, context):
         cloth = context.cloth.collision_settings
 
-        self.layout.active = cloth_panel_enabled(context.cloth)
+#self.layout.active = cloth_panel_enabled(context.cloth)
         self.layout.prop(cloth, "use_collision", text="")
 
     def draw(self, context):
@@ -261,7 +259,7 @@ class PHYSICS_PT_cloth_object_collision(PhysicButtonsPanel, Panel):
         cloth = context.cloth.collision_settings
         md = context.cloth
 
-        layout.active = cloth.use_collision and cloth_panel_enabled(md)
+        layout.active = cloth.use_collision# and cloth_panel_enabled(md)
 
         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=True)
 
@@ -283,7 +281,7 @@ class PHYSICS_PT_cloth_self_collision(PhysicButtonsPanel, Panel):
     def draw_header(self, context):
         cloth = context.cloth.collision_settings
 
-        self.layout.active = cloth_panel_enabled(context.cloth)
+#self.layout.active = cloth_panel_enabled(context.cloth)
         self.layout.prop(cloth, "use_self_collision", text="")
 
     def draw(self, context):
@@ -294,7 +292,7 @@ class PHYSICS_PT_cloth_self_collision(PhysicButtonsPanel, Panel):
         md = context.cloth
         ob = context.object
 
-        layout.active = cloth.use_self_collision and cloth_panel_enabled(md)
+        layout.active = cloth.use_self_collision# and cloth_panel_enabled(md)
 
         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=True)
 
@@ -325,7 +323,7 @@ class PHYSICS_PT_cloth_property_weights(PhysicButtonsPanel, Panel):
         ob = context.object
         cloth = context.cloth.settings
 
-        layout.active = cloth_panel_enabled(md)
+#layout.active = cloth_panel_enabled(md)
 
         flow = layout.grid_flow(row_major=True, columns=0, even_columns=True, even_rows=False, align=True)
 
@@ -382,7 +380,7 @@ classes = (
     PHYSICS_PT_cloth_physical_properties,
     PHYSICS_PT_cloth_stiffness,
     PHYSICS_PT_cloth_damping,
-    PHYSICS_PT_cloth_cache,
+#PHYSICS_PT_cloth_cache,
     PHYSICS_PT_cloth_shape,
     PHYSICS_PT_cloth_collision,
     PHYSICS_PT_cloth_object_collision,
diff --git a/source/blender/blenkernel/BKE_cloth.h b/source/blender/blenkernel/BKE_cloth.h
index a5d1472727a..0a371549aef 100644
--- a/source/blender/blenkernel/BKE_cloth.h
+++ b/source/blender/blenkernel/BKE_cloth.h
@@ -43,6 +43,9 @@ struct Scene;
  * represented by a float, given its precision. */
 #define ALMOST_ZERO FLT_EPSILON
 
+/* Toggle Cloth Cache */
+#define USE_CLOTH_CACHE 0
+
 /* Bits to or into the ClothVertex.flags. */
 typedef enum eClothVertexFlag {
   CLOTH_VERT_FLAG_PINNED = 1,
@@ -279,8 +282,10 @@ int cloth_uses_vgroup(struct ClothModifierData *clmd);
 // needed for collision.c
 void bvhtree_update_from_cloth(struct ClothModifierData *clmd, bool moving, bool self);
 
+#if USE_CLOTH_CACHE
 // needed for button_object.c
 void cloth_clear_cache(struct Object *ob, struct ClothModifierData *clmd, float framenr);
+#endif
 
 void cloth_parallel_transport_hair_frame(float mat[3][3],
                                          const float dir_old[3],
diff --git a/source/blender/blenkernel/intern/cloth.c b/source/blender/blenkernel/intern/cloth.c
index fcc0e1856af..4ad94a0da31 100644
--- a/source/blender/blenkernel/intern/cloth.c
+++ b/source/blender/blenkernel/intern/cloth.c
@@ -43,7 +43,9 @@
 #include "BKE_global.h"
 #include "BKE_mesh_runtime.h"
 #include "BKE_modifier.h"
-#include "BKE_pointcache.h"
+#if USE_CLOTH_CACHE
+#  include "BKE_pointcache.h"
+#endif
 
 #include "BPH_mass_spring.h"
 
@@ -144,9 +146,11 @@ void cloth_init(ClothModifierData *clmd)
     clmd->sim_parms->effector_weights = BKE_effector_add_weights(NULL);
   }
 
+#if USE_CLOTH_CACHE
   if (clmd->point_cache) {
     clmd->point_cache->step = 1;
   }
+#endif
 }
 
 static BVHTree *bvhtree_build_from_cloth(ClothModifierData *clmd, float epsilon)
@@ -253,6 +257,7 @@ void bvhtree_update_from_cloth(ClothModifierData *clmd, bool moving, bool self)
   }
 }
 
+#if USE_CLOTH_CACHE
 void cloth_clear_cache(Object *ob, ClothModifierData *clmd, float framenr)
 {
   PTCacheID pid;
@@ -266,23 +271,30 @@ void cloth_clear_cache(Object *ob, ClothModifierData *clmd, float framenr)
 
   BKE_ptcache_id_clear(&pid, PTCACHE_CLEAR_AFTER, framenr);
 }
+#endif
 
 static int do_init_cloth(Object *ob, ClothModifierData *clmd, Mesh *result, int framenr)
 {
+#if USE_CLOTH_CACHE
   PointCache *cache;
 
   cache = clmd->point_cache;
+#endif
 
   /* initialize simulation data if it didn't exist already */
   if (clmd->clothObject == NULL) {
     if (!cloth_from_object(ob, clmd, result, framenr, 1)) {
+#if USE_CLOTH_CACHE
       BKE_ptcache_invalidate(cache);
+#endif
       modifier_setError(&(clmd->modifier), "Can't initialize cloth");
       return 0;
     }
 
     if (clmd->clothObject == NULL) {
+#if USE_CLOTH_CACHE
       BKE_ptcache_invalidate(cache);
+#endif
       modifier_setError(&(clmd->modifier), "Null cloth object");
       return 0;
     }
@@ -362,6 +374,7 @@ void clothModifier_do(ClothModifierData *clmd,
                       Mesh *mesh,
                       float (*vertexCos)[3])
 {
+#if USE_CLOTH_CACHE
   PointCache *cache;
   PTCacheID pid;
   float timescale;
@@ -374,20 +387,30 @@ void clothModifier_do(ClothModifierData *clmd,
   BKE_ptcache_id_from_cloth(&pid, ob, clmd);
   BKE_ptcache_id_time(&pid, scene, framenr, &startframe, &endframe, &timescale);
   clmd->sim_parms->timescale = timescale * clmd->sim_parms->time_scale;
+#else
+  int framenr = DEG_get_ctime(depsgraph);
+  int startframe = scene->r.sfra;
+  int endframe = scene->r.efra;
+  clmd->sim_parms->timescale = 1.0f;
+#endif
 
   if (clmd->sim_parms->reset ||
       (clmd->clothObject && mesh->totvert != clmd->clothObject->mvert_num)) {
     clmd->sim_parms->reset = 0;
+#if USE_CLOTH_CACHE
     cache->flag |= PTCACHE_OUTDATED;
     BKE_ptcache_id_reset(scene, &pid, PTCACHE_RESET_OUTDATED);
     BKE_ptcache_validate(cache, 0);
     cache->last_exact = 0;
     cache->flag &= ~PTCACHE_REDO_NEEDED;
+#endif
   }
 
   /* simulation is only active during a specific period */
   if (framenr < startframe) {
+#if USE_CLOTH_CACHE
     BKE_ptcache_invalidate(cache);
+#endif
     return;
   }
   else if (framenr > endfra

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list