Qualify route gain and observe native gate context through ordinary input
This commit is contained in:
@@ -2,6 +2,20 @@
|
||||
class ERR_AircraftRouteRules
|
||||
{
|
||||
static bool Length(float distance) { return distance >= 18 && distance <= 20.05; }
|
||||
// Candidate route-only gain. Desired speed and cyclic magnitude remain bounded
|
||||
// exactly as in the short-translation controller; landing keeps its old gain.
|
||||
static vector Demand(vector target, vector position, vector velocity)
|
||||
{
|
||||
vector error = target - position; error[1] = 0;
|
||||
vector desired = error * 0.25;
|
||||
float speed = desired.Length();
|
||||
if (speed > 0.5) desired = desired * (0.5 / speed);
|
||||
velocity[1] = 0;
|
||||
vector demand = (desired - velocity) * 0.10;
|
||||
float magnitude = demand.Length();
|
||||
if (magnitude > 0.03) demand = demand * (0.03 / magnitude);
|
||||
return demand;
|
||||
}
|
||||
static vector Nearest(vector start, vector end, vector point)
|
||||
{
|
||||
vector leg = end - start; leg[1] = 0;
|
||||
|
||||
@@ -106,7 +106,9 @@ override void PrepareActions(CharacterControllerComponent controller, IEntity ow
|
||||
if (!m_Route) { Fail("immutable route unavailable"); return; }
|
||||
vector target = m_Route.Destination(); if (m_State == ERR_AircraftFlightState.LANDING) target = m_LandingPoint;
|
||||
vector transform[4]; m_Aircraft.GetWorldTransform(transform);
|
||||
vector demand = ERR_AircraftTranslationRules.Demand(target, transform[3], m_Simulation.GetVelocity());
|
||||
vector demand;
|
||||
if (m_State == ERR_AircraftFlightState.TRANSLATING) demand = ERR_AircraftRouteRules.Demand(target, transform[3], m_Simulation.GetVelocity());
|
||||
else demand = ERR_AircraftTranslationRules.Demand(target, transform[3], m_Simulation.GetVelocity());
|
||||
forward = Math.Clamp(vector.Dot(demand, transform[2]), -0.03, 0.03);
|
||||
aside = Math.Clamp(vector.Dot(demand, transform[0]), -0.03, 0.03);
|
||||
if (m_State == ERR_AircraftFlightState.TRANSLATING) m_TranslationUpdates++;
|
||||
|
||||
@@ -212,8 +212,8 @@ class ERR_NativeAircraftRouteProbe
|
||||
float cross = vector.DistanceXZ(transform[3], ERR_AircraftRouteRules.Nearest(home, destination, transform[3]));
|
||||
vector target = destination; if (state == ERR_AircraftFlightState.LANDING || state == ERR_AircraftFlightState.SHUTDOWN) target = m_Flight.LandingPoint();
|
||||
vector velocity = m_Simulation.GetVelocity(); vector demand;
|
||||
if (state == ERR_AircraftFlightState.TRANSLATING || state == ERR_AircraftFlightState.LANDING)
|
||||
demand = ERR_AircraftTranslationRules.Demand(target, transform[3], velocity);
|
||||
if (state == ERR_AircraftFlightState.TRANSLATING) demand = ERR_AircraftRouteRules.Demand(target, transform[3], velocity);
|
||||
else if (state == ERR_AircraftFlightState.LANDING) demand = ERR_AircraftTranslationRules.Demand(target, transform[3], velocity);
|
||||
float forward = Math.Clamp(vector.Dot(demand, transform[2]), -0.03, 0.03);
|
||||
float aside = Math.Clamp(vector.Dot(demand, transform[0]), -0.03, 0.03);
|
||||
PrintFormat("ERR AIRCRAFT ROUTE MOTION: token=%1 position=%2 velocity=%3 along=%4 cross=%5 targetError=%6 computedDemand=%7 projectedForward=%8 projectedAside=%9", m_Flight.OrderToken(), transform[3], velocity, along, cross, vector.DistanceXZ(transform[3], target), demand, forward, aside);
|
||||
|
||||
Reference in New Issue
Block a user