From cc26b5384cc0eb1ab54ba5b796c9c2160777fe20 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Tue, 10 Sep 2024 20:29:02 +0200 Subject: [PATCH] Mark buffer as dirty in mesh helpers unclear if this fixes any actual bug --- src/client/mesh.cpp | 11 ++++++++--- src/client/mesh.h | 6 +++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/client/mesh.cpp b/src/client/mesh.cpp index 43c4f475b..1e32fcfd1 100644 --- a/src/client/mesh.cpp +++ b/src/client/mesh.cpp @@ -34,7 +34,7 @@ inline static void applyShadeFactor(video::SColor& color, float factor) color.setBlue(core::clamp(core::round32(color.getBlue()*factor), 0, 255)); } -void applyFacesShading(video::SColor &color, const v3f &normal) +void applyFacesShading(video::SColor &color, const v3f normal) { /* Some drawtypes have normals set to (0, 0, 0), this must result in @@ -133,6 +133,7 @@ void scaleMesh(scene::IMesh *mesh, v3f scale) for (u32 i = 0; i < vertex_count; i++) ((video::S3DVertex *)(vertices + i * stride))->Pos *= scale; + buf->setDirty(scene::EBT_VERTEX); buf->recalculateBoundingBox(); // calculate total bounding box @@ -161,6 +162,7 @@ void translateMesh(scene::IMesh *mesh, v3f vec) for (u32 i = 0; i < vertex_count; i++) ((video::S3DVertex *)(vertices + i * stride))->Pos += vec; + buf->setDirty(scene::EBT_VERTEX); buf->recalculateBoundingBox(); // calculate total bounding box @@ -172,16 +174,17 @@ void translateMesh(scene::IMesh *mesh, v3f vec) mesh->setBoundingBox(bbox); } -void setMeshBufferColor(scene::IMeshBuffer *buf, const video::SColor &color) +void setMeshBufferColor(scene::IMeshBuffer *buf, const video::SColor color) { const u32 stride = getVertexPitchFromType(buf->getVertexType()); u32 vertex_count = buf->getVertexCount(); u8 *vertices = (u8 *) buf->getVertices(); for (u32 i = 0; i < vertex_count; i++) ((video::S3DVertex *) (vertices + i * stride))->Color = color; + buf->setDirty(scene::EBT_VERTEX); } -void setMeshColor(scene::IMesh *mesh, const video::SColor &color) +void setMeshColor(scene::IMesh *mesh, const video::SColor color) { if (mesh == NULL) return; @@ -202,6 +205,7 @@ static void applyToMesh(scene::IMesh *mesh, const F &fn) char *vertices = reinterpret_cast(buf->getVertices()); for (u32 i = 0; i < vertex_count; i++) fn(reinterpret_cast(vertices + i * stride)); + buf->setDirty(scene::EBT_VERTEX); } } @@ -218,6 +222,7 @@ void colorizeMeshBuffer(scene::IMeshBuffer *buf, const video::SColor *buffercolo // Apply shading applyFacesShading(*vc, vertex->Normal); } + buf->setDirty(scene::EBT_VERTEX); } void setMeshColorByNormalXYZ(scene::IMesh *mesh, diff --git a/src/client/mesh.h b/src/client/mesh.h index 931a5d818..c04cfb0af 100644 --- a/src/client/mesh.h +++ b/src/client/mesh.h @@ -27,7 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc., * Applies shading to a color based on the surface's * normal vector. */ -void applyFacesShading(video::SColor &color, const v3f &normal); +void applyFacesShading(video::SColor &color, const v3f normal); /* Create a new cube mesh. @@ -52,12 +52,12 @@ void translateMesh(scene::IMesh *mesh, v3f vec); /*! * Sets a constant color for all vertices in the mesh buffer. */ -void setMeshBufferColor(scene::IMeshBuffer *buf, const video::SColor &color); +void setMeshBufferColor(scene::IMeshBuffer *buf, const video::SColor color); /* Set a constant color for all vertices in the mesh */ -void setMeshColor(scene::IMesh *mesh, const video::SColor &color); +void setMeshColor(scene::IMesh *mesh, const video::SColor color); /*! * Overwrites the color of a mesh buffer.