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:
authorSergej Reich <sergej.reich@googlemail.com>2014-11-11 20:08:15 +0300
committerSergej Reich <sergej.reich@googlemail.com>2014-11-11 20:08:15 +0300
commit490b73ff22ce554eaed6f0804b1fd1e9f36ceb43 (patch)
tree13b1de52581b98d0e6387355cd580071733bbf96
parent9c15439c5c91c2834c082c0d2d2434d612764bc2 (diff)
cloth: Avoid calling powf with integer exponent
This is pretty slow and even shows up in profiling.
-rw-r--r--source/blender/blenkernel/intern/implicit.c10
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)