Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collada bug #31

Merged
merged 3 commits into from
Sep 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/kotlin/assimp/BaseImporter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ abstract class BaseImporter {
} catch (err: Exception) {
// extract error description
logger.error(err) {}
errorText = err.localizedMessage
return null
}
// return what we gathered from the import.
Expand Down
3 changes: 1 addition & 2 deletions src/main/kotlin/assimp/format/collada/ColladaLoader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -644,9 +644,8 @@ class ColladaLoader : BaseImporter() {
// for some exporters, but we won't care of it unless someone complains about.
tex.uvwsrc = when {
sampler.mUVId != Uint.MAX_VALUE.i -> sampler.mUVId // TODO MAX_VALUE to Int
else -> sampler.mUVChannel.firstOrNull(Char::isNumeric)?.let {
else -> sampler.mUVChannel.firstOrNull(Char::isNumeric)?.minus('0') ?: 0.also {
logger.warn { "Collada: unable to determine UV channel for texture" }
0
}
}

Expand Down
12 changes: 8 additions & 4 deletions src/main/kotlin/assimp/format/collada/ColladaParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,12 @@ class ColladaParser(pFile: IOStream) {
reader = factory.createXMLEventReader(pFile.reader())

// start reading
readContents()
try {
readContents()
} catch (e: Exception) {
error("Collada parse error at line ${event.location.lineNumber}, column ${event.location.columnNumber}, in \"${pFile.path}\"")
}

}

/** Read bool from text contents of current element */
Expand Down Expand Up @@ -597,9 +602,8 @@ class ColladaParser(pFile: IOStream) {
mMaterialLibrary[id] = Material() // create an entry and store it in the library under its ID
if (name.isNotEmpty()) {
if (names.contains(name)) {
val nextId = names.keys.sorted().indexOf(name) + 1
val nextName = names.keys.sorted()[nextId]
name += " " + names[nextName]
names[name] = 1 + names[name]!!
name += " " + names[name]
} else names[name] = 0
mMaterialLibrary[id]!!.mName = name
}
Expand Down