diff options
-rw-r--r-- | source/blender/blenkernel/intern/boids.c | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/particle_system.c | 11 |
2 files changed, 12 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index 8ce84609c15..a8d64ea9fb6 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -206,6 +206,8 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues * BVHTreeRayHit hit; float radius = val->personal_space * pa->size, ray_dir[3]; + memset(&col, 0, sizeof(ParticleCollision)); + copy_v3_v3(col.co1, pa->prev_state.co); add_v3_v3v3(col.co2, pa->prev_state.co, pa->prev_state.vel); sub_v3_v3v3(ray_dir, col.co2, col.co1); @@ -777,6 +779,8 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float grou if (!bbd->sim->colliders) return NULL; + memset(&col, 0, sizeof(ParticleCollision)); + /* first try to find below boid */ copy_v3_v3(col.co1, pa->state.co); sub_v3_v3v3(col.co2, pa->state.co, zvec); diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index db22e030821..526d54a97fa 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -3313,9 +3313,14 @@ static float collision_newton_rhapson(ParticleCollision *col, float radius, Part pce->inv_nor = -1; - /* Initial step size should be small, but not too small or floating point - * precision errors will appear. - z0r */ - dt_init = COLLISION_INIT_STEP * col->inv_total_time; + if (col->inv_total_time > 0.0f) { + /* Initial step size should be small, but not too small or floating point + * precision errors will appear. - z0r */ + dt_init = COLLISION_INIT_STEP * col->inv_total_time; + } + else { + dt_init = 0.001f; + } /* start from the beginning */ t0 = 0.f; |