From 09435ec149b499fabb112114bcdd24a9b3dc6cda Mon Sep 17 00:00:00 2001 From: Janne Karhu Date: Tue, 2 Nov 2010 21:16:41 +0000 Subject: Oops, particle collisions didn't take simulation subframes into account at all. * This caused nearly all particles to leak through the collision surface if simulation subframes were used and the collision object was moving. * In addition to fixing this I also did some more cleanup of the collision code and refined some of the comments. --- source/blender/blenkernel/intern/boids.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'source/blender/blenkernel/intern/boids.c') diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index 5c2c0721972..1bde0639055 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -205,7 +205,9 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues * add_v3_v3v3(col.co2, pa->prev_state.co, pa->prev_state.vel); sub_v3_v3v3(ray_dir, col.co2, col.co1); mul_v3_fl(ray_dir, acbr->look_ahead); - col.t = 0.0f; + col.f = 0.0f; + col.cfra = fmod(bbd->cfra-bbd->dfra, 1.0f); + col.dfra = bbd->dfra; hit.index = -1; hit.dist = col.ray_len = len_v3(ray_dir); @@ -772,7 +774,9 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *gro sub_v3_v3v3(col.co2, pa->state.co, zvec); sub_v3_v3(col.co2, zvec); sub_v3_v3v3(ray_dir, col.co2, col.co1); - col.t = 0.0f; + col.f = 0.0f; + col.cfra = fmod(bbd->cfra-bbd->dfra, 1.0f); + col.dfra = bbd->dfra; hit.index = -1; hit.dist = col.ray_len = len_v3(ray_dir); @@ -796,7 +800,9 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float *gro sub_v3_v3v3(col.co2, pa->state.co, zvec); sub_v3_v3(col.co2, zvec); sub_v3_v3v3(ray_dir, col.co2, col.co1); - col.t = 0.0f; + col.f = 0.0f; + col.cfra = fmod(bbd->cfra-bbd->dfra, 1.0f); + col.dfra = bbd->dfra; hit.index = -1; hit.dist = col.ray_len = len_v3(ray_dir); -- cgit v1.2.3