diff options
author | Janne Karhu <jhkarh@gmail.com> | 2007-11-30 00:09:16 +0300 |
---|---|---|
committer | Janne Karhu <jhkarh@gmail.com> | 2007-11-30 00:09:16 +0300 |
commit | 9ff9a5cdca5c834e05439699667f64524f957ccb (patch) | |
tree | d7228c1f1acb4acf534144778ddbacc4c6da8b1e /source/blender | |
parent | 18e5f7b50b33f1cb1f71ee3d1cc19477310ed87e (diff) |
2nd try at committing to trunk (instead of particles branch) :)
Fixes for bugs in #7833
- Hair softbody cache was reset on rendering.
- When Alt-a playback is synced to audio frames are skipped. This caused dynamics caching to go crazy. Now the first loop of playback goes through all frames if there are non cached dynamic systems.
Invalid point caches weren't cleared when new systems were created. This caused messed up shapes when softbody was added.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_pointcache.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle_system.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/pointcache.c | 8 | ||||
-rw-r--r-- | source/blender/src/buttons_object.c | 2 | ||||
-rw-r--r-- | source/blender/src/drawview.c | 50 |
5 files changed, 60 insertions, 3 deletions
diff --git a/source/blender/blenkernel/BKE_pointcache.h b/source/blender/blenkernel/BKE_pointcache.h index 46d240a4183..efd727d2141 100644 --- a/source/blender/blenkernel/BKE_pointcache.h +++ b/source/blender/blenkernel/BKE_pointcache.h @@ -44,5 +44,6 @@ int BKE_ptcache_id_filename(struct ID *id, char *filename, int cfra, int stack_index, short do_path, short do_ext); FILE * BKE_ptcache_id_fopen(struct ID *id, char mode, int cfra, int stack_index); void BKE_ptcache_id_clear(struct ID *id, char mode, int cfra, int stack_index); +int BKE_ptcache_id_exist(struct ID *id, int cfra, int stack_index); #endif diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 5d3a4332b5d..1c7d235cd90 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -4271,7 +4271,7 @@ void psys_to_softbody(Object *ob, ParticleSystem *psys, int force_recalc) if((psys->softflag&OB_SB_ENABLE)==0) return; - if((ob->recalc&OB_RECALC_TIME)==0) + if(ob->recalc && (ob->recalc&OB_RECALC_TIME)==0) psys->softflag|=OB_SB_REDO; /* let's replace the object's own softbody with the particle softbody */ diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 9492754260c..c4ef437019e 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -183,3 +183,11 @@ void BKE_ptcache_id_clear(struct ID *id, char mode, int cfra, int stack_index) return; } +int BKE_ptcache_id_exist(struct ID *id, int cfra, int stack_index) +{ + char filename[(FILE_MAXDIR+FILE_MAXFILE)*2]; + + BKE_ptcache_id_filename(id, filename, cfra, stack_index, 1, 1); + + return BLI_exists(filename); +} diff --git a/source/blender/src/buttons_object.c b/source/blender/src/buttons_object.c index b5733a89a0e..a6651e4a77c 100644 --- a/source/blender/src/buttons_object.c +++ b/source/blender/src/buttons_object.c @@ -3248,6 +3248,7 @@ static void object_softbodies__enable(void *ob_v, void *arg2) if (!ob->soft) { ob->soft= sbNew(); ob->softflag |= OB_SB_GOAL|OB_SB_EDGES; + softbody_clear_cache(ob, CFRA); } } /* needed so that initial state is cached correctly */ @@ -3281,6 +3282,7 @@ static void object_softbodies__enable_psys(void *ob_v, void *psys_v) psys->soft= sbNew(); psys->softflag |= OB_SB_GOAL|OB_SB_EDGES; psys->soft->particles=psys; + clear_particles_from_cache(ob, psys, CFRA); } psys->softflag |= OB_SB_ENABLE; } diff --git a/source/blender/src/drawview.c b/source/blender/src/drawview.c index 14690b08d48..bfccd0b77ff 100644 --- a/source/blender/src/drawview.c +++ b/source/blender/src/drawview.c @@ -70,6 +70,8 @@ #include "DNA_mesh_types.h" #include "DNA_meshdata_types.h" #include "DNA_meta_types.h" +#include "DNA_modifier_types.h" +#include "DNA_object_force.h" #include "DNA_object_types.h" #include "DNA_particle_types.h" #include "DNA_screen_types.h" @@ -101,8 +103,10 @@ #include "BKE_key.h" #include "BKE_main.h" #include "BKE_mesh.h" +#include "BKE_modifier.h" #include "BKE_object.h" #include "BKE_particle.h" +#include "BKE_pointcache.h" #include "BKE_scene.h" #include "BKE_texture.h" #include "BKE_utildefines.h" @@ -3292,10 +3296,50 @@ static void inner_play_prefetch_shutdown(int mode) seq_stop_threads(); } +static int cached_dynamics(int sfra, int efra) +{ + Base *base = G.scene->base.first; + Object *ob; + ModifierData *md; + ParticleSystem *psys; + int i, stack_index, cached=1; + + while(base && cached) { + ob = base->object; + if(ob->softflag & OB_SB_ENABLE && ob->soft) { + for(i=0, md=ob->modifiers.first; md; i++, md=md->next) { + if(md->type == eModifierType_Softbody) { + stack_index = i; + break; + } + } + for(i=sfra; i<=efra && cached; i++) + cached &= BKE_ptcache_id_exist(&ob->id,i,stack_index); + } + + for(psys=ob->particlesystem.first; psys; psys=psys->next) { + stack_index = modifiers_indexInObject(ob,(ModifierData*)psys_get_modifier(ob,psys)); + if(psys->part->type==PART_HAIR) { + if(psys->softflag & OB_SB_ENABLE && psys->soft); + else + stack_index = -1; + } + + if(stack_index >= 0) + for(i=sfra; i<=efra && cached; i++) + cached &= BKE_ptcache_id_exist(&ob->id,i,stack_index); + } + + base = base->next; + } + + return cached; +} void inner_play_anim_loop(int init, int mode) { ScrArea *sa; static int last_cfra = -1; + static int cached = 0; /* init */ if(init) { @@ -3304,7 +3348,7 @@ void inner_play_anim_loop(int init, int mode) tottime= 0.0; curmode= mode; last_cfra = -1; - + cached = cached_dynamics(PSFRA,PEFRA); return; } @@ -3380,8 +3424,10 @@ void inner_play_anim_loop(int init, int mode) CFRA = PSFRA; audiostream_stop(); audiostream_start( CFRA ); + cached = cached_dynamics(PSFRA,PEFRA); } else { - if (U.mixbufsize + if (cached + && U.mixbufsize && (G.scene->audio.flag & AUDIO_SYNC)) { CFRA = audiostream_pos(); } else { |