From 209110d1aa7ee369ccdf68641c3d7f9e558427de Mon Sep 17 00:00:00 2001
From: Loren Shih <seraph@lindenlab.com>
Date: Mon, 21 Mar 2011 15:39:42 -0400
Subject: [PATCH] Velocity now gets zeroed out if the param is pushed beyond
 limits. Rescaled the max speed param.

---
 indra/newview/character/avatar_lad.xml | 24 ++++++++++++------------
 indra/newview/llphysicsmotion.cpp      |  8 +++++++-
 2 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/indra/newview/character/avatar_lad.xml b/indra/newview/character/avatar_lad.xml
index 69512cdf342..d8f6fd56b32 100644
--- a/indra/newview/character/avatar_lad.xml
+++ b/indra/newview/character/avatar_lad.xml
@@ -3801,7 +3801,7 @@
      wearable="shape"
      edit_group="driven"
      value_default="0"
-     value_min="0"
+     value_min="-1"
      value_max="1">
       <param_morph />
     </param>
@@ -4396,7 +4396,7 @@
      name="Belly_Legs_Physics_UpDown_Driven"
      wearable="shape"
      edit_group="driven"
-     value_min="0"
+     value_min="-1"
      value_max="1">
       <param_morph />
     </param>
@@ -9141,9 +9141,9 @@ render_pass="bump">
      edit_group="physics"
      label_min="Less"
      label_max="More"
-     value_default=".2"
+     value_default=".1"
      value_min=".1"
-     value_max=".5"
+     value_max="1"
      camera_elevation=".3"
      camera_distance=".8">
 	 <param_driver />
@@ -9267,9 +9267,9 @@ render_pass="bump">
      edit_group="physics"
      label_min="Less"
      label_max="More"
-     value_default=".1"
+     value_default="0"
      value_min="0"
-     value_max=".1"
+     value_max="10"
      camera_elevation=".3"
      camera_distance=".8">
 	 <param_driver />
@@ -9358,9 +9358,9 @@ render_pass="bump">
      edit_group="physics"
      label_min="Less"
      label_max="More"
-     value_default=".1"
+     value_default="0"
      value_min="0"
-     value_max=".1"
+     value_max="10"
      camera_elevation=".3"
      camera_distance=".8">
 	 <param_driver />
@@ -10261,9 +10261,9 @@ render_pass="bump">
      edit_group="physics"
      label_min="Less"
      label_max="More"
-     value_default=".1"
+     value_default="0"
      value_min="0"
-     value_max=".1"
+     value_max="10"
      camera_elevation=".3"
      camera_distance=".8">
 	 <param_driver />
@@ -10329,9 +10329,9 @@ render_pass="bump">
      edit_group="physics"
      label_min="Less"
      label_max="More"
-     value_default=".1"
+     value_default="0"
      value_min="0"
-     value_max=".1"
+     value_max="10"
      camera_elevation=".3"
      camera_distance=".8">
 	 <param_driver />
diff --git a/indra/newview/llphysicsmotion.cpp b/indra/newview/llphysicsmotion.cpp
index 2a88a4a2b5f..48e632280ed 100644
--- a/indra/newview/llphysicsmotion.cpp
+++ b/indra/newview/llphysicsmotion.cpp
@@ -523,7 +523,7 @@ BOOL LLPhysicsMotion::onUpdate(F32 time)
 	const F32 acceleration_new_local = force_net / behavior_mass;
 	F32 velocity_new_local = mVelocity_local + acceleration_new_local;
 	velocity_new_local = llclamp(velocity_new_local, 
-				     -behavior_maxspeed*100.0f, behavior_maxspeed*100.0f);
+				     -behavior_maxspeed, behavior_maxspeed);
 	
 	// Temporary debugging setting to cause all avatars to move, for profiling purposes.
 	if (gSavedSettings.getBOOL("AvatarPhysicsTest"))
@@ -535,6 +535,12 @@ BOOL LLPhysicsMotion::onUpdate(F32 time)
 		(position_current_local + velocity_new_local*time_delta) :
 		position_user_local;
 
+	// Zero out the velocity if the param is being pushed beyond its limits.
+	if (position_new_local < 0 || position_new_local > 1)
+	{
+		velocity_new_local = 0;
+	}
+
 	const F32 position_new_local_clamped = llclamp(position_new_local,
 						       0.0f,
 						       1.0f);
-- 
GitLab