@@ -18,12 +18,11 @@ class ObjFileImporter : BaseImporter() {
1818 fileExtensions = listOf (" obj" ))
1919
2020 /* * Returns true, if file is an obj file. */
21- override fun canRead (file : String , ioSystem : IOSystem , checkSig : Boolean ): Boolean {
22-
23- if (! checkSig) // Check File Extension
24- return file.substring(file.lastIndexOf(' .' ) + 1 ) == " obj"
25- else // Check file Header
26- return false
21+ override fun canRead (file : String , ioSystem : IOSystem , checkSig : Boolean ): Boolean = when {
22+ // Check File Extension
23+ ! checkSig -> file.substring(file.lastIndexOf(' .' ) + 1 ) == " obj"
24+ // Check file Header
25+ else -> false
2726 }
2827
2928 // reference to load textures later
@@ -219,7 +218,7 @@ class ObjFileImporter : BaseImporter() {
219218 else if (pMesh.numVertices > AI_MAX_ALLOC (AiVector3D .size))
220219 throw Exception (" OBJ:" + pModel.m_ModelName + " | " + pMesh.name + " --> Too many vertices, would run out of memory" )
221220
222- pMesh.vertices = MutableList (pMesh.numVertices, { AiVector3D () })
221+ pMesh.vertices = MutableList (pMesh.numVertices) { AiVector3D () }
223222
224223 // Allocate buffer for normal vectors
225224 if (pModel.m_Normals.isNotEmpty() && pObjMesh.m_hasNormals) {
@@ -232,7 +231,7 @@ class ObjFileImporter : BaseImporter() {
232231 // Allocate buffer for vertex-color vectors
233232
234233 if (pModel.m_VertexColors.isNotEmpty())
235- pMesh.colors.add(Array (pMesh.numVertices, { AiColor4D () }) .toMutableList())
234+ pMesh.colors.add(Array (pMesh.numVertices) { AiColor4D () }.toMutableList())
236235 // pMesh.colors[0] = Array(pMesh.numVertices, { AiColor4D() }).toMutableList()
237236
238237 // Allocate buffer for texture coordinates
@@ -284,7 +283,7 @@ class ObjFileImporter : BaseImporter() {
284283
285284 // Get destination face
286285 val faceIndex = outIndex;
287- val pDestFace = pMesh.faces.getOrElse(faceIndex, { mutableListOf () })
286+ val pDestFace = pMesh.faces.getOrElse(faceIndex) { mutableListOf () }
288287
289288 val last = vertexIndex == pSourceFace.m_vertices.lastIndex
290289
0 commit comments