Fix for vehicle wheels rendering corrupting the saved file

This commit is contained in:
dexy 2019-03-28 20:33:07 +11:00
parent bd283a5c07
commit 60b1570930
2 changed files with 15 additions and 12 deletions

View File

@ -78,18 +78,21 @@ namespace CodeWalker.Rendering
DataSize = 0; DataSize = 0;
var hd = Key.DrawableModelsHigh.data_items; var hd = Key.DrawableModelsHigh?.data_items ?? Key.AllModels;
var med = Key.DrawableModelsMedium?.data_items; var med = Key.DrawableModelsMedium?.data_items;
var low = Key.DrawableModelsLow?.data_items; var low = Key.DrawableModelsLow?.data_items;
var vlow = Key.DrawableModelsVeryLow?.data_items; var vlow = Key.DrawableModelsVeryLow?.data_items;
int totmodels = hd.Length + ((med != null) ? med.Length : 0) + ((low != null) ? low.Length : 0) + ((vlow != null) ? vlow.Length : 0); int totmodels = (hd?.Length ?? 0) + (med?.Length ?? 0) + (low?.Length ?? 0) + (vlow?.Length ?? 0);
int curmodel = hd.Length; int curmodel = hd?.Length ?? 0;
AllModels = new RenderableModel[totmodels]; AllModels = new RenderableModel[totmodels];
HDModels = new RenderableModel[hd.Length]; HDModels = new RenderableModel[hd.Length];
for (int i = 0; i < hd.Length; i++) if (hd != null)
{ {
HDModels[i] = InitModel(hd[i]); for (int i = 0; i < hd.Length; i++)
AllModels[i] = HDModels[i]; {
HDModels[i] = InitModel(hd[i]);
AllModels[i] = HDModels[i];
}
} }
if (med != null) if (med != null)
{ {

View File

@ -2338,12 +2338,12 @@ namespace CodeWalker.Rendering
if ((dwbl != dwblcopy) && (dwbl.AllModels.Length == 0)) if ((dwbl != dwblcopy) && (dwbl.AllModels.Length == 0))
{ {
dwbl.Owner = dwblcopy; dwbl.Owner = dwblcopy;
dwbl.AllModels = dwblcopy.AllModels; dwbl.AllModels = dwblcopy.AllModels; //hopefully this is all that's need to render, otherwise drawable is actually getting edited!
dwbl.DrawableModelsHigh = dwblcopy.DrawableModelsHigh; //dwbl.DrawableModelsHigh = dwblcopy.DrawableModelsHigh;
dwbl.DrawableModelsMedium = dwblcopy.DrawableModelsMedium; //dwbl.DrawableModelsMedium = dwblcopy.DrawableModelsMedium;
dwbl.DrawableModelsLow = dwblcopy.DrawableModelsLow; //dwbl.DrawableModelsLow = dwblcopy.DrawableModelsLow;
dwbl.DrawableModelsVeryLow = dwblcopy.DrawableModelsVeryLow; //dwbl.DrawableModelsVeryLow = dwblcopy.DrawableModelsVeryLow;
dwbl.VertexDecls = dwblcopy.VertexDecls; //dwbl.VertexDecls = dwblcopy.VertexDecls;
} }
RenderDrawable(dwbl, arch, ent, txdhash); RenderDrawable(dwbl, arch, ent, txdhash);