Skip to content

Commit 181d3cc

Browse files
committed
up
1 parent e98d7cb commit 181d3cc

File tree

5 files changed

+242
-182
lines changed

5 files changed

+242
-182
lines changed

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

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,13 @@ class Vec2(x: Float, y: Float) : Vec2t<Float>(x, y) {
306306
fun times(b: Number, res: Vec2) = times(res, this, b.f, b.f)
307307
fun times(b: Vec2t<out Number>, res: Vec2) = times(res, this, b.x.f, b.y.f)
308308

309-
fun times_(bX: Number, bY: Number) = times(this, this, bX.f, bY.f)
310-
infix fun times_(b: Number) = times(this, this, b.f, b.f)
311-
infix fun times_(b: Vec2t<out Number>) = times(this, this, b.x.f, b.y.f)
309+
fun timesAssign(bX: Number, bY: Number) = times(this, this, bX.f, bY.f)
310+
infix operator fun timesAssign(b: Number) {
311+
times(this, this, b.f, b.f)
312+
}
313+
infix operator fun timesAssign(b: Vec2t<out Number>) {
314+
times(this, this, b.x.f, b.y.f)
315+
}
312316

313317

314318
infix operator fun div(b: Number) = div(Vec2(), this, b.f, b.f)
@@ -320,9 +324,13 @@ class Vec2(x: Float, y: Float) : Vec2t<Float>(x, y) {
320324
fun div(b: Number, res: Vec2) = div(res, this, b.f, b.f)
321325
fun div(b: Vec2t<out Number>, res: Vec2) = div(res, this, b.x.f, b.y.f)
322326

323-
fun div_(bX: Number, bY: Number) = div(this, this, bX.f, bY.f)
324-
infix fun div_(b: Number) = div(this, this, b.f, b.f)
325-
infix fun div_(b: Vec2t<out Number>) = div(this, this, b.x.f, b.y.f)
327+
fun divAssign(bX: Number, bY: Number) = div(this, this, bX.f, bY.f)
328+
infix operator fun divAssign(b: Number) {
329+
div(this, this, b.f, b.f)
330+
}
331+
infix operator fun divAssign(b: Vec2t<out Number>) {
332+
div(this, this, b.x.f, b.y.f)
333+
}
326334

327335

328336
infix operator fun rem(b: Number) = rem(Vec2(), this, b.f, b.f)
@@ -334,16 +342,20 @@ class Vec2(x: Float, y: Float) : Vec2t<Float>(x, y) {
334342
fun rem(b: Number, res: Vec2) = rem(res, this, b.f, b.f)
335343
fun rem(b: Vec2t<out Number>, res: Vec2) = rem(res, this, b.x.f, b.y.f)
336344

337-
fun rem_(bX: Number, bY: Number) = rem(this, this, bX.f, bY.f)
338-
infix fun rem_(b: Number) = rem(this, this, b.f, b.f)
339-
infix fun rem_(b: Vec2t<out Number>) = rem(this, this, b.x.f, b.y.f)
345+
fun remAssign(bX: Number, bY: Number) = rem(this, this, bX.f, bY.f)
346+
infix operator fun remAssign(b: Number) {
347+
rem(this, this, b.f, b.f)
348+
}
349+
infix operator fun remAssign(b: Vec2t<out Number>) {
350+
rem(this, this, b.x.f, b.y.f)
351+
}
340352

341353
// -- functions --
342354

343355
// TODO others
344356
infix fun max(b: Vec2) = glm.max(this, b, Vec2())
345357

346-
infix fun max_(b: Vec2) {
358+
infix fun maxAssign(b: Vec2) {
347359
x = glm.max(x, b.x)
348360
y = glm.max(y, b.y)
349361
}
@@ -355,14 +367,14 @@ class Vec2(x: Float, y: Float) : Vec2t<Float>(x, y) {
355367
return res
356368
}
357369

358-
infix fun max_(b: Vec2t<*>) {
370+
infix fun maxAssign(b: Vec2t<*>) {
359371
x = glm.max(x, b.x.f)
360372
y = glm.max(y, b.y.f)
361373
}
362374

363375
infix fun max(b: Float) = glm.max(this, b, Vec2())
364376

365-
infix fun max_(b: Float) {
377+
infix fun maxAssign(b: Float) {
366378
x = glm.max(x, b)
367379
y = glm.max(y, b)
368380
}
@@ -374,7 +386,7 @@ class Vec2(x: Float, y: Float) : Vec2t<Float>(x, y) {
374386
return res
375387
}
376388

377-
infix fun max_(b: Number) {
389+
infix fun maxAssign(b: Number) {
378390
x = glm.max(x, b.f)
379391
y = glm.max(y, b.f)
380392
}
@@ -393,7 +405,7 @@ class Vec2(x: Float, y: Float) : Vec2t<Float>(x, y) {
393405
@JvmOverloads
394406
fun normalize(res: Vec2 = Vec2()) = glm.normalize(this, res) // TODO others
395407

396-
fun normalize_() = glm.normalize(this, this)
408+
fun normalizeAssign() = glm.normalize(this, this)
397409

398410
@JvmOverloads
399411
fun negate(res: Vec2 = Vec2()): Vec2 {
@@ -402,7 +414,7 @@ class Vec2(x: Float, y: Float) : Vec2t<Float>(x, y) {
402414
return res
403415
}
404416

405-
fun negate_() = negate(this)
417+
fun negateAssign() = negate(this)
406418

407419
override fun equals(other: Any?) = other is Vec2 && this[0] == other[0] && this[1] == other[1]
408420
override fun hashCode() = 31 * x.hashCode() + y.hashCode()

src/main/kotlin/glm_/vec3/Vec3.kt

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,11 @@ class Vec3(x: Float, y: Float, z: Float) : Vec3t<Float>(x, y, z) {
144144
else -> throw ArrayIndexOutOfBoundsException()
145145
}
146146

147-
companion object : vec3_operators {
147+
companion object : vec3_operators() {
148148
@JvmField
149149
val length = 3
150150
@JvmField
151151
val size = length * Float.BYTES
152-
153-
154152
}
155153

156154

@@ -181,9 +179,9 @@ class Vec3(x: Float, y: Float, z: Float) : Vec3t<Float>(x, y, z) {
181179
fun plus(b: Float, res: Vec3 = Vec3()) = plus(res, this, b, b, b)
182180
fun plus(b: Vec3, res: Vec3 = Vec3()) = plus(res, this, b.x, b.y, b.z)
183181

184-
fun plus_(bX: Float, bY: Float, bZ: Float) = plus(this, this, bX, bY, bZ)
185-
infix fun plus_(b: Float) = plus(this, this, b, b, b)
186-
infix fun plus_(b: Vec3) = plus(this, this, b.x, b.y, b.z)
182+
fun plusAssign(bX: Float, bY: Float, bZ: Float) = plus(this, this, bX, bY, bZ)
183+
infix fun plusAssign(b: Float) = plus(this, this, b, b, b)
184+
infix fun plusAssign(b: Vec3) = plus(this, this, b.x, b.y, b.z)
187185

188186

189187
infix operator fun minus(b: Float) = minus(Vec3(), this, b, b, b)
@@ -195,9 +193,9 @@ class Vec3(x: Float, y: Float, z: Float) : Vec3t<Float>(x, y, z) {
195193
fun minus(b: Float, res: Vec3 = Vec3()) = minus(res, this, b, b, b)
196194
fun minus(b: Vec3, res: Vec3 = Vec3()) = minus(res, this, b.x, b.y, b.z) // TODO overload others
197195

198-
fun minus_(bX: Float, bY: Float, bZ: Float) = minus(this, this, bX, bY, bZ)
199-
infix fun minus_(b: Float) = minus(this, this, b, b, b)
200-
infix fun minus_(b: Vec3) = minus(this, this, b.x, b.y, b.z)
196+
fun minusAssign(bX: Float, bY: Float, bZ: Float) = minus(this, this, bX, bY, bZ)
197+
infix fun minusAssign(b: Float) = minus(this, this, b, b, b)
198+
infix fun minusAssign(b: Vec3) = minus(this, this, b.x, b.y, b.z)
201199

202200

203201
infix operator fun times(b: Float) = times(Vec3(), this, b, b, b)
@@ -209,9 +207,9 @@ class Vec3(x: Float, y: Float, z: Float) : Vec3t<Float>(x, y, z) {
209207
fun times(b: Float, res: Vec3 = Vec3()) = times(res, this, b, b, b)
210208
fun times(b: Vec3, res: Vec3 = Vec3()) = times(res, this, b.x, b.y, b.z)
211209

212-
fun times_(bX: Float, bY: Float, bZ: Float) = times(this, this, bX, bY, bZ)
213-
infix fun times_(b: Float) = times(this, this, b, b, b)
214-
infix fun times_(b: Vec3) = times(this, this, b.x, b.y, b.z)
210+
fun timesAssign(bX: Float, bY: Float, bZ: Float) = times(this, this, bX, bY, bZ)
211+
infix fun timesAssign(b: Float) = times(this, this, b, b, b)
212+
infix fun timesAssign(b: Vec3) = times(this, this, b.x, b.y, b.z)
215213

216214

217215
operator fun div(b: Float) = div(Vec3(), this, b, b, b)
@@ -223,9 +221,9 @@ class Vec3(x: Float, y: Float, z: Float) : Vec3t<Float>(x, y, z) {
223221
fun div(b: Float, res: Vec3 = Vec3()) = div(res, this, b, b, b)
224222
fun div(b: Vec3, res: Vec3 = Vec3()) = div(res, this, b.x, b.y, b.z)
225223

226-
fun div_(bX: Float, bY: Float, bZ: Float) = div(this, this, bX, bY, bZ)
227-
infix fun div_(b: Float) = div(this, this, b, b, b)
228-
infix fun div_(b: Vec3) = div(this, this, b.x, b.y, b.z)
224+
fun divAssign(bX: Float, bY: Float, bZ: Float) = div(this, this, bX, bY, bZ)
225+
infix fun divAssign(b: Float) = div(this, this, b, b, b)
226+
infix fun divAssign(b: Vec3) = div(this, this, b.x, b.y, b.z)
229227

230228

231229
infix operator fun rem(b: Float) = rem(Vec3(), this, b, b, b)
@@ -237,9 +235,9 @@ class Vec3(x: Float, y: Float, z: Float) : Vec3t<Float>(x, y, z) {
237235
fun rem(b: Float, res: Vec3 = Vec3()) = rem(res, this, b, b, b)
238236
fun rem(b: Vec3, res: Vec3 = Vec3()) = rem(res, this, b.x, b.y, b.z)
239237

240-
fun rem_(bX: Float, bY: Float, bZ: Float) = rem(this, this, bX, bY, bZ)
241-
infix fun rem_(b: Float) = rem(this, this, b, b, b)
242-
infix fun rem_(b: Vec3) = rem(this, this, b.x, b.y, b.z)
238+
fun remAssign(bX: Float, bY: Float, bZ: Float) = rem(this, this, bX, bY, bZ)
239+
infix fun remAssign(b: Float) = rem(this, this, b, b, b)
240+
infix fun remAssign(b: Vec3) = rem(this, this, b.x, b.y, b.z)
243241

244242

245243
// -- Generic binary arithmetic operators --
@@ -253,9 +251,9 @@ class Vec3(x: Float, y: Float, z: Float) : Vec3t<Float>(x, y, z) {
253251
fun plus(b: Number, res: Vec3) = plus(res, this, b.f, b.f, b.f)
254252
fun plus(b: Vec3t<out Number>, res: Vec3 = Vec3()) = plus(res, this, b.x.f, b.y.f, b.z.f)
255253

256-
fun plus_(bX: Number, bY: Number, bZ: Number) = plus(this, this, bX.f, bY.f, bZ.f)
257-
infix fun plus_(b: Number) = plus(this, this, b.f, b.f, b.f)
258-
infix fun plus_(b: Vec3t<out Number>) = plus(this, this, b.x.f, b.y.f, b.z.f)
254+
fun plusAssign(bX: Number, bY: Number, bZ: Number) = plus(this, this, bX.f, bY.f, bZ.f)
255+
infix fun plusAssign(b: Number) = plus(this, this, b.f, b.f, b.f)
256+
infix fun plusAssign(b: Vec3t<out Number>) = plus(this, this, b.x.f, b.y.f, b.z.f)
259257

260258

261259
infix operator fun minus(b: Number) = minus(Vec3(), this, b.f, b.f, b.f)
@@ -265,9 +263,9 @@ class Vec3(x: Float, y: Float, z: Float) : Vec3t<Float>(x, y, z) {
265263
fun minus(b: Number, res: Vec3 = Vec3()) = minus(res, this, b.f, b.f, b.f)
266264
fun minus(b: Vec3t<out Number>, res: Vec3 = Vec3()) = minus(res, this, b.x.f, b.y.f, b.z.f)
267265

268-
fun minus_(bX: Number, bY: Number, bZ: Number) = minus(this, this, bX.f, bY.f, bZ.f)
269-
infix fun minus_(b: Number) = minus(this, this, b.f, b.f, b.f)
270-
infix fun minus_(b: Vec3t<out Number>) = minus(this, this, b.x.f, b.y.f, b.z.f)
266+
fun minusAssign(bX: Number, bY: Number, bZ: Number) = minus(this, this, bX.f, bY.f, bZ.f)
267+
infix fun minusAssign(b: Number) = minus(this, this, b.f, b.f, b.f)
268+
infix fun minusAssign(b: Vec3t<out Number>) = minus(this, this, b.x.f, b.y.f, b.z.f)
271269

272270

273271
infix operator fun times(b: Number) = times(Vec3(), this, b.f, b.f, b.f)
@@ -277,9 +275,9 @@ class Vec3(x: Float, y: Float, z: Float) : Vec3t<Float>(x, y, z) {
277275
fun times(b: Number, res: Vec3 = Vec3()) = times(res, this, b.f, b.f, b.f)
278276
fun times(b: Vec3t<out Number>, res: Vec3 = Vec3()) = times(res, this, b.x.f, b.y.f, b.z.f)
279277

280-
fun times_(bX: Number, bY: Number, bZ: Number) = times(this, this, bX.f, bY.f, bZ.f)
281-
infix fun times_(b: Number) = times(this, this, b.f, b.f, b.f)
282-
infix fun times_(b: Vec3t<out Number>) = times(this, this, b.x.f, b.y.f, b.z.f)
278+
fun timesAssign(bX: Number, bY: Number, bZ: Number) = times(this, this, bX.f, bY.f, bZ.f)
279+
infix fun timesAssign(b: Number) = times(this, this, b.f, b.f, b.f)
280+
infix fun timesAssign(b: Vec3t<out Number>) = times(this, this, b.x.f, b.y.f, b.z.f)
283281

284282

285283
infix operator fun div(b: Number) = div(Vec3(), this, b.f, b.f, b.f)
@@ -289,9 +287,9 @@ class Vec3(x: Float, y: Float, z: Float) : Vec3t<Float>(x, y, z) {
289287
fun div(b: Number, res: Vec3 = Vec3()) = div(res, this, b.f, b.f, b.f)
290288
fun div(b: Vec3t<out Number>, res: Vec3 = Vec3()) = div(res, this, b.x.f, b.y.f, b.z.f)
291289

292-
fun div_(bX: Number, bY: Number, bZ: Number) = div(this, this, bX.f, bY.f, bZ.f)
293-
infix fun div_(b: Number) = div(this, this, b.f, b.f, b.f)
294-
infix fun div_(b: Vec3t<out Number>) = div(this, this, b.x.f, b.y.f, b.z.f)
290+
fun divAssign(bX: Number, bY: Number, bZ: Number) = div(this, this, bX.f, bY.f, bZ.f)
291+
infix fun divAssign(b: Number) = div(this, this, b.f, b.f, b.f)
292+
infix fun divAssign(b: Vec3t<out Number>) = div(this, this, b.x.f, b.y.f, b.z.f)
295293

296294

297295
infix operator fun rem(b: Number) = rem(Vec3(), this, b.f, b.f, b.f)
@@ -301,9 +299,9 @@ class Vec3(x: Float, y: Float, z: Float) : Vec3t<Float>(x, y, z) {
301299
fun rem(b: Number, res: Vec3 = Vec3()) = rem(res, this, b.f, b.f, b.f)
302300
fun rem(b: Vec3t<out Number>, res: Vec3 = Vec3()) = rem(res, this, b.x.f, b.y.f, b.z.f)
303301

304-
fun rem_(bX: Number, bY: Number, bZ: Number) = rem(this, this, bX.f, bY.f, bZ.f)
305-
infix fun rem_(b: Number) = rem(this, this, b.f, b.f, b.f)
306-
infix fun rem_(b: Vec3t<out Number>) = rem(this, this, b.x.f, b.y.f, b.z.f)
302+
fun remAssign(bX: Number, bY: Number, bZ: Number) = rem(this, this, bX.f, bY.f, bZ.f)
303+
infix fun remAssign(b: Number) = rem(this, this, b.f, b.f, b.f)
304+
infix fun remAssign(b: Vec3t<out Number>) = rem(this, this, b.x.f, b.y.f, b.z.f)
307305

308306

309307
// -- functions --
@@ -313,10 +311,10 @@ class Vec3(x: Float, y: Float, z: Float) : Vec3t<Float>(x, y, z) {
313311
@JvmOverloads
314312
fun normalize(res: Vec3 = Vec3()) = glm.normalize(this, res) // TODO others
315313

316-
fun normalize_() = glm.normalize(this, this)
314+
fun normalizeAssign() = glm.normalize(this, this)
317315

318316
infix fun cross(b: Vec3) = glm.cross(this, b, Vec3())
319-
infix fun cross_(b: Vec3) = glm.cross(this, b, this)
317+
infix fun crossAssign(b: Vec3) = glm.cross(this, b, this)
320318

321319
infix fun dot(b: Vec3) = glm.dot(this, b) // TODO others
322320

@@ -328,7 +326,7 @@ class Vec3(x: Float, y: Float, z: Float) : Vec3t<Float>(x, y, z) {
328326
return res
329327
}
330328

331-
fun negate_() = negate(this)
329+
fun negateAssign() = negate(this)
332330

333331

334332
override fun equals(other: Any?) = other is Vec3 && this[0] == other[0] && this[1] == other[1] && this[2] == other[2]

0 commit comments

Comments
 (0)