mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 03:54:06 +09:00
collision detection and CCD: Not exactly fixed but it works good enough
Former-commit-id: 3feb9b1156fc941390b4efe4c1540ed4c5dbd109 Former-commit-id: 8c97b0ade765731800ef09b722e0742e44443338
This commit is contained in:
@@ -10,46 +10,68 @@ import net.torvald.terrarum.mapdrawer.LightmapRenderer
|
||||
* Created by minjaesong on 16-06-16.
|
||||
*/
|
||||
object TilePropUtil {
|
||||
var flickerFuncX = 0 // in milliseconds; saves current status of func
|
||||
var flickerFuncX = 0 // in milliseconds; saves current status (time) of func
|
||||
val flickerFuncDomain = 100 // time between two noise sample, in milliseconds
|
||||
val flickerFuncRange = 0.012f // intensity [0, 1]
|
||||
|
||||
val random = HQRNG();
|
||||
var funcY = 0f
|
||||
var breathFuncX = 0
|
||||
val breathRange = 0.02f
|
||||
val breathCycleDuration = 2000 // in milliseconds
|
||||
|
||||
var patternThis = getNewRandom()
|
||||
var patternNext = getNewRandom()
|
||||
var pulsateFuncX = 0
|
||||
val pulsateRange = 0.034f
|
||||
val pulsateCycleDuration = 500 // in milliseconds
|
||||
|
||||
val random = HQRNG();
|
||||
|
||||
var flickerPatternThis = getNewRandom()
|
||||
var flickerPatternNext = getNewRandom()
|
||||
|
||||
init {
|
||||
|
||||
}
|
||||
|
||||
private fun getTorchFlicker(baseLum: Int): Int {
|
||||
funcY = linearInterpolation1D(patternThis, patternNext,
|
||||
val funcY = linearInterpolation1D(flickerPatternThis, flickerPatternNext,
|
||||
flickerFuncX.toFloat() / flickerFuncDomain
|
||||
)
|
||||
|
||||
return LightmapRenderer.brightenUniform(baseLum, funcY)
|
||||
return LightmapRenderer.alterBrightnessUniform(baseLum, funcY)
|
||||
}
|
||||
|
||||
private fun getSlowBreath(baseLum: Int): Int {
|
||||
return baseLum
|
||||
val funcY = FastMath.sin(FastMath.PI * breathFuncX / breathCycleDuration) * breathRange
|
||||
|
||||
return LightmapRenderer.alterBrightnessUniform(baseLum, funcY)
|
||||
}
|
||||
|
||||
private fun getPulsate(baseLum: Int): Int {
|
||||
return baseLum
|
||||
val funcY = FastMath.sin(FastMath.PI * pulsateFuncX / pulsateCycleDuration) * pulsateRange
|
||||
|
||||
return LightmapRenderer.alterBrightnessUniform(baseLum, funcY)
|
||||
}
|
||||
|
||||
internal fun dynamicLumFuncTickClock() {
|
||||
if (Terrarum.appgc.fps > 0)
|
||||
// FPS-time compensation
|
||||
if (Terrarum.appgc.fps > 0) {
|
||||
flickerFuncX += 1000 / Terrarum.appgc.fps
|
||||
breathFuncX += 1000 / Terrarum.appgc.fps
|
||||
pulsateFuncX += 1000 / Terrarum.appgc.fps
|
||||
}
|
||||
|
||||
// flicker-related vars
|
||||
if (flickerFuncX > flickerFuncDomain) {
|
||||
flickerFuncX -= flickerFuncDomain
|
||||
|
||||
patternThis = patternNext
|
||||
patternNext = getNewRandom()
|
||||
flickerPatternThis = flickerPatternNext
|
||||
flickerPatternNext = getNewRandom()
|
||||
}
|
||||
|
||||
// breath-related vars
|
||||
if (breathFuncX > breathCycleDuration) breathFuncX -= breathCycleDuration
|
||||
|
||||
// pulsate-related vars
|
||||
if (pulsateFuncX > pulsateCycleDuration) pulsateFuncX -= pulsateCycleDuration
|
||||
}
|
||||
|
||||
private fun getNewRandom() = random.nextFloat().times(2).minus(1f) * flickerFuncRange
|
||||
|
||||
@@ -123,7 +123,7 @@
|
||||
## Notes ##
|
||||
|
||||
# Friction: 0: frictionless, <16: slippery, 16: regular, >16: sticky
|
||||
# Opacity/Lumcolor: 30-bit RGB
|
||||
# Opacity/Lumcolor: 30-bit RGB. Light diffusers have a value of ZERO.
|
||||
# Solid: whether the tile has full collision
|
||||
# movr: Movement resistance, (walkspeedmax) / (1 + (n/16)), 16 halves movement speed
|
||||
# dsty: density. As we are putting water an 1000, it is identical to specific gravity. [g/l]
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 1 and column 18.
|
Reference in New Issue
Block a user