mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-06 08:38:30 +09:00
fix: panning dynamic source sending nan values
This commit is contained in:
@@ -18,7 +18,6 @@ import net.torvald.tsvm.peripheral.VMProgramRom
|
|||||||
*/
|
*/
|
||||||
class FixtureHomeComputer : FixtureBase {
|
class FixtureHomeComputer : FixtureBase {
|
||||||
|
|
||||||
@Transient override val spawnNeedsFloor = true
|
|
||||||
|
|
||||||
// TODO: write serialiser for TSVM && allow mods to have their own serialiser
|
// TODO: write serialiser for TSVM && allow mods to have their own serialiser
|
||||||
private val vm = VM(ModMgr.getGdxFile("dwarventech", "bios").path(), 0x200000, TheRealWorld(), arrayOf(
|
private val vm = VM(ModMgr.getGdxFile("dwarventech", "bios").path(), 0x200000, TheRealWorld(), arrayOf(
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class MixerTrackProcessor(val buffertaille: Int, val rate: Int, val track: Terra
|
|||||||
|
|
||||||
private var breakBomb = false
|
private var breakBomb = false
|
||||||
|
|
||||||
private val distFalloff = 1024.0
|
private val distFalloff = 1536.0
|
||||||
|
|
||||||
private fun printdbg(msg: Any) {
|
private fun printdbg(msg: Any) {
|
||||||
if (true) App.printdbg("AudioAdapter ${track.name}", msg)
|
if (true) App.printdbg("AudioAdapter ${track.name}", msg)
|
||||||
@@ -111,10 +111,12 @@ class MixerTrackProcessor(val buffertaille: Int, val rate: Int, val track: Terra
|
|||||||
(track.filters[0] as BinoPan).pan = 0f
|
(track.filters[0] as BinoPan).pan = 0f
|
||||||
}
|
}
|
||||||
else if (track.trackingTarget is ActorWithBody) {
|
else if (track.trackingTarget is ActorWithBody) {
|
||||||
// FIXME this may cause filter to fill the output buffer with NaNs?
|
|
||||||
val relativeXpos = relativeXposition(AudioMixer.actorNowPlaying!!, track.trackingTarget as ActorWithBody)
|
val relativeXpos = relativeXposition(AudioMixer.actorNowPlaying!!, track.trackingTarget as ActorWithBody)
|
||||||
track.volume = track.maxVolume * (1.0 - relativeXpos.absoluteValue.pow(0.5) / distFalloff)
|
track.volume = track.maxVolume * (1.0 - (relativeXpos.absoluteValue / distFalloff).pow(0.5)).coerceAtLeast(0.0)
|
||||||
(track.filters[0] as BinoPan).pan = ((2*asin(relativeXpos / distFalloff)) / Math.PI).toFloat()
|
(track.filters[0] as BinoPan).pan =
|
||||||
|
if (relativeXpos <= -distFalloff) -1f
|
||||||
|
else if (relativeXpos >= distFalloff) 1f
|
||||||
|
else ((2*asin(relativeXpos / distFalloff)) / Math.PI).toFloat()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,7 @@ class BinoPan(var pan: Float, var earDist: Float = 0.18f): TerrarumAudioFilter()
|
|||||||
val delayInSamples = (timeDiffMax * FastMath.sin(angle)).absoluteValue
|
val delayInSamples = (timeDiffMax * FastMath.sin(angle)).absoluteValue
|
||||||
val volMultDbThis = PANNING_CONST * pan.absoluteValue
|
val volMultDbThis = PANNING_CONST * pan.absoluteValue
|
||||||
val volMultFsThis = decibelsToFullscale(volMultDbThis).toFloat()
|
val volMultFsThis = decibelsToFullscale(volMultDbThis).toFloat()
|
||||||
|
|
||||||
val volMUltFsOther = 1f / volMultFsThis
|
val volMUltFsOther = 1f / volMultFsThis
|
||||||
|
|
||||||
if (pan >= 0) {
|
if (pan >= 0) {
|
||||||
|
|||||||
@@ -339,7 +339,7 @@ class TerrarumMusicGovernor : MusicGovernor() {
|
|||||||
fun stopMusic(callStopMusicHook: Boolean = true, pauseLen: Float = Float.POSITIVE_INFINITY) {
|
fun stopMusic(callStopMusicHook: Boolean = true, pauseLen: Float = Float.POSITIVE_INFINITY) {
|
||||||
stopMusic(AudioMixer.musicTrack.currentTrack, callStopMusicHook)
|
stopMusic(AudioMixer.musicTrack.currentTrack, callStopMusicHook)
|
||||||
intermissionLength = pauseLen
|
intermissionLength = pauseLen
|
||||||
printdbg(this, "StopMusic Intermission2: $intermissionLength seconds")
|
// printdbg(this, "StopMusic Intermission2: $intermissionLength seconds")
|
||||||
}
|
}
|
||||||
|
|
||||||
fun startMusic() {
|
fun startMusic() {
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ open class Electric : FixtureBase {
|
|||||||
open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
||||||
|
|
||||||
@Transient open val spawnNeedsWall: Boolean = false
|
@Transient open val spawnNeedsWall: Boolean = false
|
||||||
@Transient open val spawnNeedsFloor: Boolean = false
|
@Transient open val spawnNeedsFloor: Boolean = true
|
||||||
|
|
||||||
/** Real time, in nanoseconds */
|
/** Real time, in nanoseconds */
|
||||||
@Transient var spawnRequestedTime: Long = 0L
|
@Transient var spawnRequestedTime: Long = 0L
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
|||||||
*/
|
*/
|
||||||
class FixtureFurnaceAndAnvil : FixtureBase, CraftingStation {
|
class FixtureFurnaceAndAnvil : FixtureBase, CraftingStation {
|
||||||
|
|
||||||
@Transient override val spawnNeedsFloor = true
|
|
||||||
@Transient override val tags = listOf("metalworking")
|
@Transient override val tags = listOf("metalworking")
|
||||||
|
|
||||||
constructor() : super(
|
constructor() : super(
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import org.dyn4j.geometry.Vector2
|
|||||||
|
|
||||||
class FixtureLogicSignalEmitter : Electric {
|
class FixtureLogicSignalEmitter : Electric {
|
||||||
|
|
||||||
|
@Transient override val spawnNeedsFloor = false
|
||||||
|
|
||||||
constructor() : super(
|
constructor() : super(
|
||||||
BlockBox(BlockBox.NO_COLLISION, 1, 1),
|
BlockBox(BlockBox.NO_COLLISION, 1, 1),
|
||||||
nameFun = { Lang["ITEM_LOGIC_SIGNAL_EMITTER"] }
|
nameFun = { Lang["ITEM_LOGIC_SIGNAL_EMITTER"] }
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
|||||||
*/
|
*/
|
||||||
class FixtureSmelterBasic : FixtureBase, CraftingStation {
|
class FixtureSmelterBasic : FixtureBase, CraftingStation {
|
||||||
|
|
||||||
@Transient override val spawnNeedsFloor = true
|
|
||||||
@Transient override val tags = listOf("basicsmelter")
|
@Transient override val tags = listOf("basicsmelter")
|
||||||
|
|
||||||
constructor() : super(
|
constructor() : super(
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
|||||||
*/
|
*/
|
||||||
internal class FixtureStorageChest : FixtureBase {
|
internal class FixtureStorageChest : FixtureBase {
|
||||||
|
|
||||||
@Transient override val spawnNeedsFloor = true
|
|
||||||
|
|
||||||
constructor() : super(
|
constructor() : super(
|
||||||
BlockBox(BlockBox.ALLOW_MOVE_DOWN, 1, 1),
|
BlockBox(BlockBox.ALLOW_MOVE_DOWN, 1, 1),
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ open class FixtureSwingingDoorBase : FixtureBase {
|
|||||||
private var tilewiseDistToAxis = tw - twClosed
|
private var tilewiseDistToAxis = tw - twClosed
|
||||||
|
|
||||||
@Transient override val spawnNeedsWall = true
|
@Transient override val spawnNeedsWall = true
|
||||||
|
@Transient override val spawnNeedsFloor = false
|
||||||
|
|
||||||
@Transient override var lightBoxList = arrayListOf(Lightbox(Hitbox(TILE_SIZED * tilewiseDistToAxis, 0.0, TILE_SIZED * twClosed, TILE_SIZED * th), Cvec(0)))
|
@Transient override var lightBoxList = arrayListOf(Lightbox(Hitbox(TILE_SIZED * tilewiseDistToAxis, 0.0, TILE_SIZED * twClosed, TILE_SIZED * th), Cvec(0)))
|
||||||
// the Cvec will be calculated dynamically on Update
|
// the Cvec will be calculated dynamically on Update
|
||||||
@Transient override var shadeBoxList = arrayListOf(Lightbox(Hitbox(TILE_SIZED * tilewiseDistToAxis, 0.0, TILE_SIZED * twClosed, TILE_SIZED * th), Cvec(0)))
|
@Transient override var shadeBoxList = arrayListOf(Lightbox(Hitbox(TILE_SIZED * tilewiseDistToAxis, 0.0, TILE_SIZED * twClosed, TILE_SIZED * th), Cvec(0)))
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ import net.torvald.terrarum.blockproperties.Block
|
|||||||
* Created by minjaesong on 2022-07-28.
|
* Created by minjaesong on 2022-07-28.
|
||||||
*/
|
*/
|
||||||
class FixtureSwingingDoorOak : FixtureSwingingDoorBase {
|
class FixtureSwingingDoorOak : FixtureSwingingDoorBase {
|
||||||
@Transient override val spawnNeedsWall = true
|
|
||||||
constructor() : super() {
|
constructor() : super() {
|
||||||
_construct(
|
_construct(
|
||||||
2,
|
2,
|
||||||
@@ -25,7 +24,6 @@ class FixtureSwingingDoorOak : FixtureSwingingDoorBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class FixtureSwingingDoorEbony : FixtureSwingingDoorBase {
|
class FixtureSwingingDoorEbony : FixtureSwingingDoorBase {
|
||||||
@Transient override val spawnNeedsWall = true
|
|
||||||
constructor() : super() {
|
constructor() : super() {
|
||||||
_construct(
|
_construct(
|
||||||
2,
|
2,
|
||||||
@@ -43,7 +41,6 @@ class FixtureSwingingDoorEbony : FixtureSwingingDoorBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class FixtureSwingingDoorBirch : FixtureSwingingDoorBase {
|
class FixtureSwingingDoorBirch : FixtureSwingingDoorBase {
|
||||||
@Transient override val spawnNeedsWall = true
|
|
||||||
constructor() : super() {
|
constructor() : super() {
|
||||||
_construct(
|
_construct(
|
||||||
2,
|
2,
|
||||||
@@ -61,7 +58,6 @@ class FixtureSwingingDoorBirch : FixtureSwingingDoorBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class FixtureSwingingDoorRosewood : FixtureSwingingDoorBase {
|
class FixtureSwingingDoorRosewood : FixtureSwingingDoorBase {
|
||||||
@Transient override val spawnNeedsWall = true
|
|
||||||
constructor() : super() {
|
constructor() : super() {
|
||||||
_construct(
|
_construct(
|
||||||
2,
|
2,
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import kotlin.properties.Delegates
|
|||||||
internal class FixtureTapestry : FixtureBase {
|
internal class FixtureTapestry : FixtureBase {
|
||||||
|
|
||||||
@Transient override val spawnNeedsWall = true
|
@Transient override val spawnNeedsWall = true
|
||||||
|
@Transient override val spawnNeedsFloor = false
|
||||||
|
|
||||||
var artName = ""; private set
|
var artName = ""; private set
|
||||||
var artAuthor = ""; private set
|
var artAuthor = ""; private set
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
|||||||
*/
|
*/
|
||||||
internal class FixtureTikiTorch : FixtureBase {
|
internal class FixtureTikiTorch : FixtureBase {
|
||||||
|
|
||||||
@Transient override val spawnNeedsFloor = true
|
|
||||||
|
|
||||||
private val rndHash1 = (Math.random() * 256).toInt()
|
private val rndHash1 = (Math.random() * 256).toInt()
|
||||||
private val rndHash2 = (Math.random() * 256).toInt()
|
private val rndHash2 = (Math.random() * 256).toInt()
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import kotlin.math.roundToInt
|
|||||||
*/
|
*/
|
||||||
class FixtureTypewriter : FixtureBase {
|
class FixtureTypewriter : FixtureBase {
|
||||||
|
|
||||||
@Transient override val spawnNeedsFloor = true
|
|
||||||
var typewriterKeymapName = "us_qwerty" // used to control the keyboard input behaviour
|
var typewriterKeymapName = "us_qwerty" // used to control the keyboard input behaviour
|
||||||
private set
|
private set
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
|||||||
class FixtureWallCalendar : FixtureBase {
|
class FixtureWallCalendar : FixtureBase {
|
||||||
|
|
||||||
@Transient override val spawnNeedsWall = true
|
@Transient override val spawnNeedsWall = true
|
||||||
|
@Transient override val spawnNeedsFloor = false
|
||||||
|
|
||||||
constructor() : super(
|
constructor() : super(
|
||||||
BlockBox(BlockBox.NO_COLLISION, 1, 1),
|
BlockBox(BlockBox.NO_COLLISION, 1, 1),
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
|||||||
*/
|
*/
|
||||||
class FixtureWorkbench : FixtureBase, CraftingStation {
|
class FixtureWorkbench : FixtureBase, CraftingStation {
|
||||||
|
|
||||||
@Transient override val spawnNeedsFloor = true
|
|
||||||
@Transient override val tags = listOf("basiccrafting")
|
@Transient override val tags = listOf("basiccrafting")
|
||||||
|
|
||||||
constructor() : super(
|
constructor() : super(
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
|||||||
*/
|
*/
|
||||||
class FixtureWorldPortal : Electric {
|
class FixtureWorldPortal : Electric {
|
||||||
|
|
||||||
@Transient override val spawnNeedsFloor = true
|
|
||||||
|
|
||||||
constructor() : super(
|
constructor() : super(
|
||||||
BlockBox(BlockBox.NO_COLLISION, 5, 2),
|
BlockBox(BlockBox.NO_COLLISION, 5, 2),
|
||||||
nameFun = { Lang["ITEM_WORLD_PORTAL"] },
|
nameFun = { Lang["ITEM_WORLD_PORTAL"] },
|
||||||
|
|||||||
Reference in New Issue
Block a user