diff --git a/src/bsp/Bsp.cpp b/src/bsp/Bsp.cpp index aa077596..f34ef696 100644 --- a/src/bsp/Bsp.cpp +++ b/src/bsp/Bsp.cpp @@ -2171,10 +2171,18 @@ void update_unused_wad_files(Bsp* baseMap, Bsp* targetMap, int tex_type) { unsigned int colorCount = 256; COLOR3 palette[256]; - if (g_settings.pal_id >= 0) + if (!targetMap->is_texture_has_pal) { - colorCount = g_settings.palettes[g_settings.pal_id].colors; - memcpy(palette, g_settings.palettes[g_settings.pal_id].data, g_settings.palettes[g_settings.pal_id].colors * sizeof(COLOR3)); + if (g_settings.pal_id >= 0) + { + colorCount = g_settings.palettes[g_settings.pal_id].colors; + memcpy(palette, g_settings.palettes[g_settings.pal_id].data, g_settings.palettes[g_settings.pal_id].colors * sizeof(COLOR3)); + } + else + { + colorCount = 256; + memcpy(palette, g_settings.palette_default, 256 * sizeof(COLOR3)); + } } else { @@ -5426,7 +5434,8 @@ int Bsp::add_texture(const char* oldname, unsigned char* data, int width, int he } else { - colors = 0; + colorCount = 256; + memcpy(palette, g_settings.palette_default, 256 * sizeof(COLOR3)); } Quantizer* tmpCQuantizer = new Quantizer(colors, 8); if (colors != 0) @@ -5646,7 +5655,8 @@ int Bsp::add_texture(WADTEX* tex, bool embedded) } else { - colorCount = 0; + colorCount = 256; + memcpy(palette, g_settings.palette_default, 256 * sizeof(COLOR3)); } Quantizer* tmpCQuantizer = new Quantizer(colorCount, 8); diff --git a/src/editor/Gui.cpp b/src/editor/Gui.cpp index 0852a987..fe36137b 100644 --- a/src/editor/Gui.cpp +++ b/src/editor/Gui.cpp @@ -4833,7 +4833,7 @@ void Gui::drawMenuBar() map->update_lump_pointers(); vec3 org_mins = vec3(-256.0f, -256.0f, -256.0f), org_maxs = vec3(256.0f, 256.0f, 256.0f); - float scale_val = (FLT_MAX_COORD - 2.0f) / 256.0f; + int scale_val = (int)((FLT_MAX_COORD - 2.0f) / 256.0f); //map->get_bounding_box(mins, maxs); int newModelIdx = ImportModel(map, "./primitives/skybox.bsp", true); @@ -4869,7 +4869,7 @@ void Gui::drawMenuBar() lodepng_decode24_file(&sky_data, &w, &h, "./primitives/skytest/sky_up.png"); int out_w, out_h; auto images = splitImage((COLOR3*)sky_data, w, h, 4, 4, out_w, out_h); - const int new_w = 128, new_h = 128; + const int new_w = 256, new_h = 256; for (auto& img : images) { std::vector new_img; @@ -4900,10 +4900,18 @@ void Gui::drawMenuBar() { COLOR3 palette[256]; unsigned int colorCount = 0; - if (g_settings.pal_id >= 0) + if (!map->is_texture_has_pal) { - colorCount = g_settings.palettes[g_settings.pal_id].colors; - memcpy(palette, g_settings.palettes[g_settings.pal_id].data, g_settings.palettes[g_settings.pal_id].colors * sizeof(COLOR3)); + if (g_settings.pal_id >= 0) + { + colorCount = g_settings.palettes[g_settings.pal_id].colors; + memcpy(palette, g_settings.palettes[g_settings.pal_id].data, g_settings.palettes[g_settings.pal_id].colors * sizeof(COLOR3)); + } + else + { + colorCount = 256; + memcpy(palette, g_settings.palette_default, 256 * sizeof(COLOR3)); + } } else { @@ -4951,7 +4959,24 @@ void Gui::drawMenuBar() { mat4x4 scaleMat; scaleMat.loadIdentity(); - scaleMat.scale(0.5f / scale_val, 0.5f / scale_val, 0.5f / scale_val); + scaleMat.scale(1.0f/2.0f, 1.0f / 2.0f, 1.0f / 2.0f); + BSPTEXTUREINFO& info = map->texinfos[i]; + + info.vS = (scaleMat * vec4(info.vS, 1)).xyz(); + info.vT = (scaleMat * vec4(info.vT, 1)).xyz(); + + info.shiftS *= 2.0f; + info.shiftT *= 2.0f; + } + } + + for (int i = 0; i < map->texinfoCount; i++) + { + if (modelUsage.texInfo[i]) + { + mat4x4 scaleMat; + scaleMat.loadIdentity(); + scaleMat.scale(1.0f / scale_val, 1.0f / scale_val, 1.0f / scale_val); BSPTEXTUREINFO& info = map->texinfos[i]; info.vS = (scaleMat * vec4(info.vS, 1)).xyz(); diff --git a/src/main.cpp b/src/main.cpp index b2e40c6e..ff111061 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -98,7 +98,7 @@ // Removing HULL 0 from solid model crashes game when standing on it -std::string g_version_string = "NewBSPGuy v4.14"; +std::string g_version_string = "NewBSPGuy v4.15"; bool g_verbose = false;