summaryrefslogtreecommitdiff
path: root/indra/newview/llmanipscale.cpp
diff options
context:
space:
mode:
authorRichard Nelson <richard@lindenlab.com>2007-02-17 03:02:16 +0000
committerRichard Nelson <richard@lindenlab.com>2007-02-17 03:02:16 +0000
commit73bc0fb42b5bcd80030d9f30d5cb57ec2397ba08 (patch)
treee7c0b2e22d4719123fd688e49a16b76a084c3f77 /indra/newview/llmanipscale.cpp
parent12ac04231b8d358e70c830f7958f7efbc0f7c0d1 (diff)
merge -r 56779:58057 /branches/selection_management
Diffstat (limited to 'indra/newview/llmanipscale.cpp')
-rw-r--r--indra/newview/llmanipscale.cpp52
1 files changed, 28 insertions, 24 deletions
diff --git a/indra/newview/llmanipscale.cpp b/indra/newview/llmanipscale.cpp
index 2b5926514e..cec8ff0b13 100644
--- a/indra/newview/llmanipscale.cpp
+++ b/indra/newview/llmanipscale.cpp
@@ -140,6 +140,7 @@ void LLManipScale::handleSelect()
updateSnapGuides(bbox);
gSelectMgr->saveSelectedObjectTransform(SELECT_ACTION_TYPE_PICK);
gFloaterTools->setStatusText("Click and drag to stretch selected side");
+ LLManip::handleSelect();
}
void LLManipScale::handleDeselect()
@@ -147,6 +148,7 @@ void LLManipScale::handleDeselect()
mHighlightedPart = LL_NO_PART;
mManipPart = LL_NO_PART;
gFloaterTools->setStatusText("");
+ LLManip::handleDeselect();
}
BOOL sort_manip_by_z(LLManipScale::ManipulatorHandle *new_manip, LLManipScale::ManipulatorHandle *test_manip)
@@ -196,7 +198,7 @@ void LLManipScale::render()
{
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
- if (gSelectMgr->getSelectType() == SELECT_TYPE_HUD)
+ if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD)
{
F32 zoom = gAgent.getAvatarObject()->mHUDCurZoom;
glScalef(zoom, zoom, zoom);
@@ -212,7 +214,7 @@ void LLManipScale::render()
F32 range;
F32 range_from_agent;
- if (gSelectMgr->getSelectType() == SELECT_TYPE_HUD)
+ if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD)
{
mBoxHandleSize = BOX_HANDLE_BASE_SIZE * BOX_HANDLE_BASE_FACTOR / (F32) gCamera->getViewHeightInPixels();
mBoxHandleSize /= gAgent.getAvatarObject()->mHUDCurZoom;
@@ -311,10 +313,10 @@ BOOL LLManipScale::handleMouseDown(S32 x, S32 y, MASK mask)
// Assumes that one of the arrows on an object was hit.
BOOL LLManipScale::handleMouseDownOnPart( S32 x, S32 y, MASK mask )
{
- BOOL can_scale = gSelectMgr->getObjectCount() != 0;
- for (LLViewerObject* objectp = gSelectMgr->getFirstObject();
+ BOOL can_scale = mObjectSelection->getObjectCount() != 0;
+ for (LLViewerObject* objectp = mObjectSelection->getFirstObject();
objectp;
- objectp = gSelectMgr->getNextObject())
+ objectp = mObjectSelection->getNextObject())
{
can_scale = can_scale && objectp->permModify() && objectp->permMove() && !objectp->isSeat();
}
@@ -377,7 +379,7 @@ BOOL LLManipScale::handleHover(S32 x, S32 y, MASK mask)
{
if( hasMouseCapture() )
{
- if( gSelectMgr->isEmpty() )
+ if( mObjectSelection->isEmpty() )
{
// Somehow the object got deselected while we were dragging it.
setMouseCapture( FALSE );
@@ -413,7 +415,7 @@ void LLManipScale::highlightManipulators(S32 x, S32 y)
if( isSelectionScalable() )
{
LLMatrix4 transform;
- if (gSelectMgr->getSelectType() == SELECT_TYPE_HUD)
+ if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD)
{
LLVector4 translation(bbox.getPositionAgent());
transform.initRotTrans(bbox.getRotation(), translation);
@@ -454,7 +456,7 @@ void LLManipScale::highlightManipulators(S32 x, S32 y)
mManipulatorVertices[numManips++] = LLVector4(max.mV[VX], max.mV[VY], max.mV[VZ], 1.f);
// 1-D highlights are applicable iff one object is selected
- if( gSelectMgr->getObjectCount() == 1 )
+ if( mObjectSelection->getObjectCount() == 1 )
{
// face centers
mManipulatorVertices[numManips++] = LLVector4(ctr.mV[VX], ctr.mV[VY], max.mV[VZ], 1.f);
@@ -520,7 +522,7 @@ void LLManipScale::renderFaces( const LLBBox& bbox )
{
// Don't bother to render the drag handles for 1-D scaling if
// more than one object is selected or if it is an attachment
- if ( gSelectMgr->getObjectCount() > 1 )
+ if ( mObjectSelection->getObjectCount() > 1 )
{
return;
}
@@ -926,7 +928,7 @@ void LLManipScale::dragCorner( S32 x, S32 y )
// find max and min scale factors that will make biggest object hit max absolute scale and smallest object hit min absolute scale
LLSelectNode* selectNode;
- for( selectNode = gSelectMgr->getFirstNode(); selectNode; selectNode = gSelectMgr->getNextNode() )
+ for( selectNode = mObjectSelection->getFirstNode(); selectNode; selectNode = mObjectSelection->getNextNode() )
{
LLViewerObject* cur = selectNode->getObject();
if( cur->permModify() && cur->permMove() && !cur->isAvatar() )
@@ -946,7 +948,7 @@ void LLManipScale::dragCorner( S32 x, S32 y )
LLVector3d drag_global = uniform ? mDragStartCenterGlobal : mDragFarHitGlobal;
// do the root objects i.e. (TRUE == cur->isRootEdit())
- for( selectNode = gSelectMgr->getFirstNode(); selectNode; selectNode = gSelectMgr->getNextNode() )
+ for( selectNode = mObjectSelection->getFirstNode(); selectNode; selectNode = mObjectSelection->getNextNode() )
{
LLViewerObject* cur = selectNode->getObject();
if( cur->permModify() && cur->permMove() && !cur->isAvatar() && cur->isRootEdit() )
@@ -990,7 +992,7 @@ void LLManipScale::dragCorner( S32 x, S32 y )
}
}
// do the child objects i.e. (FALSE == cur->isRootEdit())
- for( selectNode = gSelectMgr->getFirstNode(); selectNode; selectNode = gSelectMgr->getNextNode() )
+ for( selectNode = mObjectSelection->getFirstNode(); selectNode; selectNode = mObjectSelection->getNextNode() )
{
LLViewerObject*cur = selectNode->getObject();
if( cur->permModify() && cur->permMove() && !cur->isAvatar() && !cur->isRootEdit() )
@@ -1209,7 +1211,7 @@ void LLManipScale::stretchFace( const LLVector3& drag_start_agent, const LLVecto
LLVector3 drag_start_center_agent = gAgent.getPosAgentFromGlobal(mDragStartCenterGlobal);
LLSelectNode *selectNode;
- for( selectNode = gSelectMgr->getFirstNode(); selectNode; selectNode = gSelectMgr->getNextNode() )
+ for( selectNode = mObjectSelection->getFirstNode(); selectNode; selectNode = mObjectSelection->getNextNode() )
{
LLViewerObject*cur = selectNode->getObject();
if( cur->permModify() && cur->permMove() && !cur->isAvatar() )
@@ -1330,7 +1332,7 @@ void LLManipScale::updateSnapGuides(const LLBBox& bbox)
mScaleDir = box_corner_agent - mScaleCenter;
mScaleDir.normVec();
- if(gSelectMgr->getSelectType() == SELECT_TYPE_HUD)
+ if(mObjectSelection->getSelectType() == SELECT_TYPE_HUD)
{
mSnapRegimeOffset = SNAP_GUIDE_SCREEN_OFFSET / gAgent.getAvatarObject()->mHUDCurZoom;
@@ -1342,7 +1344,7 @@ void LLManipScale::updateSnapGuides(const LLBBox& bbox)
}
LLVector3 cam_at_axis;
F32 snap_guide_length;
- if (gSelectMgr->getSelectType() == SELECT_TYPE_HUD)
+ if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD)
{
cam_at_axis.setVec(1.f, 0.f, 0.f);
snap_guide_length = SNAP_GUIDE_SCREEN_LENGTH / gAgent.getAvatarObject()->mHUDCurZoom;
@@ -1389,7 +1391,7 @@ void LLManipScale::updateSnapGuides(const LLBBox& bbox)
{
LLVector3 local_scale_dir = partToUnitVector( mManipPart );
LLVector3 local_camera_dir;
- if (gSelectMgr->getSelectType() == SELECT_TYPE_HUD)
+ if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD)
{
local_camera_dir = LLVector3(-1.f, 0.f, 0.f) * ~bbox.getRotation();
}
@@ -1668,7 +1670,7 @@ void LLManipScale::renderSnapGuides(const LLBBox& bbox)
start_tick = -(llmin(ticks_from_scale_center_1, num_ticks_per_side1));
stop_tick = llmin(max_ticks1, num_ticks_per_side1);
- F32 grid_resolution = gSelectMgr->getSelectType() == SELECT_TYPE_HUD ? 0.25f : llmax(gSavedSettings.getF32("GridResolution"), 0.001f);
+ F32 grid_resolution = mObjectSelection->getSelectType() == SELECT_TYPE_HUD ? 0.25f : llmax(gSavedSettings.getF32("GridResolution"), 0.001f);
S32 label_sub_div_offset_1 = llround(fmod(dist_grid_axis - grid_offset1, mScaleSnapUnit1 * 32.f) / (mScaleSnapUnit1 / max_subdivisions));
S32 label_sub_div_offset_2 = llround(fmod(dist_grid_axis - grid_offset2, mScaleSnapUnit2 * 32.f) / (mScaleSnapUnit2 / max_subdivisions));
@@ -1774,7 +1776,7 @@ void LLManipScale::renderSnapGuides(const LLBBox& bbox)
// render help text
- if (gSelectMgr->getSelectType() != SELECT_TYPE_HUD)
+ if (mObjectSelection->getSelectType() != SELECT_TYPE_HUD)
{
if (mHelpTextTimer.getElapsedTimeF32() < sHelpTextVisibleTime + sHelpTextFadeTime && sNumTimesHelpTextShown < sMaxTimesShowHelpText)
{
@@ -1796,10 +1798,10 @@ void LLManipScale::renderSnapGuides(const LLBBox& bbox)
std::string help_text = "Move mouse cursor over ruler";
LLColor4 help_text_color = LLColor4::white;
help_text_color.mV[VALPHA] = clamp_rescale(mHelpTextTimer.getElapsedTimeF32(), sHelpTextVisibleTime, sHelpTextVisibleTime + sHelpTextFadeTime, grid_alpha, 0.f);
- hud_render_utf8text(help_text, help_text_pos, *big_fontp, LLFontGL::NORMAL, -0.5f * big_fontp->getWidthF32(help_text), 3.f, help_text_color, gSelectMgr->getSelectType() == SELECT_TYPE_HUD);
+ hud_render_utf8text(help_text, help_text_pos, *big_fontp, LLFontGL::NORMAL, -0.5f * big_fontp->getWidthF32(help_text), 3.f, help_text_color, mObjectSelection->getSelectType() == SELECT_TYPE_HUD);
help_text = "to snap to grid";
help_text_pos -= gCamera->getUpAxis() * mSnapRegimeOffset * 0.4f;
- hud_render_utf8text(help_text, help_text_pos, *big_fontp, LLFontGL::NORMAL, -0.5f * big_fontp->getWidthF32(help_text), 3.f, help_text_color, gSelectMgr->getSelectType() == SELECT_TYPE_HUD);
+ hud_render_utf8text(help_text, help_text_pos, *big_fontp, LLFontGL::NORMAL, -0.5f * big_fontp->getWidthF32(help_text), 3.f, help_text_color, mObjectSelection->getSelectType() == SELECT_TYPE_HUD);
}
}
}
@@ -2003,14 +2005,16 @@ LLVector3 LLManipScale::nearestAxis( const LLVector3& v ) const
return LLVector3( coords[greatest_index] );
}
-BOOL LLManipScale::isSelectionScalable() const
+//FIXME: make this const once we switch to iterator interface
+//(making object traversal a const-able operation)
+BOOL LLManipScale::isSelectionScalable()
{
// An selection is scalable if you are allowed to both edit and move
// everything in it, and it does not have any sitting agents
- BOOL scalable = gSelectMgr->getFirstObject() ? TRUE : FALSE;
- for(LLViewerObject* cur = gSelectMgr->getFirstObject();
+ BOOL scalable = mObjectSelection->getFirstObject() ? TRUE : FALSE;
+ for(LLViewerObject* cur = mObjectSelection->getFirstObject();
cur;
- cur = gSelectMgr->getNextObject() )
+ cur = mObjectSelection->getNextObject() )
{
if( !(cur->permModify() && cur->permMove())
|| cur->isSeat())