From b3fd9499887d07051d4ddcace7420126b1ce9a5e Mon Sep 17 00:00:00 2001 From: Song Minjae Date: Sun, 1 Jan 2017 15:06:19 +0900 Subject: [PATCH] ThreadPool renamed to PhreadParallel, tweaks on font Former-commit-id: 52c6d53764449cecd9ab1aa96b23810e5e406cc2 Former-commit-id: cf8ff86f3c62851c8be2370774b426e09410ad6f --- Terrarum_renewed.iml | 75 +++++++++++++ assets/graphics/fonts/ascii_fullwidth.png | Bin 20740 -> 20442 bytes .../fonts/{han_johab.png => hangul_johab.png} | Bin src/net/torvald/imagefont/GameFontWhite.kt | 12 +-- src/net/torvald/terrarum/StateInGame.kt | 10 +- src/net/torvald/terrarum/StateNoiseTexGen.kt | 6 +- src/net/torvald/terrarum/Terrarum.kt | 2 +- .../terrarum/concurrent/ThreadParallel.kt | 2 +- .../terrarum/mapdrawer/LightmapRenderer.kt | 101 +++++++++--------- .../torvald/terrarum/mapdrawer/TilesDrawer.kt | 2 +- .../terrarum/mapgenerator/WorldGenerator.kt | 6 +- 11 files changed, 147 insertions(+), 69 deletions(-) rename assets/graphics/fonts/{han_johab.png => hangul_johab.png} (100%) diff --git a/Terrarum_renewed.iml b/Terrarum_renewed.iml index d6d82beed..efe4488c4 100644 --- a/Terrarum_renewed.iml +++ b/Terrarum_renewed.iml @@ -4,6 +4,81 @@ + + + + + + diff --git a/assets/graphics/fonts/ascii_fullwidth.png b/assets/graphics/fonts/ascii_fullwidth.png index 3a48fe03df9558c4a950796b998031a82de825c5..1c205e41a77b5fc5834e73e8cfb1934892dcecb1 100644 GIT binary patch delta 2886 zcma)8cT5wE5-+=er7Zm{OJyq*TcD*NMV4Y2#kL@b455Q1f>5Sl8J`6dSw#?JD}oA2 zEd^z%h@yZXSeCK`%O0|)^7Ox#eD5XS<&w+qa(DS%a(B7Ei+R2j@T8)6O*@$eO?+TI zC=C8v?cfLln67~?LzG|dA3hvEMOmLrq`-+tT__R>Cqj|>x;jvI4;Trmtw(_o;Y3{+ z5=CKrM>$Kh=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6K%wJplt;B~E~)JE-5 z=!ULgpeLQ|0+%I5j2U`#VH&6bx{h|~t6yRO0ru!9`!gERZznogXD!C=F2>9&XD(J3 z^;R^nW>EDfs@x>KA53Zl#?9cR%JsKQ8(=&~hw;?$23&A(28^CO)Zxrirbo{u|8+z2 z$$$-a+_LfqF4WuDa-V#}bU~9xO0aUi&_a)yyJ2%PmY;God#{0_p zg)wgFk_7p?&GCU0s(!W~#%1hE?RVY5wV`xucI4vW-II=m2iMj=S|zQAETob&JGSHE z{QXa*!N7B(o%)F(y7&jf4khE>ePYB8lP^;SY3M_pOXNg-L{_g5EGU0~I}Bp-t`Al| oJ+dHO;=Yh+OKeGT;O_%8^W|}?`gqNqUkh;B!rJ_?sps{70cU_4(EtDd diff --git a/assets/graphics/fonts/han_johab.png b/assets/graphics/fonts/hangul_johab.png similarity index 100% rename from assets/graphics/fonts/han_johab.png rename to assets/graphics/fonts/hangul_johab.png diff --git a/src/net/torvald/imagefont/GameFontWhite.kt b/src/net/torvald/imagefont/GameFontWhite.kt index b75ee908b..95ead87f5 100644 --- a/src/net/torvald/imagefont/GameFontWhite.kt +++ b/src/net/torvald/imagefont/GameFontWhite.kt @@ -1,18 +1,16 @@ package net.torvald.imagefont -import net.torvald.terrarum.Terrarum import org.newdawn.slick.* /** * Created by minjaesong on 16-01-20. */ -class GameFontWhite @Throws(SlickException::class) -constructor() : GameFontBase() { +class GameFontWhite : GameFontBase() { init { GameFontBase.hangulSheet = SpriteSheet( - "./assets/graphics/fonts/han_johab.png", GameFontBase.W_HANGUL, GameFontBase.H_HANGUL) + "./assets/graphics/fonts/hangul_johab.png", GameFontBase.W_HANGUL, GameFontBase.H_HANGUL) GameFontBase.asciiSheet = SpriteSheet( "./assets/graphics/fonts/ascii_fullwidth.png", GameFontBase.W_LATIN_WIDE, GameFontBase.H) GameFontBase.asciiSheetEF = SpriteSheet( @@ -68,19 +66,19 @@ constructor() : GameFontBase() { GameFontBase.extASheetEF, GameFontBase.kanaSheet, GameFontBase.cjkPunct, - null, // Filler + null, // Full unihan, filler because we're using WenQuanYi GameFontBase.cyrilic, GameFontBase.cyrilicEF, GameFontBase.fullwidthForms, GameFontBase.uniPunct, GameFontBase.wenQuanYi_1, - GameFontBase.wenQuanYi_2, // uniHan + GameFontBase.wenQuanYi_2, GameFontBase.greekSheet, GameFontBase.greekSheetEF, GameFontBase.romanianSheet, GameFontBase.romanianSheetEF, GameFontBase.thaiSheet, - null, // Filler + null, // Thai EF, filler because not being used right now GameFontBase.keycapSheet ) GameFontBase.sheetKey = shk diff --git a/src/net/torvald/terrarum/StateInGame.kt b/src/net/torvald/terrarum/StateInGame.kt index 0d1c6074c..a3babac21 100644 --- a/src/net/torvald/terrarum/StateInGame.kt +++ b/src/net/torvald/terrarum/StateInGame.kt @@ -3,7 +3,7 @@ package net.torvald.terrarum import net.torvald.imagefont.GameFontBase import net.torvald.random.HQRNG import net.torvald.terrarum.audio.AudioResourceLibrary -import net.torvald.terrarum.concurrent.ThreadPool +import net.torvald.terrarum.concurrent.ThreadParallel import net.torvald.terrarum.console.* import net.torvald.terrarum.gameactors.ActorHumanoid import net.torvald.terrarum.gameactors.* @@ -54,7 +54,7 @@ constructor() : BasicGameState() { val ACTORCONTAINER_INITIAL_SIZE = 128 val actorContainer = ArrayList(ACTORCONTAINER_INITIAL_SIZE) val actorContainerInactive = ArrayList(ACTORCONTAINER_INITIAL_SIZE) - val uiContainer = LinkedList() + val uiContainer = ArrayList() lateinit var consoleHandler: UIHandler lateinit var debugWindow: UIHandler @@ -527,8 +527,8 @@ constructor() : BasicGameState() { if (false) { // don't multithread this for now, it's SLOWER //if (Terrarum.MULTITHREAD) { val actors = actorContainer.size.toFloat() // set up indices - for (i in 0..ThreadPool.POOL_SIZE - 1) { - ThreadPool.map( + for (i in 0..ThreadParallel.POOL_SIZE - 1) { + ThreadParallel.map( i, ThreadActorUpdate( actors.div(Terrarum.THREADS).times(i).roundInt(), @@ -539,7 +539,7 @@ constructor() : BasicGameState() { ) } - ThreadPool.startAll() + ThreadParallel.startAll() } else { actorContainer.forEach { it.update(gc, delta) } diff --git a/src/net/torvald/terrarum/StateNoiseTexGen.kt b/src/net/torvald/terrarum/StateNoiseTexGen.kt index ea4bea4af..050982ad3 100644 --- a/src/net/torvald/terrarum/StateNoiseTexGen.kt +++ b/src/net/torvald/terrarum/StateNoiseTexGen.kt @@ -3,7 +3,7 @@ package net.torvald.terrarum import com.sudoplay.joise.Joise import com.sudoplay.joise.module.* import net.torvald.terrarum.Terrarum.Companion.STATE_ID_TOOL_NOISEGEN -import net.torvald.terrarum.concurrent.ThreadPool +import net.torvald.terrarum.concurrent.ThreadParallel import net.torvald.terrarum.gameactors.roundInt import org.newdawn.slick.Color import org.newdawn.slick.GameContainer @@ -128,7 +128,7 @@ class StateNoiseTexGen : BasicGameState() { } for (i in 0..Terrarum.THREADS - 1) { - ThreadPool.map( + ThreadParallel.map( i, ThreadRunNoiseSampling( imagesize.toFloat().div(Terrarum.THREADS).times(i).roundInt(), @@ -139,7 +139,7 @@ class StateNoiseTexGen : BasicGameState() { ) } - ThreadPool.startAll() + ThreadParallel.startAll() } override fun update(gc: GameContainer, sbg: StateBasedGame, delta: Int) { diff --git a/src/net/torvald/terrarum/Terrarum.kt b/src/net/torvald/terrarum/Terrarum.kt index 613899bfd..20f414768 100644 --- a/src/net/torvald/terrarum/Terrarum.kt +++ b/src/net/torvald/terrarum/Terrarum.kt @@ -152,7 +152,7 @@ constructor(gamename: String) : StateBasedGame(gamename) { lateinit var appgc: AppGameContainer var WIDTH = 1072 - var HEIGHT = 742 // IMAX ratiso + var HEIGHT = 742 // IMAX ratio var VSYNC = true val VSYNC_TRIGGER_THRESHOLD = 56 diff --git a/src/net/torvald/terrarum/concurrent/ThreadParallel.kt b/src/net/torvald/terrarum/concurrent/ThreadParallel.kt index d298c0f95..234558bd8 100644 --- a/src/net/torvald/terrarum/concurrent/ThreadParallel.kt +++ b/src/net/torvald/terrarum/concurrent/ThreadParallel.kt @@ -6,7 +6,7 @@ import java.util.* /** * Created by minjaesong on 16-05-25. */ -object ThreadPool { +object ThreadParallel { val POOL_SIZE = Terrarum.THREADS + 1 private val pool: Array = Array(POOL_SIZE, { null }) diff --git a/src/net/torvald/terrarum/mapdrawer/LightmapRenderer.kt b/src/net/torvald/terrarum/mapdrawer/LightmapRenderer.kt index 21812af49..5cd223907 100644 --- a/src/net/torvald/terrarum/mapdrawer/LightmapRenderer.kt +++ b/src/net/torvald/terrarum/mapdrawer/LightmapRenderer.kt @@ -6,13 +6,17 @@ import net.torvald.terrarum.tileproperties.TileCodex import com.jme3.math.FastMath import net.torvald.colourutil.RGB import net.torvald.colourutil.CIELuvUtil.additiveLuv +import net.torvald.terrarum.concurrent.ThreadParallel import net.torvald.terrarum.gameactors.ActorWithBody +import net.torvald.terrarum.gameactors.abs +import net.torvald.terrarum.gameactors.roundInt import net.torvald.terrarum.gameworld.GameWorld import net.torvald.terrarum.tileproperties.Tile import net.torvald.terrarum.tileproperties.TilePropUtil import org.newdawn.slick.Color import org.newdawn.slick.Graphics import java.util.* +import java.util.concurrent.locks.ReentrantLock /** * Created by minjaesong on 16-01-25. @@ -56,6 +60,7 @@ object LightmapRenderer { internal var for_x_end: Int = 0 internal var for_y_end: Int = 0 + fun getLightRawPos(x: Int, y: Int) = lightmap[y][x] fun getLight(x: Int, y: Int): Int? { @@ -112,9 +117,9 @@ object LightmapRenderer { else { // vertical edges without horizontal edge pair return Pair( if ((rect_width.even() && i.even()) || (rect_width.odd() && i.odd())) - // if the index is on the left side of the box - for_x_start - else for_x_end , + // if the index is on the left side of the box + for_x_start + else for_x_end, (i - rect_width).div(2) + for_y_start + 1 ) } @@ -135,7 +140,7 @@ object LightmapRenderer { else return x - for_x_start + (rect_size - rect_width) } else { // between two edges - if (x < for_x_start) return (y - for_y_start - 1) * 2 + rect_width + if (x < for_x_start) return (y - for_y_start - 1) * 2 + rect_width else if (x > for_x_end) return (y - for_y_start - 1) * 2 + rect_width + 1 else return null } @@ -145,8 +150,8 @@ object LightmapRenderer { if (posToMaskNum(x, y) == null) false else if (!(x in for_x_start - overscan_opaque..for_x_end + overscan_opaque && - x in for_y_start - overscan_opaque..for_y_end + overscan_opaque)) - // point is within the range of overscan_open but not overscan_opaque + x in for_y_start - overscan_opaque..for_y_end + overscan_opaque)) + // point is within the range of overscan_open but not overscan_opaque noop_mask.get(posToMaskNum(x, y)!!) else // point within the overscan_opaque must be rendered, so no no-op false @@ -174,8 +179,40 @@ object LightmapRenderer { */ purgeLightmap() + buildLanternmap() - // scan for luminous actors and store their lighting info to the lanterns + // O(36n) == O(n) where n is a size of the map. + // Because of inevitable overlaps on the area, it only works with ADDITIVE blend (aka maxblend) + // Round 1 + for (y in for_y_start - overscan_open..for_y_end) { + for (x in for_x_start - overscan_open..for_x_end) { + setLight(x, y, calculate(x, y)) + } + } + + // Round 2 + for (y in for_y_end + overscan_open downTo for_y_start) { + for (x in for_x_start - overscan_open..for_x_end) { + setLight(x, y, calculate(x, y)) + } + } + + // Round 3 + for (y in for_y_end + overscan_open downTo for_y_start) { + for (x in for_x_end + overscan_open downTo for_x_start) { + setLight(x, y, calculate(x, y)) + } + } + + // Round 4 + for (y in for_y_start - overscan_open..for_y_end) { + for (x in for_x_end + overscan_open downTo for_x_start) { + setLight(x, y, calculate(x, y)) + } + } + } + + private fun buildLanternmap() { lanternMap.clear() Terrarum.ingame.actorContainer.forEach { it -> if (it is Luminous && it is ActorWithBody) { @@ -198,43 +235,6 @@ object LightmapRenderer { } } } - - // O(36n) == O(n) where n is a size of the map. - // Because of inevitable overlaps on the area, it only works with ADDITIVE blend (aka maxblend) - try { - // Round 1 - for (y in for_y_start - overscan_open..for_y_end) { - for (x in for_x_start - overscan_open..for_x_end) { - setLight(x, y, calculate(x, y)) - } - } - - // Round 2 - for (y in for_y_end + overscan_open downTo for_y_start) { - for (x in for_x_start - overscan_open..for_x_end) { - setLight(x, y, calculate(x, y)) - } - } - - // Round 3 - for (y in for_y_end + overscan_open downTo for_y_start) { - for (x in for_x_end + overscan_open downTo for_x_start) { - setLight(x, y, calculate(x, y)) - } - } - - // Round 4 - for (y in for_y_start - overscan_open..for_y_end) { - for (x in for_x_end + overscan_open downTo for_x_start) { - setLight(x, y, calculate(x, y)) - } - } - - TilePropUtil.dynamicLumFuncTickClock() - } - catch (e: ArrayIndexOutOfBoundsException) { - } - } private fun calculate(x: Int, y: Int): Int = calculate(x, y, false) @@ -266,9 +266,14 @@ object LightmapRenderer { // END MIX TILE // mix luminous actor - for ((posX, posY, luminosity) in lanternMap) { + /*for ((posX, posY, luminosity) in lanternMap) { if (posX == x && posY == y) lightLevelThis = lightLevelThis maxBlend luminosity // maximise to not exceed 1.0 with normal (<= 1.0) light + }*/ + for (i in 0..lanternMap.size - 1) { + val lmap = lanternMap[i] + if (lmap.posX == x && lmap.posY == y) + lightLevelThis = lightLevelThis maxBlend lmap.luminosity // maximise to not exceed 1.0 with normal (<= 1.0) light } @@ -742,10 +747,10 @@ object LightmapRenderer { fun get(index: Int): IntArray { return when (index) { - RED -> reds + RED -> reds GREEN -> greens - BLUE -> blues - else -> throw IllegalArgumentException() + BLUE -> blues + else -> throw IllegalArgumentException() } } } diff --git a/src/net/torvald/terrarum/mapdrawer/TilesDrawer.kt b/src/net/torvald/terrarum/mapdrawer/TilesDrawer.kt index 7012e66f4..35be2eb72 100644 --- a/src/net/torvald/terrarum/mapdrawer/TilesDrawer.kt +++ b/src/net/torvald/terrarum/mapdrawer/TilesDrawer.kt @@ -6,7 +6,7 @@ import net.torvald.terrarum.Terrarum import net.torvald.terrarum.tileproperties.Tile import net.torvald.terrarum.tileproperties.TileCodex import com.jme3.math.FastMath -import net.torvald.terrarum.concurrent.ThreadPool +import net.torvald.terrarum.concurrent.ThreadParallel import net.torvald.terrarum.blendMul import net.torvald.terrarum.blendNormal import net.torvald.terrarum.mapdrawer.FeaturesDrawer.TILE_SIZE diff --git a/src/net/torvald/terrarum/mapgenerator/WorldGenerator.kt b/src/net/torvald/terrarum/mapgenerator/WorldGenerator.kt index 0013a2664..0b79eb9f1 100644 --- a/src/net/torvald/terrarum/mapgenerator/WorldGenerator.kt +++ b/src/net/torvald/terrarum/mapgenerator/WorldGenerator.kt @@ -7,7 +7,7 @@ import com.jme3.math.FastMath import com.sudoplay.joise.Joise import com.sudoplay.joise.module.* import net.torvald.terrarum.Terrarum -import net.torvald.terrarum.concurrent.ThreadPool +import net.torvald.terrarum.concurrent.ThreadParallel import net.torvald.terrarum.gameactors.ThreadActorUpdate import net.torvald.terrarum.gameactors.roundInt import java.util.* @@ -689,7 +689,7 @@ object WorldGenerator { if (Terrarum.MULTITHREAD) { // set up indices for (i in 0..Terrarum.THREADS - 1) { - ThreadPool.map( + ThreadParallel.map( i, ThreadProcessNoiseLayers( HEIGHT.toFloat().div(Terrarum.THREADS).times(i).roundInt(), @@ -700,7 +700,7 @@ object WorldGenerator { ) } - ThreadPool.startAll() + ThreadParallel.startAll() // FIXME game starts prematurely /* Console: [mapgenerator] Seed: 85336530