Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c16a2b298155
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 700f72a78091
Choose a head ref
  • 4 commits
  • 13 files changed
  • 1 contributor

Commits on Aug 11, 2019

  1. Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    6646b3d View commit details
  2. Fix more clients.

    pleroy committed Aug 11, 2019
    Copy the full SHA
    2462b40 View commit details
  3. Lint.

    pleroy committed Aug 11, 2019
    Copy the full SHA
    599352f View commit details
  4. Merge pull request #2280 from pleroy/2261b

     Pass the maximum number of points to compute from C# to C++
    pleroy authored Aug 11, 2019
    Copy the full SHA
    700f72a View commit details
3 changes: 3 additions & 0 deletions astronomy/lunar_orbit_test.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

#include <algorithm>
#include <filesystem>
#include <limits>
#include <string>
#include <vector>

@@ -431,6 +432,7 @@ TEST_P(LunarOrbitTest, NearCircularRepeatGroundTrackOrbit) {
ComputeNodes(surface_trajectory.Begin(),
surface_trajectory.End(),
/*north=*/Vector<double, LunarSurface>({0, 0, 1}),
/*max_points=*/std::numeric_limits<int>::max(),
ascending_nodes,
descending_nodes);

@@ -439,6 +441,7 @@ TEST_P(LunarOrbitTest, NearCircularRepeatGroundTrackOrbit) {
ComputeApsides(*ephemeris_->trajectory(moon_),
trajectory.Begin(),
trajectory.End(),
/*max_points=*/std::numeric_limits<int>::max(),
apoapsides,
periapsides);

2 changes: 2 additions & 0 deletions benchmarks/apsides.cpp
Original file line number Diff line number Diff line change
@@ -140,6 +140,7 @@ BENCHMARK_F(ApsidesBenchmark, ComputeApsides)(benchmark::State& state) {
ComputeApsides(*earth_trajectory_,
ilrsa_lageos2_trajectory_icrs_->Begin(),
ilrsa_lageos2_trajectory_icrs_->End(),
/*max_points=*/std::numeric_limits<int>::max(),
apoapsides,
periapsides);
CHECK_EQ(2364, apoapsides.Size());
@@ -154,6 +155,7 @@ BENCHMARK_F(ApsidesBenchmark, ComputeNodes)(benchmark::State& state) {
ComputeNodes(ilrsa_lageos2_trajectory_gcrs_->Begin(),
ilrsa_lageos2_trajectory_gcrs_->End(),
Vector<double, GCRS>({0, 0, 1}),
/*max_points=*/std::numeric_limits<int>::max(),
ascending,
descending);
CHECK_EQ(2365, ascending.Size());
2 changes: 2 additions & 0 deletions ksp_plugin/interface_external.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

#include "ksp_plugin/interface.hpp"

#include <limits>
#include <string>

#include "absl/strings/str_cat.h"
@@ -238,6 +239,7 @@ Status principia__ExternalGetNearestPlannedCoastDegreesOfFreedom(
ComputeApsides(/*reference=*/immobile_reference,
coast.Begin(),
coast.End(),
/*max_points=*/std::numeric_limits<int>::max(),
apoapsides,
periapsides);
if (periapsides.Empty()) {
12 changes: 9 additions & 3 deletions ksp_plugin/interface_flight_plan.cpp
Original file line number Diff line number Diff line change
@@ -345,10 +345,11 @@ void principia__FlightPlanRenderedApsides(Plugin const* const plugin,
char const* const vessel_guid,
int const celestial_index,
XYZ const sun_world_position,
int const max_points,
Iterator** const apoapsides,
Iterator** const periapsides) {
journal::Method<journal::FlightPlanRenderedApsides> m(
{plugin, vessel_guid, celestial_index, sun_world_position},
{plugin, vessel_guid, celestial_index, sun_world_position, max_points},
{apoapsides, periapsides});
CHECK_NOTNULL(plugin);
DiscreteTrajectory<Barycentric>::Iterator begin;
@@ -359,6 +360,7 @@ void principia__FlightPlanRenderedApsides(Plugin const* const plugin,
plugin->ComputeAndRenderApsides(celestial_index,
begin, end,
FromXYZ<Position<World>>(sun_world_position),
max_points,
rendered_apoapsides,
rendered_periapsides);
*apoapsides = new TypedIterator<DiscreteTrajectory<World>>(
@@ -374,9 +376,10 @@ void principia__FlightPlanRenderedClosestApproaches(
Plugin const* const plugin,
char const* const vessel_guid,
XYZ const sun_world_position,
int const max_points,
Iterator** const closest_approaches) {
journal::Method<journal::FlightPlanRenderedClosestApproaches> m(
{plugin, vessel_guid, sun_world_position},
{plugin, vessel_guid, sun_world_position, max_points},
{closest_approaches});
CHECK_NOTNULL(plugin);
DiscreteTrajectory<Barycentric>::Iterator begin;
@@ -387,6 +390,7 @@ void principia__FlightPlanRenderedClosestApproaches(
begin,
end,
FromXYZ<Position<World>>(sun_world_position),
max_points,
rendered_closest_approaches);
*closest_approaches = new TypedIterator<DiscreteTrajectory<World>>(
check_not_null(std::move(rendered_closest_approaches)),
@@ -397,10 +401,11 @@ void principia__FlightPlanRenderedClosestApproaches(
void principia__FlightPlanRenderedNodes(Plugin const* const plugin,
char const* const vessel_guid,
XYZ const sun_world_position,
int const max_points,
Iterator** const ascending,
Iterator** const descending) {
journal::Method<journal::FlightPlanRenderedNodes> m(
{plugin, vessel_guid, sun_world_position},
{plugin, vessel_guid, sun_world_position, max_points},
{ascending, descending});
CHECK_NOTNULL(plugin);
DiscreteTrajectory<Barycentric>::Iterator begin;
@@ -410,6 +415,7 @@ void principia__FlightPlanRenderedNodes(Plugin const* const plugin,
std::unique_ptr<DiscreteTrajectory<World>> rendered_descending;
plugin->ComputeAndRenderNodes(begin, end,
FromXYZ<Position<World>>(sun_world_position),
max_points,
rendered_ascending,
rendered_descending);
*ascending = new TypedIterator<DiscreteTrajectory<World>>(
12 changes: 9 additions & 3 deletions ksp_plugin/interface_renderer.cpp
Original file line number Diff line number Diff line change
@@ -37,10 +37,11 @@ void principia__RenderedPredictionApsides(Plugin const* const plugin,
char const* const vessel_guid,
int const celestial_index,
XYZ const sun_world_position,
int const max_points,
Iterator** const apoapsides,
Iterator** const periapsides) {
journal::Method<journal::RenderedPredictionApsides> m(
{plugin, vessel_guid, celestial_index, sun_world_position},
{plugin, vessel_guid, celestial_index, sun_world_position, max_points},
{apoapsides, periapsides});
CHECK_NOTNULL(plugin);
auto const& prediction = plugin->GetVessel(vessel_guid)->prediction();
@@ -50,6 +51,7 @@ void principia__RenderedPredictionApsides(Plugin const* const plugin,
prediction.Fork(),
prediction.End(),
FromXYZ<Position<World>>(sun_world_position),
max_points,
rendered_apoapsides,
rendered_periapsides);
*apoapsides = new TypedIterator<DiscreteTrajectory<World>>(
@@ -65,9 +67,10 @@ void principia__RenderedPredictionClosestApproaches(
Plugin const* const plugin,
char const* const vessel_guid,
XYZ const sun_world_position,
int const max_points,
Iterator** const closest_approaches) {
journal::Method<journal::RenderedPredictionClosestApproaches> m(
{plugin, vessel_guid, sun_world_position},
{plugin, vessel_guid, sun_world_position, max_points},
{closest_approaches});
CHECK_NOTNULL(plugin);
auto const& prediction = plugin->GetVessel(vessel_guid)->prediction();
@@ -76,6 +79,7 @@ void principia__RenderedPredictionClosestApproaches(
prediction.Fork(),
prediction.End(),
FromXYZ<Position<World>>(sun_world_position),
max_points,
rendered_closest_approaches);
*closest_approaches = new TypedIterator<DiscreteTrajectory<World>>(
check_not_null(std::move(rendered_closest_approaches)),
@@ -86,10 +90,11 @@ void principia__RenderedPredictionClosestApproaches(
void principia__RenderedPredictionNodes(Plugin const* const plugin,
char const* const vessel_guid,
XYZ const sun_world_position,
int const max_points,
Iterator** const ascending,
Iterator** const descending) {
journal::Method<journal::RenderedPredictionNodes> m(
{plugin, vessel_guid, sun_world_position},
{plugin, vessel_guid, sun_world_position, max_points},
{ascending, descending});
CHECK_NOTNULL(plugin);
auto const& prediction = plugin->GetVessel(vessel_guid)->prediction();
@@ -98,6 +103,7 @@ void principia__RenderedPredictionNodes(Plugin const* const plugin,
plugin->ComputeAndRenderNodes(prediction.Fork(),
prediction.End(),
FromXYZ<Position<World>>(sun_world_position),
max_points,
rendered_ascending,
rendered_descending);
*ascending = new TypedIterator<DiscreteTrajectory<World>>(
6 changes: 6 additions & 0 deletions ksp_plugin/plugin.cpp
Original file line number Diff line number Diff line change
@@ -876,13 +876,15 @@ void Plugin::ComputeAndRenderApsides(
DiscreteTrajectory<Barycentric>::Iterator const& begin,
DiscreteTrajectory<Barycentric>::Iterator const& end,
Position<World> const& sun_world_position,
int const max_points,
std::unique_ptr<DiscreteTrajectory<World>>& apoapsides,
std::unique_ptr<DiscreteTrajectory<World>>& periapsides) const {
DiscreteTrajectory<Barycentric> apoapsides_trajectory;
DiscreteTrajectory<Barycentric> periapsides_trajectory;
ComputeApsides(FindOrDie(celestials_, celestial_index)->trajectory(),
begin,
end,
max_points,
apoapsides_trajectory,
periapsides_trajectory);
apoapsides = renderer_->RenderBarycentricTrajectoryInWorld(
@@ -903,6 +905,7 @@ void Plugin::ComputeAndRenderClosestApproaches(
DiscreteTrajectory<Barycentric>::Iterator const& begin,
DiscreteTrajectory<Barycentric>::Iterator const& end,
Position<World> const& sun_world_position,
int const max_points,
std::unique_ptr<DiscreteTrajectory<World>>& closest_approaches) const {
CHECK(renderer_->HasTargetVessel());

@@ -911,6 +914,7 @@ void Plugin::ComputeAndRenderClosestApproaches(
ComputeApsides(renderer_->GetTargetVessel().prediction(),
begin,
end,
max_points,
apoapsides_trajectory,
periapsides_trajectory);
closest_approaches =
@@ -926,6 +930,7 @@ void Plugin::ComputeAndRenderNodes(
DiscreteTrajectory<Barycentric>::Iterator const& begin,
DiscreteTrajectory<Barycentric>::Iterator const& end,
Position<World> const& sun_world_position,
int const max_points,
std::unique_ptr<DiscreteTrajectory<World>>& ascending,
std::unique_ptr<DiscreteTrajectory<World>>& descending) const {
auto const trajectory_in_plotting =
@@ -954,6 +959,7 @@ void Plugin::ComputeAndRenderNodes(
ComputeNodes(trajectory_in_plotting->Begin(),
trajectory_in_plotting->End(),
Vector<double, Navigation>({0, 0, 1}),
max_points,
ascending_trajectory,
descending_trajectory,
show_node);
3 changes: 3 additions & 0 deletions ksp_plugin/plugin.hpp
Original file line number Diff line number Diff line change
@@ -333,6 +333,7 @@ class Plugin {
DiscreteTrajectory<Barycentric>::Iterator const& begin,
DiscreteTrajectory<Barycentric>::Iterator const& end,
Position<World> const& sun_world_position,
int max_points,
std::unique_ptr<DiscreteTrajectory<World>>& apoapsides,
std::unique_ptr<DiscreteTrajectory<World>>& periapsides) const;

@@ -342,6 +343,7 @@ class Plugin {
DiscreteTrajectory<Barycentric>::Iterator const& begin,
DiscreteTrajectory<Barycentric>::Iterator const& end,
Position<World> const& sun_world_position,
int max_points,
std::unique_ptr<DiscreteTrajectory<World>>& closest_approaches) const;

// Computes the nodes of the trajectory defined by |begin| and |end| with
@@ -350,6 +352,7 @@ class Plugin {
DiscreteTrajectory<Barycentric>::Iterator const& begin,
DiscreteTrajectory<Barycentric>::Iterator const& end,
Position<World> const& sun_world_position,
int max_points,
std::unique_ptr<DiscreteTrajectory<World>>& ascending,
std::unique_ptr<DiscreteTrajectory<World>>& descending) const;

8 changes: 8 additions & 0 deletions ksp_plugin_adapter/ksp_plugin_adapter.cs
Original file line number Diff line number Diff line change
@@ -1883,11 +1883,13 @@ private void RenderPredictionMarkers(string vessel_guid,
plugin_.RenderedPredictionNodes(
vessel_guid,
sun_world_position,
MapNodePool.MaxRenderedNodes,
out DisposableIterator ascending_nodes_iterator,
out DisposableIterator descending_nodes_iterator);
plugin_.RenderedPredictionClosestApproaches(
vessel_guid,
sun_world_position,
MapNodePool.MaxRenderedNodes,
out DisposableIterator approaches_iterator);
map_node_pool_.RenderMarkers(
ascending_nodes_iterator,
@@ -1911,6 +1913,7 @@ private void RenderPredictionMarkers(string vessel_guid,
vessel_guid,
celestial.flightGlobalsIndex,
sun_world_position,
MapNodePool.MaxRenderedNodes,
out DisposableIterator apoapsis_iterator,
out DisposableIterator periapsis_iterator);
map_node_pool_.RenderMarkers(
@@ -1930,6 +1933,7 @@ private void RenderPredictionMarkers(string vessel_guid,
plugin_.RenderedPredictionNodes(
vessel_guid,
sun_world_position,
MapNodePool.MaxRenderedNodes,
out DisposableIterator ascending_nodes_iterator,
out DisposableIterator descending_nodes_iterator);
map_node_pool_.RenderMarkers(
@@ -1952,11 +1956,13 @@ private void RenderFlightPlanMarkers(string vessel_guid,
plugin_.FlightPlanRenderedNodes(
vessel_guid,
sun_world_position,
MapNodePool.MaxRenderedNodes,
out DisposableIterator ascending_nodes_iterator,
out DisposableIterator descending_nodes_iterator);
plugin_.FlightPlanRenderedClosestApproaches(
vessel_guid,
sun_world_position,
MapNodePool.MaxRenderedNodes,
out DisposableIterator approaches_iterator);
map_node_pool_.RenderMarkers(
ascending_nodes_iterator,
@@ -1980,6 +1986,7 @@ private void RenderFlightPlanMarkers(string vessel_guid,
vessel_guid,
celestial.flightGlobalsIndex,
sun_world_position,
MapNodePool.MaxRenderedNodes,
out DisposableIterator apoapsis_iterator,
out DisposableIterator periapsis_iterator);
map_node_pool_.RenderMarkers(
@@ -1998,6 +2005,7 @@ private void RenderFlightPlanMarkers(string vessel_guid,
plugin_.FlightPlanRenderedNodes(
vessel_guid,
sun_world_position,
MapNodePool.MaxRenderedNodes,
out DisposableIterator ascending_nodes_iterator,
out DisposableIterator descending_nodes_iterator);
map_node_pool_.RenderMarkers(
13 changes: 7 additions & 6 deletions ksp_plugin_adapter/map_node_pool.cs
Original file line number Diff line number Diff line change
@@ -5,6 +5,11 @@ namespace principia {
namespace ksp_plugin_adapter {

internal class MapNodePool {
// We render at most 64 markers of one type and one provenance (e.g., at
// most 64 perilunes for the prediction of the active vessel). This is
// more than is readable, and keeps the size of the map node pool under
// control.
public const int MaxRenderedNodes = 64;

public enum NodeSource {
PREDICTION,
@@ -44,10 +49,6 @@ public void RenderMarkers(DisposableIterator apsis_iterator,
MapObject.ObjectType type,
NodeSource source,
ReferenceFrameSelector reference_frame) {
// We render at most 64 markers of one type and one provenance (e.g., at
// most 64 perilunes for the prediction of the active vessel). This is
// more than is readable, and keeps the size of the map node pool under
// control.
MapObject associated_map_object;
UnityEngine.Color colour;
switch (type) {
@@ -97,7 +98,7 @@ public void RenderMarkers(DisposableIterator apsis_iterator,
}
colour.a = 1;

for (int i = 0; i < 64 && !apsis_iterator.IteratorAtEnd();
for (int i = 0; i < MaxRenderedNodes && !apsis_iterator.IteratorAtEnd();
++i, apsis_iterator.IteratorIncrement()) {
QP apsis = apsis_iterator.IteratorGetDiscreteTrajectoryQP();
MapNodeProperties node_properties = new MapNodeProperties {
@@ -166,7 +167,7 @@ private KSP.UI.Screens.Mapview.MapNode MakePoolNode() {
(KSP.UI.Screens.Mapview.MapNode node,
Mouse.Buttons buttons) => {
if (buttons == Mouse.Buttons.Left) {
var properties = properties_[node];
MapNodeProperties properties = properties_[node];
if (PlanetariumCamera.fetch.target !=
properties_[node].associated_map_object) {
PlanetariumCamera.fetch.SetTarget(
2 changes: 2 additions & 0 deletions physics/apsides.hpp
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@ template<typename Frame>
void ComputeApsides(Trajectory<Frame> const& reference,
typename DiscreteTrajectory<Frame>::Iterator begin,
typename DiscreteTrajectory<Frame>::Iterator end,
int max_points,
DiscreteTrajectory<Frame>& apoapsides,
DiscreteTrajectory<Frame>& periapsides);

@@ -33,6 +34,7 @@ template<typename Frame, typename Predicate = ConstantFunction<bool>>
void ComputeNodes(typename DiscreteTrajectory<Frame>::Iterator begin,
typename DiscreteTrajectory<Frame>::Iterator end,
Vector<double, Frame> const& north,
int max_points,
DiscreteTrajectory<Frame>& ascending,
DiscreteTrajectory<Frame>& descending,
Predicate predicate = Identically(true));
Loading