add new methods to Heightmap

This commit is contained in:
MihailRis 2026-08-10 21:58:13 +03:00
parent 021e00422b
commit ab0768be68
2 changed files with 24 additions and 23 deletions

View file

@ -3,31 +3,26 @@
#include <glm/glm.hpp>
namespace util {
template<class T>
struct pow {
constexpr T operator()(T a, T b) const {
return glm::pow(a, b);
}
template<class T, T (*F)(T, T)>
struct binary_op {
constexpr T operator()(T a, T b) const { return F(a, b); }
};
template<class T>
struct min {
constexpr T operator()(T a, T b) const {
return glm::min(a, b);
}
template<class T> using pow = binary_op<T, glm::pow>;
template<class T> using min = binary_op<T, glm::min>;
template<class T> using max = binary_op<T, glm::max>;
template<class T, T (*F)(T)>
struct unary_op {
constexpr T operator()(T a) const { return F(a); }
};
template<class T>
struct max {
constexpr T operator()(T a, T b) const {
return glm::max(a, b);
}
};
template<class T>
struct abs {
constexpr T operator()(T a) const {
return glm::abs(a);
}
};
template<typename T> using abs = unary_op<T, glm::abs>;
template<typename T> using floor = unary_op<T, glm::floor>;
template<typename T> using round = unary_op<T, glm::round>;
template<typename T> using ceil = unary_op<T, glm::ceil>;
template<typename T> using sin = unary_op<T, glm::sin>;
template<typename T> using cos = unary_op<T, glm::cos>;
template<typename T> using tan = unary_op<T, glm::tan>;
}