diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
3 files changed, 46 insertions, 28 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 7e48659..fceae02 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -1343,31 +1343,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1343 | if (part == null || part.ParentGroup.IsDeleted) | 1343 | if (part == null || part.ParentGroup.IsDeleted) |
1344 | return; | 1344 | return; |
1345 | 1345 | ||
1346 | if (scale.x < 0.01) | 1346 | // First we need to check whether or not we need to clamp the size of a physics-enabled prim |
1347 | scale.x = 0.01; | ||
1348 | if (scale.y < 0.01) | ||
1349 | scale.y = 0.01; | ||
1350 | if (scale.z < 0.01) | ||
1351 | scale.z = 0.01; | ||
1352 | |||
1353 | PhysicsActor pa = part.ParentGroup.RootPart.PhysActor; | 1347 | PhysicsActor pa = part.ParentGroup.RootPart.PhysActor; |
1354 | |||
1355 | if (pa != null && pa.IsPhysical) | 1348 | if (pa != null && pa.IsPhysical) |
1356 | { | 1349 | { |
1357 | if (scale.x > World.m_maxPhys) | 1350 | scale.x = Math.Max(World.m_minPhys, Math.Min(World.m_maxPhys, scale.x)); |
1358 | scale.x = World.m_maxPhys; | 1351 | scale.y = Math.Max(World.m_minPhys, Math.Min(World.m_maxPhys, scale.y)); |
1359 | if (scale.y > World.m_maxPhys) | 1352 | scale.z = Math.Max(World.m_minPhys, Math.Min(World.m_maxPhys, scale.z)); |
1360 | scale.y = World.m_maxPhys; | ||
1361 | if (scale.z > World.m_maxPhys) | ||
1362 | scale.z = World.m_maxPhys; | ||
1363 | } | 1353 | } |
1364 | 1354 | ||
1365 | if (scale.x > World.m_maxNonphys) | 1355 | // Next we clamp the scale to the non-physical min/max |
1366 | scale.x = World.m_maxNonphys; | 1356 | scale.x = Math.Max(World.m_minNonphys, Math.Min(World.m_maxNonphys, scale.x)); |
1367 | if (scale.y > World.m_maxNonphys) | 1357 | scale.y = Math.Max(World.m_minNonphys, Math.Min(World.m_maxNonphys, scale.y)); |
1368 | scale.y = World.m_maxNonphys; | 1358 | scale.z = Math.Max(World.m_minNonphys, Math.Min(World.m_maxNonphys, scale.z)); |
1369 | if (scale.z > World.m_maxNonphys) | ||
1370 | scale.z = World.m_maxNonphys; | ||
1371 | 1359 | ||
1372 | Vector3 tmp = part.Scale; | 1360 | Vector3 tmp = part.Scale; |
1373 | tmp.X = (float)scale.x; | 1361 | tmp.X = (float)scale.x; |
@@ -4031,9 +4019,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4031 | public void llSetText(string text, LSL_Vector color, double alpha) | 4019 | public void llSetText(string text, LSL_Vector color, double alpha) |
4032 | { | 4020 | { |
4033 | m_host.AddScriptLPS(1); | 4021 | m_host.AddScriptLPS(1); |
4034 | Vector3 av3 = new Vector3(Util.Clip((float)color.x, 0.0f, 1.0f), | 4022 | Vector3 av3 = Util.Clip(new Vector3((float)color.x, (float)color.y, |
4035 | Util.Clip((float)color.y, 0.0f, 1.0f), | 4023 | (float)color.z), 0.0f, 1.0f); |
4036 | Util.Clip((float)color.z, 0.0f, 1.0f)); | ||
4037 | m_host.SetText(text.Length > 254 ? text.Remove(254) : text, av3, Util.Clip((float)alpha, 0.0f, 1.0f)); | 4024 | m_host.SetText(text.Length > 254 ? text.Remove(254) : text, av3, Util.Clip((float)alpha, 0.0f, 1.0f)); |
4038 | //m_host.ParentGroup.HasGroupChanged = true; | 4025 | //m_host.ParentGroup.HasGroupChanged = true; |
4039 | //m_host.ParentGroup.ScheduleGroupForFullUpdate(); | 4026 | //m_host.ParentGroup.ScheduleGroupForFullUpdate(); |
@@ -7647,9 +7634,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7647 | string primText = rules.GetLSLStringItem(idx++); | 7634 | string primText = rules.GetLSLStringItem(idx++); |
7648 | LSL_Vector primTextColor = rules.GetVector3Item(idx++); | 7635 | LSL_Vector primTextColor = rules.GetVector3Item(idx++); |
7649 | LSL_Float primTextAlpha = rules.GetLSLFloatItem(idx++); | 7636 | LSL_Float primTextAlpha = rules.GetLSLFloatItem(idx++); |
7650 | Vector3 av3 = new Vector3(Util.Clip((float)primTextColor.x, 0.0f, 1.0f), | 7637 | Vector3 av3 = Util.Clip(new Vector3((float)primTextColor.x, |
7651 | Util.Clip((float)primTextColor.y, 0.0f, 1.0f), | 7638 | (float)primTextColor.y, |
7652 | Util.Clip((float)primTextColor.z, 0.0f, 1.0f)); | 7639 | (float)primTextColor.z), 0.0f, 1.0f); |
7653 | part.SetText(primText, av3, Util.Clip((float)primTextAlpha, 0.0f, 1.0f)); | 7640 | part.SetText(primText, av3, Util.Clip((float)primTextAlpha, 0.0f, 1.0f)); |
7654 | 7641 | ||
7655 | break; | 7642 | break; |
@@ -7679,6 +7666,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7679 | LSL_Float gain = rules.GetLSLFloatItem(idx++); | 7666 | LSL_Float gain = rules.GetLSLFloatItem(idx++); |
7680 | TargetOmega(part, axis, (double)spinrate, (double)gain); | 7667 | TargetOmega(part, axis, (double)spinrate, (double)gain); |
7681 | break; | 7668 | break; |
7669 | case (int)ScriptBaseClass.PRIM_SLICE: | ||
7670 | if (remain < 1) | ||
7671 | return null; | ||
7672 | LSL_Vector slice = rules.GetVector3Item(idx++); | ||
7673 | part.UpdateSlice((float)slice.x, (float)slice.y); | ||
7674 | break; | ||
7682 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: | 7675 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: |
7683 | if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. | 7676 | if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. |
7684 | return null; | 7677 | return null; |
@@ -7687,6 +7680,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7687 | } | 7680 | } |
7688 | } | 7681 | } |
7689 | } | 7682 | } |
7683 | catch (InvalidCastException e) | ||
7684 | { | ||
7685 | ShoutError(e.Message); | ||
7686 | } | ||
7690 | finally | 7687 | finally |
7691 | { | 7688 | { |
7692 | if (positionChanged) | 7689 | if (positionChanged) |
@@ -8349,6 +8346,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8349 | case (int)ScriptBaseClass.PRIM_POS_LOCAL: | 8346 | case (int)ScriptBaseClass.PRIM_POS_LOCAL: |
8350 | res.Add(new LSL_Vector(GetPartLocalPos(part))); | 8347 | res.Add(new LSL_Vector(GetPartLocalPos(part))); |
8351 | break; | 8348 | break; |
8349 | case (int)ScriptBaseClass.PRIM_SLICE: | ||
8350 | PrimType prim_type = part.GetPrimType(); | ||
8351 | bool useProfileBeginEnd = (prim_type == PrimType.SPHERE || prim_type == PrimType.TORUS || prim_type == PrimType.TUBE || prim_type == PrimType.RING); | ||
8352 | res.Add(new LSL_Vector( | ||
8353 | (useProfileBeginEnd ? part.Shape.ProfileBegin : part.Shape.PathBegin) / 50000.0, | ||
8354 | 1 - (useProfileBeginEnd ? part.Shape.ProfileEnd : part.Shape.PathEnd) / 50000.0, | ||
8355 | 0 | ||
8356 | )); | ||
8357 | break; | ||
8352 | } | 8358 | } |
8353 | } | 8359 | } |
8354 | return res; | 8360 | return res; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index e1c054d..cad8518 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | |||
@@ -328,6 +328,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
328 | public const int PRIM_OMEGA = 32; | 328 | public const int PRIM_OMEGA = 32; |
329 | public const int PRIM_POS_LOCAL = 33; | 329 | public const int PRIM_POS_LOCAL = 33; |
330 | public const int PRIM_LINK_TARGET = 34; | 330 | public const int PRIM_LINK_TARGET = 34; |
331 | public const int PRIM_SLICE = 35; | ||
331 | public const int PRIM_TEXGEN_DEFAULT = 0; | 332 | public const int PRIM_TEXGEN_DEFAULT = 0; |
332 | public const int PRIM_TEXGEN_PLANAR = 1; | 333 | public const int PRIM_TEXGEN_PLANAR = 1; |
333 | 334 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index d848b2a..562433d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | |||
@@ -560,12 +560,23 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
560 | else if (m_data[itemIndex] is LSL_Types.LSLString) | 560 | else if (m_data[itemIndex] is LSL_Types.LSLString) |
561 | return new LSLInteger(m_data[itemIndex].ToString()); | 561 | return new LSLInteger(m_data[itemIndex].ToString()); |
562 | else | 562 | else |
563 | throw new InvalidCastException(); | 563 | throw new InvalidCastException(string.Format( |
564 | "{0} expected but {1} given", | ||
565 | typeof(LSL_Types.LSLInteger).Name, | ||
566 | m_data[itemIndex] != null ? | ||
567 | m_data[itemIndex].GetType().Name : "null")); | ||
564 | } | 568 | } |
565 | 569 | ||
566 | public LSL_Types.Vector3 GetVector3Item(int itemIndex) | 570 | public LSL_Types.Vector3 GetVector3Item(int itemIndex) |
567 | { | 571 | { |
568 | return (LSL_Types.Vector3)m_data[itemIndex]; | 572 | if(m_data[itemIndex] is LSL_Types.Vector3) |
573 | return (LSL_Types.Vector3)m_data[itemIndex]; | ||
574 | else | ||
575 | throw new InvalidCastException(string.Format( | ||
576 | "{0} expected but {1} given", | ||
577 | typeof(LSL_Types.Vector3).Name, | ||
578 | m_data[itemIndex] != null ? | ||
579 | m_data[itemIndex].GetType().Name : "null")); | ||
569 | } | 580 | } |
570 | 581 | ||
571 | public LSL_Types.Quaternion GetQuaternionItem(int itemIndex) | 582 | public LSL_Types.Quaternion GetQuaternionItem(int itemIndex) |