Minor refactor
This commit is contained in:
@@ -74,7 +74,7 @@ const AABB* Chunks::isObstacle(float x, float y, float z){
|
||||
const Block* def = contentIds->getBlockDef(v->id);
|
||||
if (def->obstacle) {
|
||||
const AABB& hitbox = def->rotatable
|
||||
? def->rt.hitboxes[v->states & BLOCK_ROT_MASK]
|
||||
? def->rt.hitboxes[v->rotation()]
|
||||
: def->hitbox;
|
||||
if (def->rt.solid) {
|
||||
return &hitbox;
|
||||
@@ -225,7 +225,9 @@ voxel* Chunks::rayCast(vec3 start,
|
||||
// TODO: replace this dumb solution with something better
|
||||
if (def && !def->rt.solid) {
|
||||
const int gridSize = BLOCK_AABB_GRID * 2;
|
||||
const AABB& box = def->rotatable ? def->rt.hitboxes[voxel->states & BLOCK_ROT_MASK] : def->hitbox;
|
||||
const AABB& box = def->rotatable
|
||||
? def->rt.hitboxes[voxel->rotation()]
|
||||
: def->hitbox;
|
||||
const int subs = gridSize;
|
||||
iend = vec3(ix, iy, iz);
|
||||
end -= iend;
|
||||
|
||||
@@ -43,15 +43,17 @@ void ChunksStorage::remove(int x, int z) {
|
||||
}
|
||||
|
||||
std::shared_ptr<Chunk> ChunksStorage::create(int x, int z) {
|
||||
World* world = level->world;
|
||||
|
||||
auto chunk = shared_ptr<Chunk>(new Chunk(x, z));
|
||||
store(chunk);
|
||||
unique_ptr<ubyte> data(level->world->wfile->getChunk(chunk->x, chunk->z));
|
||||
unique_ptr<ubyte> data(world->wfile->getChunk(chunk->x, chunk->z));
|
||||
if (data) {
|
||||
chunk->decode(data.get());
|
||||
chunk->setLoaded(true);
|
||||
}
|
||||
|
||||
light_t* lights = level->world->wfile->getLights(chunk->x, chunk->z);
|
||||
light_t* lights = world->wfile->getLights(chunk->x, chunk->z);
|
||||
if (lights) {
|
||||
chunk->lightmap->set(lights);
|
||||
chunk->setLoadedLights(true);
|
||||
|
||||
+2
-2
@@ -19,11 +19,11 @@ struct voxel {
|
||||
blockid_t id;
|
||||
uint8_t states;
|
||||
|
||||
inline uint8_t rotation() {
|
||||
inline uint8_t rotation() const {
|
||||
return states & BLOCK_ROT_MASK;
|
||||
}
|
||||
|
||||
inline int8_t variant() {
|
||||
inline int8_t variant() const {
|
||||
return (states & BLOCK_VARIANT_MASK) >> 4;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user