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>2014-03-29 15:38:01 +0400
committerCampbell Barton <ideasman42@gmail.com>2014-03-29 15:38:01 +0400
commit2100fb4094800a1cbe4e11c530d4eec3019a87a5 (patch)
tree2cd05013c7dd4d96edd62db4da0e24191d61397f /source/blender
parentfb0959f88dc57a73eacd36600607cd10584da387 (diff)
Code cleanup: avoid setting du/dv twice with ray intersection
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/blenlib/intern/math_geom.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/source/blender/blenlib/intern/math_geom.c b/source/blender/blenlib/intern/math_geom.c
index e41ec8bc9ac..7665b8eedd0 100644
--- a/source/blender/blenlib/intern/math_geom.c
+++ b/source/blender/blenlib/intern/math_geom.c
@@ -1113,7 +1113,7 @@ bool isect_ray_tri_threshold_v3(const float p1[3], const float d[3],
{
float p[3], s[3], e1[3], e2[3], q[3];
float a, f, u, v;
- float du = 0, dv = 0;
+ float du, dv;
sub_v3_v3v3(e1, v1, v0);
sub_v3_v3v3(e2, v2, v0);
@@ -1132,14 +1132,19 @@ bool isect_ray_tri_threshold_v3(const float p1[3], const float d[3],
u = f * dot_v3v3(s, p);
v = f * dot_v3v3(d, q);
- if (u < 0) du = u;
- if (u > 1) du = u - 1;
- if (v < 0) dv = v;
- if (v > 1) dv = v - 1;
if (u > 0 && v > 0 && u + v > 1) {
- float t = u + v - 1;
- du = u - t / 2;
- dv = v - t / 2;
+ float t = (u + v - 1) / 2;
+ du = u - t;
+ dv = v - t;
+ }
+ else {
+ if (u < 0) du = u;
+ else if (u > 1) du = u - 1;
+ else du = 0.0f;
+
+ if (v < 0) dv = v;
+ else if (v > 1) dv = v - 1;
+ else dv = 0.0f;
}
mul_v3_fl(e1, du);