]> git.localhorst.tv Git - blank.git/blobdiff - src/block.cpp
don't add obstructed blocks to meshes
[blank.git] / src / block.cpp
index 02e8476c4a2af7cf9ec407fd76040acf8c057dba..236a61ff62bcb0b2d122f78fc33691f35db2d3d1 100644 (file)
@@ -3,34 +3,42 @@
 
 namespace blank {
 
-const BlockType BlockType::DEFAULT;
 const NullShape BlockType::DEFAULT_SHAPE;
 
-void BlockType::FillVBO(
-       const glm::vec3 &pos,
-       std::vector<glm::vec3> &vertices,
-       std::vector<glm::vec3> &colors,
-       std::vector<glm::vec3> &normals
+BlockType::BlockType(bool v, const glm::vec3 &col, const Shape *s)
+: shape(s)
+, color(col)
+, outline_color(-1, -1, -1)
+, id(0)
+, visible(v)
+, fill({ false, false, false, false, false, false }) {
+
+}
+
+void BlockType::FillModel(
+       Model::Buffer &buf,
+       const glm::vec3 &pos_offset,
+       Model::Index idx_offset
 ) const {
-       shape->Vertices(vertices, pos);
-       colors.insert(colors.end(), shape->VertexCount(), color);
-       shape->Normals(normals);
+       shape->Vertices(buf.vertices, buf.normals, buf.indices, pos_offset, idx_offset);
+       buf.colors.insert(buf.colors.end(), shape->VertexCount(), color);
 }
 
-void BlockType::FillOutlineVBO(
-       std::vector<glm::vec3> &vertices,
-       std::vector<glm::vec3> &colors
+void BlockType::FillOutlineModel(
+       OutlineModel &model,
+       const glm::vec3 &pos_offset,
+       OutlineModel::Index idx_offset
 ) const {
-       shape->Outline(vertices);
-       colors.insert(colors.end(), shape->OutlineCount(), outline_color);
+       shape->Outline(model.vertices, model.indices, pos_offset, idx_offset);
+       model.colors.insert(model.colors.end(), shape->OutlineCount(), outline_color);
 }
 
 
 BlockTypeRegistry::BlockTypeRegistry() {
-       Add(BlockType::DEFAULT);
+       Add(BlockType());
 }
 
-int BlockTypeRegistry::Add(const BlockType &t) {
+Block::Type BlockTypeRegistry::Add(const BlockType &t) {
        int id = types.size();
        types.push_back(t);
        types.back().id = id;