From 7a67b726d5be8b7eb7d04eabdb98dc4e3beb9d71 Mon Sep 17 00:00:00 2001
From: dahlia
Date: Mon, 7 Sep 2009 17:12:17 -0700
Subject: random drive-by maths optimization in llRot2Euler() and llEuler2Rot()

---
 .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs    | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 16dd834..077315e 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -497,9 +497,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
                                              NormalizeAngle(Math.Atan2(n, Math.Sqrt(p))),
                                              NormalizeAngle(Math.Atan2(2.0 * (r.z * r.s - r.x * r.y), (t.x - t.y - t.z + t.s))));
             else if (n > 0)
-                return new LSL_Vector(0.0, Math.PI / 2, NormalizeAngle(Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z)));
+                return new LSL_Vector(0.0, Math.PI * 0.5, NormalizeAngle(Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z)));
             else
-                return new LSL_Vector(0.0, -Math.PI / 2, NormalizeAngle(Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z)));
+                return new LSL_Vector(0.0, -Math.PI * 0.5, NormalizeAngle(Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z)));
         }
 
         /* From wiki:
@@ -553,12 +553,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
 
             double x,y,z,s;
 
-            double c1 = Math.Cos(v.x/2.0);
-            double c2 = Math.Cos(v.y/2.0);
-            double c3 = Math.Cos(v.z/2.0);
-            double s1 = Math.Sin(v.x/2.0);
-            double s2 = Math.Sin(v.y/2.0);
-            double s3 = Math.Sin(v.z/2.0);
+            double c1 = Math.Cos(v.x * 0.5);
+            double c2 = Math.Cos(v.y * 0.5);
+            double c3 = Math.Cos(v.z * 0.5);
+            double s1 = Math.Sin(v.x * 0.5);
+            double s2 = Math.Sin(v.y * 0.5);
+            double s3 = Math.Sin(v.z * 0.5);
 
             x = s1*c2*c3+c1*s2*s3;
             y = c1*s2*c3-s1*c2*s3;
-- 
cgit v1.1


From 665cf0194afff36f7f4ceae80af83aa253ec61a2 Mon Sep 17 00:00:00 2001
From: dahlia
Date: Mon, 7 Sep 2009 18:02:02 -0700
Subject: llRot2Euler() now returns angles -PI < angle < PI

---
 .../Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs  | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 077315e..f261c16 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -476,9 +476,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
         // normalize an angle between -PI and PI (-180 to +180 degrees)
         protected double NormalizeAngle(double angle)
         {
-            angle = angle % (Math.PI * 2);
-            // if (angle < 0) angle = angle + Math.PI * 2;
-            return angle;
+            if (angle > -Math.PI && angle < Math.PI)
+                return angle;
+
+            int numPis = (int)(Math.PI / angle);
+            double remainder = angle - Math.PI * numPis;
+            if (numPis % 2 == 1)
+                return Math.PI - angle;
+            return remainder;
         }
 
         // Old implementation of llRot2Euler, now normalized
-- 
cgit v1.1


From 9a06056c9afee3f8c99c0a9e9513e5274bfcb45e Mon Sep 17 00:00:00 2001
From: Teravus Ovares (Dan Olivares)
Date: Tue, 8 Sep 2009 04:43:00 -0400
Subject: * Fixes a 'take object from mega region' and rez it in a regular
 region..     and have it appear 5 regions over bug by limiting the stored
 position in the asset to Constants.RegionSize.   The stored position in the
 asset gets overwritten anyway by the rezzing routine, but at least this way,
 there's no chance of the objects border crossing before the rezzing routine
 finishes.

---
 OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 36 +++++++++++++++++++++-
 OpenSim/Region/Framework/Scenes/Scene.cs           | 17 ++++++++++
 2 files changed, 52 insertions(+), 1 deletion(-)

(limited to 'OpenSim/Region')

diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index f638386..4ea283f 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -1620,8 +1620,24 @@ namespace OpenSim.Region.Framework.Scenes
         {
             UUID assetID = UUID.Zero;
 
+            Vector3 inventoryStoredPosition = new Vector3
+                        (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
+                              ? 250
+                              : objectGroup.AbsolutePosition.X)
+                         ,
+                         (objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
+                             ? 250
+                             : objectGroup.AbsolutePosition.X,
+                         objectGroup.AbsolutePosition.Z);
+
+            Vector3 originalPosition = objectGroup.AbsolutePosition;
+
+            objectGroup.AbsolutePosition = inventoryStoredPosition;
+
             string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup);
 
+            objectGroup.AbsolutePosition = originalPosition;
+
             // Get the user info of the item destination
             //
             UUID userID = UUID.Zero;
@@ -1683,6 +1699,8 @@ namespace OpenSim.Region.Framework.Scenes
                 {
                     // Deleting someone else's item
                     //
+                    
+
                     if (remoteClient == null ||
                         objectGroup.OwnerID != remoteClient.AgentId)
                     {
@@ -1857,8 +1875,24 @@ namespace OpenSim.Region.Framework.Scenes
             itemID = UUID.Zero;
             if (grp != null)
             {
+                Vector3 inventoryStoredPosition = new Vector3
+                       (((grp.AbsolutePosition.X > (int)Constants.RegionSize)
+                             ? 250
+                             : grp.AbsolutePosition.X)
+                        ,
+                        (grp.AbsolutePosition.X > (int)Constants.RegionSize)
+                            ? 250
+                            : grp.AbsolutePosition.X,
+                        grp.AbsolutePosition.Z);
+
+                Vector3 originalPosition = grp.AbsolutePosition;
+
+                grp.AbsolutePosition = inventoryStoredPosition;
+
                 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);
-              
+
+                grp.AbsolutePosition = originalPosition;
+
                 AssetBase asset = CreateAsset(
                     grp.GetPartName(grp.LocalId),
                     grp.GetPartDescription(grp.LocalId),
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 3b91dd0..d43a7e2 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -4256,7 +4256,24 @@ namespace OpenSim.Region.Framework.Scenes
                 break;
 
             case 2: // Sell a copy
+
+
+                Vector3 inventoryStoredPosition = new Vector3
+                       (((group.AbsolutePosition.X > (int)Constants.RegionSize)
+                             ? 250
+                             : group.AbsolutePosition.X)
+                        ,
+                        (group.AbsolutePosition.X > (int)Constants.RegionSize)
+                            ? 250
+                            : group.AbsolutePosition.X,
+                        group.AbsolutePosition.Z);
+
+                Vector3 originalPosition = group.AbsolutePosition;
+
+                group.AbsolutePosition = inventoryStoredPosition;
+
                 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(group);
+                group.AbsolutePosition = originalPosition;
 
                 uint perms=group.GetEffectivePermissions();
 
-- 
cgit v1.1