From 7f3461209a4380906094b1fe68cba80313d8c3b9 Mon Sep 17 00:00:00 2001 From: MaxED Date: Mon, 15 Jul 2013 08:32:32 +0000 Subject: [PATCH] MD3: Vertex indices were incorrectly assigned when a model had several surfaces with same skin. --- Source/Core/GZBuilder/md3/ModelReader.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Source/Core/GZBuilder/md3/ModelReader.cs b/Source/Core/GZBuilder/md3/ModelReader.cs index a5ca0190..13c1b08d 100644 --- a/Source/Core/GZBuilder/md3/ModelReader.cs +++ b/Source/Core/GZBuilder/md3/ModelReader.cs @@ -202,12 +202,15 @@ namespace CodeImp.DoomBuilder.GZBuilder.MD3 //create a mesh for each surface texture foreach(KeyValuePair>> group in polyIndecesListsPerTexture) { polyIndecesList = new List(); + int offset = 0; //collect indices, fix vertex offsets for(int i = 0; i < group.Value.Count; i++) { if(i > 0) { - for(int c = 0; c < group.Value[i].Count; c++ ) - group.Value[i][c] += vertexOffsets[group.Key][i-1]; + offset += vertexOffsets[group.Key][i - 1]; //Damn I need to rewrite all of this stuff from scratch... + + for(int c = 0; c < group.Value[i].Count; c++) + group.Value[i][c] += offset; } polyIndecesList.AddRange(group.Value[i].ToArray()); }