Svart hål

This commit is contained in:
2026-11-01 12:09:43 +01:00
parent c4a5a4b4ed
commit 8274a20001
14 changed files with 399 additions and 7 deletions

View File

@@ -272,7 +272,7 @@ public sealed class FlyCamera
public void RequestStarView(IEnumerable<StarSystemData> systems)
{
var nearest = systems.SelectMany(system => system.Stars.Select(star => (System: system, Star: star)))
var nearest = systems.SelectMany(system => system.Stars.Where(s => !s.IsBlackHole).Select(star => (System: system, Star: star)))
.MinBy(body => World(body.System, body.Star.PositionMeters).RelativeTo(Position, CellSizeMeters).LengthSquared);
if (nearest.Star is null) return;
var bodyPosition = World(nearest.System, nearest.Star.PositionMeters);
@@ -280,6 +280,28 @@ public sealed class FlyCamera
BeginFlight(bodyPosition, radial, nearest.Star.RadiusMeters * 2.55, nearest.Star.RadiusMeters * 5, -radial, new(0, 1, 0), 10_000_000);
}
public void RequestBlackHoleView(StarSystemData system, StarData star, IEnumerable<StarSystemData> departureSystems)
{
if (star.BlackHole is not { } hole) return;
var body = World(system, star.PositionMeters);
var equator = Perpendicular(hole.DiskNormal);
var radial = (equator * System.Math.Cos(.075) + hole.DiskNormal * System.Math.Sin(.075)).Normalized();
var up = RotateAround(hole.DiskNormal, -radial, .18);
Departure? departure = null;
var escape = departureSystems.SelectMany(s => s.Planets.Where(p => !p.IsGasPlanet).Select(p => (System: s, Planet: p)))
.MinBy(p => World(p.System, p.Planet.PositionMeters).RelativeTo(Position, CellSizeMeters).Length / p.Planet.RadiusMeters);
if (escape.Planet is { } solid)
{
var origin = World(escape.System, solid.PositionMeters);
var start = Position.RelativeTo(origin, CellSizeMeters);
if (start.Length < solid.MaximumTerrainRadiusMeters * 1.1)
departure = new(origin, start.Normalized(), body.RelativeTo(origin, CellSizeMeters).Normalized(),
start.Length, solid.MaximumTerrainRadiusMeters * 1.12);
}
BeginFlight(body, radial, star.RadiusMeters * 26, star.RadiusMeters * 70, -radial, up,
star.RadiusMeters * .08, duration: 9, fieldOfView: 32 * System.Math.PI / 180, departure: departure);
}
private UniversePosition World(StarSystemData system, DVector3 offset) => UniversePosition.AtCellCenter(system.Coordinate, CellSizeMeters).Add(offset, CellSizeMeters);
private void BeginFlight(UniversePosition body, DVector3 radial, double finalRadius, double approachRadius, DVector3 forward, DVector3 up, double speed,