aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
authorMelanie2012-06-28 22:06:02 +0200
committerMelanie2012-06-28 22:06:02 +0200
commit498820a74f6b288c26e2c33981297568c0c12d08 (patch)
treec87b1c20a3e3deeee56c33719ca8abed96499bdf /OpenSim/Region/ScriptEngine
parentFix llRegionSayTo the right way (diff)
parent reactivate physics raycasts on llCastRay() until it's clear what is its prob... (diff)
downloadopensim-SC-498820a74f6b288c26e2c33981297568c0c12d08.zip
opensim-SC-498820a74f6b288c26e2c33981297568c0c12d08.tar.gz
opensim-SC-498820a74f6b288c26e2c33981297568c0c12d08.tar.bz2
opensim-SC-498820a74f6b288c26e2c33981297568c0c12d08.tar.xz
Merge branch 'ubitwork' into avination
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs119
1 files changed, 78 insertions, 41 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index a0dc6cd..f475b99 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -660,18 +660,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
660 m_host.AddScriptLPS(1); 660 m_host.AddScriptLPS(1);
661 661
662 double x,y,z,s; 662 double x,y,z,s;
663 663 v.x *= 0.5;
664 double c1 = Math.Cos(v.x * 0.5); 664 v.y *= 0.5;
665 double c2 = Math.Cos(v.y * 0.5); 665 v.z *= 0.5;
666 double c3 = Math.Cos(v.z * 0.5); 666 double c1 = Math.Cos(v.x);
667 double s1 = Math.Sin(v.x * 0.5); 667 double c2 = Math.Cos(v.y);
668 double s2 = Math.Sin(v.y * 0.5); 668 double c1c2 = c1 * c2;
669 double s3 = Math.Sin(v.z * 0.5); 669 double s1 = Math.Sin(v.x);
670 670 double s2 = Math.Sin(v.y);
671 x = s1 * c2 * c3 + c1 * s2 * s3; 671 double s1s2 = s1 * s2;
672 y = c1 * s2 * c3 - s1 * c2 * s3; 672 double c1s2 = c1 * s2;
673 z = s1 * s2 * c3 + c1 * c2 * s3; 673 double s1c2 = s1 * c2;
674 s = c1 * c2 * c3 - s1 * s2 * s3; 674 double c3 = Math.Cos(v.z);
675 double s3 = Math.Sin(v.z);
676
677 x = s1c2 * c3 + c1s2 * s3;
678 y = c1s2 * c3 - s1c2 * s3;
679 z = s1s2 * c3 + c1c2 * s3;
680 s = c1c2 * c3 - s1s2 * s3;
675 681
676 return new LSL_Rotation(x, y, z, s); 682 return new LSL_Rotation(x, y, z, s);
677 } 683 }
@@ -1911,11 +1917,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1911 Primitive.TextureEntry tex = part.Shape.Textures; 1917 Primitive.TextureEntry tex = part.Shape.Textures;
1912 Color4 texcolor; 1918 Color4 texcolor;
1913 LSL_Vector rgb = new LSL_Vector(); 1919 LSL_Vector rgb = new LSL_Vector();
1920 int nsides = GetNumberOfSides(part);
1921
1914 if (face == ScriptBaseClass.ALL_SIDES) 1922 if (face == ScriptBaseClass.ALL_SIDES)
1915 { 1923 {
1916 int i; 1924 int i;
1917 1925 for (i = 0; i < nsides; i++)
1918 for (i = 0 ; i < GetNumberOfSides(part); i++)
1919 { 1926 {
1920 texcolor = tex.GetFace((uint)i).RGBA; 1927 texcolor = tex.GetFace((uint)i).RGBA;
1921 rgb.x += texcolor.R; 1928 rgb.x += texcolor.R;
@@ -1923,13 +1930,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1923 rgb.z += texcolor.B; 1930 rgb.z += texcolor.B;
1924 } 1931 }
1925 1932
1926 rgb.x /= (float)GetNumberOfSides(part); 1933 float invnsides = 1.0f / (float)nsides;
1927 rgb.y /= (float)GetNumberOfSides(part); 1934
1928 rgb.z /= (float)GetNumberOfSides(part); 1935 rgb.x *= invnsides;
1936 rgb.y *= invnsides;
1937 rgb.z *= invnsides;
1929 1938
1930 return rgb; 1939 return rgb;
1931 } 1940 }
1932 if (face >= 0 && face < GetNumberOfSides(part)) 1941 if (face >= 0 && face < nsides)
1933 { 1942 {
1934 texcolor = tex.GetFace((uint)face).RGBA; 1943 texcolor = tex.GetFace((uint)face).RGBA;
1935 rgb.x = texcolor.R; 1944 rgb.x = texcolor.R;
@@ -2328,15 +2337,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2328 // (root prim). ParentID may be nonzero in attachments and 2337 // (root prim). ParentID may be nonzero in attachments and
2329 // using it would cause attachments and HUDs to rotate 2338 // using it would cause attachments and HUDs to rotate
2330 // to the wrong positions. 2339 // to the wrong positions.
2340
2331 SetRot(m_host, Rot2Quaternion(rot)); 2341 SetRot(m_host, Rot2Quaternion(rot));
2332 } 2342 }
2333 else 2343 else
2334 { 2344 {
2335 // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. 2345 // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask.
2336 SceneObjectPart rootPart = m_host.ParentGroup.RootPart; 2346 SceneObjectPart rootPart;
2337 if (rootPart != null) // better safe than sorry 2347 if (m_host.ParentGroup != null) // better safe than sorry
2338 { 2348 {
2339 SetRot(m_host, rootPart.RotationOffset * Rot2Quaternion(rot)); 2349 rootPart = m_host.ParentGroup.RootPart;
2350 if (rootPart != null)
2351 SetRot(m_host, rootPart.RotationOffset * Rot2Quaternion(rot));
2340 } 2352 }
2341 } 2353 }
2342 2354
@@ -2346,6 +2358,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2346 public void llSetLocalRot(LSL_Rotation rot) 2358 public void llSetLocalRot(LSL_Rotation rot)
2347 { 2359 {
2348 m_host.AddScriptLPS(1); 2360 m_host.AddScriptLPS(1);
2361
2349 SetRot(m_host, Rot2Quaternion(rot)); 2362 SetRot(m_host, Rot2Quaternion(rot));
2350 ScriptSleep(200); 2363 ScriptSleep(200);
2351 } 2364 }
@@ -2355,25 +2368,43 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2355 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) 2368 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
2356 return; 2369 return;
2357 2370
2358 part.UpdateRotation(rot); 2371 bool isroot = (part == part.ParentGroup.RootPart);
2359 // Update rotation does not move the object in the physics scene if it's a linkset. 2372 bool isphys;
2360 2373
2361//KF: Do NOT use this next line if using ODE physics engine. This need a switch based on .ini Phys Engine type
2362// part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition;
2363
2364 // So, after thinking about this for a bit, the issue with the part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition line
2365 // is it isn't compatible with vehicles because it causes the vehicle body to have to be broken down and rebuilt
2366 // It's perfectly okay when the object is not an active physical body though.
2367 // So, part.ParentGroup.ResetChildPrimPhysicsPositions(); does the thing that Kitto is warning against
2368 // but only if the object is not physial and active. This is important for rotating doors.
2369 // without the absoluteposition = absoluteposition happening, the doors do not move in the physics
2370 // scene
2371 PhysicsActor pa = part.PhysActor; 2374 PhysicsActor pa = part.PhysActor;
2372 2375
2373 if (pa != null && !pa.IsPhysical && part == part.ParentGroup.RootPart) 2376 // keep using physactor ideia of isphysical
2377 // it should be SOP ideia of that
2378 // not much of a issue with ubitODE
2379 if (pa != null && pa.IsPhysical)
2380 isphys = true;
2381 else
2382 isphys = false;
2383
2384 // SL doesn't let scripts rotate root of physical linksets
2385 if (isroot && isphys)
2386 return;
2387
2388 part.UpdateRotation(rot);
2389
2390 // Update rotation does not move the object in the physics engine if it's a non physical linkset
2391 // so do a nasty update of parts positions if is a root part rotation
2392 if (isroot && pa != null) // with if above implies non physical root part
2374 { 2393 {
2375 part.ParentGroup.ResetChildPrimPhysicsPositions(); 2394 part.ParentGroup.ResetChildPrimPhysicsPositions();
2376 } 2395 }
2396 else // fix sitting avatars. This is only needed bc of how we link avas to child parts, not root part
2397 {
2398 List<ScenePresence> sittingavas = part.ParentGroup.GetLinkedAvatars();
2399 if (sittingavas.Count > 0)
2400 {
2401 foreach (ScenePresence av in sittingavas)
2402 {
2403 if (isroot || part.LocalId == av.ParentID)
2404 av.SendTerseUpdateToAllClients();
2405 }
2406 }
2407 }
2377 } 2408 }
2378 2409
2379 /// <summary> 2410 /// <summary>
@@ -2422,7 +2453,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2422 public LSL_Rotation llGetLocalRot() 2453 public LSL_Rotation llGetLocalRot()
2423 { 2454 {
2424 m_host.AddScriptLPS(1); 2455 m_host.AddScriptLPS(1);
2425 return new LSL_Rotation(m_host.RotationOffset.X, m_host.RotationOffset.Y, m_host.RotationOffset.Z, m_host.RotationOffset.W); 2456 Quaternion rot = m_host.RotationOffset;
2457 return new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W);
2426 } 2458 }
2427 2459
2428 public void llSetForce(LSL_Vector force, int local) 2460 public void llSetForce(LSL_Vector force, int local)
@@ -7994,7 +8026,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7994 Quaternion srot = sitpart.RotationOffset; 8026 Quaternion srot = sitpart.RotationOffset;
7995 rot = Quaternion.Conjugate(srot) * rot; // removed sit part offset rotation 8027 rot = Quaternion.Conjugate(srot) * rot; // removed sit part offset rotation
7996 av.Rotation = rot; 8028 av.Rotation = rot;
7997 av.SendAvatarDataToAllAgents(); 8029// av.SendAvatarDataToAllAgents();
8030 av.SendTerseUpdateToAllClients();
7998 } 8031 }
7999 break; 8032 break;
8000 8033
@@ -8014,7 +8047,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8014 rot = Quaternion.Conjugate(srot) * rot; // remove sit part offset rotation 8047 rot = Quaternion.Conjugate(srot) * rot; // remove sit part offset rotation
8015 } 8048 }
8016 av.Rotation = rot; 8049 av.Rotation = rot;
8017 av.SendAvatarDataToAllAgents(); 8050// av.SendAvatarDataToAllAgents();
8051 av.SendTerseUpdateToAllClients();
8018 } 8052 }
8019 break; 8053 break;
8020 8054
@@ -8109,7 +8143,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8109 { 8143 {
8110 positionChanged = false; 8144 positionChanged = false;
8111 av.OffsetPosition = finalPos; 8145 av.OffsetPosition = finalPos;
8112 av.SendAvatarDataToAllAgents(); 8146// av.SendAvatarDataToAllAgents();
8147 av.SendTerseUpdateToAllClients();
8113 } 8148 }
8114 8149
8115 LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++); 8150 LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++);
@@ -8125,7 +8160,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8125 if (positionChanged) 8160 if (positionChanged)
8126 { 8161 {
8127 av.OffsetPosition = finalPos; 8162 av.OffsetPosition = finalPos;
8128 av.SendAvatarDataToAllAgents(); 8163// av.SendAvatarDataToAllAgents();
8164 av.SendTerseUpdateToAllClients();
8129 positionChanged = false; 8165 positionChanged = false;
8130 } 8166 }
8131 } 8167 }
@@ -8534,6 +8570,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8534 case (int)ScriptBaseClass.PRIM_ROT_LOCAL: 8570 case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
8535 if (remain < 1) 8571 if (remain < 1)
8536 return; 8572 return;
8573
8537 LSL_Rotation lr = rules.GetQuaternionItem(idx++); 8574 LSL_Rotation lr = rules.GetQuaternionItem(idx++);
8538 SetRot(part, Rot2Quaternion(lr)); 8575 SetRot(part, Rot2Quaternion(lr));
8539 break; 8576 break;
@@ -12577,7 +12614,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12577 bool checkPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_PHYSICAL) == ScriptBaseClass.RC_REJECT_PHYSICAL); 12614 bool checkPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_PHYSICAL) == ScriptBaseClass.RC_REJECT_PHYSICAL);
12578 12615
12579 12616
12580 if (false)// World.SuportsRayCastFiltered()) 12617 if (World.SuportsRayCastFiltered())
12581 { 12618 {
12582 if (dist == 0) 12619 if (dist == 0)
12583 return list; 12620 return list;