Add IMeshBuffer::getColor functions

Lazy access function - same as for all other members of S3DVertex (getPosition/getNormal/getTCoords).
Not sure why color was missing, maybe got added later?
Would probably be better to have a getS3DVertex function instead which would cover them all, but it's only some slow (but nice) helper function anyway.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6415 dfc29bdd-3216-0410-991c-e03cc46cb475
This commit is contained in:
cutealien 2022-08-19 12:33:56 +00:00
parent 7d2dbdd0c8
commit 9025fcc377
5 changed files with 72 additions and 0 deletions

@ -176,6 +176,17 @@ namespace scene
return Vertices[i].TCoords; return Vertices[i].TCoords;
} }
//! returns color of vertex i
virtual video::SColor& getColor(u32 i) IRR_OVERRIDE
{
return Vertices[i].Color;
}
//! returns color of vertex i
virtual const video::SColor& getColor(u32 i) const IRR_OVERRIDE
{
return Vertices[i].Color;
}
//! Append the vertices and indices to the current buffer //! Append the vertices and indices to the current buffer
/** Only works for compatible types, i.e. either the same type /** Only works for compatible types, i.e. either the same type

@ -166,6 +166,18 @@ namespace scene
{ {
return getVertexBuffer()[i].Normal; return getVertexBuffer()[i].Normal;
} }
//! returns color of vertex i
virtual video::SColor& getColor(u32 i) IRR_OVERRIDE
{
return getVertexBuffer()[i].Color;
}
//! returns color of vertex i
virtual const video::SColor& getColor(u32 i) const IRR_OVERRIDE
{
return getVertexBuffer()[i].Color;
}
}; };

@ -119,6 +119,12 @@ namespace scene
//! returns texture coord of vertex i //! returns texture coord of vertex i
virtual core::vector2df& getTCoords(u32 i) = 0; virtual core::vector2df& getTCoords(u32 i) = 0;
//! returns color of vertex i
virtual video::SColor& getColor(u32 i) = 0;
//! returns color of vertex i
virtual const video::SColor& getColor(u32 i) const = 0;
//! Append the vertices and indices to the current buffer //! Append the vertices and indices to the current buffer
/** Only works for compatible vertex types /** Only works for compatible vertex types
and not implemented for most buffers for now. and not implemented for most buffers for now.

@ -171,6 +171,21 @@ namespace scene
return (*Vertices)[Indices[i]].TCoords; return (*Vertices)[Indices[i]].TCoords;
} }
//! returns color of vertex i
virtual video::SColor& getColor(u32 i) IRR_OVERRIDE
{
IRR_DEBUG_BREAK_IF(!Vertices);
return (*Vertices)[Indices[i]].Color;
}
//! returns color of vertex i
virtual const video::SColor& getColor(u32 i) const IRR_OVERRIDE
{
IRR_DEBUG_BREAK_IF(!Vertices);
return (*Vertices)[Indices[i]].Color;
}
//! append the vertices and indices to the current buffer //! append the vertices and indices to the current buffer
virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) IRR_OVERRIDE virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) IRR_OVERRIDE
{ {

@ -326,6 +326,34 @@ struct SSkinMeshBuffer : public IMeshBuffer
} }
} }
//! returns color of vertex i
virtual video::SColor& getColor(u32 i) IRR_OVERRIDE
{
switch (VertexType)
{
case video::EVT_2TCOORDS:
return Vertices_2TCoords[i].Color;
case video::EVT_TANGENTS:
return Vertices_Tangents[i].Color;
default:
return Vertices_Standard[i].Color;
}
}
//! returns color of vertex i
virtual const video::SColor& getColor(u32 i) const IRR_OVERRIDE
{
switch (VertexType)
{
case video::EVT_2TCOORDS:
return Vertices_2TCoords[i].Color;
case video::EVT_TANGENTS:
return Vertices_Tangents[i].Color;
default:
return Vertices_Standard[i].Color;
}
}
//! append the vertices and indices to the current buffer //! append the vertices and indices to the current buffer
virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) IRR_OVERRIDE {} virtual void append(const void* const vertices, u32 numVertices, const u16* const indices, u32 numIndices) IRR_OVERRIDE {}