Skip to content

Commit 03f3fac

Browse files
committed
to
1 parent 4c3a8b7 commit 03f3fac

34 files changed

+698
-199
lines changed

src/main/kotlin/glm_/vec1/Vec1.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,12 @@ class Vec1(x: Float) : Vec1t<Float>(x) {
8484
}
8585

8686
infix fun to(floats: FloatArray) = to(floats, 0)
87-
8887
fun to(floats: FloatArray, index: Int): FloatArray {
8988
floats[index] = x
9089
return floats
9190
}
9291

9392
infix fun to(floats: FloatBuffer) = to(floats, floats.position())
94-
9593
fun to(floats: FloatBuffer, index: Int): FloatBuffer {
9694
floats[index] = x
9795
return floats

src/main/kotlin/glm_/vec1/Vec1b.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package glm_.vec1
22

33
import glm_.BYTES
44
import glm_.b
5-
import glm_.set
65
import glm_.toByte
76
import glm_.vec2.Vec2bool
87
import glm_.vec2.Vec2t
@@ -62,6 +61,12 @@ class Vec1b(x: Byte) : Vec1t<Byte>(x) {
6261
return this
6362
}
6463

64+
infix fun to(bytes: ByteArray) = to(bytes, 0)
65+
fun to(bytes: ByteArray, index: Int): ByteArray {
66+
bytes[index] = x
67+
return bytes
68+
}
69+
6570
infix fun to(bytes: ByteBuffer) = to(bytes, bytes.position())
6671
fun to(bytes: ByteBuffer, index: Int): ByteBuffer = bytes.put(index, x)
6772

src/main/kotlin/glm_/vec1/Vec1i.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,12 @@ class Vec1i(x: Int) : Vec1t<Int>(x) {
8484
}
8585

8686
infix fun to(ints: IntArray) = to(ints, 0)
87-
8887
fun to(ints: IntArray, index: Int): IntArray {
8988
ints[index] = x
9089
return ints
9190
}
9291

9392
infix fun to(ints: IntBuffer) = to(ints, ints.position())
94-
9593
fun to(ints: IntBuffer, index: Int): IntBuffer {
9694
ints[index] = x
9795
return ints

src/main/kotlin/glm_/vec2/Vec2.kt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,28 +111,25 @@ class Vec2(x: Float, y: Float) : Vec2t<Float>(x, y) {
111111
}
112112

113113

114-
// TODO others
115114
infix fun to(floats: FloatArray) = to(floats, 0)
116-
117115
fun to(floats: FloatArray, index: Int): FloatArray {
118116
floats[index] = x
119117
floats[index + 1] = y
120118
return floats
121119
}
122120

123121
infix fun to(floats: FloatBuffer) = to(floats, 0)
124-
125122
fun to(floats: FloatBuffer, index: Int): FloatBuffer {
126123
floats[index] = x
127124
floats[index + 1] = y
128125
return floats
129126
}
130127

131128
infix fun to(bytes: ByteBuffer) = to(bytes, bytes.position())
132-
133-
fun to(bytes: ByteBuffer, offset: Int) {
129+
fun to(bytes: ByteBuffer, offset: Int):ByteBuffer {
134130
bytes.putFloat(offset, x)
135131
bytes.putFloat(offset + Float.BYTES, y)
132+
return bytes
136133
}
137134

138135

src/main/kotlin/glm_/vec2/Vec2b.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,21 @@ class Vec2b(x: Byte, y: Byte) : Vec2t<Byte>(x, y) {
6969
}
7070

7171

72+
infix fun to(bytes: ByteArray) = to(bytes, 0)
73+
fun to(bytes: ByteArray, index: Int): ByteArray {
74+
bytes[index] = x
75+
bytes[index + 1] = y
76+
return bytes
77+
}
78+
79+
infix fun to(bytes: ByteBuffer) = to(bytes, bytes.position())
80+
fun to(bytes: ByteBuffer, offset: Int):ByteBuffer {
81+
bytes.put(offset, x)
82+
bytes.put(offset + Byte.BYTES, y)
83+
return bytes
84+
}
85+
86+
7287
// -- Component accesses --
7388

7489
override operator fun get(i: Int) = when (i) {

src/main/kotlin/glm_/vec2/Vec2d.kt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,28 @@ class Vec2d(x: Double, y: Double) : Vec2t<Double>(x, y) {
8383
}
8484

8585

86+
infix fun to(doubles: DoubleArray) = to(doubles, 0)
87+
fun to(doubles: DoubleArray, index: Int): DoubleArray {
88+
doubles[index] = x
89+
doubles[index + 1] = y
90+
return doubles
91+
}
92+
93+
infix fun to(doubles: DoubleBuffer) = to(doubles, 0)
94+
fun to(doubles: DoubleBuffer, index: Int): DoubleBuffer {
95+
doubles[index] = x
96+
doubles[index + 1] = y
97+
return doubles
98+
}
99+
100+
infix fun to(bytes: ByteBuffer) = to(bytes, bytes.position())
101+
fun to(bytes: ByteBuffer, offset: Int): ByteBuffer {
102+
bytes.putDouble(offset, x)
103+
bytes.putDouble(offset + Double.BYTES, y)
104+
return bytes
105+
}
106+
107+
86108
// -- Component accesses --
87109

88110
override operator fun get(i: Int) = when (i) {

src/main/kotlin/glm_/vec2/Vec2i.kt

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,28 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
8484
}
8585

8686

87+
infix fun to(ints: IntArray) = to(ints, 0)
88+
fun to(ints: IntArray, index: Int): IntArray {
89+
ints[index] = x
90+
ints[index + 1] = y
91+
return ints
92+
}
93+
94+
infix fun to(ints: IntBuffer) = to(ints, 0)
95+
fun to(ints: IntBuffer, index: Int): IntBuffer {
96+
ints[index] = x
97+
ints[index + 1] = y
98+
return ints
99+
}
100+
101+
infix fun to(bytes: ByteBuffer) = to(bytes, bytes.position())
102+
fun to(bytes: ByteBuffer, offset: Int): ByteBuffer {
103+
bytes.putInt(offset, x)
104+
bytes.putInt(offset + Int.BYTES, y)
105+
return bytes
106+
}
107+
108+
87109
// -- Component accesses --
88110

89111
override operator fun get(i: Int) = when (i) {
@@ -104,30 +126,6 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
104126
else -> throw ArrayIndexOutOfBoundsException()
105127
}
106128

107-
// TODO others
108-
infix fun to(ints: IntArray) = to(ints, 0)
109-
110-
fun to(ints: IntArray, index: Int): IntArray {
111-
ints[index] = x
112-
ints[index + 1] = y
113-
return ints
114-
}
115-
116-
infix fun to(ints: IntBuffer) = to(ints, 0)
117-
118-
fun to(ints: IntBuffer, index: Int): IntBuffer {
119-
ints[index] = x
120-
ints[index + 1] = y
121-
return ints
122-
}
123-
124-
infix fun to(bytes: ByteBuffer) = to(bytes, bytes.position())
125-
126-
fun to(bytes: ByteBuffer, offset: Int) {
127-
bytes.putInt(offset, x)
128-
bytes.putInt(offset + Int.BYTES, y)
129-
}
130-
131129
// TODO
132130
fun comptimes() = x * y
133131

src/main/kotlin/glm_/vec2/Vec2l.kt

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package glm_.vec2
22

3-
import glm_.BYTES
4-
import glm_.L
5-
import glm_.toLong
6-
import glm_.getLong
3+
import glm_.*
74
import glm_.vec2.operators.vec2l_operators
85
import glm_.vec3.Vec3bool
96
import glm_.vec3.Vec3t
@@ -86,6 +83,28 @@ class Vec2l(x: Long, y: Long) : Vec2t<Long>(x, y) {
8683
}
8784

8885

86+
infix fun to(longs: LongArray) = to(longs, 0)
87+
fun to(longs: LongArray, index: Int): LongArray {
88+
longs[index] = x
89+
longs[index + 1] = y
90+
return longs
91+
}
92+
93+
infix fun to(longs: LongBuffer) = to(longs, 0)
94+
fun to(longs: LongBuffer, index: Int): LongBuffer {
95+
longs[index] = x
96+
longs[index + 1] = y
97+
return longs
98+
}
99+
100+
infix fun to(bytes: ByteBuffer) = to(bytes, bytes.position())
101+
fun to(bytes: ByteBuffer, offset: Int): ByteBuffer {
102+
bytes.putLong(offset, x)
103+
bytes.putLong(offset + Long.BYTES, y)
104+
return bytes
105+
}
106+
107+
89108
// -- Component accesses --
90109

91110
override operator fun get(i: Int) = when (i) {

src/main/kotlin/glm_/vec2/Vec2s.kt

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package glm_.vec2
22

3-
import glm_.BYTES
4-
import glm_.getShort
5-
import glm_.s
6-
import glm_.toShort
3+
import glm_.*
74
import glm_.vec2.operators.vec2s_operators
85
import glm_.vec3.Vec3bool
96
import glm_.vec3.Vec3t
@@ -86,6 +83,28 @@ class Vec2s(x: Short, y: Short) : Vec2t<Short>(x, y) {
8683
}
8784

8885

86+
infix fun to(shorts: ShortArray) = to(shorts, 0)
87+
fun to(shorts: ShortArray, index: Int): ShortArray {
88+
shorts[index] = x
89+
shorts[index + 1] = y
90+
return shorts
91+
}
92+
93+
infix fun to(floats: ShortBuffer) = to(floats, 0)
94+
fun to(shorts: ShortBuffer, index: Int): ShortBuffer {
95+
shorts[index] = x
96+
shorts[index + 1] = y
97+
return shorts
98+
}
99+
100+
infix fun to(bytes: ByteBuffer) = to(bytes, bytes.position())
101+
fun to(bytes: ByteBuffer, offset: Int): ByteBuffer {
102+
bytes.putShort(offset, x)
103+
bytes.putShort(offset + Short.BYTES, y)
104+
return bytes
105+
}
106+
107+
89108
// -- Component accesses --
90109

91110
override operator fun get(i: Int) = when (i) {

src/main/kotlin/glm_/vec2/Vec2ub.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,21 @@ class Vec2ub(x: Ubyte, y: Ubyte) : Vec2t<Ubyte>(x, y) {
6161
}
6262

6363

64+
infix fun to(bytes: ByteArray) = to(bytes, 0)
65+
fun to(bytes: ByteArray, index: Int): ByteArray {
66+
bytes[index] = x.v
67+
bytes[index + 1] = y.v
68+
return bytes
69+
}
70+
71+
infix fun to(bytes: ByteBuffer) = to(bytes, bytes.position())
72+
fun to(bytes: ByteBuffer, offset: Int): ByteBuffer {
73+
bytes.put(offset, x.v)
74+
bytes.put(offset + Byte.BYTES, y.v)
75+
return bytes
76+
}
77+
78+
6479
// -- Component accesses --
6580

6681
override operator fun get(i: Int) = when (i) {

0 commit comments

Comments
 (0)