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:
parent
21437090b8
commit
3c5e0d10fc
2 changed files with 8 additions and 6 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue