|
|
|
|
@ -126,18 +126,18 @@ selectOrbit(GameState* gs, GameOrbit* orbit)
|
|
|
|
|
|
|
|
|
|
bool |
|
|
|
|
addManeuver(GameOrbit* orbit, |
|
|
|
|
double anomaly, |
|
|
|
|
vec3 impulse_vector, |
|
|
|
|
ImpulseType impulse_type, |
|
|
|
|
double true_anomaly, |
|
|
|
|
double impulse_delta_v) |
|
|
|
|
{ |
|
|
|
|
assert(orbit); |
|
|
|
|
ManeuverNode& node = orbit->maneuver; |
|
|
|
|
|
|
|
|
|
if (anomaly < -M_PI || anomaly > M_PI) { |
|
|
|
|
LOGF(Error, "invalid true anomaly: %f\n", anomaly); |
|
|
|
|
if (true_anomaly < -M_PI || true_anomaly > M_PI) { |
|
|
|
|
LOGF(Error, "invalid true true_anomaly: %f\n", true_anomaly); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (orbit->maneuver.active) { |
|
|
|
|
if (node.active) { |
|
|
|
|
LOGF(Warning, "cannot add multiple maneuvers (yet)\n"); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
@ -147,21 +147,34 @@ addManeuver(GameOrbit* orbit,
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
orbit->maneuver.true_anomaly = anomaly; |
|
|
|
|
//orbit->maneuver.impulse_vector = ...
|
|
|
|
|
orbit->maneuver.impulse_delta_v = impulse_delta_v; |
|
|
|
|
orbit->maneuver.active = true; |
|
|
|
|
node.impulse_type = impulse_type; |
|
|
|
|
// TODO: thrust calculations
|
|
|
|
|
//double flight_path_angle = orbit->system.sat.gamma;
|
|
|
|
|
//node.impulse_vector.x = ...
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
if (node.impulse_type == ImpulseType::PROGRADE) { |
|
|
|
|
LOGF(Debug, "adding prograde maneuver\n"); |
|
|
|
|
node.true_anomaly = true_anomaly; |
|
|
|
|
node.impulse_delta_v = impulse_delta_v; |
|
|
|
|
node.active = true; |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
LOGF(Warning, "failed to add maneuver\n"); |
|
|
|
|
assert(0); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
removeManeuver(GameOrbit* orbit) |
|
|
|
|
{ |
|
|
|
|
assert(orbit); |
|
|
|
|
// TODO: multiple maneuver nodes
|
|
|
|
|
// NOTE: implicitly sets orbit->maneuver.active to false
|
|
|
|
|
orbit->maneuver = {0}; |
|
|
|
|
ManeuverNode& node = orbit->maneuver; |
|
|
|
|
node.impulse_type = ImpulseType::NONE; |
|
|
|
|
node.true_anomaly = 0.f; |
|
|
|
|
node.impulse_delta_v = 0.f; |
|
|
|
|
node.active = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// NOTE: test if the maneuver node would have occured between 2 orbit positions
|
|
|
|
|
@ -194,7 +207,7 @@ applyManeuver(GameOrbit* orbit)
|
|
|
|
|
LOGF(Debug, "applying maneuver\n"); |
|
|
|
|
|
|
|
|
|
// FIXME: assuming prograde impulse vector
|
|
|
|
|
assert(orbit->maneuver.impulse_type == ManeuverType::PROGRADE); |
|
|
|
|
assert(orbit->maneuver.impulse_type == ImpulseType::PROGRADE); |
|
|
|
|
|
|
|
|
|
// re-calculate state vectors at the maneuver node
|
|
|
|
|
TwoBodySystem& sys = orbit->system; |
|
|
|
|
@ -223,8 +236,6 @@ applyManeuver(GameOrbit* orbit)
|
|
|
|
|
assert(utilCStrMatch(buf->name, "position")); |
|
|
|
|
assert(buf->data_size == orbit->e3d.vert_count * sizeof(vec3)); |
|
|
|
|
updateGLBuffer(buf, orbit->e3d.vertices); |
|
|
|
|
|
|
|
|
|
removeManeuver(orbit); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// internal
|
|
|
|
|
|