replace remaining tabs in src/ to spaces
This commit is contained in:
@@ -54,9 +54,9 @@ void TextureAnimator::update(float delta) {
|
|||||||
|
|
||||||
glBlitFramebuffer(
|
glBlitFramebuffer(
|
||||||
frame.srcPos.x, srcPosY,
|
frame.srcPos.x, srcPosY,
|
||||||
frame.srcPos.x + frame.size.x,
|
frame.srcPos.x + frame.size.x,
|
||||||
srcPosY + frame.size.y,
|
srcPosY + frame.size.y,
|
||||||
frame.dstPos.x, frame.dstPos.y,
|
frame.dstPos.x, frame.dstPos.y,
|
||||||
frame.dstPos.x + frame.size.x,
|
frame.dstPos.x + frame.size.x,
|
||||||
frame.dstPos.y + frame.size.y,
|
frame.dstPos.y + frame.size.y,
|
||||||
GL_COLOR_BUFFER_BIT, GL_NEAREST
|
GL_COLOR_BUFFER_BIT, GL_NEAREST
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "LightSolver.hpp"
|
#include "LightSolver.hpp"
|
||||||
#include "Lightmap.hpp"
|
#include "Lightmap.hpp"
|
||||||
#include "content/Content.hpp"
|
#include "content/Content.hpp"
|
||||||
@@ -9,106 +10,106 @@
|
|||||||
#include "voxels/Block.hpp"
|
#include "voxels/Block.hpp"
|
||||||
|
|
||||||
LightSolver::LightSolver(const ContentIndices* contentIds, Chunks* chunks, int channel)
|
LightSolver::LightSolver(const ContentIndices* contentIds, Chunks* chunks, int channel)
|
||||||
: contentIds(contentIds),
|
: contentIds(contentIds),
|
||||||
chunks(chunks),
|
chunks(chunks),
|
||||||
channel(channel) {
|
channel(channel) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightSolver::add(int x, int y, int z, int emission) {
|
void LightSolver::add(int x, int y, int z, int emission) {
|
||||||
if (emission <= 1)
|
if (emission <= 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
addqueue.push(lightentry {x, y, z, ubyte(emission)});
|
addqueue.push(lightentry {x, y, z, ubyte(emission)});
|
||||||
|
|
||||||
Chunk* chunk = chunks->getChunkByVoxel(x, y, z);
|
Chunk* chunk = chunks->getChunkByVoxel(x, y, z);
|
||||||
chunk->flags.modified = true;
|
chunk->flags.modified = true;
|
||||||
chunk->lightmap.set(x-chunk->x*CHUNK_W, y, z-chunk->z*CHUNK_D, channel, emission);
|
chunk->lightmap.set(x-chunk->x*CHUNK_W, y, z-chunk->z*CHUNK_D, channel, emission);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightSolver::add(int x, int y, int z) {
|
void LightSolver::add(int x, int y, int z) {
|
||||||
assert (chunks != nullptr);
|
assert (chunks != nullptr);
|
||||||
add(x,y,z, chunks->getLight(x,y,z, channel));
|
add(x,y,z, chunks->getLight(x,y,z, channel));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightSolver::remove(int x, int y, int z) {
|
void LightSolver::remove(int x, int y, int z) {
|
||||||
Chunk* chunk = chunks->getChunkByVoxel(x, y, z);
|
Chunk* chunk = chunks->getChunkByVoxel(x, y, z);
|
||||||
if (chunk == nullptr)
|
if (chunk == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ubyte light = chunk->lightmap.get(x-chunk->x*CHUNK_W, y, z-chunk->z*CHUNK_D, channel);
|
ubyte light = chunk->lightmap.get(x-chunk->x*CHUNK_W, y, z-chunk->z*CHUNK_D, channel);
|
||||||
if (light == 0){
|
if (light == 0){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
remqueue.push(lightentry {x, y, z, light});
|
remqueue.push(lightentry {x, y, z, light});
|
||||||
chunk->lightmap.set(x-chunk->x*CHUNK_W, y, z-chunk->z*CHUNK_D, channel, 0);
|
chunk->lightmap.set(x-chunk->x*CHUNK_W, y, z-chunk->z*CHUNK_D, channel, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightSolver::solve(){
|
void LightSolver::solve(){
|
||||||
const int coords[] = {
|
const int coords[] = {
|
||||||
0, 0, 1,
|
0, 0, 1,
|
||||||
0, 0,-1,
|
0, 0,-1,
|
||||||
0, 1, 0,
|
0, 1, 0,
|
||||||
0,-1, 0,
|
0,-1, 0,
|
||||||
1, 0, 0,
|
1, 0, 0,
|
||||||
-1, 0, 0
|
-1, 0, 0
|
||||||
};
|
};
|
||||||
|
|
||||||
while (!remqueue.empty()){
|
while (!remqueue.empty()){
|
||||||
const lightentry entry = remqueue.front();
|
const lightentry entry = remqueue.front();
|
||||||
remqueue.pop();
|
remqueue.pop();
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
int imul3 = i*3;
|
int imul3 = i*3;
|
||||||
int x = entry.x+coords[imul3];
|
int x = entry.x+coords[imul3];
|
||||||
int y = entry.y+coords[imul3+1];
|
int y = entry.y+coords[imul3+1];
|
||||||
int z = entry.z+coords[imul3+2];
|
int z = entry.z+coords[imul3+2];
|
||||||
|
|
||||||
Chunk* chunk = chunks->getChunkByVoxel(x,y,z);
|
Chunk* chunk = chunks->getChunkByVoxel(x,y,z);
|
||||||
if (chunk) {
|
if (chunk) {
|
||||||
int lx = x - chunk->x * CHUNK_W;
|
int lx = x - chunk->x * CHUNK_W;
|
||||||
int lz = z - chunk->z * CHUNK_D;
|
int lz = z - chunk->z * CHUNK_D;
|
||||||
chunk->flags.modified = true;
|
chunk->flags.modified = true;
|
||||||
|
|
||||||
ubyte light = chunk->lightmap.get(lx,y,lz, channel);
|
ubyte light = chunk->lightmap.get(lx,y,lz, channel);
|
||||||
if (light != 0 && light == entry.light-1){
|
if (light != 0 && light == entry.light-1){
|
||||||
remqueue.push(lightentry {x, y, z, light});
|
remqueue.push(lightentry {x, y, z, light});
|
||||||
chunk->lightmap.set(lx, y, lz, channel, 0);
|
chunk->lightmap.set(lx, y, lz, channel, 0);
|
||||||
}
|
}
|
||||||
else if (light >= entry.light){
|
else if (light >= entry.light){
|
||||||
addqueue.push(lightentry {x, y, z, light});
|
addqueue.push(lightentry {x, y, z, light});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const Block* const* blockDefs = contentIds->blocks.getDefs();
|
const Block* const* blockDefs = contentIds->blocks.getDefs();
|
||||||
while (!addqueue.empty()){
|
while (!addqueue.empty()){
|
||||||
const lightentry entry = addqueue.front();
|
const lightentry entry = addqueue.front();
|
||||||
addqueue.pop();
|
addqueue.pop();
|
||||||
|
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
int imul3 = i*3;
|
int imul3 = i*3;
|
||||||
int x = entry.x+coords[imul3];
|
int x = entry.x+coords[imul3];
|
||||||
int y = entry.y+coords[imul3+1];
|
int y = entry.y+coords[imul3+1];
|
||||||
int z = entry.z+coords[imul3+2];
|
int z = entry.z+coords[imul3+2];
|
||||||
|
|
||||||
Chunk* chunk = chunks->getChunkByVoxel(x,y,z);
|
Chunk* chunk = chunks->getChunkByVoxel(x,y,z);
|
||||||
if (chunk) {
|
if (chunk) {
|
||||||
int lx = x - chunk->x * CHUNK_W;
|
int lx = x - chunk->x * CHUNK_W;
|
||||||
int lz = z - chunk->z * CHUNK_D;
|
int lz = z - chunk->z * CHUNK_D;
|
||||||
chunk->flags.modified = true;
|
chunk->flags.modified = true;
|
||||||
|
|
||||||
ubyte light = chunk->lightmap.get(lx, y, lz, channel);
|
ubyte light = chunk->lightmap.get(lx, y, lz, channel);
|
||||||
voxel& v = chunk->voxels[vox_index(lx, y, lz)];
|
voxel& v = chunk->voxels[vox_index(lx, y, lz)];
|
||||||
const Block* block = blockDefs[v.id];
|
const Block* block = blockDefs[v.id];
|
||||||
if (block->lightPassing && light+2 <= entry.light){
|
if (block->lightPassing && light+2 <= entry.light){
|
||||||
chunk->lightmap.set(
|
chunk->lightmap.set(
|
||||||
x-chunk->x*CHUNK_W, y, z-chunk->z*CHUNK_D,
|
x-chunk->x*CHUNK_W, y, z-chunk->z*CHUNK_D,
|
||||||
channel,
|
channel,
|
||||||
entry.light-1);
|
entry.light-1);
|
||||||
addqueue.push(lightentry {x, y, z, ubyte(entry.light-1)});
|
addqueue.push(lightentry {x, y, z, ubyte(entry.light-1)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ void PhysicsSolver::colisionCalc(
|
|||||||
vel.y = 0.0f;
|
vel.y = 0.0f;
|
||||||
float newy = std::floor(y) + aabb->max().y + half.y;
|
float newy = std::floor(y) + aabb->max().y + half.y;
|
||||||
if (std::abs(newy-pos.y) <= MAX_FIX+stepHeight) {
|
if (std::abs(newy-pos.y) <= MAX_FIX+stepHeight) {
|
||||||
pos.y = newy;
|
pos.y = newy;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user