From 72ab29786f6d4c97a92cb95c75091537490e2d0f Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sat, 6 May 2023 16:42:08 +0100 Subject: Templated BufferedLocation and single buffer storage for RVC locations --- game/vehicles/railVehicleClass.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'game/vehicles/railVehicleClass.cpp') diff --git a/game/vehicles/railVehicleClass.cpp b/game/vehicles/railVehicleClass.cpp index 148081f..324148c 100644 --- a/game/vehicles/railVehicleClass.cpp +++ b/game/vehicles/railVehicleClass.cpp @@ -4,6 +4,7 @@ #include "gfx/gl/vertexArrayObject.h" #include "gfx/models/mesh.h" #include "gfx/models/texture.h" +#include "stream_support.h" #include #include #include @@ -34,36 +35,36 @@ void RailVehicleClass::postLoad() { texture = getTexture(); - bodyMesh->configureVAO(instanceVAO).addAttribs(instancesBody.bufferName(), 1); + bodyMesh->configureVAO(instanceVAO).addAttribs(instances.bufferName(), 1); bogies.front() ->configureVAO(instancesBogiesVAO.front()) - .addAttribs(instancesBogies.front().bufferName(), 1); + .addAttribs(instances.bufferName(), 1); bogies.back() ->configureVAO(instancesBogiesVAO.back()) - .addAttribs(instancesBogies.back().bufferName(), 1); + .addAttribs(instances.bufferName(), 1); } void RailVehicleClass::render(const SceneShader & shader) const { - if (const auto count = instancesBody.size()) { + if (const auto count = static_cast(instances.size())) { if (texture) { texture->bind(); } shader.basicInst.use(); - bodyMesh->DrawInstanced(instanceVAO, static_cast(count)); - bogies.front()->DrawInstanced(instancesBogiesVAO.front(), static_cast(instancesBogies.front().size())); - bogies.back()->DrawInstanced(instancesBogiesVAO.back(), static_cast(instancesBogies.back().size())); + bodyMesh->DrawInstanced(instanceVAO, count); + bogies.front()->DrawInstanced(instancesBogiesVAO.front(), count); + bogies.back()->DrawInstanced(instancesBogiesVAO.back(), count); } } void RailVehicleClass::shadows(const ShadowMapper & mapper) const { - if (const auto count = instancesBody.size()) { + if (const auto count = static_cast(instances.size())) { mapper.dynamicPointInst.use(); - bodyMesh->DrawInstanced(instanceVAO, static_cast(count)); - bogies.front()->DrawInstanced(instancesBogiesVAO.front(), static_cast(instancesBogies.front().size())); - bogies.back()->DrawInstanced(instancesBogiesVAO.back(), static_cast(instancesBogies.back().size())); + bodyMesh->DrawInstanced(instanceVAO, count); + bogies.front()->DrawInstanced(instanceVAO, count); + bogies.back()->DrawInstanced(instanceVAO, count); } } -- cgit v1.2.3