summaryrefslogtreecommitdiff
path: root/src/mesh.cpp
diff options
context:
space:
mode:
authorRealBadAngel <maciej.kasatkin@o2.pl>2016-02-21 06:50:41 +0100
committerparamat <mat.gregory@virginmedia.com>2016-11-12 06:41:04 +0000
commit68f5b877c72cf91106ac343673f8a31b9712a470 (patch)
treed9706d8b21a613c40e7ecf6eb254f41d5ca980ba /src/mesh.cpp
parent8a1a9fdc24d29419422f0fb41095fd0388c4be9e (diff)
downloadminetest-68f5b877c72cf91106ac343673f8a31b9712a470.tar.gz
minetest-68f5b877c72cf91106ac343673f8a31b9712a470.tar.bz2
minetest-68f5b877c72cf91106ac343673f8a31b9712a470.zip
Halo: Highlight selected face
This is a slightly modified and cleaned up version of #3774 by RealBadAngel. By sofar: Remove color change (just make it lighter) and some minor cleanups.
Diffstat (limited to 'src/mesh.cpp')
-rw-r--r--src/mesh.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/mesh.cpp b/src/mesh.cpp
index b5bf8660a..b68862d22 100644
--- a/src/mesh.cpp
+++ b/src/mesh.cpp
@@ -226,7 +226,27 @@ void setMeshColorByNormalXYZ(scene::IMesh *mesh,
vertex->Color = colorY;
else
vertex->Color = colorZ;
+ }
+ }
+}
+
+void setMeshColorByNormal(scene::IMesh *mesh, const v3f &normal,
+ const video::SColor &color)
+{
+ if (!mesh)
+ return;
+ u16 mc = mesh->getMeshBufferCount();
+ for (u16 j = 0; j < mc; j++) {
+ scene::IMeshBuffer *buf = mesh->getMeshBuffer(j);
+ 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 *vertex = (video::S3DVertex *)(vertices + i * stride);
+ if (normal == vertex->Normal) {
+ vertex->Color = color;
+ }
}
}
}