1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-22 17:18:39 +00:00

Rotate meshnode normals correctly instead of recalculating

This commit is contained in:
Lars Mueller 2024-12-09 00:45:37 +01:00 committed by sfan5
parent 21437090b8
commit 3c5e0d10fc
2 changed files with 8 additions and 6 deletions

View file

@ -249,10 +249,14 @@ static void rotateMesh(scene::IMesh *mesh, float degrees)
float c = std::cos(degrees);
float s = std::sin(degrees);
auto rotator = [c, s] (video::S3DVertex *vertex) {
float u = vertex->Pos.*U;
float v = vertex->Pos.*V;
vertex->Pos.*U = c * u - s * v;
vertex->Pos.*V = s * u + c * v;
auto rotate_vec = [c, s] (v3f &vec) {
float u = vec.*U;
float v = vec.*V;
vec.*U = c * u - s * v;
vec.*V = s * u + c * v;
};
rotate_vec(vertex->Pos);
rotate_vec(vertex->Normal);
};
applyToMesh(mesh, rotator);
}