niacdoial / blemd

BMD importer for blender (BDL format also partially supported)
GNU General Public License v3.0
32 stars 13 forks source link

infinite loops when bmd file does not contain a tex section #40

Closed lolRazor closed 2 years ago

lolRazor commented 4 years ago

3068690cd5ca75ac8fd1c289d3898ef7 801ccbfc76db468d7d51a263152dad6b 1ec83e83958f7e0ee998efe23e5568cf No clue why this isnt working

Roseghost commented 3 years ago

^ +1, no clue how to solve it

niacdoial commented 2 years ago

OK, I have no idea how I saw this issue (twice!) and never realised what the problem actually was (early End Of File) so, er… in BModel.py, now around line 464, there is a block of lines like this:

        while strTag != "TEX" and not br.is_eof():  # "TEX1 tag is the last one every time"
            br.SeekCur(iSize)
            streamPos = br.Position()
            strTag = br.ReadFixedLengthString(3)
            _ = br.GetByte()
            iSize = br.ReadDWORD()

try to add those two lines:

        while strTag != "TEX" and not br.is_eof():  # "TEX1 tag is the last one every time"
            br.SeekCur(iSize)
            streamPos = br.Position()
+           if br.is_eof():
+               break
            strTag = br.ReadFixedLengthString(3)
            _ = br.GetByte()
            iSize = br.ReadDWORD()

does it fix the problem? If not, is the error message at least different ?

Th3DryZ69 commented 2 years ago

so I no longer have the error message when doing this, but I have Blender which loads indefinitely trying to load the file

niacdoial commented 2 years ago

…right. This might be another bug altogether. what does the stack trace look like when you do Ctrl-C in the terminal after it loaded for a while ? just to see what loop it might be stuck on.

Th3DryZ69 commented 2 years ago

I open blender I load the file for a little while then I press ctrl+c?

niacdoial commented 2 years ago

yep! in a terminal/console window, Ctrl+C means "interrupt!" instead of "copy" You just need to actually show the terminal window first, with… I think the option is in the "windows" menu of the toolbar at the top of blender?

Th3DryZ69 commented 2 years ago

image here is the error

niacdoial commented 2 years ago

ok. now, just to know if the bug is in the python code or the C code, if you change the area of common.py around line 117 like this:

+   print("call start")
    temp = subprocess.run([exefile] + args, shell=False)
    if temp.stdout:
        log.info ("process output:\n %s", temp.stdout)
    if temp.stderr:
        log.error('process errors:\n %s', temp.stderr)
+    print("call end")

does blemd repeat "call start/call end" without stopping, or does it just freeze after saying "call start"?

Th3DryZ69 commented 2 years ago

it does not write it in the console of blender it redoes the same thing as the screen above

niacdoial commented 2 years ago

oh sorry, I forgot to ask you to delete the images again. but er… how much did you wait before using ctrl+C? Because if it hangs even without calling the bundled C program, it might have been too soon.

Th3DryZ69 commented 2 years ago

if i do nothing it keeps spamming in blender console (read ic)

niacdoial commented 2 years ago

ooooh! I see exactly where the bug is. er… would you be able to recompile the bmdview.cpp file into the bmdview.exe program if I asked you to? to know if I should send you the patch, or just put it in a commit. (probably not tonight though, it's getting late)

Th3DryZ69 commented 2 years ago

I don't think so, I don't know much about coding

niacdoial commented 2 years ago

ok. er… dang, I just realised I won't have access to a windows machine for a while, so compiling it myself won't be easy. bluh.

Th3DryZ69 commented 2 years ago

I'll look into how to do it

niacdoial commented 2 years ago

er… thanks!

Th3DryZ69 commented 2 years ago

I've tried looking at several tutorials and I just can't do it.

niacdoial commented 2 years ago

ok, no problem. I'll see what I can do on my side of things.

edbefee3-3888-462a-9411-741b7e9eb54e commented 2 years ago

Well, i don't think that it not working with 2.77 is much of an "issue" anymore

niacdoial commented 2 years ago

yeah, the title needs to be revamped

edbefee3-3888-462a-9411-741b7e9eb54e commented 2 years ago

is there any BMD file without textures you can think of? i might try tweaking the code to fix this

niacdoial commented 2 years ago

oh, I know what fix can be done, I just don't have a way to re-compile the c++ file for windows systems anymore

edbefee3-3888-462a-9411-741b7e9eb54e commented 2 years ago

I'm trying to see if there's a different solution and that'd require a bmd file without textures

niacdoial commented 2 years ago

another solution would be to not call bmdview.exe whenever blemd detects that the Tex section is missing. (given that the first infinite loop can be solved with the patch in a message higher in this conversation)

edbefee3-3888-462a-9411-741b7e9eb54e commented 2 years ago

that's what I was thinking of, but i need a file to test it with

niacdoial commented 2 years ago

I don't think I have one, I just asked CrbzBrandon whenever I had a patch that I thought worked.

edbefee3-3888-462a-9411-741b7e9eb54e commented 2 years ago

Looking at the third image, it seems to be from pixelmon?

edbefee3-3888-462a-9411-741b7e9eb54e commented 2 years ago

the directory structure matches, and pixelmon did use .bmd at some point

edbefee3-3888-462a-9411-741b7e9eb54e commented 2 years ago

but it does not seem to be the same BMD as the one you're trying to load, I couldn't get STB or J3DView to view it either. the original BMDView also gets stuck in a loop.

Th3DryZ69 commented 2 years ago

that's exactly what I'm trying to have also the model and texture of the pixelmon mod

edbefee3-3888-462a-9411-741b7e9eb54e commented 2 years ago

it's a completely different format. the pixelmon one has a blender signature in it, and doesn't have the magic J3D x bmd/bdl y at offset 0x00, a list of materials at the end, and the occasional "this is padding data"

Th3DryZ69 commented 2 years ago

so there is no way to open them?

edbefee3-3888-462a-9411-741b7e9eb54e commented 2 years ago

Not that I'm aware of