1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Split CVertexBuffer from CMeshBuffer

This commit is contained in:
sfan5 2024-08-27 16:50:41 +02:00
parent 538b8b9b34
commit 5d6e15bc49
10 changed files with 246 additions and 78 deletions

View file

@ -26,7 +26,9 @@ CBillboardSceneNode::CBillboardSceneNode(ISceneNode *parent, ISceneManager *mgr,
setSize(size);
Buffer->Vertices.resize(4);
auto &Vertices = Buffer->Vertices->Data;
Vertices.resize(4);
Buffer->Indices.resize(6);
Buffer->Indices[0] = 0;
@ -36,17 +38,17 @@ CBillboardSceneNode::CBillboardSceneNode(ISceneNode *parent, ISceneManager *mgr,
Buffer->Indices[4] = 3;
Buffer->Indices[5] = 2;
Buffer->Vertices[0].TCoords.set(1.0f, 1.0f);
Buffer->Vertices[0].Color = colorBottom;
Vertices[0].TCoords.set(1.0f, 1.0f);
Vertices[0].Color = colorBottom;
Buffer->Vertices[1].TCoords.set(1.0f, 0.0f);
Buffer->Vertices[1].Color = colorTop;
Vertices[1].TCoords.set(1.0f, 0.0f);
Vertices[1].Color = colorTop;
Buffer->Vertices[2].TCoords.set(0.0f, 0.0f);
Buffer->Vertices[2].Color = colorTop;
Vertices[2].TCoords.set(0.0f, 0.0f);
Vertices[2].Color = colorTop;
Buffer->Vertices[3].TCoords.set(0.0f, 1.0f);
Buffer->Vertices[3].Color = colorBottom;
Vertices[3].TCoords.set(0.0f, 1.0f);
Vertices[3].Color = colorBottom;
}
CBillboardSceneNode::~CBillboardSceneNode()
@ -114,7 +116,7 @@ void CBillboardSceneNode::updateMesh(const irr::scene::ICameraSceneNode *camera)
view *= -1.0f;
auto *vertices = Buffer->Vertices.data();
auto &vertices = Buffer->Vertices->Data;
for (s32 i = 0; i < 4; ++i)
vertices[i].Normal = view;
@ -211,8 +213,9 @@ void CBillboardSceneNode::getSize(f32 &height, f32 &bottomEdgeWidth,
//! \param overallColor: the color to set
void CBillboardSceneNode::setColor(const video::SColor &overallColor)
{
auto &vertices = Buffer->Vertices->Data;
for (u32 vertex = 0; vertex < 4; ++vertex)
Buffer->Vertices[vertex].Color = overallColor;
vertices[vertex].Color = overallColor;
}
//! Set the color of the top and bottom vertices of the billboard
@ -221,10 +224,11 @@ void CBillboardSceneNode::setColor(const video::SColor &overallColor)
void CBillboardSceneNode::setColor(const video::SColor &topColor,
const video::SColor &bottomColor)
{
Buffer->Vertices[0].Color = bottomColor;
Buffer->Vertices[1].Color = topColor;
Buffer->Vertices[2].Color = topColor;
Buffer->Vertices[3].Color = bottomColor;
auto &vertices = Buffer->Vertices->Data;
vertices[0].Color = bottomColor;
vertices[1].Color = topColor;
vertices[2].Color = topColor;
vertices[3].Color = bottomColor;
}
//! Gets the color of the top and bottom vertices of the billboard
@ -233,8 +237,9 @@ void CBillboardSceneNode::setColor(const video::SColor &topColor,
void CBillboardSceneNode::getColor(video::SColor &topColor,
video::SColor &bottomColor) const
{
bottomColor = Buffer->Vertices[0].Color;
topColor = Buffer->Vertices[1].Color;
auto &vertices = Buffer->Vertices->Data;
bottomColor = vertices[0].Color;
topColor = vertices[1].Color;
}
//! Creates a clone of this scene node and its children.