From ee3048285f33d63a53cc12d66230e8c8b50cda3c Mon Sep 17 00:00:00 2001
From: Loren Shih <seraph@lindenlab.com>
Date: Wed, 6 Apr 2011 12:30:39 -0400
Subject: For SH-1308 Edit Physics sometimes messes up camera

Removed camera switching for phyics wearables.
---
 indra/newview/llpaneleditwearable.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/indra/newview/llpaneleditwearable.cpp b/indra/newview/llpaneleditwearable.cpp
index 8bd2d5ad6a..cb8fbd66b5 100644
--- a/indra/newview/llpaneleditwearable.cpp
+++ b/indra/newview/llpaneleditwearable.cpp
@@ -1196,6 +1196,12 @@ void LLPanelEditWearable::onTabExpandedCollapsed(const LLSD& param, U8 index)
 
 void LLPanelEditWearable::changeCamera(U8 subpart)
 {
+	// Don't change the camera if this type doesn't have a camera switch.
+	// Useful for wearables like physics that don't have an associated physical body part.
+	if (LLWearableType::getDisableCameraSwitch(mWearablePtr->getType()))
+	{
+		return;
+	}
         const LLEditWearableDictionary::WearableEntry *wearable_entry = LLEditWearableDictionary::getInstance()->getWearable(mWearablePtr->getType());
         if (!wearable_entry)
         {
-- 
cgit v1.2.3


From dfff5a476c0cd280332157034311df0c3e011b11 Mon Sep 17 00:00:00 2001
From: "Nyx (Neal Orman)" <nyx@lindenlab.com>
Date: Wed, 6 Apr 2011 14:30:27 -0400
Subject: SH-1289 VWR-25421 VWR-25415 FIX multiwearable "add" option disabled
 in inventory view

Corrected the XUI menu logic that was causing the "add" right click option to be greyed out
for clothing pieces that are valid for multiwearables.
---
 indra/newview/llinventorybridge.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp
index 622a5607df..bdb9f6167a 100644
--- a/indra/newview/llinventorybridge.cpp
+++ b/indra/newview/llinventorybridge.cpp
@@ -4681,7 +4681,7 @@ void LLWearableBridge::buildContextMenu(LLMenuGL& menu, U32 flags)
 					if (LLWearableType::getAllowMultiwear(mWearableType))
 					{
 						items.push_back(std::string("Wearable Add"));
-						if (gAgentWearables.getWearableCount(mWearableType) > 0)
+						if (gAgentWearables.getWearableCount(mWearableType) >= LLAgentWearables::MAX_CLOTHING_PER_TYPE)
 						{
 							disabled_items.push_back(std::string("Wearable Add"));
 						}
-- 
cgit v1.2.3


From 7cc0388d81476f61536c112d4838ef323f987c46 Mon Sep 17 00:00:00 2001
From: "Andrew A. de Laix" <alain@lindenlab.com>
Date: Wed, 6 Apr 2011 14:55:09 -0700
Subject: FIX VWR-25444: properly initialize DEVMODE structure to prevent
 crash.

---
 indra/llwindow/llwindowwin32.cpp | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/indra/llwindow/llwindowwin32.cpp b/indra/llwindow/llwindowwin32.cpp
index ab089081e6..6722248c23 100644
--- a/indra/llwindow/llwindowwin32.cpp
+++ b/indra/llwindow/llwindowwin32.cpp
@@ -500,6 +500,8 @@ LLWindowWin32::LLWindowWin32(LLWindowCallbacks* callbacks,
 	//-----------------------------------------------------------------------
 
 	DEVMODE dev_mode;
+	::ZeroMemory(&dev_mode, sizeof(DEVMODE));
+	dev_mode.dmSize = sizeof(DEVMODE);
 	DWORD current_refresh;
 	if (EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dev_mode))
 	{
@@ -878,6 +880,8 @@ BOOL LLWindowWin32::switchContext(BOOL fullscreen, const LLCoordScreen &size, BO
 {
 	GLuint	pixel_format;
 	DEVMODE dev_mode;
+	::ZeroMemory(&dev_mode, sizeof(DEVMODE));
+	dev_mode.dmSize = sizeof(DEVMODE);
 	DWORD	current_refresh;
 	DWORD	dw_ex_style;
 	DWORD	dw_style;
@@ -2711,6 +2715,8 @@ LLWindow::LLWindowResolution* LLWindowWin32::getSupportedResolutions(S32 &num_re
 	{
 		mSupportedResolutions = new LLWindowResolution[MAX_NUM_RESOLUTIONS];
 		DEVMODE dev_mode;
+		::ZeroMemory(&dev_mode, sizeof(DEVMODE));
+		dev_mode.dmSize = sizeof(DEVMODE);
 
 		mNumSupportedResolutions = 0;
 		for (S32 mode_num = 0; mNumSupportedResolutions < MAX_NUM_RESOLUTIONS; mode_num++)
@@ -2786,7 +2792,8 @@ F32 LLWindowWin32::getPixelAspectRatio()
 BOOL LLWindowWin32::setDisplayResolution(S32 width, S32 height, S32 bits, S32 refresh)
 {
 	DEVMODE dev_mode;
-	dev_mode.dmSize = sizeof(dev_mode);
+	::ZeroMemory(&dev_mode, sizeof(DEVMODE));
+	dev_mode.dmSize = sizeof(DEVMODE);
 	BOOL success = FALSE;
 
 	// Don't change anything if we don't have to
-- 
cgit v1.2.3


From ef8ce5bf5eb3325dec8a51d27ca01ddab47f183c Mon Sep 17 00:00:00 2001
From: Oz Linden <oz@lindenlab.com>
Date: Thu, 7 Apr 2011 12:55:12 -0400
Subject: SH-1319: Fix for disappearing torso sections on avatars

---
 indra/newview/llphysicsmotion.cpp | 24 ++++++++++++++++++++----
 indra/newview/llpolymorph.cpp     | 10 ++++++++++
 2 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/indra/newview/llphysicsmotion.cpp b/indra/newview/llphysicsmotion.cpp
index acf8973f03..254fa5c33f 100644
--- a/indra/newview/llphysicsmotion.cpp
+++ b/indra/newview/llphysicsmotion.cpp
@@ -472,7 +472,7 @@ BOOL LLPhysicsMotion::onUpdate(F32 time)
         const F32 behavior_gain = getParamValue("Gain");
         const F32 behavior_damping = getParamValue("Damping");
         const F32 behavior_drag = getParamValue("Drag");
-        const BOOL physics_test = gSavedSettings.getBOOL("AvatarPhysicsTest");
+        const BOOL physics_test = gSavedSettings.getBOOL("AvatarPhysicsTest") && gAgent.isGodlike();
         
         F32 behavior_maxeffect = getParamValue("MaxEffect");
         if (physics_test)
@@ -583,9 +583,25 @@ BOOL LLPhysicsMotion::onUpdate(F32 time)
                 velocity_new_local = 0;
         }
 
+	// Check for NaN values.  A NaN value is detected if the variables doesn't equal itself.  
+	// If NaN, then reset everything.
+	if ((mPosition_local != mPosition_local) ||
+	    (mVelocity_local != mVelocity_local) ||
+	    (position_new_local != position_new_local))
+	{
+		position_new_local = 0;
+		position_current_local = 0;
+		position_user_local = 0;
+		mVelocity_local = 0;
+		mVelocityJoint_local = 0;
+		mAccelerationJoint_local = 0;
+		mPosition_local = 0;
+		mPosition_world = LLVector3(0,0,0);
+	}
+
         const F32 position_new_local_clamped = llclamp(position_new_local,
-                                                       min_val,
-                                                       max_val);
+						       min_val,
+						       max_val);
 
         LLDriverParam *driver_param = dynamic_cast<LLDriverParam *>(mParamDriver);
         llassert_always(driver_param);
@@ -613,7 +629,7 @@ BOOL LLPhysicsMotion::onUpdate(F32 time)
         //
         // End calculate new params
         ////////////////////////////////////////////////////////////////////////////////
-        
+
         ////////////////////////////////////////////////////////////////////////////////
         // Conditionally update the visual params
         //
diff --git a/indra/newview/llpolymorph.cpp b/indra/newview/llpolymorph.cpp
index 5a67fd482a..36f8c8d13e 100644
--- a/indra/newview/llpolymorph.cpp
+++ b/indra/newview/llpolymorph.cpp
@@ -490,6 +490,16 @@ void LLPolyMorphTarget::apply( ESex avatar_sex )
 
 	mLastSex = avatar_sex;
 
+	// Check for NaN condition (NaN is detected if a variable doesn't equal itself.
+	if (mCurWeight != mCurWeight)
+	{
+		mCurWeight = 0.0;
+	}
+	if (mLastWeight != mLastWeight)
+	{
+		mLastWeight = mCurWeight+.001;
+	}
+
 	// perform differential update of morph
 	F32 delta_weight = ( getSex() & avatar_sex ) ? (mCurWeight - mLastWeight) : (getDefaultWeight() - mLastWeight);
 	// store last weight
-- 
cgit v1.2.3


From 4895b24e3861021c26a9df3ba9ba04400c63f5c8 Mon Sep 17 00:00:00 2001
From: Loren Shih <seraph@lindenlab.com>
Date: Thu, 7 Apr 2011 13:23:01 -0400
Subject: SH-1319 fix missing include

---
 indra/newview/llphysicsmotion.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/indra/newview/llphysicsmotion.cpp b/indra/newview/llphysicsmotion.cpp
index 254fa5c33f..67bb139a5e 100644
--- a/indra/newview/llphysicsmotion.cpp
+++ b/indra/newview/llphysicsmotion.cpp
@@ -40,6 +40,7 @@
 #include "v3dmath.h"
 
 #include "llphysicsmotion.h"
+#include "llagent.h"
 #include "llcharacter.h"
 #include "llviewercontrol.h"
 #include "llviewervisualparam.h"
-- 
cgit v1.2.3


From e955cb58dffa16d789d05a9a7128fc8b44c94a34 Mon Sep 17 00:00:00 2001
From: Loren Shih <seraph@lindenlab.com>
Date: Mon, 11 Apr 2011 16:13:22 -0400
Subject: SH-1328 FIXED Crash on LLWearableType::getAllowMultiwear Crash was
 because we weren't checking for null wearable lookups.

---
 indra/newview/llwearabletype.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/indra/newview/llwearabletype.cpp b/indra/newview/llwearabletype.cpp
index f933be4d8f..9e95604712 100644
--- a/indra/newview/llwearabletype.cpp
+++ b/indra/newview/llwearabletype.cpp
@@ -144,6 +144,7 @@ BOOL LLWearableType::getDisableCameraSwitch(LLWearableType::EType type)
 {
 	const LLWearableDictionary *dict = LLWearableDictionary::getInstance();
 	const WearableEntry *entry = dict->lookup(type);
+	if (!entry) return FALSE;
 	return entry->mDisableCameraSwitch;
 }
 
@@ -152,6 +153,7 @@ BOOL LLWearableType::getAllowMultiwear(LLWearableType::EType type)
 {
 	const LLWearableDictionary *dict = LLWearableDictionary::getInstance();
 	const WearableEntry *entry = dict->lookup(type);
+	if (!entry) return FALSE;
 	return entry->mAllowMultiwear;
 }
 
-- 
cgit v1.2.3


From aea35df23ea5d5af403721edffe32124890e6a2b Mon Sep 17 00:00:00 2001
From: Loren Shih <seraph@lindenlab.com>
Date: Wed, 13 Apr 2011 15:09:55 -0400
Subject: Aesthetic increase of range for breast up/down and in/out bounce. 
 Not a bug or aberrant behavior, but this just looks better if we allow higher
 range of motion.

---
 indra/newview/character/avatar_lad.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/indra/newview/character/avatar_lad.xml b/indra/newview/character/avatar_lad.xml
index 85899603ee..f8460e059d 100644
--- a/indra/newview/character/avatar_lad.xml
+++ b/indra/newview/character/avatar_lad.xml
@@ -4339,8 +4339,8 @@
      wearable="shape"
      edit_group="driven"
      value_default="0"
-     value_min="-2"
-     value_max="2">
+     value_min="-3"
+     value_max="3">
       <param_morph />
     </param>
 
@@ -4352,8 +4352,8 @@
      wearable="shape"
      edit_group="driven"
      value_default="0"
-     value_min="-1"
-     value_max="1">
+     value_min="-1.5"
+     value_max="1.5">
       <param_morph />
     </param>
 
-- 
cgit v1.2.3


From a919cc4415308d264007ed5a50abbf3e71be1100 Mon Sep 17 00:00:00 2001
From: Loren Shih <seraph@lindenlab.com>
Date: Wed, 13 Apr 2011 15:21:16 -0400
Subject: SH-1365 FIXED Avatar Physics don't behave well for less than 100% max
 effect

This change looks more complicated than it actually is.  I basically turned max effect into a scaling parameter, versus a clamping parameter.  Piece of cake, just moved some code around and made minor logic changes.
---
 indra/newview/llphysicsmotion.cpp | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/indra/newview/llphysicsmotion.cpp b/indra/newview/llphysicsmotion.cpp
index 67bb139a5e..1d3c2b72f2 100644
--- a/indra/newview/llphysicsmotion.cpp
+++ b/indra/newview/llphysicsmotion.cpp
@@ -127,7 +127,8 @@ protected:
                 return mCharacter->getVisualParamWeight(param_name.c_str());
         }
         void setParamValue(LLViewerVisualParam *param,
-                           const F32 new_value_local);
+                           const F32 new_value_local,
+						   F32 behavior_maxeffect);
 
         F32 toLocal(const LLVector3 &world);
         F32 calculateVelocity_local(const F32 time_delta);
@@ -478,9 +479,6 @@ BOOL LLPhysicsMotion::onUpdate(F32 time)
         F32 behavior_maxeffect = getParamValue("MaxEffect");
         if (physics_test)
                 behavior_maxeffect = 1.0f;
-        // Maximum effect is [0,1] range.
-        const F32 min_val = 0.5f-behavior_maxeffect/2.0;
-        const F32 max_val = 0.5f+behavior_maxeffect/2.0;
 
         // mPositon_local should be in normalized 0,1 range already.  Just making sure...
         F32 position_current_local = llclamp(mPosition_local,
@@ -578,12 +576,12 @@ BOOL LLPhysicsMotion::onUpdate(F32 time)
             position_new_local = position_user_local;
 
         // Zero out the velocity if the param is being pushed beyond its limits.
-        if ((position_new_local < min_val && velocity_new_local < 0) || 
-            (position_new_local > max_val && velocity_new_local > 0))
+        if ((position_new_local < 0 && velocity_new_local < 0) || 
+            (position_new_local > 1 && velocity_new_local > 0))
         {
                 velocity_new_local = 0;
         }
-
+	
 	// Check for NaN values.  A NaN value is detected if the variables doesn't equal itself.  
 	// If NaN, then reset everything.
 	if ((mPosition_local != mPosition_local) ||
@@ -601,8 +599,8 @@ BOOL LLPhysicsMotion::onUpdate(F32 time)
 	}
 
         const F32 position_new_local_clamped = llclamp(position_new_local,
-						       min_val,
-						       max_val);
+						       0.0f,
+						       1.0f);
 
         LLDriverParam *driver_param = dynamic_cast<LLDriverParam *>(mParamDriver);
         llassert_always(driver_param);
@@ -623,7 +621,7 @@ BOOL LLPhysicsMotion::onUpdate(F32 time)
                 {
                         LLDrivenEntry &entry = (*iter);
                         LLViewerVisualParam *driven_param = entry.mParam;
-                        setParamValue(driven_param,position_new_local_clamped);
+                        setParamValue(driven_param,position_new_local_clamped, behavior_maxeffect);
                 }
         }
         
@@ -705,12 +703,19 @@ BOOL LLPhysicsMotion::onUpdate(F32 time)
 
 // Range of new_value_local is assumed to be [0 , 1] normalized.
 void LLPhysicsMotion::setParamValue(LLViewerVisualParam *param,
-                                    F32 new_value_normalized)
+                                    F32 new_value_normalized,
+				    F32 behavior_maxeffect)
 {
         const F32 value_min_local = param->getMinWeight();
         const F32 value_max_local = param->getMaxWeight();
+        const F32 min_val = 0.5f-behavior_maxeffect/2.0;
+        const F32 max_val = 0.5f+behavior_maxeffect/2.0;
 
-        const F32 new_value_local = value_min_local + (value_max_local-value_min_local) * new_value_normalized;
+	// Scale from [0,1] to [min_val,max_val]
+	const F32 new_value_rescaled = min_val + (max_val-min_val) * new_value_normalized;
+	
+	// Scale from [0,1] to [value_min_local,value_max_local]
+        const F32 new_value_local = value_min_local + (value_max_local-value_min_local) * new_value_rescaled;
 
         mCharacter->setVisualParamWeight(param,
                                          new_value_local,
-- 
cgit v1.2.3


From fa785d9cf4638233586ecd6566a7d78dad51bb35 Mon Sep 17 00:00:00 2001
From: Loren Shih <seraph@lindenlab.com>
Date: Thu, 14 Apr 2011 14:47:05 -0400
Subject: VWR-25453 FIXED Avatar Physics Spring Needs a Higher Limit

Tripled spring limit for all params.  Very safe change.
---
 indra/newview/character/avatar_lad.xml | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/indra/newview/character/avatar_lad.xml b/indra/newview/character/avatar_lad.xml
index f8460e059d..ec162e3608 100644
--- a/indra/newview/character/avatar_lad.xml
+++ b/indra/newview/character/avatar_lad.xml
@@ -11916,7 +11916,7 @@ render_pass="bump">
      edit_group="physics_breasts_updown"
      value_default=".1"
      value_min="0"
-     value_max="1">
+     value_max="3">
 	 <param_driver />
     </param>
     <param
@@ -11971,7 +11971,7 @@ render_pass="bump">
      edit_group="physics_breasts_inout"
      value_default=".1"
      value_min="0"
-     value_max="1">
+     value_max="3">
 	 <param_driver />
     </param>
     <param
@@ -12058,7 +12058,7 @@ render_pass="bump">
      edit_group="physics_belly_updown"
      value_default=".1"
      value_min="0"
-     value_max="1">
+     value_max="3">
 	 <param_driver />
     </param>
     <param
@@ -12144,7 +12144,7 @@ render_pass="bump">
      edit_group="physics_butt_updown"
      value_default=".1"
      value_min="0"
-     value_max="1">
+     value_max="3">
 	 <param_driver />
     </param>
     <param
@@ -12193,7 +12193,7 @@ render_pass="bump">
      edit_group="physics_butt_leftright"
      value_default=".1"
      value_min="0"
-     value_max="1">
+     value_max="3">
 	 <param_driver />
     </param>
     <param
@@ -12244,7 +12244,7 @@ render_pass="bump">
      edit_group="physics_breasts_leftright"
      value_default=".1"
      value_min="0"
-     value_max="1">
+     value_max="3">
 	 <param_driver />
     </param>
     <param
-- 
cgit v1.2.3