1
1
package glm_.vec2
2
2
3
3
import glm_.*
4
- import glm_.vec2.operators.vec2i_operators
4
+ import glm_.vec2.operators.opVec2i
5
5
import glm_.vec3.Vec3bool
6
6
import glm_.vec3.Vec3t
7
7
import glm_.vec4.Vec4bool
@@ -130,7 +130,7 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
130
130
fun comptimes () = x * y
131
131
132
132
133
- companion object : vec2i_operators {
133
+ companion object : opVec2i() {
134
134
@JvmField
135
135
val length = 2
136
136
@JvmField
@@ -148,12 +148,12 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
148
148
149
149
operator fun inc () = plus(Vec2i (), this , 1 , 1 )
150
150
infix fun inc (res : Vec2i ) = plus(res, this , 1 , 1 )
151
- fun inc_ () = plus(this , this , 1 , 1 )
151
+ fun incAssign () = plus(this , this , 1 , 1 )
152
152
153
153
154
154
operator fun dec () = minus(Vec2i (), this , 1 , 1 )
155
155
infix fun dec (res : Vec2i ) = minus(res, this , 1 , 1 )
156
- fun dec_ () = minus(this , this , 1 , 1 )
156
+ fun decAssign () = minus(this , this , 1 , 1 )
157
157
158
158
159
159
// -- Specific binary arithmetic operators --
@@ -167,9 +167,13 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
167
167
fun plus (b : Int , res : Vec2i ) = plus(res, this , b, b)
168
168
fun plus (b : Vec2i , res : Vec2i ) = plus(res, this , b.x, b.y)
169
169
170
- fun plus_ (bX : Int , bY : Int ) = plus(this , this , bX, bY)
171
- infix fun plus_ (b : Int ) = plus(this , this , b, b)
172
- infix fun plus_ (b : Vec2i ) = plus(this , this , b.x, b.y)
170
+ fun plusAssign (bX : Int , bY : Int ) = plus(this , this , bX, bY)
171
+ infix operator fun plusAssign (b : Int ) {
172
+ plus(this , this , b, b)
173
+ }
174
+ infix operator fun plusAssign (b : Vec2i ) {
175
+ plus(this , this , b.x, b.y)
176
+ }
173
177
174
178
175
179
infix operator fun minus (b : Int ) = minus(Vec2i (), this , b, b)
@@ -181,9 +185,13 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
181
185
fun minus (b : Int , res : Vec2i ) = minus(res, this , b, b)
182
186
fun minus (b : Vec2i , res : Vec2i ) = minus(res, this , b.x, b.y)
183
187
184
- fun minus_ (bX : Int , bY : Int ) = minus(this , this , bX, bY)
185
- infix fun minus_ (b : Int ) = minus(this , this , b, b)
186
- infix fun minus_ (b : Vec2i ) = minus(this , this , b.x, b.y)
188
+ fun minusAssign (bX : Int , bY : Int ) = minus(this , this , bX, bY)
189
+ infix operator fun minusAssign (b : Int ) {
190
+ minus(this , this , b, b)
191
+ }
192
+ infix operator fun minusAssign (b : Vec2i ) {
193
+ minus(this , this , b.x, b.y)
194
+ }
187
195
188
196
189
197
infix operator fun times (b : Int ) = times(Vec2i (), this , b, b)
@@ -195,9 +203,13 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
195
203
fun times (b : Int , res : Vec2i ) = times(res, this , b, b)
196
204
fun times (b : Vec2i , res : Vec2i ) = times(res, this , b.x, b.y)
197
205
198
- fun times_ (bX : Int , bY : Int ) = times(this , this , bX, bY)
199
- infix fun times_ (b : Int ) = times(this , this , b, b)
200
- infix fun times_ (b : Vec2i ) = times(this , this , b.x, b.y)
206
+ fun timesAssign (bX : Int , bY : Int ) = times(this , this , bX, bY)
207
+ infix operator fun timesAssign (b : Int ) {
208
+ times(this , this , b, b)
209
+ }
210
+ infix operator fun timesAssign (b : Vec2i ) {
211
+ times(this , this , b.x, b.y)
212
+ }
201
213
202
214
203
215
infix operator fun div (b : Int ) = div(Vec2i (), this , b, b)
@@ -209,9 +221,13 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
209
221
fun div (b : Int , res : Vec2i ) = div(res, this , b, b)
210
222
fun div (b : Vec2i , res : Vec2i ) = div(res, this , b.x, b.y)
211
223
212
- fun div_ (bX : Int , bY : Int ) = div(this , this , bX, bY)
213
- infix fun div_ (b : Int ) = div(this , this , b, b)
214
- infix fun div_ (b : Vec2i ) = div(this , this , b.x, b.y)
224
+ fun divAssign (bX : Int , bY : Int ) = div(this , this , bX, bY)
225
+ infix operator fun divAssign (b : Int ) {
226
+ div(this , this , b, b)
227
+ }
228
+ infix operator fun divAssign (b : Vec2i ) {
229
+ div(this , this , b.x, b.y)
230
+ }
215
231
216
232
217
233
infix operator fun rem (b : Int ) = rem(Vec2i (), this , b, b)
@@ -223,9 +239,13 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
223
239
fun rem (b : Int , res : Vec2i ) = rem(res, this , b, b)
224
240
fun rem (b : Vec2i , res : Vec2i ) = rem(res, this , b.x, b.y)
225
241
226
- fun rem_ (bX : Int , bY : Int ) = rem(this , this , bX, bY)
227
- infix fun rem_ (b : Int ) = rem(this , this , b, b)
228
- infix fun rem_ (b : Vec2i ) = rem(this , this , b.x, b.y)
242
+ fun remAssign (bX : Int , bY : Int ) = rem(this , this , bX, bY)
243
+ infix operator fun remAssign (b : Int ) {
244
+ rem(this , this , b, b)
245
+ }
246
+ infix operator fun remAssign (b : Vec2i ) {
247
+ rem(this , this , b.x, b.y)
248
+ }
229
249
230
250
231
251
// -- Generic binary arithmetic operators --
@@ -239,9 +259,13 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
239
259
fun plus (b : Number , res : Vec2i ) = plus(res, this , b.i, b.i)
240
260
fun plus (b : Vec2t <out Number >, res : Vec2i ) = plus(res, this , b.x.i, b.y.i)
241
261
242
- fun plus_ (bX : Number , bY : Number ) = plus(this , this , bX.i, bY.i)
243
- infix fun plus_ (b : Number ) = plus(this , this , b.i, b.i)
244
- infix fun plus_ (b : Vec2t <out Number >) = plus(this , this , b.x.i, b.y.i)
262
+ fun plusAssign (bX : Number , bY : Number ) = plus(this , this , bX.i, bY.i)
263
+ infix operator fun plusAssign (b : Number ) {
264
+ plus(this , this , b.i, b.i)
265
+ }
266
+ infix operator fun plusAssign (b : Vec2t <out Number >) {
267
+ plus(this , this , b.x.i, b.y.i)
268
+ }
245
269
246
270
247
271
infix operator fun minus (b : Number ) = minus(Vec2i (), this , b.i, b.i)
@@ -253,9 +277,13 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
253
277
fun minus (b : Number , res : Vec2i ) = minus(res, this , b.i, b.i)
254
278
fun minus (b : Vec2t <out Number >, res : Vec2i ) = minus(res, this , b.x.i, b.y.i)
255
279
256
- fun minus_ (bX : Number , bY : Number ) = minus(this , this , bX.i, bY.i)
257
- infix fun minus_ (b : Number ) = minus(this , this , b.i, b.i)
258
- infix fun minus_ (b : Vec2t <out Number >) = minus(this , this , b.x.i, b.y.i)
280
+ fun minusAssign (bX : Number , bY : Number ) = minus(this , this , bX.i, bY.i)
281
+ infix operator fun minusAssign (b : Number ) {
282
+ minus(this , this , b.i, b.i)
283
+ }
284
+ infix operator fun minusAssign (b : Vec2t <out Number >) {
285
+ minus(this , this , b.x.i, b.y.i)
286
+ }
259
287
260
288
261
289
infix operator fun times (b : Number ) = times(Vec2i (), this , b.i, b.i)
@@ -267,9 +295,13 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
267
295
fun times (b : Number , res : Vec2i ) = times(res, this , b.i, b.i)
268
296
fun times (b : Vec2t <out Number >, res : Vec2i ) = times(res, this , b.x.i, b.y.i)
269
297
270
- fun times_ (bX : Number , bY : Number ) = times(this , this , bX.i, bY.i)
271
- infix fun times_ (b : Number ) = times(this , this , b.i, b.i)
272
- infix fun times_ (b : Vec2t <out Number >) = times(this , this , b.x.i, b.y.i)
298
+ fun timesAssign (bX : Number , bY : Number ) = times(this , this , bX.i, bY.i)
299
+ infix operator fun timesAssign (b : Number ) {
300
+ times(this , this , b.i, b.i)
301
+ }
302
+ infix operator fun timesAssign (b : Vec2t <out Number >) {
303
+ times(this , this , b.x.i, b.y.i)
304
+ }
273
305
274
306
275
307
infix operator fun div (b : Number ) = div(Vec2i (), this , b.i, b.i)
@@ -281,9 +313,13 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
281
313
fun div (b : Number , res : Vec2i ) = div(res, this , b.i, b.i)
282
314
fun div (b : Vec2t <out Number >, res : Vec2i ) = div(res, this , b.x.i, b.y.i)
283
315
284
- fun div_ (bX : Number , bY : Number ) = div(this , this , bX.i, bY.i)
285
- infix fun div_ (b : Number ) = div(this , this , b.i, b.i)
286
- infix fun div_ (b : Vec2t <out Number >) = div(this , this , b.x.i, b.y.i)
316
+ fun divAssign (bX : Number , bY : Number ) = div(this , this , bX.i, bY.i)
317
+ infix operator fun divAssign (b : Number ) {
318
+ div(this , this , b.i, b.i)
319
+ }
320
+ infix operator fun divAssign (b : Vec2t <out Number >) {
321
+ div(this , this , b.x.i, b.y.i)
322
+ }
287
323
288
324
289
325
infix operator fun rem (b : Number ) = rem(Vec2i (), this , b.i, b.i)
@@ -295,9 +331,13 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
295
331
fun rem (b : Number , res : Vec2i ) = rem(res, this , b.i, b.i)
296
332
fun rem (b : Vec2t <out Number >, res : Vec2i ) = rem(res, this , b.x.i, b.y.i)
297
333
298
- fun rem_ (bX : Number , bY : Number ) = rem(this , this , bX.i, bY.i)
299
- infix fun rem_ (b : Number ) = rem(this , this , b.i, b.i)
300
- infix fun rem_ (b : Vec2t <out Number >) = rem(this , this , b.x.i, b.y.i)
334
+ fun remAssign (bX : Number , bY : Number ) = rem(this , this , bX.i, bY.i)
335
+ infix operator fun remAssign (b : Number ) {
336
+ rem(this , this , b.i, b.i)
337
+ }
338
+ infix operator fun remAssign (b : Vec2t <out Number >) {
339
+ rem(this , this , b.x.i, b.y.i)
340
+ }
301
341
302
342
303
343
// -- Specific bitwise operators --
@@ -310,9 +350,9 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
310
350
@JvmOverloads
311
351
fun and (bX : Int , bY : Int , res : Vec2i = Vec2i ()) = and (res, this , bX, bY)
312
352
313
- infix fun and_ (b : Int ) = and (this , this , b, b)
314
- infix fun and_ (b : Vec2i ) = and (this , this , b.x, b.y)
315
- fun and_ (bX : Int , bY : Int ) = and (this , this , bX, bY)
353
+ infix fun andAssign (b : Int ) = and (this , this , b, b)
354
+ infix fun andAssign (b : Vec2i ) = and (this , this , b.x, b.y)
355
+ fun andAssign (bX : Int , bY : Int ) = and (this , this , bX, bY)
316
356
317
357
318
358
infix fun or (b : Int ) = or (Vec2i (), this , b, b)
@@ -323,9 +363,9 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
323
363
@JvmOverloads
324
364
fun or (bX : Int , bY : Int , res : Vec2i = Vec2i ()) = or (res, this , bX, bY)
325
365
326
- infix fun or_ (b : Int ) = or (this , this , b, b)
327
- infix fun or_ (b : Vec2i ) = or (this , this , b.x, b.y)
328
- fun or_ (bX : Int , bY : Int ) = or (this , this , bX, bY)
366
+ infix fun orAssign (b : Int ) = or (this , this , b, b)
367
+ infix fun orAssign (b : Vec2i ) = or (this , this , b.x, b.y)
368
+ fun orAssign (bX : Int , bY : Int ) = or (this , this , bX, bY)
329
369
330
370
331
371
infix fun xor (b : Int ) = xor(Vec2i (), this , b, b)
@@ -336,9 +376,9 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
336
376
@JvmOverloads
337
377
fun xor (bX : Int , bY : Int , res : Vec2i = Vec2i ()) = xor(res, this , bX, bY)
338
378
339
- infix fun xor_ (b : Int ) = xor(this , this , b, b)
340
- infix fun xor_ (b : Vec2i ) = xor(this , this , b.x, b.y)
341
- fun xor_ (bX : Int , bY : Int ) = xor(this , this , bX, bY)
379
+ infix fun xorAssign (b : Int ) = xor(this , this , b, b)
380
+ infix fun xorAssign (b : Vec2i ) = xor(this , this , b.x, b.y)
381
+ fun xorAssign (bX : Int , bY : Int ) = xor(this , this , bX, bY)
342
382
343
383
344
384
infix fun shl (b : Int ) = shl(Vec2i (), this , b, b)
@@ -349,9 +389,9 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
349
389
@JvmOverloads
350
390
fun shl (bX : Int , bY : Int , res : Vec2i = Vec2i ()) = shl(res, this , bX, bY)
351
391
352
- infix fun shl_ (b : Int ) = shl(this , this , b, b)
353
- infix fun shl_ (b : Vec2i ) = shl(this , this , b.x, b.y)
354
- fun shl_ (bX : Int , bY : Int ) = shl(this , this , bX, bY)
392
+ infix fun shlAssign (b : Int ) = shl(this , this , b, b)
393
+ infix fun shlAssign (b : Vec2i ) = shl(this , this , b.x, b.y)
394
+ fun shlAssign (bX : Int , bY : Int ) = shl(this , this , bX, bY)
355
395
356
396
357
397
infix fun shr (b : Int ) = shr(Vec2i (), this , b, b)
@@ -362,9 +402,9 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
362
402
@JvmOverloads
363
403
fun shr (bX : Int , bY : Int , res : Vec2i = Vec2i ()) = shr(res, this , bX, bY)
364
404
365
- infix fun shr_ (b : Int ) = shr(this , this , b, b)
366
- infix fun shr_ (b : Vec2i ) = shr(this , this , b.x, b.y)
367
- fun shr_ (bX : Int , bY : Int ) = shr(this , this , bX, bY)
405
+ infix fun shrAssign (b : Int ) = shr(this , this , b, b)
406
+ infix fun shrAssign (b : Vec2i ) = shr(this , this , b.x, b.y)
407
+ fun shrAssign (bX : Int , bY : Int ) = shr(this , this , bX, bY)
368
408
369
409
370
410
// TODO fill & others
@@ -374,7 +414,7 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
374
414
@JvmOverloads
375
415
fun inv (res : Vec2i = Vec2i ()) = inv (res, this )
376
416
377
- fun inv_ () = inv (this , this )
417
+ fun invAssign () = inv (this , this )
378
418
379
419
380
420
// -- Generic bitwise operators --
@@ -387,9 +427,9 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
387
427
@JvmOverloads
388
428
fun and (bX : Number , bY : Number , res : Vec2i = Vec2i ()) = and (res, this , bX.i, bY.i)
389
429
390
- infix fun and_ (b : Number ) = and (this , this , b.i, b.i)
391
- infix fun and_ (b : Vec2t <out Number >) = and (this , this , b.x.i, b.y.i)
392
- fun and_ (bX : Number , bY : Number ) = and (this , this , bX.i, bY.i)
430
+ infix fun andAssign (b : Number ) = and (this , this , b.i, b.i)
431
+ infix fun andAssign (b : Vec2t <out Number >) = and (this , this , b.x.i, b.y.i)
432
+ fun andAssign (bX : Number , bY : Number ) = and (this , this , bX.i, bY.i)
393
433
394
434
395
435
infix fun or (b : Number ) = or (Vec2i (), this , b.i, b.i)
@@ -400,9 +440,9 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
400
440
@JvmOverloads
401
441
fun or (bX : Number , bY : Number , res : Vec2i = Vec2i ()) = or (res, this , bX.i, bY.i)
402
442
403
- infix fun or_ (b : Number ) = or (this , this , b.i, b.i)
404
- infix fun or_ (b : Vec2t <out Number >) = or (this , this , b.x.i, b.y.i)
405
- fun or_ (bX : Number , bY : Number ) = or (this , this , bX.i, bY.i)
443
+ infix fun orAssign (b : Number ) = or (this , this , b.i, b.i)
444
+ infix fun orAssign (b : Vec2t <out Number >) = or (this , this , b.x.i, b.y.i)
445
+ fun orAssign (bX : Number , bY : Number ) = or (this , this , bX.i, bY.i)
406
446
407
447
408
448
infix fun xor (b : Number ) = xor(Vec2i (), this , b.i, b.i)
@@ -413,9 +453,9 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
413
453
@JvmOverloads
414
454
fun xor (bX : Number , bY : Number , res : Vec2i = Vec2i ()) = xor(res, this , bX.i, bY.i)
415
455
416
- infix fun xor_ (b : Number ) = xor(this , this , b.i, b.i)
417
- infix fun xor_ (b : Vec2t <out Number >) = xor(this , this , b.x.i, b.y.i)
418
- fun xor_ (bX : Number , bY : Number ) = xor(this , this , bX.i, bY.i)
456
+ infix fun xorAssign (b : Number ) = xor(this , this , b.i, b.i)
457
+ infix fun xorAssign (b : Vec2t <out Number >) = xor(this , this , b.x.i, b.y.i)
458
+ fun xorAssign (bX : Number , bY : Number ) = xor(this , this , bX.i, bY.i)
419
459
420
460
421
461
infix fun shl (b : Number ) = shl(Vec2i (), this , b.i, b.i)
@@ -426,9 +466,9 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
426
466
@JvmOverloads
427
467
fun shl (bX : Number , bY : Number , res : Vec2i = Vec2i ()) = shl(res, this , bX.i, bY.i)
428
468
429
- infix fun shl_ (b : Number ) = shl(this , this , b.i, b.i)
430
- infix fun shl_ (b : Vec2t <out Number >) = shl(this , this , b.x.i, b.y.i)
431
- fun shl_ (bX : Number , bY : Number ) = shl(this , this , bX.i, bY.i)
469
+ infix fun shlAssign (b : Number ) = shl(this , this , b.i, b.i)
470
+ infix fun shlAssign (b : Vec2t <out Number >) = shl(this , this , b.x.i, b.y.i)
471
+ fun shlAssign (bX : Number , bY : Number ) = shl(this , this , bX.i, bY.i)
432
472
433
473
434
474
infix fun shr (b : Number ) = shr(Vec2i (), this , b.i, b.i)
@@ -439,9 +479,9 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
439
479
@JvmOverloads
440
480
fun shr (bX : Number , bY : Number , res : Vec2i = Vec2i ()) = shr(res, this , bX.i, bY.i)
441
481
442
- infix fun shr_ (b : Number ) = shr(this , this , b.i, b.i)
443
- infix fun shr_ (b : Vec2t <out Number >) = shr(this , this , b.x.i, b.y.i)
444
- fun shr_ (bX : Number , bY : Number ) = shr(this , this , bX.i, bY.i)
482
+ infix fun shrAssign (b : Number ) = shr(this , this , b.i, b.i)
483
+ infix fun shrAssign (b : Vec2t <out Number >) = shr(this , this , b.x.i, b.y.i)
484
+ fun shrAssign (bX : Number , bY : Number ) = shr(this , this , bX.i, bY.i)
445
485
446
486
447
487
infix fun lessThan (i : Int ) = x < i && y < i
@@ -451,6 +491,7 @@ class Vec2i(x: Int, y: Int) : Vec2t<Int>(x, y) {
451
491
infix fun greaterThan (i : Int ) = x > i && y > i
452
492
infix fun greaterThanEqual (i : Int ) = x >= i && y >= i
453
493
494
+
454
495
override fun equals (other : Any? ) = other is Vec2i && this [0 ] == other[0 ] && this [1 ] == other[1 ]
455
496
override fun hashCode () = 31 * x.hashCode() + y.hashCode()
456
497
}
0 commit comments