}
-void Mapgen::setLighting(v3s16 nmin, v3s16 nmax, u8 light)
+void Mapgen::setLighting(u8 light, v3s16 nmin, v3s16 nmax)
{
ScopeProfiler sp(g_profiler, "EmergeThread: mapgen lighting update", SPT_AVG);
VoxelArea a(nmin, nmax);
}
+void Mapgen::calcLighting(v3s16 nmin, v3s16 nmax, v3s16 full_nmin, v3s16 full_nmax)
+{
+ ScopeProfiler sp(g_profiler, "EmergeThread: mapgen lighting update", SPT_AVG);
+ //TimeTaker t("updateLighting");
+
+ propagateSunlight(nmin, nmax);
+ spreadLight(full_nmin, full_nmax);
+
+ //printf("updateLighting: %dms\n", t.stop());
+}
+
+
+
void Mapgen::calcLighting(v3s16 nmin, v3s16 nmax)
{
ScopeProfiler sp(g_profiler, "EmergeThread: mapgen lighting update", SPT_AVG);
s16 findGroundLevel(v2s16 p2d, s16 ymin, s16 ymax);
void updateHeightmap(v3s16 nmin, v3s16 nmax);
void updateLiquid(UniqueQueue<v3s16> *trans_liquid, v3s16 nmin, v3s16 nmax);
- void setLighting(v3s16 nmin, v3s16 nmax, u8 light);
+
+ void setLighting(u8 light, v3s16 nmin, v3s16 nmax);
void lightSpread(VoxelArea &a, v3s16 p, u8 light);
void calcLighting(v3s16 nmin, v3s16 nmax);
+ void calcLighting(v3s16 nmin, v3s16 nmax,
+ v3s16 full_nmin, v3s16 full_nmax);
+
void propagateSunlight(v3s16 nmin, v3s16 nmax);
void spreadLight(v3s16 nmin, v3s16 nmax);
updateLiquid(&data->transforming_liquid, full_node_min, full_node_max);
// Calculate lighting
- if (flags & MG_LIGHT)
- calcLighting(node_min - v3s16(0, 1, 0), node_max + v3s16(0, 1, 0));
+ if (flags & MG_LIGHT) {
+ calcLighting(node_min - v3s16(0, 1, 0), node_max + v3s16(0, 1, 0),
+ full_node_min, full_node_max);
+ }
this->generating = false;
}
EmergeManager *emerge = getServer(L)->getEmergeManager();
ManualMapVoxelManipulator *vm = o->vm;
- v3s16 p1 = lua_istable(L, 2) ? read_v3s16(L, 2) : vm->m_area.MinEdge;
- v3s16 p2 = lua_istable(L, 3) ? read_v3s16(L, 3) : vm->m_area.MaxEdge;
- sortBoxVerticies(p1, p2);
- if (!vm->m_area.contains(VoxelArea(p1, p2)))
+ v3s16 yblock = v3s16(0, 1, 0) * MAP_BLOCKSIZE;
+ v3s16 fpmin = vm->m_area.MinEdge;
+ v3s16 fpmax = vm->m_area.MaxEdge;
+ v3s16 pmin = lua_istable(L, 2) ? read_v3s16(L, 2) : fpmin + yblock;
+ v3s16 pmax = lua_istable(L, 3) ? read_v3s16(L, 3) : fpmax - yblock;
+
+ sortBoxVerticies(pmin, pmax);
+ if (!vm->m_area.contains(VoxelArea(pmin, pmax)))
throw LuaError("Specified voxel area out of VoxelManipulator bounds");
Mapgen mg;
mg.ndef = ndef;
mg.water_level = emerge->params.water_level;
- // Mapgen::calcLighting assumes the coordinates of
- // the central chunk; correct for this
- mg.calcLighting(
- p1 + v3s16(1, 1, 1) * MAP_BLOCKSIZE,
- p2 - v3s16(1, 1, 1) * MAP_BLOCKSIZE);
+ mg.calcLighting(pmin, pmax, fpmin, fpmax);
return 0;
}
ManualMapVoxelManipulator *vm = o->vm;
- v3s16 p1 = lua_istable(L, 3) ? read_v3s16(L, 3) : vm->m_area.MinEdge;
- v3s16 p2 = lua_istable(L, 4) ? read_v3s16(L, 4) : vm->m_area.MaxEdge;
- sortBoxVerticies(p1, p2);
- if (!vm->m_area.contains(VoxelArea(p1, p2)))
+ v3s16 yblock = v3s16(0, 1, 0) * MAP_BLOCKSIZE;
+ v3s16 pmin = lua_istable(L, 3) ? read_v3s16(L, 3) : vm->m_area.MinEdge + yblock;
+ v3s16 pmax = lua_istable(L, 4) ? read_v3s16(L, 4) : vm->m_area.MaxEdge - yblock;
+
+ sortBoxVerticies(pmin, pmax);
+ if (!vm->m_area.contains(VoxelArea(pmin, pmax)))
throw LuaError("Specified voxel area out of VoxelManipulator bounds");
Mapgen mg;
mg.vm = vm;
- mg.setLighting(
- p1 + v3s16(0, 1, 0) * MAP_BLOCKSIZE,
- p2 - v3s16(0, 1, 0) * MAP_BLOCKSIZE,
- light);
+ mg.setLighting(light, pmin, pmax);
return 0;
}