Fix #20983: cloth and smoke point cache step was not enforced to 1.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 21 Jul 2010 15:58:15 +0000 (15:58 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 21 Jul 2010 15:58:15 +0000 (15:58 +0000)
source/blender/blenkernel/intern/cloth.c
source/blender/makesrna/intern/rna_object_force.c

index ce5bca1..b9b1c16 100644 (file)
@@ -144,6 +144,9 @@ void cloth_init ( ClothModifierData *clmd )
 
        if(!clmd->sim_parms->effector_weights)
                clmd->sim_parms->effector_weights = BKE_add_effector_weights(NULL);
+
+       if(clmd->point_cache)
+               clmd->point_cache->step = 1;
 }
 
 static BVHTree *bvhselftree_build_from_cloth (ClothModifierData *clmd, float epsilon)
index 97c4292..d253201 100644 (file)
@@ -294,6 +294,29 @@ static void rna_Cache_active_point_cache_index_set(struct PointerRNA *ptr, int v
        BLI_freelistN(&pidlist);
 }
 
+static void rna_PointCache_step_range(PointerRNA *ptr, int *min, int *max)
+{
+       Object *ob = ptr->id.data;
+       PointCache *cache= ptr->data;
+       PTCacheID *pid;
+       ListBase pidlist;
+
+       *min= 1;
+       *max= 20;
+
+       BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0);
+       
+       for(pid=pidlist.first; pid; pid=pid->next) {
+               if(pid->cache == cache) {
+                       if(ELEM3(pid->type, PTCACHE_TYPE_CLOTH, PTCACHE_TYPE_SMOKE_DOMAIN, PTCACHE_TYPE_SMOKE_HIGHRES))
+                               *max= 1;
+                       break;
+               }
+       }
+
+       BLI_freelistN(&pidlist);
+}
+
 static char *rna_CollisionSettings_path(PointerRNA *ptr)
 {
        Object *ob= (Object*)ptr->id.data;
@@ -670,7 +693,6 @@ static EnumPropertyItem *rna_Effector_shape_itemf(bContext *C, PointerRNA *ptr,
        }
 }
 
-
 #else
 
 static void rna_def_pointcache(BlenderRNA *brna)
@@ -694,6 +716,7 @@ static void rna_def_pointcache(BlenderRNA *brna)
 
        prop= RNA_def_property(srna, "step", PROP_INT, PROP_NONE);
        RNA_def_property_range(prop, 1, 20);
+       RNA_def_property_int_funcs(prop, NULL, NULL, "rna_PointCache_step_range");
        RNA_def_property_ui_text(prop, "Cache Step", "Number of frames between cached frames");
        RNA_def_property_update(prop, NC_OBJECT, "rna_Cache_change");