many little fixes
This commit is contained in:
parent
815aa90489
commit
b1e5a3c6fb
@ -417,43 +417,43 @@ inline void _renderXBlock(std::vector<float>& buffer, int x, int y, int z, const
|
||||
|
||||
{SETUP_UV(block->textureFaces[1]);
|
||||
|
||||
VERTEX(index, x-0.5f+xs, y-0.5f, z-0.5f+zs, u2,v1, lr0,lg0,lb0,ls0);
|
||||
VERTEX(index, x-0.5f+xs, y+0.5f, z-0.5f+zs, u2,v2, lr1,lg1,lb1,ls1);
|
||||
VERTEX(index, x+0.5f+xs, y+0.5f, z+0.5f+zs, u1,v2, lr2,lg2,lb2,ls2);
|
||||
VERTEX(index, x-0.3535f+xs, y-0.5f, z-0.3535f+zs, u2,v1, lr0,lg0,lb0,ls0);
|
||||
VERTEX(index, x-0.3535f+xs, y+0.5f, z-0.3535f+zs, u2,v2, lr1,lg1,lb1,ls1);
|
||||
VERTEX(index, x+0.3535f+xs, y+0.5f, z+0.3535f+zs, u1,v2, lr2,lg2,lb2,ls2);
|
||||
|
||||
VERTEX(index, x-0.5f+xs, y-0.5f, z-0.5f+zs, u2,v1, lr0,lg0,lb0,ls0);
|
||||
VERTEX(index, x+0.5f+xs, y+0.5f, z+0.5f+zs, u1,v2, lr2,lg2,lb2,ls2);
|
||||
VERTEX(index, x+0.5f+xs, y-0.5f, z+0.5f+zs, u1,v1, lr3,lg3,lb3,ls3);}
|
||||
VERTEX(index, x-0.3535f+xs, y-0.5f, z-0.3535f+zs, u2,v1, lr0,lg0,lb0,ls0);
|
||||
VERTEX(index, x+0.3535f+xs, y+0.5f, z+0.3535f+zs, u1,v2, lr2,lg2,lb2,ls2);
|
||||
VERTEX(index, x+0.3535f+xs, y-0.5f, z+0.3535f+zs, u1,v1, lr3,lg3,lb3,ls3);}
|
||||
|
||||
{SETUP_UV(block->textureFaces[0]);
|
||||
|
||||
VERTEX(index, x-0.5f+xs, y-0.5f, z-0.5f+zs, u1,v1, lr0,lg0,lb0,ls0);
|
||||
VERTEX(index, x+0.5f+xs, y+0.5f, z+0.5f+zs, u2,v2, lr1,lg1,lb1,ls1);
|
||||
VERTEX(index, x-0.5f+xs, y+0.5f, z-0.5f+zs, u1,v2, lr2,lg2,lb2,ls2);
|
||||
VERTEX(index, x-0.3535f+xs, y-0.5f, z-0.3535f+zs, u1,v1, lr0,lg0,lb0,ls0);
|
||||
VERTEX(index, x+0.3535f+xs, y+0.5f, z+0.3535f+zs, u2,v2, lr1,lg1,lb1,ls1);
|
||||
VERTEX(index, x-0.3535f+xs, y+0.5f, z-0.3535f+zs, u1,v2, lr2,lg2,lb2,ls2);
|
||||
|
||||
VERTEX(index, x-0.5f+xs, y-0.5f, z-0.5f+zs, u1,v1, lr0,lg0,lb0,ls0);
|
||||
VERTEX(index, x+0.5f+xs, y-0.5f, z+0.5f+zs, u2,v1, lr3,lg3,lb3,ls3);
|
||||
VERTEX(index, x+0.5f+xs, y+0.5f, z+0.5f+zs, u2,v2, lr1,lg1,lb1,ls1);}
|
||||
VERTEX(index, x-0.3535f+xs, y-0.5f, z-0.3535f+zs, u1,v1, lr0,lg0,lb0,ls0);
|
||||
VERTEX(index, x+0.3535f+xs, y-0.5f, z+0.3535f+zs, u2,v1, lr3,lg3,lb3,ls3);
|
||||
VERTEX(index, x+0.3535f+xs, y+0.5f, z+0.3535f+zs, u2,v2, lr1,lg1,lb1,ls1);}
|
||||
|
||||
{SETUP_UV(block->textureFaces[5]);
|
||||
|
||||
VERTEX(index, x-0.5f+xs, y-0.5f, z+0.5f+zs, u1,v1, lr4,lg4,lb4,ls4);
|
||||
VERTEX(index, x+0.5f+xs, y+0.5f, z-0.5f+zs, u2,v2, lr5,lg5,lb5,ls5);
|
||||
VERTEX(index, x-0.5f+xs, y+0.5f, z+0.5f+zs, u1,v2, lr6,lg6,lb6,ls6);
|
||||
VERTEX(index, x-0.3535f+xs, y-0.5f, z+0.3535f+zs, u1,v1, lr4,lg4,lb4,ls4);
|
||||
VERTEX(index, x+0.3535f+xs, y+0.5f, z-0.3535f+zs, u2,v2, lr5,lg5,lb5,ls5);
|
||||
VERTEX(index, x-0.3535f+xs, y+0.5f, z+0.3535f+zs, u1,v2, lr6,lg6,lb6,ls6);
|
||||
|
||||
VERTEX(index, x-0.5f+xs, y-0.5f, z+0.5f+zs, u1,v1, lr4,lg4,lb4,ls4);
|
||||
VERTEX(index, x+0.5f+xs, y-0.5f, z-0.5f+zs, u2,v1, lr7,lg7,lb7,ls7);
|
||||
VERTEX(index, x+0.5f+xs, y+0.5f, z-0.5f+zs, u2,v2, lr5,lg5,lb5,ls5);}
|
||||
VERTEX(index, x-0.3535f+xs, y-0.5f, z+0.3535f+zs, u1,v1, lr4,lg4,lb4,ls4);
|
||||
VERTEX(index, x+0.3535f+xs, y-0.5f, z-0.3535f+zs, u2,v1, lr7,lg7,lb7,ls7);
|
||||
VERTEX(index, x+0.3535f+xs, y+0.5f, z-0.3535f+zs, u2,v2, lr5,lg5,lb5,ls5);}
|
||||
|
||||
{SETUP_UV(block->textureFaces[4]);
|
||||
|
||||
VERTEX(index, x-0.5f+xs, y-0.5f, z+0.5f+zs, u2,v1, lr4,lg4,lb4,ls4);
|
||||
VERTEX(index, x-0.5f+xs, y+0.5f, z+0.5f+zs, u2,v2, lr5,lg5,lb5,ls5);
|
||||
VERTEX(index, x+0.5f+xs, y+0.5f, z-0.5f+zs, u1,v2, lr6,lg6,lb6,ls6);
|
||||
VERTEX(index, x-0.3535f+xs, y-0.5f, z+0.3535f+zs, u2,v1, lr4,lg4,lb4,ls4);
|
||||
VERTEX(index, x-0.3535f+xs, y+0.5f, z+0.3535f+zs, u2,v2, lr5,lg5,lb5,ls5);
|
||||
VERTEX(index, x+0.3535f+xs, y+0.5f, z-0.3535f+zs, u1,v2, lr6,lg6,lb6,ls6);
|
||||
|
||||
VERTEX(index, x-0.5f+xs, y-0.5f, z+0.5f+zs, u2,v1, lr4,lg4,lb4,ls4);
|
||||
VERTEX(index, x+0.5f+xs, y+0.5f, z-0.5f+zs, u1,v2, lr6,lg6,lb6,ls6);
|
||||
VERTEX(index, x+0.5f+xs, y-0.5f, z-0.5f+zs, u1,v1, lr7,lg7,lb7,ls7);}
|
||||
VERTEX(index, x-0.3535f+xs, y-0.5f, z+0.3535f+zs, u2,v1, lr4,lg4,lb4,ls4);
|
||||
VERTEX(index, x+0.3535f+xs, y+0.5f, z-0.3535f+zs, u1,v2, lr6,lg6,lb6,ls6);
|
||||
VERTEX(index, x+0.3535f+xs, y-0.5f, z-0.3535f+zs, u1,v1, lr7,lg7,lb7,ls7);}
|
||||
}
|
||||
|
||||
const float* VoxelRenderer::render(Chunk* chunk, const Chunk** chunks, size_t& size){
|
||||
@ -509,7 +509,7 @@ const float* VoxelRenderer::render(Chunk* chunk, const Chunk** chunks, size_t& s
|
||||
voxel vox = chunk->voxels[(y * CHUNK_D + z) * CHUNK_W + x];
|
||||
if (vox.id == 0)
|
||||
continue;
|
||||
if (Block::blocks[vox.id]->model != BLOCK_MODEL_GRASS)
|
||||
if (Block::blocks[vox.id]->model != BLOCK_MODEL_X_SPRITE)
|
||||
continue;
|
||||
_renderXBlock(buffer, x, y, z, chunks, vox, index);
|
||||
}
|
||||
|
||||
@ -95,36 +95,42 @@ void HudRenderer::draw(Level* level, Assets* assets){
|
||||
Block* cblock = Block::blocks[player->choosenBlock];
|
||||
if (cblock->model == BLOCK_MODEL_CUBE){
|
||||
batch->blockSprite(24, uicamera->fov - 72, 48, 48, 16, cblock->textureFaces, vec4(1.0f));
|
||||
} else if (cblock->model == BLOCK_MODEL_GRASS){
|
||||
} else if (cblock->model == BLOCK_MODEL_X_SPRITE){
|
||||
batch->sprite(24, uicamera->fov - 72, 48, 48, 16, cblock->textureFaces[3], vec4(1.0f));
|
||||
}
|
||||
}
|
||||
|
||||
if (!Events::_cursor_locked) {
|
||||
int size = 48;
|
||||
int step = 70;
|
||||
int y = uicamera->fov - 72 - 70;
|
||||
int x = 0;
|
||||
vec4 tint = vec4(1.0f);
|
||||
int mx = Events::x;
|
||||
int my = Events::y;
|
||||
|
||||
for (unsigned i = 1; i < 256; i++) {
|
||||
Block* cblock = Block::blocks[i];
|
||||
if (cblock == nullptr)
|
||||
break;
|
||||
int size = 48;
|
||||
int step = 70;
|
||||
int x = 24 + (i-1) * step;
|
||||
int y = uicamera->fov - 72 - 70;
|
||||
x = 24 + (i-1) * step;
|
||||
y -= 72 * (x / (Window::width - step));
|
||||
x %= (Window::width - step);
|
||||
vec4 tint(1.0f);
|
||||
int mx = Events::x;
|
||||
int my = Events::y;
|
||||
if (mx > x && mx < x + size && my > y && my < y + size) {
|
||||
tint.r *= 2.0f;
|
||||
tint.g *= 2.0f;
|
||||
tint.b *= 2.0f;
|
||||
tint.r *= 1.3f;
|
||||
tint.g *= 1.3f;
|
||||
tint.b *= 1.3f;
|
||||
if (Events::jclicked(GLFW_MOUSE_BUTTON_LEFT)) {
|
||||
player->choosenBlock = i;
|
||||
}
|
||||
} else
|
||||
{
|
||||
tint = vec4(1.0f);
|
||||
}
|
||||
|
||||
if (cblock->model == BLOCK_MODEL_CUBE){
|
||||
batch->blockSprite(x, y, size, size, 16, cblock->textureFaces, tint);
|
||||
} else if (cblock->model == BLOCK_MODEL_GRASS){
|
||||
} else if (cblock->model == BLOCK_MODEL_X_SPRITE){
|
||||
batch->sprite(x, y, size, size, 16, cblock->textureFaces[3], tint);
|
||||
}
|
||||
}
|
||||
|
||||
@ -189,7 +189,7 @@ void PlayerController::update_interaction(){
|
||||
int x = (int)(iend.x)+(int)(norm.x);
|
||||
int y = (int)(iend.y)+(int)(norm.y);
|
||||
int z = (int)(iend.z)+(int)(norm.z);
|
||||
if (block->model == BLOCK_MODEL_GRASS){
|
||||
if (block->model == BLOCK_MODEL_X_SPRITE){
|
||||
x = (int)iend.x;
|
||||
y = (int)iend.y;
|
||||
z = (int)iend.z;
|
||||
|
||||
@ -120,7 +120,7 @@ void mainloop(Level* level, Assets* assets) {
|
||||
float delta = 0.0f;
|
||||
bool occlusion = true;
|
||||
bool devdata = false;
|
||||
Window::swapInterval(0);
|
||||
Window::swapInterval(1);
|
||||
while (!Window::isShouldClose()){
|
||||
frame++;
|
||||
float currentTime = glfwGetTime();
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
#define VOXELS_BLOCK_H_
|
||||
|
||||
#define BLOCK_MODEL_CUBE 1
|
||||
#define BLOCK_MODEL_GRASS 2
|
||||
#define BLOCK_MODEL_X_SPRITE 2
|
||||
|
||||
class Block {
|
||||
public:
|
||||
|
||||
@ -142,10 +142,10 @@ void WorldGenerator::generate(voxel* voxels, int cx, int cz, int seed){
|
||||
}
|
||||
if (real_y <= 2)
|
||||
id = BLOCK_BEDROCK;
|
||||
if ((id == 0) && (real_y > 55) && ((int)height + 1 == real_y) && ((unsigned short)random() > 56000)){
|
||||
if ((id == 0) && (real_y > 55) && ((int)(height + 0.5f) == real_y) && ((unsigned short)random() > 56000)){
|
||||
id = BLOCK_GRASS;
|
||||
}
|
||||
if ((id == 0) && (real_y > 55) && ((int)height + 1 == real_y) && ((unsigned short)random() > 64000)){
|
||||
if ((id == 0) && (real_y > 55) && ((int)(height + 0.5f) == real_y) && ((unsigned short)random() > 64000)){
|
||||
id = BLOCK_FLOWER;
|
||||
}
|
||||
voxels[(y * CHUNK_D + z) * CHUNK_W + x].id = id;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user