diff --git a/orbitalkiller/src/main/scala/com/github/dunnololda/scageprojects/orbitalkiller/OrbitDataUpdater.scala b/orbitalkiller/src/main/scala/com/github/dunnololda/scageprojects/orbitalkiller/OrbitDataUpdater.scala index b0c63c5..3705db2 100644 --- a/orbitalkiller/src/main/scala/com/github/dunnololda/scageprojects/orbitalkiller/OrbitDataUpdater.scala +++ b/orbitalkiller/src/main/scala/com/github/dunnololda/scageprojects/orbitalkiller/OrbitDataUpdater.scala @@ -85,7 +85,10 @@ object OrbitDataUpdater { yy:List[DVec], orbit_color: ScageColor) = { OrbitData(update_count, bs, body_radius, planet_state, planet, o, ccw, () => { - drawSlidingLines(yy.map(_ + planet_state.coord * scale), orbit_color) + openglLocalTransform { + openglMove(planet_state.coord * scale) + drawSlidingLines(yy, orbit_color) + } if(InterfaceHolder.namesSwitcher.showNames) { val new_o = o.withNewFocusPosition(planet_state.coord) drawStringInOrbitPoint("P", 0, new_o, orbit_color) @@ -103,7 +106,10 @@ object OrbitDataUpdater { yy:List[DVec], orbit_color: ScageColor) = { OrbitData(update_count, bs, body_radius, planet_state, planet, o, ccw, () => { - drawSlidingLines(yy.map(_ + planet_state.coord * scale), orbit_color) + openglLocalTransform { + openglMove(planet_state.coord * scale) + drawSlidingLines(yy, orbit_color) + } }) } @@ -118,7 +124,10 @@ object OrbitDataUpdater { orbit_color: ScageColor) = { OrbitData(update_count, bs, body_radius, planet_state, planet, o, ccw, () => { val new_o = o.withNewFocusPosition(planet_state.coord) - drawSlidingLines(yy.map(_ + planet_state.coord * scale), orbit_color) + openglLocalTransform { + openglMove(planet_state.coord * scale) + drawSlidingLines(yy, orbit_color) + } if(InterfaceHolder.namesSwitcher.showNames) { drawStringInOrbitPoint("P", 0, new_o, orbit_color) } @@ -174,13 +183,14 @@ object OrbitDataUpdater { ccw:Boolean, orbit_color: ScageColor) = { OrbitData(update_count, bs, body_radius, planet_state, planet, o, ccw, () => { - val new_o = o.withNewFocusPosition(planet_state.coord) + val new_center = o.centerIfFocusPosition(planet_state.coord) openglLocalTransform { - openglMove(new_o.center * scale) - openglRotateDeg(Vec(-1, 0).signedDeg(new_o.f2 - new_o.f)) - drawEllipse(DVec.zero, new_o.a * scale, new_o.b * scale, orbit_color) + openglMove(new_center * scale) + if(o.f2 != o.f) openglRotateDeg(Vec(1, 0).signedDeg(o.f_minus_f2_n)) + drawEllipse(DVec.zero, o.a * scale, o.b * scale, orbit_color) } if(InterfaceHolder.namesSwitcher.showNames) { + val new_o = o.withNewFocusPosition(planet_state.coord) drawStringInOrbitPoint("P", 0, new_o, orbit_color) drawStringInOrbitPoint("A", 180, new_o, orbit_color) } @@ -196,11 +206,11 @@ object OrbitDataUpdater { ccw:Boolean, orbit_color: ScageColor) = { OrbitData(update_count, bs, body_radius, planet_state, planet, o, ccw, () => { - val new_o = o.withNewFocusPosition(planet_state.coord) + val new_center = o.centerIfFocusPosition(planet_state.coord) openglLocalTransform { - openglMove(new_o.center * scale) - openglRotateDeg(Vec(-1, 0).signedDeg(o.f2 - o.f)) - drawEllipse(DVec.zero, new_o.a * scale, new_o.b * scale, orbit_color) + openglMove(new_center * scale) + if(o.f2 != o.f) openglRotateDeg(Vec(1, 0).signedDeg(o.f_minus_f2_n)) + drawEllipse(DVec.zero, o.a * scale, o.b * scale, orbit_color) } }) } @@ -217,7 +227,7 @@ object OrbitDataUpdater { val new_o = o.withNewFocusPosition(planet_state.coord) openglLocalTransform { openglMove(new_o.center * scale) - openglRotateDeg(Vec(-1, 0).signedDeg(new_o.f2 - new_o.f)) + if(new_o.f2 != new_o.f) openglRotateDeg(Vec(-1, 0).signedDeg(new_o.f2 - new_o.f)) drawEllipse(DVec.zero, new_o.a * scale, new_o.b * scale, orbit_color) } if(InterfaceHolder.namesSwitcher.showNames) { diff --git a/orbitalkiller/src/main/scala/com/github/dunnololda/scageprojects/orbitalkiller/PolygonShip.scala b/orbitalkiller/src/main/scala/com/github/dunnololda/scageprojects/orbitalkiller/PolygonShip.scala index 60cedfe..237ac07 100644 --- a/orbitalkiller/src/main/scala/com/github/dunnololda/scageprojects/orbitalkiller/PolygonShip.scala +++ b/orbitalkiller/src/main/scala/com/github/dunnololda/scageprojects/orbitalkiller/PolygonShip.scala @@ -1109,7 +1109,7 @@ abstract class PolygonShip( } } } - def updateStateSinceDeactivation(time_msec:Long, some_system_state: mutable.Map[Int, MutableBodyState]): Unit = { + private def updateStateSinceDeactivation(time_msec:Long, some_system_state: mutable.Map[Int, MutableBodyState]): Unit = { _orbit_data match { case Some(or) => val time_since_deactivation_msec = time_msec - deactivate_moment_msec @@ -1120,11 +1120,11 @@ abstract class PolygonShip( or.orbit match { case e:EllipseOrbit => val new_e = e.withNewFocusPosition(planet_coord) - val new_coord = new_e.orbitalPointAfterTime(deactivate_point_relative + planet_coord, time_since_deactivation_msec, or.ccw) + /*val new_coord = new_e.orbitalPointAfterTime(deactivate_point_relative + planet_coord, time_since_deactivation_msec, or.ccw) if(new_coord.x.isNaN || new_coord.y.isNaN || new_coord == planet_coord) { val x = new_e.orbitalPointAfterTime(deactivate_point_relative + planet_coord, time_since_deactivation_msec, or.ccw) - } - currentState.coord = new_coord + }*/ + currentState.coord = new_e.orbitalPointAfterTime(deactivate_point_relative + planet_coord, time_since_deactivation_msec, or.ccw) val (vt, vr) = new_e.orbitalVelocityInPoint(currentState.coord) val r = if (or.ccw) (currentState.coord - planet_coord).n else -(currentState.coord - planet_coord).n val t = r.perpendicular @@ -1377,13 +1377,13 @@ abstract class PolygonShip( // если это не корабль игрока, расстояние от данного корабля до корабля игрока больше 500 км, // перигей орбиты выше верхней границы атмосферы (орбита стабильная) или мы стоим на земле, // двигатели не включены - /*val deactivate_condition = thisOrActualProxyShipIndex != player_ship.thisOrActualProxyShipIndex && + val deactivate_condition = thisOrActualProxyShipIndex != player_ship.thisOrActualProxyShipIndex && coord.dist2(OrbitalKiller.player_ship.coord) > 500l*1000l * 500l*1000l && _orbit_data.exists(or => { or.is_landed || or.ellipseOrbit.exists(e => e.r_p > or.planet.radius + or.planet.air_free_altitude) }) && - engines.forall(!_.active)*/ - val (deactivate_condition, reason) = deactivateCondition + engines.forall(!_.active) + //val (deactivate_condition, reason) = deactivateCondition if (currentState.active) { calculateShipState(time_msec) if (deactivate_condition) { @@ -1393,10 +1393,13 @@ abstract class PolygonShip( println(s"deactivated $name") } } else { - if (!deactivate_condition) { + if(!deactivate_condition || (drawMapMode && ship_interface.exists(!_.isMinimized))) { updateStateSinceDeactivation(time_msec, system_evolution.allBodyStates) + } + if (!deactivate_condition) { currentState.active = true - println(s"activated $name, reason: $reason") + println(s"activated $name") + //println(s"activated $name, reason: $reason") } } } else { diff --git a/orbitalkiller/src/main/scala/com/github/dunnololda/scageprojects/orbitalkiller/package.scala b/orbitalkiller/src/main/scala/com/github/dunnololda/scageprojects/orbitalkiller/package.scala index 7d5b9e1..e1715ee 100644 --- a/orbitalkiller/src/main/scala/com/github/dunnololda/scageprojects/orbitalkiller/package.scala +++ b/orbitalkiller/src/main/scala/com/github/dunnololda/scageprojects/orbitalkiller/package.scala @@ -1550,6 +1550,10 @@ package object orbitalkiller { val new_center = (new_f2 - new_f).n * c + new_f new EllipseOrbit(a, b, e, c, p, r_p, r_a, t, new_f, new_f2, new_center, mu) } + + def centerIfFocusPosition(new_f:DVec):DVec = { + (f2 - f).n * c + new_f + } } class HyperbolaOrbit(