1
1
package glm_.vec2
2
2
3
3
import glm_.*
4
- import glm_.vec2.operators.vec2_operators
4
+ import glm_.vec2.operators.opVec2
5
5
import glm_.vec3.Vec3bool
6
6
import glm_.vec3.Vec3t
7
7
import glm_.vec4.Vec4bool
@@ -63,7 +63,7 @@ class Vec2(x: Float, y: Float) : Vec2t<Float>(x, y) {
63
63
if (oneByteOneFloat) {
64
64
x = bytes[index].f
65
65
y = bytes[index + 1 ].f
66
- }else {
66
+ } else {
67
67
x = bytes.getFloat(index, bigEndian)
68
68
y = bytes.getFloat(index + Float .BYTES , bigEndian)
69
69
}
@@ -73,7 +73,7 @@ class Vec2(x: Float, y: Float) : Vec2t<Float>(x, y) {
73
73
if (oneByteOneFloat) {
74
74
x = bytes[index].f
75
75
y = bytes[index + 1 ].f
76
- }else {
76
+ } else {
77
77
x = bytes.getFloat(index)
78
78
y = bytes.getFloat(index + Float .BYTES )
79
79
}
@@ -113,7 +113,7 @@ class Vec2(x: Float, y: Float) : Vec2t<Float>(x, y) {
113
113
}
114
114
115
115
116
- companion object : vec2_operators {
116
+ companion object : opVec2() {
117
117
@JvmField
118
118
val length = 2
119
119
@JvmField
@@ -136,7 +136,7 @@ class Vec2(x: Float, y: Float) : Vec2t<Float>(x, y) {
136
136
}
137
137
138
138
infix fun to (bytes : ByteBuffer ) = to(bytes, bytes.position())
139
- fun to (bytes : ByteBuffer , offset : Int ):ByteBuffer {
139
+ fun to (bytes : ByteBuffer , offset : Int ): ByteBuffer {
140
140
bytes.putFloat(offset, x)
141
141
bytes.putFloat(offset + Float .BYTES , y)
142
142
return bytes
@@ -152,13 +152,14 @@ class Vec2(x: Float, y: Float) : Vec2t<Float>(x, y) {
152
152
// -- Increment main.and decrement operators --
153
153
154
154
operator fun inc () = plus(Vec2 (), this , 1f , 1f )
155
+
155
156
infix fun inc (res : Vec2 ) = plus(res, this , 1f , 1f )
156
- fun inc_ () = plus(this , this , 1f , 1f )
157
+ fun incAssign () = plus(this , this , 1f , 1f )
157
158
158
159
159
160
operator fun dec () = minus(Vec2 (), this , 1f , 1f )
160
161
infix fun dec (res : Vec2 ) = minus(res, this , 1f , 1f )
161
- fun dec_ () = minus(this , this , 1f , 1f )
162
+ fun decAssign () = minus(this , this , 1f , 1f )
162
163
163
164
// -- Specific binary arithmetic operators --
164
165
@@ -171,9 +172,14 @@ class Vec2(x: Float, y: Float) : Vec2t<Float>(x, y) {
171
172
fun plus (b : Float , res : Vec2 ) = plus(res, this , b, b)
172
173
fun plus (b : Vec2 , res : Vec2 ) = plus(res, this , b.x, b.y)
173
174
174
- fun plus_ (bX : Float , bY : Float ) = plus(this , this , bX, bY)
175
- infix fun plus_ (b : Float ) = plus(this , this , b, b)
176
- infix fun plus_ (b : Vec2 ) = plus(this , this , b.x, b.y)
175
+ fun plusAssign (bX : Float , bY : Float ) = plus(this , this , bX, bY)
176
+ infix operator fun plusAssign (b : Float ) {
177
+ plus(this , this , b, b)
178
+ }
179
+
180
+ infix operator fun plusAssign (b : Vec2 ) {
181
+ plus(this , this , b.x, b.y)
182
+ }
177
183
178
184
179
185
infix operator fun minus (b : Float ) = minus(Vec2 (), this , b, b)
@@ -185,9 +191,14 @@ class Vec2(x: Float, y: Float) : Vec2t<Float>(x, y) {
185
191
fun minus (b : Float , res : Vec2 ) = minus(res, this , b, b)
186
192
fun minus (b : Vec2 , res : Vec2 ) = minus(res, this , b.x, b.y)
187
193
188
- fun minus_ (bX : Float , bY : Float ) = minus(this , this , bX, bY)
189
- infix fun minus_ (b : Float ) = minus(this , this , b, b)
190
- infix fun minus_ (b : Vec2 ) = minus(this , this , b.x, b.y)
194
+ fun minusAssign (bX : Float , bY : Float ) = minus(this , this , bX, bY)
195
+ infix operator fun minusAssign (b : Float ) {
196
+ minus(this , this , b, b)
197
+ }
198
+
199
+ infix operator fun minusAssign (b : Vec2 ) {
200
+ minus(this , this , b.x, b.y)
201
+ }
191
202
192
203
193
204
infix operator fun times (b : Float ) = times(Vec2 (), this , b, b)
@@ -199,9 +210,13 @@ class Vec2(x: Float, y: Float) : Vec2t<Float>(x, y) {
199
210
fun times (b : Float , res : Vec2 ) = times(res, this , b, b)
200
211
fun times (b : Vec2 , res : Vec2 ) = times(res, this , b.x, b.y)
201
212
202
- fun times_ (bX : Float , bY : Float ) = times(this , this , bX, bY)
203
- infix fun times_ (b : Float ) = times(this , this , b, b)
204
- infix fun times_ (b : Vec2 ) = times(this , this , b.x, b.y)
213
+ fun timesAssign (bX : Float , bY : Float ) = times(this , this , bX, bY)
214
+ infix operator fun timesAssign (b : Float ) {
215
+ times(this , this , b, b)
216
+ }
217
+ infix operator fun timesAssign (b : Vec2 ) {
218
+ times(this , this , b.x, b.y)
219
+ }
205
220
206
221
207
222
infix operator fun div (b : Float ) = div(Vec2 (), this , b, b)
@@ -213,9 +228,14 @@ class Vec2(x: Float, y: Float) : Vec2t<Float>(x, y) {
213
228
fun div (b : Float , res : Vec2 ) = div(res, this , b, b)
214
229
fun div (b : Vec2 , res : Vec2 ) = div(res, this , b.x, b.y)
215
230
216
- fun div_ (bX : Float , bY : Float ) = div(this , this , bX, bY)
217
- infix fun div_ (b : Float ) = div(this , this , b, b)
218
- infix fun div_ (b : Vec2 ) = div(this , this , b.x, b.y)
231
+ fun divAssign (bX : Float , bY : Float ) = div(this , this , bX, bY)
232
+ infix operator fun divAssign (b : Float ) {
233
+ div(this , this , b, b)
234
+ }
235
+
236
+ infix operator fun divAssign (b : Vec2 ) {
237
+ div(this , this , b.x, b.y)
238
+ }
219
239
220
240
221
241
infix operator fun rem (b : Float ) = rem(Vec2 (), this , b, b)
@@ -227,9 +247,14 @@ class Vec2(x: Float, y: Float) : Vec2t<Float>(x, y) {
227
247
fun rem (b : Float , res : Vec2 ) = rem(res, this , b, b)
228
248
fun rem (b : Vec2 , res : Vec2 ) = rem(res, this , b.x, b.y)
229
249
230
- fun rem_ (bX : Float , bY : Float ) = rem(this , this , bX, bY)
231
- infix fun rem_ (b : Float ) = rem(this , this , b, b)
232
- infix fun rem_ (b : Vec2 ) = rem(this , this , b.x, b.y)
250
+ fun remAssign (bX : Float , bY : Float ) = rem(this , this , bX, bY)
251
+ infix operator fun remAssign (b : Float ) {
252
+ rem(this , this , b, b)
253
+ }
254
+
255
+ infix operator fun remAssign (b : Vec2 ) {
256
+ rem(this , this , b.x, b.y)
257
+ }
233
258
234
259
235
260
// -- Generic binary arithmetic operators --
@@ -243,9 +268,14 @@ class Vec2(x: Float, y: Float) : Vec2t<Float>(x, y) {
243
268
fun plus (b : Number , res : Vec2 ) = plus(res, this , b.f, b.f)
244
269
fun plus (b : Vec2t <out Number >, res : Vec2 ) = plus(res, this , b.x.f, b.y.f)
245
270
246
- fun plus_ (bX : Number , bY : Number ) = plus(this , this , bX.f, bY.f)
247
- infix fun plus_ (b : Number ) = plus(this , this , b.f, b.f)
248
- infix fun plus_ (b : Vec2t <out Number >) = plus(this , this , b.x.f, b.y.f)
271
+ fun plusAssign (bX : Number , bY : Number ) = plus(this , this , bX.f, bY.f)
272
+ infix operator fun plusAssign (b : Number ) {
273
+ plus(this , this , b.f, b.f)
274
+ }
275
+
276
+ infix operator fun plusAssign (b : Vec2t <out Number >) {
277
+ plus(this , this , b.x.f, b.y.f)
278
+ }
249
279
250
280
251
281
infix operator fun minus (b : Number ) = minus(Vec2 (), this , b.f, b.f)
@@ -257,9 +287,14 @@ class Vec2(x: Float, y: Float) : Vec2t<Float>(x, y) {
257
287
fun minus (b : Number , res : Vec2 ) = minus(res, this , b.f, b.f)
258
288
fun minus (b : Vec2t <out Number >, res : Vec2 ) = minus(res, this , b.x.f, b.y.f)
259
289
260
- fun minus_ (bX : Number , bY : Number ) = minus(this , this , bX.f, bY.f)
261
- infix fun minus_ (b : Number ) = minus(this , this , b.f, b.f)
262
- infix fun minus_ (b : Vec2t <out Number >) = minus(this , this , b.x.f, b.y.f)
290
+ fun minusAssign (bX : Number , bY : Number ) = minus(this , this , bX.f, bY.f)
291
+ infix operator fun minusAssign (b : Number ) {
292
+ minus(this , this , b.f, b.f)
293
+ }
294
+
295
+ infix operator fun minusAssign (b : Vec2t <out Number >) {
296
+ minus(this , this , b.x.f, b.y.f)
297
+ }
263
298
264
299
265
300
infix operator fun times (b : Number ) = times(Vec2 (), this , b.f, b.f)
0 commit comments