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: 4214e0736f31
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: e237bcdc9a81
Choose a head ref
Loading
35 changes: 14 additions & 21 deletions ksp_plugin/interface_flight_plan.cpp
Original file line number Diff line number Diff line change
@@ -152,9 +152,6 @@ Burn GetBurn(Plugin const& plugin,
NavigationManoeuvre ToInterfaceNavigationManoeuvre(
Plugin const& plugin,
NavigationManœuvre const& manœuvre) {
OrthogonalMap<Barycentric, World> const barycentric_to_world =
OrthogonalMap<WorldSun, World>::Identity() *
plugin.BarycentricToWorldSun();
NavigationManoeuvre result;
result.burn = GetBurn(plugin, manœuvre);
result.initial_mass_in_tonnes = manœuvre.initial_mass() / Tonne;
@@ -167,7 +164,8 @@ NavigationManoeuvre ToInterfaceNavigationManoeuvre(
Vector<double, Barycentric> const barycentric_inertial_direction =
manœuvre.InertialDirection();
Vector<double, World> const world_inertial_direction =
barycentric_to_world(barycentric_inertial_direction);
plugin.renderer().BarycentricToWorld(plugin.PlanetariumRotation())(
barycentric_inertial_direction);
result.inertial_direction = ToXYZ(world_inertial_direction);
return result;
}
@@ -272,22 +270,14 @@ principia__FlightPlanGetManoeuvreFrenetTrihedron(Plugin const* const plugin,
journal::Method<journal::FlightPlanGetManoeuvreFrenetTrihedron> m(
{plugin, vessel_guid, index});
CHECK_NOTNULL(plugin);
NavigationManoeuvreFrenetTrihedron result;

NavigationManœuvre const& manœuvre =
GetFlightPlan(*plugin, vessel_guid).GetManœuvre(index);
OrthogonalMap<Barycentric, World> const barycentric_to_world =
plugin->BarycentricToWorld();
OrthogonalMap<Frenet<Navigation>, Barycentric> frenet_to_barycentric =
manœuvre.FrenetFrame();
Instant const current_time = plugin->CurrentTime();
Instant const initial_time = manœuvre.initial_time();
auto const plotting_frame = plugin->GetPlottingFrame();
OrthogonalMap<Frenet<Navigation>, World> frenet_to_plotted_world =
barycentric_to_world *
plotting_frame->FromThisFrameAtTime(current_time).orthogonal_map() *
plotting_frame->ToThisFrameAtTime(initial_time).orthogonal_map() *
frenet_to_barycentric;
OrthogonalMap<Frenet<Navigation>, World> const frenet_to_plotted_world =
plugin->renderer().FrenetToWorld(plugin->CurrentTime(),
manœuvre,
plugin->PlanetariumRotation());
NavigationManoeuvreFrenetTrihedron result;
result.tangent = ToXYZ(
frenet_to_plotted_world(Vector<double, Frenet<Navigation>>({1, 0, 0})));
result.normal = ToXYZ(
@@ -414,10 +404,13 @@ Iterator* principia__FlightPlanRenderedSegment(
DiscreteTrajectory<Barycentric>::Iterator begin;
DiscreteTrajectory<Barycentric>::Iterator end;
GetFlightPlan(*plugin, vessel_guid).GetSegment(index, begin, end);
auto rendered_trajectory = CHECK_NOTNULL(plugin)->
RenderBarycentricTrajectoryInWorld(
begin, end,
FromXYZ<Position<World>>(sun_world_position));
auto rendered_trajectory =
plugin->renderer().RenderBarycentricTrajectoryInWorld(
plugin->CurrentTime(),
begin,
end,
FromXYZ<Position<World>>(sun_world_position),
plugin->PlanetariumRotation());
if (index % 2 == 1 && !rendered_trajectory->Empty() &&
rendered_trajectory->Begin().time() != begin.time()) {
// TODO(egg): this is ugly; we should centralize rendering.
45 changes: 32 additions & 13 deletions ksp_plugin/interface_renderer.cpp
Original file line number Diff line number Diff line change
@@ -4,22 +4,36 @@
#include "journal/method.hpp"
#include "journal/profiles.hpp"
#include "ksp_plugin/plugin.hpp"
#include "ksp_plugin/renderer.hpp"

namespace principia {
namespace interface {

using ksp_plugin::Renderer;

namespace {

Renderer& GetRenderer(Plugin* const plugin) {
return CHECK_NOTNULL(plugin)->renderer();
}

Renderer const& GetRenderer(Plugin const* const plugin) {
return CHECK_NOTNULL(plugin)->renderer();
}

} // namespace

void principia__ClearTargetVessel(Plugin* const plugin) {
journal::Method<journal::ClearTargetVessel> m({plugin});
CHECK_NOTNULL(plugin);
plugin->ClearTargetVessel();
GetRenderer(plugin).ClearTargetVessel();
return m.Return();
}

// Returns the frame last set by |plugin->SetPlottingFrame|. No transfer of
// ownership. The returned pointer is never null.
NavigationFrame const* principia__GetPlottingFrame(Plugin const* const plugin) {
journal::Method<journal::GetPlottingFrame> m({plugin});
return m.Return(CHECK_NOTNULL(plugin)->GetPlottingFrame());
return m.Return(GetRenderer(plugin).GetPlottingFrame());
}

Iterator* principia__RenderedPrediction(Plugin* const plugin,
@@ -30,10 +44,13 @@ Iterator* principia__RenderedPrediction(Plugin* const plugin,
sun_world_position});
CHECK_NOTNULL(plugin);
auto const& prediction = plugin->GetVessel(vessel_guid)->prediction();
auto rendered_trajectory = plugin->RenderBarycentricTrajectoryInWorld(
prediction.Begin(),
prediction.End(),
FromXYZ<Position<World>>(sun_world_position));
auto rendered_trajectory =
GetRenderer(plugin).RenderBarycentricTrajectoryInWorld(
plugin->CurrentTime(),
prediction.Begin(),
prediction.End(),
FromXYZ<Position<World>>(sun_world_position),
plugin->PlanetariumRotation());
return m.Return(new TypedIterator<DiscreteTrajectory<World>>(
std::move(rendered_trajectory),
plugin));
@@ -123,10 +140,13 @@ Iterator* principia__RenderedVesselTrajectory(Plugin const* const plugin,
sun_world_position});
CHECK_NOTNULL(plugin);
auto const& psychohistory = plugin->GetVessel(vessel_guid)->psychohistory();
auto rendered_trajectory = plugin->RenderBarycentricTrajectoryInWorld(
psychohistory.Begin(),
psychohistory.End(),
FromXYZ<Position<World>>(sun_world_position));
auto rendered_trajectory =
GetRenderer(plugin).RenderBarycentricTrajectoryInWorld(
plugin->CurrentTime(),
psychohistory.Begin(),
psychohistory.End(),
FromXYZ<Position<World>>(sun_world_position),
plugin->PlanetariumRotation());
return m.Return(new TypedIterator<DiscreteTrajectory<World>>(
std::move(rendered_trajectory),
plugin));
@@ -139,8 +159,7 @@ void principia__SetPlottingFrame(Plugin* const plugin,
NavigationFrame** const navigation_frame) {
journal::Method<journal::SetPlottingFrame> m({plugin, navigation_frame},
{navigation_frame});
CHECK_NOTNULL(plugin);
plugin->SetPlottingFrame(TakeOwnership(navigation_frame));
GetRenderer(plugin).SetPlottingFrame(TakeOwnership(navigation_frame));
return m.Return();
}

6 changes: 6 additions & 0 deletions ksp_plugin/ksp_plugin.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -115,6 +115,12 @@
<ClCompile Include="integrators.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="renderer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="interface_renderer.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\base\version.generated.cc">
<Filter>Source Files</Filter>
</ClCompile>
Loading