Fix part of #29310: secondary point caches for cloth did not get steps
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Thu, 24 Nov 2011 20:46:00 +0000 (20:46 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Thu, 24 Nov 2011 20:46:00 +0000 (20:46 +0000)
set to correct default, was 10 when supposed to be 1.

source/blender/blenkernel/BKE_pointcache.h
source/blender/blenkernel/intern/pointcache.c
source/blender/editors/physics/physics_pointcache.c
source/blender/makesrna/intern/rna_object_force.c

index 9f4fae7dc2e3bfbf9c2198bf2e4919c2db1dfecc..d1b0acf7142d5b36ab7c2251a33d922891c64fda 100644 (file)
@@ -127,6 +127,9 @@ typedef struct PTCacheID {
        unsigned int stack_index;
        unsigned int flag;
 
+       unsigned int default_step;
+       unsigned int max_step;
+
        /* flags defined in DNA_object_force.h */
        unsigned int data_types, info_types;
 
index dbfda18942a61b557ea3d6978c933f6526741617..2cf890349b49aff5a8782a9a7ea7ac665acf3796 100644 (file)
@@ -770,6 +770,9 @@ void BKE_ptcache_id_from_softbody(PTCacheID *pid, Object *ob, SoftBody *sb)
        pid->info_types= 0;
 
        pid->stack_index = pid->cache->index;
+
+       pid->default_step = 10;
+       pid->max_step = 20;
 }
 void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *psys)
 {
@@ -820,6 +823,9 @@ void BKE_ptcache_id_from_particles(PTCacheID *pid, Object *ob, ParticleSystem *p
                pid->data_types|= (1<<BPHYS_DATA_ROTATION);
 
        pid->info_types= (1<<BPHYS_DATA_TIMES);
+
+       pid->default_step = 10;
+       pid->max_step = 20;
 }
 void BKE_ptcache_id_from_cloth(PTCacheID *pid, Object *ob, ClothModifierData *clmd)
 {
@@ -850,6 +856,9 @@ void BKE_ptcache_id_from_cloth(PTCacheID *pid, Object *ob, ClothModifierData *cl
 
        pid->data_types= (1<<BPHYS_DATA_LOCATION) | (1<<BPHYS_DATA_VELOCITY) | (1<<BPHYS_DATA_XCONST);
        pid->info_types= 0;
+
+       pid->default_step = 1;
+       pid->max_step = 1;
 }
 void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeModifierData *smd)
 {
@@ -890,6 +899,9 @@ void BKE_ptcache_id_from_smoke(PTCacheID *pid, struct Object *ob, struct SmokeMo
                pid->data_types |= (1<<BPHYS_DATA_SMOKE_LOW);
        if(sds->wt)
                pid->data_types |= (1<<BPHYS_DATA_SMOKE_HIGH);
+
+       pid->default_step = 1;
+       pid->max_step = 1;
 }
 
 void BKE_ptcache_id_from_dynamicpaint(PTCacheID *pid, Object *ob, DynamicPaintSurface *surface)
@@ -923,6 +935,9 @@ void BKE_ptcache_id_from_dynamicpaint(PTCacheID *pid, Object *ob, DynamicPaintSu
        pid->info_types= 0;
 
        pid->stack_index = pid->cache->index;
+
+       pid->default_step = 1;
+       pid->max_step = 1;
 }
 
 void BKE_ptcache_ids_from_object(ListBase *lb, Object *ob, Scene *scene, int duplis)
index f826d0ec41a337c9a0628d6db9d2c8b3fed31e39..0cecfa05b49988d203685d2097ae2e399f8de837 100644 (file)
@@ -321,7 +321,9 @@ static int ptcache_add_new_exec(bContext *C, wmOperator *UNUSED(op))
        
        for(pid=pidlist.first; pid; pid=pid->next) {
                if(pid->cache == cache) {
-                       *(pid->cache_ptr) = BKE_ptcache_add(pid->ptcaches);
+                       PointCache *cache = BKE_ptcache_add(pid->ptcaches);
+                       cache->step = pid->default_step;
+                       *(pid->cache_ptr) = cache;
                        break;
                }
        }
index 592c3baec46a5e101d81f5be215e1a993ac8c2d8..2997acd2267882bcb518db7f5fbedade53a5c101 100644 (file)
@@ -214,21 +214,16 @@ static void rna_Cache_idname_change(Main *UNUSED(bmain), Scene *UNUSED(scene), P
 
 static void rna_Cache_list_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
 {
-       Object *ob = ptr->id.data;
        PointCache *cache= ptr->data;
-       PTCacheID *pid;
-       ListBase pidlist;
+       ListBase lb;
 
-       BKE_ptcache_ids_from_object(&pidlist, ob, NULL, 0);
+       while(cache->prev)
+               cache= cache->prev;
 
-       for(pid=pidlist.first; pid; pid=pid->next) {
-               if(pid->cache == cache) {
-                       rna_iterator_listbase_begin(iter, pid->ptcaches, NULL);
-                       break;
-               }
-       }
+       lb.first= cache;
+       lb.last= NULL; /* not used by listbase_begin */
 
-       BLI_freelistN(&pidlist);
+       rna_iterator_listbase_begin(iter, &lb, NULL);
 }
 static void rna_Cache_active_point_cache_index_range(PointerRNA *ptr, int *min, int *max)
 {
@@ -308,8 +303,7 @@ static void rna_PointCache_frame_step_range(PointerRNA *ptr, int *min, int *max)
        
        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;
+                       *max= pid->max_step;
                        break;
                }
        }