diff --git a/build.gradle b/build.gradle
index 2524f33..52cd3ec 100644
--- a/build.gradle
+++ b/build.gradle
@@ -46,7 +46,6 @@ dependencies {
implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
testImplementation group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.25'
-
ext.lwjglVersion = "3.2.0"
switch (OperatingSystem.current()) {
case OperatingSystem.WINDOWS:
diff --git a/src/main/kotlin/assimp/Importer.kt b/src/main/kotlin/assimp/Importer.kt
index 2a0f4de..c82a6ff 100644
--- a/src/main/kotlin/assimp/Importer.kt
+++ b/src/main/kotlin/assimp/Importer.kt
@@ -188,13 +188,7 @@ constructor() {
var ioHandler: IOSystem
get() = impl.ioSystem
set(value) {
- if (value != null) { // TODO check nullability
- impl.ioSystem = value
- impl.isDefaultHandler = false
- } else {
- impl.ioSystem = DefaultIOSystem()
- impl.isDefaultHandler = true
- }
+ impl.ioSystem = value
}
/** Checks whether a default progress handler is active
@@ -773,8 +767,8 @@ constructor() {
the library version they're using - a log dump is sufficient. */
val flags = compileFlags
logger.debug {
- var message = "Assimp $versionMajor.$versionMinor.$versionRevision"
- if (ASSIMP.DEBUG) message += " debug"
+ val message = "Assimp $versionMajor.$versionMinor.$versionRevision"
+ if (ASSIMP.DEBUG) "$message debug" else message
}
}
diff --git a/src/main/kotlin/assimp/ImporterPimpl.kt b/src/main/kotlin/assimp/ImporterPimpl.kt
index 4c22379..790d20d 100644
--- a/src/main/kotlin/assimp/ImporterPimpl.kt
+++ b/src/main/kotlin/assimp/ImporterPimpl.kt
@@ -5,7 +5,8 @@ import assimp.format.ProgressHandler
/** Internal PIMPL implementation for Assimp::Importer */
class ImporterPimpl {
- var isDefaultHandler = true
+ val isDefaultHandler
+ get() = ioSystem is DefaultIOSystem
/** Progress handler for feedback. */
var progressHandler: ProgressHandler = DefaultProgressHandler()
diff --git a/src/main/kotlin/assimp/MemoryIOWrapper.kt b/src/main/kotlin/assimp/MemoryIOWrapper.kt
index 5573b70..c8d1056 100644
--- a/src/main/kotlin/assimp/MemoryIOWrapper.kt
+++ b/src/main/kotlin/assimp/MemoryIOWrapper.kt
@@ -1,12 +1,11 @@
package assimp
import glm_.*
+import gli_.ByteBufferBackedInputStream
import java.io.*
import java.nio.*
import java.io.IOException
-
-
const val AI_MEMORYIO_MAGIC_FILENAME = "\$\$\$___magic___\$\$\$"
const val AI_MEMORYIO_MAGIC_FILENAME_LENGTH = 17
@@ -64,97 +63,4 @@ class MemoryIOSystem : IOSystem{
override fun readBytes(): ByteBuffer = buffer.duplicate().order(ByteOrder.nativeOrder())
}
-}
-
-// TODO move this to a different file?
-private class ByteBufferBackedInputStream(val buf: ByteBuffer) : InputStream() {
-
- /**
- * Reads the next byte of data from the input stream. The value byte is
- * returned as an int in the range 0 to
- * 255. If no byte is available because the end of the stream
- * has been reached, the value -1 is returned. This method
- * blocks until input data is available, the end of the stream is detected,
- * or an exception is thrown.
- *
- *
A subclass must provide an implementation of this method.
- *
- * @return the next byte of data, or -1 if the end of the
- * stream is reached.
- * @exception IOException if an I/O error occurs.
- */
- override fun read(): Int {
- return if (!buf.hasRemaining()) {
- -1
- } else buf.get().toInt() and 0xFF
- }
-
- /**
- * Reads up to len bytes of data from the input stream into
- * an array of bytes. An attempt is made to read as many as
- * len bytes, but a smaller number may be read.
- * The number of bytes actually read is returned as an integer.
- *
- *
This method blocks until input data is available, end of file is
- * detected, or an exception is thrown.
- *
- *
If len is zero, then no bytes are read and
- * 0 is returned; otherwise, there is an attempt to read at
- * least one byte. If no byte is available because the stream is at end of
- * file, the value -1 is returned; otherwise, at least one
- * byte is read and stored into b.
- *
- *
The first byte read is stored into element b[off], the
- * next one into b[off+1], and so on. The number of bytes read
- * is, at most, equal to len. Let k be the number of
- * bytes actually read; these bytes will be stored in elements
- * b[off] through b[off+k-1],
- * leaving elements b[off+k] through
- * b[off+len-1] unaffected.
- *
- *
In every case, elements b[0] through
- * b[off] and elements b[off+len] through
- * b[b.length-1] are unaffected.
- *
- *
The read(b, off, len) method
- * for class InputStream simply calls the method
- * read() repeatedly. If the first such call results in an
- * IOException, that exception is returned from the call to
- * the read(b, off, len) method. If
- * any subsequent call to read() results in a
- * IOException, the exception is caught and treated as if it
- * were end of file; the bytes read up to that point are stored into
- * b and the number of bytes read before the exception
- * occurred is returned. The default implementation of this method blocks
- * until the requested amount of input data len has been read,
- * end of file is detected, or an exception is thrown. Subclasses are encouraged
- * to provide a more efficient implementation of this method.
- *
- * @param b the buffer into which the data is read.
- * @param off the start offset in array b
- * at which the data is written.
- * @param len the maximum number of bytes to read.
- * @return the total number of bytes read into the buffer, or
- * -1 if there is no more data because the end of
- * the stream has been reached.
- * @exception IOException If the first byte cannot be read for any reason
- * other than end of file, or if the input stream has been closed, or if
- * some other I/O error occurs.
- * @exception NullPointerException If b is null.
- * @exception IndexOutOfBoundsException If off is negative,
- * len is negative, or len is greater than
- * b.length - off
- * @see java.io.InputStream#read()
- */
- override fun read(bytes: ByteArray, off: Int, len: Int): Int {
- @Suppress("NAME_SHADOWING")
- var len = len
- if (!buf.hasRemaining()) {
- return -1
- }
-
- len = Math.min(len, buf.remaining())
- buf.get(bytes, off, len)
- return len
- }
}
\ No newline at end of file
diff --git a/src/main/kotlin/assimp/PolyTools.kt b/src/main/kotlin/assimp/PolyTools.kt
index 3131702..a5272dd 100644
--- a/src/main/kotlin/assimp/PolyTools.kt
+++ b/src/main/kotlin/assimp/PolyTools.kt
@@ -42,6 +42,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/** @file PolyTools.h, various utilities for our dealings with arbitrary polygons */
+@file:Suppress("NOTHING_TO_INLINE")
+
package assimp
import glm_.vec2.Vec2
diff --git a/src/main/kotlin/assimp/SGSpatialSort.kt b/src/main/kotlin/assimp/SGSpatialSort.kt
index 7249283..cfe32f0 100644
--- a/src/main/kotlin/assimp/SGSpatialSort.kt
+++ b/src/main/kotlin/assimp/SGSpatialSort.kt
@@ -17,7 +17,7 @@ class SGSpatialSort {
fun prepare()
{
- val array = mPositions.toArray() as Array
+ val array = mPositions.toTypedArray()
Arrays.sort(array)
mPositions.clear()
mPositions.addAll(array)
diff --git a/src/main/kotlin/assimp/SkeletonMeshBuilder.kt b/src/main/kotlin/assimp/SkeletonMeshBuilder.kt
index 69e2224..408060c 100644
--- a/src/main/kotlin/assimp/SkeletonMeshBuilder.kt
+++ b/src/main/kotlin/assimp/SkeletonMeshBuilder.kt
@@ -73,16 +73,16 @@ constructor(scene: AiScene, root: AiNode? = null, val knobsOnly: Boolean = false
init {
// nothing to do if there's mesh data already present at the scene
- if (scene.numMeshes == 0 && scene.rootNode != null) {
- val root = root ?: scene.rootNode
+ if (scene.numMeshes == 0) {
+ val r = root ?: scene.rootNode
// build some faces around each node
- createGeometry(root)
+ createGeometry(r)
// create a mesh to hold all the generated faces
scene.numMeshes = 1
scene.meshes = arrayListOf(createMesh())
// and install it at the root node
- root.numMeshes = 1
- root.meshes = IntArray(1)
+ r.numMeshes = 1
+ r.meshes = IntArray(1)
// create a dummy material for the mesh
if (scene.numMaterials == 0){
scene.numMaterials = 1
diff --git a/src/main/kotlin/assimp/SpatialSort.kt b/src/main/kotlin/assimp/SpatialSort.kt
index cfbb1ed..720dbbe 100644
--- a/src/main/kotlin/assimp/SpatialSort.kt
+++ b/src/main/kotlin/assimp/SpatialSort.kt
@@ -20,13 +20,13 @@ class SpatialSort{
}
fun finalize() {
- val array = mPositions.toArray() as Array
+ val array = mPositions.toTypedArray()
Arrays.sort(array)
mPositions.clear()
mPositions.addAll(array)
}
- fun append(pPositions: List,pNumPositions: Int,pElementOffset: Int, pFinalize: Boolean = true)
+ fun append(pPositions: List,pNumPositions: Int, pElementOffset: Int, pFinalize: Boolean = true)
{
// store references to all given positions along with their distance to the reference plane
val initial = mPositions.size
diff --git a/src/main/kotlin/assimp/format/X/ConvertToLHProcess.kt b/src/main/kotlin/assimp/format/X/ConvertToLHProcess.kt
index b35318f..bfa00f2 100644
--- a/src/main/kotlin/assimp/format/X/ConvertToLHProcess.kt
+++ b/src/main/kotlin/assimp/format/X/ConvertToLHProcess.kt
@@ -9,7 +9,6 @@ object MakeLeftHandedProcess {
fun Execute(pScene: AiScene) {
// Check for an existent root node to proceed
- assert(pScene.rootNode != null)
debug("MakeLeftHandedProcess: MakeLeftHandedProcess begin")
// recursively convert all the nodes
diff --git a/src/main/kotlin/assimp/format/X/XFileImporter.kt b/src/main/kotlin/assimp/format/X/XFileImporter.kt
index 8f96148..dc300fd 100644
--- a/src/main/kotlin/assimp/format/X/XFileImporter.kt
+++ b/src/main/kotlin/assimp/format/X/XFileImporter.kt
@@ -40,7 +40,7 @@ class XFileImporter : BaseImporter() {
// And create the proper return structures out of it
CreateDataRepresentationFromImport(scene, parser.mScene)
- if (scene.rootNode == null)
+ if (scene.rootNode == null) // TODO do we need some other kind of check here instead? This is never true
throw Error("XFile is ill-formatted - no content imported.")
}
@@ -56,11 +56,6 @@ class XFileImporter : BaseImporter() {
// read the global meshes that were stored outside of any node
if (pData.mGlobalMeshes.size() > 0) {
- // create a root node to hold them if there isn't any, yet
- if (pScene.rootNode == null) {
- pScene.rootNode = AiNode()
- pScene.rootNode.name = "\$dummy_node"
- }
// convert all global meshes and store them in the root node.
// If there was one before, the global meshes now suddenly have its transformation matrix...
@@ -69,10 +64,6 @@ class XFileImporter : BaseImporter() {
CreateMeshes(pScene, pScene.rootNode, pData.mGlobalMeshes)
}
- if (pScene.rootNode == null) {
- throw Error("No root node")
- }
-
// Convert everything to OpenGL space... it's the same operation as the conversion back, so we can reuse the step directly
//var convertProcess : MakeLeftHandedProcess = ();
MakeLeftHandedProcess.Execute(pScene)
@@ -240,15 +231,14 @@ class XFileImporter : BaseImporter() {
}
// convert all the materials given in the array
- for (a in 0 until pMaterials.size()) {
- var oldMat = pMaterials[a]
+ for (oldMatIndex in 0 until pMaterials.size()) {
+ val oldMat = pMaterials[oldMatIndex]
if (oldMat.mIsReference) {
// find the material it refers to by name, and store its index
- for (a in 0 until pScene.numMaterials) {
- var name: String
- name = pScene.materials[a].name!!
+ for (matIndex in 0 until pScene.numMaterials) {
+ val name = pScene.materials[matIndex].name!!
if ((name == oldMat.mName)) {
- oldMat.sceneIndex = a
+ oldMat.sceneIndex = matIndex
break
}
}
@@ -261,13 +251,13 @@ class XFileImporter : BaseImporter() {
continue
}
- var mat = AiMaterial()
+ val mat = AiMaterial()
var name: String?
name = (oldMat.mName)
mat.name = name
// Shading model: hardcoded to PHONG, there is no such information in an XFile
- // FIX (aramis): If the specular exponent is 0, use gouraud shading. This is a bugfix
+ // FIX (aramis): If the specular exponent is 0, use gouraud shading. This is oldMatIndex bugfix
// for some models in the SDK (e.g. good old tiny.x)
var shadeMode = if (oldMat.mSpecularExponent == 0.0f)
AiShadingMode.gouraud else AiShadingMode.phong
@@ -275,7 +265,7 @@ class XFileImporter : BaseImporter() {
mat.shadingModel = shadeMode
// material colours
// Unclear: there's no ambient colour, but emissive. What to put for ambient?
- // Probably nothing at all, let the user select a suitable default.
+ // Probably nothing at all, let the user select oldMatIndex suitable default.
mat.color = AiMaterial.Color()
mat.color!!.emissive = oldMat.mEmissive
mat.color!!.diffuse = AiColor3D(oldMat.mDiffuse) //Why conversion to 3D?
@@ -343,7 +333,7 @@ class XFileImporter : BaseImporter() {
} else if (-1 != sz.indexOf("emissive", s) || -1 != sz.indexOf("self", s)) {
mat.textures.add(AiMaterial.Texture(file = tex, type = AiTexture.Type.emissive, uvwsrc = (iEM++)))
} else {
- // Assume it is a diffuse texture
+ // Assume it is oldMatIndex diffuse texture
mat.textures.add(AiMaterial.Texture(file = tex, type = AiTexture.Type.diffuse, uvwsrc = (iDM++)))
}
}
@@ -455,17 +445,18 @@ class XFileImporter : BaseImporter() {
// now collect the vertex data of all data streams present in the imported mesh
var newIndex = 0
- var orgPoints: MutableList = mutableListOf() // from which original point each new vertex stems
+ val orgPoints: MutableList = mutableListOf() // from which original point each new vertex stems
orgPoints.resize(numVertices, { 0 })
for (c in 0 until faces.size()) {
- var f = faces[c] // index of the source face
- var pf = sourceMesh.mPosFaces[f] // position source face
+ val f = faces[c] // index of the source face
+ val pf = sourceMesh.mPosFaces[f] // position source face
// create face. either triangle or triangle fan depending on the index count
- var df = mesh.faces[c] // destination face
+ //var df = mesh.faces[c] // destination face
//df.numIndices = pf.mIndices.size(); //3
- df = MutableList(pf.mIndices.size(), { 0 }); mesh.faces[c]=df
+ val df = MutableList(pf.mIndices.size()) { 0 }
+ mesh.faces[c]=df
// collect vertex data for indices of this face
for (d in 0 until df.size()) {
@@ -481,7 +472,7 @@ class XFileImporter : BaseImporter() {
// texture coord sets
for (e in 0 until AI_MAX_NUMBER_OF_TEXTURECOORDS) {
if (e < mesh.textureCoords.size && mesh.hasTextureCoords(e)) {
- var tex = sourceMesh.mTexCoords[e][pf.mIndices[d]]
+ val tex = sourceMesh.mTexCoords[e][pf.mIndices[d]]
mesh.textureCoords[e][newIndex] = arrayOf(tex.x, 1.0f - tex.y
//, 0.0f //Not sure why this is in original C++ code, but not in kotlin port.
).toFloatArray()
@@ -547,7 +538,7 @@ class XFileImporter : BaseImporter() {
// reallocate scene mesh array to be large enough
var prevArray = pScene.meshes
- pScene.meshes.reserve(pScene.numMeshes + meshes.size(), {AiMesh()})
+ pScene.meshes.reserve(pScene.numMeshes + meshes.size()) { AiMesh() }
// pScene.mMeshes = ArrayList(pScene.mNumMeshes + meshes.size());
// if( prevArray!=null)
// {
diff --git a/src/main/kotlin/assimp/format/X/XFileParser.kt b/src/main/kotlin/assimp/format/X/XFileParser.kt
index 40bc208..d5e5911 100644
--- a/src/main/kotlin/assimp/format/X/XFileParser.kt
+++ b/src/main/kotlin/assimp/format/X/XFileParser.kt
@@ -150,9 +150,9 @@ class XFileParser() {
var guid: String = GetNextToken()
// read and ignore data members
- var running = true
+ val running = true
while (running) {
- var s: String = GetNextToken()
+ val s: String = GetNextToken()
if (s == "}")
break
@@ -230,30 +230,29 @@ class XFileParser() {
}
fun ParseDataObjectMesh(pMesh: Mesh) {
- var name: String
- var builder: StringBuilder = StringBuilder()
+ val builder: StringBuilder = StringBuilder()
readHeadOfDataObject(builder)
- var numVertices: Int = ReadInt()
- pMesh.mPositions.resize(numVertices, { AiVector3D() })
+ val numVertices: Int = ReadInt()
+ pMesh.mPositions.resize(numVertices) { AiVector3D() }
for (a in IntRange(0, numVertices - 1))
pMesh.mPositions.set(a, ReadVector3())
- var numPosFaces: Int = ReadInt()
- pMesh.mPosFaces.resize(numPosFaces, { Face() })
+ val numPosFaces: Int = ReadInt()
+ pMesh.mPosFaces.resize(numPosFaces) { Face() }
for (a in 0 until numPosFaces) {
- var numIndices: Int = ReadInt()
- var face: Face = pMesh.mPosFaces.get(a)
+ val numIndices: Int = ReadInt()
+ val face: Face = pMesh.mPosFaces.get(a)
for (b in IntRange(0, numIndices - 1)) {
face.mIndices.push_back(ReadInt())
}
TestForSeparator()
}
- var running = true
+ val running = true
while (running) {
- var objectName: String = GetNextToken()
+ val objectName: String = GetNextToken()
if (objectName.length == 0)
throw Error("Unexpected end of file while parsing mesh structure")
diff --git a/src/main/kotlin/assimp/format/X/fast_atof.kt b/src/main/kotlin/assimp/format/X/fast_atof.kt
index d42d959..649c3af 100644
--- a/src/main/kotlin/assimp/format/X/fast_atof.kt
+++ b/src/main/kotlin/assimp/format/X/fast_atof.kt
@@ -123,49 +123,50 @@ fun fast_atoreal_move(_c : Pointer, out : Pointer, check_comma :
fun strtoul10_64(_in : Pointer, _out : Pointer>?, max_inout : Pointer? = null) : Long
{
- var in_ = _in; var out_ = _out
- var cur : Int = 0;
- var value : Long = 0.toLong();
+ var in_ = _in;
+ val out_ = _out
+ var cur : Int = 0
+ var value : Long = 0.toLong()
if ( in_.value < '0' || in_.value > '9' )
- throw RuntimeException("The string \"" + in_.value + "\" cannot be converted into a value.");
+ throw RuntimeException("The string \"" + in_.value + "\" cannot be converted into a value.")
- var running = true;
- while ( running )
+
+ while ( true )
{
if ( in_.value < '0' || in_.value > '9' )
- break;
+ break
- var new_value : Long = ( value * 10 ) + ( in_.value - '0' );
+ val new_value : Long = (value * 10) + (in_.value - '0')
// numeric overflow, we rely on you
if ( new_value < value ) {
- warn("Converting the string \"" + in_.value + "\" into a value resulted in overflow." );
- return 0;
+ warn("Converting the string \"" + in_.value + "\" into a value resulted in overflow." )
+ return 0
}
//throw std::overflow_error();
- value = new_value;
+ value = new_value
- ++in_;
- ++cur;
+ ++in_
+ ++cur
- if (max_inout!=null && max_inout!!.value == cur) {
+ if (max_inout!=null && max_inout.value == cur) {
if (out_!=null) { /* skip to end */
- while (in_.value >= '0' && in_.value <= '9')
- ++in_;
- out_.value=in_;
+ while (in_.value in '0'..'9')
+ ++in_
+ out_.value=in_
}
- return value;
+ return value
}
}
if (out_!=null)
- out_.value = in_;
+ out_.value = in_
if (max_inout != null)
- max_inout!!.value = cur;
+ max_inout.value = cur
return value;
}
\ No newline at end of file
diff --git a/src/main/kotlin/assimp/format/assbin/AssbinLoader.kt b/src/main/kotlin/assimp/format/assbin/AssbinLoader.kt
index 3f46d8f..70a2dd1 100644
--- a/src/main/kotlin/assimp/format/assbin/AssbinLoader.kt
+++ b/src/main/kotlin/assimp/format/assbin/AssbinLoader.kt
@@ -28,10 +28,10 @@ class AssbinLoader : BaseImporter() {
it.skip(44) // signature
- val a = it.int(be) // unsigned int versionMajor
- val b = it.int(be) // unsigned int versionMinor
- val c = it.int(be) // unsigned int versionRevision
- val d = it.int(be) // unsigned int compileFlags
+ /* unused */ it.int(be) // unsigned int versionMajor
+ /* unused */ it.int(be) // unsigned int versionMinor
+ /* unused */ it.int(be) // unsigned int versionRevision
+ /* unused */ it.int(be) // unsigned int compileFlags
shortened = it.short(be).bool
compressed = it.short(be).bool
diff --git a/src/main/kotlin/assimp/format/assxml/AssxmlExporter.kt b/src/main/kotlin/assimp/format/assxml/AssxmlExporter.kt
index 2dbd02f..b3e09f5 100644
--- a/src/main/kotlin/assimp/format/assxml/AssxmlExporter.kt
+++ b/src/main/kotlin/assimp/format/assxml/AssxmlExporter.kt
@@ -91,19 +91,17 @@ class AssxmlExporter {
}
fun WriteDump(scene : AiScene, io : StringBuilder, shortened : Boolean) {
- var tt=Calendar.getInstance(TimeZone.getTimeZone("GMT"))
- var p = SimpleDateFormat("HH:mm:ss").format(tt.time)
- assert(p!=null)
+ val tt=Calendar.getInstance(TimeZone.getTimeZone("GMT"))
+ val curtime = SimpleDateFormat("HH:mm:ss").format(tt.time)!!
// write header
- var header=(
+ val header=(
"\n\n\n $cleaned" }
}
@@ -456,15 +456,15 @@ class ObjFileImporter : BaseImporter() {
}
}
-
// TODO this is pretty much a copy past from gli.read(...) and should be added there
-private fun loadImageFromMemory(file: IOStream, type: String): Texture {
+private var tgaAdded = false
+private fun loadImageFromMemory(buffer: ByteBuffer, type: String): Texture {
return when(type) {
- "dds" -> gli.loadDds(file.readBytes())
- "kmg" -> gli.loadKmg(file.readBytes())
- "ktx" -> gli.loadKtx(file.readBytes())
+ "dds" -> gli.loadDds(buffer)
+ "kmg" -> gli.loadKmg(buffer)
+ "ktx" -> gli.loadKtx(buffer)
"jpeg", "jpg", "png", "gif", "bmp", "wbmp" -> {
- val image = ImageIO.read(file.read())
+ val image = ImageIO.read(ByteBufferBackedInputStream(buffer))
gli.createTexture(image)
}
"tga" -> {
@@ -472,43 +472,9 @@ private fun loadImageFromMemory(file: IOStream, type: String): Texture {
IIORegistry.getDefaultInstance().registerServiceProvider(TgaImageReaderSpi())
tgaAdded = true
}
- val image = ImageIO.read(file.read())
+ val image = ImageIO.read(ByteBufferBackedInputStream(buffer))
gli.createTexture(image)
}
else -> throw IllegalArgumentException("Type not supported")
}
-}
-
-
-private var tgaAdded = false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+}
\ No newline at end of file
diff --git a/src/main/kotlin/assimp/format/obj/ObjFileParser.kt b/src/main/kotlin/assimp/format/obj/ObjFileParser.kt
index 515a819..4f0bde4 100644
--- a/src/main/kotlin/assimp/format/obj/ObjFileParser.kt
+++ b/src/main/kotlin/assimp/format/obj/ObjFileParser.kt
@@ -39,7 +39,7 @@ class ObjFileParser(private val file: IOStream, val ioSystem: IOSystem) {
fun parseFile(streamBuffer: BufferedReader) {
- var line: String? = ""
+ var line: String?
do {
//Support for continuationToken
line = ObjTools.getNextDataLine(streamBuffer, "\\")
diff --git a/src/main/kotlin/assimp/format/stl/STLLoader.kt b/src/main/kotlin/assimp/format/stl/STLLoader.kt
index 719f5a6..4016f49 100644
--- a/src/main/kotlin/assimp/format/stl/STLLoader.kt
+++ b/src/main/kotlin/assimp/format/stl/STLLoader.kt
@@ -3,7 +3,6 @@ package assimp.format.stl
import assimp.*
import glm_.*
import unsigned.ushr
-import java.io.IOException
import java.nio.ByteBuffer
import java.util.*
@@ -74,9 +73,9 @@ class StlImporter : BaseImporter() {
// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
- override fun canRead(pFile: String, ioSystem: IOSystem, checkSig: Boolean): Boolean {
+ override fun canRead(file: String, ioSystem: IOSystem, checkSig: Boolean): Boolean {
- val extension = pFile.substring(pFile.lastIndexOf('.') + 1)
+ val extension = file.substring(file.lastIndexOf('.') + 1)
if (extension == "stl") {
return true
@@ -209,13 +208,13 @@ class StlImporter : BaseImporter() {
if ((color and (1 shl 15)) != 0.s) {
// seems we need to take the color
- if (pMesh.colors[0] == null) {
+ if (pMesh.colors[0] == null) { // TODO should there be a case where this is null? In that case the AIMesh class does not represent the data correctly
pMesh.colors[0] = Array(pMesh.numVertices, { AiColor4D(clrColorDefault) }).toMutableList()
logger.info { "STL: Mesh has vertex colors" }
}
- val clr = pMesh.colors[0]!![i * 3]
+ val clr = pMesh.colors[0][i * 3]
clr.a = 1f
val invVal = 1f / 31
if (bIsMaterialise) { // this is reversed
@@ -235,7 +234,7 @@ class StlImporter : BaseImporter() {
}
}
// now copy faces
- addFacesToMesh(pMesh);
+ addFacesToMesh(pMesh)
// use the color as diffuse material color
return bIsMaterialise && pMesh.colors[0] == null
diff --git a/src/main/kotlin/assimp/postProcess/ValidateDataStructure.kt b/src/main/kotlin/assimp/postProcess/ValidateDataStructure.kt
index 3a15baf..2033a03 100644
--- a/src/main/kotlin/assimp/postProcess/ValidateDataStructure.kt
+++ b/src/main/kotlin/assimp/postProcess/ValidateDataStructure.kt
@@ -407,7 +407,7 @@ class ValidateDSProcess : BaseProcess() {
if (i > 0 && boneAnim.rotationKeys[i].time <= last) {
val t = "%.5f".format(boneAnim.rotationKeys[i].time)
val l = "%.5f".format(last)
- reportWarning("AiNodeAnim.rotationKeys[$i].time ($t) is smaller than AiAnimation.rotationKeys[${i - 1}] (which is $last)")
+ reportWarning("AiNodeAnim.rotationKeys[$i].time ($t) is smaller than AiAnimation.rotationKeys[${i - 1}] (which is $l)")
}
last = boneAnim.rotationKeys[i].time
}
@@ -491,7 +491,7 @@ class ValidateDSProcess : BaseProcess() {
}
}
- /** extended version: checks whethr T.name occurs twice */
+ /** extended version: checks whether T.name occurs twice */
fun doValidationEx(array: ArrayList<*>, size: Int, firstName: String, secondName: String) {
// validate all entries
if (size > 0) {
@@ -508,6 +508,7 @@ class ValidateDSProcess : BaseProcess() {
is AiMaterial -> validate(element)
}
// check whether there are duplicate names
+ @Suppress("UNCHECKED_CAST")
for (a in i + 1 until size) {
val propI = element::class.memberProperties.find { it.name == "name" } as KMutableProperty1
val nameI = propI.get(element)
diff --git a/src/main/kotlin/assimp/sceneCombiner.kt b/src/main/kotlin/assimp/sceneCombiner.kt
index a6807c8..a4372a8 100644
--- a/src/main/kotlin/assimp/sceneCombiner.kt
+++ b/src/main/kotlin/assimp/sceneCombiner.kt
@@ -275,7 +275,7 @@ object SceneCombiner {
var n = src.lastIndex
while (n >= 0) { /* !!! important !!! */
val cur = src[n]
- var node: AiNode? = null
+ var node: AiNode?
// To offset or not to offset, this is the question
if (n != duplicates[n]) {
diff --git a/src/test/kotlin/X/helpers.kt b/src/test/kotlin/X/helpers.kt
index 90885db..c987e63 100644
--- a/src/test/kotlin/X/helpers.kt
+++ b/src/test/kotlin/X/helpers.kt
@@ -92,7 +92,7 @@ fun compareNode(rootNode: AiNode, rootNode1: AiNode) {
}
fun compareMetaData(aiMetadata: AiMetadata, aiMetadata1: AiMetadata) {
-
+ // TODO
}
fun compareMaterials(a1: AiMaterial, a2: AiMaterial) {
diff --git a/src/test/kotlin/assimp/anchor.kt b/src/test/kotlin/assimp/anchor.kt
index d4a601a..65b817f 100644
--- a/src/test/kotlin/assimp/anchor.kt
+++ b/src/test/kotlin/assimp/anchor.kt
@@ -62,16 +62,14 @@ fun Importer.testFile(path: String,
verify: AiScene.() -> Unit = {}): AiScene? {
logger.info { "Testing read $path:" }
- var scene: AiScene? = null
logger.info { "reading from file:"}
- scene = readFile(path, flags)
+ var scene = readFile(path, flags)
if (scene == null && failOnNull) {
fail("readFile returned 'null' for $path")
- } else {
- scene?.verify()
}
+ scene?.verify()
logger.info { "reading from memory:" }
@@ -84,9 +82,8 @@ fun Importer.testFile(path: String,
val memScene = readFileFromMemory(buffer, flags, hint)
if (memScene == null && failOnNull) {
fail("readFileFromMemory returned 'null' for $path")
- } else {
- memScene?.verify()
}
+ memScene?.verify()
if(scene == null) scene = memScene
diff --git a/src/test/kotlin/assimp/assxml/implementation_test.kt b/src/test/kotlin/assimp/assxml/implementation_test.kt
index a81427f..50877dd 100644
--- a/src/test/kotlin/assimp/assxml/implementation_test.kt
+++ b/src/test/kotlin/assimp/assxml/implementation_test.kt
@@ -6,11 +6,10 @@ import io.kotlintest.specs.StringSpec
class implementation_test : StringSpec() {
init {
- var test = "String formatting"
+ val test = "String formatting"
test {
- var a = AssxmlExporter()
- var prefix : String = Array(1, { '\t' }).joinToString(separator = "")
- var m = AiMatrix4x4()
+ val prefix : String = Array(1, { '\t' }).joinToString(separator = "")
+ val m = AiMatrix4x4()
// println(String.format("%s", "hello"))
// println(String.format("%10.6f", Random().nextFloat()))
@@ -18,24 +17,24 @@ class implementation_test : StringSpec() {
//exit(0)
- var r = String.format("%s \n" + "%s\t \n" +
- "%s\t\t%10.6f %10.6f %10.6f %10.6f\n" +
- "%s\t\t%10.6f %10.6f %10.6f %10.6f\n" +
- "%s\t\t%10.6f %10.6f %10.6f %10.6f\n" +
- "%s\t\t%10.6f %10.6f %10.6f %10.6f\n" +
- "%s\t \n",
- prefix, "dummy", prefix,
- prefix, m.a0, m.a1, m.a2, m.a3,
- prefix, m.b0, m.b1, m.b2, m.b3,
- prefix, m.c0, m.c1, m.c2, m.c3,
- prefix, m.d0, m.d1, m.d2, m.d3,
- prefix
- )
+ val r = String.format("%s \n" + "%s\t \n" +
+ "%s\t\t%10.6f %10.6f %10.6f %10.6f\n" +
+ "%s\t\t%10.6f %10.6f %10.6f %10.6f\n" +
+ "%s\t\t%10.6f %10.6f %10.6f %10.6f\n" +
+ "%s\t\t%10.6f %10.6f %10.6f %10.6f\n" +
+ "%s\t \n",
+ prefix, "dummy", prefix,
+ prefix, m.a0, m.a1, m.a2, m.a3,
+ prefix, m.b0, m.b1, m.b2, m.b3,
+ prefix, m.c0, m.c1, m.c2, m.c3,
+ prefix, m.d0, m.d1, m.d2, m.d3,
+ prefix
+ )
println(r)
println(r.length)
println(r.isBlank())
- var io= StringBuilder()
+ val io= StringBuilder()
AssxmlExporter.ioprintf(io, "%s \n%s\t \n%s\t\t%10.6f %10.6f %10.6f %10.6f\n%s\t\t%10.6f %10.6f %10.6f %10.6f\n%s\t\t%10.6f %10.6f %10.6f %10.6f\n%s\t\t%10.6f %10.6f %10.6f %10.6f\n%s\t \n".format(
prefix, "node1", prefix,
prefix, m.a0, m.b0, m.c0, m.d0,