if is an expression; use that

This commit is contained in:
Fingercomp 2025-08-03 22:36:37 +03:00
parent c06b048393
commit d1d2deddff
No known key found for this signature in database
GPG Key ID: BBC71CEE45D86E37

View File

@ -11,11 +11,9 @@ trait PositionalSoundSourcesNode extends Node {
override def update(): Unit = {
super.update()
var soundPosition: Vector3D = null
// Calculating position of sound source relative to center of workspace
// but only if corresponding setting is enabled
if (Settings.get.soundPositional) {
val soundPosition = if (Settings.get.soundPositional) {
val rootWidthHalf = OcelotDesktop.root.width / 2
val rootHeightHalf = OcelotDesktop.root.height / 2
@ -26,13 +24,13 @@ trait PositionalSoundSourcesNode extends Node {
// large monitors the sound may become too "non-audiophile"
val limit = 0.05f
soundPosition = Vector3D(
Vector3D(
(nodeCenterX - rootWidthHalf) / rootWidthHalf * limit,
(nodeCenterY - rootHeightHalf) / rootHeightHalf * limit,
0,
)
} else {
soundPosition = Vector3D.Zero
Vector3D.Zero
}
for (soundSource <- soundSources)