aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs40
1 files changed, 14 insertions, 26 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index c305f86..717cc07 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -426,14 +426,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
426 return key; 426 return key;
427 } 427 }
428 428
429 // convert a LSL_Rotation to a Quaternion
430 public static Quaternion Rot2Quaternion(LSL_Rotation r)
431 {
432 Quaternion q = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s);
433 q.Normalize();
434 return q;
435 }
436
437 //These are the implementations of the various ll-functions used by the LSL scripts. 429 //These are the implementations of the various ll-functions used by the LSL scripts.
438 public LSL_Float llSin(double f) 430 public LSL_Float llSin(double f)
439 { 431 {
@@ -2331,7 +2323,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2331 // using it would cause attachments and HUDs to rotate 2323 // using it would cause attachments and HUDs to rotate
2332 // to the wrong positions. 2324 // to the wrong positions.
2333 2325
2334 SetRot(m_host, Rot2Quaternion(rot)); 2326 SetRot(m_host, rot);
2335 } 2327 }
2336 else 2328 else
2337 { 2329 {
@@ -2341,7 +2333,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2341 { 2333 {
2342 rootPart = m_host.ParentGroup.RootPart; 2334 rootPart = m_host.ParentGroup.RootPart;
2343 if (rootPart != null) 2335 if (rootPart != null)
2344 SetRot(m_host, rootPart.RotationOffset * Rot2Quaternion(rot)); 2336 SetRot(m_host, rootPart.RotationOffset * (Quaternion)rot);
2345 } 2337 }
2346 } 2338 }
2347 2339
@@ -2351,8 +2343,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2351 public void llSetLocalRot(LSL_Rotation rot) 2343 public void llSetLocalRot(LSL_Rotation rot)
2352 { 2344 {
2353 m_host.AddScriptLPS(1); 2345 m_host.AddScriptLPS(1);
2354 2346 SetRot(m_host, rot);
2355 SetRot(m_host, Rot2Quaternion(rot));
2356 ScriptSleep(200); 2347 ScriptSleep(200);
2357 } 2348 }
2358 2349
@@ -2498,8 +2489,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2498 public LSL_Integer llRotTarget(LSL_Rotation rot, double error) 2489 public LSL_Integer llRotTarget(LSL_Rotation rot, double error)
2499 { 2490 {
2500 m_host.AddScriptLPS(1); 2491 m_host.AddScriptLPS(1);
2501 return m_host.ParentGroup.registerRotTargetWaypoint( 2492 return m_host.ParentGroup.registerRotTargetWaypoint(rot, (float)error);
2502 new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s), (float)error);
2503 } 2493 }
2504 2494
2505 public void llRotTargetRemove(int number) 2495 public void llRotTargetRemove(int number)
@@ -3111,7 +3101,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3111 // need the magnitude later 3101 // need the magnitude later
3112 // float velmag = (float)Util.GetMagnitude(llvel); 3102 // float velmag = (float)Util.GetMagnitude(llvel);
3113 3103
3114 SceneObjectGroup new_group = World.RezObject(m_host, item, pos, Rot2Quaternion(rot), vel, param); 3104 SceneObjectGroup new_group = World.RezObject(m_host, item, pos, rot, vel, param);
3115 3105
3116 // If either of these are null, then there was an unknown error. 3106 // If either of these are null, then there was an unknown error.
3117 if (new_group == null) 3107 if (new_group == null)
@@ -3193,7 +3183,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3193 return; 3183 return;
3194 } 3184 }
3195 3185
3196 m_host.StartLookAt(Rot2Quaternion(r3 * r2 * r1), (float)strength, (float)damping); 3186 m_host.StartLookAt((Quaternion)(r3 * r2 * r1), (float)strength, (float)damping);
3197 } 3187 }
3198 } 3188 }
3199 3189
@@ -3619,7 +3609,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3619 } 3609 }
3620 else 3610 else
3621 { 3611 {
3622 m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping); 3612 m_host.RotLookAt(target, (float)strength, (float)damping);
3623 } 3613 }
3624 } 3614 }
3625 3615
@@ -6970,7 +6960,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6970 6960
6971 if (!m_host.ParentGroup.IsDeleted) 6961 if (!m_host.ParentGroup.IsDeleted)
6972 { 6962 {
6973 m_host.ParentGroup.RootPart.SetVehicleRotationParam(param, Rot2Quaternion(rot)); 6963 m_host.ParentGroup.RootPart.SetVehicleRotationParam(param, rot);
6974 } 6964 }
6975 } 6965 }
6976 6966
@@ -7001,7 +6991,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7001 rot.s = 1; // ZERO_ROTATION = 0,0,0,1 6991 rot.s = 1; // ZERO_ROTATION = 0,0,0,1
7002 6992
7003 part.SitTargetPosition = offset; 6993 part.SitTargetPosition = offset;
7004 part.SitTargetOrientation = Rot2Quaternion(rot); 6994 part.SitTargetOrientation = rot;
7005 part.ParentGroup.HasGroupChanged = true; 6995 part.ParentGroup.HasGroupChanged = true;
7006 } 6996 }
7007 6997
@@ -8066,13 +8056,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8066 if (rootPart == part) 8056 if (rootPart == part)
8067 { 8057 {
8068 // special case: If we are root, rotate complete SOG to new rotation 8058 // special case: If we are root, rotate complete SOG to new rotation
8069 SetRot(part, Rot2Quaternion(q)); 8059 SetRot(part, q);
8070 } 8060 }
8071 else 8061 else
8072 { 8062 {
8073 // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. 8063 // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask.
8074 // sounds like sl bug that we need to replicate 8064 // sounds like sl bug that we need to replicate
8075 SetRot(part, rootPart.RotationOffset * Rot2Quaternion(q)); 8065 SetRot(part, rootPart.RotationOffset * (Quaternion)q);
8076 } 8066 }
8077 8067
8078 break; 8068 break;
@@ -8414,8 +8404,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8414 case (int)ScriptBaseClass.PRIM_ROT_LOCAL: 8404 case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
8415 if (remain < 1) 8405 if (remain < 1)
8416 return null; 8406 return null;
8417 LSL_Rotation lr = rules.GetQuaternionItem(idx++); 8407 SetRot(part, rules.GetQuaternionItem(idx++));
8418 SetRot(part, Rot2Quaternion(lr));
8419 break; 8408 break;
8420 case (int)ScriptBaseClass.PRIM_OMEGA: 8409 case (int)ScriptBaseClass.PRIM_OMEGA:
8421 if (remain < 3) 8410 if (remain < 3)
@@ -11878,13 +11867,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11878 else 11867 else
11879 rot = obj.GetWorldRotation(); 11868 rot = obj.GetWorldRotation();
11880 11869
11881 LSL_Rotation objrot = new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W); 11870 LSL_Rotation objrot = new LSL_Rotation(rot);
11882 ret.Add(objrot); 11871 ret.Add(objrot);
11883 } 11872 }
11884 break; 11873 break;
11885 case ScriptBaseClass.OBJECT_VELOCITY: 11874 case ScriptBaseClass.OBJECT_VELOCITY:
11886 Vector3 ovel = obj.Velocity; 11875 ret.Add(new LSL_Vector(obj.Velocity));
11887 ret.Add(new LSL_Vector(ovel.X, ovel.Y, ovel.Z));
11888 break; 11876 break;
11889 case ScriptBaseClass.OBJECT_OWNER: 11877 case ScriptBaseClass.OBJECT_OWNER:
11890 ret.Add(new LSL_String(obj.OwnerID.ToString())); 11878 ret.Add(new LSL_String(obj.OwnerID.ToString()));