Fix #30456: transforming object with a hair particle system, on a frame after

the cache end frame would reset to the previous state on confirm. Was an issue
with object animation being evaluated unnecessarily, now make check more
precise.
This commit is contained in:
Brecht Van Lommel 2012-03-19 18:14:24 +00:00
parent 8e0493b290
commit d7b072f450
2 changed files with 11 additions and 3 deletions

@ -1814,6 +1814,8 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime,
} }
ob = sim->ob; ob = sim->ob;
where_is_object_time(sim->scene, ob, pa->time); where_is_object_time(sim->scene, ob, pa->time);
psys->flag |= PSYS_OB_ANIM_RESTORE;
} }
psys_get_birth_coordinates(sim, pa, &pa->state, dtime, cfra); psys_get_birth_coordinates(sim, pa, &pa->state, dtime, cfra);
@ -4438,6 +4440,9 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys)
/* execute drivers only, as animation has already been done */ /* execute drivers only, as animation has already been done */
BKE_animsys_evaluate_animdata(scene, &part->id, part->adt, cfra, ADT_RECALC_DRIVERS); BKE_animsys_evaluate_animdata(scene, &part->id, part->adt, cfra, ADT_RECALC_DRIVERS);
/* to verify if we need to restore object afterwards */
psys->flag &= ~PSYS_OB_ANIM_RESTORE;
if(psys->recalc & PSYS_RECALC_TYPE) if(psys->recalc & PSYS_RECALC_TYPE)
psys_changed_type(&sim); psys_changed_type(&sim);
@ -4550,14 +4555,16 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys)
} }
} }
if(psys->cfra < cfra) { /* make sure emitter is left at correct time (particle emission can change this) */
/* make sure emitter is left at correct time (particle emission can change this) */ if(psys->flag & PSYS_OB_ANIM_RESTORE) {
while(ob) { while(ob) {
BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, cfra, ADT_RECALC_ANIM); BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, cfra, ADT_RECALC_ANIM);
ob = ob->parent; ob = ob->parent;
} }
ob = sim.ob; ob = sim.ob;
where_is_object_time(scene, ob, cfra); where_is_object_time(scene, ob, cfra);
psys->flag &= ~PSYS_OB_ANIM_RESTORE;
} }
psys->cfra = cfra; psys->cfra = cfra;

@ -498,7 +498,8 @@ typedef struct ParticleSystem
#define PSYS_KEYED 1024 #define PSYS_KEYED 1024
#define PSYS_EDITED 2048 #define PSYS_EDITED 2048
//#define PSYS_PROTECT_CACHE 4096 /* deprecated */ //#define PSYS_PROTECT_CACHE 4096 /* deprecated */
#define PSYS_DISABLED 8192 #define PSYS_DISABLED 8192
#define PSYS_OB_ANIM_RESTORE 16384 /* runtime flag */
/* pars->flag */ /* pars->flag */
#define PARS_UNEXIST 1 #define PARS_UNEXIST 1