mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-08-03 03:06:55 -04:00
keepOriginal is now specified in the biome and can be used for subbiomes.
fixes #1135
This commit is contained in:
parent
2f801c07f4
commit
6f26dde472
@ -2,8 +2,9 @@
|
||||
.properties = .{},
|
||||
.radius = 16,
|
||||
.chance = 0,
|
||||
.minHeight = 2,
|
||||
.maxHeight = 10,
|
||||
.minHeight = -2000,
|
||||
.maxHeight = -1000,
|
||||
.keepOriginalTerrain = 0.99,
|
||||
.roughness = 1,
|
||||
.stoneBlock = "cubyz:stone",
|
||||
.parentBiomes = .{
|
||||
|
@ -2,8 +2,9 @@
|
||||
.properties = .{},
|
||||
.radius = 16,
|
||||
.chance = 0,
|
||||
.minHeight = 50,
|
||||
.maxHeight = 80,
|
||||
.minHeight = 1500,
|
||||
.maxHeight = 3000,
|
||||
.keepOriginalTerrain = 0.99,
|
||||
.roughness = 1,
|
||||
.mountains = 50,
|
||||
.hills = 20,
|
||||
|
@ -284,6 +284,7 @@ pub const Biome = struct { // MARK: Biome
|
||||
roughness: f32,
|
||||
hills: f32,
|
||||
mountains: f32,
|
||||
keepOriginalTerrain: f32,
|
||||
caves: f32,
|
||||
caveRadiusFactor: f32,
|
||||
crystals: u32,
|
||||
@ -326,6 +327,7 @@ pub const Biome = struct { // MARK: Biome
|
||||
.roughness = zon.get(f32, "roughness", 0),
|
||||
.hills = zon.get(f32, "hills", 0),
|
||||
.mountains = zon.get(f32, "mountains", 0),
|
||||
.keepOriginalTerrain = zon.get(f32, "keepOriginalTerrain", 0),
|
||||
.interpolation = std.meta.stringToEnum(Interpolation, zon.get([]const u8, "interpolation", "square")) orelse .square,
|
||||
.interpolationWeight = @max(zon.get(f32, "interpolationWeight", 1), std.math.floatMin(f32)),
|
||||
.caves = zon.get(f32, "caves", -0.375),
|
||||
@ -357,7 +359,6 @@ pub const Biome = struct { // MARK: Biome
|
||||
.chance = src.get(f32, "chance", 1),
|
||||
.propertyMask = GenerationProperties.fromZon(src.getChild("properties"), false),
|
||||
.width = src.get(u8, "width", 2),
|
||||
.keepOriginalTerrain = src.get(f32, "keepOriginalTerrain", 0),
|
||||
};
|
||||
// Fill all unspecified property groups:
|
||||
var properties: u15 = @bitCast(dst.propertyMask);
|
||||
@ -615,14 +616,12 @@ const UnfinishedTransitionBiomeData = struct {
|
||||
chance: f32,
|
||||
propertyMask: Biome.GenerationProperties,
|
||||
width: u8,
|
||||
keepOriginalTerrain: f32,
|
||||
};
|
||||
const TransitionBiome = struct {
|
||||
biome: *const Biome,
|
||||
chance: f32,
|
||||
propertyMask: Biome.GenerationProperties,
|
||||
width: u8,
|
||||
keepOriginalTerrain: f32,
|
||||
};
|
||||
var unfinishedTransitionBiomes: std.StringHashMapUnmanaged([]UnfinishedTransitionBiomeData) = .{};
|
||||
|
||||
@ -725,14 +724,12 @@ pub fn finishLoading() void {
|
||||
.chance = 0,
|
||||
.propertyMask = .{},
|
||||
.width = 0,
|
||||
.keepOriginalTerrain = 0,
|
||||
};
|
||||
continue;
|
||||
},
|
||||
.chance = src.chance,
|
||||
.propertyMask = src.propertyMask,
|
||||
.width = src.width,
|
||||
.keepOriginalTerrain = src.keepOriginalTerrain,
|
||||
};
|
||||
}
|
||||
main.globalAllocator.free(transitionBiomes);
|
||||
|
@ -290,14 +290,16 @@ const GenerationStructure = struct {
|
||||
while(y < max[1]) : (y += 1) {
|
||||
const distSquare = vec.lengthSquare(Vec2f{x, y} - relPos);
|
||||
if(distSquare < relRadius*relRadius) {
|
||||
var seed = map.map[@intFromFloat(x)][@intFromFloat(y)].seed;
|
||||
map.map[@intFromFloat(x)][@intFromFloat(y)] = .{
|
||||
const entry = &map.map[@intFromFloat(x)][@intFromFloat(y)];
|
||||
var seed = entry.seed;
|
||||
const newHeight = @as(f32, @floatFromInt(biome.minHeight)) + @as(f32, @floatFromInt(biome.maxHeight - biome.minHeight))*random.nextFloat(&seed);
|
||||
entry.* = .{
|
||||
.biome = biome,
|
||||
.roughness = biome.roughness,
|
||||
.hills = biome.hills,
|
||||
.mountains = biome.mountains,
|
||||
.height = @as(f32, @floatFromInt(biome.minHeight)) + @as(f32, @floatFromInt(biome.maxHeight - biome.minHeight))*random.nextFloat(&seed),
|
||||
.seed = map.map[@intFromFloat(x)][@intFromFloat(y)].seed,
|
||||
.roughness = std.math.lerp(biome.roughness, entry.roughness, biome.keepOriginalTerrain),
|
||||
.hills = std.math.lerp(biome.hills, entry.hills, biome.keepOriginalTerrain),
|
||||
.mountains = std.math.lerp(biome.mountains, entry.mountains, biome.keepOriginalTerrain),
|
||||
.height = std.math.lerp(newHeight, entry.height, biome.keepOriginalTerrain),
|
||||
.seed = entry.seed,
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -379,10 +381,10 @@ const GenerationStructure = struct {
|
||||
const newHeight = @as(f32, @floatFromInt(transitionBiome.biome.minHeight)) + @as(f32, @floatFromInt(transitionBiome.biome.maxHeight - transitionBiome.biome.minHeight))*random.nextFloat(&seed);
|
||||
map[x][y] = .{
|
||||
.biome = transitionBiome.biome,
|
||||
.roughness = std.math.lerp(transitionBiome.biome.roughness, map[x][y].roughness, transitionBiome.keepOriginalTerrain),
|
||||
.hills = std.math.lerp(transitionBiome.biome.hills, map[x][y].hills, transitionBiome.keepOriginalTerrain),
|
||||
.mountains = std.math.lerp(transitionBiome.biome.mountains, map[x][y].mountains, transitionBiome.keepOriginalTerrain),
|
||||
.height = std.math.lerp(newHeight, map[x][y].height, transitionBiome.keepOriginalTerrain),
|
||||
.roughness = std.math.lerp(transitionBiome.biome.roughness, map[x][y].roughness, transitionBiome.biome.keepOriginalTerrain),
|
||||
.hills = std.math.lerp(transitionBiome.biome.hills, map[x][y].hills, transitionBiome.biome.keepOriginalTerrain),
|
||||
.mountains = std.math.lerp(transitionBiome.biome.mountains, map[x][y].mountains, transitionBiome.biome.keepOriginalTerrain),
|
||||
.height = std.math.lerp(newHeight, map[x][y].height, transitionBiome.biome.keepOriginalTerrain),
|
||||
.seed = map[x][y].seed,
|
||||
};
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user