void BaseBufferRenderBatch::AddNodeToBuffer(uint& refVertexIndex, uint& refIndexIndex, IRenderable& node) { auto mesh = node.Mesh(); const Matrix4& newMatrix = node.WorldMatrix(); mesh->AddToVertexBufferObject(mVertexBufferObject, refVertexIndex, newMatrix); mesh->AddToNormalBufferObject(mNormalBufferObject, refVertexIndex, newMatrix); mesh->AddToTexCoordBufferObject(mTexcoordBufferObject, refVertexIndex); mesh->AddToColorBufferObject(mColorBufferObject, refVertexIndex, node.WorldColor()); mesh->AddToIndexBufferObject(mIndexBufferObject, refVertexIndex, refIndexIndex); uintp vertexCount = mesh->VertexCount(); uintp indexCount = mesh->IndexCount(); node.SetBatch(this, refVertexIndex, (uint)vertexCount, refIndexIndex, (uint)indexCount); refVertexIndex += (uint)vertexCount; refIndexIndex += (uint)indexCount; RenderingStatics::Instance().IncreaseChangedNodeCount(); }
void BaseBufferRenderBatch::UpdateNodeToBuffer(uint& refVertexIndex, uint& refIndexIndex, IRenderable& node, RenderableChangedFlags changedFlags) { auto mesh = node.Mesh(); if (MEDUSA_FLAG_HAS(changedFlags,RenderableChangedFlags::NewVertex)) { const Matrix4& newMatrix = node.WorldMatrix(); mesh->AddToVertexBufferObject(mVertexBufferObject, refVertexIndex, newMatrix); } if (MEDUSA_FLAG_HAS(changedFlags, RenderableChangedFlags::NewNormal)) { const Matrix4& newMatrix = node.WorldMatrix(); mesh->AddToNormalBufferObject(mNormalBufferObject, refVertexIndex, newMatrix); } if (MEDUSA_FLAG_HAS(changedFlags, RenderableChangedFlags::NewTexCoord)) { mesh->AddToTexCoordBufferObject(mTexcoordBufferObject, refVertexIndex); } if (MEDUSA_FLAG_HAS(changedFlags, RenderableChangedFlags::NewColor)) { mesh->AddToColorBufferObject(mColorBufferObject, refVertexIndex, node.WorldColor()); } if (MEDUSA_FLAG_HAS(changedFlags, RenderableChangedFlags::NewIndex)) { mesh->AddToIndexBufferObject(mIndexBufferObject, refVertexIndex, refIndexIndex); } uintp vertexCount = mesh->VertexCount(); uintp indexCount = mesh->IndexCount(); node.SetBatch(this, refVertexIndex, (uint)vertexCount, refIndexIndex, (uint)indexCount); refVertexIndex += (uint)vertexCount; refIndexIndex += (uint)indexCount; RenderingStatics::Instance().IncreaseChangedNodeCount(); }