C++17 std::variant and shader uniforms are a match made in heaven ; )
This commit is contained in:
parent
40b84fb78f
commit
f9fbf44391
4 changed files with 35 additions and 19 deletions
|
@ -29,32 +29,30 @@
|
|||
namespace pw {
|
||||
|
||||
const static double __PW_PI = 3.1415926535897932384626433832795028841971693993751058209;
|
||||
const static double __RAD2DEG = 180.0 / __PW_PI;
|
||||
const static double __DEG2RAD = __PW_PI / 180.0;
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline const T pi() { return static_cast<T>(__PW_PI); }
|
||||
|
||||
template <typename T>
|
||||
inline const T one_over_pi() { return static_cast<T>(1 / __PW_PI); }
|
||||
|
||||
template <typename T>
|
||||
inline T rad_to_deg(const T& angle_in_radian) {
|
||||
return angle_in_radian * __RAD2DEG;
|
||||
return angle_in_radian * static_cast<T>(180) * one_over_pi<T>();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T deg_to_rad(const T& angle_in_degree) {
|
||||
return angle_in_degree * __DEG2RAD;
|
||||
return angle_in_degree * pi<T>() / static_cast<T>(180);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static inline
|
||||
T repeat(const T& t, const T& length) {
|
||||
inline T repeat(const T& t, const T& length) {
|
||||
return std::clamp(t - std::floor(t / length) * length, T(0), length);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static inline
|
||||
T ping_pong(const T& t,const T& length) {
|
||||
inline T ping_pong(const T& t,const T& length) {
|
||||
auto tn = repeat(t, length * T(2));
|
||||
return length - std::abs(tn - length);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue