From fb78c88576d9fed90ee69dfa35a9fbd3179ff486 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Mon, 30 Mar 2026 13:04:36 +0100 Subject: Use a single buffer for the location/rotation data of all renderable objects Removes the BufferedLocation and BufferedLocationUpdater mess. Note: appears to break bogie rendering in asset factory test only, same symptom as broken network render test? (out of date buffer data) --- game/vehicles/railVehicleClass.cpp | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'game/vehicles/railVehicleClass.cpp') diff --git a/game/vehicles/railVehicleClass.cpp b/game/vehicles/railVehicleClass.cpp index 176fe82..4e9404c 100644 --- a/game/vehicles/railVehicleClass.cpp +++ b/game/vehicles/railVehicleClass.cpp @@ -7,7 +7,6 @@ #include #include #include -#include bool RailVehicleClass::persist(Persistence::PersistenceStore & store) @@ -20,12 +19,10 @@ RailVehicleClass::persist(Persistence::PersistenceStore & store) std::any RailVehicleClass::createAt(const Location & position) const { - return std::make_shared::InstanceProxy>(instances.acquire(LocationVertex { - .body = {.rotation = position.getRotationTransform(), .position = position.pos}, - .front = {.rotation = position.getRotationTransform(), - .position = {sincos(position.rot.x) * wheelBase * 0.5F, position.pos.z}}, - .back = {.rotation = position.getRotationTransform(), - .position = {sincos(position.rot.x) * wheelBase * -0.5F, position.pos.z}}, + return std::make_shared::InstanceProxy>(instances.acquire(InstanceVertex { + .body = locationData->acquire(position), + .front = locationData->acquire(position + ((sincos(position.rot.x) * wheelBase * 0.5F) || 0.F)), + .back = locationData->acquire(position + ((sincos(position.rot.x) * wheelBase * -0.5F) || 0.F)), })); } @@ -34,22 +31,20 @@ RailVehicleClass::postLoad() { texture = getTexture(); glDebugScope _ {0}; - bodyMesh->configureVAO(instanceVAO, 0) - .addAttribs(1); - static_assert(sizeof(LocationVertex) == 144UL); + bodyMesh->configureVAO(instanceVAO, 0).addAttribs(1); } void RailVehicleClass::renderAllParts(const size_t count) const { - using PartPair = std::pair; + using PartPair = std::pair; const auto bufferName = instances.bufferName(); for (const auto & [mesh, part] : { - PartPair {bodyMesh, &LocationVertex::body}, - PartPair {bogies.front(), &LocationVertex::front}, - PartPair {bogies.back(), &LocationVertex::back}, + PartPair {bodyMesh, &InstanceVertex::body}, + PartPair {bogies.front(), &InstanceVertex::front}, + PartPair {bogies.back(), &InstanceVertex::back}, }) { - instanceVAO.useBuffer(1, bufferName, part); + instanceVAO.useBuffer(1, bufferName, part); mesh->drawInstanced(instanceVAO, static_cast(count)); } } -- cgit v1.3