From d7b072f450d122f31d28d1fc0aa216da8dee38fc Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Mon, 19 Mar 2012 18:14:24 +0000 Subject: [PATCH] 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. --- source/blender/blenkernel/intern/particle_system.c | 11 +++++++++-- source/blender/makesdna/DNA_particle_types.h | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index c3e7e4531b9..50c960d6c56 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -1814,6 +1814,8 @@ void reset_particle(ParticleSimulationData *sim, ParticleData *pa, float dtime, } ob = sim->ob; 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); @@ -4438,6 +4440,9 @@ void particle_system_update(Scene *scene, Object *ob, ParticleSystem *psys) /* execute drivers only, as animation has already been done */ 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) 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) { BKE_animsys_evaluate_animdata(scene, &ob->id, ob->adt, cfra, ADT_RECALC_ANIM); ob = ob->parent; } ob = sim.ob; where_is_object_time(scene, ob, cfra); + + psys->flag &= ~PSYS_OB_ANIM_RESTORE; } psys->cfra = cfra; diff --git a/source/blender/makesdna/DNA_particle_types.h b/source/blender/makesdna/DNA_particle_types.h index 5bb4d1009e9..547a91e7852 100644 --- a/source/blender/makesdna/DNA_particle_types.h +++ b/source/blender/makesdna/DNA_particle_types.h @@ -498,7 +498,8 @@ typedef struct ParticleSystem #define PSYS_KEYED 1024 #define PSYS_EDITED 2048 //#define PSYS_PROTECT_CACHE 4096 /* deprecated */ -#define PSYS_DISABLED 8192 +#define PSYS_DISABLED 8192 +#define PSYS_OB_ANIM_RESTORE 16384 /* runtime flag */ /* pars->flag */ #define PARS_UNEXIST 1