From 9b5a8aa89264f2b47552741a3b0abb66c6408a86 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Thu, 23 Dec 2021 15:41:24 +0100 Subject: [PATCH] pico: detect intentional material name and do not replace them with texture MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Detect intentional material name to not replace it with texture name. Reimplement commits by Garux: https://github.com/Garux/netradiant-custom/commit/1bd3e7ae186b55fb61e3738d2493432c0b1f5a7b https://github.com/Garux/netradiant-custom/commit/ea21eee2254fb2e667732d8f1b0f83c439a89bfa This attempts to restore proper material behaviour when the mapper knows what he is doing, also called Julius' case or correct case because Julius is always correct™ while keeping the fallback for other situations, also called newbie's case which may be compatible with third-party tools not following Quake 3 conventions. See: https://gitlab.com/xonotic/netradiant/-/merge_requests/179#note_777324051 <3 @julius__ @Garux --- libs/picomodel/picointernal.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/libs/picomodel/picointernal.c b/libs/picomodel/picointernal.c index 614d7c53..0a8597f8 100644 --- a/libs/picomodel/picointernal.c +++ b/libs/picomodel/picointernal.c @@ -741,7 +741,28 @@ void _pico_deduce_shadernames( picoModel_t *model ){ const char* mapname = model->shader[i]->mapName; const char* shadername = model->shader[i]->name; - if( mapname && *mapname ) + + /* Detect intentional material name to not replace it with texture name. + + Reimplement commits by Garux: + https://github.com/Garux/netradiant-custom/commit/1bd3e7ae186b55fb61e3738d2493432c0b1f5a7b + https://github.com/Garux/netradiant-custom/commit/ea21eee2254fb2e667732d8f1b0f83c439a89bfa + + This attempts to restore proper material behaviour when the mapper knows what he is doing, + also called Julius' case or correct case because Julius is always correct™ + while keeping the fallback for other situations, also called newbie's case + which may be compatible with third-party tools not following Quake 3 conventions. + + See: https://gitlab.com/xonotic/netradiant/-/merge_requests/179#note_777324051 */ + if ( shadername && *shadername && + ( _pico_strnicmp( shadername, "models/", 7 ) == 0 + || _pico_strnicmp( shadername, "models\\", 7 ) == 0 + || _pico_strnicmp( shadername, "textures/", 9 ) == 0 + || _pico_strnicmp( shadername, "textures\\", 9 ) == 0 ) ) + { + _pico_deduce_shadername( model->fileName, shadername, model->shader[i] ); + } + else if( mapname && *mapname ) _pico_deduce_shadername( model->fileName, mapname, model->shader[i] ); else if( shadername && *shadername ) _pico_deduce_shadername( model->fileName, shadername, model->shader[i] ); -- 2.39.2