Skip to content

Commit de4fdf4

Browse files
committed
don't refresh vesseldata multiple times per frame
1 parent 47f70ef commit de4fdf4

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
## Unreleased
44

5-
- Improve performance when new vessels are created (e.g. during RUD) - thanks @bimo1d
5+
- Improve performance by avoiding reparsing the ShipEffects config when new vessels are created (e.g. during RUD) - thanks @bimo1d
66
- Avoid creating ShipEffects VesselModule for debris, spaceobjects, and dropped items - thanks @bimo1d
7+
- Improve performance when vessel part count changes several times in a frame (e.g. during RUD)
8+
- Avoid creating ShipEffects VesselModule for non-loaded vessels
79

810
## 0.9.13 - 2026-04-20
911

Source/RocketSoundEnhancement/ShipEffects.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ public bool Initialize()
101101

102102
List<Part> asteroidParts = new List<Part>();
103103
List<ModuleEngines> engines = new List<ModuleEngines>();
104+
bool vesselDataDirty = false;
104105

105106
void CacheVesselData()
106107
{
@@ -121,13 +122,14 @@ void CacheVesselData()
121122
}
122123
}
123124
}
125+
vesselDataDirty = false;
124126
}
125127

126128
private void OnVesselPartCountChanged(Vessel data)
127129
{
128130
if (data != vessel) return;
129131

130-
CacheVesselData();
132+
vesselDataDirty = true;
131133
}
132134

133135
IEnumerator SetupAudioSources(List<SoundLayer> soundLayers, bool hasAirSimFilter = true)
@@ -271,6 +273,11 @@ private void LateUpdate()
271273
if (!HighLogic.LoadedSceneIsFlight || !initialized || gamePaused || noPhysics || ignoreVessel)
272274
return;
273275

276+
if (vesselDataDirty)
277+
{
278+
CacheVesselData();
279+
}
280+
274281
foreach (var soundLayerGroup in ShipEffectsConfig.SoundLayerGroups)
275282
{
276283
if (soundLayerGroup.Key == PhysicsControl.SONICBOOM)

0 commit comments

Comments
 (0)