mirror of
https://github.com/minetest/minetest.git
synced 2025-01-24 23:11:31 +01:00
Add weights to biomes (#15142)
This commit is contained in:
parent
44b261d136
commit
4c44942a39
@ -43,6 +43,7 @@ core.features = {
|
|||||||
hotbar_hud_element = true,
|
hotbar_hud_element = true,
|
||||||
bulk_lbms = true,
|
bulk_lbms = true,
|
||||||
abm_without_neighbors = true,
|
abm_without_neighbors = true,
|
||||||
|
biome_weights = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
function core.has_feature(arg)
|
function core.has_feature(arg)
|
||||||
|
@ -5657,6 +5657,8 @@ Utilities
|
|||||||
bulk_lbms = true,
|
bulk_lbms = true,
|
||||||
-- ABM supports field without_neighbors (5.10.0)
|
-- ABM supports field without_neighbors (5.10.0)
|
||||||
abm_without_neighbors = true,
|
abm_without_neighbors = true,
|
||||||
|
-- biomes have a weight parameter (5.11.0)
|
||||||
|
biome_weights = true,
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -10709,6 +10711,10 @@ performance and computing power the practical limit is much lower.
|
|||||||
-- distribution of the biomes.
|
-- distribution of the biomes.
|
||||||
-- Heat and humidity have average values of 50, vary mostly between
|
-- Heat and humidity have average values of 50, vary mostly between
|
||||||
-- 0 and 100 but can exceed these values.
|
-- 0 and 100 but can exceed these values.
|
||||||
|
|
||||||
|
weight = 1.0,
|
||||||
|
-- Relative weight of the biome in the Voronoi diagram.
|
||||||
|
-- A value of 0 (or less) is ignored and equivalent to 1.0.
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -39,6 +39,7 @@ BiomeManager::BiomeManager(Server *server) :
|
|||||||
b->heat_point = 0.0;
|
b->heat_point = 0.0;
|
||||||
b->humidity_point = 0.0;
|
b->humidity_point = 0.0;
|
||||||
b->vertical_blend = 0;
|
b->vertical_blend = 0;
|
||||||
|
b->weight = 1.0f;
|
||||||
|
|
||||||
b->m_nodenames.emplace_back("mapgen_stone");
|
b->m_nodenames.emplace_back("mapgen_stone");
|
||||||
b->m_nodenames.emplace_back("mapgen_stone");
|
b->m_nodenames.emplace_back("mapgen_stone");
|
||||||
@ -256,7 +257,9 @@ Biome *BiomeGenOriginal::calcBiomeFromNoise(float heat, float humidity, v3s16 po
|
|||||||
|
|
||||||
float d_heat = heat - b->heat_point;
|
float d_heat = heat - b->heat_point;
|
||||||
float d_humidity = humidity - b->humidity_point;
|
float d_humidity = humidity - b->humidity_point;
|
||||||
float dist = (d_heat * d_heat) + (d_humidity * d_humidity);
|
float dist = ((d_heat * d_heat) + (d_humidity * d_humidity));
|
||||||
|
if (b->weight > 0.f)
|
||||||
|
dist /= b->weight;
|
||||||
|
|
||||||
if (pos.Y <= b->max_pos.Y) { // Within y limits of biome b
|
if (pos.Y <= b->max_pos.Y) { // Within y limits of biome b
|
||||||
if (dist < dist_min) {
|
if (dist < dist_min) {
|
||||||
@ -321,6 +324,7 @@ ObjDef *Biome::clone() const
|
|||||||
obj->heat_point = heat_point;
|
obj->heat_point = heat_point;
|
||||||
obj->humidity_point = humidity_point;
|
obj->humidity_point = humidity_point;
|
||||||
obj->vertical_blend = vertical_blend;
|
obj->vertical_blend = vertical_blend;
|
||||||
|
obj->weight = weight;
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,7 @@ public:
|
|||||||
float heat_point;
|
float heat_point;
|
||||||
float humidity_point;
|
float humidity_point;
|
||||||
s16 vertical_blend;
|
s16 vertical_blend;
|
||||||
|
float weight;
|
||||||
|
|
||||||
virtual void resolveNodeNames();
|
virtual void resolveNodeNames();
|
||||||
};
|
};
|
||||||
|
@ -374,6 +374,7 @@ Biome *read_biome_def(lua_State *L, int index, const NodeDefManager *ndef)
|
|||||||
b->heat_point = getfloatfield_default(L, index, "heat_point", 0.f);
|
b->heat_point = getfloatfield_default(L, index, "heat_point", 0.f);
|
||||||
b->humidity_point = getfloatfield_default(L, index, "humidity_point", 0.f);
|
b->humidity_point = getfloatfield_default(L, index, "humidity_point", 0.f);
|
||||||
b->vertical_blend = getintfield_default(L, index, "vertical_blend", 0);
|
b->vertical_blend = getintfield_default(L, index, "vertical_blend", 0);
|
||||||
|
b->weight = getfloatfield_default(L, index, "weight", 1.f);
|
||||||
b->flags = 0; // reserved
|
b->flags = 0; // reserved
|
||||||
|
|
||||||
b->min_pos = getv3s16field_default(
|
b->min_pos = getv3s16field_default(
|
||||||
|
Loading…
Reference in New Issue
Block a user