QodotPlugin / qodot-plugin

(LEGACY) Quake .map support for Godot 3.x
MIT License
960 stars 70 forks source link

'Filter' texture flag defaults to 'on' when using new textures and rebuilding #155

Open Bropocalypse opened 2 years ago

Bropocalypse commented 2 years ago

I'm currently using pixellated graphics in my project and I've noticed that rebuilding a map in Godot causes the newly added textures' filters to default their 'Filter' flag to 'On' even though it was deliberately turned 'Off' when imported into Godot(I know because I set them manually). This behavior does not occur on subsequent rebuilds after re-setting the flag back to 'Off'(it only happens to textures newly added to the texture collection in TrenchBroom), but it's a little annoying.

Steps to reproduce: 1) Import a texture into Godot(in my case I use .PNG files), placing it into TrenchBroom's designated textures folder. 2) Set the texture's 'Filter' flag to 'Off'. 3) Refresh the texture collections in Trenchbroom and use the new texture in the current map. Save the file. 4) In Godot, press 'Quick Build' or 'Full Build' to rebuild the map. 5) Check the texture's flags(you may need to click on a different one and then back again to refresh the Import tab's display). 6) the flag will be defaulted to 'On'. You can turn it off and re-import it and it will behave normally.

Godot v3.4.4.stable.official [419e713a2] Qodot 1.7.1 TrenchBroom v2021.1 (release Linux)

disco0 commented 2 years ago

Was in similar situation for a modding project involving external user textures, ended up setting the relevant flags on textures (Texture.FLAG_REPEAT | Texture.FLAG_ANISOTROPIC_FILTER) when they're created qodot_texture_loader.gd:

func load_texture(texture_name: String) -> Texture:
    if(texture_name == TEXTURE_EMPTY):
        return null

    # Load image as texture if it's external
    if texture_name in external_texture_dict:
        var dict_value = external_texture_dict[texture_name]
        var img = Image.new()
        var err = img.load(external_texture_dict[texture_name])
        if err == 0:
            var tex = ImageTexture.new()
            tex.create_from_image(img)
            tex.flags = Texture.FLAG_REPEAT | Texture.FLAG_ANISOTROPIC_FILTER
            return tex as Texture
        else:
            return null
# ...

Its in a added external texture dictionary lookup, but it still should apply to any other texture creation