From c74ed79e8d516e9a668daa885dea6e8567d5e695 Mon Sep 17 00:00:00 2001 From: Robert Beckebans Date: Wed, 8 Jun 2022 21:34:04 +0200 Subject: [PATCH] Support the Valve 220 texture projection in MapPolygonMesh::ConvertFromBrush() --- neo/idlib/MapFile.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/neo/idlib/MapFile.cpp b/neo/idlib/MapFile.cpp index 37154ece..5a119944 100644 --- a/neo/idlib/MapFile.cpp +++ b/neo/idlib/MapFile.cpp @@ -2220,6 +2220,24 @@ void MapPolygonMesh::ConvertFromBrush( const idMapBrush* mapBrush, int entityNum st.x = ( xyz * texVec[0].ToVec3() ) + texVec[0][3]; st.y = ( xyz * texVec[1].ToVec3() ) + texVec[1][3]; + // support Valve 220 projection + if( mapSide->GetProjectionType() == idMapBrushSide::PROJECTION_VALVE220 ) + { + const idMaterial* material = declManager->FindMaterial( mapSide->GetMaterial() ); + + idVec2i texSize = mapSide->GetTextureSize(); + + idImage* image = material->GetEditorImage(); + if( image != NULL ) + { + texSize.x = image->GetUploadWidth(); + texSize.y = image->GetUploadHeight(); + } + + st.x /= texSize[0]; + st.y /= texSize[1]; + } + // flip y //st.y = 1.0f - st.y;