add 'uv-lock' block property

This commit is contained in:
MihailRis 2026-11-02 00:03:25 +03:00
parent c2777eba09
commit 463a439089
8 changed files with 131 additions and 12 deletions

View file

@ -35,7 +35,7 @@ struct UVRegion {
v2 = v1 + uvh * h;
}
inline glm::vec2 apply(const glm::vec2& uv) {
glm::vec2 apply(const glm::vec2& uv) const {
float w = getWidth();
float h = getHeight();
return glm::vec2(u1 + uv.x * w, v1 + uv.y * h);

View file

@ -183,4 +183,19 @@ namespace util {
}
return false;
}
inline void uv_by_normal(
const glm::vec3& n, glm::vec3& u, glm::vec3& v
) {
if (std::abs(n.y) > 0.5f) {
u = {n.y > 0 ? 1 : -1, 0, 0};
v = {0, 0, -1};
} else if (std::abs(n.z) > 0.5f) {
u = {n.z > 0 ? 1 : -1, 0, 0};
v = {0, 1, 0};
} else {
u = {0, 0, n.x > 0 ? -1 : 1};
v = {0, 1, 0};
}
}
}