aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llmaniprotate.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llmaniprotate.cpp')
-rw-r--r--linden/indra/newview/llmaniprotate.cpp121
1 files changed, 46 insertions, 75 deletions
diff --git a/linden/indra/newview/llmaniprotate.cpp b/linden/indra/newview/llmaniprotate.cpp
index b60e29a..11b5e8c 100644
--- a/linden/indra/newview/llmaniprotate.cpp
+++ b/linden/indra/newview/llmaniprotate.cpp
@@ -86,7 +86,7 @@ const F32 MANIPULATOR_SCALE_HALF_LIFE = 0.07f;
86extern void handle_reset_rotation(void*); // in LLViewerWindow 86extern void handle_reset_rotation(void*); // in LLViewerWindow
87 87
88LLManipRotate::LLManipRotate( LLToolComposite* composite ) 88LLManipRotate::LLManipRotate( LLToolComposite* composite )
89: LLManip( "Rotate", composite ), 89: LLManip( std::string("Rotate"), composite ),
90 mRotationCenter(), 90 mRotationCenter(),
91 mCenterScreen(), 91 mCenterScreen(),
92 mRotation(), 92 mRotation(),
@@ -98,7 +98,6 @@ LLManipRotate::LLManipRotate( LLToolComposite* composite )
98 mCenterToCamMag(0.f), 98 mCenterToCamMag(0.f),
99 mCenterToProfilePlane(), 99 mCenterToProfilePlane(),
100 mCenterToProfilePlaneMag(0.f), 100 mCenterToProfilePlaneMag(0.f),
101 mManipPart( LL_NO_PART ),
102 mSendUpdateOnMouseUp( FALSE ), 101 mSendUpdateOnMouseUp( FALSE ),
103 mSmoothRotate( FALSE ), 102 mSmoothRotate( FALSE ),
104 mCamEdgeOn(FALSE), 103 mCamEdgeOn(FALSE),
@@ -113,13 +112,6 @@ void LLManipRotate::handleSelect()
113 LLManip::handleSelect(); 112 LLManip::handleSelect();
114} 113}
115 114
116void LLManipRotate::handleDeselect()
117{
118 mHighlightedPart = LL_NO_PART;
119 mManipPart = LL_NO_PART;
120 LLManip::handleDeselect();
121}
122
123void LLManipRotate::render() 115void LLManipRotate::render()
124{ 116{
125 LLGLSUIDefault gls_ui; 117 LLGLSUIDefault gls_ui;
@@ -144,7 +136,7 @@ void LLManipRotate::render()
144 glPushMatrix(); 136 glPushMatrix();
145 if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD) 137 if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD)
146 { 138 {
147 F32 zoom = gAgent.getAvatarObject()->mHUDCurZoom; 139 F32 zoom = gAgent.mHUDCurZoom;
148 glScalef(zoom, zoom, zoom); 140 glScalef(zoom, zoom, zoom);
149 } 141 }
150 142
@@ -363,8 +355,7 @@ BOOL LLManipRotate::handleMouseDown(S32 x, S32 y, MASK mask)
363 LLViewerObject* first_object = mObjectSelection->getFirstMoveableObject(TRUE); 355 LLViewerObject* first_object = mObjectSelection->getFirstMoveableObject(TRUE);
364 if( first_object ) 356 if( first_object )
365 { 357 {
366 LLViewerObject* hit_obj = gViewerWindow->lastObjectHit(); 358 if( mHighlightedPart != LL_NO_PART )
367 if( hit_obj && mHighlightedPart != LL_NO_PART )
368 { 359 {
369 handled = handleMouseDownOnPart( x, y, mask ); 360 handled = handleMouseDownOnPart( x, y, mask );
370 } 361 }
@@ -457,6 +448,19 @@ BOOL LLManipRotate::handleMouseUp(S32 x, S32 y, MASK mask)
457 448
458 if( hasMouseCapture() ) 449 if( hasMouseCapture() )
459 { 450 {
451 for (LLObjectSelection::iterator iter = mObjectSelection->begin();
452 iter != mObjectSelection->end(); iter++)
453 {
454 LLSelectNode* selectNode = *iter;
455 LLViewerObject* object = selectNode->getObject();
456
457 // have permission to move and object is root of selection or individually selected
458 if (object->permMove() && (object->isRootEdit() || selectNode->mIndividualSelection))
459 {
460 object->mUnselectedChildrenPositions.clear() ;
461 }
462 }
463
460 mManipPart = LL_NO_PART; 464 mManipPart = LL_NO_PART;
461 465
462 // Might have missed last update due to timing. 466 // Might have missed last update due to timing.
@@ -553,16 +557,12 @@ void LLManipRotate::drag( S32 x, S32 y )
553 } 557 }
554 558
555 LLQuaternion new_rot = selectNode->mSavedRotation * mRotation; 559 LLQuaternion new_rot = selectNode->mSavedRotation * mRotation;
556 std::vector<LLVector3> child_positions; 560 std::vector<LLVector3>& child_positions = object->mUnselectedChildrenPositions ;
557 std::vector<LLQuaternion> child_rotations; 561 std::vector<LLQuaternion> child_rotations;
558 if (object->isRootEdit() && selectNode->mIndividualSelection) 562 if (object->isRootEdit() && selectNode->mIndividualSelection)
559 { 563 {
560 for (U32 i = 0; i < object->mChildList.size(); i++) 564 object->saveUnselectedChildrenRotation(child_rotations) ;
561 { 565 object->saveUnselectedChildrenPosition(child_positions) ;
562 LLViewerObject* childp = object->mChildList[i];
563 child_positions.push_back(childp->getPositionEdit());
564 child_rotations.push_back(childp->getRotationEdit());
565 }
566 } 566 }
567 567
568 if (object->getParent() && object->mDrawable.notNull()) 568 if (object->getParent() && object->mDrawable.notNull())
@@ -584,17 +584,7 @@ void LLManipRotate::drag( S32 x, S32 y )
584 { 584 {
585 //RN: must do non-damped updates on these objects so relative rotation appears constant 585 //RN: must do non-damped updates on these objects so relative rotation appears constant
586 // instead of having two competing slerps making the child objects appear to "wobble" 586 // instead of having two competing slerps making the child objects appear to "wobble"
587 for (U32 i = 0; i < object->mChildList.size(); i++) 587 object->resetChildrenRotationAndPosition(child_rotations, child_positions) ;
588 {
589 LLViewerObject* childp = object->mChildList[i];
590 LLVector3 child_offset = ((child_positions[i] - object->getPositionEdit()) * ~object->getRotationEdit()) - childp->getPosition();
591 if (!childp->isSelected() && childp->mDrawable.notNull())
592 {
593 childp->setRotation(child_rotations[i] * ~object->getRotationEdit());
594 childp->setPosition((child_positions[i] - object->getPositionEdit()) * ~object->getRotationEdit());
595 rebuild(childp);
596 }
597 }
598 } 588 }
599 } 589 }
600 } 590 }
@@ -676,28 +666,8 @@ void LLManipRotate::drag( S32 x, S32 y )
676 if (object->isRootEdit() && selectNode->mIndividualSelection) 666 if (object->isRootEdit() && selectNode->mIndividualSelection)
677 { 667 {
678 // only offset by parent's translation as we've already countered parent's rotation 668 // only offset by parent's translation as we've already countered parent's rotation
679 LLVector3 child_offset;
680 if (object->isAttachment() && object->mDrawable.notNull())
681 {
682 LLXform* attachment_point_xform = object->mDrawable->getXform()->getParent();
683 LLQuaternion parent_rotation = object->getRotation() * attachment_point_xform->getWorldRotation();
684 child_offset = LLVector3(old_position - new_position) * ~parent_rotation;
685 }
686 else
687 {
688 child_offset = LLVector3(old_position - new_position) * ~object->getRenderRotation();
689 }
690
691 rebuild(object); 669 rebuild(object);
692 for (U32 i = 0; i < object->mChildList.size(); i++) 670 object->resetChildrenPosition(old_position - new_position) ;
693 {
694 LLViewerObject* childp = object->mChildList[i];
695 if (!childp->isSelected() && childp->mDrawable.notNull())
696 {
697 childp->setPosition(childp->getPosition() + child_offset);
698 rebuild(childp);
699 }
700 }
701 } 671 }
702 } 672 }
703 } 673 }
@@ -926,6 +896,7 @@ void LLManipRotate::renderSnapGuides()
926 } 896 }
927 gGL.end(); 897 gGL.end();
928 898
899 // *TODO: Translate
929 //RN: text rendering does own shadow pass, so only render once 900 //RN: text rendering does own shadow pass, so only render once
930 if (pass == 1 && render_text && i % 16 == 0) 901 if (pass == 1 && render_text && i % 16 == 0)
931 { 902 {
@@ -933,32 +904,32 @@ void LLManipRotate::renderSnapGuides()
933 { 904 {
934 if (i == 0) 905 if (i == 0)
935 { 906 {
936 renderTickText(text_point, mObjectSelection->isAttachment() ? "Forward" : "East", LLColor4::white); 907 renderTickText(text_point, mObjectSelection->isAttachment() ? std::string("Forward") : std::string("East"), LLColor4::white);
937 } 908 }
938 else if (i == 16) 909 else if (i == 16)
939 { 910 {
940 if (constraint_axis.mV[VZ] > 0.f) 911 if (constraint_axis.mV[VZ] > 0.f)
941 { 912 {
942 renderTickText(text_point, mObjectSelection->isAttachment() ? "Left" : "North", LLColor4::white); 913 renderTickText(text_point, mObjectSelection->isAttachment() ? std::string("Left") : std::string("North"), LLColor4::white);
943 } 914 }
944 else 915 else
945 { 916 {
946 renderTickText(text_point, mObjectSelection->isAttachment() ? "Right" : "South", LLColor4::white); 917 renderTickText(text_point, mObjectSelection->isAttachment() ? std::string("Right") : std::string("South"), LLColor4::white);
947 } 918 }
948 } 919 }
949 else if (i == 32) 920 else if (i == 32)
950 { 921 {
951 renderTickText(text_point, mObjectSelection->isAttachment() ? "Back" : "West", LLColor4::white); 922 renderTickText(text_point, mObjectSelection->isAttachment() ? std::string("Back") : std::string("West"), LLColor4::white);
952 } 923 }
953 else 924 else
954 { 925 {
955 if (constraint_axis.mV[VZ] > 0.f) 926 if (constraint_axis.mV[VZ] > 0.f)
956 { 927 {
957 renderTickText(text_point, mObjectSelection->isAttachment() ? "Right" : "South", LLColor4::white); 928 renderTickText(text_point, mObjectSelection->isAttachment() ? std::string("Right") : std::string("South"), LLColor4::white);
958 } 929 }
959 else 930 else
960 { 931 {
961 renderTickText(text_point, mObjectSelection->isAttachment() ? "Left" : "North", LLColor4::white); 932 renderTickText(text_point, mObjectSelection->isAttachment() ? std::string("Left") : std::string("North"), LLColor4::white);
962 } 933 }
963 } 934 }
964 } 935 }
@@ -966,32 +937,32 @@ void LLManipRotate::renderSnapGuides()
966 { 937 {
967 if (i == 0) 938 if (i == 0)
968 { 939 {
969 renderTickText(text_point, mObjectSelection->isAttachment() ? "Left" : "North", LLColor4::white); 940 renderTickText(text_point, mObjectSelection->isAttachment() ? std::string("Left") : std::string("North"), LLColor4::white);
970 } 941 }
971 else if (i == 16) 942 else if (i == 16)
972 { 943 {
973 if (constraint_axis.mV[VX] > 0.f) 944 if (constraint_axis.mV[VX] > 0.f)
974 { 945 {
975 renderTickText(text_point, "Up", LLColor4::white); 946 renderTickText(text_point, std::string("Up"), LLColor4::white);
976 } 947 }
977 else 948 else
978 { 949 {
979 renderTickText(text_point, "Down", LLColor4::white); 950 renderTickText(text_point, std::string("Down"), LLColor4::white);
980 } 951 }
981 } 952 }
982 else if (i == 32) 953 else if (i == 32)
983 { 954 {
984 renderTickText(text_point, mObjectSelection->isAttachment() ? "Right" : "South", LLColor4::white); 955 renderTickText(text_point, mObjectSelection->isAttachment() ? std::string("Right") : std::string("South"), LLColor4::white);
985 } 956 }
986 else 957 else
987 { 958 {
988 if (constraint_axis.mV[VX] > 0.f) 959 if (constraint_axis.mV[VX] > 0.f)
989 { 960 {
990 renderTickText(text_point, "Down", LLColor4::white); 961 renderTickText(text_point, std::string("Down"), LLColor4::white);
991 } 962 }
992 else 963 else
993 { 964 {
994 renderTickText(text_point, "Up", LLColor4::white); 965 renderTickText(text_point, std::string("Up"), LLColor4::white);
995 } 966 }
996 } 967 }
997 } 968 }
@@ -999,32 +970,32 @@ void LLManipRotate::renderSnapGuides()
999 { 970 {
1000 if (i == 0) 971 if (i == 0)
1001 { 972 {
1002 renderTickText(text_point, "Up", LLColor4::white); 973 renderTickText(text_point, std::string("Up"), LLColor4::white);
1003 } 974 }
1004 else if (i == 16) 975 else if (i == 16)
1005 { 976 {
1006 if (constraint_axis.mV[VY] > 0.f) 977 if (constraint_axis.mV[VY] > 0.f)
1007 { 978 {
1008 renderTickText(text_point, mObjectSelection->isAttachment() ? "Forward" : "East", LLColor4::white); 979 renderTickText(text_point, mObjectSelection->isAttachment() ? std::string("Forward") : std::string("East"), LLColor4::white);
1009 } 980 }
1010 else 981 else
1011 { 982 {
1012 renderTickText(text_point, mObjectSelection->isAttachment() ? "Back" : "West", LLColor4::white); 983 renderTickText(text_point, mObjectSelection->isAttachment() ? std::string("Back") : std::string("West"), LLColor4::white);
1013 } 984 }
1014 } 985 }
1015 else if (i == 32) 986 else if (i == 32)
1016 { 987 {
1017 renderTickText(text_point, "Down", LLColor4::white); 988 renderTickText(text_point, std::string("Down"), LLColor4::white);
1018 } 989 }
1019 else 990 else
1020 { 991 {
1021 if (constraint_axis.mV[VY] > 0.f) 992 if (constraint_axis.mV[VY] > 0.f)
1022 { 993 {
1023 renderTickText(text_point, mObjectSelection->isAttachment() ? "Back" : "West", LLColor4::white); 994 renderTickText(text_point, mObjectSelection->isAttachment() ? std::string("Back") : std::string("West"), LLColor4::white);
1024 } 995 }
1025 else 996 else
1026 { 997 {
1027 renderTickText(text_point, mObjectSelection->isAttachment() ? "Forward" : "East", LLColor4::white); 998 renderTickText(text_point, mObjectSelection->isAttachment() ? std::string("Forward") : std::string("East"), LLColor4::white);
1028 } 999 }
1029 } 1000 }
1030 } 1001 }
@@ -1125,18 +1096,18 @@ BOOL LLManipRotate::updateVisiblity()
1125 LLVector3 center = gAgent.getPosAgentFromGlobal( mRotationCenter ); 1096 LLVector3 center = gAgent.getPosAgentFromGlobal( mRotationCenter );
1126 if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD) 1097 if (mObjectSelection->getSelectType() == SELECT_TYPE_HUD)
1127 { 1098 {
1128 mCenterToCam = LLVector3(-1.f / gAgent.getAvatarObject()->mHUDCurZoom, 0.f, 0.f); 1099 mCenterToCam = LLVector3(-1.f / gAgent.mHUDCurZoom, 0.f, 0.f);
1129 mCenterToCamNorm = mCenterToCam; 1100 mCenterToCamNorm = mCenterToCam;
1130 mCenterToCamMag = mCenterToCamNorm.normVec(); 1101 mCenterToCamMag = mCenterToCamNorm.normVec();
1131 1102
1132 mRadiusMeters = RADIUS_PIXELS / (F32) LLViewerCamera::getInstance()->getViewHeightInPixels(); 1103 mRadiusMeters = RADIUS_PIXELS / (F32) LLViewerCamera::getInstance()->getViewHeightInPixels();
1133 mRadiusMeters /= gAgent.getAvatarObject()->mHUDCurZoom; 1104 mRadiusMeters /= gAgent.mHUDCurZoom;
1134 1105
1135 mCenterToProfilePlaneMag = mRadiusMeters * mRadiusMeters / mCenterToCamMag; 1106 mCenterToProfilePlaneMag = mRadiusMeters * mRadiusMeters / mCenterToCamMag;
1136 mCenterToProfilePlane = -mCenterToProfilePlaneMag * mCenterToCamNorm; 1107 mCenterToProfilePlane = -mCenterToProfilePlaneMag * mCenterToCamNorm;
1137 1108
1138 mCenterScreen.set((S32)((0.5f - mRotationCenter.mdV[VY]) / gAgent.getAvatarObject()->mHUDCurZoom * gViewerWindow->getWindowWidth()), 1109 mCenterScreen.set((S32)((0.5f - mRotationCenter.mdV[VY]) / gAgent.mHUDCurZoom * gViewerWindow->getWindowWidth()),
1139 (S32)((mRotationCenter.mdV[VZ] + 0.5f) / gAgent.getAvatarObject()->mHUDCurZoom * gViewerWindow->getWindowHeight())); 1110 (S32)((mRotationCenter.mdV[VZ] + 0.5f) / gAgent.mHUDCurZoom * gViewerWindow->getWindowHeight()));
1140 visible = TRUE; 1111 visible = TRUE;
1141 } 1112 }
1142 else 1113 else
@@ -1652,8 +1623,8 @@ void LLManipRotate::mouseToRay( S32 x, S32 y, LLVector3* ray_pt, LLVector3* ray_
1652{ 1623{
1653 if (LLSelectMgr::getInstance()->getSelection()->getSelectType() == SELECT_TYPE_HUD) 1624 if (LLSelectMgr::getInstance()->getSelection()->getSelectType() == SELECT_TYPE_HUD)
1654 { 1625 {
1655 F32 mouse_x = (((F32)x / gViewerWindow->getWindowWidth()) - 0.5f) / gAgent.getAvatarObject()->mHUDCurZoom; 1626 F32 mouse_x = (((F32)x / gViewerWindow->getWindowWidth()) - 0.5f) / gAgent.mHUDCurZoom;
1656 F32 mouse_y = ((((F32)y) / gViewerWindow->getWindowHeight()) - 0.5f) / gAgent.getAvatarObject()->mHUDCurZoom; 1627 F32 mouse_y = ((((F32)y) / gViewerWindow->getWindowHeight()) - 0.5f) / gAgent.mHUDCurZoom;
1657 1628
1658 *ray_pt = LLVector3(-1.f, -mouse_x, mouse_y); 1629 *ray_pt = LLVector3(-1.f, -mouse_x, mouse_y);
1659 *ray_dir = LLVector3(1.f, 0.f, 0.f); 1630 *ray_dir = LLVector3(1.f, 0.f, 0.f);