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:
authorCampbell Barton <ideasman42@gmail.com>2015-08-21 10:05:48 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-08-21 10:09:18 +0300
commitc727fc59abe2b7e525bdc6594bbd7ec3285936e0 (patch)
treedfcadf23e28c2464655f4c06a5f94621721fe0c2 /source/blender/blenkernel
parenta98b02ff941edb1d92892f520641433582754f0d (diff)
BVH-raycast: ensure input direction is unit-length
This was already the case for most users of ray-cast. Doing this avoids 2x normalize calls per ray-cast in many places.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/intern/boids.c6
-rw-r--r--source/blender/blenkernel/intern/constraint.c1
-rw-r--r--source/blender/blenkernel/intern/dynamicpaint.c5
-rw-r--r--source/blender/blenkernel/intern/particle_system.c2
4 files changed, 7 insertions, 7 deletions
diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c
index 11879c7973c..fdc5524e84c 100644
--- a/source/blender/blenkernel/intern/boids.c
+++ b/source/blender/blenkernel/intern/boids.c
@@ -214,7 +214,7 @@ static int rule_avoid_collision(BoidRule *rule, BoidBrainData *bbd, BoidValues *
mul_v3_fl(ray_dir, acbr->look_ahead);
col.f = 0.0f;
hit.index = -1;
- hit.dist = col.original_ray_length = len_v3(ray_dir);
+ hit.dist = col.original_ray_length = normalize_v3(ray_dir);
/* find out closest deflector object */
for (coll = bbd->sim->colliders->first; coll; coll=coll->next) {
@@ -794,7 +794,7 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float grou
sub_v3_v3v3(ray_dir, col.co2, col.co1);
col.f = 0.0f;
hit.index = -1;
- hit.dist = col.original_ray_length = len_v3(ray_dir);
+ hit.dist = col.original_ray_length = normalize_v3(ray_dir);
col.pce.inside = 0;
for (coll = bbd->sim->colliders->first; coll; coll = coll->next) {
@@ -820,7 +820,7 @@ static Object *boid_find_ground(BoidBrainData *bbd, ParticleData *pa, float grou
sub_v3_v3v3(ray_dir, col.co2, col.co1);
col.f = 0.0f;
hit.index = -1;
- hit.dist = col.original_ray_length = len_v3(ray_dir);
+ hit.dist = col.original_ray_length = normalize_v3(ray_dir);
for (coll = bbd->sim->colliders->first; coll; coll = coll->next) {
col.current = coll->ob;
diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c
index e7f6210fef4..2aba4fcde27 100644
--- a/source/blender/blenkernel/intern/constraint.c
+++ b/source/blender/blenkernel/intern/constraint.c
@@ -4106,6 +4106,7 @@ static void followtrack_evaluate(bConstraint *con, bConstraintOb *cob, ListBase
mul_v3_m4v3(ray_end, imat, cob->matrix[3]);
sub_v3_v3v3(ray_nor, ray_end, ray_start);
+ normalize_v3(ray_nor);
bvhtree_from_mesh_looptri(&treeData, target, 0.0f, 4, 6);
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index d97233aad90..7f1d2e877ed 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -3290,10 +3290,9 @@ static int dynamicPaint_paintMesh(DynamicPaintSurface *surface,
if (brush->flags & MOD_DPAINT_PROX_PROJECT && brush->collision != MOD_DPAINT_COL_VOLUME) {
mul_v3_fl(avg_brushNor, 1.0f / (float)numOfVerts);
/* instead of null vector use positive z */
- if (!(MIN3(avg_brushNor[0], avg_brushNor[1], avg_brushNor[2])))
+ if (UNLIKELY(normalize_v3(avg_brushNor) == 0.0f)) {
avg_brushNor[2] = 1.0f;
- else
- normalize_v3(avg_brushNor);
+ }
}
/* check bounding box collision */
diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c
index e340a0ade94..8b925fff415 100644
--- a/source/blender/blenkernel/intern/particle_system.c
+++ b/source/blender/blenkernel/intern/particle_system.c
@@ -2594,7 +2594,7 @@ static int collision_detect(ParticleData *pa, ParticleCollision *col, BVHTreeRay
sub_v3_v3v3(ray_dir, col->co2, col->co1);
hit->index = -1;
- hit->dist = col->original_ray_length = len_v3(ray_dir);
+ hit->dist = col->original_ray_length = normalize_v3(ray_dir);
col->pce.inside = 0;
/* even if particle is stationary we want to check for moving colliders */