diff --git a/indra/newview/llfloaterpathfindinglinksets.cpp b/indra/newview/llfloaterpathfindinglinksets.cpp index 0cce1277b002a7546a534154cddf7423d7571fe0..78c0d342b2de42570ec17f33157df96c05838c9d 100644 --- a/indra/newview/llfloaterpathfindinglinksets.cpp +++ b/indra/newview/llfloaterpathfindinglinksets.cpp @@ -36,26 +36,29 @@ #include "llviewerregion.h" #include "llhttpclient.h" #include "lltextbase.h" +#include "lluuid.h" +#include "llviewerobject.h" +#include "llviewerobjectlist.h" //--------------------------------------------------------------------------- // NavmeshDataGetResponder //--------------------------------------------------------------------------- - -class NavmeshDataGetResponder : public LLHTTPClient::Responder -{ -public: - NavmeshDataGetResponder(const std::string& pNavmeshDataGetURL, LLFloaterPathfindingLinksets *pLinksetsFloater); - virtual ~NavmeshDataGetResponder(); - - virtual void result(const LLSD& pContent); - virtual void error(U32 pStatus, const std::string& pReason); - -private: - NavmeshDataGetResponder(const NavmeshDataGetResponder& pOther); - - std::string mNavmeshDataGetURL; - LLFloaterPathfindingLinksets *mLinksetsFloater; -}; + +class NavmeshDataGetResponder : public LLHTTPClient::Responder +{ +public: + NavmeshDataGetResponder(const std::string& pNavmeshDataGetURL, LLFloaterPathfindingLinksets *pLinksetsFloater); + virtual ~NavmeshDataGetResponder(); + + virtual void result(const LLSD& pContent); + virtual void error(U32 pStatus, const std::string& pReason); + +private: + NavmeshDataGetResponder(const NavmeshDataGetResponder& pOther); + + std::string mNavmeshDataGetURL; + LLFloaterPathfindingLinksets *mLinksetsFloater; +}; //--------------------------------------------------------------------------- // LLFloaterPathfindingLinksets @@ -90,10 +93,10 @@ void LLFloaterPathfindingLinksets::openLinksetsEditor() LLFloaterReg::toggleInstanceOrBringToFront("pathfinding_linksets"); } -LLFloaterPathfindingLinksets::EFetchState LLFloaterPathfindingLinksets::getFetchState() const -{ - return mFetchState; -} +LLFloaterPathfindingLinksets::EFetchState LLFloaterPathfindingLinksets::getFetchState() const +{ + return mFetchState; +} BOOL LLFloaterPathfindingLinksets::isFetchInProgress() const { @@ -140,22 +143,22 @@ void LLFloaterPathfindingLinksets::sendNavmeshDataGetRequest() setFetchState(kFetchStarting); clearLinksetsList(); - LLViewerRegion* region = gAgent.getRegion(); - if (region != NULL) - { - std::string navmeshDataURL = region->getCapability("ObjectNavmesh"); - if (navmeshDataURL.empty()) - { + LLViewerRegion* region = gAgent.getRegion(); + if (region != NULL) + { + std::string navmeshDataURL = region->getCapability("ObjectNavmesh"); + if (navmeshDataURL.empty()) + { setFetchState(kFetchComplete); - llwarns << "cannot query navmesh data from current region '" << region->getName() << "'" << llendl; - } - else - { + llwarns << "cannot query navmesh data from current region '" << region->getName() << "'" << llendl; + } + else + { setFetchState(kFetchInProgress); - LLHTTPClient::get(navmeshDataURL, new NavmeshDataGetResponder(navmeshDataURL, this)); - } - } - } + LLHTTPClient::get(navmeshDataURL, new NavmeshDataGetResponder(navmeshDataURL, this)); + } + } + } } void LLFloaterPathfindingLinksets::handleNavmeshDataGetReply(const LLSD& pNavmeshData) @@ -168,7 +171,7 @@ void LLFloaterPathfindingLinksets::handleNavmeshDataGetReply(const LLSD& pNavmes for (LLSD::map_const_iterator itemsIter = pNavmeshData.beginMap(); itemsIter != pNavmeshData.endMap(); ++itemsIter) { - const std::string& uuid = itemsIter->first; + LLUUID uuid(itemsIter->first); const LLSD& itemData = itemsIter->second; const LLSD::String& itemName = itemData.get("name").asString(); @@ -182,9 +185,16 @@ void LLFloaterPathfindingLinksets::handleNavmeshDataGetReply(const LLSD& pNavmes LLSD::Real itemC = itemData.get("C").asReal(); LLSD::Real itemD = itemData.get("D").asReal(); - F32 location_x = 50.0f, location_y = 50.0f, location_z = 50.0f; // XXX stinson: use real location later - LLVector3 itemLocation(location_x, location_y, location_z); - F32 itemDistance = dist_vec(avatarPosition, itemLocation); + // XXX stinson: get a better way to get all objects locations in the region as the + // following calculation only returns objects of which the viewer is aware. + LLViewerObject *viewerObject = gObjectList.findObject(uuid); + bool hasDistance = (viewerObject != NULL); + F32 itemDistance = -999.0f; + if (hasDistance) + { + const LLVector3& itemLocation = viewerObject->getPositionAgent(); + itemDistance = dist_vec(avatarPosition, itemLocation); + } LLSD columns; @@ -197,11 +207,18 @@ void LLFloaterPathfindingLinksets::handleNavmeshDataGetReply(const LLSD& pNavmes columns[1]["font"] = "SANSSERIF"; columns[2]["column"] = "land_impact"; - columns[2]["value"] = llformat("%1d m", itemLandImpact); + columns[2]["value"] = llformat("%1d", itemLandImpact); columns[2]["font"] = "SANSSERIF"; columns[3]["column"] = "dist_from_you"; - columns[3]["value"] = llformat("%1.0f m", itemDistance); + if (hasDistance) + { + columns[3]["value"] = llformat("%1.0f m", itemDistance); + } + else + { + columns[3]["value"] = "--"; + } columns[3]["font"] = "SANSSERIF"; columns[4]["column"] = "is_fixed"; @@ -242,18 +259,18 @@ void LLFloaterPathfindingLinksets::handleNavmeshDataGetReply(const LLSD& pNavmes setFetchState(kFetchComplete); } -void LLFloaterPathfindingLinksets::handleNavmeshDataGetError(const std::string& pURL, const std::string& pErrorReason) -{ +void LLFloaterPathfindingLinksets::handleNavmeshDataGetError(const std::string& pURL, const std::string& pErrorReason) +{ setFetchState(kFetchError); clearLinksetsList(); - llwarns << "Error fetching navmesh data from URL '" << pURL << "' because " << pErrorReason << llendl; -} - -void LLFloaterPathfindingLinksets::setFetchState(EFetchState pFetchState) -{ - mFetchState = pFetchState; - updateLinksetsStatusMessage(); -} + llwarns << "Error fetching navmesh data from URL '" << pURL << "' because " << pErrorReason << llendl; +} + +void LLFloaterPathfindingLinksets::setFetchState(EFetchState pFetchState) +{ + mFetchState = pFetchState; + updateLinksetsStatusMessage(); +} void LLFloaterPathfindingLinksets::onLinksetsSelectionChange() { @@ -347,8 +364,8 @@ void LLFloaterPathfindingLinksets::updateLinksetsStatusMessage() mLinksetsStatus->setText((LLStringExplicit)statusText, styleParams); } - -NavmeshDataGetResponder::NavmeshDataGetResponder(const std::string& pNavmeshDataGetURL, LLFloaterPathfindingLinksets *pLinksetsFloater) + +NavmeshDataGetResponder::NavmeshDataGetResponder(const std::string& pNavmeshDataGetURL, LLFloaterPathfindingLinksets *pLinksetsFloater) : mNavmeshDataGetURL(pNavmeshDataGetURL), mLinksetsFloater(pLinksetsFloater) { diff --git a/indra/newview/llfloaterpathfindinglinksets.h b/indra/newview/llfloaterpathfindinglinksets.h index 9a54468d58e023afc2f3c21452b12ab3fefd91ea..66472beb995754fb4d5bb85e7039bed28926f411 100644 --- a/indra/newview/llfloaterpathfindinglinksets.h +++ b/indra/newview/llfloaterpathfindinglinksets.h @@ -1,45 +1,45 @@ -/** - * @file llfloaterpathfindinglinksets.h - * @author William Todd Stinson - * @brief "Pathfinding linksets" floater, allowing manipulation of the Havok AI pathfinding settings. - * - * $LicenseInfo:firstyear=2002&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$ - */ - -#ifndef LL_LLFLOATERPATHFINDINGLINKSETS_H -#define LL_LLFLOATERPATHFINDINGLINKSETS_H - -#include "llfloater.h" - -class LLSD; -class LLTextBase; -class LLScrollListCtrl; - -class LLFloaterPathfindingLinksets -: public LLFloater -{ - friend class LLFloaterReg; - friend class NavmeshDataGetResponder; - +/** + * @file llfloaterpathfindinglinksets.h + * @author William Todd Stinson + * @brief "Pathfinding linksets" floater, allowing manipulation of the Havok AI pathfinding settings. + * + * $LicenseInfo:firstyear=2002&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$ + */ + +#ifndef LL_LLFLOATERPATHFINDINGLINKSETS_H +#define LL_LLFLOATERPATHFINDINGLINKSETS_H + +#include "llfloater.h" + +class LLSD; +class LLTextBase; +class LLScrollListCtrl; + +class LLFloaterPathfindingLinksets +: public LLFloater +{ + friend class LLFloaterReg; + friend class NavmeshDataGetResponder; + typedef enum { kFetchInitial, @@ -50,44 +50,44 @@ class LLFloaterPathfindingLinksets kFetchError, kFetchComplete } EFetchState; - -public: - virtual BOOL postBuild(); - virtual void onOpen(const LLSD& pKey); - - static void openLinksetsEditor(); - - EFetchState getFetchState() const; - BOOL isFetchInProgress() const; - -protected: - -private: - EFetchState mFetchState; - LLScrollListCtrl *mLinksetsScrollList; - LLTextBase *mLinksetsStatus; - - // Does its own instance management, so clients not allowed - // to allocate or destroy. - LLFloaterPathfindingLinksets(const LLSD& pSeed); - virtual ~LLFloaterPathfindingLinksets(); - - void sendNavmeshDataGetRequest(); - void handleNavmeshDataGetReply(const LLSD& pNavmeshData); - void handleNavmeshDataGetError(const std::string& pURL, const std::string& pErrorReason); - - void setFetchState(EFetchState pFetchState); - - void onLinksetsSelectionChange(); - void onRefreshLinksetsClicked(); - void onSelectAllLinksetsClicked(); - void onSelectNoneLinksetsClicked(); - - void clearLinksetsList(); - void selectAllLinksets(); - void selectNoneLinksets(); - - void updateLinksetsStatusMessage(); -}; - -#endif // LL_LLFLOATERPATHFINDINGLINKSETS_H + +public: + virtual BOOL postBuild(); + virtual void onOpen(const LLSD& pKey); + + static void openLinksetsEditor(); + + EFetchState getFetchState() const; + BOOL isFetchInProgress() const; + +protected: + +private: + EFetchState mFetchState; + LLScrollListCtrl *mLinksetsScrollList; + LLTextBase *mLinksetsStatus; + + // Does its own instance management, so clients not allowed + // to allocate or destroy. + LLFloaterPathfindingLinksets(const LLSD& pSeed); + virtual ~LLFloaterPathfindingLinksets(); + + void sendNavmeshDataGetRequest(); + void handleNavmeshDataGetReply(const LLSD& pNavmeshData); + void handleNavmeshDataGetError(const std::string& pURL, const std::string& pErrorReason); + + void setFetchState(EFetchState pFetchState); + + void onLinksetsSelectionChange(); + void onRefreshLinksetsClicked(); + void onSelectAllLinksetsClicked(); + void onSelectNoneLinksetsClicked(); + + void clearLinksetsList(); + void selectAllLinksets(); + void selectNoneLinksets(); + + void updateLinksetsStatusMessage(); +}; + +#endif // LL_LLFLOATERPATHFINDINGLINKSETS_H