diff options
| author | Dan Goodliffe <dan.goodliffe@octal.co.uk> | 2026-03-30 13:04:36 +0100 |
|---|---|---|
| committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2026-03-31 00:37:24 +0100 |
| commit | fb78c88576d9fed90ee69dfa35a9fbd3179ff486 (patch) | |
| tree | 3666e8c7a7ebf56b5d9e6919093c3a9c7766a750 /gfx/renderable.cpp | |
| parent | Use uint32_t for indexes in InstanceVertices (diff) | |
| download | ilt-fb78c88576d9fed90ee69dfa35a9fbd3179ff486.tar.bz2 ilt-fb78c88576d9fed90ee69dfa35a9fbd3179ff486.tar.xz ilt-fb78c88576d9fed90ee69dfa35a9fbd3179ff486.zip | |
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)
Diffstat (limited to 'gfx/renderable.cpp')
| -rw-r--r-- | gfx/renderable.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
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::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<CommonLocationData>(); + } +} + +GLuint +gl_traits<InstanceVertices<Renderable::CommonLocation>::InstanceProxy>::vertexArrayAttribFormat( + GLuint vao, GLuint index, GLuint offset) +{ + return gl_traits< + decltype(InstanceVertices<Renderable::CommonLocation>::InstanceProxy::index)>::vertexArrayAttribFormat(vao, + index, offset + offsetof(InstanceVertices<Renderable::CommonLocation>::InstanceProxy, index)); +}; void Renderable::preFrame(const Frustum &, const Frustum &) |
