mirror of
https://github.com/minetest/minetest.git
synced 2024-12-31 18:37:29 +01:00
Rotate meshnode normals correctly instead of recalculating
This commit is contained in:
parent
21437090b8
commit
3c5e0d10fc
@ -1673,8 +1673,6 @@ void MapblockMeshGenerator::drawMeshNode()
|
||||
modified = false;
|
||||
if (modified) {
|
||||
recalculateBoundingBox(mesh);
|
||||
// FIXME: we should rotate the normals too, instead of recalculating
|
||||
meshmanip->recalculateNormals(mesh, true, false);
|
||||
}
|
||||
} else {
|
||||
warningstream << "drawMeshNode(): missing mesh" << std::endl;
|
||||
|
@ -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…
Reference in New Issue
Block a user