minimap is working but update is slow

This commit is contained in:
minjaesong
2021-12-16 12:55:21 +09:00
parent b906c41be8
commit ff848c7c3a
11 changed files with 114 additions and 67 deletions

View File

@@ -31,6 +31,8 @@ import kotlin.math.roundToInt
*/
class NoiseGenerator : ScreenAdapter() {
private val threadExecutor = ThreadExecutor()
lateinit var batch: SpriteBatch
lateinit var camera: OrthographicCamera
lateinit var pixmap: Pixmap
@@ -109,13 +111,13 @@ class NoiseGenerator : ScreenAdapter() {
// regen
if (timerFired && ThreadExecutor.allFinished) {
if (timerFired && threadExecutor.allFinished) {
timerFired = false
totalTestsDone += 1
}
if (regenerate && ThreadExecutor.allFinished) {
if (regenerate && threadExecutor.allFinished) {
//printdbg(this, "Reticulating splines...")
regenerate = false
@@ -126,9 +128,9 @@ class NoiseGenerator : ScreenAdapter() {
val seed = RNG.nextLong()
val jobs = List(jobsCount) { makeGenFun(seed, it) }
ThreadExecutor.renew()
ThreadExecutor.submitAll(jobs)
ThreadExecutor.join()
threadExecutor.renew()
threadExecutor.submitAll(jobs)
threadExecutor.join()
}
@@ -195,7 +197,7 @@ class NoiseGenerator : ScreenAdapter() {
System.exit(0)
}
// time to construct a new test
if (totalTestsDone % samplingCount == 0 && ThreadExecutor.allFinished) {
if (totalTestsDone % samplingCount == 0 && threadExecutor.allFinished) {
pixelsInSingleJob = (IMAGE_SIZE * IMAGE_SIZE) / testSets[totalTestsDone / samplingCount]
@@ -216,7 +218,7 @@ class NoiseGenerator : ScreenAdapter() {
}
// auto-press SPACE
if (ThreadExecutor.allFinished) {
if (threadExecutor.allFinished) {
regenerate = true
constructOnce = false
}

View File

@@ -38,6 +38,8 @@ const val TWO_PI = Math.PI * 2
*/
class WorldgenNoiseSandbox : ApplicationAdapter() {
private val threadExecutor = ThreadExecutor()
private lateinit var batch: SpriteBatch
private lateinit var camera: OrthographicCamera
private lateinit var font: BitmapFont
@@ -70,7 +72,7 @@ class WorldgenNoiseSandbox : ApplicationAdapter() {
testTex.blending = Pixmap.Blending.None
tempTex = Texture(1, 1, Pixmap.Format.RGBA8888)
genSlices = maxOf(ThreadExecutor.threadCount, testTex.width / 8)
genSlices = maxOf(threadExecutor.threadCount, testTex.width / 8)
println("Init done")
}
@@ -234,12 +236,12 @@ class WorldgenNoiseSandbox : ApplicationAdapter() {
} }
ThreadExecutor.renew()
threadExecutor.renew()
runnables.forEach {
ThreadExecutor.submit(it)
threadExecutor.submit(it)
}
ThreadExecutor.join()
threadExecutor.join()
initialGenDone = true
}