diff options
| author | leviathan <leviathan@lindenlab.com> | 2026-09-17 21:16:56 -0700 |
|---|---|---|
| committer | leviathan <leviathan@lindenlab.com> | 2026-10-16 13:14:38 -0700 |
| commit | bf43fb63d490de5eb10c242b4c453057aece5bcb (patch) | |
| tree | e653cf7bc8c7db663b26f1aa08b1ff5d8b2347e6 /indra/newview/llagent.cpp | |
| parent | f329b9d6e0bc659beb5a249e0ab27fc0acd9068b (diff) | |
limit distance at which 'toggle-sit' action will work #6341
Diffstat (limited to 'indra/newview/llagent.cpp')
| -rw-r--r-- | indra/newview/llagent.cpp | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index ff1f645e5f..6ec64e9c74 100644 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -113,6 +113,12 @@ const F32 AUTOPILOT_MIN_TARGET_HEIGHT_OFF_GROUND = 1.f; // meters const F32 AUTOPILOT_MAX_TIME_NO_PROGRESS_WALK = 1.5f; // seconds const F32 AUTOPILOT_MAX_TIME_NO_PROGRESS_FLY = 2.5f; // seconds. Flying is less presize, needs a bit more time +// Ground-sit requests that do not originate from a click on the ground (e.g. the +// game-control/keyboard "toggle sit" action) have no target position to check +// against, so refuse them outright when the ground below the agent is farther +// than this away, rather than snapping the agent down onto distant terrain. +const F32 MAX_SIT_ON_GROUND_DISTANCE = 30.f; // meters + const F32 MAX_VELOCITY_AUTO_LAND_SQUARED = 4.f * 4.f; const F64 CHAT_AGE_FAST_RATE = 3.0; @@ -1341,9 +1347,32 @@ LLVector3d LLAgent::getPosGlobalFromAgent(const LLVector3 &pos_agent) const return pos_agent_d + mAgentOriginGlobal; } +static void finish_sit_on_ground(bool success, void*) +{ + if (success) + { + gAgent.setFlying(false); + gAgent.clearControlFlags(AGENT_CONTROL_STAND_UP); // might have been set by autopilot + gAgent.setControlFlags(AGENT_CONTROL_SIT_ON_GROUND); + } +} + void LLAgent::sitDown() { - setControlFlags(AGENT_CONTROL_SIT_ON_GROUND); + // Sit on the ground directly beneath (or above) the agent's current position. + // Refuse if that spot is too far away, and otherwise walk/fly there first, + // rather than snapping straight down onto it (e.g. terrain far below a flying + // agent) as AGENT_CONTROL_SIT_ON_GROUND would do if sent immediately. + LLVector3d pos_global = getPositionGlobal(); + LLVector3d sit_spot_global = pos_global; + sit_spot_global.mdV[VZ] = LLWorld::getInstance()->resolveLandHeightGlobal(pos_global); + + if (dist_vec(pos_global, sit_spot_global) > MAX_SIT_ON_GROUND_DISTANCE) + { + return; + } + + startAutoPilotGlobal(sit_spot_global, "Sit", NULL, finish_sit_on_ground, NULL, 0.7f); } //----------------------------------------------------------------------------- |
