Skip to content
Snippets Groups Projects
Commit f36b2612 authored by Todd Stinson's avatar Todd Stinson
Browse files

PATH-142: Implementing some basic distance from viewer calculation per...

PATH-142: Implementing some basic distance from viewer calculation per linksets.  Note that this does not return all distances because some objects are in the region but the viewer is not aware of yet.
parent ebeddd7f
No related branches found
No related tags found
No related merge requests found
...@@ -36,26 +36,29 @@ ...@@ -36,26 +36,29 @@
#include "llviewerregion.h" #include "llviewerregion.h"
#include "llhttpclient.h" #include "llhttpclient.h"
#include "lltextbase.h" #include "lltextbase.h"
#include "lluuid.h"
#include "llviewerobject.h"
#include "llviewerobjectlist.h"
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// NavmeshDataGetResponder // NavmeshDataGetResponder
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
class NavmeshDataGetResponder : public LLHTTPClient::Responder class NavmeshDataGetResponder : public LLHTTPClient::Responder
{ {
public: public:
NavmeshDataGetResponder(const std::string& pNavmeshDataGetURL, LLFloaterPathfindingLinksets *pLinksetsFloater); NavmeshDataGetResponder(const std::string& pNavmeshDataGetURL, LLFloaterPathfindingLinksets *pLinksetsFloater);
virtual ~NavmeshDataGetResponder(); virtual ~NavmeshDataGetResponder();
virtual void result(const LLSD& pContent); virtual void result(const LLSD& pContent);
virtual void error(U32 pStatus, const std::string& pReason); virtual void error(U32 pStatus, const std::string& pReason);
private: private:
NavmeshDataGetResponder(const NavmeshDataGetResponder& pOther); NavmeshDataGetResponder(const NavmeshDataGetResponder& pOther);
std::string mNavmeshDataGetURL; std::string mNavmeshDataGetURL;
LLFloaterPathfindingLinksets *mLinksetsFloater; LLFloaterPathfindingLinksets *mLinksetsFloater;
}; };
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// LLFloaterPathfindingLinksets // LLFloaterPathfindingLinksets
...@@ -90,10 +93,10 @@ void LLFloaterPathfindingLinksets::openLinksetsEditor() ...@@ -90,10 +93,10 @@ void LLFloaterPathfindingLinksets::openLinksetsEditor()
LLFloaterReg::toggleInstanceOrBringToFront("pathfinding_linksets"); LLFloaterReg::toggleInstanceOrBringToFront("pathfinding_linksets");
} }
LLFloaterPathfindingLinksets::EFetchState LLFloaterPathfindingLinksets::getFetchState() const LLFloaterPathfindingLinksets::EFetchState LLFloaterPathfindingLinksets::getFetchState() const
{ {
return mFetchState; return mFetchState;
} }
BOOL LLFloaterPathfindingLinksets::isFetchInProgress() const BOOL LLFloaterPathfindingLinksets::isFetchInProgress() const
{ {
...@@ -140,22 +143,22 @@ void LLFloaterPathfindingLinksets::sendNavmeshDataGetRequest() ...@@ -140,22 +143,22 @@ void LLFloaterPathfindingLinksets::sendNavmeshDataGetRequest()
setFetchState(kFetchStarting); setFetchState(kFetchStarting);
clearLinksetsList(); clearLinksetsList();
LLViewerRegion* region = gAgent.getRegion(); LLViewerRegion* region = gAgent.getRegion();
if (region != NULL) if (region != NULL)
{ {
std::string navmeshDataURL = region->getCapability("ObjectNavmesh"); std::string navmeshDataURL = region->getCapability("ObjectNavmesh");
if (navmeshDataURL.empty()) if (navmeshDataURL.empty())
{ {
setFetchState(kFetchComplete); setFetchState(kFetchComplete);
llwarns << "cannot query navmesh data from current region '" << region->getName() << "'" << llendl; llwarns << "cannot query navmesh data from current region '" << region->getName() << "'" << llendl;
} }
else else
{ {
setFetchState(kFetchInProgress); setFetchState(kFetchInProgress);
LLHTTPClient::get(navmeshDataURL, new NavmeshDataGetResponder(navmeshDataURL, this)); LLHTTPClient::get(navmeshDataURL, new NavmeshDataGetResponder(navmeshDataURL, this));
} }
} }
} }
} }
void LLFloaterPathfindingLinksets::handleNavmeshDataGetReply(const LLSD& pNavmeshData) void LLFloaterPathfindingLinksets::handleNavmeshDataGetReply(const LLSD& pNavmeshData)
...@@ -168,7 +171,7 @@ void LLFloaterPathfindingLinksets::handleNavmeshDataGetReply(const LLSD& pNavmes ...@@ -168,7 +171,7 @@ void LLFloaterPathfindingLinksets::handleNavmeshDataGetReply(const LLSD& pNavmes
for (LLSD::map_const_iterator itemsIter = pNavmeshData.beginMap(); for (LLSD::map_const_iterator itemsIter = pNavmeshData.beginMap();
itemsIter != pNavmeshData.endMap(); ++itemsIter) itemsIter != pNavmeshData.endMap(); ++itemsIter)
{ {
const std::string& uuid = itemsIter->first; LLUUID uuid(itemsIter->first);
const LLSD& itemData = itemsIter->second; const LLSD& itemData = itemsIter->second;
const LLSD::String& itemName = itemData.get("name").asString(); const LLSD::String& itemName = itemData.get("name").asString();
...@@ -182,9 +185,16 @@ void LLFloaterPathfindingLinksets::handleNavmeshDataGetReply(const LLSD& pNavmes ...@@ -182,9 +185,16 @@ void LLFloaterPathfindingLinksets::handleNavmeshDataGetReply(const LLSD& pNavmes
LLSD::Real itemC = itemData.get("C").asReal(); LLSD::Real itemC = itemData.get("C").asReal();
LLSD::Real itemD = itemData.get("D").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 // XXX stinson: get a better way to get all objects locations in the region as the
LLVector3 itemLocation(location_x, location_y, location_z); // following calculation only returns objects of which the viewer is aware.
F32 itemDistance = dist_vec(avatarPosition, itemLocation); 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; LLSD columns;
...@@ -197,11 +207,18 @@ void LLFloaterPathfindingLinksets::handleNavmeshDataGetReply(const LLSD& pNavmes ...@@ -197,11 +207,18 @@ void LLFloaterPathfindingLinksets::handleNavmeshDataGetReply(const LLSD& pNavmes
columns[1]["font"] = "SANSSERIF"; columns[1]["font"] = "SANSSERIF";
columns[2]["column"] = "land_impact"; columns[2]["column"] = "land_impact";
columns[2]["value"] = llformat("%1d m", itemLandImpact); columns[2]["value"] = llformat("%1d", itemLandImpact);
columns[2]["font"] = "SANSSERIF"; columns[2]["font"] = "SANSSERIF";
columns[3]["column"] = "dist_from_you"; 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[3]["font"] = "SANSSERIF";
columns[4]["column"] = "is_fixed"; columns[4]["column"] = "is_fixed";
...@@ -242,18 +259,18 @@ void LLFloaterPathfindingLinksets::handleNavmeshDataGetReply(const LLSD& pNavmes ...@@ -242,18 +259,18 @@ void LLFloaterPathfindingLinksets::handleNavmeshDataGetReply(const LLSD& pNavmes
setFetchState(kFetchComplete); 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); setFetchState(kFetchError);
clearLinksetsList(); clearLinksetsList();
llwarns << "Error fetching navmesh data from URL '" << pURL << "' because " << pErrorReason << llendl; llwarns << "Error fetching navmesh data from URL '" << pURL << "' because " << pErrorReason << llendl;
} }
void LLFloaterPathfindingLinksets::setFetchState(EFetchState pFetchState) void LLFloaterPathfindingLinksets::setFetchState(EFetchState pFetchState)
{ {
mFetchState = pFetchState; mFetchState = pFetchState;
updateLinksetsStatusMessage(); updateLinksetsStatusMessage();
} }
void LLFloaterPathfindingLinksets::onLinksetsSelectionChange() void LLFloaterPathfindingLinksets::onLinksetsSelectionChange()
{ {
...@@ -347,8 +364,8 @@ void LLFloaterPathfindingLinksets::updateLinksetsStatusMessage() ...@@ -347,8 +364,8 @@ void LLFloaterPathfindingLinksets::updateLinksetsStatusMessage()
mLinksetsStatus->setText((LLStringExplicit)statusText, styleParams); mLinksetsStatus->setText((LLStringExplicit)statusText, styleParams);
} }
NavmeshDataGetResponder::NavmeshDataGetResponder(const std::string& pNavmeshDataGetURL, LLFloaterPathfindingLinksets *pLinksetsFloater) NavmeshDataGetResponder::NavmeshDataGetResponder(const std::string& pNavmeshDataGetURL, LLFloaterPathfindingLinksets *pLinksetsFloater)
: mNavmeshDataGetURL(pNavmeshDataGetURL), : mNavmeshDataGetURL(pNavmeshDataGetURL),
mLinksetsFloater(pLinksetsFloater) mLinksetsFloater(pLinksetsFloater)
{ {
......
/** /**
* @file llfloaterpathfindinglinksets.h * @file llfloaterpathfindinglinksets.h
* @author William Todd Stinson * @author William Todd Stinson
* @brief "Pathfinding linksets" floater, allowing manipulation of the Havok AI pathfinding settings. * @brief "Pathfinding linksets" floater, allowing manipulation of the Havok AI pathfinding settings.
* *
* $LicenseInfo:firstyear=2002&license=viewerlgpl$ * $LicenseInfo:firstyear=2002&license=viewerlgpl$
* Second Life Viewer Source Code * Second Life Viewer Source Code
* Copyright (C) 2010, Linden Research, Inc. * Copyright (C) 2010, Linden Research, Inc.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; * License as published by the Free Software Foundation;
* version 2.1 of the License only. * version 2.1 of the License only.
* *
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$ * $/LicenseInfo$
*/ */
#ifndef LL_LLFLOATERPATHFINDINGLINKSETS_H #ifndef LL_LLFLOATERPATHFINDINGLINKSETS_H
#define LL_LLFLOATERPATHFINDINGLINKSETS_H #define LL_LLFLOATERPATHFINDINGLINKSETS_H
#include "llfloater.h" #include "llfloater.h"
class LLSD; class LLSD;
class LLTextBase; class LLTextBase;
class LLScrollListCtrl; class LLScrollListCtrl;
class LLFloaterPathfindingLinksets class LLFloaterPathfindingLinksets
: public LLFloater : public LLFloater
{ {
friend class LLFloaterReg; friend class LLFloaterReg;
friend class NavmeshDataGetResponder; friend class NavmeshDataGetResponder;
typedef enum typedef enum
{ {
kFetchInitial, kFetchInitial,
...@@ -50,44 +50,44 @@ class LLFloaterPathfindingLinksets ...@@ -50,44 +50,44 @@ class LLFloaterPathfindingLinksets
kFetchError, kFetchError,
kFetchComplete kFetchComplete
} EFetchState; } EFetchState;
public: public:
virtual BOOL postBuild(); virtual BOOL postBuild();
virtual void onOpen(const LLSD& pKey); virtual void onOpen(const LLSD& pKey);
static void openLinksetsEditor(); static void openLinksetsEditor();
EFetchState getFetchState() const; EFetchState getFetchState() const;
BOOL isFetchInProgress() const; BOOL isFetchInProgress() const;
protected: protected:
private: private:
EFetchState mFetchState; EFetchState mFetchState;
LLScrollListCtrl *mLinksetsScrollList; LLScrollListCtrl *mLinksetsScrollList;
LLTextBase *mLinksetsStatus; LLTextBase *mLinksetsStatus;
// Does its own instance management, so clients not allowed // Does its own instance management, so clients not allowed
// to allocate or destroy. // to allocate or destroy.
LLFloaterPathfindingLinksets(const LLSD& pSeed); LLFloaterPathfindingLinksets(const LLSD& pSeed);
virtual ~LLFloaterPathfindingLinksets(); virtual ~LLFloaterPathfindingLinksets();
void sendNavmeshDataGetRequest(); void sendNavmeshDataGetRequest();
void handleNavmeshDataGetReply(const LLSD& pNavmeshData); void handleNavmeshDataGetReply(const LLSD& pNavmeshData);
void handleNavmeshDataGetError(const std::string& pURL, const std::string& pErrorReason); void handleNavmeshDataGetError(const std::string& pURL, const std::string& pErrorReason);
void setFetchState(EFetchState pFetchState); void setFetchState(EFetchState pFetchState);
void onLinksetsSelectionChange(); void onLinksetsSelectionChange();
void onRefreshLinksetsClicked(); void onRefreshLinksetsClicked();
void onSelectAllLinksetsClicked(); void onSelectAllLinksetsClicked();
void onSelectNoneLinksetsClicked(); void onSelectNoneLinksetsClicked();
void clearLinksetsList(); void clearLinksetsList();
void selectAllLinksets(); void selectAllLinksets();
void selectNoneLinksets(); void selectNoneLinksets();
void updateLinksetsStatusMessage(); void updateLinksetsStatusMessage();
}; };
#endif // LL_LLFLOATERPATHFINDINGLINKSETS_H #endif // LL_LLFLOATERPATHFINDINGLINKSETS_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment