Files
neoLegacy/Minecraft.Client/DynamicLighting.h
T

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);
};