Skip to content

Commit

Permalink
Only register movables' appearances when in PVS range
Browse files Browse the repository at this point in the history
  • Loading branch information
wixoaGit committed Dec 29, 2024
1 parent 52c6f55 commit ab39b71
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 14 deletions.
4 changes: 2 additions & 2 deletions OpenDreamRuntime/AtomManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ public ImmutableAppearance MustGetAppearance(DreamObject atom) {
DreamObjectTurf turf => turf.Appearance,
DreamObjectMovable movable => movable.SpriteComponent.Appearance!,
DreamObjectArea area => area.Appearance,
DreamObjectImage image => image.IsMutableAppearance ? AppearanceSystem!.AddAppearance(image.MutableAppearance!, registerApearance: false) : image.SpriteComponent!.Appearance!,
DreamObjectImage image => image.IsMutableAppearance ? AppearanceSystem!.AddAppearance(image.MutableAppearance!, registerAppearance: false) : image.SpriteComponent!.Appearance!,
_ => throw new Exception($"Cannot get appearance of {atom}")
};
}
Expand All @@ -517,7 +517,7 @@ public bool TryGetAppearance(DreamObject atom, [NotNullWhen(true)] out Immutable
else if (atom is DreamObjectMovable movable && movable.SpriteComponent.Appearance is not null)
appearance = movable.SpriteComponent.Appearance;
else if (atom is DreamObjectImage image)
appearance = image.IsMutableAppearance ? AppearanceSystem!.AddAppearance(image.MutableAppearance!, registerApearance: false) : image.SpriteComponent?.Appearance;
appearance = image.IsMutableAppearance ? AppearanceSystem!.AddAppearance(image.MutableAppearance!, registerAppearance: false) : image.SpriteComponent?.Appearance;
else if (atom is DreamObjectArea area)
appearance = area.Appearance;
else
Expand Down
2 changes: 1 addition & 1 deletion OpenDreamRuntime/Objects/Types/DreamList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ public override void RemoveValue(DreamValue value) {
return;

_atomManager.UpdateAppearance(_owner, appearance => {
GetOverlaysList(appearance).Remove(_appearanceSystem.AddAppearance(overlayAppearance, registerApearance:false));
GetOverlaysList(appearance).Remove(_appearanceSystem.AddAppearance(overlayAppearance, registerAppearance:false));
});
}

Expand Down
8 changes: 6 additions & 2 deletions OpenDreamRuntime/Rendering/DMISpriteSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,16 @@ public override void Initialize() {
}

private void GetComponentState(EntityUid uid, DMISpriteComponent component, ref ComponentGetState args) {
args.State = new SharedDMISpriteComponent.DMISpriteComponentState(component.Appearance?.MustGetID(), component.ScreenLocation);
uint? appearanceId = (component.Appearance != null)
? _appearance?.AddAppearance(component.Appearance).MustGetID()
: null;

args.State = new SharedDMISpriteComponent.DMISpriteComponentState(appearanceId, component.ScreenLocation);
}

public void SetSpriteAppearance(Entity<DMISpriteComponent> ent, MutableAppearance appearance, bool dirty = true) {
DMISpriteComponent component = ent.Comp;
component.Appearance = _appearance?.AddAppearance(appearance);
component.Appearance = new ImmutableAppearance(appearance, _appearance);
if(dirty)
Dirty(ent, component);
}
Expand Down
20 changes: 12 additions & 8 deletions OpenDreamRuntime/Rendering/ServerAppearanceSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Robust.Shared.Player;
using Robust.Shared.Network;
using System.Diagnostics;
using Robust.Shared.Console;

namespace OpenDreamRuntime.Rendering;

Expand Down Expand Up @@ -61,11 +62,10 @@ private void OnPlayerStatusChanged(object? sender, SessionStatusEventArgs e) {
if(proxyWeakRef.TryGetTarget(out var immutable))
sendData.Add(immutable.MustGetID(), immutable);
}
Logger.GetSawmill("appearance").Debug($"Sending {sendData.Count} appearances to new player {e.Session.Name}");

Logger.GetSawmill("appearance").Debug($"Sending {sendData.Count} appearances to new player {e.Session.Name}");
e.Session.Channel.SendMessage(new MsgAllAppearances(sendData));
}

}
}

Expand All @@ -77,17 +77,21 @@ private void RegisterAppearance(ImmutableAppearance immutableAppearance) {
_networkManager.ServerSendToAll(new MsgNewAppearance(immutableAppearance));
}

public ImmutableAppearance AddAppearance(MutableAppearance appearance, bool registerApearance = true) {
public ImmutableAppearance AddAppearance(MutableAppearance appearance, bool registerAppearance = true) {

Check failure on line 80 in OpenDreamRuntime/Rendering/ServerAppearanceSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'ServerAppearanceSystem.AddAppearance(MutableAppearance, bool)': not all code paths return a value

Check failure on line 80 in OpenDreamRuntime/Rendering/ServerAppearanceSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'ServerAppearanceSystem.AddAppearance(MutableAppearance, bool)': not all code paths return a value

Check failure on line 80 in OpenDreamRuntime/Rendering/ServerAppearanceSystem.cs

View workflow job for this annotation

GitHub Actions / build

'ServerAppearanceSystem.AddAppearance(MutableAppearance, bool)': not all code paths return a value

Check failure on line 80 in OpenDreamRuntime/Rendering/ServerAppearanceSystem.cs

View workflow job for this annotation

GitHub Actions / build

'ServerAppearanceSystem.AddAppearance(MutableAppearance, bool)': not all code paths return a value
ImmutableAppearance immutableAppearance = new(appearance, this);

AddAppearance(immutableAppearance, registerAppearance);
}

public ImmutableAppearance AddAppearance(ImmutableAppearance appearance, bool registerAppearance = true) {
lock (_lock) {
if(_appearanceLookup.TryGetValue(new(immutableAppearance), out var weakReference) && weakReference.TryGetTarget(out var originalImmutable)) {
if(_appearanceLookup.TryGetValue(new(appearance), out var weakReference) && weakReference.TryGetTarget(out var originalImmutable)) {
return originalImmutable;
} else if (registerApearance) {
RegisterAppearance(immutableAppearance);
return immutableAppearance;
} else if (registerAppearance) {
RegisterAppearance(appearance);
return appearance;
} else {
return immutableAppearance;
return appearance;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion RobustToolbox
Submodule RobustToolbox updated 62 files
+22 −22 .github/workflows/build-docfx.yml
+19 −18 .github/workflows/build-test.yml
+42 −36 .github/workflows/codeql-analysis.yml
+43 −42 .github/workflows/publish-client.yml
+28 −27 .github/workflows/test-content.yml
+1 −1 MSBuild/Robust.Engine.Version.props
+0 −17 RELEASE-NOTES.md
+2 −1 Robust.Client/GameObjects/EntitySystems/ContainerSystem.cs
+0 −5 Robust.Client/Graphics/Clyde/Clyde.RenderHandle.cs
+0 −2 Robust.Client/Graphics/Drawing/DrawingHandleBase.cs
+1 −1 Robust.Client/Graphics/Drawing/DrawingHandleScreen.cs
+1 −1 Robust.Client/Graphics/Drawing/DrawingHandleWorld.cs
+5 −8 Robust.Client/Graphics/Font.cs
+5 −10 Robust.Client/ResourceManagement/ResourceCache.Preload.cs
+0 −2 Robust.Client/ResourceManagement/ResourceTypes/RSIResource.cs
+5 −0 Robust.Client/UserInterface/Controls/ColorSelectorSliders.cs
+1 −0 Robust.Client/UserInterface/Controls/GridContainer.cs
+1 −1 Robust.Client/UserInterface/RichTextEntry.cs
+0 −18 Robust.Packaging/AssetProcessing/Passes/AssetPassFilterDrop.cs
+2 −2 Robust.Server/BaseServer.cs
+3 −1 Robust.Server/ServerStatus/StatusHost.Acz.Sources.cs
+0 −16 Robust.Server/ServerStatus/StatusHost.Handlers.cs
+0 −15 Robust.Shared.Maths/MathHelper.cs
+1 −1 Robust.Shared.Maths/Matrix3Helpers.cs
+0 −35 Robust.Shared.Maths/Vector2Helpers.cs
+0 −37 Robust.Shared/CVars.cs
+0 −75 Robust.Shared/Collections/ValueList.cs
+1 −1 Robust.Shared/Containers/SharedContainerSystem.cs
+1 −18 Robust.Shared/ContentPack/AssemblyTypeChecker.ReportBadReferences.cs
+0 −21 Robust.Shared/GameObjects/Components/UserInterface/BoundUserInterface.cs
+0 −6 Robust.Shared/GameObjects/Components/UserInterface/UserInterfaceComponent.cs
+0 −12 Robust.Shared/GameObjects/EntityManager.Components.cs
+3 −3 Robust.Shared/GameObjects/Systems/EntityLookupSystem.ComponentQueries.cs
+1 −1 Robust.Shared/GameObjects/Systems/SharedMapSystem.Grid.cs
+1 −23 Robust.Shared/GameObjects/Systems/SharedUserInterfaceSystem.cs
+11 −4 Robust.Shared/Map/Events/MapSerializationEvents.cs
+2 −0 Robust.Shared/Noise/FastNoise.cs
+0 −212 Robust.Shared/Physics/B2DynamicTree.cs
+0 −1 Robust.Shared/Physics/BroadPhase/DynamicTreeBroadPhase.cs
+0 −243 Robust.Shared/Physics/Collision/DistanceProxy.cs
+0 −8 Robust.Shared/Physics/Collision/Shapes/PolygonShape.cs
+0 −2 Robust.Shared/Physics/IBroadPhase.cs
+2 −2 Robust.Shared/Physics/Shapes/Polygon.cs
+0 −736 Robust.Shared/Physics/Systems/RayCastSystem.Geometry.cs
+0 −465 Robust.Shared/Physics/Systems/RayCastSystem.cs
+24 −41 Robust.Shared/Physics/Systems/SharedBroadphaseSystem.cs
+133 −190 Robust.Shared/Physics/Systems/SharedPhysicsSystem.Queries.cs
+0 −72 Robust.Shared/Physics/Transform.cs
+1 −4 Robust.Shared/Prototypes/Attributes.cs
+20 −9 Robust.Shared/Prototypes/PrototypeManager.cs
+3 −8 Robust.Shared/Resources/RsiLoading.cs
+1 −0 Robust.Shared/Toolshed/Commands/Entities/WithCommand.cs
+3 −4 Robust.Shared/Toolshed/TypeParsers/BoolTypeParser.cs
+2 −2 Robust.Shared/Toolshed/TypeParsers/EntityTypeParser.cs
+4 −4 Robust.Shared/Toolshed/TypeParsers/EnumTypeParser.cs
+2 −2 Robust.Shared/Toolshed/TypeParsers/SessionTypeParser.cs
+0 −2 Robust.UnitTesting/Shared/IoC/IoCManager_Test.cs
+0 −8 Robust.UnitTesting/Shared/Maths/Angle_Test.cs
+11 −10 Robust.UnitTesting/Shared/Maths/Matrix3_Test.cs
+0 −145 Robust.UnitTesting/Shared/Physics/RayCast_Test.cs
+0 −8 Robust.UnitTesting/Shared/Serialization/SerializationTests/CommunitaryLungTest.cs
+10 −33 Robust.UnitTesting/Shared/Serialization/TypeSerializers/AngleSerializerTest.cs

0 comments on commit ab39b71

Please sign in to comment.