summaryrefslogtreecommitdiff
path: root/indra/newview/lllandmarkactions.cpp
diff options
context:
space:
mode:
authorDenis Serdjuk <dserduk@productengine.com>2009-11-02 12:44:58 +0200
committerDenis Serdjuk <dserduk@productengine.com>2009-11-02 12:44:58 +0200
commit88a97c64835a399931f2c584392bd39e366f05ec (patch)
tree927159a4d619df93139f98f875130c13f6af1135 /indra/newview/lllandmarkactions.cpp
parent50047b1ea598dc827a6b44e15211acadec06f9af (diff)
fixed bug EXT-1298 'Create Landmark' star has solid color even if there's no landmarks in parcel
--HG-- branch : product-engine
Diffstat (limited to 'indra/newview/lllandmarkactions.cpp')
-rw-r--r--indra/newview/lllandmarkactions.cpp37
1 files changed, 37 insertions, 0 deletions
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