diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-03-30 05:23:19 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-03-30 05:28:09 +0400 |
commit | 480c5019bb2359a96f56e52f406250210946d51b (patch) | |
tree | a2200d16072634efeedbb1c394e5fe0e8dab42f0 | |
parent | 3bd15fcf15e6f4ebcf45b5e5483a2d3b2e53058b (diff) |
Code cleanup: reflect_v3_v3v3 made redundant copies
-rw-r--r-- | source/blender/blenlib/intern/math_vector.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c index d3869f307fb..19865aa00bd 100644 --- a/source/blender/blenlib/intern/math_vector.c +++ b/source/blender/blenlib/intern/math_vector.c @@ -471,25 +471,19 @@ void bisect_v3_v3v3v3(float out[3], const float v1[3], const float v2[3], const normalize_v3(out); } -/* Returns a reflection vector from a vector and a normal vector +/** + * Returns a reflection vector from a vector and a normal vector * reflect = vec - ((2 * DotVecs(vec, mirror)) * mirror) */ -void reflect_v3_v3v3(float out[3], const float v1[3], const float v2[3]) +void reflect_v3_v3v3(float out[3], const float vec[3], const float normal[3]) { - float vec[3], normal[3]; - float reflect[3] = {0.0f, 0.0f, 0.0f}; - float dot2; - - copy_v3_v3(vec, v1); - copy_v3_v3(normal, v2); - - dot2 = 2 * dot_v3v3(vec, normal); + const float dot2 = 2.0f * dot_v3v3(vec, normal); - reflect[0] = vec[0] - (dot2 * normal[0]); - reflect[1] = vec[1] - (dot2 * normal[1]); - reflect[2] = vec[2] - (dot2 * normal[2]); + BLI_ASSERT_UNIT_V3(normal); - copy_v3_v3(out, reflect); + out[0] = vec[0] - (dot2 * normal[0]); + out[1] = vec[1] - (dot2 * normal[1]); + out[2] = vec[2] - (dot2 * normal[2]); } void ortho_basis_v3v3_v3(float v1[3], float v2[3], const float v[3]) |