summaryrefslogtreecommitdiff
path: root/indra/newview/llagentui.cpp
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2024-05-22 20:51:58 +0300
committerGitHub <noreply@github.com>2024-05-22 20:51:58 +0300
commit6cc7dd09d5e69cf57e6de7fb568a0ad2693f9c9a (patch)
treefab23811a5cedc1ebf01479c852ee92ff62b636c /indra/newview/llagentui.cpp
parentef8f4819822288e044ea719feb6af7a1f4df4c4e (diff)
parent7bb5afc11ee5a6af78302a8d76a9a619e2baaab2 (diff)
Merge pull request #1545 from Ansariel/DRTVWR-600-maint-A
Merge main into DRTVWR-600-maint-a
Diffstat (limited to 'indra/newview/llagentui.cpp')
-rw-r--r--indra/newview/llagentui.cpp388
1 files changed, 194 insertions, 194 deletions
diff --git a/indra/newview/llagentui.cpp b/indra/newview/llagentui.cpp
index 5e1e4c5272..ab71e70a8a 100644
--- a/indra/newview/llagentui.cpp
+++ b/indra/newview/llagentui.cpp
@@ -1,194 +1,194 @@
-/**
- * @file llagentui.cpp
- * @brief Utility methods to process agent's data as slurl's etc. before displaying
- *
- * $LicenseInfo:firstyear=2009&license=viewerlgpl$
- * Second Life Viewer Source Code
- * Copyright (C) 2010, Linden Research, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation;
- * version 2.1 of the License only.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
- * $/LicenseInfo$
- */
-
-#include "llviewerprecompiledheaders.h"
-
-#include "llagentui.h"
-
-// Library includes
-#include "llparcel.h"
-
-// Viewer includes
-#include "llagent.h"
-#include "llviewercontrol.h"
-#include "llviewerregion.h"
-#include "llviewerparcelmgr.h"
-#include "llvoavatarself.h"
-#include "llslurl.h"
-
-//static
-void LLAgentUI::buildFullname(std::string& name)
-{
- if (isAgentAvatarValid())
- name = gAgentAvatarp->getFullname();
-}
-
-//static
-void LLAgentUI::buildSLURL(LLSLURL& slurl, const bool escaped /*= true*/)
-{
- LLSLURL return_slurl;
- LLViewerRegion *regionp = gAgent.getRegion();
- if (regionp)
- {
- // Make sure coordinates are within current region
- LLVector3d global_pos = gAgent.getPositionGlobal();
- LLVector3d region_origin = regionp->getOriginGlobal();
- // -1 otherwise slurl will fmod 256 to 0.
- // And valid slurl range is supposed to be 0..255
- F64 max_val = REGION_WIDTH_METERS - 1;
- global_pos.mdV[VX] = llclamp(global_pos[VX], region_origin[VX], region_origin[VX] + max_val);
- global_pos.mdV[VY] = llclamp(global_pos[VY], region_origin[VY], region_origin[VY] + max_val);
-
- return_slurl = LLSLURL(regionp->getName(), global_pos);
- }
- slurl = return_slurl;
-}
-
-//static
-bool LLAgentUI::checkAgentDistance(const LLVector3& pole, F32 radius)
-{
- F32 delta_x = gAgent.getPositionAgent().mV[VX] - pole.mV[VX];
- F32 delta_y = gAgent.getPositionAgent().mV[VY] - pole.mV[VY];
-
- return sqrt( delta_x* delta_x + delta_y* delta_y ) < radius;
-}
-bool LLAgentUI::buildLocationString(std::string& str, ELocationFormat fmt,const LLVector3& agent_pos_region)
-{
- LLViewerRegion* region = gAgent.getRegion();
- LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
-
- if (!region || !parcel) return false;
-
- S32 pos_x = S32(agent_pos_region.mV[VX] + 0.5f);
- S32 pos_y = S32(agent_pos_region.mV[VY] + 0.5f);
- S32 pos_z = S32(agent_pos_region.mV[VZ] + 0.5f);
-
- // Round the numbers based on the velocity
- F32 velocity_mag_sq = gAgent.getVelocity().magVecSquared();
-
- const F32 FLY_CUTOFF = 6.f; // meters/sec
- const F32 FLY_CUTOFF_SQ = FLY_CUTOFF * FLY_CUTOFF;
- const F32 WALK_CUTOFF = 1.5f; // meters/sec
- const F32 WALK_CUTOFF_SQ = WALK_CUTOFF * WALK_CUTOFF;
-
- if (velocity_mag_sq > FLY_CUTOFF_SQ)
- {
- pos_x -= pos_x % 4;
- pos_y -= pos_y % 4;
- }
- else if (velocity_mag_sq > WALK_CUTOFF_SQ)
- {
- pos_x -= pos_x % 2;
- pos_y -= pos_y % 2;
- }
-
- // create a default name and description for the landmark
- std::string parcel_name = LLViewerParcelMgr::getInstance()->getAgentParcelName();
- std::string region_name = region->getName();
- std::string sim_access_string = region->getSimAccessString();
- std::string buffer;
- if( parcel_name.empty() )
- {
- // the parcel doesn't have a name
- switch (fmt)
- {
- case LOCATION_FORMAT_LANDMARK:
- buffer = llformat("%.100s", region_name.c_str());
- break;
- case LOCATION_FORMAT_NORMAL:
- buffer = llformat("%s", region_name.c_str());
- break;
- case LOCATION_FORMAT_NORMAL_COORDS:
- buffer = llformat("%s (%d, %d, %d)",
- region_name.c_str(),
- pos_x, pos_y, pos_z);
- break;
- case LOCATION_FORMAT_NO_COORDS:
- buffer = llformat("%s%s%s",
- region_name.c_str(),
- sim_access_string.empty() ? "" : " - ",
- sim_access_string.c_str());
- break;
- case LOCATION_FORMAT_NO_MATURITY:
- buffer = llformat("%s (%d, %d, %d)",
- region_name.c_str(),
- pos_x, pos_y, pos_z);
- break;
- case LOCATION_FORMAT_FULL:
- buffer = llformat("%s (%d, %d, %d)%s%s",
- region_name.c_str(),
- pos_x, pos_y, pos_z,
- sim_access_string.empty() ? "" : " - ",
- sim_access_string.c_str());
- break;
- }
- }
- else
- {
- // the parcel has a name, so include it in the landmark name
- switch (fmt)
- {
- case LOCATION_FORMAT_LANDMARK:
- buffer = llformat("%.100s", parcel_name.c_str());
- break;
- case LOCATION_FORMAT_NORMAL:
- buffer = llformat("%s, %s", parcel_name.c_str(), region_name.c_str());
- break;
- case LOCATION_FORMAT_NORMAL_COORDS:
- buffer = llformat("%s (%d, %d, %d)",
- parcel_name.c_str(),
- pos_x, pos_y, pos_z);
- break;
- case LOCATION_FORMAT_NO_MATURITY:
- buffer = llformat("%s, %s (%d, %d, %d)",
- parcel_name.c_str(),
- region_name.c_str(),
- pos_x, pos_y, pos_z);
- break;
- case LOCATION_FORMAT_NO_COORDS:
- buffer = llformat("%s, %s%s%s",
- parcel_name.c_str(),
- region_name.c_str(),
- sim_access_string.empty() ? "" : " - ",
- sim_access_string.c_str());
- break;
- case LOCATION_FORMAT_FULL:
- buffer = llformat("%s, %s (%d, %d, %d)%s%s",
- parcel_name.c_str(),
- region_name.c_str(),
- pos_x, pos_y, pos_z,
- sim_access_string.empty() ? "" : " - ",
- sim_access_string.c_str());
- break;
- }
- }
- str = buffer;
- return true;
-}
-bool LLAgentUI::buildLocationString(std::string& str, ELocationFormat fmt)
-{
- return buildLocationString(str,fmt, gAgent.getPositionAgent());
-}
+/**
+ * @file llagentui.cpp
+ * @brief Utility methods to process agent's data as slurl's etc. before displaying
+ *
+ * $LicenseInfo:firstyear=2009&license=viewerlgpl$
+ * Second Life Viewer Source Code
+ * Copyright (C) 2010, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
+ * $/LicenseInfo$
+ */
+
+#include "llviewerprecompiledheaders.h"
+
+#include "llagentui.h"
+
+// Library includes
+#include "llparcel.h"
+
+// Viewer includes
+#include "llagent.h"
+#include "llviewercontrol.h"
+#include "llviewerregion.h"
+#include "llviewerparcelmgr.h"
+#include "llvoavatarself.h"
+#include "llslurl.h"
+
+//static
+void LLAgentUI::buildFullname(std::string& name)
+{
+ if (isAgentAvatarValid())
+ name = gAgentAvatarp->getFullname();
+}
+
+//static
+void LLAgentUI::buildSLURL(LLSLURL& slurl, const bool escaped /*= true*/)
+{
+ LLSLURL return_slurl;
+ LLViewerRegion *regionp = gAgent.getRegion();
+ if (regionp)
+ {
+ // Make sure coordinates are within current region
+ LLVector3d global_pos = gAgent.getPositionGlobal();
+ LLVector3d region_origin = regionp->getOriginGlobal();
+ // -1 otherwise slurl will fmod 256 to 0.
+ // And valid slurl range is supposed to be 0..255
+ F64 max_val = REGION_WIDTH_METERS - 1;
+ global_pos.mdV[VX] = llclamp(global_pos[VX], region_origin[VX], region_origin[VX] + max_val);
+ global_pos.mdV[VY] = llclamp(global_pos[VY], region_origin[VY], region_origin[VY] + max_val);
+
+ return_slurl = LLSLURL(regionp->getName(), global_pos);
+ }
+ slurl = return_slurl;
+}
+
+//static
+bool LLAgentUI::checkAgentDistance(const LLVector3& pole, F32 radius)
+{
+ F32 delta_x = gAgent.getPositionAgent().mV[VX] - pole.mV[VX];
+ F32 delta_y = gAgent.getPositionAgent().mV[VY] - pole.mV[VY];
+
+ return sqrt( delta_x* delta_x + delta_y* delta_y ) < radius;
+}
+bool LLAgentUI::buildLocationString(std::string& str, ELocationFormat fmt,const LLVector3& agent_pos_region)
+{
+ LLViewerRegion* region = gAgent.getRegion();
+ LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
+
+ if (!region || !parcel) return false;
+
+ S32 pos_x = S32(agent_pos_region.mV[VX] + 0.5f);
+ S32 pos_y = S32(agent_pos_region.mV[VY] + 0.5f);
+ S32 pos_z = S32(agent_pos_region.mV[VZ] + 0.5f);
+
+ // Round the numbers based on the velocity
+ F32 velocity_mag_sq = gAgent.getVelocity().magVecSquared();
+
+ const F32 FLY_CUTOFF = 6.f; // meters/sec
+ const F32 FLY_CUTOFF_SQ = FLY_CUTOFF * FLY_CUTOFF;
+ const F32 WALK_CUTOFF = 1.5f; // meters/sec
+ const F32 WALK_CUTOFF_SQ = WALK_CUTOFF * WALK_CUTOFF;
+
+ if (velocity_mag_sq > FLY_CUTOFF_SQ)
+ {
+ pos_x -= pos_x % 4;
+ pos_y -= pos_y % 4;
+ }
+ else if (velocity_mag_sq > WALK_CUTOFF_SQ)
+ {
+ pos_x -= pos_x % 2;
+ pos_y -= pos_y % 2;
+ }
+
+ // create a default name and description for the landmark
+ std::string parcel_name = LLViewerParcelMgr::getInstance()->getAgentParcelName();
+ std::string region_name = region->getName();
+ std::string sim_access_string = region->getSimAccessString();
+ std::string buffer;
+ if( parcel_name.empty() )
+ {
+ // the parcel doesn't have a name
+ switch (fmt)
+ {
+ case LOCATION_FORMAT_LANDMARK:
+ buffer = llformat("%.100s", region_name.c_str());
+ break;
+ case LOCATION_FORMAT_NORMAL:
+ buffer = llformat("%s", region_name.c_str());
+ break;
+ case LOCATION_FORMAT_NORMAL_COORDS:
+ buffer = llformat("%s (%d, %d, %d)",
+ region_name.c_str(),
+ pos_x, pos_y, pos_z);
+ break;
+ case LOCATION_FORMAT_NO_COORDS:
+ buffer = llformat("%s%s%s",
+ region_name.c_str(),
+ sim_access_string.empty() ? "" : " - ",
+ sim_access_string.c_str());
+ break;
+ case LOCATION_FORMAT_NO_MATURITY:
+ buffer = llformat("%s (%d, %d, %d)",
+ region_name.c_str(),
+ pos_x, pos_y, pos_z);
+ break;
+ case LOCATION_FORMAT_FULL:
+ buffer = llformat("%s (%d, %d, %d)%s%s",
+ region_name.c_str(),
+ pos_x, pos_y, pos_z,
+ sim_access_string.empty() ? "" : " - ",
+ sim_access_string.c_str());
+ break;
+ }
+ }
+ else
+ {
+ // the parcel has a name, so include it in the landmark name
+ switch (fmt)
+ {
+ case LOCATION_FORMAT_LANDMARK:
+ buffer = llformat("%.100s", parcel_name.c_str());
+ break;
+ case LOCATION_FORMAT_NORMAL:
+ buffer = llformat("%s, %s", parcel_name.c_str(), region_name.c_str());
+ break;
+ case LOCATION_FORMAT_NORMAL_COORDS:
+ buffer = llformat("%s (%d, %d, %d)",
+ parcel_name.c_str(),
+ pos_x, pos_y, pos_z);
+ break;
+ case LOCATION_FORMAT_NO_MATURITY:
+ buffer = llformat("%s, %s (%d, %d, %d)",
+ parcel_name.c_str(),
+ region_name.c_str(),
+ pos_x, pos_y, pos_z);
+ break;
+ case LOCATION_FORMAT_NO_COORDS:
+ buffer = llformat("%s, %s%s%s",
+ parcel_name.c_str(),
+ region_name.c_str(),
+ sim_access_string.empty() ? "" : " - ",
+ sim_access_string.c_str());
+ break;
+ case LOCATION_FORMAT_FULL:
+ buffer = llformat("%s, %s (%d, %d, %d)%s%s",
+ parcel_name.c_str(),
+ region_name.c_str(),
+ pos_x, pos_y, pos_z,
+ sim_access_string.empty() ? "" : " - ",
+ sim_access_string.c_str());
+ break;
+ }
+ }
+ str = buffer;
+ return true;
+}
+bool LLAgentUI::buildLocationString(std::string& str, ELocationFormat fmt)
+{
+ return buildLocationString(str,fmt, gAgent.getPositionAgent());
+}