diff options
Diffstat (limited to 'indra/newview/llselectmgr.cpp')
-rw-r--r-- | indra/newview/llselectmgr.cpp | 116 |
1 files changed, 76 insertions, 40 deletions
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp index ba2434d7b0..c2dfd779a3 100644 --- a/indra/newview/llselectmgr.cpp +++ b/indra/newview/llselectmgr.cpp @@ -83,6 +83,7 @@ #include "llglheaders.h" +LLViewerObject* getSelectedParentObject(LLViewerObject *object) ; // // Consts // @@ -259,7 +260,7 @@ void LLSelectMgr::overrideObjectUpdates() virtual bool apply(LLSelectNode* selectNode) { LLViewerObject* object = selectNode->getObject(); - if (object->permMove()) + if (object && object->permMove()) { if (!selectNode->mLastPositionLocal.isExactlyZero()) { @@ -1035,10 +1036,19 @@ void LLSelectMgr::getGrid(LLVector3& origin, LLQuaternion &rotation, LLVector3 & if (mGridMode == GRID_MODE_LOCAL && mSelectedObjects->getObjectCount()) { + LLViewerObject* root = getSelectedParentObject(mSelectedObjects->getFirstObject()); LLBBox bbox = mSavedSelectionBBox; mGridOrigin = mSavedSelectionBBox.getCenterAgent(); - mGridRotation = mSavedSelectionBBox.getRotation(); mGridScale = mSavedSelectionBBox.getExtentLocal() * 0.5f; + + if(mSelectedObjects->getObjectCount() < 2 || !root || root->mDrawable.isNull()) + { + mGridRotation = mSavedSelectionBBox.getRotation(); + } + else //set to the root object + { + mGridRotation = root->getRenderRotation(); + } } else if (mGridMode == GRID_MODE_REF_OBJECT && first_grid_object && first_grid_object->mDrawable.notNull()) { @@ -1314,6 +1324,8 @@ void LLSelectMgr::dump() { LLSelectNode* node = *iter; LLViewerObject* objectp = node->getObject(); + if (!objectp) + continue; for (S32 te = 0; te < objectp->getNumTEs(); ++te ) { if (node->isTESelected(te)) @@ -2096,6 +2108,11 @@ void LLSelectMgr::adjustTexturesByScale(BOOL send_to_sim, BOOL stretch) LLSelectNode* selectNode = *iter; LLViewerObject* object = selectNode->getObject(); + if (!object) + { + continue; + } + if (!object->permModify()) { continue; @@ -2196,7 +2213,7 @@ BOOL LLSelectMgr::selectGetModify() { LLSelectNode* node = *iter; LLViewerObject* object = node->getObject(); - if( !node->mValid ) + if( !object || !node->mValid ) { return FALSE; } @@ -3256,7 +3273,7 @@ void LLSelectMgr::packBuyObjectIDs(LLSelectNode* node, void* data) { buy->mObjectsSent.push_back(object); gMessageSystem->nextBlockFast(_PREHASH_ObjectData); - gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, node->getObject()->getLocalID() ); + gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, object->getLocalID() ); gMessageSystem->addU8Fast(_PREHASH_SaleType, buy->mSaleInfo.getSaleType()); gMessageSystem->addS32Fast(_PREHASH_SalePrice, buy->mSaleInfo.getSalePrice()); } @@ -3717,6 +3734,10 @@ void LLSelectMgr::saveSelectedObjectTransform(EActionType action_type) virtual bool apply(LLSelectNode* selectNode) { LLViewerObject* object = selectNode->getObject(); + if (!object) + { + return true; // skip + } selectNode->mSavedPositionLocal = object->getPosition(); if (object->isAttachment()) { @@ -4047,7 +4068,10 @@ void LLSelectMgr::sendListToRegions(const LLString& message_name, push_all(std::queue<LLSelectNode*>& n) : nodes_to_send(n) {} virtual bool apply(LLSelectNode* node) { - nodes_to_send.push(node); + if (node->getObject()) + { + nodes_to_send.push(node); + } return true; } }; @@ -4058,29 +4082,20 @@ void LLSelectMgr::sendListToRegions(const LLString& message_name, push_some(std::queue<LLSelectNode*>& n, bool roots) : nodes_to_send(n), mRoots(roots) {} virtual bool apply(LLSelectNode* node) { - BOOL is_root = node->getObject()->isRootEdit(); - if ((mRoots && is_root) || (!mRoots && !is_root)) + if (node->getObject()) { - nodes_to_send.push(node); + BOOL is_root = node->getObject()->isRootEdit(); + if ((mRoots && is_root) || (!mRoots && !is_root)) + { + nodes_to_send.push(node); + } } return true; } }; - struct push_editable : public LLSelectedNodeFunctor - { - std::queue<LLSelectNode*>& nodes_to_send; - push_editable(std::queue<LLSelectNode*>& n) : nodes_to_send(n) {} - virtual bool apply(LLSelectNode* node) - { - - nodes_to_send.push(node); - return true; - } - }; struct push_all pushall(nodes_to_send); struct push_some pushroots(nodes_to_send, TRUE); struct push_some pushnonroots(nodes_to_send, FALSE); - struct push_editable pusheditable(nodes_to_send); switch(send_type) { @@ -4088,7 +4103,7 @@ void LLSelectMgr::sendListToRegions(const LLString& message_name, if(message_name == "ObjectBuy") getSelection()->applyToRootNodes(&pushroots); else - getSelection()->applyToRootNodes(&pusheditable); + getSelection()->applyToRootNodes(&pushall); break; case SEND_INDIVIDUALS: @@ -4152,7 +4167,7 @@ void LLSelectMgr::sendListToRegions(const LLString& message_name, } else { - node = nodes_to_send.front(); + node = nodes_to_send.front(); nodes_to_send.pop(); } } @@ -4292,7 +4307,7 @@ void LLSelectMgr::processObjectProperties(LLMessageSystem* msg, void** user_data f(const LLUUID& id) : mID(id) {} virtual bool apply(LLSelectNode* node) { - return (node->getObject()->mID == mID); + return (node->getObject() && node->getObject()->mID == mID); } } func(id); LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstNode(&func); @@ -4435,7 +4450,7 @@ void LLSelectMgr::processObjectPropertiesFamily(LLMessageSystem* msg, void** use f(const LLUUID& id) : mID(id) {} virtual bool apply(LLSelectNode* node) { - return (node->getObject()->mID == mID); + return (node->getObject() && node->getObject()->mID == mID); } } func(id); LLSelectNode* node = LLSelectMgr::getInstance()->getHoverObjects()->getFirstNode(&func); @@ -4541,7 +4556,8 @@ void LLSelectMgr::updateSilhouettes() { LLSelectNode* node = *iter; LLViewerObject* objectp = node->getObject(); - + if (!objectp) + continue; // do roots first, then children so that root flags are cleared ASAP BOOL roots_only = (pass == 0); BOOL is_root = (objectp->isRootEdit()); @@ -4614,6 +4630,8 @@ void LLSelectMgr::updateSilhouettes() { LLSelectNode* node = *iter; LLViewerObject* objectp = node->getObject(); + if (!objectp) + continue; if (objectp->isRoot() || !select_linked_set) { if (roots.count(objectp) == 0) @@ -4657,14 +4675,14 @@ void LLSelectMgr::updateSilhouettes() iter != roots.end(); iter++) { LLViewerObject* objectp = *iter; - LLSelectNode* rect_select_root_node = new LLSelectNode(objectp, TRUE); - rect_select_root_node->selectAllTEs(TRUE); - if (!canSelectObject(objectp)) { continue; } + LLSelectNode* rect_select_root_node = new LLSelectNode(objectp, TRUE); + rect_select_root_node->selectAllTEs(TRUE); + if (!select_linked_set) { rect_select_root_node->mIndividualSelection = TRUE; @@ -4702,7 +4720,9 @@ void LLSelectMgr::updateSilhouettes() { LLSelectNode* node = *iter; LLViewerObject* objectp = node->getObject(); - + if (!objectp) + continue; + // do roots first, then children so that root flags are cleared ASAP BOOL roots_only = (pass == 0); BOOL is_root = objectp->isRootEdit(); @@ -4806,6 +4826,8 @@ void LLSelectMgr::renderSilhouettes(BOOL for_hud) { LLSelectNode* node = *iter; LLViewerObject* objectp = node->getObject(); + if (!objectp) + continue; if (objectp->isHUDAttachment() != for_hud) { continue; @@ -4844,6 +4866,8 @@ void LLSelectMgr::renderSilhouettes(BOOL for_hud) { LLSelectNode* node = *iter; LLViewerObject* objectp = node->getObject(); + if (!objectp) + continue; if (objectp->isHUDAttachment() != for_hud) { continue; @@ -5439,6 +5463,8 @@ void LLSelectMgr::updateSelectionCenter() { LLSelectNode* node = *iter; LLViewerObject* object = node->getObject(); + if (!object) + continue; LLViewerObject *myAvatar = gAgent.getAvatarObject(); LLViewerObject *root = object->getRootEdit(); if (mSelectedObjects->mSelectType == SELECT_TYPE_WORLD && // not an attachment @@ -5665,6 +5691,12 @@ void LLSelectMgr::validateSelection() BOOL LLSelectMgr::canSelectObject(LLViewerObject* object) { + // Never select dead objects + if (!object || object->isDead()) + { + return FALSE; + } + if (mForceSelection) { return TRUE; @@ -5677,9 +5709,6 @@ BOOL LLSelectMgr::canSelectObject(LLViewerObject* object) return FALSE; } - // Can't select dead objects - if (object->isDead()) return FALSE; - // Can't select orphans if (object->isOrphaned()) return FALSE; @@ -5851,6 +5880,8 @@ S32 LLObjectSelection::getTECount() { LLSelectNode* node = *iter; LLViewerObject* object = node->getObject(); + if (!object) + continue; S32 num_tes = object->getNumTEs(); for (S32 te = 0; te < num_tes; te++) { @@ -5883,6 +5914,8 @@ bool LLObjectSelection::applyToObjects(LLSelectedObjectFunctor* func, bool first { iterator nextiter = iter++; LLViewerObject* object = (*nextiter)->getObject(); + if (!object) + continue; bool r = func->apply(object); if (firstonly && r) return true; @@ -5899,6 +5932,8 @@ bool LLObjectSelection::applyToRootObjects(LLSelectedObjectFunctor* func, bool f { root_iterator nextiter = iter++; LLViewerObject* object = (*nextiter)->getObject(); + if (!object) + continue; bool r = func->apply(object); if (firstonly && r) return true; @@ -5916,6 +5951,8 @@ bool LLObjectSelection::applyToTEs(LLSelectedTEFunctor* func, bool firstonly) iterator nextiter = iter++; LLSelectNode* node = *nextiter; LLViewerObject* object = (*nextiter)->getObject(); + if (!object) + continue; S32 num_tes = llmin((S32)object->getNumTEs(), (S32)object->getNumFaces()); // avatars have TEs but no faces for (S32 te = 0; te < num_tes; ++te) { @@ -6118,7 +6155,7 @@ LLSelectNode* LLObjectSelection::getFirstMoveableNode(BOOL get_root_first) bool apply(LLSelectNode* node) { LLViewerObject* obj = node->getObject(); - return obj->permMove(); + return obj && obj->permMove(); } } func; LLSelectNode* res = get_root_first ? getFirstRootNode(&func, TRUE) : getFirstNode(&func); @@ -6135,7 +6172,7 @@ LLViewerObject* LLObjectSelection::getFirstCopyableObject(BOOL get_parent) bool apply(LLSelectNode* node) { LLViewerObject* obj = node->getObject(); - return obj->permCopy() && !obj->isAttachment(); + return obj && obj->permCopy() && !obj->isAttachment(); } } func; return getFirstSelectedObject(&func, get_parent); @@ -6156,10 +6193,9 @@ LLViewerObject* LLObjectSelection::getFirstDeleteableObject() LLViewerObject* obj = node->getObject(); // you can delete an object if you are the owner // or you have permission to modify it. - if( (obj->permModify()) - || (obj->permYouOwner()) - || (!obj->permAnyOwner()) // public - ) + if( obj && ( (obj->permModify()) || + (obj->permYouOwner()) || + (!obj->permAnyOwner()) )) // public { if( !obj->isAttachment() ) { @@ -6183,7 +6219,7 @@ LLViewerObject* LLObjectSelection::getFirstEditableObject(BOOL get_parent) bool apply(LLSelectNode* node) { LLViewerObject* obj = node->getObject(); - return obj->permModify(); + return obj && obj->permModify(); } } func; return getFirstSelectedObject(&func, get_parent); @@ -6199,7 +6235,7 @@ LLViewerObject* LLObjectSelection::getFirstMoveableObject(BOOL get_parent) bool apply(LLSelectNode* node) { LLViewerObject* obj = node->getObject(); - return obj->permMove(); + return obj && obj->permMove(); } } func; return getFirstSelectedObject(&func, get_parent); |