mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-08-03 19:28:49 -04:00
Fix perlin noise for other allocators and switch it to the stackAllocator.
Also revisited some of the cache sizes.
This commit is contained in:
parent
1837fe7adf
commit
bcae83313a
@ -568,7 +568,7 @@ pub const CaveBiomeMapView = struct { // MARK: CaveBiomeMapView
|
||||
// MARK: cache
|
||||
const cacheSize = 1 << 8; // Must be a power of 2!
|
||||
const cacheMask = cacheSize - 1;
|
||||
const associativity = 8;
|
||||
const associativity = 8; // 128 MiB
|
||||
var cache: Cache(CaveBiomeMapFragment, cacheSize, associativity, CaveBiomeMapFragment.decreaseRefCount) = .{};
|
||||
|
||||
var profile: TerrainGenerationProfile = undefined;
|
||||
|
@ -101,9 +101,9 @@ pub const ClimateMapGenerator = struct {
|
||||
};
|
||||
|
||||
|
||||
const cacheSize = 1 << 8; // Must be a power of 2!
|
||||
const cacheSize = 1 << 5; // Must be a power of 2!
|
||||
const cacheMask = cacheSize - 1;
|
||||
const associativity = 4;
|
||||
const associativity = 8; // ~400 MiB
|
||||
var cache: Cache(ClimateMapFragment, cacheSize, associativity, ClimateMapFragment.decreaseRefCount) = .{};
|
||||
var profile: TerrainGenerationProfile = undefined;
|
||||
|
||||
|
@ -72,8 +72,8 @@ pub fn generateMapFragment(map: *MapFragment, worldSeed: u64) void {
|
||||
RandomlyWeightedFractalNoise.generateSparseFractalTerrain(map.pos.wx, map.pos.wy, 256, worldSeed ^ 6758947592930535, mountainMap, map.pos.voxelSize);
|
||||
|
||||
// A smooth map for smaller hills.
|
||||
const hillMap = PerlinNoise.generateSmoothNoise(main.globalAllocator, map.pos.wx, map.pos.wy, mapSize, mapSize, 128, 32, worldSeed ^ 157839765839495820, map.pos.voxelSize, 0.5);
|
||||
defer hillMap.deinit(main.globalAllocator);
|
||||
const hillMap = PerlinNoise.generateSmoothNoise(main.stackAllocator, map.pos.wx, map.pos.wy, mapSize, mapSize, 128, 32, worldSeed ^ 157839765839495820, map.pos.voxelSize, 0.5);
|
||||
defer hillMap.deinit(main.stackAllocator);
|
||||
|
||||
// A fractal map to generate high-detail roughness.
|
||||
const roughMap = Array2D(f32).init(main.stackAllocator, scaledSize, scaledSize);
|
||||
|
@ -129,6 +129,7 @@ const Context = struct {
|
||||
/// Returns a ridgid map of floats with values between 0 and 1.
|
||||
pub fn generateRidgidNoise(allocator: NeverFailingAllocator, x: i32, y: i32, width: u31, height: u31, maxScale: u31, minScale: u31, worldSeed: u64, voxelSize: u31, reductionFactor: f32) Array2D(f32) {
|
||||
const map = Array2D(f32).init(allocator, width/voxelSize, height/voxelSize);
|
||||
@memset(map.mem, 0);
|
||||
var seed = worldSeed;
|
||||
random.scrambleSeed(&seed);
|
||||
var context = Context {
|
||||
@ -161,6 +162,7 @@ pub fn generateRidgidNoise(allocator: NeverFailingAllocator, x: i32, y: i32, wid
|
||||
/// Returns a smooth map of floats with values between 0 and 1.
|
||||
pub fn generateSmoothNoise(allocator: NeverFailingAllocator, x: i32, y: i32, width: u31, height: u31, maxScale: u31, minScale: u31, worldSeed: u64, voxelSize: u31, reductionFactor: f32) Array2D(f32) {
|
||||
const map = Array2D(f32).init(allocator, width/voxelSize, height/voxelSize);
|
||||
@memset(map.mem, 0);
|
||||
var seed = worldSeed;
|
||||
random.scrambleSeed(&seed);
|
||||
var context = Context {
|
||||
|
Loading…
x
Reference in New Issue
Block a user