mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 10:31:50 +00:00
add new methods to Heightmap
This commit is contained in:
parent
021e00422b
commit
ab0768be68
2 changed files with 24 additions and 23 deletions
|
|
@ -264,6 +264,12 @@ static std::unordered_map<std::string, lua_CFunction> methods {
|
|||
{"min", lua::wrap<l_binop_func<util::min>>},
|
||||
{"max", lua::wrap<l_binop_func<util::max>>},
|
||||
{"abs", lua::wrap<l_unaryop_func<util::abs>>},
|
||||
{"floor", lua::wrap<l_unaryop_func<util::floor>>},
|
||||
{"round", lua::wrap<l_unaryop_func<util::round>>},
|
||||
{"ceil", lua::wrap<l_unaryop_func<util::ceil>>},
|
||||
{"sin", lua::wrap<l_unaryop_func<util::sin>>},
|
||||
{"cos", lua::wrap<l_unaryop_func<util::cos>>},
|
||||
{"tan", lua::wrap<l_unaryop_func<util::tan>>},
|
||||
{"resize", lua::wrap<l_resize>},
|
||||
{"crop", lua::wrap<l_crop>},
|
||||
{"at", lua::wrap<l_at>},
|
||||
|
|
|
|||
|
|
@ -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>;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue