diff options
author | Sergej Reich <sergej.reich@googlemail.com> | 2014-11-11 20:08:15 +0300 |
---|---|---|
committer | Sergej Reich <sergej.reich@googlemail.com> | 2014-11-11 20:08:15 +0300 |
commit | 490b73ff22ce554eaed6f0804b1fd1e9f36ceb43 (patch) | |
tree | 13b1de52581b98d0e6387355cd580071733bbf96 /source/blender/blenkernel/intern/implicit.c | |
parent | 9c15439c5c91c2834c082c0d2d2434d612764bc2 (diff) |
cloth: Avoid calling powf with integer exponent
This is pretty slow and even shows up in profiling.
Diffstat (limited to 'source/blender/blenkernel/intern/implicit.c')
-rw-r--r-- | source/blender/blenkernel/intern/implicit.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index 9a8c32c4393..fe64af184a9 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -686,14 +686,18 @@ int implicit_free(ClothModifierData *clmd) DO_INLINE float fb(float length, float L) { float x = length / L; - return (-11.541f * powf(x, 4) + 34.193f * powf(x, 3) - 39.083f * powf(x, 2) + 23.116f * x - 9.713f); + float xx = x * x; + float xxx = xx * x; + float xxxx = xxx * x; + return (-11.541f * xxxx + 34.193f * xxx - 39.083f * xx + 23.116f * x - 9.713f); } DO_INLINE float fbderiv(float length, float L) { float x = length/L; - - return (-46.164f * powf(x, 3) + 102.579f * powf(x, 2) - 78.166f * x + 23.116f); + float xx = x * x; + float xxx = xx * x; + return (-46.164f * xxx + 102.579f * xx - 78.166f * x + 23.116f); } DO_INLINE float fbstar(float length, float L, float kb, float cb) |