forked from Mirrorlandia_minetest/minetest
Variable name fix + structure creation unrolling in lighting code
This commit is contained in:
parent
6036f865cb
commit
bcdb3d56c0
@ -2238,7 +2238,7 @@ void MMVManip::initialEmerge(v3s16 blockpos_min, v3s16 blockpos_max,
|
|||||||
bool block_data_inexistent = false;
|
bool block_data_inexistent = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
TimeTaker timer1("emerge load", &emerge_load_time);
|
TimeTaker timer2("emerge load", &emerge_load_time);
|
||||||
|
|
||||||
block = m_map->getBlockNoCreate(p);
|
block = m_map->getBlockNoCreate(p);
|
||||||
if(block->isDummy())
|
if(block->isDummy())
|
||||||
|
@ -995,21 +995,22 @@ void finish_bulk_light_update(Map *map, mapblock_v3 minblock,
|
|||||||
// --- STEP 2: Get all newly inserted light sources
|
// --- STEP 2: Get all newly inserted light sources
|
||||||
|
|
||||||
// For each block:
|
// For each block:
|
||||||
for (s16 b_x = minblock.X; b_x <= maxblock.X; b_x++)
|
v3s16 blockpos;
|
||||||
for (s16 b_y = minblock.Y; b_y <= maxblock.Y; b_y++)
|
v3s16 relpos;
|
||||||
for (s16 b_z = minblock.Z; b_z <= maxblock.Z; b_z++) {
|
for (blockpos.X = minblock.X; blockpos.X <= maxblock.X; blockpos.X++)
|
||||||
const v3s16 blockpos(b_x, b_y, b_z);
|
for (blockpos.Y = minblock.Y; blockpos.Y <= maxblock.Y; blockpos.Y++)
|
||||||
|
for (blockpos.Z = minblock.Z; blockpos.Z <= maxblock.Z; blockpos.Z++) {
|
||||||
MapBlock *block = map->getBlockNoCreateNoEx(blockpos);
|
MapBlock *block = map->getBlockNoCreateNoEx(blockpos);
|
||||||
if (!block || block->isDummy())
|
if (!block || block->isDummy())
|
||||||
// Skip not existing blocks
|
// Skip not existing blocks
|
||||||
continue;
|
continue;
|
||||||
// For each node in the block:
|
// For each node in the block:
|
||||||
for (s32 x = 0; x < MAP_BLOCKSIZE; x++)
|
for (relpos.X = 0; relpos.X < MAP_BLOCKSIZE; relpos.X++)
|
||||||
for (s32 z = 0; z < MAP_BLOCKSIZE; z++)
|
for (relpos.Z = 0; relpos.Z < MAP_BLOCKSIZE; relpos.Z++)
|
||||||
for (s32 y = 0; y < MAP_BLOCKSIZE; y++) {
|
for (relpos.Y = 0; relpos.Y < MAP_BLOCKSIZE; relpos.Y++) {
|
||||||
v3s16 relpos(x, y, z);
|
MapNode node = block->getNodeNoCheck(relpos.X, relpos.Y, relpos.Y, &is_valid);
|
||||||
MapNode node = block->getNodeNoCheck(x, y, z, &is_valid);
|
|
||||||
const ContentFeatures &f = ndef->get(node);
|
const ContentFeatures &f = ndef->get(node);
|
||||||
|
|
||||||
// For each light bank
|
// For each light bank
|
||||||
for (size_t b = 0; b < 2; b++) {
|
for (size_t b = 0; b < 2; b++) {
|
||||||
LightBank bank = banks[b];
|
LightBank bank = banks[b];
|
||||||
@ -1088,14 +1089,15 @@ void blit_back_with_light(ServerMap *map, MMVManip *vm,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// --- STEP 2: Get nodes from borders to unlight
|
// --- STEP 2: Get nodes from borders to unlight
|
||||||
|
v3s16 blockpos;
|
||||||
|
v3s16 relpos;
|
||||||
|
|
||||||
// In case there are unloaded holes in the voxel manipulator
|
// In case there are unloaded holes in the voxel manipulator
|
||||||
// unlight each block.
|
// unlight each block.
|
||||||
// For each block:
|
// For each block:
|
||||||
for (s16 b_x = minblock.X; b_x <= maxblock.X; b_x++)
|
for (blockpos.X = minblock.X; blockpos.X <= maxblock.X; blockpos.X++)
|
||||||
for (s16 b_y = minblock.Y; b_y <= maxblock.Y; b_y++)
|
for (blockpos.Y = minblock.Y; blockpos.Y <= maxblock.Y; blockpos.Y++)
|
||||||
for (s16 b_z = minblock.Z; b_z <= maxblock.Z; b_z++) {
|
for (blockpos.Z = minblock.Z; blockpos.Z <= maxblock.Z; blockpos.Z++) {
|
||||||
v3s16 blockpos(b_x, b_y, b_z);
|
|
||||||
MapBlock *block = map->getBlockNoCreateNoEx(blockpos);
|
MapBlock *block = map->getBlockNoCreateNoEx(blockpos);
|
||||||
if (!block || block->isDummy())
|
if (!block || block->isDummy())
|
||||||
// Skip not existing blocks.
|
// Skip not existing blocks.
|
||||||
@ -1104,15 +1106,17 @@ void blit_back_with_light(ServerMap *map, MMVManip *vm,
|
|||||||
// For each border of the block:
|
// For each border of the block:
|
||||||
for (const VoxelArea &a : block_pad) {
|
for (const VoxelArea &a : block_pad) {
|
||||||
// For each node of the border:
|
// For each node of the border:
|
||||||
for (s32 x = a.MinEdge.X; x <= a.MaxEdge.X; x++)
|
for (relpos.X = a.MinEdge.X; relpos.X <= a.MaxEdge.X; relpos.X++)
|
||||||
for (s32 z = a.MinEdge.Z; z <= a.MaxEdge.Z; z++)
|
for (relpos.Z = a.MinEdge.Z; relpos.Z <= a.MaxEdge.Z; relpos.Z++)
|
||||||
for (s32 y = a.MinEdge.Y; y <= a.MaxEdge.Y; y++) {
|
for (relpos.Y = a.MinEdge.Y; relpos.Y <= a.MaxEdge.Y; relpos.Y++) {
|
||||||
v3s16 relpos(x, y, z);
|
|
||||||
// Get old and new node
|
// Get old and new node
|
||||||
MapNode oldnode = block->getNodeNoCheck(x, y, z, &is_valid);
|
MapNode oldnode = block->getNodeNoCheck(relpos.X, relpos.Y, relpos.Z, &is_valid);
|
||||||
const ContentFeatures &oldf = ndef->get(oldnode);
|
const ContentFeatures &oldf = ndef->get(oldnode);
|
||||||
MapNode newnode = vm->getNodeNoExNoEmerge(relpos + offset);
|
MapNode newnode = vm->getNodeNoExNoEmerge(relpos + offset);
|
||||||
const ContentFeatures &newf = ndef->get(newnode);
|
const ContentFeatures &newf = oldnode == newnode ? oldf :
|
||||||
|
ndef->get(newnode);
|
||||||
|
|
||||||
// For each light bank
|
// For each light bank
|
||||||
for (size_t b = 0; b < 2; b++) {
|
for (size_t b = 0; b < 2; b++) {
|
||||||
LightBank bank = banks[b];
|
LightBank bank = banks[b];
|
||||||
@ -1229,13 +1233,14 @@ void repair_block_light(ServerMap *map, MapBlock *block,
|
|||||||
|
|
||||||
// For each border of the block:
|
// For each border of the block:
|
||||||
for (const VoxelArea &a : block_pad) {
|
for (const VoxelArea &a : block_pad) {
|
||||||
|
v3s16 relpos;
|
||||||
// For each node of the border:
|
// For each node of the border:
|
||||||
for (s32 x = a.MinEdge.X; x <= a.MaxEdge.X; x++)
|
for (relpos.X = a.MinEdge.X; relpos.X <= a.MaxEdge.X; relpos.X++)
|
||||||
for (s32 z = a.MinEdge.Z; z <= a.MaxEdge.Z; z++)
|
for (relpos.Z = a.MinEdge.Z; relpos.Z <= a.MaxEdge.Z; relpos.Z++)
|
||||||
for (s32 y = a.MinEdge.Y; y <= a.MaxEdge.Y; y++) {
|
for (relpos.Y = a.MinEdge.Y; relpos.Y <= a.MaxEdge.Y; relpos.Y++) {
|
||||||
v3s16 relpos(x, y, z);
|
|
||||||
// Get node
|
// Get node
|
||||||
MapNode node = block->getNodeNoCheck(x, y, z, &is_valid);
|
MapNode node = block->getNodeNoCheck(relpos.X, relpos.Y, relpos.Z, &is_valid);
|
||||||
const ContentFeatures &f = ndef->get(node);
|
const ContentFeatures &f = ndef->get(node);
|
||||||
// For each light bank
|
// For each light bank
|
||||||
for (size_t b = 0; b < 2; b++) {
|
for (size_t b = 0; b < 2; b++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user