From 5795e8939bcd5e849c5e63e2c443bada03c93a20 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 3 Apr 2026 14:17:38 +0100 Subject: Create mix-ins for handling asset and instance lights --- game/scenary/illuminator.h | 8 ++------ game/scenary/light.cpp | 9 +-------- game/scenary/light.h | 2 +- 3 files changed, 4 insertions(+), 15 deletions(-) (limited to 'game/scenary') diff --git a/game/scenary/illuminator.h b/game/scenary/illuminator.h index 216b536..2373812 100644 --- a/game/scenary/illuminator.h +++ b/game/scenary/illuminator.h @@ -1,7 +1,7 @@ #pragma once #include "assetFactory/asset.h" -#include "assetFactory/lights.h" +#include "game/mixins/lights.h" #include "gfx/gl/instanceVertices.h" #include "gfx/models/texture.h" #include "gfx/renderable.h" @@ -9,7 +9,7 @@ class SceneShader; class Location; -class Illuminator : public Asset, public Renderable, public StdTypeDefs { +class Illuminator : public Asset, public Renderable, public AssetLights, public StdTypeDefs { Mesh::Ptr bodyMesh; Texture::Ptr texture; std::shared_ptr instanceVAO; @@ -29,8 +29,4 @@ protected: friend Persistence::SelectionPtrBase>; bool persist(Persistence::PersistenceStore & store) override; void postLoad() override; - -public: - std::vector spotLight; - std::vector pointLight; }; diff --git a/game/scenary/light.cpp b/game/scenary/light.cpp index c51efda..455d5b5 100644 --- a/game/scenary/light.cpp +++ b/game/scenary/light.cpp @@ -5,12 +5,5 @@ Light::Light(std::shared_ptr type, const Location & position) type {std::move(type)}, instance {this->type->instances.acquire(Renderable::commonLocationData.lock()->acquire(position))} { - std::ranges::transform(this->type->spotLight, std::back_inserter(spotLightInstances), - [spotLights = Renderable::commonSpotLights.lock(), this](const auto & spotLight) { - return spotLights->acquire(*spotLight, instance->location.index); - }); - std::ranges::transform(this->type->pointLight, std::back_inserter(pointLightInstances), - [pointLights = Renderable::commonPointLights.lock(), this](const auto & pointLight) { - return pointLights->acquire(*pointLight, instance->location.index); - }); + lightsEnable(this->type, instance->location.index); } diff --git a/game/scenary/light.h b/game/scenary/light.h index b1ea469..0b9320c 100644 --- a/game/scenary/light.h +++ b/game/scenary/light.h @@ -5,7 +5,7 @@ class Location; -class Light : public WorldObject { +class Light : public WorldObject, public InstanceLights { std::shared_ptr type; InstanceVertices::InstanceProxy instance; -- cgit v1.3