1
+ package glm_.vec1
2
+
3
+ import glm_.BYTES
4
+ import glm_.b
5
+ import glm_.i
6
+ import glm_.vec2.Vec2bool
7
+ import glm_.vec2.Vec2t
8
+ import glm_.vec3.Vec3bool
9
+ import glm_.vec3.Vec3t
10
+ import glm_.vec4.Vec4bool
11
+ import glm_.vec4.Vec4t
12
+ import java.nio.*
13
+
14
+ class Vec1b (x : Byte ) : Vec1t<Byte>(x) {
15
+
16
+ // -- Explicit basic, conversion other main.and conversion vector constructors --
17
+
18
+ constructor () : this (0 )
19
+
20
+ constructor (v: Vec2t <out Number >) : this (v.x)
21
+ constructor (v: Vec3t <out Number >) : this (v.x)
22
+ constructor (v: Vec4t <out Number >) : this (v.x)
23
+
24
+ constructor (v: Vec2bool ) : this (v.x.b)
25
+ constructor (v: Vec3bool ) : this (v.x.b)
26
+ constructor (v: Vec4bool ) : this (v.x.b)
27
+
28
+ constructor (bytes: ByteArray , index: Int = 0 ) : this (bytes[index])
29
+ constructor (chars: CharArray , index: Int = 0 ) : this (chars[index].b)
30
+ constructor (shorts: ShortArray , index: Int = 0 ) : this (shorts[index])
31
+ constructor (ints: IntArray , index: Int = 0 ) : this (ints[index])
32
+ constructor (longs: LongArray , index: Int = 0 ) : this (longs[index])
33
+ constructor (floats: FloatArray , index: Int = 0 ) : this (floats[index])
34
+ constructor (doubles: DoubleArray , index: Int = 0 ) : this (doubles[index])
35
+ constructor (booleans: BooleanArray , index: Int = 0 ) : this (booleans[index].b)
36
+
37
+ constructor (numbers: Array <out Number >, index: Int = 0 ) : this (numbers[index])
38
+ constructor (chars: Array <Char >, index: Int = 0 ) : this (chars[index].b)
39
+ constructor (booleans: Array <Boolean >, index: Int = 0 ) : this (booleans[index].b)
40
+
41
+ constructor (list: List <Any >, index: Int = 0 ) : this (list[index].b)
42
+
43
+ constructor (bytes: ByteBuffer , index: Int = bytes.position()) : this (bytes[index])
44
+ constructor (chars: CharBuffer , index: Int = chars.position()) : this (chars[index].b)
45
+ constructor (shorts: ShortBuffer , index: Int = shorts.position()) : this (shorts[index])
46
+ constructor (ints: IntBuffer , index: Int = ints.position()) : this (ints[index])
47
+ constructor (longs: LongBuffer , index: Int = longs.position()) : this (longs[index])
48
+ constructor (floats: FloatBuffer , index: Int = floats.position()) : this (floats[index])
49
+ constructor (doubles: DoubleBuffer , index: Int = doubles.position()) : this (doubles[index])
50
+
51
+ constructor (x: Number ) : this (x.b)
52
+
53
+
54
+ fun put (x : Byte , y : Byte ): Vec1b {
55
+ this .x = x
56
+ return this
57
+ }
58
+
59
+ override fun put (x : Number ): Vec1b {
60
+ this .x = x.b
61
+ return this
62
+ }
63
+
64
+
65
+ // -- Component accesses --
66
+
67
+ operator fun get (i : Int ) = when (i) {
68
+ 0 -> x
69
+ else -> throw ArrayIndexOutOfBoundsException ()
70
+ }
71
+
72
+ operator fun set (i : Int , s : Byte ) = when (i) {
73
+ 0 -> x = s
74
+ else -> throw ArrayIndexOutOfBoundsException ()
75
+ }
76
+
77
+ operator fun set (i : Int , s : Number ) = when (i) {
78
+ 0 -> x = s.b
79
+ else -> throw ArrayIndexOutOfBoundsException ()
80
+ }
81
+ }
0 commit comments