From a33e24413ea74aaad91d9eeaa685d1c523c5d210 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Fri, 2 Mar 2012 19:17:16 -0800 Subject: PATH-304,PATH-205: Initial reworking of the navmesh download functionality. --- indra/newview/llpathfindingnavmesh.cpp | 133 +++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 indra/newview/llpathfindingnavmesh.cpp (limited to 'indra/newview/llpathfindingnavmesh.cpp') diff --git a/indra/newview/llpathfindingnavmesh.cpp b/indra/newview/llpathfindingnavmesh.cpp new file mode 100644 index 0000000000..fd1a498e3b --- /dev/null +++ b/indra/newview/llpathfindingnavmesh.cpp @@ -0,0 +1,133 @@ +/** + * @file llpathfindingnavmesh.cpp + * @author William Todd Stinson + * @brief A class for representing the navmesh of a pathfinding region. + * + * $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$ + */ + +#include "llviewerprecompiledheaders.h" +#include "lluuid.h" +#include "llpathfindingnavmesh.h" +#include "llsdserialize.h" + +#include + +//--------------------------------------------------------------------------- +// LLPathfindingNavMesh +//--------------------------------------------------------------------------- + +LLPathfindingNavMesh::LLPathfindingNavMesh(const LLUUID &pRegionUUID) + : mRegionUUID(pRegionUUID), + mNavMeshRequestStatus(kNavMeshRequestUnknown), + mNavMeshSignal(), + mNavMeshData(), + mNavMeshVersion(0U) +{ +} + +LLPathfindingNavMesh::~LLPathfindingNavMesh() +{ +} + +LLPathfindingNavMesh::navmesh_slot_t LLPathfindingNavMesh::registerNavMeshListener(navmesh_callback_t pNavMeshCallback) +{ + return mNavMeshSignal.connect(pNavMeshCallback); +} + +bool LLPathfindingNavMesh::hasNavMeshVersion(U32 pNavMeshVersion) const +{ + return (((mNavMeshRequestStatus == kNavMeshRequestStarted) || (mNavMeshRequestStatus == kNavMeshRequestCompleted)) && (mNavMeshVersion == pNavMeshVersion)); +} + +void LLPathfindingNavMesh::handleRefresh() +{ + mNavMeshSignal(mNavMeshRequestStatus, mRegionUUID, mNavMeshVersion, mNavMeshData); +} + +void LLPathfindingNavMesh::handleNavMeshStart(U32 pNavMeshVersion) +{ + mNavMeshVersion = pNavMeshVersion; + setRequestStatus(kNavMeshRequestStarted); +} + +void LLPathfindingNavMesh::handleNavMeshResult(const LLSD &pContent, U32 pNavMeshVersion) +{ + llassert(mNavMeshVersion == pNavMeshVersion); + if (mNavMeshVersion == pNavMeshVersion) + { + if ( pContent.has("navmesh_data") ) + { + const LLSD::Binary &value = pContent["navmesh_data"].asBinary(); + unsigned int binSize = value.size(); + std::string newStr(reinterpret_cast(&value[0]), binSize); + std::istringstream streamdecomp( newStr ); + unsigned int decompBinSize = 0; + bool valid = false; + U8* pUncompressedNavMeshContainer = unzip_llsdNavMesh( valid, decompBinSize, streamdecomp, binSize ) ; + if ( !valid ) + { + llwarns << "Unable to decompress the navmesh llsd." << llendl; + setRequestStatus(kNavMeshRequestFormatError); + } + else + { + llassert(pUncompressedNavMeshContainer); + mNavMeshData.resize( decompBinSize ); + memcpy( &mNavMeshData[0], &pUncompressedNavMeshContainer[0], decompBinSize ); + setRequestStatus(kNavMeshRequestCompleted); + } + if ( pUncompressedNavMeshContainer ) + { + free( pUncompressedNavMeshContainer ); + } + } + else + { + llwarns << "No mesh data received" << llendl; + setRequestStatus(kNavMeshRequestMessageError); + } + } +} + +void LLPathfindingNavMesh::handleNavMeshNotEnabled() +{ + mNavMeshData.clear(); + setRequestStatus(kNavMeshRequestNotEnabled); +} + +void LLPathfindingNavMesh::handleNavMeshError(U32 pStatus, const std::string &pReason, const std::string &pURL, U32 pNavMeshVersion) +{ + llwarns << "error with request to URL '" << pURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; + llassert(mNavMeshVersion == pNavMeshVersion); + mNavMeshData.clear(); + if (mNavMeshVersion == pNavMeshVersion) + { + setRequestStatus(kNavMeshRequestMessageError); + } +} + +void LLPathfindingNavMesh::setRequestStatus(ENavMeshRequestStatus pNavMeshRequestStatus) +{ + mNavMeshRequestStatus = pNavMeshRequestStatus; + mNavMeshSignal(mNavMeshRequestStatus, mRegionUUID, mNavMeshVersion, mNavMeshData); +} -- cgit v1.2.3 From 581de7c7b8025c48e585c1af80e060af94aca328 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 5 Mar 2012 17:20:35 -0800 Subject: PATH-205,PATH-304: More work to handle downloading of out-of-date navmeshes. --- indra/newview/llpathfindingnavmesh.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/llpathfindingnavmesh.cpp') diff --git a/indra/newview/llpathfindingnavmesh.cpp b/indra/newview/llpathfindingnavmesh.cpp index fd1a498e3b..469972efa9 100644 --- a/indra/newview/llpathfindingnavmesh.cpp +++ b/indra/newview/llpathfindingnavmesh.cpp @@ -87,7 +87,7 @@ void LLPathfindingNavMesh::handleNavMeshResult(const LLSD &pContent, U32 pNavMes if ( !valid ) { llwarns << "Unable to decompress the navmesh llsd." << llendl; - setRequestStatus(kNavMeshRequestFormatError); + setRequestStatus(kNavMeshRequestError); } else { @@ -104,7 +104,7 @@ void LLPathfindingNavMesh::handleNavMeshResult(const LLSD &pContent, U32 pNavMes else { llwarns << "No mesh data received" << llendl; - setRequestStatus(kNavMeshRequestMessageError); + setRequestStatus(kNavMeshRequestError); } } } @@ -122,7 +122,7 @@ void LLPathfindingNavMesh::handleNavMeshError(U32 pStatus, const std::string &pR mNavMeshData.clear(); if (mNavMeshVersion == pNavMeshVersion) { - setRequestStatus(kNavMeshRequestMessageError); + setRequestStatus(kNavMeshRequestError); } } -- cgit v1.2.3 From f578181af9cbe3277374578c27487e2e72956079 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Thu, 8 Mar 2012 12:34:11 -0800 Subject: PATH-304: Adding functionality to handle the reloading of out-of-date navmeshes. --- indra/newview/llpathfindingnavmesh.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'indra/newview/llpathfindingnavmesh.cpp') diff --git a/indra/newview/llpathfindingnavmesh.cpp b/indra/newview/llpathfindingnavmesh.cpp index 469972efa9..84343cf31e 100644 --- a/indra/newview/llpathfindingnavmesh.cpp +++ b/indra/newview/llpathfindingnavmesh.cpp @@ -64,6 +64,13 @@ void LLPathfindingNavMesh::handleRefresh() mNavMeshSignal(mNavMeshRequestStatus, mRegionUUID, mNavMeshVersion, mNavMeshData); } +void LLPathfindingNavMesh::handleNavMeshNewVersion(U32 pNavMeshVersion) +{ + mNavMeshData.clear(); + mNavMeshVersion = pNavMeshVersion; + setRequestStatus(kNavMeshRequestNeedsUpdate); +} + void LLPathfindingNavMesh::handleNavMeshStart(U32 pNavMeshVersion) { mNavMeshVersion = pNavMeshVersion; @@ -72,7 +79,6 @@ void LLPathfindingNavMesh::handleNavMeshStart(U32 pNavMeshVersion) void LLPathfindingNavMesh::handleNavMeshResult(const LLSD &pContent, U32 pNavMeshVersion) { - llassert(mNavMeshVersion == pNavMeshVersion); if (mNavMeshVersion == pNavMeshVersion) { if ( pContent.has("navmesh_data") ) @@ -118,10 +124,9 @@ void LLPathfindingNavMesh::handleNavMeshNotEnabled() void LLPathfindingNavMesh::handleNavMeshError(U32 pStatus, const std::string &pReason, const std::string &pURL, U32 pNavMeshVersion) { llwarns << "error with request to URL '" << pURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; - llassert(mNavMeshVersion == pNavMeshVersion); - mNavMeshData.clear(); if (mNavMeshVersion == pNavMeshVersion) { + mNavMeshData.clear(); setRequestStatus(kNavMeshRequestError); } } -- cgit v1.2.3 From b3197fc12e41bc60e3510d840c67ef98816c3ae8 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 12 Mar 2012 18:48:40 -0700 Subject: PATH-304: Making the navmesh version information work for both Premium Wilderness regions (old pathfinding simulator build with missing capabilities) as well as the new pathfinding simulator builds with the version services. --- indra/newview/llpathfindingnavmesh.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'indra/newview/llpathfindingnavmesh.cpp') diff --git a/indra/newview/llpathfindingnavmesh.cpp b/indra/newview/llpathfindingnavmesh.cpp index 84343cf31e..81fa7b24db 100644 --- a/indra/newview/llpathfindingnavmesh.cpp +++ b/indra/newview/llpathfindingnavmesh.cpp @@ -66,9 +66,12 @@ void LLPathfindingNavMesh::handleRefresh() void LLPathfindingNavMesh::handleNavMeshNewVersion(U32 pNavMeshVersion) { - mNavMeshData.clear(); - mNavMeshVersion = pNavMeshVersion; - setRequestStatus(kNavMeshRequestNeedsUpdate); + if (mNavMeshVersion != pNavMeshVersion) + { + mNavMeshData.clear(); + mNavMeshVersion = pNavMeshVersion; + setRequestStatus(kNavMeshRequestNeedsUpdate); + } } void LLPathfindingNavMesh::handleNavMeshStart(U32 pNavMeshVersion) @@ -121,13 +124,18 @@ void LLPathfindingNavMesh::handleNavMeshNotEnabled() setRequestStatus(kNavMeshRequestNotEnabled); } +void LLPathfindingNavMesh::handleNavMeshError() +{ + mNavMeshData.clear(); + setRequestStatus(kNavMeshRequestError); +} + void LLPathfindingNavMesh::handleNavMeshError(U32 pStatus, const std::string &pReason, const std::string &pURL, U32 pNavMeshVersion) { llwarns << "error with request to URL '" << pURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; if (mNavMeshVersion == pNavMeshVersion) { - mNavMeshData.clear(); - setRequestStatus(kNavMeshRequestError); + handleNavMeshError(); } } -- cgit v1.2.3 From c990cc71ce124059a072c7778ac962253bacb199 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Mon, 12 Mar 2012 19:18:19 -0700 Subject: PATH-304: Adding an extra state for the pathfinding console to report that the status of the navmesh is being checked. --- indra/newview/llpathfindingnavmesh.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'indra/newview/llpathfindingnavmesh.cpp') diff --git a/indra/newview/llpathfindingnavmesh.cpp b/indra/newview/llpathfindingnavmesh.cpp index 81fa7b24db..138295a8cf 100644 --- a/indra/newview/llpathfindingnavmesh.cpp +++ b/indra/newview/llpathfindingnavmesh.cpp @@ -56,12 +56,28 @@ LLPathfindingNavMesh::navmesh_slot_t LLPathfindingNavMesh::registerNavMeshListen bool LLPathfindingNavMesh::hasNavMeshVersion(U32 pNavMeshVersion) const { - return (((mNavMeshRequestStatus == kNavMeshRequestStarted) || (mNavMeshRequestStatus == kNavMeshRequestCompleted)) && (mNavMeshVersion == pNavMeshVersion)); + return ((mNavMeshVersion == pNavMeshVersion) && + ((mNavMeshRequestStatus == kNavMeshRequestStarted) || (mNavMeshRequestStatus == kNavMeshRequestCompleted) || + ((mNavMeshRequestStatus == kNavMeshRequestChecking) && !mNavMeshData.empty()))); } -void LLPathfindingNavMesh::handleRefresh() +void LLPathfindingNavMesh::handleRefresh(U32 pNavMeshVersion) { - mNavMeshSignal(mNavMeshRequestStatus, mRegionUUID, mNavMeshVersion, mNavMeshData); + llassert(pNavMeshVersion == mNavMeshVersion); + if (mNavMeshRequestStatus == kNavMeshRequestChecking) + { + llassert(!mNavMeshData.empty()); + setRequestStatus(kNavMeshRequestCompleted); + } + else + { + mNavMeshSignal(mNavMeshRequestStatus, mRegionUUID, mNavMeshVersion, mNavMeshData); + } +} + +void LLPathfindingNavMesh::handleNavMeshCheckVersion() +{ + setRequestStatus(kNavMeshRequestChecking); } void LLPathfindingNavMesh::handleNavMeshNewVersion(U32 pNavMeshVersion) -- cgit v1.2.3 From 9aa0c58c20f8d60dc2f674ce1eaa805db8f599c8 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 13 Mar 2012 14:29:01 -0700 Subject: PATH-304: Using the embedded navmesh version information. --- indra/newview/llpathfindingnavmesh.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'indra/newview/llpathfindingnavmesh.cpp') diff --git a/indra/newview/llpathfindingnavmesh.cpp b/indra/newview/llpathfindingnavmesh.cpp index 138295a8cf..740d1cde24 100644 --- a/indra/newview/llpathfindingnavmesh.cpp +++ b/indra/newview/llpathfindingnavmesh.cpp @@ -32,6 +32,9 @@ #include +#define NAVMESH_VERSION_FIELD "navmesh_version" +#define NAVMESH_DATA_FIELD "navmesh_data" + //--------------------------------------------------------------------------- // LLPathfindingNavMesh //--------------------------------------------------------------------------- @@ -98,11 +101,24 @@ void LLPathfindingNavMesh::handleNavMeshStart(U32 pNavMeshVersion) void LLPathfindingNavMesh::handleNavMeshResult(const LLSD &pContent, U32 pNavMeshVersion) { + if (pContent.has(NAVMESH_VERSION_FIELD)) + { + llassert(pContent.get(NAVMESH_VERSION_FIELD).isInteger()); + llassert(pContent.get(NAVMESH_VERSION_FIELD).asInteger() >= 0); + U32 embeddedNavMeshVersion = static_cast(pContent.get(NAVMESH_VERSION_FIELD).asInteger()); + llassert(embeddedNavMeshVersion == pNavMeshVersion); // stinson 03/13/2012 : does this ever occur? + if (embeddedNavMeshVersion != pNavMeshVersion) + { + llwarns << "Mismatch between expected and embedded navmesh versions occurred" << llendl; + pNavMeshVersion = embeddedNavMeshVersion; + } + } + if (mNavMeshVersion == pNavMeshVersion) { - if ( pContent.has("navmesh_data") ) + if ( pContent.has(NAVMESH_DATA_FIELD) ) { - const LLSD::Binary &value = pContent["navmesh_data"].asBinary(); + const LLSD::Binary &value = pContent.get(NAVMESH_DATA_FIELD).asBinary(); unsigned int binSize = value.size(); std::string newStr(reinterpret_cast(&value[0]), binSize); std::istringstream streamdecomp( newStr ); -- cgit v1.2.3 From d4fb7c99febf07b4eb7f3a9d2eab485e356d1439 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Wed, 14 Mar 2012 14:09:36 -0700 Subject: PATH-302: Adding in status reporting for the simulator navmesh status. Separating the viewer status messaging from the simulator status. --- indra/newview/llpathfindingnavmesh.cpp | 65 +++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 24 deletions(-) (limited to 'indra/newview/llpathfindingnavmesh.cpp') diff --git a/indra/newview/llpathfindingnavmesh.cpp b/indra/newview/llpathfindingnavmesh.cpp index 740d1cde24..10e9abaf0c 100644 --- a/indra/newview/llpathfindingnavmesh.cpp +++ b/indra/newview/llpathfindingnavmesh.cpp @@ -28,6 +28,7 @@ #include "llviewerprecompiledheaders.h" #include "lluuid.h" #include "llpathfindingnavmesh.h" +#include "llpathfindingnavmeshstatus.h" #include "llsdserialize.h" #include @@ -40,11 +41,11 @@ //--------------------------------------------------------------------------- LLPathfindingNavMesh::LLPathfindingNavMesh(const LLUUID &pRegionUUID) - : mRegionUUID(pRegionUUID), + : mNavMeshStatus(pRegionUUID), mNavMeshRequestStatus(kNavMeshRequestUnknown), mNavMeshSignal(), - mNavMeshData(), - mNavMeshVersion(0U) + mNavMeshData() + { } @@ -57,16 +58,23 @@ LLPathfindingNavMesh::navmesh_slot_t LLPathfindingNavMesh::registerNavMeshListen return mNavMeshSignal.connect(pNavMeshCallback); } -bool LLPathfindingNavMesh::hasNavMeshVersion(U32 pNavMeshVersion) const +bool LLPathfindingNavMesh::hasNavMeshVersion(const LLPathfindingNavMeshStatus &pNavMeshStatus) const { - return ((mNavMeshVersion == pNavMeshVersion) && + return ((mNavMeshStatus.getVersion() == pNavMeshStatus.getVersion()) && ((mNavMeshRequestStatus == kNavMeshRequestStarted) || (mNavMeshRequestStatus == kNavMeshRequestCompleted) || ((mNavMeshRequestStatus == kNavMeshRequestChecking) && !mNavMeshData.empty()))); } -void LLPathfindingNavMesh::handleRefresh(U32 pNavMeshVersion) +void LLPathfindingNavMesh::handleNavMeshCheckVersion() +{ + setRequestStatus(kNavMeshRequestChecking); +} + +void LLPathfindingNavMesh::handleRefresh(const LLPathfindingNavMeshStatus &pNavMeshStatus) { - llassert(pNavMeshVersion == mNavMeshVersion); + llassert(mNavMeshStatus.getRegionUUID() == pNavMeshStatus.getRegionUUID()); + llassert(mNavMeshStatus.getVersion() == pNavMeshStatus.getVersion()); + mNavMeshStatus = pNavMeshStatus; if (mNavMeshRequestStatus == kNavMeshRequestChecking) { llassert(!mNavMeshData.empty()); @@ -74,28 +82,30 @@ void LLPathfindingNavMesh::handleRefresh(U32 pNavMeshVersion) } else { - mNavMeshSignal(mNavMeshRequestStatus, mRegionUUID, mNavMeshVersion, mNavMeshData); + sendStatus(); } } -void LLPathfindingNavMesh::handleNavMeshCheckVersion() -{ - setRequestStatus(kNavMeshRequestChecking); -} - -void LLPathfindingNavMesh::handleNavMeshNewVersion(U32 pNavMeshVersion) +void LLPathfindingNavMesh::handleNavMeshNewVersion(const LLPathfindingNavMeshStatus &pNavMeshStatus) { - if (mNavMeshVersion != pNavMeshVersion) + llassert(mNavMeshStatus.getRegionUUID() == pNavMeshStatus.getRegionUUID()); + if (mNavMeshStatus.getVersion() == pNavMeshStatus.getVersion()) + { + mNavMeshStatus = pNavMeshStatus; + sendStatus(); + } + else { mNavMeshData.clear(); - mNavMeshVersion = pNavMeshVersion; + mNavMeshStatus = pNavMeshStatus; setRequestStatus(kNavMeshRequestNeedsUpdate); } } -void LLPathfindingNavMesh::handleNavMeshStart(U32 pNavMeshVersion) +void LLPathfindingNavMesh::handleNavMeshStart(const LLPathfindingNavMeshStatus &pNavMeshStatus) { - mNavMeshVersion = pNavMeshVersion; + llassert(mNavMeshStatus.getRegionUUID() == pNavMeshStatus.getRegionUUID()); + mNavMeshStatus = pNavMeshStatus; setRequestStatus(kNavMeshRequestStarted); } @@ -114,8 +124,9 @@ void LLPathfindingNavMesh::handleNavMeshResult(const LLSD &pContent, U32 pNavMes } } - if (mNavMeshVersion == pNavMeshVersion) + if (mNavMeshStatus.getVersion() == pNavMeshVersion) { + ENavMeshRequestStatus status; if ( pContent.has(NAVMESH_DATA_FIELD) ) { const LLSD::Binary &value = pContent.get(NAVMESH_DATA_FIELD).asBinary(); @@ -128,14 +139,14 @@ void LLPathfindingNavMesh::handleNavMeshResult(const LLSD &pContent, U32 pNavMes if ( !valid ) { llwarns << "Unable to decompress the navmesh llsd." << llendl; - setRequestStatus(kNavMeshRequestError); + status = kNavMeshRequestError; } else { llassert(pUncompressedNavMeshContainer); mNavMeshData.resize( decompBinSize ); memcpy( &mNavMeshData[0], &pUncompressedNavMeshContainer[0], decompBinSize ); - setRequestStatus(kNavMeshRequestCompleted); + status = kNavMeshRequestCompleted; } if ( pUncompressedNavMeshContainer ) { @@ -145,8 +156,9 @@ void LLPathfindingNavMesh::handleNavMeshResult(const LLSD &pContent, U32 pNavMes else { llwarns << "No mesh data received" << llendl; - setRequestStatus(kNavMeshRequestError); + status = kNavMeshRequestError; } + setRequestStatus(status); } } @@ -165,7 +177,7 @@ void LLPathfindingNavMesh::handleNavMeshError() void LLPathfindingNavMesh::handleNavMeshError(U32 pStatus, const std::string &pReason, const std::string &pURL, U32 pNavMeshVersion) { llwarns << "error with request to URL '" << pURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; - if (mNavMeshVersion == pNavMeshVersion) + if (mNavMeshStatus.getVersion() == pNavMeshVersion) { handleNavMeshError(); } @@ -174,5 +186,10 @@ void LLPathfindingNavMesh::handleNavMeshError(U32 pStatus, const std::string &pR void LLPathfindingNavMesh::setRequestStatus(ENavMeshRequestStatus pNavMeshRequestStatus) { mNavMeshRequestStatus = pNavMeshRequestStatus; - mNavMeshSignal(mNavMeshRequestStatus, mRegionUUID, mNavMeshVersion, mNavMeshData); + sendStatus(); +} + +void LLPathfindingNavMesh::sendStatus() +{ + mNavMeshSignal(mNavMeshRequestStatus, mNavMeshStatus, mNavMeshData); } -- cgit v1.2.3 From a72034fa42ebaf7e2f56c4a8cb0f445f12d22fe4 Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 24 Apr 2012 19:23:20 -0700 Subject: PATH-580: BUGFIX Adding functionality to detect when the region's capabilities have not yet been loading and deferring requests for the navmesh query until the capabilities are fully loaded. --- indra/newview/llpathfindingnavmesh.cpp | 396 +++++++++++++++++---------------- 1 file changed, 201 insertions(+), 195 deletions(-) (limited to 'indra/newview/llpathfindingnavmesh.cpp') diff --git a/indra/newview/llpathfindingnavmesh.cpp b/indra/newview/llpathfindingnavmesh.cpp index 10e9abaf0c..4e4e9fceef 100644 --- a/indra/newview/llpathfindingnavmesh.cpp +++ b/indra/newview/llpathfindingnavmesh.cpp @@ -1,195 +1,201 @@ -/** - * @file llpathfindingnavmesh.cpp - * @author William Todd Stinson - * @brief A class for representing the navmesh of a pathfinding region. - * - * $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$ - */ - -#include "llviewerprecompiledheaders.h" -#include "lluuid.h" -#include "llpathfindingnavmesh.h" -#include "llpathfindingnavmeshstatus.h" -#include "llsdserialize.h" - -#include - -#define NAVMESH_VERSION_FIELD "navmesh_version" -#define NAVMESH_DATA_FIELD "navmesh_data" - -//--------------------------------------------------------------------------- -// LLPathfindingNavMesh -//--------------------------------------------------------------------------- - -LLPathfindingNavMesh::LLPathfindingNavMesh(const LLUUID &pRegionUUID) - : mNavMeshStatus(pRegionUUID), - mNavMeshRequestStatus(kNavMeshRequestUnknown), - mNavMeshSignal(), - mNavMeshData() - -{ -} - -LLPathfindingNavMesh::~LLPathfindingNavMesh() -{ -} - -LLPathfindingNavMesh::navmesh_slot_t LLPathfindingNavMesh::registerNavMeshListener(navmesh_callback_t pNavMeshCallback) -{ - return mNavMeshSignal.connect(pNavMeshCallback); -} - -bool LLPathfindingNavMesh::hasNavMeshVersion(const LLPathfindingNavMeshStatus &pNavMeshStatus) const -{ - return ((mNavMeshStatus.getVersion() == pNavMeshStatus.getVersion()) && - ((mNavMeshRequestStatus == kNavMeshRequestStarted) || (mNavMeshRequestStatus == kNavMeshRequestCompleted) || - ((mNavMeshRequestStatus == kNavMeshRequestChecking) && !mNavMeshData.empty()))); -} - -void LLPathfindingNavMesh::handleNavMeshCheckVersion() -{ - setRequestStatus(kNavMeshRequestChecking); -} - -void LLPathfindingNavMesh::handleRefresh(const LLPathfindingNavMeshStatus &pNavMeshStatus) -{ - llassert(mNavMeshStatus.getRegionUUID() == pNavMeshStatus.getRegionUUID()); - llassert(mNavMeshStatus.getVersion() == pNavMeshStatus.getVersion()); - mNavMeshStatus = pNavMeshStatus; - if (mNavMeshRequestStatus == kNavMeshRequestChecking) - { - llassert(!mNavMeshData.empty()); - setRequestStatus(kNavMeshRequestCompleted); - } - else - { - sendStatus(); - } -} - -void LLPathfindingNavMesh::handleNavMeshNewVersion(const LLPathfindingNavMeshStatus &pNavMeshStatus) -{ - llassert(mNavMeshStatus.getRegionUUID() == pNavMeshStatus.getRegionUUID()); - if (mNavMeshStatus.getVersion() == pNavMeshStatus.getVersion()) - { - mNavMeshStatus = pNavMeshStatus; - sendStatus(); - } - else - { - mNavMeshData.clear(); - mNavMeshStatus = pNavMeshStatus; - setRequestStatus(kNavMeshRequestNeedsUpdate); - } -} - -void LLPathfindingNavMesh::handleNavMeshStart(const LLPathfindingNavMeshStatus &pNavMeshStatus) -{ - llassert(mNavMeshStatus.getRegionUUID() == pNavMeshStatus.getRegionUUID()); - mNavMeshStatus = pNavMeshStatus; - setRequestStatus(kNavMeshRequestStarted); -} - -void LLPathfindingNavMesh::handleNavMeshResult(const LLSD &pContent, U32 pNavMeshVersion) -{ - if (pContent.has(NAVMESH_VERSION_FIELD)) - { - llassert(pContent.get(NAVMESH_VERSION_FIELD).isInteger()); - llassert(pContent.get(NAVMESH_VERSION_FIELD).asInteger() >= 0); - U32 embeddedNavMeshVersion = static_cast(pContent.get(NAVMESH_VERSION_FIELD).asInteger()); - llassert(embeddedNavMeshVersion == pNavMeshVersion); // stinson 03/13/2012 : does this ever occur? - if (embeddedNavMeshVersion != pNavMeshVersion) - { - llwarns << "Mismatch between expected and embedded navmesh versions occurred" << llendl; - pNavMeshVersion = embeddedNavMeshVersion; - } - } - - if (mNavMeshStatus.getVersion() == pNavMeshVersion) - { - ENavMeshRequestStatus status; - if ( pContent.has(NAVMESH_DATA_FIELD) ) - { - const LLSD::Binary &value = pContent.get(NAVMESH_DATA_FIELD).asBinary(); - unsigned int binSize = value.size(); - std::string newStr(reinterpret_cast(&value[0]), binSize); - std::istringstream streamdecomp( newStr ); - unsigned int decompBinSize = 0; - bool valid = false; - U8* pUncompressedNavMeshContainer = unzip_llsdNavMesh( valid, decompBinSize, streamdecomp, binSize ) ; - if ( !valid ) - { - llwarns << "Unable to decompress the navmesh llsd." << llendl; - status = kNavMeshRequestError; - } - else - { - llassert(pUncompressedNavMeshContainer); - mNavMeshData.resize( decompBinSize ); - memcpy( &mNavMeshData[0], &pUncompressedNavMeshContainer[0], decompBinSize ); - status = kNavMeshRequestCompleted; - } - if ( pUncompressedNavMeshContainer ) - { - free( pUncompressedNavMeshContainer ); - } - } - else - { - llwarns << "No mesh data received" << llendl; - status = kNavMeshRequestError; - } - setRequestStatus(status); - } -} - -void LLPathfindingNavMesh::handleNavMeshNotEnabled() -{ - mNavMeshData.clear(); - setRequestStatus(kNavMeshRequestNotEnabled); -} - -void LLPathfindingNavMesh::handleNavMeshError() -{ - mNavMeshData.clear(); - setRequestStatus(kNavMeshRequestError); -} - -void LLPathfindingNavMesh::handleNavMeshError(U32 pStatus, const std::string &pReason, const std::string &pURL, U32 pNavMeshVersion) -{ - llwarns << "error with request to URL '" << pURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; - if (mNavMeshStatus.getVersion() == pNavMeshVersion) - { - handleNavMeshError(); - } -} - -void LLPathfindingNavMesh::setRequestStatus(ENavMeshRequestStatus pNavMeshRequestStatus) -{ - mNavMeshRequestStatus = pNavMeshRequestStatus; - sendStatus(); -} - -void LLPathfindingNavMesh::sendStatus() -{ - mNavMeshSignal(mNavMeshRequestStatus, mNavMeshStatus, mNavMeshData); -} +/** + * @file llpathfindingnavmesh.cpp + * @author William Todd Stinson + * @brief A class for representing the navmesh of a pathfinding region. + * + * $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$ + */ + +#include "llviewerprecompiledheaders.h" +#include "lluuid.h" +#include "llpathfindingnavmesh.h" +#include "llpathfindingnavmeshstatus.h" +#include "llsdserialize.h" + +#include + +#define NAVMESH_VERSION_FIELD "navmesh_version" +#define NAVMESH_DATA_FIELD "navmesh_data" + +//--------------------------------------------------------------------------- +// LLPathfindingNavMesh +//--------------------------------------------------------------------------- + +LLPathfindingNavMesh::LLPathfindingNavMesh(const LLUUID &pRegionUUID) + : mNavMeshStatus(pRegionUUID), + mNavMeshRequestStatus(kNavMeshRequestUnknown), + mNavMeshSignal(), + mNavMeshData() + +{ +} + +LLPathfindingNavMesh::~LLPathfindingNavMesh() +{ +} + +LLPathfindingNavMesh::navmesh_slot_t LLPathfindingNavMesh::registerNavMeshListener(navmesh_callback_t pNavMeshCallback) +{ + return mNavMeshSignal.connect(pNavMeshCallback); +} + +bool LLPathfindingNavMesh::hasNavMeshVersion(const LLPathfindingNavMeshStatus &pNavMeshStatus) const +{ + return ((mNavMeshStatus.getVersion() == pNavMeshStatus.getVersion()) && + ((mNavMeshRequestStatus == kNavMeshRequestStarted) || (mNavMeshRequestStatus == kNavMeshRequestCompleted) || + ((mNavMeshRequestStatus == kNavMeshRequestChecking) && !mNavMeshData.empty()))); +} + +void LLPathfindingNavMesh::handleNavMeshWaitForRegionLoad() +{ + setRequestStatus(kNavMeshRequestWaiting); +} + +void LLPathfindingNavMesh::handleNavMeshCheckVersion() +{ + setRequestStatus(kNavMeshRequestChecking); +} + +void LLPathfindingNavMesh::handleRefresh(const LLPathfindingNavMeshStatus &pNavMeshStatus) +{ + llassert(mNavMeshStatus.getRegionUUID() == pNavMeshStatus.getRegionUUID()); + llassert(mNavMeshStatus.getVersion() == pNavMeshStatus.getVersion()); + mNavMeshStatus = pNavMeshStatus; + if (mNavMeshRequestStatus == kNavMeshRequestChecking) + { + llassert(!mNavMeshData.empty()); + setRequestStatus(kNavMeshRequestCompleted); + } + else + { + sendStatus(); + } +} + +void LLPathfindingNavMesh::handleNavMeshNewVersion(const LLPathfindingNavMeshStatus &pNavMeshStatus) +{ + llassert(mNavMeshStatus.getRegionUUID() == pNavMeshStatus.getRegionUUID()); + if (mNavMeshStatus.getVersion() == pNavMeshStatus.getVersion()) + { + mNavMeshStatus = pNavMeshStatus; + sendStatus(); + } + else + { + mNavMeshData.clear(); + mNavMeshStatus = pNavMeshStatus; + setRequestStatus(kNavMeshRequestNeedsUpdate); + } +} + +void LLPathfindingNavMesh::handleNavMeshStart(const LLPathfindingNavMeshStatus &pNavMeshStatus) +{ + llassert(mNavMeshStatus.getRegionUUID() == pNavMeshStatus.getRegionUUID()); + mNavMeshStatus = pNavMeshStatus; + setRequestStatus(kNavMeshRequestStarted); +} + +void LLPathfindingNavMesh::handleNavMeshResult(const LLSD &pContent, U32 pNavMeshVersion) +{ + if (pContent.has(NAVMESH_VERSION_FIELD)) + { + llassert(pContent.get(NAVMESH_VERSION_FIELD).isInteger()); + llassert(pContent.get(NAVMESH_VERSION_FIELD).asInteger() >= 0); + U32 embeddedNavMeshVersion = static_cast(pContent.get(NAVMESH_VERSION_FIELD).asInteger()); + llassert(embeddedNavMeshVersion == pNavMeshVersion); // stinson 03/13/2012 : does this ever occur? + if (embeddedNavMeshVersion != pNavMeshVersion) + { + llwarns << "Mismatch between expected and embedded navmesh versions occurred" << llendl; + pNavMeshVersion = embeddedNavMeshVersion; + } + } + + if (mNavMeshStatus.getVersion() == pNavMeshVersion) + { + ENavMeshRequestStatus status; + if ( pContent.has(NAVMESH_DATA_FIELD) ) + { + const LLSD::Binary &value = pContent.get(NAVMESH_DATA_FIELD).asBinary(); + unsigned int binSize = value.size(); + std::string newStr(reinterpret_cast(&value[0]), binSize); + std::istringstream streamdecomp( newStr ); + unsigned int decompBinSize = 0; + bool valid = false; + U8* pUncompressedNavMeshContainer = unzip_llsdNavMesh( valid, decompBinSize, streamdecomp, binSize ) ; + if ( !valid ) + { + llwarns << "Unable to decompress the navmesh llsd." << llendl; + status = kNavMeshRequestError; + } + else + { + llassert(pUncompressedNavMeshContainer); + mNavMeshData.resize( decompBinSize ); + memcpy( &mNavMeshData[0], &pUncompressedNavMeshContainer[0], decompBinSize ); + status = kNavMeshRequestCompleted; + } + if ( pUncompressedNavMeshContainer ) + { + free( pUncompressedNavMeshContainer ); + } + } + else + { + llwarns << "No mesh data received" << llendl; + status = kNavMeshRequestError; + } + setRequestStatus(status); + } +} + +void LLPathfindingNavMesh::handleNavMeshNotEnabled() +{ + mNavMeshData.clear(); + setRequestStatus(kNavMeshRequestNotEnabled); +} + +void LLPathfindingNavMesh::handleNavMeshError() +{ + mNavMeshData.clear(); + setRequestStatus(kNavMeshRequestError); +} + +void LLPathfindingNavMesh::handleNavMeshError(U32 pStatus, const std::string &pReason, const std::string &pURL, U32 pNavMeshVersion) +{ + llwarns << "error with request to URL '" << pURL << "' because " << pReason << " (statusCode:" << pStatus << ")" << llendl; + if (mNavMeshStatus.getVersion() == pNavMeshVersion) + { + handleNavMeshError(); + } +} + +void LLPathfindingNavMesh::setRequestStatus(ENavMeshRequestStatus pNavMeshRequestStatus) +{ + mNavMeshRequestStatus = pNavMeshRequestStatus; + sendStatus(); +} + +void LLPathfindingNavMesh::sendStatus() +{ + mNavMeshSignal(mNavMeshRequestStatus, mNavMeshStatus, mNavMeshData); +} + -- cgit v1.2.3 From 78910cf3016fc55eaf8214640b348df0f8bcdeda Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Tue, 26 Jun 2012 18:04:19 -0700 Subject: Updating the header licensing comments. --- indra/newview/llpathfindingnavmesh.cpp | 58 ++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 28 deletions(-) (limited to 'indra/newview/llpathfindingnavmesh.cpp') diff --git a/indra/newview/llpathfindingnavmesh.cpp b/indra/newview/llpathfindingnavmesh.cpp index 4e4e9fceef..1a49560712 100644 --- a/indra/newview/llpathfindingnavmesh.cpp +++ b/indra/newview/llpathfindingnavmesh.cpp @@ -1,35 +1,38 @@ -/** - * @file llpathfindingnavmesh.cpp - * @author William Todd Stinson - * @brief A class for representing the navmesh of a pathfinding region. - * - * $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$ - */ +/** +* @file llpathfindingnavmesh.cpp +* @brief Implementation of llpathfindingnavmesh +* @author Stinson@lindenlab.com +* +* $LicenseInfo:firstyear=2012&license=viewerlgpl$ +* Second Life Viewer Source Code +* Copyright (C) 2012, 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 "lluuid.h" + #include "llpathfindingnavmesh.h" + #include "llpathfindingnavmeshstatus.h" #include "llsdserialize.h" +#include "lluuid.h" #include @@ -198,4 +201,3 @@ void LLPathfindingNavMesh::sendStatus() { mNavMeshSignal(mNavMeshRequestStatus, mNavMeshStatus, mNavMeshData); } - -- cgit v1.2.3 From 685a672b74550ca0dbf8a816257c84c9c44fd34d Mon Sep 17 00:00:00 2001 From: Todd Stinson Date: Thu, 28 Jun 2012 15:37:55 -0700 Subject: Cleaning up new files in preparation for merge into viewer-release. --- indra/newview/llpathfindingnavmesh.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'indra/newview/llpathfindingnavmesh.cpp') diff --git a/indra/newview/llpathfindingnavmesh.cpp b/indra/newview/llpathfindingnavmesh.cpp index 1a49560712..e01dd3a152 100644 --- a/indra/newview/llpathfindingnavmesh.cpp +++ b/indra/newview/llpathfindingnavmesh.cpp @@ -30,12 +30,13 @@ #include "llpathfindingnavmesh.h" +#include + #include "llpathfindingnavmeshstatus.h" +#include "llsd.h" #include "llsdserialize.h" #include "lluuid.h" -#include - #define NAVMESH_VERSION_FIELD "navmesh_version" #define NAVMESH_DATA_FIELD "navmesh_data" @@ -119,6 +120,7 @@ void LLPathfindingNavMesh::handleNavMeshStart(const LLPathfindingNavMeshStatus & void LLPathfindingNavMesh::handleNavMeshResult(const LLSD &pContent, U32 pNavMeshVersion) { + llassert(pContent.has(NAVMESH_VERSION_FIELD)); if (pContent.has(NAVMESH_VERSION_FIELD)) { llassert(pContent.get(NAVMESH_VERSION_FIELD).isInteger()); -- cgit v1.2.3