Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into 2024-08-19-reloads
Browse files Browse the repository at this point in the history
# Conflicts:
#	RELEASE-NOTES.md
  • Loading branch information
metalgearsloth committed Sep 3, 2024
2 parents 1e3d149 + f3dfa1f commit 6b7a8b2
Show file tree
Hide file tree
Showing 126 changed files with 1,484 additions and 1,058 deletions.
2 changes: 1 addition & 1 deletion MSBuild/Robust.Engine.Version.props
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project>
<!-- This file automatically reset by Tools/version.py -->
<PropertyGroup><Version>231.1.1</Version></PropertyGroup>
<PropertyGroup><Version>233.0.2</Version></PropertyGroup>
</Project>
Expand Down
64 changes: 63 additions & 1 deletion RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@ END TEMPLATE-->
### New features

* AddComponent now has an overload for ComponentRegistryEntry.
* `MarkupNode` is now `IEquatable<MarkupNode>`. It already supported equality checks, now it implements the interface.
* Added `Entity<T>` overloads to the following `SharedMapSystem` methods: `GetTileRef`, `GetAnchoredEntities`, `TileIndicesFor`.
* Added `EntityUid`-only overloads to the following `SharedTransformSystem` methods: `AnchorEntity`, `Unanchor`.

### Bugfixes

*None yet*
* Fixed equality checks for `MarkupNode` not properly handling attributes.
* Fixed `MarkupNode` not having a `GetHashCode()` implementation.

### Other

Expand All @@ -54,6 +58,64 @@ END TEMPLATE-->
*None yet*


## 233.0.2

### Bugfixes

* Fix exceptions in client game state handling for grids. Now they will rely upon the networked fixture data and not try to rebuild in the grid state handler.


## 233.0.1

### Bugfixes

* Fix IsHardCollidable component to EntityUid references.


## 233.0.0

### Breaking changes

* Made EntityRenamed a broadcast event & added additional args.
* Made test runs parallelizable.
* Added a debug assert that other threads aren't touching entities.

### Bugfixes

* Fix some entitylookup method transformations and add more tests.
* Fix mousehover not updating if new controls showed up under the mouse.

### Internal

* `ClientGameStateManager` now only initialises or starts entities after their parents have already been initialized. There are also some new debug asserts to try ensure that this rule isn't broken elsewhere.
* Engine version script now supports dashes.


## 232.0.0

### Breaking changes

* Obsolete method `AppearanceComponent.TryGetData` is now access-restricted to `SharedAppearanceSystem`; use `SharedAppearanceSystem.TryGetData` instead.

### New features

* Added `SharedAppearanceSystem.AppendData`, which appends non-existing `AppearanceData` from one `AppearanceComponent` to another.
* Added `AppearanceComponent.AppearanceDataInit`, which can be used to set initial `AppearanceData` entries in .yaml.

### Bugfixes

* Fix BUI interfaces not deep-copying in state handling.
* Add Robust.Xaml.csproj to the solution to fix some XAML issues.

### Other

* Serialization will now add type tags (`!type:<T>`) for necessary `NodeData` when writing (currently only for `object` nodes).

### Internal

* Added `ObjectSerializer`, which handles serialization of the generic `object` type.


## 231.1.1

### Bugfixes
Expand Down
96 changes: 96 additions & 0 deletions Robust.Benchmarks/Physics/BoxStackBenchmark.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
using System;
using System.Numerics;
using BenchmarkDotNet.Attributes;
using Microsoft.Extensions.Configuration;
using Robust.Shared.Analyzers;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Collision.Shapes;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Physics.Systems;
using Robust.UnitTesting.Server;

namespace Robust.Benchmarks.Physics;

[Virtual]
[MediumRunJob]
public class PhysicsBoxStackBenchmark
{
private ISimulation _sim = default!;

[GlobalSetup]
public void Setup()
{
_sim = RobustServerSimulation.NewSimulation().InitializeInstance();

var entManager = _sim.Resolve<IEntityManager>();
entManager.System<SharedMapSystem>().CreateMap(out var mapId);
SetupTumbler(entManager, mapId);

for (var i = 0; i < 30; i++)
{
entManager.TickUpdate(0.016f, false);
}
}

[Benchmark]
public void BoxStack()
{
var entManager = _sim.Resolve<IEntityManager>();

for (var i = 0; i < 10000; i++)
{
entManager.TickUpdate(0.016f, false);
}
}

private void SetupTumbler(IEntityManager entManager, MapId mapId)
{
var physics = entManager.System<SharedPhysicsSystem>();
var fixtures = entManager.System<FixtureSystem>();

var groundUid = entManager.SpawnEntity(null, new MapCoordinates(0, 0, mapId));
var ground = entManager.AddComponent<PhysicsComponent>(groundUid);

var horizontal = new EdgeShape(new Vector2(-40, 0), new Vector2(40, 0));
fixtures.CreateFixture(groundUid, "fix1", new Fixture(horizontal, 2, 2, true), body: ground);

var vertical = new EdgeShape(new Vector2(10, 0), new Vector2(10, 10));
fixtures.CreateFixture(groundUid, "fix2", new Fixture(vertical, 2, 2, true), body: ground);

var xs = new[]
{
0.0f, -10.0f, -5.0f, 5.0f, 10.0f
};

var columnCount = 1;
var rowCount = 15;
PolygonShape shape;

for (var j = 0; j < columnCount; j++)
{
for (var i = 0; i < rowCount; i++)
{
var x = 0.0f;

var boxUid = entManager.SpawnEntity(null,
new MapCoordinates(new Vector2(xs[j] + x, 0.55f + 1.1f * i), mapId));
var box = entManager.AddComponent<PhysicsComponent>(boxUid);

physics.SetBodyType(boxUid, BodyType.Dynamic, body: box);

shape = new PolygonShape();
shape.SetAsBox(0.5f, 0.5f);
physics.SetFixedRotation(boxUid, false, body: box);
fixtures.CreateFixture(boxUid, "fix1", new Fixture(shape, 2, 2, true), body: box);

physics.WakeBody(boxUid, body: box);
physics.SetSleepingAllowed(boxUid, box, false);
}
}

physics.WakeBody(groundUid, body: ground);
}
}
92 changes: 92 additions & 0 deletions Robust.Benchmarks/Physics/CircleStackBenchmark.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
using System.Numerics;
using BenchmarkDotNet.Attributes;
using Robust.Shared.Analyzers;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Collision.Shapes;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Physics.Systems;
using Robust.UnitTesting.Server;

namespace Robust.Benchmarks.Physics;

[Virtual]
public class PhysicsCircleStackBenchmark
{
private ISimulation _sim = default!;

[GlobalSetup]
public void Setup()
{
_sim = RobustServerSimulation.NewSimulation().InitializeInstance();

var entManager = _sim.Resolve<IEntityManager>();
entManager.System<SharedMapSystem>().CreateMap(out var mapId);
SetupTumbler(entManager, mapId);

for (var i = 0; i < 30; i++)
{
entManager.TickUpdate(0.016f, false);
}
}

[Benchmark]
public void CircleStack()
{
var entManager = _sim.Resolve<IEntityManager>();

for (var i = 0; i < 10000; i++)
{
entManager.TickUpdate(0.016f, false);
}
}

private void SetupTumbler(IEntityManager entManager, MapId mapId)
{
var physics = entManager.System<SharedPhysicsSystem>();
var fixtures = entManager.System<FixtureSystem>();

var groundUid = entManager.SpawnEntity(null, new MapCoordinates(0, 0, mapId));
var ground = entManager.AddComponent<PhysicsComponent>(groundUid);

var horizontal = new EdgeShape(new Vector2(-40, 0), new Vector2(40, 0));
fixtures.CreateFixture(groundUid, "fix1", new Fixture(horizontal, 2, 2, true), body: ground);

var vertical = new EdgeShape(new Vector2(20, 0), new Vector2(20, 20));
fixtures.CreateFixture(groundUid, "fix2", new Fixture(vertical, 2, 2, true), body: ground);

var xs = new[]
{
0.0f, -10.0f, -5.0f, 5.0f, 10.0f
};

var columnCount = 1;
var rowCount = 15;
PhysShapeCircle shape;

for (var j = 0; j < columnCount; j++)
{
for (var i = 0; i < rowCount; i++)
{
var x = 0.0f;

var boxUid = entManager.SpawnEntity(null,
new MapCoordinates(new Vector2(xs[j] + x, 0.55f + 2.1f * i), mapId));
var box = entManager.AddComponent<PhysicsComponent>(boxUid);

physics.SetBodyType(boxUid, BodyType.Dynamic, body: box);
shape = new PhysShapeCircle(0.5f);
physics.SetFixedRotation(boxUid, false, body: box);
// TODO: Need to detect shape and work out if we need to use fixedrotation

fixtures.CreateFixture(boxUid, "fix1", new Fixture(shape, 2, 2, true, 5f));
physics.WakeBody(boxUid, body: box);
physics.SetSleepingAllowed(boxUid, box, false);
}
}

physics.WakeBody(groundUid, body: ground);
}
}
91 changes: 91 additions & 0 deletions Robust.Benchmarks/Physics/PyramidBenchmark.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
using System;
using System.Numerics;
using BenchmarkDotNet.Attributes;
using Robust.Shared.Analyzers;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Collision.Shapes;
using Robust.Shared.Physics.Components;
using Robust.Shared.Physics.Dynamics;
using Robust.Shared.Physics.Systems;
using Robust.UnitTesting.Server;

namespace Robust.Benchmarks.Physics;

[Virtual]
public class PhysicsPyramidBenchmark
{
private ISimulation _sim = default!;

[GlobalSetup]
public void Setup()
{
_sim = RobustServerSimulation.NewSimulation().InitializeInstance();

var entManager = _sim.Resolve<IEntityManager>();
entManager.System<SharedMapSystem>().CreateMap(out var mapId);
SetupTumbler(entManager, mapId);

for (var i = 0; i < 300; i++)
{
entManager.TickUpdate(0.016f, false);
}
}

[Benchmark]
public void Pyramid()
{
var entManager = _sim.Resolve<IEntityManager>();

for (var i = 0; i < 5000; i++)
{
entManager.TickUpdate(0.016f, false);
}
}

private void SetupTumbler(IEntityManager entManager, MapId mapId)
{
const byte count = 20;

// Setup ground
var physics = entManager.System<SharedPhysicsSystem>();
var fixtures = entManager.System<FixtureSystem>();
var groundUid = entManager.SpawnEntity(null, new MapCoordinates(0, 0, mapId));
var ground = entManager.AddComponent<PhysicsComponent>(groundUid);

var horizontal = new EdgeShape(new Vector2(40, 0), new Vector2(-40, 0));
fixtures.CreateFixture(groundUid, "fix1", new Fixture(horizontal, 2, 2, true), body: ground);
physics.WakeBody(groundUid, body: ground);

// Setup boxes
float a = 0.5f;
PolygonShape shape = new();
shape.SetAsBox(a, a);

var x = new Vector2(-7.0f, 0.75f);
Vector2 y;
Vector2 deltaX = new Vector2(0.5625f, 1.25f);
Vector2 deltaY = new Vector2(1.125f, 0.0f);

for (var i = 0; i < count; ++i)
{
y = x;

for (var j = i; j < count; ++j)
{
var boxUid = entManager.SpawnEntity(null, new MapCoordinates(y, mapId));
var box = entManager.AddComponent<PhysicsComponent>(boxUid);
physics.SetBodyType(boxUid, BodyType.Dynamic, body: box);

fixtures.CreateFixture(boxUid, "fix1", new Fixture(shape, 2, 2, true, 5f), body: box);
y += deltaY;

physics.WakeBody(boxUid, body: box);
physics.SetSleepingAllowed(boxUid, box, false);
}

x += deltaX;
}
}
}
Loading

0 comments on commit 6b7a8b2

Please sign in to comment.