Benjamin ‘Touky’ Huet touky pirms 12 gadiem
vecāks
revīzija
2f85ae6d0a
3 mainītis faili ar 26 papildinājumiem un 0 dzēšanām
  1. +10
    -0
      src/lol/math/math.h
  2. +8
    -0
      src/lol/math/vector.h
  3. +8
    -0
      src/numeric.h

+ 10
- 0
src/lol/math/math.h Parādīt failu

@@ -64,6 +64,16 @@ static inline void sincos(float const &x, float *s, float *c)
*c = std::cos(x);
}

static inline double lerp(double const &a, double const &b, double const &x)
{
return a + (b - a) * x;
}
static inline float lerp(float const &a, float const &b, float const &x)
{
return a + (b - a) * x;
}


/* These accelerated functions will be merged into the above, one day */
double lol_sin(double);
double lol_cos(double);


+ 8
- 0
src/lol/math/vector.h Parādīt failu

@@ -1229,6 +1229,14 @@ extern Quat<T> slerp(Quat<T> const &qa, Quat<T> const &qb, T f);
for (size_t n = 0; n < sizeof(a) / sizeof(t1); n++) \
ret += a[n] * b[n]; \
return ret; \
} \
tprefix \
inline tname<tf> lerp(tname<t1> const &a, tname<t2> const &b, tf x) \
{ \
tname<tf> ret; \
for (size_t n = 0; n < sizeof(a) / sizeof(t1); n++) \
ret[n] = a[n] + (a[n] - b[n]) * x; \
return ret; \
}

#define DECLARE_BINARY_VECTOR_COERCE_OPS(tname, tprefix, t1, t2, tf) \


+ 8
- 0
src/numeric.h Parādīt failu

@@ -52,6 +52,14 @@ template <typename T> static inline T PotUp(T val)
return val + 1;
}

//Lerp for float
template <typename T1, typename T2, typename Tf> static inline T1 damp(const T1 &a, const T2 &b, const Tf &x, const Tf &dt)
{
if (dt <= .0f)
return a;
return lol::lerp(a, b, dt / (dt + x));
}

} /* namespace lol */

#endif // __LOL_NUMERIC_H__


Notiek ielāde…
Atcelt
Saglabāt