X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fworld%2Fblock.cpp;h=aa8fc7772732f765ef684fdbed7e4d1b261936a7;hb=957b1df87d9a692c517a269221da81227100240e;hp=e06f3e0bc63d84c29b86b7defcce8d0f3a34af27;hpb=549646ac3e5bede5e77031f773649edf8de83608;p=blank.git diff --git a/src/world/block.cpp b/src/world/block.cpp index e06f3e0..aa8fc77 100644 --- a/src/world/block.cpp +++ b/src/world/block.cpp @@ -14,10 +14,6 @@ namespace blank { const NullShape BlockType::DEFAULT_SHAPE; -bool operator ==(const Block &a, const Block &b) { - return a.type == b.type && a.orient == b.orient; -} - std::ostream &operator <<(std::ostream &out, const Block &block) { return out << "Block(" << block.type << ", " << block.GetFace() << ", " << block.GetTurn() << ')'; } @@ -73,17 +69,33 @@ std::ostream &operator <<(std::ostream &out, const Block::Turn &turn) { } -BlockType::BlockType(bool v, const glm::vec3 &col, const Shape *s) noexcept -: shape(s) -, color(col) +BlockType::BlockType() noexcept +: shape(&DEFAULT_SHAPE) +, texture(0) +, hsl_mod(0.0f, 1.0f, 1.0f) +, rgb_mod(1.0f, 1.0f, 1.0f) , outline_color(-1, -1, -1) , label("some block") , id(0) , luminosity(0) -, visible(v) -, block_light(false) -, collision(false) -, collide_block(false) +, visible(true) +, block_light(true) +, collision(true) +, collide_block(true) +, generate(false) +, min_solidity(0.5f) +, mid_solidity(0.75f) +, max_solidity(1.0f) +, min_humidity(-1.0f) +, mid_humidity(0.0f) +, max_humidity(1.0f) +, min_temperature(-1.0f) +, mid_temperature(0.0f) +, max_temperature(1.0f) +, min_richness(-1.0f) +, mid_richness(0.0f) +, max_richness(1.0f) +, commonness(1.0f) , fill({ false, false, false, false, false, false }) { } @@ -93,8 +105,9 @@ void BlockType::FillEntityModel( const glm::mat4 &transform, EntityModel::Index idx_offset ) const noexcept { - shape->Vertices(buf.vertices, buf.normals, buf.indices, transform, idx_offset); - buf.colors.insert(buf.colors.end(), shape->VertexCount(), color); + shape->Vertices(buf, transform, texture, 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); } void BlockType::FillBlockModel( @@ -102,22 +115,24 @@ void BlockType::FillBlockModel( const glm::mat4 &transform, BlockModel::Index idx_offset ) const noexcept { - shape->Vertices(buf.vertices, buf.indices, transform, idx_offset); - buf.colors.insert(buf.colors.end(), shape->VertexCount(), color); + shape->Vertices(buf, transform, texture, 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); } -void BlockType::FillOutlineModel( - OutlineModel::Buffer &buf, - const glm::vec3 &pos_offset, - OutlineModel::Index idx_offset -) const noexcept { - shape->Outline(buf.vertices, buf.indices, 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); } BlockTypeRegistry::BlockTypeRegistry() { - Add(BlockType()); + BlockType air; + air.visible = false; + air.block_light = false; + air.collision = false; + air.collide_block = false; + Add(air); } Block::Type BlockTypeRegistry::Add(const BlockType &t) {