diff options
Diffstat (limited to 'linden/indra/newview/llselectmgr.cpp')
-rw-r--r-- | linden/indra/newview/llselectmgr.cpp | 288 |
1 files changed, 254 insertions, 34 deletions
diff --git a/linden/indra/newview/llselectmgr.cpp b/linden/indra/newview/llselectmgr.cpp index 366f770..e13d8ea 100644 --- a/linden/indra/newview/llselectmgr.cpp +++ b/linden/indra/newview/llselectmgr.cpp | |||
@@ -101,7 +101,6 @@ extern LLVector3d gLastHitObjectOffset; | |||
101 | // | 101 | // |
102 | // Globals | 102 | // Globals |
103 | // | 103 | // |
104 | LLSelectMgr* gSelectMgr = NULL; | ||
105 | 104 | ||
106 | BOOL gDebugSelectMgr = FALSE; | 105 | BOOL gDebugSelectMgr = FALSE; |
107 | 106 | ||
@@ -157,8 +156,6 @@ static LLPointer<LLObjectSelection> sNullSelection; | |||
157 | 156 | ||
158 | void LLSelectMgr::cleanupGlobals() | 157 | void LLSelectMgr::cleanupGlobals() |
159 | { | 158 | { |
160 | delete gSelectMgr; | ||
161 | gSelectMgr = NULL; | ||
162 | sNullSelection = NULL; | 159 | sNullSelection = NULL; |
163 | } | 160 | } |
164 | 161 | ||
@@ -507,7 +504,7 @@ BOOL LLSelectMgr::removeObjectFromSelections(const LLUUID &id) | |||
507 | LLTool *tool = NULL; | 504 | LLTool *tool = NULL; |
508 | if (!gNoRender) | 505 | if (!gNoRender) |
509 | { | 506 | { |
510 | tool = gToolMgr->getCurrentTool(); | 507 | tool = LLToolMgr::getInstance()->getCurrentTool(); |
511 | 508 | ||
512 | // It's possible that the tool is editing an object that is not selected | 509 | // It's possible that the tool is editing an object that is not selected |
513 | LLViewerObject* tool_editing_object = tool->getEditingObject(); | 510 | LLViewerObject* tool_editing_object = tool->getEditingObject(); |
@@ -1432,7 +1429,7 @@ void LLSelectMgr::selectionSetImage(const LLUUID& imageid) | |||
1432 | { | 1429 | { |
1433 | object->sendTEUpdate(); | 1430 | object->sendTEUpdate(); |
1434 | // 1 particle effect per object | 1431 | // 1 particle effect per object |
1435 | LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)gHUDManager->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BEAM, TRUE); | 1432 | LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_BEAM, TRUE); |
1436 | effectp->setSourceObject(gAgent.getAvatarObject()); | 1433 | effectp->setSourceObject(gAgent.getAvatarObject()); |
1437 | effectp->setTargetObject(object); | 1434 | effectp->setTargetObject(object); |
1438 | effectp->setDuration(LL_HUD_DUR_SHORT); | 1435 | effectp->setDuration(LL_HUD_DUR_SHORT); |
@@ -2787,28 +2784,28 @@ void LLSelectMgr::confirmDelete(S32 option, void* data) | |||
2787 | LLUUID trash_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_TRASH); | 2784 | LLUUID trash_id = gInventory.findCategoryUUIDForType(LLAssetType::AT_TRASH); |
2788 | // attempt to derez into the trash. | 2785 | // attempt to derez into the trash. |
2789 | LLDeRezInfo* info = new LLDeRezInfo(DRD_TRASH, trash_id); | 2786 | LLDeRezInfo* info = new LLDeRezInfo(DRD_TRASH, trash_id); |
2790 | gSelectMgr->sendListToRegions("DeRezObject", | 2787 | LLSelectMgr::getInstance()->sendListToRegions("DeRezObject", |
2791 | packDeRezHeader, | 2788 | packDeRezHeader, |
2792 | packObjectLocalID, | 2789 | packObjectLocalID, |
2793 | (void*)info, | 2790 | (void*)info, |
2794 | SEND_ONLY_ROOTS); | 2791 | SEND_ONLY_ROOTS); |
2795 | // VEFFECT: Delete Object - one effect for all deletes | 2792 | // VEFFECT: Delete Object - one effect for all deletes |
2796 | if (gSelectMgr->mSelectedObjects->mSelectType != SELECT_TYPE_HUD) | 2793 | if (LLSelectMgr::getInstance()->mSelectedObjects->mSelectType != SELECT_TYPE_HUD) |
2797 | { | 2794 | { |
2798 | LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)gHUDManager->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINT, TRUE); | 2795 | LLHUDEffectSpiral *effectp = (LLHUDEffectSpiral *)LLHUDManager::getInstance()->createViewerEffect(LLHUDObject::LL_HUD_EFFECT_POINT, TRUE); |
2799 | effectp->setPositionGlobal( gSelectMgr->getSelectionCenterGlobal() ); | 2796 | effectp->setPositionGlobal( LLSelectMgr::getInstance()->getSelectionCenterGlobal() ); |
2800 | effectp->setColor(LLColor4U(gAgent.getEffectColor())); | 2797 | effectp->setColor(LLColor4U(gAgent.getEffectColor())); |
2801 | F32 duration = 0.5f; | 2798 | F32 duration = 0.5f; |
2802 | duration += gSelectMgr->mSelectedObjects->getObjectCount() / 64.f; | 2799 | duration += LLSelectMgr::getInstance()->mSelectedObjects->getObjectCount() / 64.f; |
2803 | effectp->setDuration(duration); | 2800 | effectp->setDuration(duration); |
2804 | } | 2801 | } |
2805 | 2802 | ||
2806 | gAgent.setLookAt(LOOKAT_TARGET_CLEAR); | 2803 | gAgent.setLookAt(LOOKAT_TARGET_CLEAR); |
2807 | 2804 | ||
2808 | // Keep track of how many objects have been deleted. | 2805 | // Keep track of how many objects have been deleted. |
2809 | F64 obj_delete_count = gViewerStats->getStat(LLViewerStats::ST_OBJECT_DELETE_COUNT); | 2806 | F64 obj_delete_count = LLViewerStats::getInstance()->getStat(LLViewerStats::ST_OBJECT_DELETE_COUNT); |
2810 | obj_delete_count += gSelectMgr->mSelectedObjects->getObjectCount(); | 2807 | obj_delete_count += LLSelectMgr::getInstance()->mSelectedObjects->getObjectCount(); |
2811 | gViewerStats->setStat(LLViewerStats::ST_OBJECT_DELETE_COUNT, obj_delete_count ); | 2808 | LLViewerStats::getInstance()->setStat(LLViewerStats::ST_OBJECT_DELETE_COUNT, obj_delete_count ); |
2812 | } | 2809 | } |
2813 | break; | 2810 | break; |
2814 | case 1: | 2811 | case 1: |
@@ -3360,6 +3357,36 @@ void LLSelectMgr::deselectAll() | |||
3360 | updatePointAt(); | 3357 | updatePointAt(); |
3361 | } | 3358 | } |
3362 | 3359 | ||
3360 | void LLSelectMgr::deselectAllForStandingUp() | ||
3361 | { | ||
3362 | /* | ||
3363 | This function is similar deselectAll() except for the first if statement | ||
3364 | which was removed. This is needed as a workaround for DEV-2854 | ||
3365 | */ | ||
3366 | |||
3367 | // Zap the angular velocity, as the sim will set it to zero | ||
3368 | for (LLObjectSelection::iterator iter = mSelectedObjects->begin(); | ||
3369 | iter != mSelectedObjects->end(); iter++ ) | ||
3370 | { | ||
3371 | LLViewerObject *objectp = (*iter)->getObject(); | ||
3372 | objectp->setAngularVelocity( 0,0,0 ); | ||
3373 | objectp->setVelocity( 0,0,0 ); | ||
3374 | } | ||
3375 | |||
3376 | sendListToRegions( | ||
3377 | "ObjectDeselect", | ||
3378 | packAgentAndSessionID, | ||
3379 | packObjectLocalID, | ||
3380 | NULL, | ||
3381 | SEND_INDIVIDUALS); | ||
3382 | |||
3383 | removeAll(); | ||
3384 | |||
3385 | mLastSentSelectionCenterGlobal.clearVec(); | ||
3386 | |||
3387 | updatePointAt(); | ||
3388 | } | ||
3389 | |||
3363 | void LLSelectMgr::deselectUnused() | 3390 | void LLSelectMgr::deselectUnused() |
3364 | { | 3391 | { |
3365 | // no more outstanding references to this selection | 3392 | // no more outstanding references to this selection |
@@ -3496,7 +3523,7 @@ void LLSelectMgr::sendAttach(U8 attachment_point) | |||
3496 | return; | 3523 | return; |
3497 | } | 3524 | } |
3498 | 3525 | ||
3499 | BOOL build_mode = gToolMgr->inEdit(); | 3526 | BOOL build_mode = LLToolMgr::getInstance()->inEdit(); |
3500 | // Special case: Attach to default location for this object. | 3527 | // Special case: Attach to default location for this object. |
3501 | if (0 == attachment_point || | 3528 | if (0 == attachment_point || |
3502 | get_if_there(gAgent.getAvatarObject()->mAttachmentPoints, (S32)attachment_point, (LLViewerJointAttachment*)NULL)) | 3529 | get_if_there(gAgent.getAvatarObject()->mAttachmentPoints, (S32)attachment_point, (LLViewerJointAttachment*)NULL)) |
@@ -4283,7 +4310,7 @@ void LLSelectMgr::processObjectProperties(LLMessageSystem* msg, void** user_data | |||
4283 | return (node->getObject() && node->getObject()->mID == mID); | 4310 | return (node->getObject() && node->getObject()->mID == mID); |
4284 | } | 4311 | } |
4285 | } func(id); | 4312 | } func(id); |
4286 | LLSelectNode* node = gSelectMgr->getSelection()->getFirstNode(&func); | 4313 | LLSelectNode* node = LLSelectMgr::getInstance()->getSelection()->getFirstNode(&func); |
4287 | 4314 | ||
4288 | if (node) | 4315 | if (node) |
4289 | { | 4316 | { |
@@ -4426,7 +4453,7 @@ void LLSelectMgr::processObjectPropertiesFamily(LLMessageSystem* msg, void** use | |||
4426 | return (node->getObject() && node->getObject()->mID == mID); | 4453 | return (node->getObject() && node->getObject()->mID == mID); |
4427 | } | 4454 | } |
4428 | } func(id); | 4455 | } func(id); |
4429 | LLSelectNode* node = gSelectMgr->getHoverObjects()->getFirstNode(&func); | 4456 | LLSelectNode* node = LLSelectMgr::getInstance()->getHoverObjects()->getFirstNode(&func); |
4430 | 4457 | ||
4431 | if (node) | 4458 | if (node) |
4432 | { | 4459 | { |
@@ -4452,7 +4479,7 @@ void LLSelectMgr::processForceObjectSelect(LLMessageSystem* msg, void**) | |||
4452 | 4479 | ||
4453 | if (reset_list) | 4480 | if (reset_list) |
4454 | { | 4481 | { |
4455 | gSelectMgr->deselectAll(); | 4482 | LLSelectMgr::getInstance()->deselectAll(); |
4456 | } | 4483 | } |
4457 | 4484 | ||
4458 | LLUUID full_id; | 4485 | LLUUID full_id; |
@@ -4478,7 +4505,7 @@ void LLSelectMgr::processForceObjectSelect(LLMessageSystem* msg, void**) | |||
4478 | } | 4505 | } |
4479 | 4506 | ||
4480 | // Don't select, just highlight | 4507 | // Don't select, just highlight |
4481 | gSelectMgr->highlightObjectAndFamily(objects); | 4508 | LLSelectMgr::getInstance()->highlightObjectAndFamily(objects); |
4482 | } | 4509 | } |
4483 | 4510 | ||
4484 | 4511 | ||
@@ -4493,9 +4520,7 @@ void LLSelectMgr::updateSilhouettes() | |||
4493 | 4520 | ||
4494 | if (!mSilhouetteImagep) | 4521 | if (!mSilhouetteImagep) |
4495 | { | 4522 | { |
4496 | LLUUID id; | 4523 | mSilhouetteImagep = gImageList.getImageFromFile("silhouette.j2c", TRUE, TRUE); |
4497 | id.set( gViewerArt.getString("silhouette.tga") ); | ||
4498 | mSilhouetteImagep = gImageList.getImage(id, TRUE, TRUE); | ||
4499 | } | 4524 | } |
4500 | 4525 | ||
4501 | mHighlightedObjects->cleanupNodes(); | 4526 | mHighlightedObjects->cleanupNodes(); |
@@ -4547,7 +4572,7 @@ void LLSelectMgr::updateSilhouettes() | |||
4547 | { | 4572 | { |
4548 | if (num_sils_genned++ < MAX_SILS_PER_FRAME)// && objectp->mDrawable->isVisible()) | 4573 | if (num_sils_genned++ < MAX_SILS_PER_FRAME)// && objectp->mDrawable->isVisible()) |
4549 | { | 4574 | { |
4550 | generateSilhouette(node, gCamera->getOrigin()); | 4575 | generateSilhouette(node, LLViewerCamera::getInstance()->getOrigin()); |
4551 | changed_objects.push_back(objectp); | 4576 | changed_objects.push_back(objectp); |
4552 | } | 4577 | } |
4553 | else if (objectp->isAttachment()) | 4578 | else if (objectp->isAttachment()) |
@@ -4712,7 +4737,7 @@ void LLSelectMgr::updateSilhouettes() | |||
4712 | { | 4737 | { |
4713 | if (num_sils_genned++ < MAX_SILS_PER_FRAME) | 4738 | if (num_sils_genned++ < MAX_SILS_PER_FRAME) |
4714 | { | 4739 | { |
4715 | generateSilhouette(node, gCamera->getOrigin()); | 4740 | generateSilhouette(node, LLViewerCamera::getInstance()->getOrigin()); |
4716 | changed_objects.push_back(objectp); | 4741 | changed_objects.push_back(objectp); |
4717 | } | 4742 | } |
4718 | else if (objectp->isAttachment() && objectp->getRootEdit()->mDrawable.notNull()) | 4743 | else if (objectp->isAttachment() && objectp->getRootEdit()->mDrawable.notNull()) |
@@ -4782,7 +4807,7 @@ void LLSelectMgr::renderSilhouettes(BOOL for_hud) | |||
4782 | glPushMatrix(); | 4807 | glPushMatrix(); |
4783 | glLoadIdentity(); | 4808 | glLoadIdentity(); |
4784 | F32 depth = llmax(1.f, hud_bbox.getExtentLocal().mV[VX] * 1.1f); | 4809 | F32 depth = llmax(1.f, hud_bbox.getExtentLocal().mV[VX] * 1.1f); |
4785 | glOrtho(-0.5f * gCamera->getAspect(), 0.5f * gCamera->getAspect(), -0.5f, 0.5f, 0.f, depth); | 4810 | glOrtho(-0.5f * LLViewerCamera::getInstance()->getAspect(), 0.5f * LLViewerCamera::getInstance()->getAspect(), -0.5f, 0.5f, 0.f, depth); |
4786 | 4811 | ||
4787 | glMatrixMode(GL_MODELVIEW); | 4812 | glMatrixMode(GL_MODELVIEW); |
4788 | glPushMatrix(); | 4813 | glPushMatrix(); |
@@ -5225,8 +5250,8 @@ void LLSelectNode::renderOneSilhouette(const LLColor4 &color) | |||
5225 | } | 5250 | } |
5226 | else | 5251 | else |
5227 | { | 5252 | { |
5228 | LLVector3 view_vector = gCamera->getOrigin() - objectp->getRenderPosition(); | 5253 | LLVector3 view_vector = LLViewerCamera::getInstance()->getOrigin() - objectp->getRenderPosition(); |
5229 | silhouette_thickness = view_vector.magVec() * LLSelectMgr::sHighlightThickness * (gCamera->getView() / gCamera->getDefaultFOV()); | 5254 | silhouette_thickness = view_vector.magVec() * LLSelectMgr::sHighlightThickness * (LLViewerCamera::getInstance()->getView() / LLViewerCamera::getInstance()->getDefaultFOV()); |
5230 | } | 5255 | } |
5231 | F32 animationTime = (F32)LLFrameTimer::getElapsedSeconds(); | 5256 | F32 animationTime = (F32)LLFrameTimer::getElapsedSeconds(); |
5232 | 5257 | ||
@@ -5240,10 +5265,10 @@ void LLSelectNode::renderOneSilhouette(const LLColor4 &color) | |||
5240 | gGL.blendFunc(GL_SRC_COLOR, GL_ONE); | 5265 | gGL.blendFunc(GL_SRC_COLOR, GL_ONE); |
5241 | LLGLEnable fog(GL_FOG); | 5266 | LLGLEnable fog(GL_FOG); |
5242 | glFogi(GL_FOG_MODE, GL_LINEAR); | 5267 | glFogi(GL_FOG_MODE, GL_LINEAR); |
5243 | float d = (gCamera->getPointOfInterest()-gCamera->getOrigin()).magVec(); | 5268 | float d = (LLViewerCamera::getInstance()->getPointOfInterest()-LLViewerCamera::getInstance()->getOrigin()).magVec(); |
5244 | LLColor4 fogCol = color * (F32)llclamp((gSelectMgr->getSelectionCenterGlobal()-gAgent.getCameraPositionGlobal()).magVec()/(gSelectMgr->getBBoxOfSelection().getExtentLocal().magVec()*4), 0.0, 1.0); | 5269 | LLColor4 fogCol = color * (F32)llclamp((LLSelectMgr::getInstance()->getSelectionCenterGlobal()-gAgent.getCameraPositionGlobal()).magVec()/(LLSelectMgr::getInstance()->getBBoxOfSelection().getExtentLocal().magVec()*4), 0.0, 1.0); |
5245 | glFogf(GL_FOG_START, d); | 5270 | glFogf(GL_FOG_START, d); |
5246 | glFogf(GL_FOG_END, d*(1 + (gCamera->getView() / gCamera->getDefaultFOV()))); | 5271 | glFogf(GL_FOG_END, d*(1 + (LLViewerCamera::getInstance()->getView() / LLViewerCamera::getInstance()->getDefaultFOV()))); |
5247 | glFogfv(GL_FOG_COLOR, fogCol.mV); | 5272 | glFogfv(GL_FOG_COLOR, fogCol.mV); |
5248 | 5273 | ||
5249 | LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE, GL_GEQUAL); | 5274 | LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE, GL_GEQUAL); |
@@ -5371,7 +5396,7 @@ S32 get_family_count(LLViewerObject *parent) | |||
5371 | } | 5396 | } |
5372 | else | 5397 | else |
5373 | { | 5398 | { |
5374 | if (gSelectMgr->canSelectObject(child)) | 5399 | if (LLSelectMgr::getInstance()->canSelectObject(child)) |
5375 | { | 5400 | { |
5376 | count += get_family_count( child ); | 5401 | count += get_family_count( child ); |
5377 | } | 5402 | } |
@@ -5463,9 +5488,9 @@ void LLSelectMgr::updateSelectionCenter() | |||
5463 | 5488 | ||
5464 | } | 5489 | } |
5465 | 5490 | ||
5466 | if ( !(gAgentID == LLUUID::null) && gToolMgr) | 5491 | if ( !(gAgentID == LLUUID::null)) |
5467 | { | 5492 | { |
5468 | LLTool *tool = gToolMgr->getCurrentTool(); | 5493 | LLTool *tool = LLToolMgr::getInstance()->getCurrentTool(); |
5469 | if (mShowSelection) | 5494 | if (mShowSelection) |
5470 | { | 5495 | { |
5471 | LLVector3d select_center_global; | 5496 | LLVector3d select_center_global; |
@@ -5654,9 +5679,9 @@ void LLSelectMgr::validateSelection() | |||
5654 | { | 5679 | { |
5655 | virtual bool apply(LLViewerObject* object) | 5680 | virtual bool apply(LLViewerObject* object) |
5656 | { | 5681 | { |
5657 | if (!gSelectMgr->canSelectObject(object)) | 5682 | if (!LLSelectMgr::getInstance()->canSelectObject(object)) |
5658 | { | 5683 | { |
5659 | gSelectMgr->deselectObjectOnly(object); | 5684 | LLSelectMgr::getInstance()->deselectObjectOnly(object); |
5660 | } | 5685 | } |
5661 | return true; | 5686 | return true; |
5662 | } | 5687 | } |
@@ -6216,4 +6241,199 @@ LLViewerObject* LLObjectSelection::getFirstMoveableObject(BOOL get_parent) | |||
6216 | return getFirstSelectedObject(&func, get_parent); | 6241 | return getFirstSelectedObject(&func, get_parent); |
6217 | } | 6242 | } |
6218 | 6243 | ||
6244 | //----------------------------------------------------------------------------- | ||
6245 | // Position + Rotation update methods called from LLViewerJoystick | ||
6246 | //----------------------------------------------------------------------------- | ||
6247 | bool LLSelectMgr::selectionMove(const LLVector3& displ, | ||
6248 | F32 roll, F32 pitch, F32 yaw, U32 update_type) | ||
6249 | { | ||
6250 | if (update_type == UPD_NONE) | ||
6251 | { | ||
6252 | return false; | ||
6253 | } | ||
6254 | |||
6255 | LLVector3 displ_global; | ||
6256 | bool update_success = true; | ||
6257 | bool update_position = update_type & UPD_POSITION; | ||
6258 | bool update_rotation = update_type & UPD_ROTATION; | ||
6259 | const bool noedit_linked_parts = !gSavedSettings.getBOOL("EditLinkedParts"); | ||
6260 | |||
6261 | if (update_position) | ||
6262 | { | ||
6263 | // calculate the distance of the object closest to the camera origin | ||
6264 | F32 min_dist = 1e+30f; | ||
6265 | LLVector3 obj_pos; | ||
6266 | for (LLObjectSelection::root_iterator it = getSelection()->root_begin(); | ||
6267 | it != getSelection()->root_end(); ++it) | ||
6268 | { | ||
6269 | obj_pos = (*it)->getObject()->getPositionEdit(); | ||
6270 | |||
6271 | F32 obj_dist = dist_vec(obj_pos, LLViewerCamera::getInstance()->getOrigin()); | ||
6272 | if (obj_dist < min_dist) | ||
6273 | { | ||
6274 | min_dist = obj_dist; | ||
6275 | } | ||
6276 | } | ||
6277 | |||
6278 | // factor the distance inside the displacement vector. This will get us | ||
6279 | // equally visible movements for both close and far away selections. | ||
6280 | min_dist = sqrt(min_dist) / 2; | ||
6281 | displ_global.setVec(displ.mV[0]*min_dist, | ||
6282 | displ.mV[1]*min_dist, | ||
6283 | displ.mV[2]*min_dist); | ||
6284 | |||
6285 | // equates to: Displ_global = Displ * M_cam_axes_in_global_frame | ||
6286 | displ_global = LLViewerCamera::getInstance()->rotateToAbsolute(displ_global); | ||
6287 | } | ||
6288 | |||
6289 | LLQuaternion new_rot; | ||
6290 | if (update_rotation) | ||
6291 | { | ||
6292 | // let's calculate the rotation around each camera axes | ||
6293 | LLQuaternion qx(roll, LLViewerCamera::getInstance()->getAtAxis()); | ||
6294 | LLQuaternion qy(pitch, LLViewerCamera::getInstance()->getLeftAxis()); | ||
6295 | LLQuaternion qz(yaw, LLViewerCamera::getInstance()->getUpAxis()); | ||
6296 | new_rot.setQuat(qx * qy * qz); | ||
6297 | } | ||
6298 | |||
6299 | LLViewerObject *obj; | ||
6300 | S32 obj_count = getSelection()->getObjectCount(); | ||
6301 | for (LLObjectSelection::root_iterator it = getSelection()->root_begin(); | ||
6302 | it != getSelection()->root_end(); ++it ) | ||
6303 | { | ||
6304 | obj = (*it)->getObject(); | ||
6305 | bool enable_pos = false, enable_rot = false; | ||
6306 | bool perm_move = obj->permMove(); | ||
6307 | bool perm_mod = obj->permModify(); | ||
6308 | |||
6309 | LLVector3d sel_center(getSelectionCenterGlobal()); | ||
6310 | |||
6311 | if (update_rotation) | ||
6312 | { | ||
6313 | enable_rot = perm_move | ||
6314 | && ((perm_mod && !obj->isAttachment()) || noedit_linked_parts); | ||
6315 | |||
6316 | if (enable_rot) | ||
6317 | { | ||
6318 | int children_count = obj->getChildren().size(); | ||
6319 | if (obj_count > 1 && children_count > 0) | ||
6320 | { | ||
6321 | // for linked sets, rotate around the group center | ||
6322 | const LLVector3 t(obj->getPositionGlobal() - sel_center); | ||
6323 | |||
6324 | // Ra = T x R x T^-1 | ||
6325 | LLMatrix4 mt; mt.setTranslation(t); | ||
6326 | const LLMatrix4 mnew_rot(new_rot); | ||
6327 | LLMatrix4 mt_1; mt_1.setTranslation(-t); | ||
6328 | mt *= mnew_rot; | ||
6329 | mt *= mt_1; | ||
6330 | |||
6331 | // Rfin = Rcur * Ra | ||
6332 | obj->setRotation(obj->getRotationEdit() * mt.quaternion()); | ||
6333 | displ_global += mt.getTranslation(); | ||
6334 | } | ||
6335 | else | ||
6336 | { | ||
6337 | obj->setRotation(obj->getRotationEdit() * new_rot); | ||
6338 | } | ||
6339 | } | ||
6340 | else | ||
6341 | { | ||
6342 | update_success = false; | ||
6343 | } | ||
6344 | } | ||
6345 | |||
6346 | if (update_position) | ||
6347 | { | ||
6348 | // establish if object can be moved or not | ||
6349 | enable_pos = perm_move && !obj->isAttachment() | ||
6350 | && (perm_mod || noedit_linked_parts); | ||
6351 | |||
6352 | if (enable_pos) | ||
6353 | { | ||
6354 | obj->setPosition(obj->getPositionEdit() + displ_global); | ||
6355 | } | ||
6356 | else | ||
6357 | { | ||
6358 | update_success = false; | ||
6359 | } | ||
6360 | } | ||
6361 | |||
6362 | if (enable_pos && enable_rot && obj->mDrawable.notNull()) | ||
6363 | { | ||
6364 | gPipeline.markMoved(obj->mDrawable, TRUE); | ||
6365 | } | ||
6366 | } | ||
6367 | |||
6368 | if (update_position && update_success && obj_count > 1) | ||
6369 | { | ||
6370 | updateSelectionCenter(); | ||
6371 | } | ||
6372 | |||
6373 | return update_success; | ||
6374 | } | ||
6375 | |||
6376 | void LLSelectMgr::sendSelectionMove() | ||
6377 | { | ||
6378 | LLSelectNode *node = mSelectedObjects->getFirstRootNode(); | ||
6379 | if (node == NULL) | ||
6380 | { | ||
6381 | return; | ||
6382 | } | ||
6383 | |||
6384 | //saveSelectedObjectTransform(SELECT_ACTION_TYPE_PICK); | ||
6385 | |||
6386 | U32 update_type = UPD_POSITION | UPD_ROTATION; | ||
6387 | LLViewerRegion *last_region, *curr_region = node->getObject()->getRegion(); | ||
6388 | S32 objects_in_this_packet = 0; | ||
6389 | |||
6390 | // apply to linked objects if unable to select their individual parts | ||
6391 | if (!gSavedSettings.getBOOL("EditLinkedParts") && !getTEMode()) | ||
6392 | { | ||
6393 | // tell simulator to apply to whole linked sets | ||
6394 | update_type |= UPD_LINKED_SETS; | ||
6395 | } | ||
6396 | |||
6397 | // prepare first bulk message | ||
6398 | gMessageSystem->newMessage("MultipleObjectUpdate"); | ||
6399 | packAgentAndSessionID(&update_type); | ||
6400 | |||
6401 | LLViewerObject *obj = NULL; | ||
6402 | for (LLObjectSelection::root_iterator it = getSelection()->root_begin(); | ||
6403 | it != getSelection()->root_end(); ++it) | ||
6404 | { | ||
6405 | obj = (*it)->getObject(); | ||
6219 | 6406 | ||
6407 | // note: following code adapted from sendListToRegions() (@3924) | ||
6408 | last_region = curr_region; | ||
6409 | curr_region = obj->getRegion(); | ||
6410 | |||
6411 | // if not simulator or message too big | ||
6412 | if (curr_region != last_region | ||
6413 | || gMessageSystem->isSendFull(NULL) | ||
6414 | || objects_in_this_packet >= MAX_OBJECTS_PER_PACKET) | ||
6415 | { | ||
6416 | // send sim the current message and start new one | ||
6417 | gMessageSystem->sendReliable(last_region->getHost()); | ||
6418 | objects_in_this_packet = 0; | ||
6419 | gMessageSystem->newMessage("MultipleObjectUpdate"); | ||
6420 | packAgentAndSessionID(&update_type); | ||
6421 | } | ||
6422 | |||
6423 | // add another instance of the body of data | ||
6424 | packMultipleUpdate(*it, &update_type); | ||
6425 | ++objects_in_this_packet; | ||
6426 | } | ||
6427 | |||
6428 | // flush remaining messages | ||
6429 | if (gMessageSystem->getCurrentSendTotal() > 0) | ||
6430 | { | ||
6431 | gMessageSystem->sendReliable(curr_region->getHost()); | ||
6432 | } | ||
6433 | else | ||
6434 | { | ||
6435 | gMessageSystem->clearMessage(); | ||
6436 | } | ||
6437 | |||
6438 | //saveSelectedObjectTransform(SELECT_ACTION_TYPE_PICK); | ||
6439 | } | ||