1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-02 16:38:41 +00:00

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.
This commit is contained in:
RealBadAngel 2016-02-21 06:50:41 +01:00 committed by paramat
parent 8a1a9fdc24
commit 68f5b877c7
6 changed files with 39 additions and 2 deletions

View file

@ -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;
}
}
}
}