]> git.localhorst.tv Git - blank.git/commitdiff
actually load shapes
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Tue, 13 Oct 2015 12:38:30 +0000 (14:38 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Tue, 13 Oct 2015 12:38:30 +0000 (14:38 +0200)
load, not use :P

15 files changed:
assets
src/app/Assets.hpp
src/app/app.cpp
src/client/InteractiveState.hpp
src/client/client.cpp
src/model/Shape.cpp [deleted file]
src/model/Shape.hpp
src/model/ShapeRegistry.hpp [new file with mode: 0644]
src/model/shape.cpp [new file with mode: 0644]
src/server/ServerState.cpp
src/server/ServerState.hpp
src/standalone/MasterState.cpp
src/standalone/MasterState.hpp
src/world/BlockType.hpp
src/world/block.cpp

diff --git a/assets b/assets
index 0a3fe3553f0e6fe9a9cd8d8994c15c873d247e34..d49b4a9e4d4b4afe6f483139f3c37db58376bfae 160000 (submodule)
--- a/assets
+++ b/assets
@@ -1 +1 @@
-Subproject commit 0a3fe3553f0e6fe9a9cd8d8994c15c873d247e34
+Subproject commit d49b4a9e4d4b4afe6f483139f3c37db58376bfae
index db0933f961c1520156d52caecb060cc3c753d22e..b9d62e2e04ae7ba284dd9fe69aa058208ad7627a 100644 (file)
@@ -11,6 +11,7 @@ namespace blank {
 class ArrayTexture;
 class BlockTypeRegistry;
 class CubeMap;
+class ShapeRegistry;
 class Sound;
 class Texture;
 class TextureIndex;
@@ -23,6 +24,7 @@ public:
        void LoadBlockTypes(const std::string &set_name, BlockTypeRegistry &, TextureIndex &) const;
        CubeMap LoadCubeMap(const std::string &name) const;
        Font LoadFont(const std::string &name, int size) const;
+       void LoadShapes(const std::string &set_name, ShapeRegistry &) const;
        Sound LoadSound(const std::string &name) const;
        Texture LoadTexture(const std::string &name) const;
        void LoadTexture(const std::string &name, ArrayTexture &, int layer) const;
index 4f2a6ecdfaad1ff6a7b4a49cb462aea382ef426c..eb3dac1b8b4aa0eedcbd3456981a8554c408ebfa 100644 (file)
@@ -14,6 +14,8 @@
 #include "../graphics/Texture.hpp"
 #include "../io/TokenStreamReader.hpp"
 #include "../model/bounds.hpp"
+#include "../model/Shape.hpp"
+#include "../model/ShapeRegistry.hpp"
 #include "../world/BlockType.hpp"
 #include "../world/BlockTypeRegistry.hpp"
 #include "../world/Entity.hpp"
@@ -311,7 +313,7 @@ CuboidBounds slab_shape({{ -0.5f, -0.5f, -0.5f }, { 0.5f, 0.0f, 0.5f }});
 
 }
 
-void AssetLoader::LoadBlockTypes(const std::string &set_name, BlockTypeRegistry &reg, TextureIndex &tex_index) const {
+void AssetLoader::LoadBlockTypes(const string &set_name, BlockTypeRegistry &reg, TextureIndex &tex_index) const {
        string full = data + set_name + ".types";
        std::ifstream file(full);
        if (!file) {
@@ -336,7 +338,17 @@ void AssetLoader::LoadBlockTypes(const std::string &set_name, BlockTypeRegistry
                                type.visible = in.GetBool();
                        } else if (name == "texture") {
                                in.ReadString(tex_name);
-                               type.texture = tex_index.GetID(tex_name);
+                               type.textures.push_back(tex_index.GetID(tex_name));
+                       } else if (name == "textures") {
+                               in.Skip(Token::BRACKET_OPEN);
+                               while (in.Peek().type != Token::BRACKET_CLOSE) {
+                                       in.ReadString(tex_name);
+                                       type.textures.push_back(tex_index.GetID(tex_name));
+                                       if (in.Peek().type == Token::COMMA) {
+                                               in.Skip(Token::COMMA);
+                                       }
+                               }
+                               in.Skip(Token::BRACKET_CLOSE);
                        } else if (name == "rgb_mod") {
                                in.ReadVec(type.rgb_mod);
                        } else if (name == "hsl_mod") {
@@ -485,6 +497,23 @@ Font AssetLoader::LoadFont(const string &name, int size) const {
        return Font(full.c_str(), size);
 }
 
+void AssetLoader::LoadShapes(const string &set_name, ShapeRegistry &shapes) const {
+       string full = data + set_name + ".shapes";
+       std::ifstream file(full);
+       if (!file) {
+               throw std::runtime_error("failed to open shape file " + full);
+       }
+       TokenStreamReader in(file);
+       string shape_name;
+       while (in.HasMore()) {
+               in.ReadIdentifier(shape_name);
+               in.Skip(Token::EQUALS);
+               Shape &shape = shapes.Add(shape_name);
+               shape.Read(in);
+               in.Skip(Token::SEMICOLON);
+       }
+}
+
 Sound AssetLoader::LoadSound(const string &name) const {
        string full = sounds + name + ".wav";
        return Sound(full.c_str());
index 8e7064eacf0a1e2be1f98bf309abe463f26d7043..86757a294c10501dd28c074a28ba59410220bb59 100644 (file)
@@ -9,6 +9,7 @@
 #include "../app/IntervalTimer.hpp"
 #include "../graphics/SkyBox.hpp"
 #include "../io/WorldSave.hpp"
+#include "../model/ShapeRegistry.hpp"
 #include "../model/Skeletons.hpp"
 #include "../net/Packet.hpp"
 #include "../ui/HUD.hpp"
@@ -58,6 +59,7 @@ public:
 
 private:
        MasterState &master;
+       ShapeRegistry shapes;
        BlockTypeRegistry block_types;
        WorldSave save;
        World world;
index 7e8c04ebd9c325dea92b557d64e8b85a0859870d..00966dc6ee1e97e2d28b6682f0211ef8343c13eb 100644 (file)
@@ -48,6 +48,7 @@ void InitialState::Render(Viewport &viewport) {
 // TODO: this clutter is a giant mess
 InteractiveState::InteractiveState(MasterState &master, uint32_t player_id)
 : master(master)
+, shapes()
 , block_types()
 , save(master.GetEnv().config.GetWorldPath(master.GetWorldConf().name, master.GetConfig().net.host))
 , world(block_types, master.GetWorldConf())
@@ -65,6 +66,7 @@ InteractiveState::InteractiveState(MasterState &master, uint32_t player_id)
                save.Write(master.GetWorldConf());
        }
        TextureIndex tex_index;
+       master.GetEnv().loader.LoadShapes("default", shapes);
        master.GetEnv().loader.LoadBlockTypes("default", block_types, tex_index);
        interface.SetInventorySlots(block_types.size() - 1);
        chunk_renderer.LoadTextures(master.GetEnv().loader, tex_index);
diff --git a/src/model/Shape.cpp b/src/model/Shape.cpp
deleted file mode 100644 (file)
index 7be434d..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-#include "Shape.hpp"
-
-#include "bounds.hpp"
-#include "../io/TokenStreamReader.hpp"
-
-#include <string>
-
-using namespace std;
-
-
-namespace blank {
-
-Shape::Shape()
-: bounds()
-, vertices()
-, indices() {
-
-}
-
-
-void Shape::Read(TokenStreamReader &in) {
-       bounds.reset();
-       vertices.clear();
-       indices.clear();
-
-       string name;
-       while (in.HasMore()) {
-               in.ReadIdentifier(name);
-               in.Skip(Token::EQUALS);
-               if (name == "bounds") {
-                       string bounds_class;
-                       in.ReadIdentifier(bounds_class);
-                       in.Skip(Token::BRACKET_OPEN);
-                       if (bounds_class == "Cuboid") {
-                               glm::vec3 min;
-                               glm::vec3 max;
-                               in.ReadVec(min);
-                               in.Skip(Token::COMMA);
-                               in.ReadVec(max);
-                               bounds.reset(new CuboidBounds(AABB{min, max}));
-                       } else if (bounds_class == "Stair") {
-                               glm::vec3 min;
-                               glm::vec3 max;
-                               glm::vec2 split;
-                               in.ReadVec(min);
-                               in.Skip(Token::COMMA);
-                               in.ReadVec(max);
-                               in.Skip(Token::COMMA);
-                               in.ReadVec(split);
-                               bounds.reset(new StairBounds(AABB{min, max}, split));
-                       } else {
-                               while (in.Peek().type != Token::BRACKET_CLOSE) {
-                                       in.Next();
-                               }
-                       }
-                       in.Skip(Token::BRACKET_CLOSE);
-
-               } else if (name == "vertices") {
-                       in.Skip(Token::ANGLE_BRACKET_OPEN);
-                       while (in.HasMore() && in.Peek().type != Token::ANGLE_BRACKET_CLOSE) {
-                               in.Skip(Token::ANGLE_BRACKET_OPEN);
-                               Vertex vtx;
-                               in.ReadVec(vtx.position);
-                               in.Skip(Token::COMMA);
-                               in.ReadVec(vtx.normal);
-                               in.Skip(Token::COMMA);
-                               in.ReadVec(vtx.tex_st);
-                               in.Skip(Token::COMMA);
-                               in.ReadNumber(vtx.tex_id);
-                               if (in.Peek().type == Token::COMMA) {
-                                       in.Skip(Token::COMMA);
-                               }
-                               in.Skip(Token::ANGLE_BRACKET_CLOSE);
-                               if (in.Peek().type == Token::COMMA) {
-                                       in.Skip(Token::COMMA);
-                               }
-                       }
-
-               } else if (name == "indices") {
-                       in.Skip(Token::ANGLE_BRACKET_OPEN);
-                       while (in.HasMore() && in.Peek().type != Token::ANGLE_BRACKET_CLOSE) {
-                               indices.push_back(in.GetULong());
-                               if (in.Peek().type == Token::COMMA) {
-                                       in.Skip(Token::COMMA);
-                               }
-                       }
-
-               } else {
-                       // try to skip, might fail though
-                       while (in.Peek().type != Token::SEMICOLON) {
-                               in.Next();
-                       }
-               }
-               in.Skip(Token::SEMICOLON);
-       }
-}
-
-float Shape::TexR(const vector<float> &tex_map, size_t off) noexcept {
-       if (off < tex_map.size()) {
-               return tex_map[off];
-       } else if (!tex_map.empty()) {
-               return tex_map.back();
-       } else {
-               return 0.0f;
-       }
-}
-
-void Shape::Fill(
-       EntityMesh::Buffer &buf,
-       const vector<float> &tex_map
-) const {
-       for (const auto &vtx : vertices) {
-               buf.vertices.emplace_back(vtx.position);
-               buf.normals.emplace_back(vtx.normal);
-               buf.tex_coords.emplace_back(vtx.tex_st.s, vtx.tex_st.t, TexR(tex_map, vtx.tex_id));
-       }
-       for (auto idx : indices) {
-               buf.indices.emplace_back(idx);
-       }
-}
-
-void Shape::Fill(
-       EntityMesh::Buffer &buf,
-       const glm::mat4 &transform,
-       const vector<float> &tex_map
-) const {
-       for (const auto &vtx : vertices) {
-               buf.vertices.emplace_back(transform * glm::vec4(vtx.position, 1.0f));
-               buf.normals.emplace_back(transform * glm::vec4(vtx.normal, 0.0f));
-               buf.tex_coords.emplace_back(vtx.tex_st.s, vtx.tex_st.t, TexR(tex_map, vtx.tex_id));
-       }
-       for (auto idx : indices) {
-               buf.indices.emplace_back(idx);
-       }
-}
-
-void Shape::Fill(
-       BlockMesh::Buffer &buf,
-       const glm::mat4 &transform,
-       const vector<float> &tex_map,
-       size_t idx_offset
-) const {
-       for (const auto &vtx : vertices) {
-               buf.vertices.emplace_back(transform * glm::vec4(vtx.position, 1.0f));
-               buf.tex_coords.emplace_back(vtx.tex_st.s, vtx.tex_st.t, TexR(tex_map, vtx.tex_id));
-       }
-       for (auto idx : indices) {
-               buf.indices.emplace_back(idx_offset + idx);
-       }
-}
-
-}
index 21602707b593132e6f9871beedcc98b0d6d83fab..ac4dc8095f159e85e5eb3b7020e32895edaa903d 100644 (file)
@@ -45,7 +45,7 @@ private:
        struct Vertex {
                glm::vec3 position;
                glm::vec3 normal;
-               glm::vec3 tex_st;
+               glm::vec2 tex_st;
                std::size_t tex_id;
        };
        std::vector<Vertex> vertices;
diff --git a/src/model/ShapeRegistry.hpp b/src/model/ShapeRegistry.hpp
new file mode 100644 (file)
index 0000000..53db569
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef BLANK_MODEL_SHAPEREGISTRY_HPP_
+#define BLANK_MODEL_SHAPEREGISTRY_HPP_
+
+#include "Shape.hpp"
+
+#include <map>
+#include <string>
+
+
+namespace blank {
+
+class ShapeRegistry {
+
+public:
+       ShapeRegistry();
+
+       Shape &Add(const std::string &);
+
+       Shape &Get(const std::string &);
+       const Shape &Get(const std::string &) const;
+
+private:
+       std::map<std::string, Shape> shapes;
+
+};
+
+}
+
+#endif
diff --git a/src/model/shape.cpp b/src/model/shape.cpp
new file mode 100644 (file)
index 0000000..e88c0e1
--- /dev/null
@@ -0,0 +1,189 @@
+#include "Shape.hpp"
+#include "ShapeRegistry.hpp"
+
+#include "bounds.hpp"
+#include "../io/TokenStreamReader.hpp"
+
+#include <string>
+
+using namespace std;
+
+
+namespace blank {
+
+Shape::Shape()
+: bounds()
+, vertices()
+, indices() {
+
+}
+
+void Shape::Read(TokenStreamReader &in) {
+       bounds.reset();
+       vertices.clear();
+       indices.clear();
+
+       string name;
+       in.Skip(Token::ANGLE_BRACKET_OPEN);
+       while (in.HasMore() && in.Peek().type != Token::ANGLE_BRACKET_CLOSE) {
+               in.ReadIdentifier(name);
+               in.Skip(Token::EQUALS);
+               if (name == "bounds") {
+                       string bounds_class;
+                       in.ReadIdentifier(bounds_class);
+                       in.Skip(Token::PARENTHESIS_OPEN);
+                       if (bounds_class == "Cuboid") {
+                               glm::vec3 min;
+                               glm::vec3 max;
+                               in.ReadVec(min);
+                               in.Skip(Token::COMMA);
+                               in.ReadVec(max);
+                               bounds.reset(new CuboidBounds(AABB{min, max}));
+                       } else if (bounds_class == "Stair") {
+                               glm::vec3 min;
+                               glm::vec3 max;
+                               glm::vec2 split;
+                               in.ReadVec(min);
+                               in.Skip(Token::COMMA);
+                               in.ReadVec(max);
+                               in.Skip(Token::COMMA);
+                               in.ReadVec(split);
+                               bounds.reset(new StairBounds(AABB{min, max}, split));
+                       } else {
+                               while (in.Peek().type != Token::PARENTHESIS_CLOSE) {
+                                       in.Next();
+                               }
+                       }
+                       in.Skip(Token::PARENTHESIS_CLOSE);
+
+               } else if (name == "vertices") {
+                       in.Skip(Token::ANGLE_BRACKET_OPEN);
+                       while (in.HasMore() && in.Peek().type != Token::ANGLE_BRACKET_CLOSE) {
+                               in.Skip(Token::ANGLE_BRACKET_OPEN);
+                               Vertex vtx;
+                               in.ReadVec(vtx.position);
+                               in.Skip(Token::COMMA);
+                               in.ReadVec(vtx.normal);
+                               in.Skip(Token::COMMA);
+                               in.ReadVec(vtx.tex_st);
+                               in.Skip(Token::COMMA);
+                               in.ReadNumber(vtx.tex_id);
+                               if (in.Peek().type == Token::COMMA) {
+                                       in.Skip(Token::COMMA);
+                               }
+                               in.Skip(Token::ANGLE_BRACKET_CLOSE);
+                               if (in.Peek().type == Token::COMMA) {
+                                       in.Skip(Token::COMMA);
+                               }
+                       }
+                       in.Skip(Token::ANGLE_BRACKET_CLOSE);
+
+               } else if (name == "indices") {
+                       in.Skip(Token::ANGLE_BRACKET_OPEN);
+                       while (in.HasMore() && in.Peek().type != Token::ANGLE_BRACKET_CLOSE) {
+                               indices.push_back(in.GetULong());
+                               if (in.Peek().type == Token::COMMA) {
+                                       in.Skip(Token::COMMA);
+                               }
+                       }
+                       in.Skip(Token::ANGLE_BRACKET_CLOSE);
+
+               } else {
+                       // try to skip, might fail though
+                       while (in.Peek().type != Token::SEMICOLON) {
+                               in.Next();
+                       }
+               }
+               in.Skip(Token::SEMICOLON);
+       }
+       in.Skip(Token::ANGLE_BRACKET_CLOSE);
+}
+
+float Shape::TexR(const vector<float> &tex_map, size_t off) noexcept {
+       if (off < tex_map.size()) {
+               return tex_map[off];
+       } else if (!tex_map.empty()) {
+               return tex_map.back();
+       } else {
+               return 0.0f;
+       }
+}
+
+void Shape::Fill(
+       EntityMesh::Buffer &buf,
+       const vector<float> &tex_map
+) const {
+       for (const auto &vtx : vertices) {
+               buf.vertices.emplace_back(vtx.position);
+               buf.normals.emplace_back(vtx.normal);
+               buf.tex_coords.emplace_back(vtx.tex_st.s, vtx.tex_st.t, TexR(tex_map, vtx.tex_id));
+       }
+       for (auto idx : indices) {
+               buf.indices.emplace_back(idx);
+       }
+}
+
+void Shape::Fill(
+       EntityMesh::Buffer &buf,
+       const glm::mat4 &transform,
+       const vector<float> &tex_map
+) const {
+       for (const auto &vtx : vertices) {
+               buf.vertices.emplace_back(transform * glm::vec4(vtx.position, 1.0f));
+               buf.normals.emplace_back(transform * glm::vec4(vtx.normal, 0.0f));
+               buf.tex_coords.emplace_back(vtx.tex_st.s, vtx.tex_st.t, TexR(tex_map, vtx.tex_id));
+       }
+       for (auto idx : indices) {
+               buf.indices.emplace_back(idx);
+       }
+}
+
+void Shape::Fill(
+       BlockMesh::Buffer &buf,
+       const glm::mat4 &transform,
+       const vector<float> &tex_map,
+       size_t idx_offset
+) const {
+       for (const auto &vtx : vertices) {
+               buf.vertices.emplace_back(transform * glm::vec4(vtx.position, 1.0f));
+               buf.tex_coords.emplace_back(vtx.tex_st.s, vtx.tex_st.t, TexR(tex_map, vtx.tex_id));
+       }
+       for (auto idx : indices) {
+               buf.indices.emplace_back(idx_offset + idx);
+       }
+}
+
+
+ShapeRegistry::ShapeRegistry()
+: shapes() {
+
+}
+
+Shape &ShapeRegistry::Add(const string &name) {
+       auto result = shapes.emplace(name, Shape());
+       if (result.second) {
+               return result.first->second;
+       } else {
+               throw runtime_error("duplicate shape " + name);
+       }
+}
+
+Shape &ShapeRegistry::Get(const string &name) {
+       auto entry = shapes.find(name);
+       if (entry != shapes.end()) {
+               return entry->second;
+       } else {
+               throw runtime_error("unknown shape " + name);
+       }
+}
+
+const Shape &ShapeRegistry::Get(const string &name) const {
+       auto entry = shapes.find(name);
+       if (entry != shapes.end()) {
+               return entry->second;
+       } else {
+               throw runtime_error("unknown shape " + name);
+       }
+}
+
+}
index fc0da820e4513aeef509a032454c03497e571faa..23740be1b963e612253fe1e05e4942ffeb32421d 100644 (file)
@@ -19,6 +19,7 @@ ServerState::ServerState(
        const Config &config
 )
 : env(env)
+, shapes()
 , block_types()
 , world(block_types, wc)
 , generator(gc)
@@ -28,6 +29,7 @@ ServerState::ServerState(
 , server(config.net, world, wc, ws)
 , loop_timer(16) {
        TextureIndex tex_index;
+       env.loader.LoadShapes("default", shapes);
        env.loader.LoadBlockTypes("default", block_types, tex_index);
        generator.LoadTypes(block_types);
        skeletons.LoadHeadless();
index 3a4851470edb8a1cecf555e52048a4a971fcd45d..bfefccf397f0ae0be42a5ac6213bbd01b2d33eb1 100644 (file)
@@ -5,6 +5,7 @@
 #include "../ai/Spawner.hpp"
 #include "../app/IntervalTimer.hpp"
 #include "../app/State.hpp"
+#include "../model/ShapeRegistry.hpp"
 #include "../model/Skeletons.hpp"
 #include "../world/BlockTypeRegistry.hpp"
 #include "../world/ChunkLoader.hpp"
@@ -39,6 +40,7 @@ public:
 
 private:
        HeadlessEnvironment &env;
+       ShapeRegistry shapes;
        BlockTypeRegistry block_types;
        World world;
        Generator generator;
index 68e49a966fc607e07e84f6d65c17d2e62eb84da6..c66c8fadae20191472b14d17beffdd6b33c18d42 100644 (file)
@@ -21,6 +21,7 @@ MasterState::MasterState(
 )
 : config(config)
 , env(env)
+, shapes()
 , block_types()
 , save(save)
 , world(block_types, wc)
@@ -40,6 +41,7 @@ MasterState::MasterState(
 , preload(env, chunk_loader, chunk_renderer)
 , unload(env, world.Chunks(), save) {
        TextureIndex tex_index;
+       env.loader.LoadShapes("default", shapes);
        env.loader.LoadBlockTypes("default", block_types, tex_index);
        interface.SetInventorySlots(block_types.size() - 1);
        generator.LoadTypes(block_types);
index 9e0b8e4c68e119fade7c03636bff1b71f79e30fb..680bb5e620cbaa15a9a3f6414f02ecf0c767263c 100644 (file)
@@ -8,6 +8,7 @@
 #include "UnloadState.hpp"
 #include "../ai/Spawner.hpp"
 #include "../graphics/SkyBox.hpp"
+#include "../model/ShapeRegistry.hpp"
 #include "../model/Skeletons.hpp"
 #include "../ui/DirectInput.hpp"
 #include "../ui/HUD.hpp"
@@ -62,6 +63,7 @@ public:
 private:
        Config &config;
        Environment &env;
+       ShapeRegistry shapes;
        BlockTypeRegistry block_types;
        const WorldSave &save;
        World world;
index 4208d94665d29ed56436b8662a406427f787b0b8..429bdaaa447dd25aeb39ba79f61aa1f5ddbc2840 100644 (file)
@@ -8,6 +8,7 @@
 #include "../model/bounds.hpp"
 
 #include <glm/glm.hpp>
+#include <vector>
 
 
 namespace blank {
@@ -17,7 +18,7 @@ namespace blank {
 struct BlockType {
 
        const CollisionBounds *shape;
-       float texture;
+       std::vector<float> textures;
        glm::vec3 hsl_mod;
        glm::vec3 rgb_mod;
        glm::vec3 outline_color;
index 727fcade04984bfcb8140dae48c4948a3580f2ce..1a5d88d750eadcdc090584e48f3651a161022eda 100644 (file)
@@ -71,7 +71,7 @@ std::ostream &operator <<(std::ostream &out, const Block::Turn &turn) {
 
 BlockType::BlockType() noexcept
 : shape(&DEFAULT_SHAPE)
-, texture(0)
+, textures()
 , hsl_mod(0.0f, 1.0f, 1.0f)
 , rgb_mod(1.0f, 1.0f, 1.0f)
 , outline_color(-1, -1, -1)
@@ -105,7 +105,11 @@ void BlockType::FillEntityMesh(
        const glm::mat4 &transform,
        EntityMesh::Index idx_offset
 ) const noexcept {
-       shape->Vertices(buf, transform, texture, idx_offset);
+       if (textures.empty()) {
+               shape->Vertices(buf, transform, 0.0f, idx_offset);
+       } else {
+               shape->Vertices(buf, transform, textures[0], idx_offset);
+       }
        buf.hsl_mods.insert(buf.hsl_mods.end(), shape->VertexCount(), hsl_mod);
        buf.rgb_mods.insert(buf.rgb_mods.end(), shape->VertexCount(), rgb_mod);
 }
@@ -115,7 +119,11 @@ void BlockType::FillBlockMesh(
        const glm::mat4 &transform,
        BlockMesh::Index idx_offset
 ) const noexcept {
-       shape->Vertices(buf, transform, texture, idx_offset);
+       if (textures.empty()) {
+               shape->Vertices(buf, transform, 0.0f, idx_offset);
+       } else {
+               shape->Vertices(buf, transform, textures[0], idx_offset);
+       }
        buf.hsl_mods.insert(buf.hsl_mods.end(), shape->VertexCount(), hsl_mod);
        buf.rgb_mods.insert(buf.rgb_mods.end(), shape->VertexCount(), rgb_mod);
 }