From 9368c09220aadb42d9952645d762ed626780c43a Mon Sep 17 00:00:00 2001 From: Falki-git <72734856+Falki-git@users.noreply.github.com> Date: Thu, 8 Feb 2024 23:06:27 +0100 Subject: [PATCH 1/2] Fix waypoints to not be created below ground if the body isn't loaded. In this case a MaxTerrainHeight offset is added to the altitude of the waypoint. --- src/SpaceWarp.Game/API/Game/Waypoints/Waypoint.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/SpaceWarp.Game/API/Game/Waypoints/Waypoint.cs b/src/SpaceWarp.Game/API/Game/Waypoints/Waypoint.cs index 502143d..063d0f7 100644 --- a/src/SpaceWarp.Game/API/Game/Waypoints/Waypoint.cs +++ b/src/SpaceWarp.Game/API/Game/Waypoints/Waypoint.cs @@ -13,8 +13,6 @@ namespace SpaceWarp.API.Game.Waypoints; [PublicAPI] public class Waypoint { - - private SimulationObjectModel _waypointObject; /// @@ -130,7 +128,17 @@ public Waypoint(double latitude, double longitude, double? altitudeFromRadius = var body = celestialBodies.Find(c => c.Name == bodyName); if (body == null) throw new Exception($"Could not create waypoint as there is no body with the name of {bodyName}"); - altitudeFromRadius ??= body.SurfaceProvider.GetTerrainAltitudeFromCenter(latitude, longitude) - body.radius; + if (altitudeFromRadius == null) + { + altitudeFromRadius = body.SurfaceProvider.GetTerrainAltitudeFromCenter(latitude, longitude) - body.radius; + + // if the local space of the body is not loaded, then the altitude of the terrain from its center is equal to the radius + if (altitudeFromRadius == 0) + { + // we'll set the altitude to the MaxTerrainHeight, so that the waypoint will always appear above the surface + altitudeFromRadius += body.MaxTerrainHeight; + } + } AltitudeFromRadius = altitudeFromRadius.Value; _state = waypointState; if (_state == WaypointState.Visible) From 9396c52a841807c912e3431756b7efda8d38f599 Mon Sep 17 00:00:00 2001 From: cheese3660 Date: Fri, 9 Feb 2024 08:15:12 -0500 Subject: [PATCH 2/2] Update swinfo.json --- plugin_template/BepInEx/plugins/SpaceWarp/swinfo.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin_template/BepInEx/plugins/SpaceWarp/swinfo.json b/plugin_template/BepInEx/plugins/SpaceWarp/swinfo.json index 364069d..bd1122b 100644 --- a/plugin_template/BepInEx/plugins/SpaceWarp/swinfo.json +++ b/plugin_template/BepInEx/plugins/SpaceWarp/swinfo.json @@ -5,7 +5,7 @@ "name": "Space Warp", "description": "Space Warp is an API for KSP 2 mod developers.", "source": "https://github.com/SpaceWarpDev/SpaceWarp", - "version": "1.9.1", + "version": "1.9.2", "version_check": "https://raw.githubusercontent.com/SpaceWarpDev/SpaceWarp/main/plugin_template/BepInEx/plugins/SpaceWarp/swinfo.json", "ksp2_version": { "min": "0.2.1",