mirror of
https://git.neolegacy.dev/neoStudiosLCE/neoLegacy.git
synced 2026-11-18 19:50:00 +01:00
Co-authored-by: DrPerkyLegit <116128211+DrPerkyLegit@users.noreply.github.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: Anaël <60509176+Bakoubak@users.noreply.github.com> Reviewed-on: https://git.neolegacy.dev/neoStudiosLCE/neoLegacy/pulls/4205
55 lines
1.7 KiB
C++
55 lines
1.7 KiB
C++
#pragma once
|
|
|
|
#include <atomic>
|
|
#include <mutex>
|
|
#include <vector>
|
|
#include <unordered_map>
|
|
|
|
class GameRenderer;
|
|
class Entity;
|
|
|
|
class DynamicLighting {
|
|
private:
|
|
struct DynamicLightSource {
|
|
Entity* entity;
|
|
double luminance;
|
|
double x;
|
|
double y;
|
|
double z;
|
|
};
|
|
|
|
|
|
static double constexpr MAX_RADIUS = 7.75;
|
|
|
|
static std::mutex dynamicEntityLightSourcesMutex;
|
|
static std::vector<Entity*> dynamicEntityLightSources;
|
|
|
|
static std::mutex dynamicCompiledLightSourcesMutex;
|
|
static std::vector<DynamicLightSource> dynamicCompiledLightSources;
|
|
|
|
static std::unordered_map<int, std::pair<int, int>> dynamicEntitySourceDefines;
|
|
static std::unordered_map<int, std::pair<int, int>> dynamicItemSourceDefines;
|
|
|
|
static int64_t lastUpdate;
|
|
static std::atomic<bool> dynamicLightingEnabled;
|
|
static int getEntityFlickerRange(Entity* entity);
|
|
static int getItemFlickerRange(shared_ptr<ItemInstance> item);
|
|
static int getFlickeredLuminance(Entity* entity, int luminance, int64_t now);
|
|
|
|
public:
|
|
static void addDynamicEntityLightSource(Entity* entity);
|
|
static void removeDynamicEntityLightSource(Entity* entity);
|
|
|
|
static int getLightmapWithDynamicLight(int x, int y, int z, int lightMap);
|
|
static int getLightmapWithDynamicLight(Entity* entity, int lightMap);
|
|
static int getLightmapWithDynamicLight(double dynamicLuminance, int lightMap);
|
|
|
|
static int getEntityLuminance(Entity* entity);
|
|
static int getItemLuminance(shared_ptr<ItemInstance> item);
|
|
|
|
static int getDynamicLuminance(int x, int y, int z);
|
|
static int maxDynamicLuminance(int x, int y, int z, DynamicLightSource& source, double currentLuminance);
|
|
|
|
static void updateAll(GameRenderer* renderer);
|
|
static void markTilesDirty(MultiPlayerLevel* level, int x, int y, int z, int luminance);
|
|
}; |