Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJanne Karhu <jhkarh@gmail.com>2011-07-24 21:44:22 +0400
committerJanne Karhu <jhkarh@gmail.com>2011-07-24 21:44:22 +0400
commita22de3f73c28b86f481376d52fbcfd7bb8ee25f2 (patch)
treec209505a899446aa72debf73dbb3f14965beb5dc
parent4ab7c6ae1a6d9867d30d5eb960aece38bb0233f7 (diff)
Effector calculations are now thread safe.
* where_is_object_time was called for every effector evaluation only to determine the object velocity in some rare cases. * Calculating the effector velocity is now done in the effector precalculation stage. * Removing this makes the code thread safe and also should give some nice performance boosts when simulating a lot of points. * Thanks to MiikaH for noticing this problem.
-rw-r--r--source/blender/blenkernel/BKE_effect.h1
-rw-r--r--source/blender/blenkernel/intern/effect.c23
2 files changed, 13 insertions, 11 deletions
diff --git a/source/blender/blenkernel/BKE_effect.h b/source/blender/blenkernel/BKE_effect.h
index 97ac711651b..12f9383cefb 100644
--- a/source/blender/blenkernel/BKE_effect.h
+++ b/source/blender/blenkernel/BKE_effect.h
@@ -105,6 +105,7 @@ typedef struct EffectorCache {
/* precalculated for guides */
struct GuideEffectorData *guide_data;
float guide_loc[4], guide_dir[3], guide_radius;
+ float velocity[3];
float frame;
int flag;
diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c
index ee46bef6038..4b95c44f55f 100644
--- a/source/blender/blenkernel/intern/effect.c
+++ b/source/blender/blenkernel/intern/effect.c
@@ -241,6 +241,16 @@ static void precalculate_effector(EffectorCache *eff)
}
else if(eff->psys)
psys_update_particle_tree(eff->psys, eff->scene->r.cfra);
+
+ /* Store object velocity */
+ if(eff->ob) {
+ float old_vel[3];
+
+ where_is_object_time(eff->scene, eff->ob, cfra - 1.0f);
+ copy_v3_v3(old_vel, eff->ob->obmat[3]);
+ where_is_object_time(eff->scene, eff->ob, cfra);
+ sub_v3_v3v3(eff->velocity, eff->ob->obmat[3], old_vel);
+ }
}
static EffectorCache *new_effector_cache(Scene *scene, Object *ob, ParticleSystem *psys, PartDeflect *pd)
{
@@ -680,10 +690,6 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
Object *ob = eff->ob;
Object obcopy = *ob;
- /* XXX this is not thread-safe, but used from multiple threads by
- particle system */
- where_is_object_time(eff->scene, ob, cfra);
-
/* use z-axis as normal*/
normalize_v3_v3(efd->nor, ob->obmat[2]);
@@ -702,13 +708,8 @@ int get_effector_data(EffectorCache *eff, EffectorData *efd, EffectedPoint *poin
VECCOPY(efd->loc, ob->obmat[3]);
}
- if(real_velocity) {
- VECCOPY(efd->vel, ob->obmat[3]);
-
- where_is_object_time(eff->scene, ob, cfra - 1.0f);
-
- sub_v3_v3v3(efd->vel, efd->vel, ob->obmat[3]);
- }
+ if(real_velocity)
+ copy_v3_v3(efd->vel, eff->velocity);
*eff->ob = obcopy;