Parik27 / DragonFF

Blender Add-on to edit RenderWare and GTA Formats
GNU General Public License v3.0
366 stars 128 forks source link

Images aren't shared among imported materials (check_existing=True issue) #14

Open swift502 opened 5 years ago

swift502 commented 5 years ago

Hi,

I'd really like to solve this because it's the last remaining piece for me.

The check_existing option used here doesn't seem to work:

https://github.com/Zarig/DragonFF/blob/40762f456a6b446e941ace4f7d32cdf1bed2415f/gta/dff_importer.py#L269-L273

I tried to find what exactly happens in Blender's source (maybe it's an actual bug?), but I ended up here, and don't really know where it leads. I can't find this "load" function anywhere:

https://github.com/dfelinto/blender/blob/78f8679cfc6d6e8f19d84908ab4343ce6638faf3/release/scripts/modules/bpy_extras/image_utils.py#L106

I tried all sorts of things and additional options and nothing seems to work. Any ideas on what's causing this?

swift502 commented 5 years ago

Ok I think the actual function is here. https://github.com/dfelinto/blender/blob/483ae407d9d1b2b173face0efb96f2d287d51ea4/source/blender/blenkernel/intern/image.c#L566-L604

Parik27 commented 5 years ago

Yeah, not sure what's wrong there. It seems to be checking for the images. Might depend on context, not sure about that either.

swift502 commented 5 years ago

I hopefully solved it in a dirty (again) way. https://github.com/swift502/DragonFF/commit/ed9c4042df955eb0458c068b977653590e69ed45

And to be honest, I don't even understand how the material merging in your master worked for me in the first place, because the list which holds the loaded materials is reset on every dff import isn't it?

But I never noticed any duplicate materials when importing the maps, so I don't know. Maybe there just isn't that many shared materials.