From 82c2d1315e02ac2abdaf2432d57fbdbb829b55bc Mon Sep 17 00:00:00 2001 From: DBotThePony Date: Sun, 21 Apr 2024 22:30:14 +0700 Subject: [PATCH] Same goes to karst/worm caves --- .../kstarbound/world/terrain/KarstCaveTerrainSelector.kt | 7 ++++--- .../kstarbound/world/terrain/WormCaveTerrainSelector.kt | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/world/terrain/KarstCaveTerrainSelector.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/world/terrain/KarstCaveTerrainSelector.kt index 6a957396..022384a2 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/world/terrain/KarstCaveTerrainSelector.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/world/terrain/KarstCaveTerrainSelector.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.kstarbound.world.terrain import com.github.benmanes.caffeine.cache.Caffeine import com.github.benmanes.caffeine.cache.Scheduler import ru.dbotthepony.kommons.arrays.Double2DArray +import ru.dbotthepony.kommons.arrays.Float2DArray import ru.dbotthepony.kstarbound.math.vector.Vector2i import ru.dbotthepony.kstarbound.Starbound import ru.dbotthepony.kstarbound.defs.PerlinNoiseParameters @@ -67,7 +68,7 @@ class KarstCaveTerrainSelector(data: Data, parameters: TerrainSelectorParameters private inner class Sector(val sector: Vector2i) { private var maxValue = 0.0 - private val values = Double2DArray.allocate(data.sectorSize, data.sectorSize) + private val values = Float2DArray.allocate(data.sectorSize, data.sectorSize) init { for (y in sector.y - data.bufferHeight until sector.y + data.sectorSize + data.bufferHeight) { @@ -118,11 +119,11 @@ class KarstCaveTerrainSelector(data: Data, parameters: TerrainSelectorParameters operator fun get(x: Int, y: Int): Double { val get = values[x - sector.x, y - sector.y] - return if (get > 0.0) get else -maxValue + return if (get > 0.0) get.toDouble() else -maxValue } private operator fun set(x: Int, y: Int, value: Double) { - values[x - sector.x, y - sector.y] = value + values[x - sector.x, y - sector.y] = value.toFloat() } } diff --git a/src/main/kotlin/ru/dbotthepony/kstarbound/world/terrain/WormCaveTerrainSelector.kt b/src/main/kotlin/ru/dbotthepony/kstarbound/world/terrain/WormCaveTerrainSelector.kt index 95d929fc..d8b2e712 100644 --- a/src/main/kotlin/ru/dbotthepony/kstarbound/world/terrain/WormCaveTerrainSelector.kt +++ b/src/main/kotlin/ru/dbotthepony/kstarbound/world/terrain/WormCaveTerrainSelector.kt @@ -3,6 +3,7 @@ package ru.dbotthepony.kstarbound.world.terrain import com.github.benmanes.caffeine.cache.Caffeine import com.github.benmanes.caffeine.cache.Scheduler import ru.dbotthepony.kommons.arrays.Double2DArray +import ru.dbotthepony.kommons.arrays.Float2DArray import ru.dbotthepony.kommons.math.linearInterpolation import ru.dbotthepony.kstarbound.math.vector.Vector2d import ru.dbotthepony.kstarbound.math.vector.Vector2i @@ -49,7 +50,7 @@ class WormCaveTerrainSelector(data: Data, parameters: TerrainSelectorParameters) ) private inner class Sector(val sector: Vector2i) { - private val values = Double2DArray.allocate(data.sectorSize, data.sectorSize) + private val values = Float2DArray.allocate(data.sectorSize, data.sectorSize) private var maxValue = data.wormSizeRange.y / 2.0 init { @@ -172,11 +173,11 @@ class WormCaveTerrainSelector(data: Data, parameters: TerrainSelectorParameters) operator fun get(x: Int, y: Int): Double { val get = values[x - sector.x, y - sector.y] - return if (get > 0.0) get else -maxValue + return if (get > 0.0) get.toDouble() else -maxValue } private operator fun set(x: Int, y: Int, value: Double) { - values[x - sector.x, y - sector.y] = value + values[x - sector.x, y - sector.y] = value.toFloat() } }