Skip to content

Commit e8aa34f

Browse files
committed
⬆️
Kotlin 1.2.41
1 parent 1c2d974 commit e8aa34f

File tree

16 files changed

+840
-109
lines changed

16 files changed

+840
-109
lines changed

build.gradle

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ group = 'com.github.kotlin-graphics'
99

1010
buildscript {
1111

12-
ext.kotlinVersion = '1.2.40'
12+
ext.kotlinVersion = '1.2.41'
1313

1414
repositories {
1515
jcenter()
@@ -33,9 +33,9 @@ dependencies {
3333
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
3434
implementation "org.jetbrains.kotlin:kotlin-reflect"
3535

36-
implementation 'com.github.kotlin-graphics:uno-sdk:f97f9853e6158a86550268b63ad2800e0e08737f'
36+
implementation 'com.github.kotlin-graphics:uno-sdk:6db5c2919e60af45389b5f255d1c0a29c29f7ef6'
3737

38-
testCompile 'io.kotlintest:kotlintest-runner-junit5:3.0.6'
38+
testCompile 'io.kotlintest:kotlintest-runner-junit5:3.0.5'
3939

4040
implementation 'io.github.microutils:kotlin-logging:1.4.6'
4141

@@ -65,13 +65,15 @@ dependencies {
6565
implementation "org.lwjgl:lwjgl-openal:${lwjglVersion}"
6666
implementation "org.lwjgl:lwjgl-opengl:${lwjglVersion}"
6767
implementation "org.lwjgl:lwjgl-stb:${lwjglVersion}"
68+
implementation "org.lwjgl:lwjgl-tootle:$lwjglVersion"
6869

6970
testRuntime "org.lwjgl:lwjgl:${lwjglVersion}:${lwjglNatives}"
7071
testRuntime "org.lwjgl:lwjgl-glfw:${lwjglVersion}:${lwjglNatives}"
7172
testRuntime "org.lwjgl:lwjgl-jemalloc:${lwjglVersion}:${lwjglNatives}"
7273
testRuntime "org.lwjgl:lwjgl-openal:${lwjglVersion}:${lwjglNatives}"
7374
testRuntime "org.lwjgl:lwjgl-opengl:${lwjglVersion}:${lwjglNatives}"
7475
testRuntime "org.lwjgl:lwjgl-stb:${lwjglVersion}:${lwjglNatives}"
76+
testRuntime "org.lwjgl:lwjgl-tootle:$lwjglVersion:$lwjglNatives"
7577
}
7678

7779
repositories {

src/main/kotlin/assimp/Importer.kt

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4343
package assimp
4444

4545
import assimp.format.ProgressHandler
46+
import assimp.postProcess.OptimizeMeshes
47+
import assimp.postProcess.ValidateDSProcess
4648
import glm_.BYTES
4749
import glm_.i
4850
import glm_.size
@@ -320,7 +322,7 @@ constructor() {
320322
if (!ASSIMP.NO.VALIDATEDS_PROCESS)
321323
// The ValidateDS process is an exception. It is executed first, even before ScenePreprocessor is called.
322324
if (flags has Pps.ValidateDataStructure) {
323-
ValidateDSProcess.executeOnScene(this)
325+
ValidateDSProcess().executeOnScene(this)
324326
if (impl.scene == null) return null
325327
}
326328
// Preprocess the scene and prepare it for post-processing
@@ -409,11 +411,11 @@ constructor() {
409411
/* The ValidateDS process plays an exceptional role. It isn't contained in the global list of post-processing
410412
steps, so we need to call it manually. */
411413
if (flags has Pps.ValidateDataStructure) {
412-
ValidateDSProcess.executeOnScene(this)
414+
ValidateDSProcess().executeOnScene(this)
413415
if (impl.scene == null) return null
414416
}
415417
if (flags has Pps.OptimizeMeshes) {
416-
OptimizeMeshes.executeOnScene(this)
418+
OptimizeMeshes().executeOnScene(this)
417419
if (impl.scene == null) return null
418420
}
419421
var flags = flags
@@ -445,7 +447,7 @@ constructor() {
445447
// If the extra verbose mode is active, execute the ValidateDataStructureStep again - after each step
446448
if (impl.extraVerbose) {
447449
logger.debug { "Verbose Import: revalidating data structures" }
448-
ValidateDSProcess.executeOnScene(this)
450+
ValidateDSProcess().executeOnScene(this)
449451
if (impl.scene == null) {
450452
logger.error { "Verbose Import: failed to revalidate data structures" }
451453
break
@@ -472,7 +474,7 @@ constructor() {
472474
// The ValidateDS process plays an exceptional role. It isn't contained in the global
473475
// list of post-processing steps, so we need to call it manually.
474476
if (requestValidation) {
475-
ValidateDSProcess.executeOnScene(this)
477+
ValidateDSProcess().executeOnScene(this)
476478
if (impl.scene == null) return null
477479
}
478480
}
@@ -492,7 +494,7 @@ constructor() {
492494
// If the extra verbose mode is active, execute the ValidateDataStructureStep again - after each step
493495
if (impl.extraVerbose || requestValidation) {
494496
logger.debug { "Verbose Import: revalidating data structures" }
495-
ValidateDSProcess.executeOnScene(this)
497+
ValidateDSProcess().executeOnScene(this)
496498
if (impl.scene == null)
497499
logger.error { "Verbose Import: failed to revalidate data structures" }
498500
}

src/main/kotlin/assimp/assimp.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ val logger = KotlinLogging.logger {}
1010
fun Mat4.decompose(pScaling: AiVector3D, pRotation: AiQuaternion, pPosition: AiVector3D) {
1111

1212
/* extract translation */
13-
pPosition.x = this[0][3]
14-
pPosition.y = this[1][3]
15-
pPosition.z = this[2][3]
13+
pPosition[0] = this[0][3]
14+
pPosition[1] = this[1][3]
15+
pPosition[2] = this[2][3]
1616

1717
/* extract the columns of the matrix. */
1818
val vCols = listOf(
19-
AiVector3D(this[0][0], this[1][0], this[2][0]),
20-
AiVector3D(this[0][1], this[1][1], this[2][1]),
21-
AiVector3D(this[0][2], this[1][2], this[2][2]))
19+
AiVector3D(this[0, 0], this[1, 0], this[2, 0]),
20+
AiVector3D(this[0, 1], this[1, 1], this[2, 1]),
21+
AiVector3D(this[0 ,2], this[1, 2], this[2, 2]))
2222

2323
/* extract the scaling factors */
2424
pScaling.x = vCols[0].length

src/main/kotlin/assimp/camera.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ package assimp
4343

4444
import glm_.BYTES
4545
import glm_.f
46+
import glm_.glm
4647
import glm_.mat4x4.Mat4
4748
import glm_.vec3.Vec3
4849

@@ -129,7 +130,7 @@ class AiCamera(
129130
* line of the screen and the left or right border.
130131
* The default value is 1/4PI.
131132
*/
132-
var horizontalFOV: Float = .25f * Math.PI.f, // TODO glm
133+
var horizontalFOV: Float = .25f * glm.PIf,
133134

134135
/** Distance of the near clipping plane from the camera.
135136
*

src/main/kotlin/assimp/defs.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ val String.words get() = trim().split("\\s+".toRegex())
9191
//////////////////////////////////////////////////////////////////////////
9292

9393
/* This is PI. Hi PI. */
94-
val AI_MATH_TWO_PI = glm.PI * 2 // TODO glm?
95-
val AI_MATH_TWO_PIf = glm.PIf * 2 // TODO glm?
96-
val AI_MATH_HALF_PI = glm.PIf * 0.5
94+
val AI_MATH_TWO_PI = glm.PI2
95+
val AI_MATH_TWO_PIf = glm.PI2f
96+
val AI_MATH_HALF_PI = glm.HPIf
9797

9898
val AiVector3D.squareLength get() = x * x + y * y + z * z
9999

src/main/kotlin/assimp/mesh.kt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -328,26 +328,30 @@ open class AiMesh(
328328
//! Check whether the mesh contains a vertex color set
329329
//! \param index Index of the vertex color set
330330
fun hasVertexColors(index: Int) =
331-
if (index >= assimp.AI_MAX_NUMBER_OF_COLOR_SETS) false
332-
else index < colors.size && numVertices > 0
331+
if (index >= AI_MAX_NUMBER_OF_COLOR_SETS)
332+
false
333+
else
334+
index < colors.size && numVertices > 0
333335

334336
//! Check whether the mesh contains a texture coordinate set
335337
//! \param index Index of the texture coordinates set
336338
fun hasTextureCoords(index: Int) =
337-
if (index >= assimp.AI_MAX_NUMBER_OF_TEXTURECOORDS) false
338-
else textureCoords[index].isNotEmpty() && numVertices > 0
339+
if (index >= AI_MAX_NUMBER_OF_TEXTURECOORDS || index >= textureCoords.size)
340+
false
341+
else
342+
textureCoords[index].isNotEmpty() && numVertices > 0
339343

340344
//! Get the number of UV channels the mesh contains
341345
fun getNumUVChannels(): Int {
342346
var n = 0
343-
while (n < assimp.AI_MAX_NUMBER_OF_TEXTURECOORDS && n < textureCoords.size && textureCoords[n].isNotEmpty()) ++n
347+
while (n < AI_MAX_NUMBER_OF_TEXTURECOORDS && n < textureCoords.size && textureCoords[n].isNotEmpty()) ++n
344348
return n
345349
}
346350

347351
//! Get the number of vertex color channels the mesh contains
348352
fun getNumColorChannels(): Int {
349353
var n = 0
350-
while (n < assimp.AI_MAX_NUMBER_OF_COLOR_SETS && n < colors.size) ++n
354+
while (n < AI_MAX_NUMBER_OF_COLOR_SETS && n < colors.size) ++n
351355
return n
352356
}
353357

src/main/kotlin/assimp/postProcess/convertToLhProcess.kt renamed to src/main/kotlin/assimp/postProcess/ConvertToLhProcess.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ import glm_.mat4x4.Mat4
6363
*
6464
* @note RH-LH and LH-RH is the same, so this class can be used for both
6565
*/
66-
class MakeLeftHandedProcess : BaseProcess() {
66+
object MakeLeftHandedProcess : BaseProcess() {
6767

6868
/** Returns whether the processing step is present in the given flag field. */
6969
override fun isActive(flags: AiPostProcessStepsFlags): Boolean = flags has AiPostProcessStep.MakeLeftHanded
@@ -183,7 +183,7 @@ class MakeLeftHandedProcess : BaseProcess() {
183183
// ---------------------------------------------------------------------------
184184
/** Postprocessing step to flip the face order of the imported data
185185
*/
186-
class FlipWindingOrderProcess : BaseProcess() {
186+
object FlipWindingOrderProcess : BaseProcess() {
187187

188188
/** Returns whether the processing step is present in the given flag field. */
189189
override fun isActive(flags: AiPostProcessStepsFlags): Boolean = flags has AiPostProcessStep.FlipWindingOrder
@@ -210,7 +210,7 @@ class FlipWindingOrderProcess : BaseProcess() {
210210
}
211211

212212
/** Postprocessing step to flip the UV coordinate system of the import data */
213-
class FlipUVsProcess : BaseProcess() {
213+
object FlipUVsProcess : BaseProcess() {
214214

215215
override fun isActive(flags: AiPostProcessStepsFlags): Boolean = flags has AiPostProcessStep.FlipUVs
216216

src/main/kotlin/assimp/optimizeMeshes.kt renamed to src/main/kotlin/assimp/postProcess/OptimizeMeshes.kt

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
package assimp
1+
package assimp.postProcess
22

3+
import assimp.*
34
import assimp.AiPostProcessStep as Pps
45
import assimp.AiShadingMode as Sm
56

6-
object OptimizeMeshes : BaseProcess(){
7+
class OptimizeMeshes : BaseProcess(){
8+
79
private val NotSet = 0xffffffff
810
private val DeadBeef = 0xdeadbeef
911
private lateinit var mScene : AiScene
@@ -37,14 +39,14 @@ object OptimizeMeshes : BaseProcess(){
3739
mScene = scene
3840

3941
findInstancedMeshes(mScene.rootNode)
40-
if( maxVerts == DeadBeef ) /* undo the magic hack */
42+
if( maxVerts == DeadBeef) /* undo the magic hack */
4143
maxVerts = NotSet
4244

4345
var n : Long = 0
4446
for (i in 0 until mScene.numMeshes) {
4547
meshes[i].vertex_format = ProcessHelper.getMeshVFormatUnique(mScene.meshes[i])
4648

47-
if (meshes[i].instance_cnt > 1 && meshes[i].output_id == NotSet ) {
49+
if (meshes[i].instance_cnt > 1 && meshes[i].output_id == NotSet) {
4850
meshes[i].output_id = n++
4951
output.add(mScene.meshes[i])
5052
}
@@ -59,10 +61,10 @@ object OptimizeMeshes : BaseProcess(){
5961
assert(output.size <= oldNum)
6062

6163
mScene.numMeshes = output.size
62-
System.arraycopy(output,0,mScene.meshes,0,output.size)
64+
System.arraycopy(output,0, mScene.meshes,0, output.size)
6365

6466
if (output.size != oldNum) {
65-
logger.info("OptimizeMeshesProcess finished. Input meshes: %d, Output meshes: %d",oldNum,mScene.numMeshes)
67+
logger.info("OptimizeMeshesProcess finished. Input meshes: %d, Output meshes: %d",oldNum, mScene.numMeshes)
6668
} else {
6769
logger.debug( "OptimizeMeshesProcess finished" )
6870
}
@@ -82,7 +84,7 @@ object OptimizeMeshes : BaseProcess(){
8284
++meshes[ pNode.meshes[ i ] ].instance_cnt
8385
}
8486
for(i in 0 until pNode.numChildren) {
85-
findInstancedMeshes( pNode.children[ i ] )
87+
findInstancedMeshes(pNode.children[i])
8688
}
8789
}
8890

@@ -102,8 +104,8 @@ object OptimizeMeshes : BaseProcess(){
102104
// Find meshes to merge with us
103105
var a = 0
104106
while(a < pNode.numMeshes){
105-
var am = pNode.meshes[a]
106-
if (meshes[am].instance_cnt == 1 && canJoin(im,am,verts,faces)) {
107+
val am = pNode.meshes[a]
108+
if (meshes[am].instance_cnt == 1 && canJoin(im, am, verts, faces)) {
107109

108110
merge_list.add(mScene.meshes[am])
109111
verts += mScene.meshes[am].numVertices
@@ -120,8 +122,8 @@ object OptimizeMeshes : BaseProcess(){
120122
if (merge_list.size != 0 ){
121123
merge_list.add(mScene.meshes[im])
122124

123-
var out = ArrayList<AiMesh>()
124-
SceneCombiner.mergeMeshes(out,0,merge_list,0,merge_list.size)
125+
val out = ArrayList<AiMesh>()
126+
SceneCombiner.mergeMeshes(out, 0, merge_list, 0, merge_list.size)
125127
for(oMesh in out){
126128
output.add(oMesh)
127129
}
@@ -134,7 +136,7 @@ object OptimizeMeshes : BaseProcess(){
134136

135137

136138
for(i in 0 until pNode.numChildren) {
137-
processNode( pNode.children[ i ] )
139+
processNode(pNode.children[i])
138140
}
139141
}
140142

@@ -143,8 +145,8 @@ object OptimizeMeshes : BaseProcess(){
143145
if (meshes[a].vertex_format != meshes[b].vertex_format)
144146
return false
145147

146-
var ma = mScene.meshes[a]
147-
var mb = mScene.meshes[b]
148+
val ma = mScene.meshes[a]
149+
val mb = mScene.meshes[b]
148150

149151
if ((NotSet != maxVerts && verts+mb.numVertices > maxVerts) || (NotSet != maxFaces && faces+mb.numFaces > maxFaces)) {
150152
return false

0 commit comments

Comments
 (0)