diff options
Diffstat (limited to 'indra/newview/llagent.cpp')
-rw-r--r-- | indra/newview/llagent.cpp | 76 |
1 files changed, 59 insertions, 17 deletions
diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index c65bc0fa50..baf0acc94b 100644 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -108,7 +108,8 @@ const U8 AGENT_STATE_EDITING = 0x10; // Autopilot constants const F32 AUTOPILOT_HEIGHT_ADJUST_DISTANCE = 8.f; // meters const F32 AUTOPILOT_MIN_TARGET_HEIGHT_OFF_GROUND = 1.f; // meters -const F32 AUTOPILOT_MAX_TIME_NO_PROGRESS = 1.5f; // seconds +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 const F32 MAX_VELOCITY_AUTO_LAND_SQUARED = 4.f * 4.f; const F64 CHAT_AGE_FAST_RATE = 3.0; @@ -878,13 +879,12 @@ boost::signals2::connection LLAgent::addParcelChangedCallback(parcel_changed_cal } // static -void LLAgent::capabilityReceivedCallback(const LLUUID ®ion_id) +void LLAgent::capabilityReceivedCallback(const LLUUID ®ion_id, LLViewerRegion *regionp) { - LLViewerRegion* region = gAgent.getRegion(); - if (region && region->getRegionID() == region_id) + if (regionp && regionp->getRegionID() == region_id) { - region->requestSimulatorFeatures(); - LLAppViewer::instance()->updateNameLookupUrl(); + regionp->requestSimulatorFeatures(); + LLAppViewer::instance()->updateNameLookupUrl(regionp); } } @@ -935,7 +935,7 @@ void LLAgent::setRegion(LLViewerRegion *regionp) if (regionp->capabilitiesReceived()) { regionp->requestSimulatorFeatures(); - LLAppViewer::instance()->updateNameLookupUrl(); + LLAppViewer::instance()->updateNameLookupUrl(regionp); } else { @@ -961,11 +961,11 @@ void LLAgent::setRegion(LLViewerRegion *regionp) if (regionp->capabilitiesReceived()) { - LLAppViewer::instance()->updateNameLookupUrl(); + LLAppViewer::instance()->updateNameLookupUrl(regionp); } else { - regionp->setCapabilitiesReceivedCallback([](const LLUUID ®ion_id) {LLAppViewer::instance()->updateNameLookupUrl(); }); + regionp->setCapabilitiesReceivedCallback([](const LLUUID ®ion_id, LLViewerRegion* regionp) {LLAppViewer::instance()->updateNameLookupUrl(regionp); }); } } @@ -1562,6 +1562,12 @@ void LLAgent::startAutoPilotGlobal( { return; } + + if (target_global.isExactlyZero()) + { + LL_WARNS() << "Canceling attempt to start autopilot towards invalid position" << LL_ENDL; + return; + } // Are there any pending callbacks from previous auto pilot requests? if (mAutoPilotFinishedCallback) @@ -1777,7 +1783,16 @@ void LLAgent::autoPilot(F32 *delta_yaw) if (target_dist >= mAutoPilotTargetDist) { mAutoPilotNoProgressFrameCount++; - if (mAutoPilotNoProgressFrameCount > AUTOPILOT_MAX_TIME_NO_PROGRESS * gFPSClamped) + bool out_of_time = false; + if (getFlying()) + { + out_of_time = mAutoPilotNoProgressFrameCount > AUTOPILOT_MAX_TIME_NO_PROGRESS_FLY * gFPSClamped; + } + else + { + out_of_time = mAutoPilotNoProgressFrameCount > AUTOPILOT_MAX_TIME_NO_PROGRESS_WALK * gFPSClamped; + } + if (out_of_time) { stopAutoPilot(); return; @@ -1826,7 +1841,7 @@ void LLAgent::autoPilot(F32 *delta_yaw) F32 slow_distance; if (getFlying()) { - slow_distance = llmax(6.f, mAutoPilotStopDistance + 5.f); + slow_distance = llmax(8.f, mAutoPilotStopDistance + 5.f); } else { @@ -1870,14 +1885,41 @@ void LLAgent::autoPilot(F32 *delta_yaw) } else if (mAutoPilotTargetDist > mAutoPilotStopDistance) { - // walking/flying slow + // walking/flying slow + U32 movement_flag = 0; + if (at * direction > 0.9f) { - setControlFlags(AGENT_CONTROL_AT_POS); - } - else if (at * direction < -0.9f) - { - setControlFlags(AGENT_CONTROL_AT_NEG); + movement_flag = AGENT_CONTROL_AT_POS; + } + else if (at * direction < -0.9f) + { + movement_flag = AGENT_CONTROL_AT_NEG; + } + + if (getFlying()) + { + // flying is too fast and has high inertia, artificially slow it down + // Don't update flags too often, server might not react + static U64 last_time_microsec = 0; + U64 time_microsec = LLTimer::getTotalTime(); + U64 delta = time_microsec - last_time_microsec; + // fly during ~0-40 ms, stop during ~40-250 ms + if (delta > 250000) // 250ms + { + // reset even if !movement_flag + last_time_microsec = time_microsec; + } + else if (delta > 40000) // 40 ms + { + clearControlFlags(AGENT_CONTROL_AT_POS | AGENT_CONTROL_AT_POS); + movement_flag = 0; + } + } + + if (movement_flag) + { + setControlFlags(movement_flag); } } |