From 57f4a76edbfd6c2b6077047e9fba31788d161b44 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Wed, 19 Aug 2015 11:56:29 +0200 Subject: [PATCH] some outline improvements --- assets | 2 +- src/app/app.cpp | 2 ++ src/model/Shape.hpp | 9 ++------- src/model/shape.cpp | 14 +++----------- src/world/BlockType.hpp | 6 +----- src/world/block.cpp | 8 ++------ 6 files changed, 11 insertions(+), 30 deletions(-) diff --git a/assets b/assets index 424ac96..7f1ebb8 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 424ac96eaafa7e1eb49fabcc9f670a5aa3f54ca3 +Subproject commit 7f1ebb8448f866ac28ea14b0dd8792edebedcf5a diff --git a/src/app/app.cpp b/src/app/app.cpp index a6acade..610f995 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -269,6 +269,8 @@ void Assets::LoadBlockTypes(const std::string &set_name, BlockTypeRegistry ®, type.texture = tex_index.GetID(tex_name); } else if (name == "color") { in.ReadVec(type.color); + } else if (name == "outline") { + in.ReadVec(type.outline_color); } else if (name == "label") { in.ReadString(type.label); } else if (name == "luminosity") { diff --git a/src/model/Shape.hpp b/src/model/Shape.hpp index 51b950f..28a36ab 100644 --- a/src/model/Shape.hpp +++ b/src/model/Shape.hpp @@ -51,13 +51,8 @@ struct Shape { /// the number of vertex indices this shape's outline has size_t OutlineIndexCount() const { return out_idx.size(); } - /// fill given buffers with this shape's outline's elements with - /// an optional offset - void Outline( - OutlineModel::Buffer &out, - const OutlineModel::Position &offset = { 0.0f, 0.0f, 0.0f }, - OutlineModel::Index idx_offset = 0 - ) const; + /// fill given buffers with this shape's outline's elements + void Outline(OutlineModel::Buffer &out) const; /// Check if given ray would pass though this shape if it were /// transformed with given matrix. diff --git a/src/model/shape.cpp b/src/model/shape.cpp index c2d8261..4ee5b8f 100644 --- a/src/model/shape.cpp +++ b/src/model/shape.cpp @@ -59,17 +59,9 @@ void Shape::Vertices( } } -void Shape::Outline( - OutlineModel::Buffer &out, - const OutlineModel::Position &elem_offset, - OutlineModel::Index idx_offset -) const { - for (const auto &pos : out_pos) { - out.vertices.emplace_back(elem_offset + pos); - } - for (auto idx : out_idx) { - out.indices.emplace_back(idx_offset + idx); - } +void Shape::Outline(OutlineModel::Buffer &out) const { + out.vertices.insert(out.vertices.end(), out_pos.begin(), out_pos.end()); + out.indices.insert(out.indices.end(), out_idx.begin(), out_idx.end()); } void Shape::SetShape( diff --git a/src/world/BlockType.hpp b/src/world/BlockType.hpp index 95a9605..bdc4721 100644 --- a/src/world/BlockType.hpp +++ b/src/world/BlockType.hpp @@ -74,11 +74,7 @@ struct BlockType { const glm::mat4 &transform = glm::mat4(1.0f), BlockModel::Index idx_offset = 0 ) const noexcept; - void FillOutlineModel( - OutlineModel::Buffer &m, - const glm::vec3 &pos_offset = { 0, 0, 0 }, - OutlineModel::Index idx_offset = 0 - ) const noexcept; + void FillOutlineModel(OutlineModel::Buffer &m) const noexcept; }; diff --git a/src/world/block.cpp b/src/world/block.cpp index 54ceba0..09acfef 100644 --- a/src/world/block.cpp +++ b/src/world/block.cpp @@ -103,12 +103,8 @@ void BlockType::FillBlockModel( buf.colors.insert(buf.colors.end(), shape->VertexCount(), color); } -void BlockType::FillOutlineModel( - OutlineModel::Buffer &buf, - const glm::vec3 &pos_offset, - OutlineModel::Index idx_offset -) const noexcept { - shape->Outline(buf, pos_offset, idx_offset); +void BlockType::FillOutlineModel(OutlineModel::Buffer &buf) const noexcept { + shape->Outline(buf); buf.colors.insert(buf.colors.end(), shape->OutlineCount(), outline_color); } -- 2.39.2