diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-04-23 21:31:41 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2023-04-23 21:31:41 +0100 |
commit | 687afb09ada73fb4aee932242a3b7ee492e63cb0 (patch) | |
tree | e8c654edf5b0927238c89d8c861afe9bed995c8c /game/vehicles/railVehicleClass.h | |
parent | Add BufferedLocation (diff) | |
download | ilt-687afb09ada73fb4aee932242a3b7ee492e63cb0.tar.bz2 ilt-687afb09ada73fb4aee932242a3b7ee492e63cb0.tar.xz ilt-687afb09ada73fb4aee932242a3b7ee492e63cb0.zip |
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.
Diffstat (limited to 'game/vehicles/railVehicleClass.h')
-rw-r--r-- | game/vehicles/railVehicleClass.h | 15 |
1 files changed, 12 insertions, 3 deletions
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 <array> #include <memory> #include <string> @@ -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<Location, 2> &) const; - void shadows(const ShadowMapper &, const Location &, const std::array<Location, 2> &) const; + void render(const SceneShader & shader) const override; + void shadows(const ShadowMapper & shadowMapper) const override; std::array<Mesh::Ptr, 2> bogies; Mesh::Ptr bodyMesh; @@ -23,9 +25,16 @@ public: float length; float maxSpeed; + mutable InstanceVertices<glm::mat4> instancesBody; + mutable std::array<InstanceVertices<glm::mat4>, 2> instancesBogies; + protected: friend Persistence::SelectionPtrBase<std::shared_ptr<RailVehicleClass>>; bool persist(Persistence::PersistenceStore & store) override; void postLoad() override; + +private: + glVertexArray instanceVAO; + std::array<glVertexArray, 2> instancesBogiesVAO; }; using RailVehicleClassPtr = std::shared_ptr<RailVehicleClass>; |