11using CodeWalker . GameFiles ;
2+ using CodeWalker . Project ;
23using CodeWalker . Properties ;
34using CodeWalker . World ;
45using SharpDX ;
@@ -4023,6 +4024,8 @@ public class RenderLodManager
40234024 public bool ShowScriptedYmaps = true ;
40244025 public bool HDLightsEnabled = true ;
40254026 public bool LODLightsEnabled = true ;
4027+ public bool RenderItems => ProjectForm . renderitems ;
4028+ public bool HideGtavMap => ProjectForm . hidegtavmap ;
40264029
40274030 public Camera Camera = null ;
40284031 public Vector3 Position = Vector3 . Zero ;
@@ -4062,10 +4065,10 @@ public void Update(Dictionary<MetaHash, YmapFile> ymaps, Camera camera, float el
40624065 {
40634066 YmapFile ymap = null ;
40644067 if ( ! ymaps . TryGetValue ( kvp . Key , out ymap ) || ( ymap != kvp . Value ) || ( ymap . IsScripted && ! ShowScriptedYmaps ) || ( ymap . LodManagerUpdate ) )
4065- {
4066- RemoveYmaps . Add ( kvp . Key ) ;
4068+ {
4069+ RemoveYmaps . Add ( kvp . Key ) ;
4070+ }
40674071 }
4068- }
40694072 foreach ( var remYmap in RemoveYmaps )
40704073 {
40714074 var ymap = CurrentYmaps [ remYmap ] ;
@@ -4076,16 +4079,16 @@ public void Update(Dictionary<MetaHash, YmapFile> ymaps, Camera camera, float el
40764079 for ( int i = 0 ; i < remEnts . Length ; i ++ )
40774080 {
40784081 var ent = remEnts [ i ] ;
4079- RootEntities . Remove ( ent ) ;
4080- ent . LodManagerChildren ? . Clear ( ) ;
4081- ent . LodManagerChildren = null ;
4082- ent . LodManagerRenderable = null ;
4083- if ( ( ent . Parent != null ) && ( ent . Parent . Ymap != ymap ) )
4084- {
4085- ent . Parent . LodManagerRemoveChild ( ent ) ;
4082+ RootEntities . Remove ( ent ) ;
4083+ ent . LodManagerChildren ? . Clear ( ) ;
4084+ ent . LodManagerChildren = null ;
4085+ ent . LodManagerRenderable = null ;
4086+ if ( ( ent . Parent != null ) && ( ent . Parent . Ymap != ymap ) )
4087+ {
4088+ ent . Parent . LodManagerRemoveChild ( ent ) ;
4089+ }
40864090 }
40874091 }
4088- }
40894092 var remLodLights = ymap . LODLights ? . LodLights ;
40904093 if ( remLodLights != null )
40914094 {
@@ -4137,18 +4140,33 @@ public void Update(Dictionary<MetaHash, YmapFile> ymaps, Camera camera, float el
41374140
41384141 VisibleLeaves . Clear ( ) ;
41394142 VisibleLights . Clear ( ) ;
4140- foreach ( var kvp in RootEntities )
4143+
4144+ if ( HideGtavMap )
41414145 {
4142- var ent = kvp . Key ;
4143- if ( EntityVisibleAtMaxLodLevel ( ent ) )
4146+ foreach ( var kvp in CurrentYmaps )
41444147 {
4145- ent . Distance = MapViewEnabled ? MapViewDist : ( ent . Position - Position ) . Length ( ) ;
4146- if ( ent . Distance <= ( ent . LodDist * LodDistMult ) )
4148+ var ymap = kvp . Value ;
4149+ if ( ymap . HasChanged && ymap . AllEntities != null )
41474150 {
4148- RecurseAddVisibleLeaves ( ent ) ;
4151+ if ( ! RenderItems ) continue ;
4152+ foreach ( var ent in ymap . AllEntities )
4153+ {
4154+ ProcessEntitiesForVisibility ( ent ) ;
4155+ }
41494156 }
41504157 }
41514158 }
4159+ else
4160+ {
4161+ foreach ( var kvp in RootEntities )
4162+ {
4163+ var ent = kvp . Key ;
4164+ if ( ent . Ymap . HasChanged && ! RenderItems )
4165+ continue ;
4166+
4167+ ProcessEntitiesForVisibility ( ent ) ;
4168+ }
4169+ }
41524170
41534171 UpdateLodLights . Clear ( ) ;
41544172 foreach ( var light in VisibleLights )
@@ -4179,7 +4197,17 @@ public void Update(Dictionary<MetaHash, YmapFile> ymaps, Camera camera, float el
41794197 VisibleLights = VisibleLightsPrev ;
41804198 VisibleLightsPrev = vl ;
41814199 }
4182-
4200+ private void ProcessEntitiesForVisibility ( YmapEntityDef ent )
4201+ {
4202+ if ( EntityVisibleAtMaxLodLevel ( ent ) )
4203+ {
4204+ ent . Distance = MapViewEnabled ? MapViewDist : ( ent . Position - Position ) . Length ( ) ;
4205+ if ( ent . Distance <= ( ent . LodDist * LodDistMult ) )
4206+ {
4207+ RecurseAddVisibleLeaves ( ent ) ;
4208+ }
4209+ }
4210+ }
41834211 private void RecurseAddVisibleLeaves ( YmapEntityDef ent )
41844212 {
41854213 var clist = GetEntityChildren ( ent ) ;
@@ -4196,6 +4224,9 @@ private void RecurseAddVisibleLeaves(YmapEntityDef ent)
41964224 {
41974225 if ( EntityVisible ( ent ) )
41984226 {
4227+ if ( ! RenderItems && ent . Ymap . HasChanged )
4228+ return ;
4229+
41994230 VisibleLeaves . Add ( ent ) ;
42004231
42014232 if ( HDLightsEnabled && ( ent . Lights != null ) )
0 commit comments