mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-12 22:41:49 +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>>},
|
{"min", lua::wrap<l_binop_func<util::min>>},
|
||||||
{"max", lua::wrap<l_binop_func<util::max>>},
|
{"max", lua::wrap<l_binop_func<util::max>>},
|
||||||
{"abs", lua::wrap<l_unaryop_func<util::abs>>},
|
{"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>},
|
{"resize", lua::wrap<l_resize>},
|
||||||
{"crop", lua::wrap<l_crop>},
|
{"crop", lua::wrap<l_crop>},
|
||||||
{"at", lua::wrap<l_at>},
|
{"at", lua::wrap<l_at>},
|
||||||
|
|
|
||||||
|
|
@ -3,31 +3,26 @@
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
namespace util {
|
namespace util {
|
||||||
template<class T>
|
template<class T, T (*F)(T, T)>
|
||||||
struct pow {
|
struct binary_op {
|
||||||
constexpr T operator()(T a, T b) const {
|
constexpr T operator()(T a, T b) const { return F(a, b); }
|
||||||
return glm::pow(a, b);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template<class T> using pow = binary_op<T, glm::pow>;
|
||||||
struct min {
|
template<class T> using min = binary_op<T, glm::min>;
|
||||||
constexpr T operator()(T a, T b) const {
|
template<class T> using max = binary_op<T, glm::max>;
|
||||||
return glm::min(a, b);
|
|
||||||
}
|
|
||||||
|
template<class T, T (*F)(T)>
|
||||||
|
struct unary_op {
|
||||||
|
constexpr T operator()(T a) const { return F(a); }
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template<typename T> using abs = unary_op<T, glm::abs>;
|
||||||
struct max {
|
template<typename T> using floor = unary_op<T, glm::floor>;
|
||||||
constexpr T operator()(T a, T b) const {
|
template<typename T> using round = unary_op<T, glm::round>;
|
||||||
return glm::max(a, b);
|
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>;
|
||||||
template<class T>
|
|
||||||
struct abs {
|
|
||||||
constexpr T operator()(T a) const {
|
|
||||||
return glm::abs(a);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue