aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs24
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs89
2 files changed, 37 insertions, 76 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index b51ce38..8e74dc8 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -611,10 +611,7 @@ namespace OpenSim.Region.Framework.Scenes
611 611
612 public bool IsSelected 612 public bool IsSelected
613 { 613 {
614 get 614 get { return m_isSelected; }
615 {
616 return m_isSelected;
617 }
618 set 615 set
619 { 616 {
620 m_isSelected = value; 617 m_isSelected = value;
@@ -622,23 +619,8 @@ namespace OpenSim.Region.Framework.Scenes
622 ParentGroup.PartSelectChanged(value); 619 ParentGroup.PartSelectChanged(value);
623 } 620 }
624 } 621 }
625 622
626 public bool IsPhysical 623
627 {
628 get
629 {
630 return ((Flags & PrimFlags.Physics) != 0);
631 }
632 }
633
634 public bool IsPhantom
635 {
636 get
637 {
638 return ((Flags & PrimFlags.Phantom) != 0);
639 }
640 }
641
642 public Dictionary<int, string> CollisionFilter 624 public Dictionary<int, string> CollisionFilter
643 { 625 {
644 get { return m_CollisionFilter; } 626 get { return m_CollisionFilter; }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index b507937..959d928 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -660,24 +660,18 @@ 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 v.x *= 0.5; 663
664 v.y *= 0.5; 664 double c1 = Math.Cos(v.x * 0.5);
665 v.z *= 0.5; 665 double c2 = Math.Cos(v.y * 0.5);
666 double c1 = Math.Cos(v.x); 666 double c3 = Math.Cos(v.z * 0.5);
667 double c2 = Math.Cos(v.y); 667 double s1 = Math.Sin(v.x * 0.5);
668 double c1c2 = c1 * c2; 668 double s2 = Math.Sin(v.y * 0.5);
669 double s1 = Math.Sin(v.x); 669 double s3 = Math.Sin(v.z * 0.5);
670 double s2 = Math.Sin(v.y); 670
671 double s1s2 = s1 * s2; 671 x = s1 * c2 * c3 + c1 * s2 * s3;
672 double c1s2 = c1 * s2; 672 y = c1 * s2 * c3 - s1 * c2 * s3;
673 double s1c2 = s1 * c2; 673 z = s1 * s2 * c3 + c1 * c2 * s3;
674 double c3 = Math.Cos(v.z); 674 s = c1 * c2 * c3 - s1 * s2 * s3;
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;
681 675
682 return new LSL_Rotation(x, y, z, s); 676 return new LSL_Rotation(x, y, z, s);
683 } 677 }
@@ -1917,12 +1911,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1917 Primitive.TextureEntry tex = part.Shape.Textures; 1911 Primitive.TextureEntry tex = part.Shape.Textures;
1918 Color4 texcolor; 1912 Color4 texcolor;
1919 LSL_Vector rgb = new LSL_Vector(); 1913 LSL_Vector rgb = new LSL_Vector();
1920 int nsides = GetNumberOfSides(part);
1921
1922 if (face == ScriptBaseClass.ALL_SIDES) 1914 if (face == ScriptBaseClass.ALL_SIDES)
1923 { 1915 {
1924 int i; 1916 int i;
1925 for (i = 0; i < nsides; i++) 1917
1918 for (i = 0 ; i < GetNumberOfSides(part); i++)
1926 { 1919 {
1927 texcolor = tex.GetFace((uint)i).RGBA; 1920 texcolor = tex.GetFace((uint)i).RGBA;
1928 rgb.x += texcolor.R; 1921 rgb.x += texcolor.R;
@@ -1930,15 +1923,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1930 rgb.z += texcolor.B; 1923 rgb.z += texcolor.B;
1931 } 1924 }
1932 1925
1933 float invnsides = 1.0f / (float)nsides; 1926 rgb.x /= (float)GetNumberOfSides(part);
1934 1927 rgb.y /= (float)GetNumberOfSides(part);
1935 rgb.x *= invnsides; 1928 rgb.z /= (float)GetNumberOfSides(part);
1936 rgb.y *= invnsides;
1937 rgb.z *= invnsides;
1938 1929
1939 return rgb; 1930 return rgb;
1940 } 1931 }
1941 if (face >= 0 && face < nsides) 1932 if (face >= 0 && face < GetNumberOfSides(part))
1942 { 1933 {
1943 texcolor = tex.GetFace((uint)face).RGBA; 1934 texcolor = tex.GetFace((uint)face).RGBA;
1944 rgb.x = texcolor.R; 1935 rgb.x = texcolor.R;
@@ -2337,14 +2328,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2337 // (root prim). ParentID may be nonzero in attachments and 2328 // (root prim). ParentID may be nonzero in attachments and
2338 // using it would cause attachments and HUDs to rotate 2329 // using it would cause attachments and HUDs to rotate
2339 // to the wrong positions. 2330 // to the wrong positions.
2340
2341 SetRot(m_host, Rot2Quaternion(rot)); 2331 SetRot(m_host, Rot2Quaternion(rot));
2342 } 2332 }
2343 else 2333 else
2344 { 2334 {
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. 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.
2346 SceneObjectPart rootPart;// = m_host.ParentGroup.RootPart; 2336 SceneObjectPart rootPart = m_host.ParentGroup.RootPart;
2347 if (m_host.ParentGroup != null && ((rootPart = m_host.ParentGroup.RootPart) != null)) // better safe than sorry 2337 if (rootPart != null) // better safe than sorry
2348 { 2338 {
2349 SetRot(m_host, rootPart.RotationOffset * Rot2Quaternion(rot)); 2339 SetRot(m_host, rootPart.RotationOffset * Rot2Quaternion(rot));
2350 } 2340 }
@@ -2356,7 +2346,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2356 public void llSetLocalRot(LSL_Rotation rot) 2346 public void llSetLocalRot(LSL_Rotation rot)
2357 { 2347 {
2358 m_host.AddScriptLPS(1); 2348 m_host.AddScriptLPS(1);
2359
2360 SetRot(m_host, Rot2Quaternion(rot)); 2349 SetRot(m_host, Rot2Quaternion(rot));
2361 ScriptSleep(200); 2350 ScriptSleep(200);
2362 } 2351 }
@@ -2366,33 +2355,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2366 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) 2355 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
2367 return; 2356 return;
2368 2357
2369 bool isroot = (part == part.ParentGroup.RootPart); 2358 part.UpdateRotation(rot);
2359 // Update rotation does not move the object in the physics scene if it's a linkset.
2370 2360
2371 // SL doesn't let scripts rotate root of physical linksets 2361//KF: Do NOT use this next line if using ODE physics engine. This need a switch based on .ini Phys Engine type
2372 if (isroot && part.IsPhysical) 2362// part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition;
2373 return;
2374 2363
2375 part.UpdateRotation(rot); 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;
2376 2372
2377 // Update rotation does not move the object in the physics scene if it's a linkset. 2373 if (pa != null && !pa.IsPhysical)
2378 // so do a nasty update
2379 // but only root part rotation changes positions and only needed if we have physics actor
2380 if (isroot && part.PhysActor != null)
2381 { 2374 {
2382 part.ParentGroup.ResetChildPrimPhysicsPositions(); 2375 part.ParentGroup.ResetChildPrimPhysicsPositions();
2383 } 2376 }
2384 else // fix sitting avatars
2385 {
2386 List<ScenePresence> sittingavas = part.ParentGroup.GetLinkedAvatars();
2387 if (sittingavas.Count > 0)
2388 {
2389 foreach (ScenePresence av in sittingavas)
2390 {
2391 if (isroot || part.LocalId == av.ParentID)
2392 av.SendAvatarDataToAllAgents();
2393 }
2394 }
2395 }
2396 } 2377 }
2397 2378
2398 /// <summary> 2379 /// <summary>
@@ -2441,8 +2422,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2441 public LSL_Rotation llGetLocalRot() 2422 public LSL_Rotation llGetLocalRot()
2442 { 2423 {
2443 m_host.AddScriptLPS(1); 2424 m_host.AddScriptLPS(1);
2444 Quaternion rot = m_host.RotationOffset; 2425 return new LSL_Rotation(m_host.RotationOffset.X, m_host.RotationOffset.Y, m_host.RotationOffset.Z, m_host.RotationOffset.W);
2445 return new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W);
2446 } 2426 }
2447 2427
2448 public void llSetForce(LSL_Vector force, int local) 2428 public void llSetForce(LSL_Vector force, int local)
@@ -8554,7 +8534,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8554 case (int)ScriptBaseClass.PRIM_ROT_LOCAL: 8534 case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
8555 if (remain < 1) 8535 if (remain < 1)
8556 return; 8536 return;
8557
8558 LSL_Rotation lr = rules.GetQuaternionItem(idx++); 8537 LSL_Rotation lr = rules.GetQuaternionItem(idx++);
8559 SetRot(part, Rot2Quaternion(lr)); 8538 SetRot(part, Rot2Quaternion(lr));
8560 break; 8539 break;