From da947328f0a4a255af53e0d4e6d982e66a734df8 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Fri, 21 Jan 2022 19:38:58 +0100 Subject: [PATCH] Fixed some wrong texture projections with convertMapToValve220 --- neo/renderer/Material.cpp | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/neo/renderer/Material.cpp b/neo/renderer/Material.cpp index 862344ba..b4be7e6a 100644 --- a/neo/renderer/Material.cpp +++ b/neo/renderer/Material.cpp @@ -247,8 +247,32 @@ idImage* idMaterial::GetEditorImage() const else { // look for an explicit one - // RB: changed to TD_DIFFUSE because BFG didn't ship the editor images + // RB: changed to TD_DIFFUSE because BFG didn't ship the editor images and + // the qer_editorImage might be the same as the diffusemap editorImage = globalImages->ImageFromFile( editorImageName, TF_DEFAULT, TR_REPEAT, TD_DIFFUSE ); + + // look for the diffusemap alternative like TrenchBroom does + // this is required to have the texture dimensions for the convertMapToValve220 cmd + if( editorImage && editorImage->IsLoaded() && editorImage->IsDefaulted() ) + { + // _D3XP :: First check for a diffuse image, then use the first + if( numStages && stages ) + { + int i; + for( i = 0; i < numStages; i++ ) + { + if( stages[i].lighting == SL_DIFFUSE ) + { + editorImage = stages[i].texture.image; + break; + } + } + if( !editorImage ) + { + editorImage = stages[0].texture.image; + } + } + } } if( !editorImage )