diff options
author | Melanie | 2012-07-06 20:51:18 +0100 |
---|---|---|
committer | Melanie | 2012-07-06 20:51:18 +0100 |
commit | 26d89777d88c9abfa35fed0b78bcd8f93c3d0bf2 (patch) | |
tree | bf9802d765a4965dd1b42c4b2d3145b5813c0c1f /OpenSim/Region/ScriptEngine/Shared/Api/Implementation | |
parent | Merge branch 'master' into careminster (diff) | |
parent | added llSetVelocity. will refuse to work on vehicles and on attachments ( th... (diff) | |
download | opensim-SC-26d89777d88c9abfa35fed0b78bcd8f93c3d0bf2.zip opensim-SC-26d89777d88c9abfa35fed0b78bcd8f93c3d0bf2.tar.gz opensim-SC-26d89777d88c9abfa35fed0b78bcd8f93c3d0bf2.tar.bz2 opensim-SC-26d89777d88c9abfa35fed0b78bcd8f93c3d0bf2.tar.xz |
Merge branch 'avination' into careminster
Conflicts:
OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs
OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 225 |
1 files changed, 179 insertions, 46 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 14dd2ad..b257cd4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -618,18 +618,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
618 | m_host.AddScriptLPS(1); | 618 | m_host.AddScriptLPS(1); |
619 | 619 | ||
620 | double x,y,z,s; | 620 | double x,y,z,s; |
621 | 621 | v.x *= 0.5; | |
622 | double c1 = Math.Cos(v.x * 0.5); | 622 | v.y *= 0.5; |
623 | double c2 = Math.Cos(v.y * 0.5); | 623 | v.z *= 0.5; |
624 | double c3 = Math.Cos(v.z * 0.5); | 624 | double c1 = Math.Cos(v.x); |
625 | double s1 = Math.Sin(v.x * 0.5); | 625 | double c2 = Math.Cos(v.y); |
626 | double s2 = Math.Sin(v.y * 0.5); | 626 | double c1c2 = c1 * c2; |
627 | double s3 = Math.Sin(v.z * 0.5); | 627 | double s1 = Math.Sin(v.x); |
628 | 628 | double s2 = Math.Sin(v.y); | |
629 | x = s1 * c2 * c3 + c1 * s2 * s3; | 629 | double s1s2 = s1 * s2; |
630 | y = c1 * s2 * c3 - s1 * c2 * s3; | 630 | double c1s2 = c1 * s2; |
631 | z = s1 * s2 * c3 + c1 * c2 * s3; | 631 | double s1c2 = s1 * c2; |
632 | s = c1 * c2 * c3 - s1 * s2 * s3; | 632 | double c3 = Math.Cos(v.z); |
633 | double s3 = Math.Sin(v.z); | ||
634 | |||
635 | x = s1c2 * c3 + c1s2 * s3; | ||
636 | y = c1s2 * c3 - s1c2 * s3; | ||
637 | z = s1s2 * c3 + c1c2 * s3; | ||
638 | s = c1c2 * c3 - s1s2 * s3; | ||
633 | 639 | ||
634 | return new LSL_Rotation(x, y, z, s); | 640 | return new LSL_Rotation(x, y, z, s); |
635 | } | 641 | } |
@@ -1869,11 +1875,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1869 | Primitive.TextureEntry tex = part.Shape.Textures; | 1875 | Primitive.TextureEntry tex = part.Shape.Textures; |
1870 | Color4 texcolor; | 1876 | Color4 texcolor; |
1871 | LSL_Vector rgb = new LSL_Vector(); | 1877 | LSL_Vector rgb = new LSL_Vector(); |
1878 | int nsides = GetNumberOfSides(part); | ||
1879 | |||
1872 | if (face == ScriptBaseClass.ALL_SIDES) | 1880 | if (face == ScriptBaseClass.ALL_SIDES) |
1873 | { | 1881 | { |
1874 | int i; | 1882 | int i; |
1875 | 1883 | for (i = 0; i < nsides; i++) | |
1876 | for (i = 0 ; i < GetNumberOfSides(part); i++) | ||
1877 | { | 1884 | { |
1878 | texcolor = tex.GetFace((uint)i).RGBA; | 1885 | texcolor = tex.GetFace((uint)i).RGBA; |
1879 | rgb.x += texcolor.R; | 1886 | rgb.x += texcolor.R; |
@@ -1881,14 +1888,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1881 | rgb.z += texcolor.B; | 1888 | rgb.z += texcolor.B; |
1882 | } | 1889 | } |
1883 | 1890 | ||
1884 | rgb.x /= (float)GetNumberOfSides(part); | 1891 | float invnsides = 1.0f / (float)nsides; |
1885 | rgb.y /= (float)GetNumberOfSides(part); | 1892 | |
1886 | rgb.z /= (float)GetNumberOfSides(part); | 1893 | rgb.x *= invnsides; |
1894 | rgb.y *= invnsides; | ||
1895 | rgb.z *= invnsides; | ||
1887 | 1896 | ||
1888 | return rgb; | 1897 | return rgb; |
1889 | } | 1898 | } |
1890 | 1899 | if (face >= 0 && face < nsides) | |
1891 | if (face >= 0 && face < GetNumberOfSides(part)) | ||
1892 | { | 1900 | { |
1893 | texcolor = tex.GetFace((uint)face).RGBA; | 1901 | texcolor = tex.GetFace((uint)face).RGBA; |
1894 | rgb.x = texcolor.R; | 1902 | rgb.x = texcolor.R; |
@@ -2288,15 +2296,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2288 | // (root prim). ParentID may be nonzero in attachments and | 2296 | // (root prim). ParentID may be nonzero in attachments and |
2289 | // using it would cause attachments and HUDs to rotate | 2297 | // using it would cause attachments and HUDs to rotate |
2290 | // to the wrong positions. | 2298 | // to the wrong positions. |
2299 | |||
2291 | SetRot(m_host, Rot2Quaternion(rot)); | 2300 | SetRot(m_host, Rot2Quaternion(rot)); |
2292 | } | 2301 | } |
2293 | else | 2302 | else |
2294 | { | 2303 | { |
2295 | // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. | 2304 | // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. |
2296 | SceneObjectPart rootPart = m_host.ParentGroup.RootPart; | 2305 | SceneObjectPart rootPart; |
2297 | if (rootPart != null) // better safe than sorry | 2306 | if (m_host.ParentGroup != null) // better safe than sorry |
2298 | { | 2307 | { |
2299 | SetRot(m_host, rootPart.RotationOffset * Rot2Quaternion(rot)); | 2308 | rootPart = m_host.ParentGroup.RootPart; |
2309 | if (rootPart != null) | ||
2310 | SetRot(m_host, rootPart.RotationOffset * Rot2Quaternion(rot)); | ||
2300 | } | 2311 | } |
2301 | } | 2312 | } |
2302 | 2313 | ||
@@ -2306,6 +2317,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2306 | public void llSetLocalRot(LSL_Rotation rot) | 2317 | public void llSetLocalRot(LSL_Rotation rot) |
2307 | { | 2318 | { |
2308 | m_host.AddScriptLPS(1); | 2319 | m_host.AddScriptLPS(1); |
2320 | |||
2309 | SetRot(m_host, Rot2Quaternion(rot)); | 2321 | SetRot(m_host, Rot2Quaternion(rot)); |
2310 | ScriptSleep(200); | 2322 | ScriptSleep(200); |
2311 | } | 2323 | } |
@@ -2315,25 +2327,43 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2315 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | 2327 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
2316 | return; | 2328 | return; |
2317 | 2329 | ||
2318 | part.UpdateRotation(rot); | 2330 | bool isroot = (part == part.ParentGroup.RootPart); |
2319 | // Update rotation does not move the object in the physics scene if it's a linkset. | 2331 | bool isphys; |
2320 | 2332 | ||
2321 | //KF: Do NOT use this next line if using ODE physics engine. This need a switch based on .ini Phys Engine type | ||
2322 | // part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition; | ||
2323 | |||
2324 | // So, after thinking about this for a bit, the issue with the part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition line | ||
2325 | // is it isn't compatible with vehicles because it causes the vehicle body to have to be broken down and rebuilt | ||
2326 | // It's perfectly okay when the object is not an active physical body though. | ||
2327 | // So, part.ParentGroup.ResetChildPrimPhysicsPositions(); does the thing that Kitto is warning against | ||
2328 | // but only if the object is not physial and active. This is important for rotating doors. | ||
2329 | // without the absoluteposition = absoluteposition happening, the doors do not move in the physics | ||
2330 | // scene | ||
2331 | PhysicsActor pa = part.PhysActor; | 2333 | PhysicsActor pa = part.PhysActor; |
2332 | 2334 | ||
2333 | if (pa != null && !pa.IsPhysical && part == part.ParentGroup.RootPart) | 2335 | // keep using physactor ideia of isphysical |
2336 | // it should be SOP ideia of that | ||
2337 | // not much of a issue with ubitODE | ||
2338 | if (pa != null && pa.IsPhysical) | ||
2339 | isphys = true; | ||
2340 | else | ||
2341 | isphys = false; | ||
2342 | |||
2343 | // SL doesn't let scripts rotate root of physical linksets | ||
2344 | if (isroot && isphys) | ||
2345 | return; | ||
2346 | |||
2347 | part.UpdateRotation(rot); | ||
2348 | |||
2349 | // Update rotation does not move the object in the physics engine if it's a non physical linkset | ||
2350 | // so do a nasty update of parts positions if is a root part rotation | ||
2351 | if (isroot && pa != null) // with if above implies non physical root part | ||
2334 | { | 2352 | { |
2335 | part.ParentGroup.ResetChildPrimPhysicsPositions(); | 2353 | part.ParentGroup.ResetChildPrimPhysicsPositions(); |
2336 | } | 2354 | } |
2355 | else // fix sitting avatars. This is only needed bc of how we link avas to child parts, not root part | ||
2356 | { | ||
2357 | List<ScenePresence> sittingavas = part.ParentGroup.GetLinkedAvatars(); | ||
2358 | if (sittingavas.Count > 0) | ||
2359 | { | ||
2360 | foreach (ScenePresence av in sittingavas) | ||
2361 | { | ||
2362 | if (isroot || part.LocalId == av.ParentID) | ||
2363 | av.SendTerseUpdateToAllClients(); | ||
2364 | } | ||
2365 | } | ||
2366 | } | ||
2337 | } | 2367 | } |
2338 | 2368 | ||
2339 | /// <summary> | 2369 | /// <summary> |
@@ -2382,7 +2412,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2382 | public LSL_Rotation llGetLocalRot() | 2412 | public LSL_Rotation llGetLocalRot() |
2383 | { | 2413 | { |
2384 | m_host.AddScriptLPS(1); | 2414 | m_host.AddScriptLPS(1); |
2385 | return new LSL_Rotation(m_host.RotationOffset.X, m_host.RotationOffset.Y, m_host.RotationOffset.Z, m_host.RotationOffset.W); | 2415 | Quaternion rot = m_host.RotationOffset; |
2416 | return new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W); | ||
2386 | } | 2417 | } |
2387 | 2418 | ||
2388 | public void llSetForce(LSL_Vector force, int local) | 2419 | public void llSetForce(LSL_Vector force, int local) |
@@ -2466,6 +2497,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2466 | m_host.ApplyImpulse(v, local != 0); | 2497 | m_host.ApplyImpulse(v, local != 0); |
2467 | } | 2498 | } |
2468 | 2499 | ||
2500 | |||
2469 | public void llApplyRotationalImpulse(LSL_Vector force, int local) | 2501 | public void llApplyRotationalImpulse(LSL_Vector force, int local) |
2470 | { | 2502 | { |
2471 | m_host.AddScriptLPS(1); | 2503 | m_host.AddScriptLPS(1); |
@@ -2492,6 +2524,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2492 | llSetTorque(torque, local); | 2524 | llSetTorque(torque, local); |
2493 | } | 2525 | } |
2494 | 2526 | ||
2527 | public void llSetVelocity(LSL_Vector vel, int local) | ||
2528 | { | ||
2529 | m_host.AddScriptLPS(1); | ||
2530 | m_host.SetVelocity(new Vector3((float)vel.x, (float)vel.y, (float)vel.z), local != 0); | ||
2531 | } | ||
2532 | |||
2495 | public LSL_Vector llGetVel() | 2533 | public LSL_Vector llGetVel() |
2496 | { | 2534 | { |
2497 | m_host.AddScriptLPS(1); | 2535 | m_host.AddScriptLPS(1); |
@@ -2518,10 +2556,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2518 | return new LSL_Vector(m_host.Acceleration.X, m_host.Acceleration.Y, m_host.Acceleration.Z); | 2556 | return new LSL_Vector(m_host.Acceleration.X, m_host.Acceleration.Y, m_host.Acceleration.Z); |
2519 | } | 2557 | } |
2520 | 2558 | ||
2559 | |||
2560 | public void llSetAngularVelocity(LSL_Vector avel, int local) | ||
2561 | { | ||
2562 | m_host.AddScriptLPS(1); | ||
2563 | // Still not done !!!! | ||
2564 | // m_host.SetAngularVelocity(new Vector3((float)avel.x, (float)avel.y, (float)avel.z), local != 0); | ||
2565 | } | ||
2566 | |||
2521 | public LSL_Vector llGetOmega() | 2567 | public LSL_Vector llGetOmega() |
2522 | { | 2568 | { |
2523 | m_host.AddScriptLPS(1); | 2569 | m_host.AddScriptLPS(1); |
2524 | return new LSL_Vector(m_host.AngularVelocity.X, m_host.AngularVelocity.Y, m_host.AngularVelocity.Z); | 2570 | Vector3 avel = m_host.AngularVelocity; |
2571 | return new LSL_Vector(avel.X, avel.Y, avel.Z); | ||
2525 | } | 2572 | } |
2526 | 2573 | ||
2527 | public LSL_Float llGetTimeOfDay() | 2574 | public LSL_Float llGetTimeOfDay() |
@@ -7740,7 +7787,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7740 | Quaternion srot = sitpart.RotationOffset; | 7787 | Quaternion srot = sitpart.RotationOffset; |
7741 | rot = Quaternion.Conjugate(srot) * rot; // removed sit part offset rotation | 7788 | rot = Quaternion.Conjugate(srot) * rot; // removed sit part offset rotation |
7742 | av.Rotation = rot; | 7789 | av.Rotation = rot; |
7743 | av.SendAvatarDataToAllAgents(); | 7790 | // av.SendAvatarDataToAllAgents(); |
7791 | av.SendTerseUpdateToAllClients(); | ||
7744 | } | 7792 | } |
7745 | break; | 7793 | break; |
7746 | 7794 | ||
@@ -7760,7 +7808,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7760 | rot = Quaternion.Conjugate(srot) * rot; // remove sit part offset rotation | 7808 | rot = Quaternion.Conjugate(srot) * rot; // remove sit part offset rotation |
7761 | } | 7809 | } |
7762 | av.Rotation = rot; | 7810 | av.Rotation = rot; |
7763 | av.SendAvatarDataToAllAgents(); | 7811 | // av.SendAvatarDataToAllAgents(); |
7812 | av.SendTerseUpdateToAllClients(); | ||
7764 | } | 7813 | } |
7765 | break; | 7814 | break; |
7766 | 7815 | ||
@@ -7855,7 +7904,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7855 | { | 7904 | { |
7856 | positionChanged = false; | 7905 | positionChanged = false; |
7857 | av.OffsetPosition = finalPos; | 7906 | av.OffsetPosition = finalPos; |
7858 | av.SendAvatarDataToAllAgents(); | 7907 | // av.SendAvatarDataToAllAgents(); |
7908 | av.SendTerseUpdateToAllClients(); | ||
7859 | } | 7909 | } |
7860 | 7910 | ||
7861 | LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++); | 7911 | LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++); |
@@ -7871,7 +7921,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7871 | if (positionChanged) | 7921 | if (positionChanged) |
7872 | { | 7922 | { |
7873 | av.OffsetPosition = finalPos; | 7923 | av.OffsetPosition = finalPos; |
7874 | av.SendAvatarDataToAllAgents(); | 7924 | // av.SendAvatarDataToAllAgents(); |
7925 | av.SendTerseUpdateToAllClients(); | ||
7875 | positionChanged = false; | 7926 | positionChanged = false; |
7876 | } | 7927 | } |
7877 | } | 7928 | } |
@@ -8280,6 +8331,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8280 | case (int)ScriptBaseClass.PRIM_ROT_LOCAL: | 8331 | case (int)ScriptBaseClass.PRIM_ROT_LOCAL: |
8281 | if (remain < 1) | 8332 | if (remain < 1) |
8282 | return; | 8333 | return; |
8334 | |||
8283 | LSL_Rotation lr = rules.GetQuaternionItem(idx++); | 8335 | LSL_Rotation lr = rules.GetQuaternionItem(idx++); |
8284 | SetRot(part, Rot2Quaternion(lr)); | 8336 | SetRot(part, Rot2Quaternion(lr)); |
8285 | break; | 8337 | break; |
@@ -8379,10 +8431,91 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8379 | 8431 | ||
8380 | public LSL_String llXorBase64Strings(string str1, string str2) | 8432 | public LSL_String llXorBase64Strings(string str1, string str2) |
8381 | { | 8433 | { |
8382 | m_host.AddScriptLPS(1); | 8434 | string b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; |
8383 | Deprecated("llXorBase64Strings"); | 8435 | |
8384 | ScriptSleep(300); | 8436 | ScriptSleep(300); |
8385 | return String.Empty; | 8437 | m_host.AddScriptLPS(1); |
8438 | |||
8439 | if (str1 == String.Empty) | ||
8440 | return String.Empty; | ||
8441 | if (str2 == String.Empty) | ||
8442 | return str1; | ||
8443 | |||
8444 | int len = str2.Length; | ||
8445 | if ((len % 4) != 0) // LL is EVIL!!!! | ||
8446 | { | ||
8447 | while (str2.EndsWith("=")) | ||
8448 | str2 = str2.Substring(0, str2.Length - 1); | ||
8449 | |||
8450 | len = str2.Length; | ||
8451 | int mod = len % 4; | ||
8452 | |||
8453 | if (mod == 1) | ||
8454 | str2 = str2.Substring(0, str2.Length - 1); | ||
8455 | else if (mod == 2) | ||
8456 | str2 += "=="; | ||
8457 | else if (mod == 3) | ||
8458 | str2 += "="; | ||
8459 | } | ||
8460 | |||
8461 | byte[] data1; | ||
8462 | byte[] data2; | ||
8463 | try | ||
8464 | { | ||
8465 | data1 = Convert.FromBase64String(str1); | ||
8466 | data2 = Convert.FromBase64String(str2); | ||
8467 | } | ||
8468 | catch (Exception) | ||
8469 | { | ||
8470 | return new LSL_String(String.Empty); | ||
8471 | } | ||
8472 | |||
8473 | // For cases where the decoded length of s2 is greater | ||
8474 | // than the decoded length of s1, simply perform a normal | ||
8475 | // decode and XOR | ||
8476 | // | ||
8477 | if (data2.Length >= data1.Length) | ||
8478 | { | ||
8479 | for (int pos = 0 ; pos < data1.Length ; pos++ ) | ||
8480 | data1[pos] ^= data2[pos]; | ||
8481 | |||
8482 | return Convert.ToBase64String(data1); | ||
8483 | } | ||
8484 | |||
8485 | // Remove padding | ||
8486 | while (str1.EndsWith("=")) | ||
8487 | str1 = str1.Substring(0, str1.Length - 1); | ||
8488 | while (str2.EndsWith("=")) | ||
8489 | str2 = str2.Substring(0, str2.Length - 1); | ||
8490 | |||
8491 | byte[] d1 = new byte[str1.Length]; | ||
8492 | byte[] d2 = new byte[str2.Length]; | ||
8493 | |||
8494 | for (int i = 0 ; i < str1.Length ; i++) | ||
8495 | { | ||
8496 | int idx = b64.IndexOf(str1.Substring(i, 1)); | ||
8497 | if (idx == -1) | ||
8498 | idx = 0; | ||
8499 | d1[i] = (byte)idx; | ||
8500 | } | ||
8501 | |||
8502 | for (int i = 0 ; i < str2.Length ; i++) | ||
8503 | { | ||
8504 | int idx = b64.IndexOf(str2.Substring(i, 1)); | ||
8505 | if (idx == -1) | ||
8506 | idx = 0; | ||
8507 | d2[i] = (byte)idx; | ||
8508 | } | ||
8509 | |||
8510 | string output = String.Empty; | ||
8511 | |||
8512 | for (int pos = 0 ; pos < d1.Length ; pos++) | ||
8513 | output += b64[d1[pos] ^ d2[pos % d2.Length]]; | ||
8514 | |||
8515 | while (output.Length % 3 > 0) | ||
8516 | output += "="; | ||
8517 | |||
8518 | return output; | ||
8386 | } | 8519 | } |
8387 | 8520 | ||
8388 | public void llRemoteDataSetRegion() | 8521 | public void llRemoteDataSetRegion() |
@@ -12254,7 +12387,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12254 | bool checkPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_PHYSICAL) == ScriptBaseClass.RC_REJECT_PHYSICAL); | 12387 | bool checkPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_PHYSICAL) == ScriptBaseClass.RC_REJECT_PHYSICAL); |
12255 | 12388 | ||
12256 | 12389 | ||
12257 | if (false)// World.SuportsRayCastFiltered()) | 12390 | if (World.SuportsRayCastFiltered()) |
12258 | { | 12391 | { |
12259 | if (dist == 0) | 12392 | if (dist == 0) |
12260 | return list; | 12393 | return list; |