aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs105
1 files changed, 89 insertions, 16 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 8aeca31..b0a99f3 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2412,8 +2412,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2412 2412
2413 float groupmass = new_group.GetMass(); 2413 float groupmass = new_group.GetMass();
2414 2414
2415 //Recoil. 2415 if (new_group.RootPart.PhysActor != null && new_group.RootPart.PhysActor.IsPhysical && llvel != Vector3.Zero)
2416 llApplyImpulse(new LSL_Vector(llvel.X * groupmass, llvel.Y * groupmass, llvel.Z * groupmass), 0); 2416 {
2417 new_group.RootPart.ApplyImpulse(llvel, false);
2418 //Recoil.
2419 llApplyImpulse(new LSL_Vector(llvel.X * groupmass, llvel.Y * groupmass, llvel.Z * groupmass), 0);
2420 }
2417 // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay) 2421 // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay)
2418 ScriptSleep((int)((groupmass * velmag) / 10)); 2422 ScriptSleep((int)((groupmass * velmag) / 10));
2419 // ScriptSleep(100); 2423 // ScriptSleep(100);
@@ -4935,22 +4939,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4935 } 4939 }
4936 else 4940 else
4937 { 4941 {
4938 byte[] parms = avatar.Appearance.VisualParams; 4942 agentSize = new LSL_Vector(0.45, 0.6, calculateAgentHeight(avatar));
4939 // The values here were arrived at from experimentation with the sliders
4940 // in edit appearance in SL to find the ones that affected the height and how
4941 // much they affected it.
4942 float avatarHeight = 1.23077f // Shortest possible avatar height
4943 + 0.516945f * (float)parms[25] / 255.0f // Body height
4944 + 0.072514f * (float)parms[120] / 255.0f // Head size
4945 + 0.3836f * (float)parms[125] / 255.0f // Leg length
4946 + 0.08f * (float)parms[77] / 255.0f // Shoe heel height
4947 + 0.07f * (float)parms[78] / 255.0f // Shoe platform height
4948 + 0.076f * (float)parms[148] / 255.0f; // Neck length
4949 agentSize = new LSL_Vector(0.45, 0.6, avatarHeight);
4950 } 4943 }
4951 return agentSize; 4944 return agentSize;
4952 } 4945 }
4953 4946
4947 private float calculateAgentHeight(ScenePresence avatar)
4948 {
4949 byte[] parms = avatar.Appearance.VisualParams;
4950 // The values here were arrived at from experimentation with the sliders
4951 // in edit appearance in SL to find the ones that affected the height and how
4952 // much they affected it.
4953 float avatarHeight = 1.23077f // Shortest possible avatar height
4954 + 0.516945f * (float)parms[25] / 255.0f // Body height
4955 + 0.072514f * (float)parms[120] / 255.0f // Head size
4956 + 0.3836f * (float)parms[125] / 255.0f // Leg length
4957 + 0.08f * (float)parms[77] / 255.0f // Shoe heel height
4958 + 0.07f * (float)parms[78] / 255.0f // Shoe platform height
4959 + 0.076f * (float)parms[148] / 255.0f; // Neck length
4960 return avatarHeight;
4961 }
4962
4954 public LSL_Integer llSameGroup(string agent) 4963 public LSL_Integer llSameGroup(string agent)
4955 { 4964 {
4956 m_host.AddScriptLPS(1); 4965 m_host.AddScriptLPS(1);
@@ -6431,11 +6440,75 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6431 return m_host.ParentGroup.PrimCount; 6440 return m_host.ParentGroup.PrimCount;
6432 } 6441 }
6433 6442
6443 /// <summary>
6444 /// A partial implementation.
6445 /// http://lslwiki.net/lslwiki/wakka.php?wakka=llGetBoundingBox
6446 /// So far only valid for standing/flying/ground sitting avatars and single prim objects.
6447 /// If the object has multiple prims and/or a sitting avatar then the bounding
6448 /// box is for the root prim only.
6449 /// </summary>
6434 public LSL_List llGetBoundingBox(string obj) 6450 public LSL_List llGetBoundingBox(string obj)
6435 { 6451 {
6436 m_host.AddScriptLPS(1); 6452 m_host.AddScriptLPS(1);
6437 NotImplemented("llGetBoundingBox"); 6453 UUID objID = UUID.Zero;
6438 return new LSL_List(); 6454 LSL_List result = new LSL_List();
6455 if (!UUID.TryParse(obj, out objID))
6456 {
6457 result.Add(new LSL_Vector());
6458 result.Add(new LSL_Vector());
6459 return result;
6460 }
6461 ScenePresence presence = World.GetScenePresence(objID);
6462 if (presence != null)
6463 {
6464 if (presence.ParentID == 0) // not sat on an object
6465 {
6466 LSL_Vector lower;
6467 LSL_Vector upper;
6468 if (presence.Animations.DefaultAnimation.AnimID == AnimationSet.Animations.AnimsUUID["SIT_GROUND_CONSTRAINED"])
6469 {
6470 // This is for ground sitting avatars
6471 float height = calculateAgentHeight(presence) / 2.66666667f;
6472 lower = new LSL_Vector(-0.3375f, -0.45f, height * -1.0f);
6473 upper = new LSL_Vector(0.3375f, 0.45f, 0.0f);
6474 }
6475 else
6476 {
6477 // This is for standing/flying avatars
6478 float height = calculateAgentHeight(presence) / 2.0f;
6479 lower = new LSL_Vector(-0.225f, -0.3f, height * -1.0f);
6480 upper = new LSL_Vector(0.225f, 0.3f, height + 0.05f);
6481 }
6482 result.Add(lower);
6483 result.Add(upper);
6484 return result;
6485 }
6486 else
6487 {
6488 // sitting on an object so we need the bounding box of that
6489 // which should include the avatar so set the UUID to the
6490 // UUID of the object the avatar is sat on and allow it to fall through
6491 // to processing an object
6492 SceneObjectPart p = World.GetSceneObjectPart(presence.ParentID);
6493 objID = p.UUID;
6494 }
6495 }
6496 SceneObjectPart part = World.GetSceneObjectPart(objID);
6497 // Currently only works for single prims without a sitting avatar
6498 if (part != null)
6499 {
6500 Vector3 halfSize = part.Scale / 2.0f;
6501 LSL_Vector lower = new LSL_Vector(halfSize.X * -1.0f, halfSize.Y * -1.0f, halfSize.Z * -1.0f);
6502 LSL_Vector upper = new LSL_Vector(halfSize.X, halfSize.Y, halfSize.Z);
6503 result.Add(lower);
6504 result.Add(upper);
6505 return result;
6506 }
6507
6508 // Not found so return empty values
6509 result.Add(new LSL_Vector());
6510 result.Add(new LSL_Vector());
6511 return result;
6439 } 6512 }
6440 6513
6441 public LSL_Vector llGetGeometricCenter() 6514 public LSL_Vector llGetGeometricCenter()