From 687afb09ada73fb4aee932242a3b7ee492e63cb0 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Sun, 23 Apr 2023 21:31:41 +0100 Subject: Handle rendering of RailVehicles through RailVehicleClass instancing Trains no longer need rendering as their parts are all RVC assets and that just works now. This commit creates some irritating duplication in RVC wrt body/2 bogies all of which are stored separately, but function in exactly the same way. This breaks RV shadows as we have no instancing shadow shaders yet. --- game/vehicles/railVehicleClass.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'game/vehicles/railVehicleClass.h') diff --git a/game/vehicles/railVehicleClass.h b/game/vehicles/railVehicleClass.h index 1a52e2b..2fda8f7 100644 --- a/game/vehicles/railVehicleClass.h +++ b/game/vehicles/railVehicleClass.h @@ -1,7 +1,9 @@ #pragma once #include "assetFactory/asset.h" +#include "gfx/gl/instanceVertices.h" #include "gfx/models/mesh.h" +#include "gfx/renderable.h" #include #include #include @@ -11,10 +13,10 @@ class ShadowMapper; class Texture; class Location; -class RailVehicleClass : public Asset { +class RailVehicleClass : public Renderable, public Asset { public: - void render(const SceneShader &, const Location &, const std::array &) const; - void shadows(const ShadowMapper &, const Location &, const std::array &) const; + void render(const SceneShader & shader) const override; + void shadows(const ShadowMapper & shadowMapper) const override; std::array bogies; Mesh::Ptr bodyMesh; @@ -23,9 +25,16 @@ public: float length; float maxSpeed; + mutable InstanceVertices instancesBody; + mutable std::array, 2> instancesBogies; + protected: friend Persistence::SelectionPtrBase>; bool persist(Persistence::PersistenceStore & store) override; void postLoad() override; + +private: + glVertexArray instanceVAO; + std::array instancesBogiesVAO; }; using RailVehicleClassPtr = std::shared_ptr; -- cgit v1.2.3