From 378ae8ce6588ce921b2aa960c08d4293c6b419e5 Mon Sep 17 00:00:00 2001
From: Todd Stinson <stinson@lindenlab.com>
Date: Tue, 13 Mar 2012 15:33:15 -0700
Subject: PATH-199: Enforcing permanent objects in frozen state to not move.

---
 indra/newview/llmaniprotate.cpp    | 10 +++++-----
 indra/newview/llmanipscale.cpp     | 12 ++++++------
 indra/newview/llmaniptranslate.cpp |  4 ++--
 indra/newview/llpanelobject.cpp    | 17 +++++++++++++----
 indra/newview/llpanelobject.h      |  3 ++-
 indra/newview/llselectmgr.cpp      | 12 ++++++------
 indra/newview/lltoolgrab.cpp       | 14 ++++++++++----
 indra/newview/llviewermenu.cpp     |  1 +
 indra/newview/llviewerobject.cpp   |  6 ++++++
 indra/newview/llviewerobject.h     |  2 ++
 indra/newview/llviewerwindow.cpp   |  2 +-
 11 files changed, 54 insertions(+), 29 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llmaniprotate.cpp b/indra/newview/llmaniprotate.cpp
index a8da94f75e..7ac347e66a 100644
--- a/indra/newview/llmaniprotate.cpp
+++ b/indra/newview/llmaniprotate.cpp
@@ -481,7 +481,7 @@ BOOL LLManipRotate::handleMouseUp(S32 x, S32 y, MASK mask)
 			LLViewerObject* object = selectNode->getObject();
 
 			// have permission to move and object is root of selection or individually selected
-			if (object->permMove() && (object->isRootEdit() || selectNode->mIndividualSelection))
+			if (object->permMove() && !object->isPermanentEnforced() && (object->isRootEdit() || selectNode->mIndividualSelection))
 			{
 				object->mUnselectedChildrenPositions.clear() ;
 			}
@@ -569,7 +569,7 @@ void LLManipRotate::drag( S32 x, S32 y )
 		LLViewerObject* object = selectNode->getObject();
 
 		// have permission to move and object is root of selection or individually selected
-		if (object->permMove() && (object->isRootEdit() || selectNode->mIndividualSelection))
+		if (object->permMove() && !object->isPermanentEnforced() && (object->isRootEdit() || selectNode->mIndividualSelection))
 		{
 			if (!object->isRootEdit())
 			{
@@ -623,7 +623,7 @@ void LLManipRotate::drag( S32 x, S32 y )
 		LLViewerObject* object = selectNode->getObject();
 
 		// to avoid cumulative position changes we calculate the objects new position using its saved position
-		if (object && object->permMove())
+		if (object && object->permMove() && !object->isPermanentEnforced())
 		{
 			LLVector3 center   = gAgent.getPosAgentFromGlobal( mRotationCenter );
 
@@ -704,7 +704,7 @@ void LLManipRotate::drag( S32 x, S32 y )
 	{
 		LLSelectNode* selectNode = *iter;
 		LLViewerObject*cur = selectNode->getObject();
-		if( cur->permModify() && cur->permMove() && !cur->isAvatar())
+		if( cur->permModify() && cur->permMove() && !cur->isPermanentEnforced() && !cur->isAvatar())
 		{
 			selectNode->mLastRotation = cur->getRotation();
 			selectNode->mLastPositionLocal = cur->getPosition();
@@ -1871,7 +1871,7 @@ BOOL LLManipRotate::canAffectSelection()
 		{
 			virtual bool apply(LLViewerObject* objectp)
 			{
-				return objectp->permMove() && (objectp->permModify() || !gSavedSettings.getBOOL("EditLinkedParts"));
+				return objectp->permMove() && !objectp->isPermanentEnforced() && (objectp->permModify() || !gSavedSettings.getBOOL("EditLinkedParts"));
 			}
 		} func;
 		can_rotate = mObjectSelection->applyToObjects(&func);
diff --git a/indra/newview/llmanipscale.cpp b/indra/newview/llmanipscale.cpp
index f6df4cdfbf..160ba40433 100644
--- a/indra/newview/llmanipscale.cpp
+++ b/indra/newview/llmanipscale.cpp
@@ -826,7 +826,7 @@ void LLManipScale::drag( S32 x, S32 y )
 	{
 		LLSelectNode* selectNode = *iter;
 		LLViewerObject*cur = selectNode->getObject();
-		if( cur->permModify() && cur->permMove() && !cur->isAvatar())
+		if( cur->permModify() && cur->permMove() && !cur->isPermanentEnforced() && !cur->isAvatar())
 		{
 			selectNode->mLastScale = cur->getScale();
 			selectNode->mLastPositionLocal = cur->getPosition();
@@ -973,7 +973,7 @@ void LLManipScale::dragCorner( S32 x, S32 y )
 	{
 		LLSelectNode* selectNode = *iter;
 		LLViewerObject* cur = selectNode->getObject();
-		if(  cur->permModify() && cur->permMove() && !cur->isAvatar() )
+		if(  cur->permModify() && cur->permMove() && !cur->isPermanentEnforced() && !cur->isAvatar() )
 		{
 			const LLVector3& scale = selectNode->mSavedScale;
 
@@ -995,7 +995,7 @@ void LLManipScale::dragCorner( S32 x, S32 y )
 	{
 		LLSelectNode* selectNode = *iter;
 		LLViewerObject* cur = selectNode->getObject();
-		if( cur->permModify() && cur->permMove() && !cur->isAvatar() && cur->isRootEdit() )
+		if( cur->permModify() && cur->permMove() && !cur->isPermanentEnforced() && !cur->isAvatar() && cur->isRootEdit() )
 		{
 			const LLVector3& scale = selectNode->mSavedScale;
 			cur->setScale( scale_factor * scale );
@@ -1043,7 +1043,7 @@ void LLManipScale::dragCorner( S32 x, S32 y )
 	{
 		LLSelectNode* selectNode = *iter;
 		LLViewerObject*cur = selectNode->getObject();
-		if( cur->permModify() && cur->permMove() && !cur->isAvatar() && !cur->isRootEdit() )
+		if( cur->permModify() && cur->permMove() && !cur->isPermanentEnforced() && !cur->isAvatar() && !cur->isRootEdit() )
 		{
 			const LLVector3& scale = selectNode->mSavedScale;
 			cur->setScale( scale_factor * scale, FALSE );
@@ -1251,7 +1251,7 @@ void LLManipScale::stretchFace( const LLVector3& drag_start_agent, const LLVecto
 	{
 		LLSelectNode* selectNode = *iter;
 		LLViewerObject*cur = selectNode->getObject();
-		if( cur->permModify() && cur->permMove() && !cur->isAvatar() )
+		if( cur->permModify() && cur->permMove() && !cur->isPermanentEnforced() && !cur->isAvatar() )
 		{
 			LLBBox cur_bbox			= cur->getBoundingBoxAgent();
 			LLVector3 start_local	= cur_bbox.agentToLocal( drag_start_agent );
@@ -2057,7 +2057,7 @@ BOOL LLManipScale::canAffectSelection()
 		{
 			virtual bool apply(LLViewerObject* objectp)
 			{
-				return objectp->permModify() && objectp->permMove() && !objectp->isSeat();
+				return objectp->permModify() && objectp->permMove() && !objectp->isPermanentEnforced() && !objectp->isSeat();
 			}
 		} func;
 		can_scale = mObjectSelection->applyToObjects(&func);
diff --git a/indra/newview/llmaniptranslate.cpp b/indra/newview/llmaniptranslate.cpp
index 3a88fbd96d..e6ccfc0af5 100644
--- a/indra/newview/llmaniptranslate.cpp
+++ b/indra/newview/llmaniptranslate.cpp
@@ -687,7 +687,7 @@ BOOL LLManipTranslate::handleHover(S32 x, S32 y, MASK mask)
 			}
 		}
 
-		if (object->permMove())
+		if (object->permMove() && !object->isPermanentEnforced())
 		{
 			// handle attachments in local space
 			if (object->isAttachment() && object->mDrawable.notNull())
@@ -2281,7 +2281,7 @@ BOOL LLManipTranslate::canAffectSelection()
 		{
 			virtual bool apply(LLViewerObject* objectp)
 			{
-				return objectp->permMove() && (objectp->permModify() || !gSavedSettings.getBOOL("EditLinkedParts"));
+				return objectp->permMove() && !objectp->isPermanentEnforced() && (objectp->permModify() || !gSavedSettings.getBOOL("EditLinkedParts"));
 			}
 		} func;
 		can_move = mObjectSelection->applyToObjects(&func);
diff --git a/indra/newview/llpanelobject.cpp b/indra/newview/llpanelobject.cpp
index ee62a39f75..26f4b09b30 100644
--- a/indra/newview/llpanelobject.cpp
+++ b/indra/newview/llpanelobject.cpp
@@ -66,6 +66,8 @@
 #include "llviewercontrol.h"
 #include "lluictrlfactory.h"
 //#include "llfirstuse.h"
+#include "llfloatertools.h"
+#include "llpathfindingmanager.h"
 
 #include "lldrawpool.h"
 
@@ -271,6 +273,8 @@ BOOL	LLPanelObject::postBuild()
 	childSetCommitCallback("sculpt mirror control", onCommitSculptType, this);
 	mCtrlSculptInvert = getChild<LLCheckBoxCtrl>("sculpt invert control");
 	childSetCommitCallback("sculpt invert control", onCommitSculptType, this);
+
+	LLPathfindingManager::getInstance()->registerAgentStateListener(boost::bind(&LLPanelObject::handleAgentStateCallback, this));
 	
 	// Start with everyone disabled
 	clearCtrls();
@@ -341,9 +345,9 @@ void LLPanelObject::getState( )
 	}
 
 	// can move or rotate only linked group with move permissions, or sub-object with move and modify perms
-	BOOL enable_move	= objectp->permMove() && !objectp->isAttachment() && (objectp->permModify() || !gSavedSettings.getBOOL("EditLinkedParts"));
-	BOOL enable_scale	= objectp->permMove() && objectp->permModify();
-	BOOL enable_rotate	= objectp->permMove() && ( (objectp->permModify() && !objectp->isAttachment()) || !gSavedSettings.getBOOL("EditLinkedParts"));
+	BOOL enable_move	= objectp->permMove() && !objectp->isPermanentEnforced() && !objectp->isAttachment() && (objectp->permModify() || !gSavedSettings.getBOOL("EditLinkedParts"));
+	BOOL enable_scale	= objectp->permMove() && !objectp->isPermanentEnforced() && objectp->permModify();
+	BOOL enable_rotate	= objectp->permMove() && !objectp->isPermanentEnforced() && ( (objectp->permModify() && !objectp->isAttachment()) || !gSavedSettings.getBOOL("EditLinkedParts"));
 
 	S32 selected_count = LLSelectMgr::getInstance()->getSelection()->getObjectCount();
 	BOOL single_volume = (LLSelectMgr::getInstance()->selectionAllPCode( LL_PCODE_VOLUME ))
@@ -548,7 +552,7 @@ void LLPanelObject::getState( )
 	{
 		// Only allowed to change these parameters for objects
 		// that you have permissions on AND are not attachments.
-		enabled = root_objectp->permModify();
+		enabled = root_objectp->permModify() && !root_objectp->isPermanentEnforced();
 		
 		// Volume type
 		const LLVolumeParams &volume_params = objectp->getVolume()->getParams();
@@ -1968,6 +1972,11 @@ void LLPanelObject::onCommitSculpt( const LLSD& data )
 	sendSculpt();
 }
 
+void LLPanelObject::handleAgentStateCallback() const
+{
+	gFloaterTools->dirty();
+}
+
 BOOL LLPanelObject::onDropSculpt(LLInventoryItem* item)
 {
     LLTextureCtrl* mTextureCtrl = getChild<LLTextureCtrl>("sculpt texture control");
diff --git a/indra/newview/llpanelobject.h b/indra/newview/llpanelobject.h
index 86b59d4ff9..8c94c99151 100644
--- a/indra/newview/llpanelobject.h
+++ b/indra/newview/llpanelobject.h
@@ -74,7 +74,8 @@ public:
 	void     		onSelectSculpt(const LLSD& data);
 	BOOL     		onDropSculpt(LLInventoryItem* item);
 	static void     onCommitSculptType(    LLUICtrl *ctrl, void* userdata);
-		
+
+	void            handleAgentStateCallback() const;
 	
 protected:
 	void			getState();
diff --git a/indra/newview/llselectmgr.cpp b/indra/newview/llselectmgr.cpp
index 9cfcf3de79..1ee365ce97 100644
--- a/indra/newview/llselectmgr.cpp
+++ b/indra/newview/llselectmgr.cpp
@@ -276,7 +276,7 @@ void LLSelectMgr::overrideObjectUpdates()
 		virtual bool apply(LLSelectNode* selectNode)
 		{
 			LLViewerObject* object = selectNode->getObject();
-			if (object && object->permMove())
+			if (object && object->permMove() && !object->isPermanentEnforced())
 			{
 				if (!selectNode->mLastPositionLocal.isExactlyZero())
 				{
@@ -955,7 +955,7 @@ void LLSelectMgr::highlightObjectOnly(LLViewerObject* objectp)
 	}
 	
 	if ((gSavedSettings.getBOOL("SelectOwnedOnly") && !objectp->permYouOwner()) 
-		|| (gSavedSettings.getBOOL("SelectMovableOnly") && !objectp->permMove()))
+		|| (gSavedSettings.getBOOL("SelectMovableOnly") && (!objectp->permMove() ||  objectp->isPermanentEnforced())))
 	{
 		// only select my own objects
 		return;
@@ -6236,7 +6236,7 @@ BOOL LLSelectMgr::canSelectObject(LLViewerObject* object)
 	}
 
 	if ((gSavedSettings.getBOOL("SelectOwnedOnly") && !object->permYouOwner()) ||
-		(gSavedSettings.getBOOL("SelectMovableOnly") && !object->permMove()))
+		(gSavedSettings.getBOOL("SelectMovableOnly") && (!object->permMove() ||  object->isPermanentEnforced())))
 	{
 		// only select my own objects
 		return FALSE;
@@ -6928,7 +6928,7 @@ LLSelectNode* LLObjectSelection::getFirstMoveableNode(BOOL get_root_first)
 		bool apply(LLSelectNode* node)
 		{
 			LLViewerObject* obj = node->getObject();
-			return obj && obj->permMove();
+			return obj && obj->permMove() && !obj->isPermanentEnforced();
 		}
 	} func;
 	LLSelectNode* res = get_root_first ? getFirstRootNode(&func, TRUE) : getFirstNode(&func);
@@ -7008,7 +7008,7 @@ LLViewerObject* LLObjectSelection::getFirstMoveableObject(BOOL get_parent)
 		bool apply(LLSelectNode* node)
 		{
 			LLViewerObject* obj = node->getObject();
-			return obj && obj->permMove();
+			return obj && obj->permMove() && !obj->isPermanentEnforced();
 		}
 	} func;
 	return getFirstSelectedObject(&func, get_parent);
@@ -7077,7 +7077,7 @@ bool LLSelectMgr::selectionMove(const LLVector3& displ,
 	{
 		obj = (*it)->getObject();
 		bool enable_pos = false, enable_rot = false;
-		bool perm_move = obj->permMove();
+		bool perm_move = obj->permMove() && !obj->isPermanentEnforced();
 		bool perm_mod = obj->permModify();
 		
 		LLVector3d sel_center(getSelectionCenterGlobal());
diff --git a/indra/newview/lltoolgrab.cpp b/indra/newview/lltoolgrab.cpp
index 61ff59c53a..192f83d064 100644
--- a/indra/newview/lltoolgrab.cpp
+++ b/indra/newview/lltoolgrab.cpp
@@ -222,18 +222,24 @@ BOOL LLToolGrab::handleObjectHit(const LLPickInfo& info)
 			if (gAgentCamera.cameraMouselook())
 			{
 				mMode = GRAB_LOCKED;
+				gViewerWindow->hideCursor();
+				gViewerWindow->moveCursorToCenter();
 			}
-			else
+			else if (objectp->permMove() && !objectp->isPermanentEnforced())
 			{
 				mMode = GRAB_ACTIVE_CENTER;
+				gViewerWindow->hideCursor();
+				gViewerWindow->moveCursorToCenter();
+			}
+			else
+			{
+				mMode = GRAB_LOCKED;
 			}
 
-			gViewerWindow->hideCursor();
-			gViewerWindow->moveCursorToCenter();
 			
 		}
 	}
-	else if( !objectp->permMove() )
+	else if( !objectp->permMove() || objectp->isPermanentEnforced())
 	{
 		// if mouse is over a physical object without move permission, show feedback if user tries to move it.
 		mMode = GRAB_LOCKED;
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index e91a1d6afa..390cad65c4 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -6436,6 +6436,7 @@ BOOL object_selected_and_point_valid()
 		(selection->getFirstRootObject()->getPCode() == LL_PCODE_VOLUME) && 
 		selection->getFirstRootObject()->permYouOwner() &&
 		selection->getFirstRootObject()->flagObjectMove() &&
+		!selection->getFirstRootObject()->flagObjectPermanent() &&
 		!((LLViewerObject*)selection->getFirstRootObject()->getRoot())->isAvatar() && 
 		(selection->getFirstRootObject()->getNVPair("AssetContainer") == NULL);
 }
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 330cf51b3e..c70ceac525 100644
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -100,6 +100,7 @@
 #include "lltrans.h"
 #include "llsdutil.h"
 #include "llmediaentry.h"
+#include "llpathfindingmanager.h"
 
 //#define DEBUG_UPDATE_TYPE
 
@@ -5321,6 +5322,11 @@ void LLViewerObject::markForUpdate(BOOL priority)
 	}
 }
 
+bool LLViewerObject::isPermanentEnforced() const
+{
+	return flagObjectPermanent() && !LLPathfindingManager::getInstance()->isAllowAlterPermanent();
+}
+
 bool LLViewerObject::getIncludeInSearch() const
 {
 	return flagIncludeInSearch();
diff --git a/indra/newview/llviewerobject.h b/indra/newview/llviewerobject.h
index 63215942ac..1af1eff458 100644
--- a/indra/newview/llviewerobject.h
+++ b/indra/newview/llviewerobject.h
@@ -496,6 +496,8 @@ public:
 	inline F32      getPhysicsFriction() const      { return mPhysicsFriction; }
 	inline F32      getPhysicsDensity() const       { return mPhysicsDensity; }
 	inline F32      getPhysicsRestitution() const   { return mPhysicsRestitution; }
+
+	bool            isPermanentEnforced() const;
 	
 	bool getIncludeInSearch() const;
 	void setIncludeInSearch(bool include_in_search);
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 8750b3b1f2..49e07a1fe3 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -3530,7 +3530,7 @@ void LLViewerWindow::renderSelections( BOOL for_gl_pick, BOOL pick_parcel_walls,
 						LLSelectNode* nodep = *iter;
 						LLViewerObject* object = nodep->getObject();
 						BOOL this_object_movable = FALSE;
-						if (object->permMove() && (object->permModify() || selecting_linked_set))
+						if (object->permMove() && !object->isPermanentEnforced() && (object->permModify() || selecting_linked_set))
 						{
 							moveable_object_selected = TRUE;
 							this_object_movable = TRUE;
-- 
cgit v1.2.3