mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2025-01-10 23:07:51 +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:
|
//fields used by the editor:
|
||||||
public bool HasChanged { get; set; } = false;
|
public bool HasChanged { get; set; } = false;
|
||||||
public List<string> SaveWarnings = null;
|
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)
|
public YmapFile() : base(null, GameFileType.Ymap)
|
||||||
@ -900,6 +900,7 @@ namespace CodeWalker.GameFiles
|
|||||||
}
|
}
|
||||||
|
|
||||||
HasChanged = true;
|
HasChanged = true;
|
||||||
|
LodManagerUpdate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool RemoveEntity(YmapEntityDef ent)
|
public bool RemoveEntity(YmapEntityDef ent)
|
||||||
@ -934,10 +935,12 @@ namespace CodeWalker.GameFiles
|
|||||||
res = false;
|
res = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LodManagerOldEntities = AllEntities;
|
||||||
AllEntities = newAllEntities.ToArray();
|
AllEntities = newAllEntities.ToArray();
|
||||||
RootEntities = newRootEntities.ToArray();
|
RootEntities = newRootEntities.ToArray();
|
||||||
|
|
||||||
HasChanged = true;
|
HasChanged = true;
|
||||||
|
LodManagerUpdate = true;
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -3589,7 +3589,7 @@ namespace CodeWalker.Rendering
|
|||||||
foreach (var kvp in CurrentYmaps)
|
foreach (var kvp in CurrentYmaps)
|
||||||
{
|
{
|
||||||
YmapFile ymap = null;
|
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);
|
RemoveYmaps.Add(kvp.Key);
|
||||||
}
|
}
|
||||||
@ -3598,11 +3598,12 @@ namespace CodeWalker.Rendering
|
|||||||
{
|
{
|
||||||
var ymap = CurrentYmaps[remYmap];
|
var ymap = CurrentYmaps[remYmap];
|
||||||
CurrentYmaps.Remove(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);
|
RootEntities.Remove(ent);
|
||||||
ent.LodManagerChildren?.Clear();
|
ent.LodManagerChildren?.Clear();
|
||||||
ent.LodManagerChildren = null;
|
ent.LodManagerChildren = null;
|
||||||
@ -3613,6 +3614,8 @@ namespace CodeWalker.Rendering
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ymap.LodManagerUpdate = false;
|
||||||
|
ymap.LodManagerOldEntities = null;
|
||||||
}
|
}
|
||||||
foreach (var kvp in ymaps)
|
foreach (var kvp in ymaps)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user