Skip to content

Conversation

@Wasabi375
Copy link
Contributor

I'm still working on it but I thought I might as well create the pr now, so that this is visible.
There are still a few tests failing. I'm not sure if this is due to the fact that some tests fail on master or that some of the Importers are still trying to access files on the drive directly as I have not yet looked at those tests.

Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
some todos about importers not working from memory

Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
@Sylvyrfysh
Copy link
Collaborator

Why does XFileImporter check if the file exists before opening, while BlenderLoader does not? I see blender is disabled, but would still like the coding to be consistent. My personal opinon on this is that we should not be checking if the file exists since the open function appears to check if the file exists itself.

Also, the exists function in DefaultIOStream compated to Files.exists(path) should be addressed. Both exist in the code and it leads to a little more fragmentation I feel could be unified.

Copy link
Collaborator

@Sylvyrfysh Sylvyrfysh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove the checks if files exist myself as open will throw a IOException otherwise, and a stacktrace will be sufficient to see which model opening failed.


// Check whether we can read from the file
if (!file.canRead())
if (!ioSystem.exists(file))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but we again check here

// with positions that match each other or not?
// If I move duplicate back here I need to also adjust the byte order here
// Then I no longer need to change it in MemoryIOSystem.open
override fun readBytes(): ByteBuffer = buffer
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would call duplicate here, then remove all other duplicates in the code while making sure the internal buffer is not used

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you are right. This way there should also be only this one place where we need to call duplicate which means that we only have to call order(ByteOrder.nativeOrder()) once. For some reason duplicate resets the byteOrder to BIG_ENDIAN.


// Read file into memory
this.file = file//File(file)
if (!ioSystem.exists(file)) throw IOException("Failed to open file $file.")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not your change, but we check if exists here. Change?


// Check whether we can read from the file
if (!file.canRead()) throw IOException("Failed to open PLY file $file.")
if (!ioSystem.exists(file)) throw IOException("Failed to open PLY file $file.")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checking if exists


// Check whether we can read from the file
if (!file.canRead()) throw IOException("Failed to open STL file $pFile.")
if (!ioSystem.exists(file)) throw IOException("Failed to open STL file $file.")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checking if file exists

@Wasabi375
Copy link
Contributor Author

I agree with you I think. I did not yet take the time to make sure all the different importers are consistent in the way the do things. I noticed of cause that they are. For some reason one of them is using a pointer to a ByteArray instead of a Buffer for example.
I was planning on going over some of it. AFAIK they follow the original C code closely which might explain some of it. I'll see what I can do there.
I also like your idea of removing the existence checks before calling open. They are as you pointed out unnecessary. I just added them because they where there already just using the "old" system.

The places where it's still using File(filename) I just have not yet changed. The reason is that some of the file formats expect multiple files or at least sometimes do (I think md3, md5 and obj). I either need to change MemoryIOSystem so it can somehow contain multiple files or create another class maybe MemoryMultiFileIOSystem. I tend towards the first solution.


Something else to consider is the filename for memory files, especially in memoryIOSystems with multiple files. They can't all be called AI_MEMORYIO_MAGIC_FILENAME and so far I don't see any reason why any of them needs to be called like this. As far as I can tell this name will not work with the multi-file formats anyways as they need the filename to find the other files.

ObjImporter now loads multi file objects

Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
…with a different test name)

Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
…versions

Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
Q3Shader.loadShader(fill, "$path../../../scripts/$filename.shader")
// TODO read from memory: how do we resolve ../../..
if (!Q3Shader.loadShader(fill, "$path../../../scripts/$modelFile.shader", ioSystem))
Q3Shader.loadShader(fill, "$path../../../scripts/$filename.shader", ioSystem)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really sure what to do here. I could implement a fully functioning path system but I'm not sure if that is not a bit overkill. The other option would be, that if you want to load relative paths like this from memory that you need to specify those in the name. So you actually name a file "somePath/../../../scripts/moduleName.shader".
This would work right now. Don't think it's a good solution though...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't find a solution now, we can postpone the decision until someone needs this and find together a solution

Copy link
Contributor Author

@Wasabi375 Wasabi375 Sep 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I see 3 solutions:

  1. leave it as it is, there is a simple workaround I used in the test
  2. modify the ioSystem so that it resolves ".." in a way that it removes the last directory
  3. change the ioSystem so it uses java.nio.file.Path instead of Strings to represent a file. That way resolving paths would be trivial, but implementing Path and FileSystem/FileSystemProvider takes a lot of effort and I don't think it's worth it.

I think for now we can leave it and maybe implement option 2 later.
I created an issue for it: #17

Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
@Wasabi375
Copy link
Contributor Author

So long as I have not missed anything, I think this should be all 😉 Would be nice if you guys could look over it again.
Also I think this might be a good point to push a new release. The current one is broken after all.

Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
@Wasabi375 Wasabi375 requested a review from Sylvyrfysh September 6, 2018 05:54
@elect86
Copy link
Collaborator

elect86 commented Sep 6, 2018

For me is fine, as soon as @Sylvyrfysh gives me the green light I can publish it

}


// TODO this is pretty much a copy past from gli.read(...) and should be added there
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@elect86 You are working on gli right? Can you add a readFromMemory there or should I just sent a PR there myself?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I sent you an invite for the organization, so that you can automatically work on that without me having to invite for each single repo (I did the same for @Sylvyrfysh)

@Sylvyrfysh
Copy link
Collaborator

Looks good!

@elect86
Copy link
Collaborator

elect86 commented Sep 6, 2018

I was trying to run the "build" gradle task but the tests seems not perceived

Also, trying to run a single test, such as assbin, fails with the following

Does it work on your machines, guys?

Edit: looking more carefully the html reports shows most of the tests failing because of


java.nio.file.InvalidPathException: Illegal char <:> at index 2: /C:/Users/elect/IdeaProjects/assimp/build/resources/test/models/X//BCN_Epileptic.X
	at java.base/sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
	at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
	at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
	at java.base/sun.nio.fs.WindowsPath.parse(WindowsPath.java:92)
	at java.base/sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:229)
	at java.base/java.nio.file.Paths.get(Paths.java:84)
	at assimp.DefaultIOSystem.open(DefaultIOSystem.kt:14)
	at assimp.format.assbin.AssbinLoader.canRead(AssbinLoader.kt:23)
	at assimp.Importer.readFile(Importer.kt:281)
	at assimp.Importer.readFile(Importer.kt:237)
	at assimp.AnchorKt.testFile(anchor.kt:45)
	at assimp.AnchorKt.testFile(anchor.kt:33)
	at assimp.AnchorKt.testFile$default(anchor.kt:32)
	at X.BCN_Epileptic$1.invoke(BCN_Epileptic.kt:14)
	at X.BCN_Epileptic$1.invoke(BCN_Epileptic.kt:8)
	at io.kotlintest.runner.jvm.TestCaseExecutor$executeTestSet$1.run(TestCaseExecutor.kt:94)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
	at java.base/java.lang.Thread.run(Thread.java:844)

@Wasabi375
Copy link
Contributor Author

Are you running own windows? It's the only platform I have not tested. All tests run fine on my mac and the travis build is on linux I think. I'll load the project up on my windows computer tomorrow and see if I get the same problem.

@Wasabi375
Copy link
Contributor Author

Also if you look at the path it's trying to load, it seems to be invalid.
It starts with "/C:/". But there should not be a / at the start. I guess it is trying to resolve it as a relative path which is not allowed to contain colons. I have no idea though why it would create this path.

@Sylvyrfysh
Copy link
Collaborator

Sylvyrfysh commented Sep 7, 2018 via email

Signed-off-by: Burkhard Mittelbach <wasabi37a@googlemail.com>
@Wasabi375
Copy link
Contributor Author

I can't reproduce the bug @elect86 described. I just tested the project on my windows pc as well. I found another small bug though. I hate that windows is using \ instead of / as a separator.....

@Sylvyrfysh
Copy link
Collaborator

Whatever change you made, worked. Windows works again for me

@Wasabi375
Copy link
Contributor Author

Strange, my change should only effect MD3 loading.

@elect86
Copy link
Collaborator

elect86 commented Sep 7, 2018

I use both window and linux, although I was on windows 10 x64 when I tested that.

Problem persist, I'll try to debug. Windows is indeed more tedious in this regard..

However I wonder why the test result interface changed in Idea, I recall in the past all the test, passed and not, were listed, now no more. Do you have any tips about that?

@elect86
Copy link
Collaborator

elect86 commented Sep 7, 2018

So, I managed to fix it on my machine. I'd like now a feedback from you :)

Ps: I notice that I can have the test interface I meant if I run a test singularly

https://imgur.com/g7Ej6F6

@Sylvyrfysh
Copy link
Collaborator

thoroughly off topic but still relevant: should we create a slack or something so we can communicate easier on this

@elect86 elect86 merged commit 40bea13 into kotlin-graphics:master Sep 7, 2018
@Sylvyrfysh
Copy link
Collaborator

did the windows fix get merged here?

@elect86
Copy link
Collaborator

elect86 commented Sep 7, 2018

Our traffic is quite low in average, therefore I'd suggest to use lwjgl or kotlin slack

Actually I messed up, I thought to pull his modifications, but I was working on the master, now I reverted my mistaken push.. in this regards, how can I pull a push request?

Ps: thanks @Wasabi375 for your push :)

Edit: it seems there is still no viable gui option, https://stackoverflow.com/questions/40217494/how-to-review-a-pull-request-in-intellij-idea

@Sylvyrfysh
Copy link
Collaborator

Do you still want to un-pull?

@elect86
Copy link
Collaborator

elect86 commented Sep 8, 2018

No, it's fine, thanks

elect86 added a commit that referenced this pull request Sep 23, 2018
Followup to PR #16 (read from memory)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants