Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions GameData/RealAntennas/RealAntennasCommNetParams.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -405,3 +405,25 @@ Kopernicus:NEEDS[!Kopernicus]
}
}
}

@Kopernicus:LAST[zRealAntennas]
{
@Body[Kerbin]
Comment thread
DRVeyl marked this conversation as resolved.
Outdated
{
@PQS
{
@Mods
{
@City2[*TrackingStation],*
{
@Antenna,*
{
&TARGET //
Comment thread
DRVeyl marked this conversation as resolved.
Outdated
{
}
}
}
}
}
}
}
Comment thread
DRVeyl marked this conversation as resolved.
Outdated
8 changes: 4 additions & 4 deletions src/RealAntennasProject/Physics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ public static float NoiseTemperature(RealAntenna rx, Vector3d origin)
float amt = AntennaMicrowaveTemp(rx);
float atmos = AtmosphericTemp(rx, origin);
float cosmic = CosmicBackgroundTemp(rx, origin);
// Home Stations are directional, but treated as always pointing towards the peer.
float allbody = rx.ParentNode.isHome ? AllBodyTemps(rx, origin - rx.Position) : AllBodyTemps(rx, rx.ToTarget);
// Tracking antennas and omni antennas always point towards the peer.
float allbody = (rx.IsTracking || rx.Shape == AntennaShape.Omni) ? AllBodyTemps(rx, origin - rx.Position) : AllBodyTemps(rx, rx.ToTarget);
Comment thread
DRVeyl marked this conversation as resolved.
Outdated
float total = amt + atmos + cosmic + allbody;
// Debug.LogFormat("NoiseTemp: Antenna {0:F2} Atmos: {1:F2} Cosmic: {2:F2} Bodies: {3:F2} Total: {4:F2}", amt, atmos, cosmic, allbody, total);
return total;
Expand Down Expand Up @@ -304,7 +304,7 @@ private static float CosmicBackgroundTemp(RealAntenna rx, Vector3d origin)
temp = CosmicBackgroundTemp(new double3(normal.x, normal.y, normal.z),
new double3(to_origin.x, to_origin.y, to_origin.z),
rx.Frequency,
rxNode.isHome);
rxNode.isGroundStation);

}
return temp;
Expand All @@ -320,7 +320,7 @@ public static float AllBodyTemps(RealAntenna rx, Vector3d rxPointing)
// Note there are ~33 bodies in RSS.
foreach (CelestialBody body in FlightGlobals.Bodies)
{
if (!node.isHome || !node.ParentBody.Equals(body))
if (!node.isGroundStation || !node.ParentBody.Equals(body))
{
temp += BodyNoiseTemp(rx, body, rxPointing);
}
Expand Down
12 changes: 8 additions & 4 deletions src/RealAntennasProject/PlannerGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,6 @@ private void FireOnce()
var defaultPos = home.GetWorldSurfacePosition(0, 0, 100);
var defaultOffset = home.GetWorldSurfacePosition(0, 0, 1e6);
var defaultDir = (defaultOffset - defaultPos).normalized;
var offset = fixedNode.isHome ? 1e8 : 0;
fixedNode.transform.SetPositionAndRotation(defaultPos + offset * defaultDir, Quaternion.identity);
primaryNearNode.transform.SetPositionAndRotation(defaultPos + (offset + distanceMin) * defaultDir, Quaternion.identity);
primaryFarNode.transform.SetPositionAndRotation(defaultPos + (offset + distanceMax) * defaultDir, Quaternion.identity);
fixedNode.precisePosition = fixedNode.position;
primaryNearNode.precisePosition = primaryNearNode.position;
primaryFarNode.precisePosition = primaryFarNode.position;
Expand All @@ -361,6 +357,14 @@ private void FireOnce()
primaryNearNode.ParentBody = (primaryAntenna.ParentNode as RACommNode)?.ParentBody;
primaryFarNode.ParentBody = (primaryAntenna.ParentNode as RACommNode)?.ParentBody;
fixedNode.ParentBody = (fixedAntenna.ParentNode as RACommNode)?.ParentBody;
primaryNearNode.ParentVessel = (primaryAntenna.ParentNode as RACommNode)?.ParentVessel; // Copy this info over as well in case anything needs it.
primaryFarNode.ParentVessel = (primaryAntenna.ParentNode as RACommNode)?.ParentVessel;
fixedNode.ParentVessel = (fixedAntenna.ParentNode as RACommNode)?.ParentVessel;

var offset = fixedNode.isGroundStation ? 1e8 : 0;
fixedNode.transform.SetPositionAndRotation(defaultPos + offset * defaultDir, Quaternion.identity);
primaryNearNode.transform.SetPositionAndRotation(defaultPos + (offset + distanceMin) * defaultDir, Quaternion.identity);
primaryFarNode.transform.SetPositionAndRotation(defaultPos + (offset + distanceMax) * defaultDir, Quaternion.identity);

var nodes = new List<CommNet.CommNode> { fixedNode, primaryNearNode };
var bodies = new List<CelestialBody> { Planetarium.fetch.Home };
Expand Down
2 changes: 1 addition & 1 deletion src/RealAntennasProject/Precompute/FilteringJobs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void Execute(int index)
int y = pairs[index].y;
CNInfo a = nodes[x];
CNInfo b = nodes[y];
valid[index] = x != y && !(a.isHome && b.isHome) && a.canComm && b.canComm;
valid[index] = x != y && !(a.isGroundStation && b.isGroundStation) && a.canComm && b.canComm;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/RealAntennasProject/Precompute/Precompute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public struct CNInfo
{
internal double3 position;
internal double3 surfaceNormal;
internal bool isHome;
internal bool isGroundStation;
internal bool canComm;
}

Expand Down Expand Up @@ -682,7 +682,7 @@ private void SetupCommNodes(out NativeList<CNInfo> infos, List<CommNet.CommNode>
infos.Add(new CNInfo()
{
position = new double3(node.precisePosition.x, node.precisePosition.y, node.precisePosition.z),
isHome = node.isHome,
isGroundStation = node.isGroundStation,
canComm = forceValid || node.CanComm(),
surfaceNormal = new double3(surfN.x, surfN.y, surfN.z),
//name = $"{node}",
Expand Down
4 changes: 4 additions & 0 deletions src/RealAntennasProject/RACommNetwork.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class RACommNetwork : CommNetwork
public List<CommNode> Nodes { get => nodes; }
public RealAntenna DebugAntenna => connectionDebugger?.antenna;
public Network.ConnectionDebugger connectionDebugger = null;
public readonly EventVoid NetworkUpdateComplete = new EventVoid("Network Rebuild Complete");
public double LastUpdateUT { get; private set; } = 0;

public override CommNode Add(CommNode conn)
{
Expand Down Expand Up @@ -164,6 +166,8 @@ public virtual void CompleteRebuild()
PostUpdateNodes();
if (OnNetworkPostUpdate is Action)
OnNetworkPostUpdate();
LastUpdateUT = Planetarium.GetUniversalTime();
NetworkUpdateComplete.Fire();
tempWatch.Stop();
Profiler.EndSample();
(RACommNetScenario.Instance as RACommNetScenario).metrics.AddMeasurement("Precompute LateRebuild", PrecomputeLateWatch.Elapsed.TotalMilliseconds);
Expand Down
2 changes: 2 additions & 0 deletions src/RealAntennasProject/RACommNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public class RACommNode : CommNet.CommNode
public List<RealAntenna> RAAntennaList { get; set; }
public CelestialBody ParentBody { get; set; }
public Vessel ParentVessel { get; set; }
public bool isGroundStation => !(ParentBody is null);
// Skopos stations have isHome set to false, hence the need for this check.

public RACommNode() : base() { }
public RACommNode(Transform t) : base(t)
Expand Down
9 changes: 8 additions & 1 deletion src/RealAntennasProject/RealAntenna.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class RealAntenna
public virtual bool CanTarget => Shape != AntennaShape.Omni && !IsTracking;
public Vector3 ToTarget => (CanTarget && Target != null) ? (Vector3) (Target.transform.position - Position) : Vector3.zero;

// In the absence of a TARGET config node, antennas will target the centre of the home body.
// However, if the antenna belongs to a node with a ParentBody, Target will be set to null.
private Targeting.AntennaTarget _target;
public Targeting.AntennaTarget Target
{
Expand Down Expand Up @@ -119,8 +121,13 @@ public virtual void LoadFromConfigNode(ConfigNode config)
AMWTemp = (config.HasValue("AMWTemp")) ? float.Parse(config.GetValue("AMWTemp")) : 290f;
if (config.HasNode("TARGET"))
Target = Targeting.AntennaTarget.LoadFromConfig(config.GetNode("TARGET"), this);
else if (Shape != AntennaShape.Omni && (ParentNode == null || !ParentNode.isHome) && !(Target?.Validate() == true) && HighLogic.LoadedSceneHasPlanetarium)
else if (ParentNode is RACommNode RANode && RANode.isGroundStation) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we move this condition to SetDefaultTarget instead (and make the default target TARGET{} for ground stations)?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think ParentNode being null is a sign something is broken. Can't participate in the network if you ...don't have a node in the network. Yeah, a validity check probably goes in SetDefaultTarget.

Debug.LogFormat($"{ModTag} ground station {RANode.displayName} antenna {Name} missing TARGET node - defaulted to null");
Target = null;
}
else if (Shape != AntennaShape.Omni && !(Target?.Validate() == true) && HighLogic.LoadedSceneHasPlanetarium)
Target = Targeting.AntennaTarget.LoadFromConfig(SetDefaultTarget(), this);

EncoderOverride = (config.HasValue("EncoderOverride")) ? config.GetValue("EncoderOverride") : null;
}

Expand Down
2 changes: 1 addition & 1 deletion src/RealAntennasProject/RealAntennasUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private void VesselCounts(out int vessels, out int groundStations, out int anten
net = $"{racn}";
foreach (RACommNode node in racn.Nodes)
{
if (node.isHome)
if (node.isGroundStation)
{
groundStations++;
}
Expand Down
Loading