const char *GenElementManager::ELEMENT_TITLE = "element";
+static const s16 INVALID_HEIGHT = MAP_GENERATION_LIMIT + 1;
+
FlagDesc flagdesc_mapgen[] = {
{"trees", MG_TREES},
{"caves", MG_CAVES},
u32 Mapgen::getBlockSeed2(v3s16 p, int seed)
{
- return noise3d(p.X, p.Y, p.Z, seed);
+ u32 n = 1619 * p.X + 31337 * p.Y + 52591 * p.Z + 1013 * seed;
+ n = (n >> 13) ^ n;
+ return (n * (n * n * 60493 + 19990303) + 1376312589);
}
}
+void Mapgen::initHeightMap(s16 *dest, size_t len)
+{
+ for (size_t i = 0; i < len; i++)
+ dest[i] = INVALID_HEIGHT;
+}
+
void Mapgen::updateHeightmap(v3s16 nmin, v3s16 nmax)
{
if (!heightmap)
for (s16 x = nmin.X; x <= nmax.X; x++, index++) {
s16 y = findGroundLevel(v2s16(x, z), nmin.Y, nmax.Y);
- // if the values found are out of range, trust the old heightmap
- if (y == nmax.Y && heightmap[index] > nmax.Y)
- continue;
- if (y == nmin.Y - 1 && heightmap[index] < nmin.Y)
- continue;
+ if (heightmap[index] != INVALID_HEIGHT) {
+ // if the values found are out of range, trust the old heightmap
+ if (y == nmax.Y && heightmap[index] > nmax.Y)
+ continue;
+ if (y == nmin.Y - 1 && heightmap[index] < nmin.Y)
+ continue;
+ }
heightmap[index] = y;
}
}
-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);
{
//TimeTaker t("spreadLight");
VoxelArea a(nmin, nmax);
- v3s16 em = vm->m_area.getExtent();
for (int z = a.MinEdge.Z; z <= a.MaxEdge.Z; z++) {
for (int y = a.MinEdge.Y; y <= a.MaxEdge.Y; y++) {
std::map<std::string, std::vector<v3s16> > &event_map,
bool peek_events)
{
- std::list<GenNotifyEvent>::iterator it;
-
- for (it = m_notify_events.begin(); it != m_notify_events.end(); ++it) {
+ for (std::vector<GenNotifyEvent>::iterator it = m_notify_events.begin();
+ it != m_notify_events.end(); ++it) {
GenNotifyEvent &gn = *it;
std::string name = (gn.type == GENNOTIFY_DECORATION) ?
"decoration#"+ itos(gn.id) :