cloth: Avoid calling powf with integer exponent
This is pretty slow and even shows up in profiling.
This commit is contained in:
parent
9c15439c5c
commit
490b73ff22
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue