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) --- gfx/renderable.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'gfx/renderable.cpp') diff --git a/gfx/renderable.cpp b/gfx/renderable.cpp index 8caab93..4597597 100644 --- a/gfx/renderable.cpp +++ b/gfx/renderable.cpp @@ -1,4 +1,39 @@ #include "renderable.h" +#include "gl_traits.h" +#include "location.h" +#include "maths.h" + +std::weak_ptr Renderable::commonLocationData; + +Renderable::CommonLocation::CommonLocation(Location const & location) : + position {location.pos, 0}, rotation {location.rot, 0}, rotationMatrix {location.getRotationTransform()} +{ +} + +Renderable::CommonLocation & +Renderable::CommonLocation ::operator=(Location const & location) +{ + position = location.pos || 0; + rotation = location.rot || 0.F; + rotationMatrix = location.getRotationTransform(); + return *this; +} + +Renderable::Renderable() +{ + if (!(locationData = commonLocationData.lock())) { + commonLocationData = locationData = std::make_shared(); + } +} + +GLuint +gl_traits::InstanceProxy>::vertexArrayAttribFormat( + GLuint vao, GLuint index, GLuint offset) +{ + return gl_traits< + decltype(InstanceVertices::InstanceProxy::index)>::vertexArrayAttribFormat(vao, + index, offset + offsetof(InstanceVertices::InstanceProxy, index)); +}; void Renderable::preFrame(const Frustum &, const Frustum &) -- cgit v1.3