using System.Numerics;
using Microsoft.UI.Composition;
using Windows.Foundation;
using XFEEDToolBox.Core.Galaxy;
using XFEEDToolBox.Core.Models;
namespace XFEEDToolBox.Controls;
public sealed partial class GalaxyMapView
{
private GalaxyConstellationResolution constellationResolution = new([], [], 16);
private readonly List<(LineVisual Line, CompositionColorBrush Brush)> constellationLines = [];
internal int VisibleConstellationSegments { get; private set; }
internal int ResolvedConstellationGroupsForProbe => constellationResolution.Groups.Count;
internal int PendingConstellationGroupsForProbe => constellationResolution.PendingGroupCount;
internal GalaxyConstellationResolution ConstellationResolutionForProbe => constellationResolution;
internal int OriginalConstellationSubmittedForProbe=>graphics?.SubmittedOriginalConstellationLines??0;
internal bool OriginalConstellationWorldStyleForProbe=>graphics?.OriginalConstellationWorldStyleRestored==true;
private void RebuildConstellations()
{
if (Filter?.ShowConstellations != true)
{
constellationResolution = new([], [], 16);
return;
}
// Use the same strictly filtered catalogue snapshot as the stellar models.
// This adds no network/native request and never supplies an estimated position.
var endpoints = GalaxyOriginalConstellations.EndpointNames.ToHashSet(StringComparer.OrdinalIgnoreCase);
var facts = new Dictionary<string, Coordinates>(StringComparer.OrdinalIgnoreCase);
foreach (var sample in ordered)
if (endpoints.Contains(sample.System.Name)) facts.TryAdd(sample.System.Name, sample.System.Position);
constellationResolution = GalaxyOriginalConstellations.Resolve(facts.GetValueOrDefault);
}
private void DrawConstellations(GalaxyCamera camera, ref int lineCount)
{
VisibleConstellationSegments = 0;
graphics?.SetOriginalConstellations(Filter?.ShowConstellations==true?constellationResolution.Groups:[],camera);
if (Filter?.ShowConstellations == true)
foreach (var group in constellationResolution.Groups)
{
var alpha = GalaxyOriginalConstellations.Alpha(group, camera.Eye, camera.Focus);
if (alpha <= GalaxyOriginalConstellations.SubmissionAlpha) continue;
foreach (var edge in group.Lines)
{
if (!GalaxyMapGeometry.TryProjectSegment(camera, edge.From, edge.To, out var segment)) continue;
var from = new Point(segment.X1, segment.Y1); var to = new Point(segment.X2, segment.Y2);
var dx = to.X - from.X; var dy = to.Y - from.Y;
var length = Math.Sqrt(dx * dx + dy * dy);
if (length < .3) continue;
// GPU uses the actual world-width StarMapLine pass. Retain a
// neutral Composition fallback when no D3D renderer is available.
if (graphics is null)
{
if (constellationLines.Count <= VisibleConstellationSegments)
{
var brush = compositor!.CreateColorBrush(Windows.UI.Color.FromArgb(255, 255, 255, 255));
constellationLines.Add((CreateLine(brush, 1), brush));
}
var line = constellationLines[VisibleConstellationSegments];
line.Brush.Color = Windows.UI.Color.FromArgb((byte)Math.Round(alpha * 255), 255, 255, 255);
line.Line.Shape.Scale = Vector2.One;
line.Line.Move(from, to);
}
VisibleConstellationSegments++;
}
}
for (var i = graphics is null ? VisibleConstellationSegments : 0; i < constellationLines.Count; i++)
constellationLines[i].Line.Shape.Scale = Vector2.Zero;
}
}
using System.Numerics;
using Microsoft.UI.Composition;
using Windows.Foundation;
using XFEEDToolBox.Core.Galaxy;
using XFEEDToolBox.Core.Models;
namespace XFEEDToolBox.Controls;
public sealed partial class GalaxyMapView
{
private GalaxyConstellationResolution constellationResolution = new([], [], 16);
private readonly List<(LineVisual Line, CompositionColorBrush Brush)> constellationLines = [];
internal int VisibleConstellationSegments { get; private set; }
internal int ResolvedConstellationGroupsForProbe => constellationResolution.Groups.Count;
internal int PendingConstellationGroupsForProbe => constellationResolution.PendingGroupCount;
internal GalaxyConstellationResolution ConstellationResolutionForProbe => constellationResolution;
internal int OriginalConstellationSubmittedForProbe=>graphics?.SubmittedOriginalConstellationLines??0;
internal bool OriginalConstellationWorldStyleForProbe=>graphics?.OriginalConstellationWorldStyleRestored==true;
private void RebuildConstellations()
{
if (Filter?.ShowConstellations != true)
{
constellationResolution = new([], [], 16);
return;
}
// Use the same strictly filtered catalogue snapshot as the stellar models.
// This adds no network/native request and never supplies an estimated position.
var endpoints = GalaxyOriginalConstellations.EndpointNames.ToHashSet(StringComparer.OrdinalIgnoreCase);
var facts = new Dictionary<string, Coordinates>(StringComparer.OrdinalIgnoreCase);
foreach (var sample in ordered)
if (endpoints.Contains(sample.System.Name)) facts.TryAdd(sample.System.Name, sample.System.Position);
constellationResolution = GalaxyOriginalConstellations.Resolve(facts.GetValueOrDefault);
}
private void DrawConstellations(GalaxyCamera camera, ref int lineCount)
{
VisibleConstellationSegments = 0;
graphics?.SetOriginalConstellations(Filter?.ShowConstellations==true?constellationResolution.Groups:[],camera);
if (Filter?.ShowConstellations == true)
foreach (var group in constellationResolution.Groups)
{
var alpha = GalaxyOriginalConstellations.Alpha(group, camera.Eye, camera.Focus);
if (alpha <= GalaxyOriginalConstellations.SubmissionAlpha) continue;
foreach (var edge in group.Lines)
{
if (!GalaxyMapGeometry.TryProjectSegment(camera, edge.From, edge.To, out var segment)) continue;
var from = new Point(segment.X1, segment.Y1); var to = new Point(segment.X2, segment.Y2);
var dx = to.X - from.X; var dy = to.Y - from.Y;
var length = Math.Sqrt(dx * dx + dy * dy);
if (length < .3) continue;
// GPU uses the actual world-width StarMapLine pass. Retain a
// neutral Composition fallback when no D3D renderer is available.
if (graphics is null)
{
if (constellationLines.Count <= VisibleConstellationSegments)
{
var brush = compositor!.CreateColorBrush(Windows.UI.Color.FromArgb(255, 255, 255, 255));
constellationLines.Add((CreateLine(brush, 1), brush));
}
var line = constellationLines[VisibleConstellationSegments];
line.Brush.Color = Windows.UI.Color.FromArgb((byte)Math.Round(alpha * 255), 255, 255, 255);
line.Line.Shape.Scale = Vector2.One;
line.Line.Move(from, to);
}
VisibleConstellationSegments++;
}
}
for (var i = graphics is null ? VisibleConstellationSegments : 0; i < constellationLines.Count; i++)
constellationLines[i].Line.Shape.Scale = Vector2.Zero;
}
}