Skip to content

Commit 70b4eb2

Browse files
committed
- finished migration to *Assign
- functional programming constructors
1 parent 181d3cc commit 70b4eb2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+3153
-2219
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ apply plugin: 'com.github.johnrengelman.shadow'
99

1010
buildscript {
1111

12-
ext.kotlinVersion = '1.2.0-rc-39'
12+
ext.kotlinVersion = '1.2.0'
1313

1414
repositories {
1515
jcenter() // shadow
@@ -27,7 +27,7 @@ dependencies {
2727

2828
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
2929

30-
compile 'com.github.kotlin-graphics:kotlin-unsigned:f15b79c3ac751e4dea3ebee52117801943cbe5cd'
30+
compile 'com.github.kotlin-graphics:kotlin-unsigned:545b8f2fcb'
3131

3232
testCompile 'io.kotlintest:kotlintest:2.0.7'
3333
}

src/main/kotlin/glm_/colorSpace.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package glm_
22

3+
import glm_.vec2.Vec2
34
import glm_.vec3.Vec3
45
import glm_.vec4.Vec4
56

src/main/kotlin/glm_/mat3x3/Mat3.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ data class Mat3(override var value: MutableList<Vec3>) : Mat3x3t<Vec3>(value) {
5656
Vec3(v1),
5757
Vec3(v2)))
5858

59+
constructor(block: (Int) -> Float): this(block(0), block(1), block(2), block(3), block(4),
60+
block(5), block(6), block(7), block(8))
61+
5962
// -- Matrix conversions --
6063

6164
constructor(mat2x2: Mat2x2t<*>) : this(mutableListOf(

src/main/kotlin/glm_/mat4x4/Mat4.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ data class Mat4(override var value: MutableList<Vec4>) : Mat4x4t<Vec4>(value) {
5353
constructor(v: Vec3t<*>, w: Number) : this(v.x, v.y, v.z, w)
5454
constructor(a: Vec3t<*>, aW: Number, b: Vec3t<*>, bW: Number, c: Vec3t<*>, cW: Number, d: Vec3t<*>, dW: Number) : this(
5555
a.x, a.y, a.z, aW, b.x, b.y, b.z, bW, c.x, c.y, c.z, cW, d.x, d.y, d.z, dW)
56+
5657
constructor(v: Vec4t<*>) : this(v.x, v.y, v.z, v.w)
5758

5859
constructor(x0: Number, y0: Number, z0: Number, w0: Number,
@@ -70,6 +71,10 @@ data class Mat4(override var value: MutableList<Vec4>) : Mat4x4t<Vec4>(value) {
7071
Vec4(v2),
7172
Vec4(v3)))
7273

74+
constructor(block: (Int) -> Float) : this(block(0), block(1), block(2), block(3), block(4),
75+
block(5), block(6), block(7), block(8), block(9), block(10), block(11), block(12),
76+
block(13), block(14), block(15))
77+
7378
// -- Matrix conversions --
7479

7580
constructor(mat2x2: Mat2x2t<*>) : this(mutableListOf(
@@ -549,5 +554,6 @@ data class Mat4(override var value: MutableList<Vec4>) : Mat4x4t<Vec4>(value) {
549554
this[1, 0] == other[1, 0] && this[1, 1] == other[1, 1] && this[1, 2] == other[1, 2] && this[1, 3] == other[1, 3] &&
550555
this[2, 0] == other[2, 0] && this[2, 1] == other[2, 1] && this[2, 2] == other[2, 2] && this[2, 3] == other[2, 3] &&
551556
this[3, 0] == other[3, 0] && this[3, 1] == other[3, 1] && this[3, 2] == other[3, 2] && this[3, 3] == other[3, 3]
557+
552558
override fun hashCode() = 31 * (31 * (31 * value[0].hashCode() + value[1].hashCode()) + value[2].hashCode()) + value[3].hashCode()
553559
}

src/main/kotlin/glm_/matrix_transform.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ interface matrix_transform {
785785
res.z = proj[0][2] * tmpX + proj[1][2] * tmpY + proj[2][2] * tmpZ + proj[3][2] * tmpW
786786
//val tmpW = proj[0][3] * tmpX + proj[1][3] * tmpY + proj[2][3] * tmpZ + proj[3][3] * tmpW
787787

788-
res div_ tmpW
788+
res /= tmpW
789789

790790
res.x = res.x * 0.5f + 0.5f
791791
res.y = res.y * 0.5f + 0.5f
@@ -920,7 +920,9 @@ interface matrix_transform {
920920

921921
res.put(objX, objY, objZ)
922922

923-
return res div_ objW
923+
res /= objW
924+
925+
return res
924926
}
925927

926928
fun unProject(win: Vec3, model: Mat4, proj: Mat4, viewport: Vec4i) = unProject(Vec3(), win, model, proj, viewport)

0 commit comments

Comments
 (0)