mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
cull/collision/lights groups (#359)
groups make things turn off when you're not in the sector. (cull = renderers, collision = colliders/shapes, lights = lights) this pr makes nh add groups to anything using DetailBuilder.Make this should improve performance, since things will only appear when you're close enough to them. it should also help with Jack's mod since he uses lots of cacti (ie volumes) this pr also makes keepLoaded actually function (and adds the setting to scatter)
This commit is contained in:
commit
0a54bb2447
29
NewHorizons/Builder/General/GroupsBuilder.cs
Normal file
29
NewHorizons/Builder/General/GroupsBuilder.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using UnityEngine;
|
||||
using Logger = NewHorizons.Utility.Logger;
|
||||
|
||||
namespace NewHorizons.Builder.General;
|
||||
|
||||
public static class GroupsBuilder
|
||||
{
|
||||
/// <summary>
|
||||
/// puts groups on an object, activated by sector.
|
||||
/// run this before the gameobject is active.
|
||||
/// </summary>
|
||||
public static void Make(GameObject go, Sector sector)
|
||||
{
|
||||
if (!sector)
|
||||
{
|
||||
Logger.LogWarning($"tried to put groups on {go.name} when sector is null");
|
||||
return;
|
||||
}
|
||||
if (go.activeInHierarchy)
|
||||
{
|
||||
Logger.LogWarning($"tried to put groups on an active gameobject {go.name}");
|
||||
return;
|
||||
}
|
||||
|
||||
go.GetAddComponent<SectorCullGroup>()._sector = sector;
|
||||
go.GetAddComponent<SectorCollisionGroup>()._sector = sector;
|
||||
go.GetAddComponent<SectorLightsCullGroup>()._sector = sector;
|
||||
}
|
||||
}
|
||||
@ -1,3 +1,4 @@
|
||||
using NewHorizons.Builder.General;
|
||||
using NewHorizons.External.Configs;
|
||||
using NewHorizons.External.Modules;
|
||||
using NewHorizons.Handlers;
|
||||
@ -100,6 +101,7 @@ namespace NewHorizons.Builder.Props
|
||||
|
||||
prop.transform.localScale = detail.scale != 0 ? Vector3.one * detail.scale : prefab.transform.localScale;
|
||||
|
||||
if (!detail.keepLoaded) GroupsBuilder.Make(prop, sector);
|
||||
prop.SetActive(true);
|
||||
|
||||
if (prop == null) return null;
|
||||
|
||||
@ -96,6 +96,7 @@ namespace NewHorizons.Builder.Props
|
||||
{
|
||||
position = point.normalized * height,
|
||||
scale = propInfo.scale,
|
||||
keepLoaded = propInfo.keepLoaded,
|
||||
alignToNormal = true
|
||||
};
|
||||
var prop = DetailBuilder.Make(go, sector, prefab, detailInfo);
|
||||
|
||||
5
NewHorizons/External/Modules/PropModule.cs
vendored
5
NewHorizons/External/Modules/PropModule.cs
vendored
@ -139,6 +139,11 @@ namespace NewHorizons.External.Modules
|
||||
/// The highest height that these objects will be placed at (only relevant if there's a heightmap)
|
||||
/// </summary>
|
||||
public float? maxHeight;
|
||||
|
||||
/// <summary>
|
||||
/// Should this detail stay loaded even if you're outside the sector (good for very large props)
|
||||
/// </summary>
|
||||
public bool keepLoaded;
|
||||
}
|
||||
|
||||
[JsonObject]
|
||||
|
||||
@ -1391,6 +1391,10 @@
|
||||
],
|
||||
"description": "The highest height that these objects will be placed at (only relevant if there's a heightmap)",
|
||||
"format": "float"
|
||||
},
|
||||
"keepLoaded": {
|
||||
"type": "boolean",
|
||||
"description": "Should this detail stay loaded even if you're outside the sector (good for very large props)"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user