Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/rendering/StarTilePainter.hpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-08-20 18:56:50 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2023-08-20 18:56:50 +1000
commit6e7c0498ef18ea558621eb7ca98f91122a55e6a6 (patch)
treee967d03fbd3222f21e102ec608dc42eb811a990f /source/rendering/StarTilePainter.hpp
parent0bb0bd30b00a8c9dd5ee6c0398908ba9d7f057ae (diff)
Hook tile meshing up to Material Item drop and preview
Diffstat (limited to 'source/rendering/StarTilePainter.hpp')
-rw-r--r--source/rendering/StarTilePainter.hpp34
1 files changed, 2 insertions, 32 deletions
diff --git a/source/rendering/StarTilePainter.hpp b/source/rendering/StarTilePainter.hpp
index 9e21850..3126a16 100644
--- a/source/rendering/StarTilePainter.hpp
+++ b/source/rendering/StarTilePainter.hpp
@@ -6,6 +6,7 @@
#include "StarMaterialRenderProfile.hpp"
#include "StarRenderer.hpp"
#include "StarWorldCamera.hpp"
+#include "StarTileDrawer.hpp"
namespace Star {
@@ -13,7 +14,7 @@ STAR_CLASS(Assets);
STAR_CLASS(MaterialDatabase);
STAR_CLASS(TilePainter);
-class TilePainter {
+class TilePainter : public TileDrawer {
public:
// The rendered tiles are split and cached in chunks of RenderChunkSize x
// RenderChunkSize. This means that, around the border, there may be as many
@@ -62,13 +63,10 @@ private:
typedef HashMap<TerrainLayer, HashMap<QuadZLevel, RenderBufferPtr>> TerrainChunk;
typedef HashMap<LiquidId, RenderBufferPtr> LiquidChunk;
- typedef size_t MaterialRenderPieceIndex;
typedef tuple<MaterialId, MaterialRenderPieceIndex, MaterialHue, bool> MaterialPieceTextureKey;
typedef String AssetTextureKey;
typedef Variant<MaterialPieceTextureKey, AssetTextureKey> TextureKey;
- typedef List<pair<MaterialRenderPieceConstPtr, Vec2F>> MaterialPieceResultList;
-
struct TextureKeyHash {
size_t operator()(TextureKey const& key) const;
};
@@ -80,15 +78,6 @@ private:
static ChunkHash terrainChunkHash(WorldRenderData& renderData, Vec2I chunkIndex);
static ChunkHash liquidChunkHash(WorldRenderData& renderData, Vec2I chunkIndex);
- static QuadZLevel materialZLevel(uint32_t zLevel, MaterialId material, MaterialHue hue, MaterialColorVariant colorVariant);
- static QuadZLevel modZLevel(uint32_t zLevel, ModId mod, MaterialHue hue, MaterialColorVariant colorVariant);
- static QuadZLevel damageZLevel();
-
- static RenderTile const& getRenderTile(WorldRenderData const& renderData, Vec2I const& worldPos);
-
- template <typename Function>
- static void forEachRenderTile(WorldRenderData const& renderData, RectI const& worldCoordRange, Function&& function);
-
void renderTerrainChunks(WorldCamera const& camera, TerrainLayer terrainLayer);
shared_ptr<TerrainChunk const> getTerrainChunk(WorldRenderData& renderData, Vec2I chunkIndex);
@@ -98,17 +87,10 @@ private:
TerrainLayer terrainLayer, Vec2I const& pos, WorldRenderData const& renderData);
void produceLiquidPrimitives(HashMap<LiquidId, List<RenderPrimitive>>& primitives, Vec2I const& pos, WorldRenderData const& renderData);
- bool determineMatchingPieces(MaterialPieceResultList& resultList, bool* occlude, MaterialDatabaseConstPtr const& materialDb, MaterialRenderMatchList const& matchList,
- WorldRenderData const& renderData, Vec2I const& basePos, TileLayer layer, bool isMod);
-
float liquidDrawLevel(float liquidLevel) const;
List<LiquidInfo> m_liquids;
- Vec4B m_backgroundLayerColor;
- Vec4B m_foregroundLayerColor;
- Vec2F m_liquidDrawLevels;
-
RendererPtr m_renderer;
TextureGroupPtr m_textureGroup;
@@ -123,18 +105,6 @@ private:
Vec2F m_cameraPan;
};
-template <typename Function>
-void TilePainter::forEachRenderTile(WorldRenderData const& renderData, RectI const& worldCoordRange, Function&& function) {
- RectI indexRect = RectI::withSize(renderData.geometry.diff(worldCoordRange.min(), renderData.tileMinPosition), worldCoordRange.size());
- indexRect.limit(RectI::withSize(Vec2I(0, 0), Vec2I(renderData.tiles.size())));
-
- if (!indexRect.isEmpty()) {
- renderData.tiles.forEach(Array2S(indexRect.min()), Array2S(indexRect.size()), [&](Array2S const& index, RenderTile const& tile) {
- return function(worldCoordRange.min() + (Vec2I(index) - indexRect.min()), tile);
- });
- }
-}
-
}
#endif