]> git.localhorst.tv Git - blank.git/commitdiff
modify stair model so cut is along x axis
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Thu, 12 Mar 2015 20:36:55 +0000 (21:36 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Thu, 12 Mar 2015 21:21:30 +0000 (22:21 +0100)
src/block.hpp
src/chunk.cpp
src/shape.cpp
src/world.cpp

index 3777e6d77b6169d345ca73592d4f7b54182c765c..23c3979feba4ecd36d9867512901b81229a10fef 100644 (file)
@@ -57,10 +57,10 @@ struct BlockType {
        bool visible;
 
        struct Faces {
        bool visible;
 
        struct Faces {
+               bool up;
+               bool down;
                bool right;
                bool left;
                bool right;
                bool left;
-               bool top;
-               bool bottom;
                bool front;
                bool back;
        } fill;
                bool front;
                bool back;
        } fill;
index fbee721c601b4fb0451f17ef72ef43f1b6f3599f..4cabcecf040e17784ac86b2e0d5c869949d63c34 100644 (file)
@@ -160,11 +160,11 @@ bool Chunk::Obstructed(int idx) const {
        const BlockType &left = Type(blocks[idx - 1]);
        if (!left.fill.right) return false;
 
        const BlockType &left = Type(blocks[idx - 1]);
        if (!left.fill.right) return false;
 
-       const BlockType &top = Type(blocks[idx + Width()]);
-       if (!top.fill.bottom) return false;
+       const BlockType &up = Type(blocks[idx + Width()]);
+       if (!up.fill.down) return false;
 
 
-       const BlockType &bottom = Type(blocks[idx - Width()]);
-       if (!bottom.fill.top) return false;
+       const BlockType &down = Type(blocks[idx - Width()]);
+       if (!down.fill.up) return false;
 
        const BlockType &front = Type(blocks[idx + Width() * Height()]);
        if (!front.fill.back) return false;
 
        const BlockType &front = Type(blocks[idx + Width() * Height()]);
        if (!front.fill.back) return false;
index 3d6f4420833efba99231876f13e8adbfaf78bf9f..8111258be6f83d5b2f7d24baeca0a96c99757e3d 100644 (file)
@@ -155,7 +155,7 @@ bool CuboidShape::Intersects(
 
 StairShape::StairShape(const AABB &bb, const glm::vec2 &clip)
 : Shape()
 
 StairShape::StairShape(const AABB &bb, const glm::vec2 &clip)
 : Shape()
-, top({ { clip.x, clip.y, bb.min.z }, bb.max })
+, 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({
                { top.min.x, top.min.y, top.max.z }, // front, upper
 , bot({ bb.min, { bb.max.x, clip.y, bb.max.z } }) {
        SetShape({
                { top.min.x, top.min.y, top.max.z }, // front, upper
@@ -166,22 +166,18 @@ StairShape::StairShape(const AABB &bb, const glm::vec2 &clip)
                { bot.max.x, bot.min.y, bot.max.z },
                { bot.min.x, bot.max.y, bot.max.z },
                { bot.max.x, bot.max.y, bot.max.z },
                { bot.max.x, bot.min.y, bot.max.z },
                { bot.min.x, bot.max.y, bot.max.z },
                { bot.max.x, bot.max.y, bot.max.z },
-               { top.min.x, top.min.y, top.min.z }, // back, upper
-               { top.min.x, top.max.y, top.min.z },
-               { top.max.x, top.min.y, top.min.z },
-               { top.max.x, top.max.y, top.min.z },
-               { bot.min.x, bot.min.y, bot.min.z }, // back, lower
-               { bot.min.x, bot.max.y, bot.min.z },
-               { bot.max.x, bot.min.y, bot.min.z },
-               { bot.max.x, bot.max.y, bot.min.z },
+               { bot.min.x, bot.min.y, bot.min.z }, // back
+               { bot.min.x, top.max.y, bot.min.z },
+               { top.max.x, bot.min.y, bot.min.z },
+               { top.max.x, top.max.y, bot.min.z },
                { top.min.x, top.max.y, top.min.z }, // top, upper
                { top.min.x, top.max.y, top.max.z },
                { top.max.x, top.max.y, top.min.z },
                { top.max.x, top.max.y, top.max.z },
                { top.min.x, top.max.y, top.min.z }, // top, upper
                { top.min.x, top.max.y, top.max.z },
                { top.max.x, top.max.y, top.min.z },
                { top.max.x, top.max.y, top.max.z },
-               { bot.min.x, bot.max.y, bot.min.z }, // top, lower
+               { bot.min.x, bot.max.y, top.max.z }, // top, lower
                { bot.min.x, bot.max.y, bot.max.z },
                { bot.min.x, bot.max.y, bot.max.z },
-               { top.min.x, bot.max.y, bot.min.z },
-               { top.min.x, bot.max.y, bot.max.z },
+               { bot.max.x, bot.max.y, top.max.z },
+               { bot.max.x, bot.max.y, bot.max.z },
                { bot.min.x, bot.min.y, bot.min.z }, // bottom
                { bot.max.x, bot.min.y, bot.min.z },
                { bot.min.x, bot.min.y, bot.max.z },
                { bot.min.x, bot.min.y, bot.min.z }, // bottom
                { bot.max.x, bot.min.y, bot.min.z },
                { bot.min.x, bot.min.y, bot.max.z },
@@ -194,12 +190,16 @@ StairShape::StairShape(const AABB &bb, const glm::vec2 &clip)
                { bot.min.x, bot.min.y, bot.max.z },
                { bot.min.x, bot.max.y, bot.min.z },
                { bot.min.x, bot.max.y, bot.max.z },
                { bot.min.x, bot.min.y, bot.max.z },
                { bot.min.x, bot.max.y, bot.min.z },
                { bot.min.x, bot.max.y, bot.max.z },
-               { bot.max.x, bot.min.y, bot.min.z }, // right
-               { bot.max.x, top.max.y, bot.min.z },
+               { top.max.x, top.min.y, top.min.z }, // right, upper
+               { top.max.x, top.max.y, top.min.z },
+               { top.max.x, top.min.y, top.max.z },
+               { top.max.x, top.max.y, top.max.z },
+               { bot.max.x, bot.min.y, bot.min.z }, // right, lower
+               { bot.max.x, bot.max.y, bot.min.z },
                { bot.max.x, bot.min.y, bot.max.z },
                { bot.max.x, bot.min.y, bot.max.z },
-               { bot.max.x, top.max.y, bot.max.z },
+               { bot.max.x, bot.max.y, bot.max.z },
        }, {
        }, {
-               {  0.0f,  0.0f,  1.0f }, // front, x2
+               {  0.0f,  0.0f,  1.0f }, // front x2
                {  0.0f,  0.0f,  1.0f },
                {  0.0f,  0.0f,  1.0f },
                {  0.0f,  0.0f,  1.0f },
                {  0.0f,  0.0f,  1.0f },
                {  0.0f,  0.0f,  1.0f },
                {  0.0f,  0.0f,  1.0f },
@@ -207,15 +207,11 @@ StairShape::StairShape(const AABB &bb, const glm::vec2 &clip)
                {  0.0f,  0.0f,  1.0f },
                {  0.0f,  0.0f,  1.0f },
                {  0.0f,  0.0f,  1.0f },
                {  0.0f,  0.0f,  1.0f },
                {  0.0f,  0.0f,  1.0f },
                {  0.0f,  0.0f,  1.0f },
-               {  0.0f,  0.0f, -1.0f }, // back, x2
-               {  0.0f,  0.0f, -1.0f },
-               {  0.0f,  0.0f, -1.0f },
-               {  0.0f,  0.0f, -1.0f },
-               {  0.0f,  0.0f, -1.0f },
+               {  0.0f,  0.0f, -1.0f }, // back
                {  0.0f,  0.0f, -1.0f },
                {  0.0f,  0.0f, -1.0f },
                {  0.0f,  0.0f, -1.0f },
                {  0.0f,  0.0f, -1.0f },
                {  0.0f,  0.0f, -1.0f },
                {  0.0f,  0.0f, -1.0f },
-               {  0.0f,  1.0f,  0.0f }, // top, x2
+               {  0.0f,  1.0f,  0.0f }, // top x2
                {  0.0f,  1.0f,  0.0f },
                {  0.0f,  1.0f,  0.0f },
                {  0.0f,  1.0f,  0.0f },
                {  0.0f,  1.0f,  0.0f },
                {  0.0f,  1.0f,  0.0f },
                {  0.0f,  1.0f,  0.0f },
@@ -227,7 +223,7 @@ StairShape::StairShape(const AABB &bb, const glm::vec2 &clip)
                {  0.0f, -1.0f,  0.0f },
                {  0.0f, -1.0f,  0.0f },
                {  0.0f, -1.0f,  0.0f },
                {  0.0f, -1.0f,  0.0f },
                {  0.0f, -1.0f,  0.0f },
                {  0.0f, -1.0f,  0.0f },
-               { -1.0f,  0.0f,  0.0f }, // left, x2
+               { -1.0f,  0.0f,  0.0f }, // left x2
                { -1.0f,  0.0f,  0.0f },
                { -1.0f,  0.0f,  0.0f },
                { -1.0f,  0.0f,  0.0f },
                { -1.0f,  0.0f,  0.0f },
                { -1.0f,  0.0f,  0.0f },
                { -1.0f,  0.0f,  0.0f },
@@ -235,31 +231,35 @@ StairShape::StairShape(const AABB &bb, const glm::vec2 &clip)
                { -1.0f,  0.0f,  0.0f },
                { -1.0f,  0.0f,  0.0f },
                { -1.0f,  0.0f,  0.0f },
                { -1.0f,  0.0f,  0.0f },
                { -1.0f,  0.0f,  0.0f },
                { -1.0f,  0.0f,  0.0f },
-               {  1.0f,  0.0f,  0.0f }, // right
+               {  1.0f,  0.0f,  0.0f }, // right x2
+               {  1.0f,  0.0f,  0.0f },
+               {  1.0f,  0.0f,  0.0f },
+               {  1.0f,  0.0f,  0.0f },
+               {  1.0f,  0.0f,  0.0f },
                {  1.0f,  0.0f,  0.0f },
                {  1.0f,  0.0f,  0.0f },
                {  1.0f,  0.0f,  0.0f },
        }, {
                 0,  1,  2,  2,  1,  3, // front, upper
                 4,  5,  6,  6,  5,  7, // front, lower
                {  1.0f,  0.0f,  0.0f },
                {  1.0f,  0.0f,  0.0f },
                {  1.0f,  0.0f,  0.0f },
        }, {
                 0,  1,  2,  2,  1,  3, // front, upper
                 4,  5,  6,  6,  5,  7, // front, lower
-                8,  9, 10, 10,  9, 11, // back, upper
-               12, 13, 14, 14, 13, 15, // back, lower
-               16, 17, 18, 18, 17, 19, // top, upper
-               20, 21, 22, 22, 21, 23, // top, lower
-               24, 25, 26, 26, 25, 27, // bottom
-               28, 29, 30, 30, 29, 31, // left, upper
-               32, 33, 34, 34, 33, 35, // left, lower
-               36, 37, 38, 38, 37, 39, // right
+                8,  9, 10, 10,  9, 11, // back
+               12, 13, 14, 14, 13, 15, // top, upper
+               16, 17, 18, 18, 17, 19, // top, lower
+               20, 21, 22, 22, 21, 23, // bottom
+               24, 25, 26, 26, 25, 27, // left, upper
+               28, 29, 30, 30, 29, 31, // left, lower
+               32, 33, 34, 34, 33, 35, // right, upper
+               36, 37, 38, 38, 37, 39, // right, lower
        });
        SetOutline({
                { bot.min.x, bot.min.y, bot.min.z }, // bottom
                { bot.max.x, bot.min.y, bot.min.z },
                { bot.min.x, bot.min.y, bot.max.z },
                { bot.max.x, bot.min.y, bot.max.z },
        });
        SetOutline({
                { bot.min.x, bot.min.y, bot.min.z }, // bottom
                { bot.max.x, bot.min.y, bot.min.z },
                { bot.min.x, bot.min.y, bot.max.z },
                { bot.max.x, bot.min.y, bot.max.z },
-               { bot.min.x, bot.max.y, bot.min.z }, // middle
-               { top.min.x, bot.max.y, bot.min.z },
-               { bot.min.x, bot.max.y, top.max.z },
-               { top.min.x, bot.max.y, top.max.z },
+               { bot.min.x, bot.max.y, top.max.z }, // middle
+               { bot.max.x, bot.max.y, top.max.z },
+               { bot.min.x, bot.max.y, bot.max.z },
+               { bot.max.x, bot.max.y, bot.max.z },
                { top.min.x, top.max.y, top.min.z }, // top
                { top.max.x, top.max.y, top.min.z },
                { top.min.x, top.max.y, top.max.z },
                { top.min.x, top.max.y, top.min.z }, // top
                { top.max.x, top.max.y, top.min.z },
                { top.min.x, top.max.y, top.max.z },
@@ -268,9 +268,10 @@ StairShape::StairShape(const AABB &bb, const glm::vec2 &clip)
                 0,  1,  1,  3,  3,  2,  2,  0, // bottom
                 4,  5,  5,  7,  7,  6,  6,  4, // middle
                 8,  9,  9, 11, 11, 10, 10 , 8, // top
                 0,  1,  1,  3,  3,  2,  2,  0, // bottom
                 4,  5,  5,  7,  7,  6,  6,  4, // middle
                 8,  9,  9, 11, 11, 10, 10 , 8, // top
-                0,  4,  2,  6, // verticals
-                5,  8,  7, 10,
-                1,  9,  3, 11,
+                0,  8,  4, 10,  2,  6, // verticals, btf
+                1,  9,  5, 11,  3,  7,
+       //       5,  8,  7, 10,
+       //       1,  9,  3, 11,
        });
 }
 
        });
 }
 
index 46abf711facdfc85ea497bd8ee8f555f44dc767e..5244d152bbe1326e190d2819120c1e54d7b3729f 100644 (file)
@@ -15,8 +15,8 @@ World::World()
 , chunks(blockType, generate)
 , player() {
        BlockType::Faces block_fill = {  true,  true,  true,  true,  true,  true };
 , chunks(blockType, generate)
 , player() {
        BlockType::Faces block_fill = {  true,  true,  true,  true,  true,  true };
-       BlockType::Faces slab_fill  = { false, false, false,  true, false, false };
-       BlockType::Faces stair_fill = {  true, false, false,  true, false, false };
+       BlockType::Faces slab_fill  = { false,  true, false, false, false, false };
+       BlockType::Faces stair_fill = { false,  true, false, false, false,  true };
 
        { // white block
                BlockType type(true, { 1.0f, 1.0f, 1.0f }, &blockShape);
 
        { // white block
                BlockType type(true, { 1.0f, 1.0f, 1.0f }, &blockShape);