diff options
author | Kitto Flora | 2010-06-17 13:04:32 -0400 |
---|---|---|
committer | Kitto Flora | 2010-06-17 13:04:32 -0400 |
commit | cea79056025950303e3b784d824d3cb6168152d0 (patch) | |
tree | 0e708850e10f2a6b65cf718264b526ff1a12b9c5 /OpenSim/Region/ScriptEngine | |
parent | Add rez on water surface. (diff) | |
parent | Merge branch 'careminster-presence-refactor' of ssh://3dhosting.de/var/git/ca... (diff) | |
download | opensim-SC-cea79056025950303e3b784d824d3cb6168152d0.zip opensim-SC-cea79056025950303e3b784d824d3cb6168152d0.tar.gz opensim-SC-cea79056025950303e3b784d824d3cb6168152d0.tar.bz2 opensim-SC-cea79056025950303e3b784d824d3cb6168152d0.tar.xz |
Merge branch 'careminster-presence-refactor' of ssh://3dhosting.de/var/git/careminster into careminster-presence-refactor
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 72 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 9 |
2 files changed, 50 insertions, 31 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 9f3e354..fe8c70e 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -502,25 +502,33 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
502 | return remainder; | 502 | return remainder; |
503 | } | 503 | } |
504 | 504 | ||
505 | // Old implementation of llRot2Euler, now normalized | 505 | public LSL_Vector llRot2Euler(LSL_Rotation q1) |
506 | 506 | { | |
507 | public LSL_Vector llRot2Euler(LSL_Rotation r) | 507 | m_host.AddScriptLPS(1); |
508 | { | 508 | LSL_Vector eul = new LSL_Vector(); |
509 | m_host.AddScriptLPS(1); | 509 | |
510 | //This implementation is from http://lslwiki.net/lslwiki/wakka.php?wakka=LibraryRotationFunctions. ckrinke | 510 | double sqw = q1.s*q1.s; |
511 | LSL_Rotation t = new LSL_Rotation(r.x * r.x, r.y * r.y, r.z * r.z, r.s * r.s); | 511 | double sqx = q1.x*q1.x; |
512 | double m = (t.x + t.y + t.z + t.s); | 512 | double sqy = q1.z*q1.z; |
513 | if (m == 0) return new LSL_Vector(); | 513 | double sqz = q1.y*q1.y; |
514 | double n = 2 * (r.y * r.s + r.x * r.z); | 514 | double unit = sqx + sqy + sqz + sqw; // if normalised is one, otherwise is correction factor |
515 | double p = m * m - n * n; | 515 | double test = q1.x*q1.z + q1.y*q1.s; |
516 | if (p > 0) | 516 | if (test > 0.4999*unit) { // singularity at north pole |
517 | return new LSL_Vector(NormalizeAngle(Math.Atan2(2.0 * (r.x * r.s - r.y * r.z), (-t.x - t.y + t.z + t.s))), | 517 | eul.z = 2 * Math.Atan2(q1.x,q1.s); |
518 | NormalizeAngle(Math.Atan2(n, Math.Sqrt(p))), | 518 | eul.y = Math.PI/2; |
519 | NormalizeAngle(Math.Atan2(2.0 * (r.z * r.s - r.x * r.y), (t.x - t.y - t.z + t.s)))); | 519 | eul.x = 0; |
520 | else if (n > 0) | 520 | return eul; |
521 | 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))); | 521 | } |
522 | else | 522 | if (test < -0.4999*unit) { // singularity at south pole |
523 | 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))); | 523 | eul.z = -2 * Math.Atan2(q1.x,q1.s); |
524 | eul.y = -Math.PI/2; | ||
525 | eul.x = 0; | ||
526 | return eul; | ||
527 | } | ||
528 | eul.z = Math.Atan2(2*q1.z*q1.s-2*q1.x*q1.y , sqx - sqy - sqz + sqw); | ||
529 | eul.y = Math.Asin(2*test/unit); | ||
530 | eul.x = Math.Atan2(2*q1.x*q1.s-2*q1.z*q1.y , -sqx + sqy - sqz + sqw); | ||
531 | return eul; | ||
524 | } | 532 | } |
525 | 533 | ||
526 | /* From wiki: | 534 | /* From wiki: |
@@ -3065,9 +3073,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3065 | { | 3073 | { |
3066 | m_host.AddScriptLPS(1); | 3074 | m_host.AddScriptLPS(1); |
3067 | 3075 | ||
3068 | if (m_host.ParentGroup.RootPart.AttachmentPoint == 0) | ||
3069 | return; | ||
3070 | |||
3071 | TaskInventoryItem item; | 3076 | TaskInventoryItem item; |
3072 | 3077 | ||
3073 | m_host.TaskInventory.LockItemsForRead(true); | 3078 | m_host.TaskInventory.LockItemsForRead(true); |
@@ -3093,11 +3098,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3093 | 3098 | ||
3094 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); | 3099 | ScenePresence presence = World.GetScenePresence(m_host.OwnerID); |
3095 | 3100 | ||
3101 | /* | ||
3096 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; | 3102 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; |
3097 | if (attachmentsModule != null) | 3103 | if (attachmentsModule != null) |
3104 | { | ||
3098 | attachmentsModule.AttachObject( | 3105 | attachmentsModule.AttachObject( |
3099 | presence.ControllingClient, grp.LocalId, | 3106 | presence.ControllingClient, grp.LocalId, |
3100 | (uint)attachment, Quaternion.Identity, Vector3.Zero, false); | 3107 | (uint)attachment, Quaternion.Identity, Vector3.Zero, false); |
3108 | } | ||
3109 | */ | ||
3110 | grp.AttachToAgent(m_host.OwnerID, (uint)attachment, Vector3.Zero, false); | ||
3101 | } | 3111 | } |
3102 | } | 3112 | } |
3103 | 3113 | ||
@@ -9470,8 +9480,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9470 | { | 9480 | { |
9471 | m_host.AddScriptLPS(1); | 9481 | m_host.AddScriptLPS(1); |
9472 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, 0); | 9482 | DetectParams detectedParams = m_ScriptEngine.GetDetectParams(m_itemID, 0); |
9473 | if (detectedParams == null) return; // only works on the first detected avatar | 9483 | if (detectedParams == null) |
9474 | 9484 | { | |
9485 | if (m_host.IsAttachment == true) | ||
9486 | { | ||
9487 | detectedParams = new DetectParams(); | ||
9488 | detectedParams.Key = m_host.OwnerID; | ||
9489 | } | ||
9490 | else | ||
9491 | { | ||
9492 | return; | ||
9493 | } | ||
9494 | } | ||
9495 | |||
9475 | ScenePresence avatar = World.GetScenePresence(detectedParams.Key); | 9496 | ScenePresence avatar = World.GetScenePresence(detectedParams.Key); |
9476 | if (avatar != null) | 9497 | if (avatar != null) |
9477 | { | 9498 | { |
@@ -9479,6 +9500,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9479 | new Vector3((float)pos.x, (float)pos.y, (float)pos.z), | 9500 | new Vector3((float)pos.x, (float)pos.y, (float)pos.z), |
9480 | new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z)); | 9501 | new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z)); |
9481 | } | 9502 | } |
9503 | |||
9482 | ScriptSleep(1000); | 9504 | ScriptSleep(1000); |
9483 | } | 9505 | } |
9484 | 9506 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 0e86c86..db43902 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -2222,12 +2222,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2222 | { | 2222 | { |
2223 | if (avatar.IsChildAgent == false) | 2223 | if (avatar.IsChildAgent == false) |
2224 | { | 2224 | { |
2225 | if (avatar.PhysicsActor != null && avatar.PhysicsActor.Position != null) | 2225 | result.Add(avatar.UUID); |
2226 | { | 2226 | result.Add(avatar.AbsolutePosition); |
2227 | result.Add(avatar.UUID); | 2227 | result.Add(avatar.Name); |
2228 | result.Add(avatar.PhysicsActor.Position); | ||
2229 | result.Add(avatar.Name); | ||
2230 | } | ||
2231 | } | 2228 | } |
2232 | } | 2229 | } |
2233 | }); | 2230 | }); |