From 5e110169701c8438a2c8191f03d3c5a4f080728c Mon Sep 17 00:00:00 2001
From: Loren Shih <seraph@lindenlab.com>
Date: Wed, 25 Aug 2010 17:51:01 -0400
Subject: [PATCH] Fixed an issue where you go into appearance pose when editing
 physics if you were formerly in edit outfit. Miscellaneous code cleanup.

---
 indra/newview/llagentwearables.cpp      |  2 +-
 indra/newview/llagentwearables.h        |  2 +-
 indra/newview/llbreastmotion.cpp        |  3 ++-
 indra/newview/llsidepanelappearance.cpp | 18 +++++++++++++-----
 4 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp
index 91a09cd886f..c1aae867efb 100644
--- a/indra/newview/llagentwearables.cpp
+++ b/indra/newview/llagentwearables.cpp
@@ -821,7 +821,7 @@ void LLAgentWearables::popWearable(const LLWearableType::EType type, U32 index)
 	}
 }
 
-U32	LLAgentWearables::getWearableIndex(LLWearable *wearable)
+U32	LLAgentWearables::getWearableIndex(const LLWearable *wearable) const
 {
 	if (wearable == NULL)
 	{
diff --git a/indra/newview/llagentwearables.h b/indra/newview/llagentwearables.h
index d7e77a5a5bd..3ef50f14da4 100644
--- a/indra/newview/llagentwearables.h
+++ b/indra/newview/llagentwearables.h
@@ -124,7 +124,7 @@ class LLAgentWearables : public LLInitClass<LLAgentWearables>
 	void			setWearableOutfit(const LLInventoryItem::item_array_t& items, const LLDynamicArray< LLWearable* >& wearables, BOOL remove);
 	void			setWearableName(const LLUUID& item_id, const std::string& new_name);
 	void			addLocalTextureObject(const LLWearableType::EType wearable_type, const LLVOAvatarDefines::ETextureIndex texture_type, U32 wearable_index);
-	U32				getWearableIndex(LLWearable *wearable);
+	U32				getWearableIndex(const LLWearable *wearable) const;
 
 protected:
 	void			setWearableFinal(LLInventoryItem* new_item, LLWearable* new_wearable, bool do_append = false);
diff --git a/indra/newview/llbreastmotion.cpp b/indra/newview/llbreastmotion.cpp
index 8d3571e83dc..036aa2ff396 100644
--- a/indra/newview/llbreastmotion.cpp
+++ b/indra/newview/llbreastmotion.cpp
@@ -42,7 +42,8 @@
 #include "llbreastmotion.h"
 #include "llcharacter.h"
 #include "llviewercontrol.h"
-#include "llviewervisualparam.H"
+#include "llviewervisualparam.h"
+#include "llvoavatarself.h"
 
 // #define OUTPUT_BREAST_DATA
 
diff --git a/indra/newview/llsidepanelappearance.cpp b/indra/newview/llsidepanelappearance.cpp
index e8733bf3e43..1422971b525 100644
--- a/indra/newview/llsidepanelappearance.cpp
+++ b/indra/newview/llsidepanelappearance.cpp
@@ -185,18 +185,26 @@ void LLSidepanelAppearance::onVisibilityChange(const LLSD &new_visibility)
 {
 	if (new_visibility.asBoolean())
 	{
-		bool is_outfit_edit_visible = mOutfitEdit && mOutfitEdit->getVisible();
-		bool is_wearable_edit_visible = mEditWearable && mEditWearable->getVisible();
+		const BOOL is_outfit_edit_visible = mOutfitEdit && mOutfitEdit->getVisible();
+		const BOOL is_wearable_edit_visible = mEditWearable && mEditWearable->getVisible();
 
 		if (is_outfit_edit_visible || is_wearable_edit_visible)
 		{
-			if (!gAgentCamera.cameraCustomizeAvatar() && gSavedSettings.getBOOL("AppearanceCameraMovement"))
+			const LLWearable *wearable_ptr = mEditWearable->getWearable();
+			if (!wearable_ptr)
+			{
+				llwarns << "Visibility change to invalid wearable" << llendl;
+				return;
+			}
+			const BOOL disable_camera_motion = LLWearableType::getDisableCameraSwitch(wearable_ptr->getType());
+			if (!gAgentCamera.cameraCustomizeAvatar() && 
+				!disable_camera_motion &&
+				gSavedSettings.getBOOL("AppearanceCameraMovement"))
 			{
 				gAgentCamera.changeCameraToCustomizeAvatar();
 			}
 			if (is_wearable_edit_visible)
 			{
-				LLWearable *wearable_ptr = mEditWearable->getWearable();
 				if (gAgentWearables.getWearableIndex(wearable_ptr) == LLAgentWearables::MAX_CLOTHING_PER_TYPE)
 				{
 					// we're no longer wearing the wearable we were last editing, switch back to outfit editor
@@ -380,7 +388,7 @@ void LLSidepanelAppearance::toggleWearableEditPanel(BOOL visible, LLWearable *we
 		{
 			gAgentCamera.changeCameraToCustomizeAvatar();
 		}
-		mEditWearable->setWearable(wearable);
+		mEditWearable->setWearable(wearable, disable_camera_switch);
 		mEditWearable->onOpen(LLSD()); // currently no-op, just for consistency
 	}
 	else
-- 
GitLab