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,19 +78,22 @@ namespace CodeWalker.Rendering
DataSize = 0;
var hd = Key.DrawableModelsHigh.data_items;
var hd = Key.DrawableModelsHigh?.data_items ?? Key.AllModels;
var med = Key.DrawableModelsMedium?.data_items;
var low = Key.DrawableModelsLow?.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 curmodel = hd.Length;
int totmodels = (hd?.Length ?? 0) + (med?.Length ?? 0) + (low?.Length ?? 0) + (vlow?.Length ?? 0);
int curmodel = hd?.Length ?? 0;
AllModels = new RenderableModel[totmodels];
HDModels = new RenderableModel[hd.Length];
if (hd != null)
{
for (int i = 0; i < hd.Length; i++)
{
HDModels[i] = InitModel(hd[i]);
AllModels[i] = HDModels[i];
}
}
if (med != null)
{
MedModels = new RenderableModel[med.Length];

View File

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