mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-26 00:43:00 +08:00
Merge pull request #14 from neos7/master
Saving of grass batches for ymaps (fixed)
This commit is contained in:
commit
0c558e746c
@ -29,7 +29,6 @@ namespace CodeWalker.GameFiles
|
||||
|
||||
public Unk_975711773[] CBoxOccluders { get; set; }
|
||||
public Unk_2741784237[] COccludeModels { get; set; }
|
||||
public rage__fwGrassInstanceListDef[] GrassInstanceList { get; set; }
|
||||
|
||||
|
||||
public string[] Strings { get; set; }
|
||||
@ -576,7 +575,6 @@ namespace CodeWalker.GameFiles
|
||||
{
|
||||
if (GrassInstanceBatches == null)
|
||||
{
|
||||
GrassInstanceList = null;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -584,12 +582,19 @@ namespace CodeWalker.GameFiles
|
||||
{ }
|
||||
|
||||
int count = GrassInstanceBatches.Length;
|
||||
GrassInstanceList = new rage__fwGrassInstanceListDef[count];
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
GrassInstanceList[i] = GrassInstanceBatches[i].Batch;
|
||||
}
|
||||
var g = GrassInstanceBatches[i];
|
||||
var b = g.Batch;
|
||||
|
||||
var aabb = new rage__spdAABB();
|
||||
aabb.min = new Vector4(g.AABBMin, 0);
|
||||
aabb.max = new Vector4(g.AABBMax, 0);
|
||||
|
||||
b.BatchAABB = aabb;
|
||||
|
||||
GrassInstanceBatches[i].Batch = b;
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] Save()
|
||||
@ -600,10 +605,9 @@ namespace CodeWalker.GameFiles
|
||||
//since Ymap object contents have been modified, need to recreate the arrays which are what is saved.
|
||||
BuildCEntityDefs(); //technically this isn't required anymore since the CEntityDefs is no longer used for saving.
|
||||
BuildCCarGens();
|
||||
|
||||
BuildInstances();
|
||||
|
||||
//TODO:
|
||||
//BuildInstances();
|
||||
//BuildLodLights();
|
||||
//BuildDistantLodLights();
|
||||
//BuildTimecycleModifiers(); //already being saved - update them..
|
||||
@ -660,14 +664,37 @@ namespace CodeWalker.GameFiles
|
||||
if (mapdata.containerLods.Count1 != 0) LogSaveWarning("containerLods were not saved. (TODO!)");
|
||||
if (mapdata.occludeModels.Count1 != 0) LogSaveWarning("occludeModels were not saved. (TODO!)");
|
||||
if (mapdata.boxOccluders.Count1 != 0) LogSaveWarning("boxOccluders were not saved. (TODO!)");
|
||||
if (mapdata.instancedData.GrassInstanceList.Count1 != 0) LogSaveWarning("instancedData.GrassInstanceList was not saved. (TODO!)");
|
||||
if (mapdata.instancedData.PropInstanceList.Count1 != 0) LogSaveWarning("instancedData.PropInstanceList was not saved. (TODO!)");
|
||||
if (mapdata.LODLightsSOA.direction.Count1 != 0) LogSaveWarning("LODLightsSOA was not saved. (TODO!)");
|
||||
if (mapdata.DistantLODLightsSOA.position.Count1 != 0) LogSaveWarning("DistantLODLightsSOA was not saved. (TODO!)");
|
||||
mapdata.containerLods = new Array_Structure();
|
||||
mapdata.occludeModels = new Array_Structure();
|
||||
mapdata.boxOccluders = new Array_Structure();
|
||||
mapdata.instancedData = new rage__fwInstancedMapData();
|
||||
|
||||
if ((GrassInstanceBatches != null) && (GrassInstanceBatches.Length > 0))
|
||||
{
|
||||
var instancedData = new rage__fwInstancedMapData();
|
||||
rage__fwGrassInstanceListDef[] batches = new rage__fwGrassInstanceListDef[GrassInstanceBatches.Length];
|
||||
for (int i = 0; i < GrassInstanceBatches.Length; i++)
|
||||
{
|
||||
var batch = GrassInstanceBatches[i];
|
||||
|
||||
if (batch != null)
|
||||
{
|
||||
var b = batch.Batch;
|
||||
b.InstanceList = mb.AddItemArrayPtr(MetaName.rage__fwGrassInstanceListDef__InstanceData, batch.Instances);
|
||||
batches[i] = b;
|
||||
}
|
||||
}
|
||||
|
||||
instancedData.GrassInstanceList = mb.AddItemArrayPtr(MetaName.rage__fwGrassInstanceListDef, batches);
|
||||
mapdata.instancedData = instancedData;
|
||||
}
|
||||
else
|
||||
{
|
||||
mapdata.instancedData = new rage__fwInstancedMapData();
|
||||
}
|
||||
|
||||
mapdata.LODLightsSOA = new CLODLight();
|
||||
mapdata.DistantLODLightsSOA = new CDistantLODLight();
|
||||
|
||||
@ -691,6 +718,12 @@ namespace CodeWalker.GameFiles
|
||||
|
||||
|
||||
//make sure all the relevant structure and enum infos are present.
|
||||
if ((GrassInstanceBatches != null) && (GrassInstanceBatches.Length > 0))
|
||||
{
|
||||
mb.AddStructureInfo(MetaName.rage__spdAABB);
|
||||
mb.AddStructureInfo(MetaName.rage__fwGrassInstanceListDef__InstanceData);
|
||||
mb.AddStructureInfo(MetaName.rage__fwGrassInstanceListDef);
|
||||
}
|
||||
mb.AddStructureInfo(MetaName.rage__fwInstancedMapData);
|
||||
mb.AddStructureInfo(MetaName.CLODLight);
|
||||
mb.AddStructureInfo(MetaName.CDistantLODLight);
|
||||
@ -1017,6 +1050,10 @@ namespace CodeWalker.GameFiles
|
||||
{
|
||||
contentFlags = SetBit(contentFlags, 6); //64
|
||||
}
|
||||
if ((GrassInstanceBatches != null) && (GrassInstanceBatches.Length > 0))
|
||||
{
|
||||
contentFlags = SetBit(contentFlags, 10); //64
|
||||
}
|
||||
|
||||
|
||||
bool change = false;
|
||||
|
Loading…
Reference in New Issue
Block a user