diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llmanipscale.cpp | 116 |
1 files changed, 59 insertions, 57 deletions
diff --git a/linden/indra/newview/llmanipscale.cpp b/linden/indra/newview/llmanipscale.cpp index c130824..a67e3fc 100644 --- a/linden/indra/newview/llmanipscale.cpp +++ b/linden/indra/newview/llmanipscale.cpp | |||
@@ -2,6 +2,8 @@ | |||
2 | * @file llmanipscale.cpp | 2 | * @file llmanipscale.cpp |
3 | * @brief LLManipScale class implementation | 3 | * @brief LLManipScale class implementation |
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ | ||
6 | * | ||
5 | * Copyright (c) 2001-2007, Linden Research, Inc. | 7 | * Copyright (c) 2001-2007, Linden Research, Inc. |
6 | * | 8 | * |
7 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
@@ -24,6 +26,7 @@ | |||
24 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | 26 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO |
25 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | 27 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, |
26 | * COMPLETENESS OR PERFORMANCE. | 28 | * COMPLETENESS OR PERFORMANCE. |
29 | * $/LicenseInfo$ | ||
27 | */ | 30 | */ |
28 | 31 | ||
29 | #include "llviewerprecompiledheaders.h" | 32 | #include "llviewerprecompiledheaders.h" |
@@ -159,7 +162,7 @@ void LLManipScale::handleSelect() | |||
159 | LLBBox bbox = gSelectMgr->getBBoxOfSelection(); | 162 | LLBBox bbox = gSelectMgr->getBBoxOfSelection(); |
160 | updateSnapGuides(bbox); | 163 | updateSnapGuides(bbox); |
161 | gSelectMgr->saveSelectedObjectTransform(SELECT_ACTION_TYPE_PICK); | 164 | gSelectMgr->saveSelectedObjectTransform(SELECT_ACTION_TYPE_PICK); |
162 | gFloaterTools->setStatusText("Click and drag to stretch selected side"); | 165 | gFloaterTools->setStatusText("scale"); |
163 | LLManip::handleSelect(); | 166 | LLManip::handleSelect(); |
164 | } | 167 | } |
165 | 168 | ||
@@ -167,7 +170,6 @@ void LLManipScale::handleDeselect() | |||
167 | { | 170 | { |
168 | mHighlightedPart = LL_NO_PART; | 171 | mHighlightedPart = LL_NO_PART; |
169 | mManipPart = LL_NO_PART; | 172 | mManipPart = LL_NO_PART; |
170 | gFloaterTools->setStatusText(""); | ||
171 | LLManip::handleDeselect(); | 173 | LLManip::handleDeselect(); |
172 | } | 174 | } |
173 | 175 | ||
@@ -182,7 +184,6 @@ LLManipScale::LLManipScale( LLToolComposite* composite ) | |||
182 | mBoxHandleSize( 1.f ), | 184 | mBoxHandleSize( 1.f ), |
183 | mScaledBoxHandleSize( 1.f ), | 185 | mScaledBoxHandleSize( 1.f ), |
184 | mManipPart( LL_NO_PART ), | 186 | mManipPart( LL_NO_PART ), |
185 | mHighlightedPart( LL_NO_PART ), | ||
186 | mLastMouseX( -1 ), | 187 | mLastMouseX( -1 ), |
187 | mLastMouseY( -1 ), | 188 | mLastMouseY( -1 ), |
188 | mSendUpdateOnMouseUp( FALSE ), | 189 | mSendUpdateOnMouseUp( FALSE ), |
@@ -214,7 +215,7 @@ void LLManipScale::render() | |||
214 | LLGLEnable gl_blend(GL_BLEND); | 215 | LLGLEnable gl_blend(GL_BLEND); |
215 | LLGLEnable gls_alpha_test(GL_ALPHA_TEST); | 216 | LLGLEnable gls_alpha_test(GL_ALPHA_TEST); |
216 | 217 | ||
217 | if( isSelectionScalable() ) | 218 | if( canAffectSelection() ) |
218 | { | 219 | { |
219 | glMatrixMode(GL_MODELVIEW); | 220 | glMatrixMode(GL_MODELVIEW); |
220 | glPushMatrix(); | 221 | glPushMatrix(); |
@@ -333,14 +334,7 @@ BOOL LLManipScale::handleMouseDown(S32 x, S32 y, MASK mask) | |||
333 | // Assumes that one of the arrows on an object was hit. | 334 | // Assumes that one of the arrows on an object was hit. |
334 | BOOL LLManipScale::handleMouseDownOnPart( S32 x, S32 y, MASK mask ) | 335 | BOOL LLManipScale::handleMouseDownOnPart( S32 x, S32 y, MASK mask ) |
335 | { | 336 | { |
336 | BOOL can_scale = mObjectSelection->getObjectCount() != 0; | 337 | BOOL can_scale = canAffectSelection(); |
337 | for (LLViewerObject* objectp = mObjectSelection->getFirstObject(); | ||
338 | objectp; | ||
339 | objectp = mObjectSelection->getNextObject()) | ||
340 | { | ||
341 | can_scale = can_scale && objectp->permModify() && objectp->permMove() && !objectp->isSeat(); | ||
342 | } | ||
343 | |||
344 | if (!can_scale) | 338 | if (!can_scale) |
345 | { | 339 | { |
346 | return FALSE; | 340 | return FALSE; |
@@ -380,29 +374,32 @@ BOOL LLManipScale::handleMouseUp(S32 x, S32 y, MASK mask) | |||
380 | // first, perform normal processing in case this was a quick-click | 374 | // first, perform normal processing in case this was a quick-click |
381 | handleHover(x, y, mask); | 375 | handleHover(x, y, mask); |
382 | 376 | ||
383 | if( (LL_FACE_MIN <= (S32)mManipPart) | 377 | if( hasMouseCapture() ) |
384 | && ((S32)mManipPart <= LL_FACE_MAX) ) | ||
385 | { | ||
386 | sendUpdates(TRUE,TRUE,FALSE); | ||
387 | } | ||
388 | else | ||
389 | if( (LL_CORNER_MIN <= (S32)mManipPart) | ||
390 | && ((S32)mManipPart <= LL_CORNER_MAX) ) | ||
391 | { | 378 | { |
392 | sendUpdates(TRUE,TRUE,TRUE); | 379 | if( (LL_FACE_MIN <= (S32)mManipPart) |
393 | } | 380 | && ((S32)mManipPart <= LL_FACE_MAX) ) |
394 | 381 | { | |
395 | //send texture update | 382 | sendUpdates(TRUE,TRUE,FALSE); |
396 | gSelectMgr->adjustTexturesByScale(TRUE, getStretchTextures()); | 383 | } |
397 | 384 | else | |
398 | gSelectMgr->enableSilhouette(TRUE); | 385 | if( (LL_CORNER_MIN <= (S32)mManipPart) |
399 | mManipPart = LL_NO_PART; | 386 | && ((S32)mManipPart <= LL_CORNER_MAX) ) |
387 | { | ||
388 | sendUpdates(TRUE,TRUE,TRUE); | ||
389 | } | ||
390 | |||
391 | //send texture update | ||
392 | gSelectMgr->adjustTexturesByScale(TRUE, getStretchTextures()); | ||
393 | |||
394 | gSelectMgr->enableSilhouette(TRUE); | ||
395 | mManipPart = LL_NO_PART; | ||
400 | 396 | ||
401 | // Might have missed last update due to UPDATE_DELAY timing | 397 | // Might have missed last update due to UPDATE_DELAY timing |
402 | gSelectMgr->sendMultipleUpdate( mLastUpdateFlags ); | 398 | gSelectMgr->sendMultipleUpdate( mLastUpdateFlags ); |
403 | 399 | ||
404 | //gAgent.setObjectTracking(gSavedSettings.getBOOL("TrackFocusObject")); | 400 | //gAgent.setObjectTracking(gSavedSettings.getBOOL("TrackFocusObject")); |
405 | gSelectMgr->saveSelectedObjectTransform(SELECT_ACTION_TYPE_PICK); | 401 | gSelectMgr->saveSelectedObjectTransform(SELECT_ACTION_TYPE_PICK); |
402 | } | ||
406 | return LLManip::handleMouseUp(x, y, mask); | 403 | return LLManip::handleMouseUp(x, y, mask); |
407 | } | 404 | } |
408 | 405 | ||
@@ -444,7 +441,7 @@ void LLManipScale::highlightManipulators(S32 x, S32 y) | |||
444 | // Don't do this with nothing selected, as it kills the framerate. | 441 | // Don't do this with nothing selected, as it kills the framerate. |
445 | LLBBox bbox = gSelectMgr->getBBoxOfSelection(); | 442 | LLBBox bbox = gSelectMgr->getBBoxOfSelection(); |
446 | 443 | ||
447 | if( isSelectionScalable() ) | 444 | if( canAffectSelection() ) |
448 | { | 445 | { |
449 | LLMatrix4 transform; | 446 | LLMatrix4 transform; |
450 | if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD) | 447 | if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD) |
@@ -824,10 +821,10 @@ void LLManipScale::drag( S32 x, S32 y ) | |||
824 | } | 821 | } |
825 | 822 | ||
826 | // store changes to override updates | 823 | // store changes to override updates |
827 | for (LLSelectNode* selectNode = gSelectMgr->getSelection()->getFirstNode(); | 824 | for (LLObjectSelection::iterator iter = gSelectMgr->getSelection()->begin(); |
828 | selectNode != NULL; | 825 | iter != gSelectMgr->getSelection()->end(); iter++) |
829 | selectNode = gSelectMgr->getSelection()->getNextNode()) | ||
830 | { | 826 | { |
827 | LLSelectNode* selectNode = *iter; | ||
831 | LLViewerObject*cur = selectNode->getObject(); | 828 | LLViewerObject*cur = selectNode->getObject(); |
832 | if( cur->permModify() && cur->permMove() && !cur->isAvatar()) | 829 | if( cur->permModify() && cur->permMove() && !cur->isAvatar()) |
833 | { | 830 | { |
@@ -971,9 +968,10 @@ void LLManipScale::dragCorner( S32 x, S32 y ) | |||
971 | F32 min_scale_factor = MIN_OBJECT_SCALE / MAX_OBJECT_SCALE; | 968 | F32 min_scale_factor = MIN_OBJECT_SCALE / MAX_OBJECT_SCALE; |
972 | 969 | ||
973 | // find max and min scale factors that will make biggest object hit max absolute scale and smallest object hit min absolute scale | 970 | // find max and min scale factors that will make biggest object hit max absolute scale and smallest object hit min absolute scale |
974 | LLSelectNode* selectNode; | 971 | for (LLObjectSelection::iterator iter = mObjectSelection->begin(); |
975 | for( selectNode = mObjectSelection->getFirstNode(); selectNode; selectNode = mObjectSelection->getNextNode() ) | 972 | iter != mObjectSelection->end(); iter++) |
976 | { | 973 | { |
974 | LLSelectNode* selectNode = *iter; | ||
977 | LLViewerObject* cur = selectNode->getObject(); | 975 | LLViewerObject* cur = selectNode->getObject(); |
978 | if( cur->permModify() && cur->permMove() && !cur->isAvatar() ) | 976 | if( cur->permModify() && cur->permMove() && !cur->isAvatar() ) |
979 | { | 977 | { |
@@ -992,8 +990,10 @@ void LLManipScale::dragCorner( S32 x, S32 y ) | |||
992 | LLVector3d drag_global = uniform ? mDragStartCenterGlobal : mDragFarHitGlobal; | 990 | LLVector3d drag_global = uniform ? mDragStartCenterGlobal : mDragFarHitGlobal; |
993 | 991 | ||
994 | // do the root objects i.e. (TRUE == cur->isRootEdit()) | 992 | // do the root objects i.e. (TRUE == cur->isRootEdit()) |
995 | for( selectNode = mObjectSelection->getFirstNode(); selectNode; selectNode = mObjectSelection->getNextNode() ) | 993 | for (LLObjectSelection::iterator iter = mObjectSelection->begin(); |
994 | iter != mObjectSelection->end(); iter++) | ||
996 | { | 995 | { |
996 | LLSelectNode* selectNode = *iter; | ||
997 | LLViewerObject* cur = selectNode->getObject(); | 997 | LLViewerObject* cur = selectNode->getObject(); |
998 | if( cur->permModify() && cur->permMove() && !cur->isAvatar() && cur->isRootEdit() ) | 998 | if( cur->permModify() && cur->permMove() && !cur->isAvatar() && cur->isRootEdit() ) |
999 | { | 999 | { |
@@ -1036,8 +1036,10 @@ void LLManipScale::dragCorner( S32 x, S32 y ) | |||
1036 | } | 1036 | } |
1037 | } | 1037 | } |
1038 | // do the child objects i.e. (FALSE == cur->isRootEdit()) | 1038 | // do the child objects i.e. (FALSE == cur->isRootEdit()) |
1039 | for( selectNode = mObjectSelection->getFirstNode(); selectNode; selectNode = mObjectSelection->getNextNode() ) | 1039 | for (LLObjectSelection::iterator iter = mObjectSelection->begin(); |
1040 | iter != mObjectSelection->end(); iter++) | ||
1040 | { | 1041 | { |
1042 | LLSelectNode* selectNode = *iter; | ||
1041 | LLViewerObject*cur = selectNode->getObject(); | 1043 | LLViewerObject*cur = selectNode->getObject(); |
1042 | if( cur->permModify() && cur->permMove() && !cur->isAvatar() && !cur->isRootEdit() ) | 1044 | if( cur->permModify() && cur->permMove() && !cur->isAvatar() && !cur->isRootEdit() ) |
1043 | { | 1045 | { |
@@ -1242,9 +1244,10 @@ void LLManipScale::stretchFace( const LLVector3& drag_start_agent, const LLVecto | |||
1242 | { | 1244 | { |
1243 | LLVector3 drag_start_center_agent = gAgent.getPosAgentFromGlobal(mDragStartCenterGlobal); | 1245 | LLVector3 drag_start_center_agent = gAgent.getPosAgentFromGlobal(mDragStartCenterGlobal); |
1244 | 1246 | ||
1245 | LLSelectNode *selectNode; | 1247 | for (LLObjectSelection::iterator iter = mObjectSelection->begin(); |
1246 | for( selectNode = mObjectSelection->getFirstNode(); selectNode; selectNode = mObjectSelection->getNextNode() ) | 1248 | iter != mObjectSelection->end(); iter++) |
1247 | { | 1249 | { |
1250 | LLSelectNode* selectNode = *iter; | ||
1248 | LLViewerObject*cur = selectNode->getObject(); | 1251 | LLViewerObject*cur = selectNode->getObject(); |
1249 | if( cur->permModify() && cur->permMove() && !cur->isAvatar() ) | 1252 | if( cur->permModify() && cur->permMove() && !cur->isAvatar() ) |
1250 | { | 1253 | { |
@@ -2037,23 +2040,22 @@ LLVector3 LLManipScale::nearestAxis( const LLVector3& v ) const | |||
2037 | return LLVector3( coords[greatest_index] ); | 2040 | return LLVector3( coords[greatest_index] ); |
2038 | } | 2041 | } |
2039 | 2042 | ||
2040 | //FIXME: make this const once we switch to iterator interface | 2043 | // virtual |
2041 | //(making object traversal a const-able operation) | 2044 | BOOL LLManipScale::canAffectSelection() |
2042 | BOOL LLManipScale::isSelectionScalable() | ||
2043 | { | 2045 | { |
2044 | // An selection is scalable if you are allowed to both edit and move | 2046 | // An selection is scalable if you are allowed to both edit and move |
2045 | // everything in it, and it does not have any sitting agents | 2047 | // everything in it, and it does not have any sitting agents |
2046 | BOOL scalable = mObjectSelection->getFirstObject() ? TRUE : FALSE; | 2048 | BOOL can_scale = mObjectSelection->getObjectCount() != 0; |
2047 | for(LLViewerObject* cur = mObjectSelection->getFirstObject(); | 2049 | if (can_scale) |
2048 | cur; | ||
2049 | cur = mObjectSelection->getNextObject() ) | ||
2050 | { | 2050 | { |
2051 | if( !(cur->permModify() && cur->permMove()) | 2051 | struct f : public LLSelectedObjectFunctor |
2052 | || cur->isSeat()) | ||
2053 | { | 2052 | { |
2054 | scalable = FALSE; | 2053 | virtual bool apply(LLViewerObject* objectp) |
2055 | break; | 2054 | { |
2056 | } | 2055 | return objectp->permModify() && objectp->permMove() && !objectp->isSeat(); |
2057 | } | 2056 | } |
2058 | return scalable; | 2057 | } func; |
2058 | can_scale = mObjectSelection->applyToObjects(&func); | ||
2059 | } | ||
2060 | return can_scale; | ||
2059 | } | 2061 | } |