mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2025-01-10 20:05:11 +08:00
Fix for add/remove entities not applying to world view
This commit is contained in:
parent
1b59ef40d0
commit
3f445182f3
@ -62,8 +62,8 @@ namespace CodeWalker.GameFiles
|
||||
//fields used by the editor:
|
||||
public bool HasChanged { get; set; } = false;
|
||||
public List<string> SaveWarnings = null;
|
||||
|
||||
|
||||
public bool LodManagerUpdate = false; //forces the LOD manager to refresh this ymap when rendering
|
||||
public YmapEntityDef[] LodManagerOldEntities = null; //when entities are removed, need the old ones to remove from lod manager
|
||||
|
||||
|
||||
public YmapFile() : base(null, GameFileType.Ymap)
|
||||
@ -900,6 +900,7 @@ namespace CodeWalker.GameFiles
|
||||
}
|
||||
|
||||
HasChanged = true;
|
||||
LodManagerUpdate = true;
|
||||
}
|
||||
|
||||
public bool RemoveEntity(YmapEntityDef ent)
|
||||
@ -934,10 +935,12 @@ namespace CodeWalker.GameFiles
|
||||
res = false;
|
||||
}
|
||||
|
||||
LodManagerOldEntities = AllEntities;
|
||||
AllEntities = newAllEntities.ToArray();
|
||||
RootEntities = newRootEntities.ToArray();
|
||||
|
||||
HasChanged = true;
|
||||
LodManagerUpdate = true;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
@ -3589,7 +3589,7 @@ namespace CodeWalker.Rendering
|
||||
foreach (var kvp in CurrentYmaps)
|
||||
{
|
||||
YmapFile ymap = null;
|
||||
if (!ymaps.TryGetValue(kvp.Key, out ymap) || (ymap != kvp.Value) || (ymap.IsScripted && !ShowScriptedYmaps))
|
||||
if (!ymaps.TryGetValue(kvp.Key, out ymap) || (ymap != kvp.Value) || (ymap.IsScripted && !ShowScriptedYmaps) || (ymap.LodManagerUpdate))
|
||||
{
|
||||
RemoveYmaps.Add(kvp.Key);
|
||||
}
|
||||
@ -3598,11 +3598,12 @@ namespace CodeWalker.Rendering
|
||||
{
|
||||
var ymap = CurrentYmaps[remYmap];
|
||||
CurrentYmaps.Remove(remYmap);
|
||||
if (ymap.AllEntities != null) // remove this ymap's entities from the tree.....
|
||||
var remEnts = ymap.LodManagerOldEntities ?? ymap.AllEntities;
|
||||
if (remEnts != null) // remove this ymap's entities from the tree.....
|
||||
{
|
||||
for (int i = 0; i < ymap.AllEntities.Length; i++)
|
||||
for (int i = 0; i < remEnts.Length; i++)
|
||||
{
|
||||
var ent = ymap.AllEntities[i];
|
||||
var ent = remEnts[i];
|
||||
RootEntities.Remove(ent);
|
||||
ent.LodManagerChildren?.Clear();
|
||||
ent.LodManagerChildren = null;
|
||||
@ -3613,6 +3614,8 @@ namespace CodeWalker.Rendering
|
||||
}
|
||||
}
|
||||
}
|
||||
ymap.LodManagerUpdate = false;
|
||||
ymap.LodManagerOldEntities = null;
|
||||
}
|
||||
foreach (var kvp in ymaps)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user