aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llselectmgr.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:37 -0500
committerJacek Antonelli2008-08-15 23:45:37 -0500
commit31ba05810c641f14e8ab5da8ad2aaf527779f6c1 (patch)
treec4b8d635dfb657fa4cfee7c285f8cadbf24afa90 /linden/indra/newview/llselectmgr.cpp
parentSecond Life viewer sources 1.19.1.1 (diff)
downloadmeta-impy-31ba05810c641f14e8ab5da8ad2aaf527779f6c1.zip
meta-impy-31ba05810c641f14e8ab5da8ad2aaf527779f6c1.tar.gz
meta-impy-31ba05810c641f14e8ab5da8ad2aaf527779f6c1.tar.bz2
meta-impy-31ba05810c641f14e8ab5da8ad2aaf527779f6c1.tar.xz
Second Life viewer sources 1.19.1.2
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llselectmgr.cpp101
1 files changed, 67 insertions, 34 deletions
diff --git a/linden/indra/newview/llselectmgr.cpp b/linden/indra/newview/llselectmgr.cpp
index 45a4ff5..da71c6b 100644
--- a/linden/indra/newview/llselectmgr.cpp
+++ b/linden/indra/newview/llselectmgr.cpp
@@ -83,6 +83,7 @@
83 83
84#include "llglheaders.h" 84#include "llglheaders.h"
85 85
86LLViewerObject* getSelectedParentObject(LLViewerObject *object) ;
86// 87//
87// Consts 88// Consts
88// 89//
@@ -262,7 +263,7 @@ void LLSelectMgr::overrideObjectUpdates()
262 virtual bool apply(LLSelectNode* selectNode) 263 virtual bool apply(LLSelectNode* selectNode)
263 { 264 {
264 LLViewerObject* object = selectNode->getObject(); 265 LLViewerObject* object = selectNode->getObject();
265 if (object->permMove()) 266 if (object && object->permMove())
266 { 267 {
267 if (!selectNode->mLastPositionLocal.isExactlyZero()) 268 if (!selectNode->mLastPositionLocal.isExactlyZero())
268 { 269 {
@@ -1038,10 +1039,19 @@ void LLSelectMgr::getGrid(LLVector3& origin, LLQuaternion &rotation, LLVector3 &
1038 1039
1039 if (mGridMode == GRID_MODE_LOCAL && mSelectedObjects->getObjectCount()) 1040 if (mGridMode == GRID_MODE_LOCAL && mSelectedObjects->getObjectCount())
1040 { 1041 {
1042 LLViewerObject* root = getSelectedParentObject(mSelectedObjects->getFirstObject());
1041 LLBBox bbox = mSavedSelectionBBox; 1043 LLBBox bbox = mSavedSelectionBBox;
1042 mGridOrigin = mSavedSelectionBBox.getCenterAgent(); 1044 mGridOrigin = mSavedSelectionBBox.getCenterAgent();
1043 mGridRotation = mSavedSelectionBBox.getRotation();
1044 mGridScale = mSavedSelectionBBox.getExtentLocal() * 0.5f; 1045 mGridScale = mSavedSelectionBBox.getExtentLocal() * 0.5f;
1046
1047 if(mSelectedObjects->getObjectCount() < 2 || !root || root->mDrawable.isNull())
1048 {
1049 mGridRotation = mSavedSelectionBBox.getRotation();
1050 }
1051 else //set to the root object
1052 {
1053 mGridRotation = root->getRenderRotation();
1054 }
1045 } 1055 }
1046 else if (mGridMode == GRID_MODE_REF_OBJECT && first_grid_object && first_grid_object->mDrawable.notNull()) 1056 else if (mGridMode == GRID_MODE_REF_OBJECT && first_grid_object && first_grid_object->mDrawable.notNull())
1047 { 1057 {
@@ -1317,6 +1327,8 @@ void LLSelectMgr::dump()
1317 { 1327 {
1318 LLSelectNode* node = *iter; 1328 LLSelectNode* node = *iter;
1319 LLViewerObject* objectp = node->getObject(); 1329 LLViewerObject* objectp = node->getObject();
1330 if (!objectp)
1331 continue;
1320 for (S32 te = 0; te < objectp->getNumTEs(); ++te ) 1332 for (S32 te = 0; te < objectp->getNumTEs(); ++te )
1321 { 1333 {
1322 if (node->isTESelected(te)) 1334 if (node->isTESelected(te))
@@ -2099,6 +2111,11 @@ void LLSelectMgr::adjustTexturesByScale(BOOL send_to_sim, BOOL stretch)
2099 LLSelectNode* selectNode = *iter; 2111 LLSelectNode* selectNode = *iter;
2100 LLViewerObject* object = selectNode->getObject(); 2112 LLViewerObject* object = selectNode->getObject();
2101 2113
2114 if (!object)
2115 {
2116 continue;
2117 }
2118
2102 if (!object->permModify()) 2119 if (!object->permModify())
2103 { 2120 {
2104 continue; 2121 continue;
@@ -2199,7 +2216,7 @@ BOOL LLSelectMgr::selectGetModify()
2199 { 2216 {
2200 LLSelectNode* node = *iter; 2217 LLSelectNode* node = *iter;
2201 LLViewerObject* object = node->getObject(); 2218 LLViewerObject* object = node->getObject();
2202 if( !node->mValid ) 2219 if( !object || !node->mValid )
2203 { 2220 {
2204 return FALSE; 2221 return FALSE;
2205 } 2222 }
@@ -3259,7 +3276,7 @@ void LLSelectMgr::packBuyObjectIDs(LLSelectNode* node, void* data)
3259 { 3276 {
3260 buy->mObjectsSent.push_back(object); 3277 buy->mObjectsSent.push_back(object);
3261 gMessageSystem->nextBlockFast(_PREHASH_ObjectData); 3278 gMessageSystem->nextBlockFast(_PREHASH_ObjectData);
3262 gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, node->getObject()->getLocalID() ); 3279 gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, object->getLocalID() );
3263 gMessageSystem->addU8Fast(_PREHASH_SaleType, buy->mSaleInfo.getSaleType()); 3280 gMessageSystem->addU8Fast(_PREHASH_SaleType, buy->mSaleInfo.getSaleType());
3264 gMessageSystem->addS32Fast(_PREHASH_SalePrice, buy->mSaleInfo.getSalePrice()); 3281 gMessageSystem->addS32Fast(_PREHASH_SalePrice, buy->mSaleInfo.getSalePrice());
3265 } 3282 }
@@ -3690,6 +3707,10 @@ void LLSelectMgr::saveSelectedObjectTransform(EActionType action_type)
3690 virtual bool apply(LLSelectNode* selectNode) 3707 virtual bool apply(LLSelectNode* selectNode)
3691 { 3708 {
3692 LLViewerObject* object = selectNode->getObject(); 3709 LLViewerObject* object = selectNode->getObject();
3710 if (!object)
3711 {
3712 return true; // skip
3713 }
3693 selectNode->mSavedPositionLocal = object->getPosition(); 3714 selectNode->mSavedPositionLocal = object->getPosition();
3694 if (object->isAttachment()) 3715 if (object->isAttachment())
3695 { 3716 {
@@ -4020,7 +4041,10 @@ void LLSelectMgr::sendListToRegions(const LLString& message_name,
4020 push_all(std::queue<LLSelectNode*>& n) : nodes_to_send(n) {} 4041 push_all(std::queue<LLSelectNode*>& n) : nodes_to_send(n) {}
4021 virtual bool apply(LLSelectNode* node) 4042 virtual bool apply(LLSelectNode* node)
4022 { 4043 {
4023 nodes_to_send.push(node); 4044 if (node->getObject())
4045 {
4046 nodes_to_send.push(node);
4047 }
4024 return true; 4048 return true;
4025 } 4049 }
4026 }; 4050 };
@@ -4031,29 +4055,20 @@ void LLSelectMgr::sendListToRegions(const LLString& message_name,
4031 push_some(std::queue<LLSelectNode*>& n, bool roots) : nodes_to_send(n), mRoots(roots) {} 4055 push_some(std::queue<LLSelectNode*>& n, bool roots) : nodes_to_send(n), mRoots(roots) {}
4032 virtual bool apply(LLSelectNode* node) 4056 virtual bool apply(LLSelectNode* node)
4033 { 4057 {
4034 BOOL is_root = node->getObject()->isRootEdit(); 4058 if (node->getObject())
4035 if ((mRoots && is_root) || (!mRoots && !is_root))
4036 { 4059 {
4037 nodes_to_send.push(node); 4060 BOOL is_root = node->getObject()->isRootEdit();
4061 if ((mRoots && is_root) || (!mRoots && !is_root))
4062 {
4063 nodes_to_send.push(node);
4064 }
4038 } 4065 }
4039 return true; 4066 return true;
4040 } 4067 }
4041 }; 4068 };
4042 struct push_editable : public LLSelectedNodeFunctor
4043 {
4044 std::queue<LLSelectNode*>& nodes_to_send;
4045 push_editable(std::queue<LLSelectNode*>& n) : nodes_to_send(n) {}
4046 virtual bool apply(LLSelectNode* node)
4047 {
4048
4049 nodes_to_send.push(node);
4050 return true;
4051 }
4052 };
4053 struct push_all pushall(nodes_to_send); 4069 struct push_all pushall(nodes_to_send);
4054 struct push_some pushroots(nodes_to_send, TRUE); 4070 struct push_some pushroots(nodes_to_send, TRUE);
4055 struct push_some pushnonroots(nodes_to_send, FALSE); 4071 struct push_some pushnonroots(nodes_to_send, FALSE);
4056 struct push_editable pusheditable(nodes_to_send);
4057 4072
4058 switch(send_type) 4073 switch(send_type)
4059 { 4074 {
@@ -4061,7 +4076,7 @@ void LLSelectMgr::sendListToRegions(const LLString& message_name,
4061 if(message_name == "ObjectBuy") 4076 if(message_name == "ObjectBuy")
4062 getSelection()->applyToRootNodes(&pushroots); 4077 getSelection()->applyToRootNodes(&pushroots);
4063 else 4078 else
4064 getSelection()->applyToRootNodes(&pusheditable); 4079 getSelection()->applyToRootNodes(&pushall);
4065 4080
4066 break; 4081 break;
4067 case SEND_INDIVIDUALS: 4082 case SEND_INDIVIDUALS:
@@ -4125,7 +4140,7 @@ void LLSelectMgr::sendListToRegions(const LLString& message_name,
4125 } 4140 }
4126 else 4141 else
4127 { 4142 {
4128 node = nodes_to_send.front(); 4143 node = nodes_to_send.front();
4129 nodes_to_send.pop(); 4144 nodes_to_send.pop();
4130 } 4145 }
4131 } 4146 }
@@ -4265,7 +4280,7 @@ void LLSelectMgr::processObjectProperties(LLMessageSystem* msg, void** user_data
4265 f(const LLUUID& id) : mID(id) {} 4280 f(const LLUUID& id) : mID(id) {}
4266 virtual bool apply(LLSelectNode* node) 4281 virtual bool apply(LLSelectNode* node)
4267 { 4282 {
4268 return (node->getObject()->mID == mID); 4283 return (node->getObject() && node->getObject()->mID == mID);
4269 } 4284 }
4270 } func(id); 4285 } func(id);
4271 LLSelectNode* node = gSelectMgr->getSelection()->getFirstNode(&func); 4286 LLSelectNode* node = gSelectMgr->getSelection()->getFirstNode(&func);
@@ -4408,7 +4423,7 @@ void LLSelectMgr::processObjectPropertiesFamily(LLMessageSystem* msg, void** use
4408 f(const LLUUID& id) : mID(id) {} 4423 f(const LLUUID& id) : mID(id) {}
4409 virtual bool apply(LLSelectNode* node) 4424 virtual bool apply(LLSelectNode* node)
4410 { 4425 {
4411 return (node->getObject()->mID == mID); 4426 return (node->getObject() && node->getObject()->mID == mID);
4412 } 4427 }
4413 } func(id); 4428 } func(id);
4414 LLSelectNode* node = gSelectMgr->getHoverObjects()->getFirstNode(&func); 4429 LLSelectNode* node = gSelectMgr->getHoverObjects()->getFirstNode(&func);
@@ -4516,7 +4531,8 @@ void LLSelectMgr::updateSilhouettes()
4516 { 4531 {
4517 LLSelectNode* node = *iter; 4532 LLSelectNode* node = *iter;
4518 LLViewerObject* objectp = node->getObject(); 4533 LLViewerObject* objectp = node->getObject();
4519 4534 if (!objectp)
4535 continue;
4520 // do roots first, then children so that root flags are cleared ASAP 4536 // do roots first, then children so that root flags are cleared ASAP
4521 BOOL roots_only = (pass == 0); 4537 BOOL roots_only = (pass == 0);
4522 BOOL is_root = (objectp->isRootEdit()); 4538 BOOL is_root = (objectp->isRootEdit());
@@ -4589,6 +4605,8 @@ void LLSelectMgr::updateSilhouettes()
4589 { 4605 {
4590 LLSelectNode* node = *iter; 4606 LLSelectNode* node = *iter;
4591 LLViewerObject* objectp = node->getObject(); 4607 LLViewerObject* objectp = node->getObject();
4608 if (!objectp)
4609 continue;
4592 if (objectp->isRoot() || !select_linked_set) 4610 if (objectp->isRoot() || !select_linked_set)
4593 { 4611 {
4594 if (roots.count(objectp) == 0) 4612 if (roots.count(objectp) == 0)
@@ -4677,7 +4695,9 @@ void LLSelectMgr::updateSilhouettes()
4677 { 4695 {
4678 LLSelectNode* node = *iter; 4696 LLSelectNode* node = *iter;
4679 LLViewerObject* objectp = node->getObject(); 4697 LLViewerObject* objectp = node->getObject();
4680 4698 if (!objectp)
4699 continue;
4700
4681 // do roots first, then children so that root flags are cleared ASAP 4701 // do roots first, then children so that root flags are cleared ASAP
4682 BOOL roots_only = (pass == 0); 4702 BOOL roots_only = (pass == 0);
4683 BOOL is_root = objectp->isRootEdit(); 4703 BOOL is_root = objectp->isRootEdit();
@@ -4781,6 +4801,8 @@ void LLSelectMgr::renderSilhouettes(BOOL for_hud)
4781 { 4801 {
4782 LLSelectNode* node = *iter; 4802 LLSelectNode* node = *iter;
4783 LLViewerObject* objectp = node->getObject(); 4803 LLViewerObject* objectp = node->getObject();
4804 if (!objectp)
4805 continue;
4784 if (objectp->isHUDAttachment() != for_hud) 4806 if (objectp->isHUDAttachment() != for_hud)
4785 { 4807 {
4786 continue; 4808 continue;
@@ -4819,6 +4841,8 @@ void LLSelectMgr::renderSilhouettes(BOOL for_hud)
4819 { 4841 {
4820 LLSelectNode* node = *iter; 4842 LLSelectNode* node = *iter;
4821 LLViewerObject* objectp = node->getObject(); 4843 LLViewerObject* objectp = node->getObject();
4844 if (!objectp)
4845 continue;
4822 if (objectp->isHUDAttachment() != for_hud) 4846 if (objectp->isHUDAttachment() != for_hud)
4823 { 4847 {
4824 continue; 4848 continue;
@@ -5414,6 +5438,8 @@ void LLSelectMgr::updateSelectionCenter()
5414 { 5438 {
5415 LLSelectNode* node = *iter; 5439 LLSelectNode* node = *iter;
5416 LLViewerObject* object = node->getObject(); 5440 LLViewerObject* object = node->getObject();
5441 if (!object)
5442 continue;
5417 LLViewerObject *myAvatar = gAgent.getAvatarObject(); 5443 LLViewerObject *myAvatar = gAgent.getAvatarObject();
5418 LLViewerObject *root = object->getRootEdit(); 5444 LLViewerObject *root = object->getRootEdit();
5419 if (mSelectedObjects->mSelectType == SELECT_TYPE_WORLD && // not an attachment 5445 if (mSelectedObjects->mSelectType == SELECT_TYPE_WORLD && // not an attachment
@@ -5826,6 +5852,8 @@ S32 LLObjectSelection::getTECount()
5826 { 5852 {
5827 LLSelectNode* node = *iter; 5853 LLSelectNode* node = *iter;
5828 LLViewerObject* object = node->getObject(); 5854 LLViewerObject* object = node->getObject();
5855 if (!object)
5856 continue;
5829 S32 num_tes = object->getNumTEs(); 5857 S32 num_tes = object->getNumTEs();
5830 for (S32 te = 0; te < num_tes; te++) 5858 for (S32 te = 0; te < num_tes; te++)
5831 { 5859 {
@@ -5858,6 +5886,8 @@ bool LLObjectSelection::applyToObjects(LLSelectedObjectFunctor* func, bool first
5858 { 5886 {
5859 iterator nextiter = iter++; 5887 iterator nextiter = iter++;
5860 LLViewerObject* object = (*nextiter)->getObject(); 5888 LLViewerObject* object = (*nextiter)->getObject();
5889 if (!object)
5890 continue;
5861 bool r = func->apply(object); 5891 bool r = func->apply(object);
5862 if (firstonly && r) 5892 if (firstonly && r)
5863 return true; 5893 return true;
@@ -5874,6 +5904,8 @@ bool LLObjectSelection::applyToRootObjects(LLSelectedObjectFunctor* func, bool f
5874 { 5904 {
5875 root_iterator nextiter = iter++; 5905 root_iterator nextiter = iter++;
5876 LLViewerObject* object = (*nextiter)->getObject(); 5906 LLViewerObject* object = (*nextiter)->getObject();
5907 if (!object)
5908 continue;
5877 bool r = func->apply(object); 5909 bool r = func->apply(object);
5878 if (firstonly && r) 5910 if (firstonly && r)
5879 return true; 5911 return true;
@@ -5891,6 +5923,8 @@ bool LLObjectSelection::applyToTEs(LLSelectedTEFunctor* func, bool firstonly)
5891 iterator nextiter = iter++; 5923 iterator nextiter = iter++;
5892 LLSelectNode* node = *nextiter; 5924 LLSelectNode* node = *nextiter;
5893 LLViewerObject* object = (*nextiter)->getObject(); 5925 LLViewerObject* object = (*nextiter)->getObject();
5926 if (!object)
5927 continue;
5894 S32 num_tes = llmin((S32)object->getNumTEs(), (S32)object->getNumFaces()); // avatars have TEs but no faces 5928 S32 num_tes = llmin((S32)object->getNumTEs(), (S32)object->getNumFaces()); // avatars have TEs but no faces
5895 for (S32 te = 0; te < num_tes; ++te) 5929 for (S32 te = 0; te < num_tes; ++te)
5896 { 5930 {
@@ -6093,7 +6127,7 @@ LLSelectNode* LLObjectSelection::getFirstMoveableNode(BOOL get_root_first)
6093 bool apply(LLSelectNode* node) 6127 bool apply(LLSelectNode* node)
6094 { 6128 {
6095 LLViewerObject* obj = node->getObject(); 6129 LLViewerObject* obj = node->getObject();
6096 return obj->permMove(); 6130 return obj && obj->permMove();
6097 } 6131 }
6098 } func; 6132 } func;
6099 LLSelectNode* res = get_root_first ? getFirstRootNode(&func, TRUE) : getFirstNode(&func); 6133 LLSelectNode* res = get_root_first ? getFirstRootNode(&func, TRUE) : getFirstNode(&func);
@@ -6110,7 +6144,7 @@ LLViewerObject* LLObjectSelection::getFirstCopyableObject(BOOL get_parent)
6110 bool apply(LLSelectNode* node) 6144 bool apply(LLSelectNode* node)
6111 { 6145 {
6112 LLViewerObject* obj = node->getObject(); 6146 LLViewerObject* obj = node->getObject();
6113 return obj->permCopy() && !obj->isAttachment(); 6147 return obj && obj->permCopy() && !obj->isAttachment();
6114 } 6148 }
6115 } func; 6149 } func;
6116 return getFirstSelectedObject(&func, get_parent); 6150 return getFirstSelectedObject(&func, get_parent);
@@ -6131,10 +6165,9 @@ LLViewerObject* LLObjectSelection::getFirstDeleteableObject()
6131 LLViewerObject* obj = node->getObject(); 6165 LLViewerObject* obj = node->getObject();
6132 // you can delete an object if you are the owner 6166 // you can delete an object if you are the owner
6133 // or you have permission to modify it. 6167 // or you have permission to modify it.
6134 if( (obj->permModify()) 6168 if( obj && ( (obj->permModify()) ||
6135 || (obj->permYouOwner()) 6169 (obj->permYouOwner()) ||
6136 || (!obj->permAnyOwner()) // public 6170 (!obj->permAnyOwner()) )) // public
6137 )
6138 { 6171 {
6139 if( !obj->isAttachment() ) 6172 if( !obj->isAttachment() )
6140 { 6173 {
@@ -6158,7 +6191,7 @@ LLViewerObject* LLObjectSelection::getFirstEditableObject(BOOL get_parent)
6158 bool apply(LLSelectNode* node) 6191 bool apply(LLSelectNode* node)
6159 { 6192 {
6160 LLViewerObject* obj = node->getObject(); 6193 LLViewerObject* obj = node->getObject();
6161 return obj->permModify(); 6194 return obj && obj->permModify();
6162 } 6195 }
6163 } func; 6196 } func;
6164 return getFirstSelectedObject(&func, get_parent); 6197 return getFirstSelectedObject(&func, get_parent);
@@ -6174,7 +6207,7 @@ LLViewerObject* LLObjectSelection::getFirstMoveableObject(BOOL get_parent)
6174 bool apply(LLSelectNode* node) 6207 bool apply(LLSelectNode* node)
6175 { 6208 {
6176 LLViewerObject* obj = node->getObject(); 6209 LLViewerObject* obj = node->getObject();
6177 return obj->permMove(); 6210 return obj && obj->permMove();
6178 } 6211 }
6179 } func; 6212 } func;
6180 return getFirstSelectedObject(&func, get_parent); 6213 return getFirstSelectedObject(&func, get_parent);