Files
blitz-kt/src/main/kotlin/blitz/math/Vec4s.kt
2025-09-22 13:02:35 +02:00

26 lines
880 B
Kotlin

package blitz.math
import blitz.annotations.Immutable
@Immutable
@JvmInline
@Suppress("NOTHING_TO_INLINE")
value class Vec4s(val packed: ULong) {
inline val x: Short get() = (packed shr 48).toUShort().toShort()
inline val y: Short get() = (packed shr 32).toUShort().toShort()
inline val z: Short get() = (packed shr 16).toUShort().toShort()
inline val w: Short get() = packed.toUShort().toShort()
constructor(x: Short, y: Short, z: Short, w: Short): this(
(x.toUShort().toULong() shl 48) or
(y.toUShort().toULong() shl 32) or
(z.toUShort().toULong() shl 16) or
w.toUShort().toULong())
override fun toString() = "($x, $y, $z, $w)"
inline operator fun component1() = x
inline operator fun component2() = y
inline operator fun component3() = z
inline operator fun component4() = w
}