diff options
author | Melanie | 2012-08-18 19:01:05 +0100 |
---|---|---|
committer | Melanie | 2012-08-18 19:01:05 +0100 |
commit | 914f97cb761842b9e5627adde78fe36eccc753bd (patch) | |
tree | e1eebb8ebd92ee8019f7bfd9262d88501e5aaf38 /OpenSim | |
parent | Merge branch 'master' into careminster (diff) | |
parent | integrating redundant code into operator (diff) | |
download | opensim-SC-914f97cb761842b9e5627adde78fe36eccc753bd.zip opensim-SC-914f97cb761842b9e5627adde78fe36eccc753bd.tar.gz opensim-SC-914f97cb761842b9e5627adde78fe36eccc753bd.tar.bz2 opensim-SC-914f97cb761842b9e5627adde78fe36eccc753bd.tar.xz |
Merge branch 'master' into careminster
Conflicts:
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
Diffstat (limited to 'OpenSim')
7 files changed, 47 insertions, 37 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())); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs index 929948b..84cf6ca 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs | |||
@@ -333,8 +333,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
333 | { | 333 | { |
334 | if (type == typeof(OpenMetaverse.Quaternion)) | 334 | if (type == typeof(OpenMetaverse.Quaternion)) |
335 | { | 335 | { |
336 | LSL_Rotation rot = (LSL_Rotation)lslparm; | 336 | return (OpenMetaverse.Quaternion)((LSL_Rotation)lslparm); |
337 | return new OpenMetaverse.Quaternion((float)rot.x,(float)rot.y,(float)rot.z,(float)rot.s); | ||
338 | } | 337 | } |
339 | } | 338 | } |
340 | 339 | ||
@@ -366,8 +365,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
366 | result[i] = new UUID((LSL_Key)plist[i]); | 365 | result[i] = new UUID((LSL_Key)plist[i]); |
367 | else if (plist[i] is LSL_Rotation) | 366 | else if (plist[i] is LSL_Rotation) |
368 | { | 367 | { |
369 | LSL_Rotation rot = (LSL_Rotation)plist[i]; | 368 | result[i] = (OpenMetaverse.Quaternion)( |
370 | result[i] = new OpenMetaverse.Quaternion((float)rot.x,(float)rot.y,(float)rot.z,(float)rot.s); | 369 | (LSL_Rotation)plist[i]); |
371 | } | 370 | } |
372 | else if (plist[i] is LSL_Vector) | 371 | else if (plist[i] is LSL_Vector) |
373 | { | 372 | { |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 321d1d8..37766fb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -2565,7 +2565,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2565 | ScenePresence sp = World.GetScenePresence(npcId); | 2565 | ScenePresence sp = World.GetScenePresence(npcId); |
2566 | 2566 | ||
2567 | if (sp != null) | 2567 | if (sp != null) |
2568 | sp.Rotation = LSL_Api.Rot2Quaternion(rotation); | 2568 | sp.Rotation = rotation; |
2569 | } | 2569 | } |
2570 | } | 2570 | } |
2571 | 2571 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index 8b3be4a..4dd795d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs | |||
@@ -352,7 +352,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
352 | q = avatar.Rotation; | 352 | q = avatar.Rotation; |
353 | } | 353 | } |
354 | 354 | ||
355 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); | 355 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q); |
356 | LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); | 356 | LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); |
357 | double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); | 357 | double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); |
358 | 358 | ||
@@ -482,7 +482,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
482 | q = avatar.Rotation; | 482 | q = avatar.Rotation; |
483 | } | 483 | } |
484 | 484 | ||
485 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); | 485 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q); |
486 | LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); | 486 | LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); |
487 | double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); | 487 | double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); |
488 | bool attached = (SensePoint.ParentGroup.AttachmentPoint != 0); | 488 | bool attached = (SensePoint.ParentGroup.AttachmentPoint != 0); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index 4ab2f23..c9c4753 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | |||
@@ -361,6 +361,14 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
361 | s = 1; | 361 | s = 1; |
362 | } | 362 | } |
363 | 363 | ||
364 | public Quaternion(OMV_Quaternion rot) | ||
365 | { | ||
366 | x = rot.X; | ||
367 | y = rot.Y; | ||
368 | z = rot.Z; | ||
369 | s = rot.W; | ||
370 | } | ||
371 | |||
364 | #endregion | 372 | #endregion |
365 | 373 | ||
366 | #region Overriders | 374 | #region Overriders |
@@ -407,6 +415,21 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
407 | return new list(new object[] { r }); | 415 | return new list(new object[] { r }); |
408 | } | 416 | } |
409 | 417 | ||
418 | public static implicit operator OMV_Quaternion(Quaternion rot) | ||
419 | { | ||
420 | // LSL quaternions can normalize to 0, normal Quaternions can't. | ||
421 | if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0) | ||
422 | rot.z = 1; // ZERO_ROTATION = 0,0,0,1 | ||
423 | OMV_Quaternion omvrot = new OMV_Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); | ||
424 | omvrot.Normalize(); | ||
425 | return omvrot; | ||
426 | } | ||
427 | |||
428 | public static implicit operator Quaternion(OMV_Quaternion rot) | ||
429 | { | ||
430 | return new Quaternion(rot); | ||
431 | } | ||
432 | |||
410 | public static bool operator ==(Quaternion lhs, Quaternion rhs) | 433 | public static bool operator ==(Quaternion lhs, Quaternion rhs) |
411 | { | 434 | { |
412 | // Return true if the fields match: | 435 | // Return true if the fields match: |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs index a1ad07d..cee10df 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs | |||
@@ -391,8 +391,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
391 | myScriptEngine.PostObjectEvent(localID, new EventParams( | 391 | myScriptEngine.PostObjectEvent(localID, new EventParams( |
392 | "at_rot_target", new object[] { | 392 | "at_rot_target", new object[] { |
393 | new LSL_Types.LSLInteger(handle), | 393 | new LSL_Types.LSLInteger(handle), |
394 | new LSL_Types.Quaternion(targetrot.X,targetrot.Y,targetrot.Z,targetrot.W), | 394 | new LSL_Types.Quaternion(targetrot), |
395 | new LSL_Types.Quaternion(atrot.X,atrot.Y,atrot.Z,atrot.W) }, | 395 | new LSL_Types.Quaternion(atrot) }, |
396 | new DetectParams[0])); | 396 | new DetectParams[0])); |
397 | } | 397 | } |
398 | 398 | ||
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index eee5d7b..f5ad990 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -1558,7 +1558,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1558 | else if (p[i] is Vector3) | 1558 | else if (p[i] is Vector3) |
1559 | lsl_p[i] = new LSL_Types.Vector3((Vector3)p[i]); | 1559 | lsl_p[i] = new LSL_Types.Vector3((Vector3)p[i]); |
1560 | else if (p[i] is Quaternion) | 1560 | else if (p[i] is Quaternion) |
1561 | lsl_p[i] = new LSL_Types.Quaternion(((Quaternion)p[i]).X, ((Quaternion)p[i]).Y, ((Quaternion)p[i]).Z, ((Quaternion)p[i]).W); | 1561 | lsl_p[i] = new LSL_Types.Quaternion((Quaternion)p[i]); |
1562 | else if (p[i] is float) | 1562 | else if (p[i] is float) |
1563 | lsl_p[i] = new LSL_Types.LSLFloat((float)p[i]); | 1563 | lsl_p[i] = new LSL_Types.LSLFloat((float)p[i]); |
1564 | else | 1564 | else |
@@ -1584,7 +1584,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1584 | else if (p[i] is Vector3) | 1584 | else if (p[i] is Vector3) |
1585 | lsl_p[i] = new LSL_Types.Vector3((Vector3)p[i]); | 1585 | lsl_p[i] = new LSL_Types.Vector3((Vector3)p[i]); |
1586 | else if (p[i] is Quaternion) | 1586 | else if (p[i] is Quaternion) |
1587 | lsl_p[i] = new LSL_Types.Quaternion(((Quaternion)p[i]).X, ((Quaternion)p[i]).Y, ((Quaternion)p[i]).Z, ((Quaternion)p[i]).W); | 1587 | lsl_p[i] = new LSL_Types.Quaternion((Quaternion)p[i]); |
1588 | else if (p[i] is float) | 1588 | else if (p[i] is float) |
1589 | lsl_p[i] = new LSL_Types.LSLFloat((float)p[i]); | 1589 | lsl_p[i] = new LSL_Types.LSLFloat((float)p[i]); |
1590 | else | 1590 | else |