From b61d462707dd3d40a32a6104d88eb24f6a52df63 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Mon, 12 Oct 2015 16:18:01 +0200 Subject: [PATCH] renamed Shape -> CollisionBounds et al --- src/app/app.cpp | 8 ++-- src/model/{Shape.hpp => CollisionBounds.hpp} | 6 +-- src/model/{shape.cpp => bounds.cpp} | 42 ++++++++++---------- src/model/{shapes.hpp => bounds.hpp} | 24 +++++------ src/model/model.cpp | 10 ++--- src/ui/ui.cpp | 2 +- src/world/BlockType.hpp | 6 +-- src/world/block.cpp | 2 +- src/world/chunk.cpp | 2 +- 9 files changed, 51 insertions(+), 51 deletions(-) rename src/model/{Shape.hpp => CollisionBounds.hpp} (96%) rename src/model/{shape.cpp => bounds.cpp} (94%) rename src/model/{shapes.hpp => bounds.hpp} (71%) diff --git a/src/app/app.cpp b/src/app/app.cpp index 1e82cab..4f2a6ec 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -13,7 +13,7 @@ #include "../graphics/Font.hpp" #include "../graphics/Texture.hpp" #include "../io/TokenStreamReader.hpp" -#include "../model/shapes.hpp" +#include "../model/bounds.hpp" #include "../world/BlockType.hpp" #include "../world/BlockTypeRegistry.hpp" #include "../world/Entity.hpp" @@ -305,9 +305,9 @@ Assets::Assets(const AssetLoader &loader) namespace { -CuboidShape block_shape({{ -0.5f, -0.5f, -0.5f }, { 0.5f, 0.5f, 0.5f }}); -StairShape stair_shape({{ -0.5f, -0.5f, -0.5f }, { 0.5f, 0.5f, 0.5f }}, { 0.0f, 0.0f }); -CuboidShape slab_shape({{ -0.5f, -0.5f, -0.5f }, { 0.5f, 0.0f, 0.5f }}); +CuboidBounds block_shape({{ -0.5f, -0.5f, -0.5f }, { 0.5f, 0.5f, 0.5f }}); +StairBounds stair_shape({{ -0.5f, -0.5f, -0.5f }, { 0.5f, 0.5f, 0.5f }}, { 0.0f, 0.0f }); +CuboidBounds slab_shape({{ -0.5f, -0.5f, -0.5f }, { 0.5f, 0.0f, 0.5f }}); } diff --git a/src/model/Shape.hpp b/src/model/CollisionBounds.hpp similarity index 96% rename from src/model/Shape.hpp rename to src/model/CollisionBounds.hpp index d2e0695..15c4fe1 100644 --- a/src/model/Shape.hpp +++ b/src/model/CollisionBounds.hpp @@ -1,5 +1,5 @@ -#ifndef BLANK_MODEL_SHAPE_HPP_ -#define BLANK_MODEL_SHAPE_HPP_ +#ifndef BLANK_MODEL_COLLISIONBOUNDS_HPP_ +#define BLANK_MODEL_COLLISIONBOUNDS_HPP_ #include "../graphics/BlockMesh.hpp" #include "../graphics/EntityMesh.hpp" @@ -13,7 +13,7 @@ namespace blank { class AABB; class Ray; -struct Shape { +struct CollisionBounds { /// the number of vertices (and normals) this shape has size_t VertexCount() const noexcept { return vtx_pos.size(); } diff --git a/src/model/shape.cpp b/src/model/bounds.cpp similarity index 94% rename from src/model/shape.cpp rename to src/model/bounds.cpp index d69046e..c1c04e1 100644 --- a/src/model/shape.cpp +++ b/src/model/bounds.cpp @@ -1,10 +1,10 @@ -#include "Shape.hpp" -#include "shapes.hpp" +#include "bounds.hpp" +#include "CollisionBounds.hpp" namespace blank { -void Shape::Vertices( +void CollisionBounds::Vertices( EntityMesh::Buffer &out, float tex_offset ) const { @@ -22,7 +22,7 @@ void Shape::Vertices( } } -void Shape::Vertices( +void CollisionBounds::Vertices( EntityMesh::Buffer &out, const glm::mat4 &transform, float tex_offset, @@ -42,7 +42,7 @@ void Shape::Vertices( } } -void Shape::Vertices( +void CollisionBounds::Vertices( BlockMesh::Buffer &out, const glm::mat4 &transform, float tex_offset, @@ -59,12 +59,12 @@ void Shape::Vertices( } } -void Shape::Outline(OutlineMesh::Buffer &out) const { +void CollisionBounds::Outline(OutlineMesh::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( +void CollisionBounds::SetShape( const EntityMesh::Positions &pos, const EntityMesh::Normals &nrm, const EntityMesh::Indices &idx @@ -74,13 +74,13 @@ void Shape::SetShape( vtx_idx = idx; } -void Shape::SetTexture( +void CollisionBounds::SetTexture( const BlockMesh::TexCoords &tex_coords ) { vtx_tex_coords = tex_coords; } -void Shape::SetOutline( +void CollisionBounds::SetOutline( const OutlineMesh::Positions &pos, const OutlineMesh::Indices &idx ) { @@ -89,12 +89,12 @@ void Shape::SetOutline( } -NullShape::NullShape() -: Shape() { +NullBounds::NullBounds() +: CollisionBounds() { } -bool NullShape::Intersects( +bool NullBounds::Intersects( const Ray &, const glm::mat4 &, float &, glm::vec3 & @@ -102,7 +102,7 @@ bool NullShape::Intersects( return false; } -bool NullShape::Intersects( +bool NullBounds::Intersects( const glm::mat4 &, const AABB &, const glm::mat4 &, @@ -113,8 +113,8 @@ bool NullShape::Intersects( } -CuboidShape::CuboidShape(const AABB &b) -: Shape() +CuboidBounds::CuboidBounds(const AABB &b) +: CollisionBounds() , bb(b) { bb.Adjust(); SetShape({ @@ -217,7 +217,7 @@ CuboidShape::CuboidShape(const AABB &b) }); } -bool CuboidShape::Intersects( +bool CuboidBounds::Intersects( const Ray &ray, const glm::mat4 &M, float &dist, glm::vec3 &normal @@ -225,7 +225,7 @@ bool CuboidShape::Intersects( return Intersection(ray, bb, M, &dist, &normal); } -bool CuboidShape::Intersects( +bool CuboidBounds::Intersects( const glm::mat4 &M, const AABB &box, const glm::mat4 &box_M, @@ -236,8 +236,8 @@ bool CuboidShape::Intersects( } -StairShape::StairShape(const AABB &bb, const glm::vec2 &clip) -: Shape() +StairBounds::StairBounds(const AABB &bb, const glm::vec2 &clip) +: CollisionBounds() , top({ { bb.min.x, clip.y, bb.min.z }, { bb.max.x, bb.max.y, clip.x } }) , bot({ bb.min, { bb.max.x, clip.y, bb.max.z } }) { SetShape({ @@ -398,7 +398,7 @@ StairShape::StairShape(const AABB &bb, const glm::vec2 &clip) }); } -bool StairShape::Intersects( +bool StairBounds::Intersects( const Ray &ray, const glm::mat4 &M, float &dist, @@ -434,7 +434,7 @@ bool StairShape::Intersects( } } -bool StairShape::Intersects( +bool StairBounds::Intersects( const glm::mat4 &M, const AABB &box, const glm::mat4 &box_M, diff --git a/src/model/shapes.hpp b/src/model/bounds.hpp similarity index 71% rename from src/model/shapes.hpp rename to src/model/bounds.hpp index 4820530..05f8df1 100644 --- a/src/model/shapes.hpp +++ b/src/model/bounds.hpp @@ -1,8 +1,8 @@ -#ifndef BLANK_MODEL_SHAPES_HPP_ -#define BLANK_MODEL_SHAPES_HPP_ +#ifndef BLANK_MODEL_BOUNDS_HPP_ +#define BLANK_MODEL_BOUNDS_HPP_ +#include "CollisionBounds.hpp" #include "geometry.hpp" -#include "Shape.hpp" #include #include @@ -10,11 +10,11 @@ namespace blank { -class NullShape -: public Shape { +class NullBounds +: public CollisionBounds { public: - NullShape(); + NullBounds(); bool Intersects(const Ray &, const glm::mat4 &, float &, glm::vec3 &) const noexcept override; bool Intersects(const glm::mat4 &, const AABB &, const glm::mat4 &, float &, glm::vec3 &) const noexcept override; @@ -22,11 +22,11 @@ public: }; -class CuboidShape -: public Shape { +class CuboidBounds +: public CollisionBounds { public: - CuboidShape(const AABB &bounds); + CuboidBounds(const AABB &bounds); bool Intersects(const Ray &, const glm::mat4 &, float &, glm::vec3 &) const noexcept override; bool Intersects(const glm::mat4 &, const AABB &, const glm::mat4 &, float &, glm::vec3 &) const noexcept override; @@ -37,11 +37,11 @@ private: }; -class StairShape -: public Shape { +class StairBounds +: public CollisionBounds { public: - StairShape(const AABB &bounds, const glm::vec2 &clip); + StairBounds(const AABB &bounds, const glm::vec2 &clip); bool Intersects(const Ray &, const glm::mat4 &, float &, glm::vec3 &) const noexcept override; bool Intersects(const glm::mat4 &, const AABB &, const glm::mat4 &, float &, glm::vec3 &) const noexcept override; diff --git a/src/model/model.cpp b/src/model/model.cpp index 987d86c..22d2bed 100644 --- a/src/model/model.cpp +++ b/src/model/model.cpp @@ -2,7 +2,7 @@ #include "Instance.hpp" #include "Skeletons.hpp" -#include "shapes.hpp" +#include "bounds.hpp" #include "../graphics/DirectionalLighting.hpp" #include "../graphics/EntityMesh.hpp" @@ -149,7 +149,7 @@ void Skeletons::Load() { meshes.resize(4); EntityMesh::Buffer buf; { - CuboidShape shape(skeletons[0]->Bounds()); + CuboidBounds shape(skeletons[0]->Bounds()); shape.Vertices(buf, 3.0f); buf.hsl_mods.resize(shape.VertexCount(), { 0.0f, 1.0f, 1.0f }); buf.rgb_mods.resize(shape.VertexCount(), { 1.0f, 1.0f, 0.0f }); @@ -157,7 +157,7 @@ void Skeletons::Load() { skeletons[0]->SetNodeMesh(&meshes[0]); } { - CuboidShape shape(skeletons[1]->Bounds()); + CuboidBounds shape(skeletons[1]->Bounds()); buf.Clear(); shape.Vertices(buf, 0.0f); buf.hsl_mods.resize(shape.VertexCount(), { 0.0f, 1.0f, 1.0f }); @@ -166,7 +166,7 @@ void Skeletons::Load() { skeletons[1]->SetNodeMesh(&meshes[1]); } { - StairShape shape(skeletons[2]->Bounds(), { 0.4f, 0.4f }); + StairBounds shape(skeletons[2]->Bounds(), { 0.4f, 0.4f }); buf.Clear(); shape.Vertices(buf, 1.0f); buf.hsl_mods.resize(shape.VertexCount(), { 0.0f, 1.0f, 1.0f }); @@ -175,7 +175,7 @@ void Skeletons::Load() { skeletons[2]->SetNodeMesh(&meshes[2]); } { - CuboidShape shape(skeletons[3]->Bounds()); + CuboidBounds shape(skeletons[3]->Bounds()); buf.Clear(); shape.Vertices(buf, 2.0f); buf.hsl_mods.resize(shape.VertexCount(), { 0.0f, 1.0f, 1.0f }); diff --git a/src/ui/ui.cpp b/src/ui/ui.cpp index c249ed4..c7d8b24 100644 --- a/src/ui/ui.cpp +++ b/src/ui/ui.cpp @@ -15,7 +15,7 @@ #include "../graphics/Font.hpp" #include "../graphics/Viewport.hpp" #include "../io/TokenStreamReader.hpp" -#include "../model/shapes.hpp" +#include "../model/bounds.hpp" #include "../world/BlockLookup.hpp" #include "../world/World.hpp" #include "../world/WorldManipulator.hpp" diff --git a/src/world/BlockType.hpp b/src/world/BlockType.hpp index 5fab931..4208d94 100644 --- a/src/world/BlockType.hpp +++ b/src/world/BlockType.hpp @@ -5,7 +5,7 @@ #include "../graphics/BlockMesh.hpp" #include "../graphics/EntityMesh.hpp" #include "../graphics/OutlineMesh.hpp" -#include "../model/shapes.hpp" +#include "../model/bounds.hpp" #include @@ -16,7 +16,7 @@ namespace blank { /// attributes of a type of block struct BlockType { - const Shape *shape; + const CollisionBounds *shape; float texture; glm::vec3 hsl_mod; glm::vec3 rgb_mod; @@ -75,7 +75,7 @@ struct BlockType { BlockType() noexcept; - static const NullShape DEFAULT_SHAPE; + static const NullBounds DEFAULT_SHAPE; bool FaceFilled(const Block &block, Block::Face face) const noexcept { return fill[block.OrientedFace(face)]; diff --git a/src/world/block.cpp b/src/world/block.cpp index d2453cf..727fcad 100644 --- a/src/world/block.cpp +++ b/src/world/block.cpp @@ -11,7 +11,7 @@ namespace blank { -const NullShape BlockType::DEFAULT_SHAPE; +const NullBounds BlockType::DEFAULT_SHAPE; std::ostream &operator <<(std::ostream &out, const Block &block) { diff --git a/src/world/chunk.cpp b/src/world/chunk.cpp index 14c3af5..bd2d426 100644 --- a/src/world/chunk.cpp +++ b/src/world/chunk.cpp @@ -435,7 +435,7 @@ BlockMesh::Buffer buf; void Chunk::Update(BlockMesh &model) noexcept { int vtx_count = 0, idx_count = 0; for (const auto &block : blocks) { - const Shape *shape = Type(block).shape; + const CollisionBounds *shape = Type(block).shape; vtx_count += shape->VertexCount(); idx_count += shape->VertexIndexCount(); } -- 2.39.2