mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
ThreadPool renamed to PhreadParallel, tweaks on font
Former-commit-id: 52c6d53764449cecd9ab1aa96b23810e5e406cc2 Former-commit-id: cf8ff86f3c62851c8be2370774b426e09410ad6f
This commit is contained in:
@@ -4,6 +4,81 @@
|
||||
<facet type="Lua" name="Lua">
|
||||
<configuration SdkName="Kahlua" />
|
||||
</facet>
|
||||
<facet type="kotlin-language" name="Kotlin">
|
||||
<configuration version="1">
|
||||
<option name="compilerInfo">
|
||||
<KotlinCompilerInfo>
|
||||
<option name="compilerSettings">
|
||||
<CompilerSettings>
|
||||
<option name="additionalArguments" value="-version" />
|
||||
<option name="copyJsLibraryFiles" value="true" />
|
||||
<option name="outputDirectoryForJsLibraryFiles" value="lib" />
|
||||
</CompilerSettings>
|
||||
</option>
|
||||
<option name="k2jsCompilerArguments">
|
||||
<K2JSCompilerArguments>
|
||||
<option name="outputFile" />
|
||||
<option name="noStdlib" value="false" />
|
||||
<option name="libraryFiles" />
|
||||
<option name="sourceMap" value="false" />
|
||||
<option name="metaInfo" value="false" />
|
||||
<option name="kjsm" value="false" />
|
||||
<option name="target" />
|
||||
<option name="moduleKind" />
|
||||
<option name="main" />
|
||||
<option name="outputPrefix" />
|
||||
<option name="outputPostfix" />
|
||||
<option name="languageVersion" />
|
||||
<option name="apiVersion" />
|
||||
<option name="suppressWarnings" value="false" />
|
||||
<option name="verbose" value="false" />
|
||||
<option name="version" value="false" />
|
||||
<option name="help" value="false" />
|
||||
<option name="extraHelp" value="false" />
|
||||
<option name="noInline" value="false" />
|
||||
<option name="repeat" />
|
||||
<option name="pluginClasspaths" />
|
||||
<option name="pluginOptions" />
|
||||
<option name="freeArgs">
|
||||
<list />
|
||||
</option>
|
||||
<option name="unknownExtraFlags">
|
||||
<list />
|
||||
</option>
|
||||
</K2JSCompilerArguments>
|
||||
</option>
|
||||
<option name="_commonCompilerArguments">
|
||||
<DummyImpl>
|
||||
<option name="languageVersion" />
|
||||
<option name="apiVersion" />
|
||||
<option name="suppressWarnings" value="false" />
|
||||
<option name="verbose" value="false" />
|
||||
<option name="version" value="false" />
|
||||
<option name="help" value="false" />
|
||||
<option name="extraHelp" value="false" />
|
||||
<option name="noInline" value="false" />
|
||||
<option name="repeat" />
|
||||
<option name="pluginClasspaths" />
|
||||
<option name="pluginOptions" />
|
||||
<option name="freeArgs">
|
||||
<list />
|
||||
</option>
|
||||
<option name="unknownExtraFlags">
|
||||
<list />
|
||||
</option>
|
||||
</DummyImpl>
|
||||
</option>
|
||||
</KotlinCompilerInfo>
|
||||
</option>
|
||||
<option name="versionInfo">
|
||||
<KotlinVersionInfo>
|
||||
<option name="apiLevel" value="1.0" />
|
||||
<option name="languageLevel" value="1.0" />
|
||||
<option name="targetPlatformName" value="JVM 1.6" />
|
||||
</KotlinVersionInfo>
|
||||
</option>
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
@@ -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
|
||||
|
||||
@@ -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<Actor>(ACTORCONTAINER_INITIAL_SIZE)
|
||||
val actorContainerInactive = ArrayList<Actor>(ACTORCONTAINER_INITIAL_SIZE)
|
||||
val uiContainer = LinkedList<UIHandler>()
|
||||
val uiContainer = ArrayList<UIHandler>()
|
||||
|
||||
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) }
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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<Thread?> = Array(POOL_SIZE, { null })
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user