From 88a97c64835a399931f2c584392bd39e366f05ec Mon Sep 17 00:00:00 2001 From: Denis Serdjuk Date: Mon, 2 Nov 2009 12:44:58 +0200 Subject: fixed bug EXT-1298 'Create Landmark' star has solid color even if there's no landmarks in parcel --HG-- branch : product-engine --- indra/newview/lllandmarkactions.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'indra/newview/lllandmarkactions.cpp') diff --git a/indra/newview/lllandmarkactions.cpp b/indra/newview/lllandmarkactions.cpp index 091346d3b4..0b07dd4f21 100644 --- a/indra/newview/lllandmarkactions.cpp +++ b/indra/newview/lllandmarkactions.cpp @@ -133,6 +133,33 @@ public: } }; +// Returns true if the given inventory item is a landmark pointing to the current parcel. +// Used to find out if there is at least one landmark from current parcel. +class LLFistAgentParcelLandmark : public LLInventoryCollectFunctor +{ +private: + bool mFounded;// to avoid unnecessary check + +public: + LLFistAgentParcelLandmark(): mFounded(false){} + + /*virtual*/ bool operator()(LLInventoryCategory* cat, LLInventoryItem* item) + { + if (mFounded || !item || item->getType() != LLAssetType::AT_LANDMARK) + return false; + + LLLandmark* landmark = gLandmarkList.getAsset(item->getAssetUUID()); + if (!landmark) // the landmark not been loaded yet + return false; + + LLVector3d landmark_global_pos; + if (!landmark->getGlobalPos(landmark_global_pos)) + return false; + mFounded = LLViewerParcelMgr::getInstance()->inAgentParcel(landmark_global_pos); + return mFounded; + } +}; + static void fetch_landmarks(LLInventoryModel::cat_array_t& cats, LLInventoryModel::item_array_t& items, LLInventoryCollectFunctor& add) @@ -172,6 +199,16 @@ bool LLLandmarkActions::landmarkAlreadyExists() return findLandmarkForAgentPos() != NULL; } +//static +bool LLLandmarkActions::hasParcelLandmark() +{ + LLFistAgentParcelLandmark get_first_agent_landmark; + LLInventoryModel::cat_array_t cats; + LLInventoryModel::item_array_t items; + fetch_landmarks(cats, items, get_first_agent_landmark); + return !items.empty(); + +} // *TODO: This could be made more efficient by only fetching the FIRST // landmark that meets the criteria -- cgit v1.2.3