diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
11 files changed, 247 insertions, 198 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 3e1b43e..0c7f49b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -426,14 +426,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
426 | return key; | 426 | return key; |
427 | } | 427 | } |
428 | 428 | ||
429 | // convert a LSL_Rotation to a Quaternion | ||
430 | public static Quaternion Rot2Quaternion(LSL_Rotation r) | ||
431 | { | ||
432 | Quaternion q = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); | ||
433 | q.Normalize(); | ||
434 | return q; | ||
435 | } | ||
436 | |||
437 | //These are the implementations of the various ll-functions used by the LSL scripts. | 429 | //These are the implementations of the various ll-functions used by the LSL scripts. |
438 | public LSL_Float llSin(double f) | 430 | public LSL_Float llSin(double f) |
439 | { | 431 | { |
@@ -1240,9 +1232,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1240 | public LSL_Float llGround(LSL_Vector offset) | 1232 | public LSL_Float llGround(LSL_Vector offset) |
1241 | { | 1233 | { |
1242 | m_host.AddScriptLPS(1); | 1234 | m_host.AddScriptLPS(1); |
1243 | Vector3 pos = m_host.GetWorldPosition() + new Vector3((float)offset.x, | 1235 | Vector3 pos = m_host.GetWorldPosition() + (Vector3)offset; |
1244 | (float)offset.y, | ||
1245 | (float)offset.z); | ||
1246 | 1236 | ||
1247 | //Get the slope normal. This gives us the equation of the plane tangent to the slope. | 1237 | //Get the slope normal. This gives us the equation of the plane tangent to the slope. |
1248 | LSL_Vector vsn = llGroundNormal(offset); | 1238 | LSL_Vector vsn = llGroundNormal(offset); |
@@ -1492,31 +1482,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1492 | if (part == null || part.ParentGroup.IsDeleted) | 1482 | if (part == null || part.ParentGroup.IsDeleted) |
1493 | return; | 1483 | return; |
1494 | 1484 | ||
1495 | if (scale.x < 0.01) | 1485 | // First we need to check whether or not we need to clamp the size of a physics-enabled prim |
1496 | scale.x = 0.01; | ||
1497 | if (scale.y < 0.01) | ||
1498 | scale.y = 0.01; | ||
1499 | if (scale.z < 0.01) | ||
1500 | scale.z = 0.01; | ||
1501 | |||
1502 | PhysicsActor pa = part.ParentGroup.RootPart.PhysActor; | 1486 | PhysicsActor pa = part.ParentGroup.RootPart.PhysActor; |
1503 | |||
1504 | if (pa != null && pa.IsPhysical) | 1487 | if (pa != null && pa.IsPhysical) |
1505 | { | 1488 | { |
1506 | if (scale.x > World.m_maxPhys) | 1489 | scale.x = Math.Max(World.m_minPhys, Math.Min(World.m_maxPhys, scale.x)); |
1507 | scale.x = World.m_maxPhys; | 1490 | scale.y = Math.Max(World.m_minPhys, Math.Min(World.m_maxPhys, scale.y)); |
1508 | if (scale.y > World.m_maxPhys) | 1491 | scale.z = Math.Max(World.m_minPhys, Math.Min(World.m_maxPhys, scale.z)); |
1509 | scale.y = World.m_maxPhys; | 1492 | } |
1510 | if (scale.z > World.m_maxPhys) | 1493 | else |
1511 | scale.z = World.m_maxPhys; | 1494 | { |
1495 | // If not physical, then we clamp the scale to the non-physical min/max | ||
1496 | scale.x = Math.Max(World.m_minNonphys, Math.Min(World.m_maxNonphys, scale.x)); | ||
1497 | scale.y = Math.Max(World.m_minNonphys, Math.Min(World.m_maxNonphys, scale.y)); | ||
1498 | scale.z = Math.Max(World.m_minNonphys, Math.Min(World.m_maxNonphys, scale.z)); | ||
1512 | } | 1499 | } |
1513 | |||
1514 | if (scale.x > World.m_maxNonphys) | ||
1515 | scale.x = World.m_maxNonphys; | ||
1516 | if (scale.y > World.m_maxNonphys) | ||
1517 | scale.y = World.m_maxNonphys; | ||
1518 | if (scale.z > World.m_maxNonphys) | ||
1519 | scale.z = World.m_maxNonphys; | ||
1520 | 1500 | ||
1521 | Vector3 tmp = part.Scale; | 1501 | Vector3 tmp = part.Scale; |
1522 | tmp.X = (float)scale.x; | 1502 | tmp.X = (float)scale.x; |
@@ -1590,7 +1570,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1590 | if (face == ScriptBaseClass.ALL_SIDES) | 1570 | if (face == ScriptBaseClass.ALL_SIDES) |
1591 | face = SceneObjectPart.ALL_SIDES; | 1571 | face = SceneObjectPart.ALL_SIDES; |
1592 | 1572 | ||
1593 | m_host.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); | 1573 | m_host.SetFaceColorAlpha(face, color, null); |
1594 | } | 1574 | } |
1595 | 1575 | ||
1596 | public void SetTexGen(SceneObjectPart part, int face,int style) | 1576 | public void SetTexGen(SceneObjectPart part, int face,int style) |
@@ -2220,7 +2200,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2220 | 2200 | ||
2221 | bool sameParcel = here.GlobalID == there.GlobalID; | 2201 | bool sameParcel = here.GlobalID == there.GlobalID; |
2222 | 2202 | ||
2223 | if (!sameParcel && !World.Permissions.CanObjectEntry(m_host.UUID, false, new Vector3((float)pos.x, (float)pos.y, (float)pos.z))) | 2203 | if (!sameParcel && !World.Permissions.CanRezObject( |
2204 | m_host.ParentGroup.PrimCount, m_host.ParentGroup.OwnerID, pos)) | ||
2224 | { | 2205 | { |
2225 | return 0; | 2206 | return 0; |
2226 | } | 2207 | } |
@@ -2279,16 +2260,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2279 | if (part.ParentGroup.RootPart == part) | 2260 | if (part.ParentGroup.RootPart == part) |
2280 | { | 2261 | { |
2281 | SceneObjectGroup parent = part.ParentGroup; | 2262 | SceneObjectGroup parent = part.ParentGroup; |
2282 | Vector3 dest = new Vector3((float)toPos.x, (float)toPos.y, (float)toPos.z); | 2263 | if (!World.Permissions.CanObjectEntry(parent.UUID, false, (Vector3)toPos)) |
2283 | if (!World.Permissions.CanObjectEntry(parent.UUID, false, dest)) | ||
2284 | return; | 2264 | return; |
2285 | Util.FireAndForget(delegate(object x) { | 2265 | Util.FireAndForget(delegate(object x) { |
2286 | parent.UpdateGroupPosition(dest); | 2266 | parent.UpdateGroupPosition((Vector3)toPos); |
2287 | }); | 2267 | }); |
2288 | } | 2268 | } |
2289 | else | 2269 | else |
2290 | { | 2270 | { |
2291 | part.OffsetPosition = new Vector3((float)toPos.x, (float)toPos.y, (float)toPos.z); | 2271 | part.OffsetPosition = (Vector3)toPos; |
2292 | SceneObjectGroup parent = part.ParentGroup; | 2272 | SceneObjectGroup parent = part.ParentGroup; |
2293 | parent.HasGroupChanged = true; | 2273 | parent.HasGroupChanged = true; |
2294 | parent.ScheduleGroupForTerseUpdate(); | 2274 | parent.ScheduleGroupForTerseUpdate(); |
@@ -2326,7 +2306,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2326 | pos = part.AbsolutePosition; | 2306 | pos = part.AbsolutePosition; |
2327 | } | 2307 | } |
2328 | 2308 | ||
2329 | return new LSL_Vector(pos.X, pos.Y, pos.Z); | 2309 | // m_log.DebugFormat("[LSL API]: Returning {0} in GetPartLocalPos()", pos); |
2310 | |||
2311 | return new LSL_Vector(pos); | ||
2330 | } | 2312 | } |
2331 | 2313 | ||
2332 | public void llSetRot(LSL_Rotation rot) | 2314 | public void llSetRot(LSL_Rotation rot) |
@@ -2343,7 +2325,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2343 | // using it would cause attachments and HUDs to rotate | 2325 | // using it would cause attachments and HUDs to rotate |
2344 | // to the wrong positions. | 2326 | // to the wrong positions. |
2345 | 2327 | ||
2346 | SetRot(m_host, Rot2Quaternion(rot)); | 2328 | SetRot(m_host, rot); |
2347 | } | 2329 | } |
2348 | else | 2330 | else |
2349 | { | 2331 | { |
@@ -2353,7 +2335,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2353 | { | 2335 | { |
2354 | rootPart = m_host.ParentGroup.RootPart; | 2336 | rootPart = m_host.ParentGroup.RootPart; |
2355 | if (rootPart != null) | 2337 | if (rootPart != null) |
2356 | SetRot(m_host, rootPart.RotationOffset * Rot2Quaternion(rot)); | 2338 | SetRot(m_host, rootPart.RotationOffset * (Quaternion)rot); |
2357 | } | 2339 | } |
2358 | } | 2340 | } |
2359 | 2341 | ||
@@ -2363,8 +2345,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2363 | public void llSetLocalRot(LSL_Rotation rot) | 2345 | public void llSetLocalRot(LSL_Rotation rot) |
2364 | { | 2346 | { |
2365 | m_host.AddScriptLPS(1); | 2347 | m_host.AddScriptLPS(1); |
2366 | 2348 | SetRot(m_host, rot); | |
2367 | SetRot(m_host, Rot2Quaternion(rot)); | ||
2368 | ScriptSleep(200); | 2349 | ScriptSleep(200); |
2369 | } | 2350 | } |
2370 | 2351 | ||
@@ -2476,7 +2457,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2476 | if (local != 0) | 2457 | if (local != 0) |
2477 | force *= llGetRot(); | 2458 | force *= llGetRot(); |
2478 | 2459 | ||
2479 | m_host.ParentGroup.RootPart.SetForce(new Vector3((float)force.x, (float)force.y, (float)force.z)); | 2460 | m_host.ParentGroup.RootPart.SetForce(force); |
2480 | } | 2461 | } |
2481 | } | 2462 | } |
2482 | 2463 | ||
@@ -2488,10 +2469,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2488 | 2469 | ||
2489 | if (!m_host.ParentGroup.IsDeleted) | 2470 | if (!m_host.ParentGroup.IsDeleted) |
2490 | { | 2471 | { |
2491 | Vector3 tmpForce = m_host.ParentGroup.RootPart.GetForce(); | 2472 | force = m_host.ParentGroup.RootPart.GetForce(); |
2492 | force.x = tmpForce.X; | ||
2493 | force.y = tmpForce.Y; | ||
2494 | force.z = tmpForce.Z; | ||
2495 | } | 2473 | } |
2496 | 2474 | ||
2497 | return force; | 2475 | return force; |
@@ -2500,8 +2478,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2500 | public LSL_Integer llTarget(LSL_Vector position, double range) | 2478 | public LSL_Integer llTarget(LSL_Vector position, double range) |
2501 | { | 2479 | { |
2502 | m_host.AddScriptLPS(1); | 2480 | m_host.AddScriptLPS(1); |
2503 | return m_host.ParentGroup.registerTargetWaypoint( | 2481 | return m_host.ParentGroup.registerTargetWaypoint(position, |
2504 | new Vector3((float)position.x, (float)position.y, (float)position.z), (float)range); | 2482 | (float)range); |
2505 | } | 2483 | } |
2506 | 2484 | ||
2507 | public void llTargetRemove(int number) | 2485 | public void llTargetRemove(int number) |
@@ -2513,8 +2491,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2513 | public LSL_Integer llRotTarget(LSL_Rotation rot, double error) | 2491 | public LSL_Integer llRotTarget(LSL_Rotation rot, double error) |
2514 | { | 2492 | { |
2515 | m_host.AddScriptLPS(1); | 2493 | m_host.AddScriptLPS(1); |
2516 | return m_host.ParentGroup.registerRotTargetWaypoint( | 2494 | return m_host.ParentGroup.registerRotTargetWaypoint(rot, (float)error); |
2517 | new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s), (float)error); | ||
2518 | } | 2495 | } |
2519 | 2496 | ||
2520 | public void llRotTargetRemove(int number) | 2497 | public void llRotTargetRemove(int number) |
@@ -2526,7 +2503,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2526 | public void llMoveToTarget(LSL_Vector target, double tau) | 2503 | public void llMoveToTarget(LSL_Vector target, double tau) |
2527 | { | 2504 | { |
2528 | m_host.AddScriptLPS(1); | 2505 | m_host.AddScriptLPS(1); |
2529 | m_host.MoveToTarget(new Vector3((float)target.x, (float)target.y, (float)target.z), (float)tau); | 2506 | m_host.MoveToTarget(target, (float)tau); |
2530 | } | 2507 | } |
2531 | 2508 | ||
2532 | public void llStopMoveToTarget() | 2509 | public void llStopMoveToTarget() |
@@ -2539,7 +2516,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2539 | { | 2516 | { |
2540 | m_host.AddScriptLPS(1); | 2517 | m_host.AddScriptLPS(1); |
2541 | //No energy force yet | 2518 | //No energy force yet |
2542 | Vector3 v = new Vector3((float)force.x, (float)force.y, (float)force.z); | 2519 | Vector3 v = force; |
2543 | if (v.Length() > 20000.0f) | 2520 | if (v.Length() > 20000.0f) |
2544 | { | 2521 | { |
2545 | v.Normalize(); | 2522 | v.Normalize(); |
@@ -2552,13 +2529,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2552 | public void llApplyRotationalImpulse(LSL_Vector force, int local) | 2529 | public void llApplyRotationalImpulse(LSL_Vector force, int local) |
2553 | { | 2530 | { |
2554 | m_host.AddScriptLPS(1); | 2531 | m_host.AddScriptLPS(1); |
2555 | m_host.ParentGroup.RootPart.ApplyAngularImpulse(new Vector3((float)force.x, (float)force.y, (float)force.z), local != 0); | 2532 | m_host.ParentGroup.RootPart.ApplyAngularImpulse(force, local != 0); |
2556 | } | 2533 | } |
2557 | 2534 | ||
2558 | public void llSetTorque(LSL_Vector torque, int local) | 2535 | public void llSetTorque(LSL_Vector torque, int local) |
2559 | { | 2536 | { |
2560 | m_host.AddScriptLPS(1); | 2537 | m_host.AddScriptLPS(1); |
2561 | m_host.ParentGroup.RootPart.SetAngularImpulse(new Vector3((float)torque.x, (float)torque.y, (float)torque.z), local != 0); | 2538 | m_host.ParentGroup.RootPart.SetAngularImpulse(torque, local != 0); |
2562 | } | 2539 | } |
2563 | 2540 | ||
2564 | public LSL_Vector llGetTorque() | 2541 | public LSL_Vector llGetTorque() |
@@ -3123,13 +3100,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3123 | return; | 3100 | return; |
3124 | } | 3101 | } |
3125 | 3102 | ||
3126 | Vector3 llpos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z); | ||
3127 | Vector3 llvel = new Vector3((float)vel.x, (float)vel.y, (float)vel.z); | ||
3128 | |||
3129 | // need the magnitude later | 3103 | // need the magnitude later |
3130 | // float velmag = (float)Util.GetMagnitude(llvel); | 3104 | // float velmag = (float)Util.GetMagnitude(llvel); |
3131 | 3105 | ||
3132 | SceneObjectGroup new_group = World.RezObject(m_host, item, llpos, Rot2Quaternion(rot), llvel, param); | 3106 | SceneObjectGroup new_group = World.RezObject(m_host, item, pos, rot, vel, param); |
3133 | 3107 | ||
3134 | // If either of these are null, then there was an unknown error. | 3108 | // If either of these are null, then there was an unknown error. |
3135 | if (new_group == null) | 3109 | if (new_group == null) |
@@ -3156,11 +3130,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3156 | 3130 | ||
3157 | PhysicsActor pa = new_group.RootPart.PhysActor; | 3131 | PhysicsActor pa = new_group.RootPart.PhysActor; |
3158 | 3132 | ||
3159 | if (pa != null && pa.IsPhysical && llvel != Vector3.Zero) | 3133 | if (pa != null && pa.IsPhysical && (Vector3)vel != Vector3.Zero) |
3160 | { | 3134 | { |
3161 | float groupmass = new_group.GetMass(); | 3135 | float groupmass = new_group.GetMass(); |
3162 | llvel *= -groupmass; | 3136 | vel *= -groupmass; |
3163 | llApplyImpulse(new LSL_Vector(llvel.X, llvel.Y,llvel.Z), 0); | 3137 | llApplyImpulse(vel, 0); |
3164 | } | 3138 | } |
3165 | // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay) | 3139 | // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay) |
3166 | return; | 3140 | return; |
@@ -3211,7 +3185,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3211 | return; | 3185 | return; |
3212 | } | 3186 | } |
3213 | 3187 | ||
3214 | m_host.StartLookAt(Rot2Quaternion(r3 * r2 * r1), (float)strength, (float)damping); | 3188 | m_host.StartLookAt((Quaternion)(r3 * r2 * r1), (float)strength, (float)damping); |
3215 | } | 3189 | } |
3216 | } | 3190 | } |
3217 | 3191 | ||
@@ -3637,7 +3611,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3637 | } | 3611 | } |
3638 | else | 3612 | else |
3639 | { | 3613 | { |
3640 | m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping); | 3614 | m_host.RotLookAt(target, (float)strength, (float)damping); |
3641 | } | 3615 | } |
3642 | } | 3616 | } |
3643 | 3617 | ||
@@ -3718,7 +3692,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3718 | 3692 | ||
3719 | protected void TargetOmega(SceneObjectPart part, LSL_Vector axis, double spinrate, double gain) | 3693 | protected void TargetOmega(SceneObjectPart part, LSL_Vector axis, double spinrate, double gain) |
3720 | { | 3694 | { |
3721 | part.UpdateAngularVelocity(new Vector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate))); | 3695 | part.UpdateAngularVelocity(axis * spinrate); |
3722 | } | 3696 | } |
3723 | 3697 | ||
3724 | public LSL_Integer llGetStartParameter() | 3698 | public LSL_Integer llGetStartParameter() |
@@ -3928,7 +3902,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3928 | try | 3902 | try |
3929 | { | 3903 | { |
3930 | foreach (SceneObjectPart part in parts) | 3904 | foreach (SceneObjectPart part in parts) |
3931 | part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); | 3905 | part.SetFaceColorAlpha(face, color, null); |
3932 | } | 3906 | } |
3933 | finally | 3907 | finally |
3934 | { | 3908 | { |
@@ -4398,9 +4372,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4398 | public void llSetText(string text, LSL_Vector color, double alpha) | 4372 | public void llSetText(string text, LSL_Vector color, double alpha) |
4399 | { | 4373 | { |
4400 | m_host.AddScriptLPS(1); | 4374 | m_host.AddScriptLPS(1); |
4401 | Vector3 av3 = new Vector3(Util.Clip((float)color.x, 0.0f, 1.0f), | 4375 | Vector3 av3 = Util.Clip(color, 0.0f, 1.0f); |
4402 | Util.Clip((float)color.y, 0.0f, 1.0f), | ||
4403 | Util.Clip((float)color.z, 0.0f, 1.0f)); | ||
4404 | m_host.SetText(text.Length > 254 ? text.Remove(254) : text, av3, Util.Clip((float)alpha, 0.0f, 1.0f)); | 4376 | m_host.SetText(text.Length > 254 ? text.Remove(254) : text, av3, Util.Clip((float)alpha, 0.0f, 1.0f)); |
4405 | //m_host.ParentGroup.HasGroupChanged = true; | 4377 | //m_host.ParentGroup.HasGroupChanged = true; |
4406 | //m_host.ParentGroup.ScheduleGroupForFullUpdate(); | 4378 | //m_host.ParentGroup.ScheduleGroupForFullUpdate(); |
@@ -4616,14 +4588,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4616 | ScriptSleep(5000); | 4588 | ScriptSleep(5000); |
4617 | } | 4589 | } |
4618 | 4590 | ||
4619 | public void llTeleportAgent(string agent, string destination, LSL_Vector pos, LSL_Vector lookAt) | 4591 | public void llTeleportAgent(string agent, string destination, LSL_Vector targetPos, LSL_Vector targetLookAt) |
4620 | { | 4592 | { |
4621 | m_host.AddScriptLPS(1); | 4593 | m_host.AddScriptLPS(1); |
4622 | UUID agentId = new UUID(); | 4594 | UUID agentId = new UUID(); |
4623 | 4595 | ||
4624 | Vector3 targetPos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z); | ||
4625 | Vector3 targetLookAt = new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z); | ||
4626 | |||
4627 | if (UUID.TryParse(agent, out agentId)) | 4596 | if (UUID.TryParse(agent, out agentId)) |
4628 | { | 4597 | { |
4629 | ScenePresence presence = World.GetScenePresence(agentId); | 4598 | ScenePresence presence = World.GetScenePresence(agentId); |
@@ -4652,15 +4621,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4652 | } | 4621 | } |
4653 | } | 4622 | } |
4654 | 4623 | ||
4655 | public void llTeleportAgentGlobalCoords(string agent, LSL_Vector global_coords, LSL_Vector pos, LSL_Vector lookAt) | 4624 | public void llTeleportAgentGlobalCoords(string agent, LSL_Vector global_coords, LSL_Vector targetPos, LSL_Vector targetLookAt) |
4656 | { | 4625 | { |
4657 | m_host.AddScriptLPS(1); | 4626 | m_host.AddScriptLPS(1); |
4658 | UUID agentId = new UUID(); | 4627 | UUID agentId = new UUID(); |
4659 | 4628 | ||
4660 | ulong regionHandle = Utils.UIntsToLong((uint)global_coords.x, (uint)global_coords.y); | 4629 | ulong regionHandle = Utils.UIntsToLong((uint)global_coords.x, (uint)global_coords.y); |
4661 | 4630 | ||
4662 | Vector3 targetPos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z); | ||
4663 | Vector3 targetLookAt = new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z); | ||
4664 | if (UUID.TryParse(agent, out agentId)) | 4631 | if (UUID.TryParse(agent, out agentId)) |
4665 | { | 4632 | { |
4666 | ScenePresence presence = World.GetScenePresence(agentId); | 4633 | ScenePresence presence = World.GetScenePresence(agentId); |
@@ -4957,7 +4924,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4957 | distance_attenuation = 1f / normalized_units; | 4924 | distance_attenuation = 1f / normalized_units; |
4958 | } | 4925 | } |
4959 | 4926 | ||
4960 | Vector3 applied_linear_impulse = new Vector3((float)impulse.x, (float)impulse.y, (float)impulse.z); | 4927 | Vector3 applied_linear_impulse = impulse; |
4961 | { | 4928 | { |
4962 | float impulse_length = applied_linear_impulse.Length(); | 4929 | float impulse_length = applied_linear_impulse.Length(); |
4963 | 4930 | ||
@@ -6525,9 +6492,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6525 | 6492 | ||
6526 | //Plug the x,y coordinates of the slope normal into the equation of the plane to get | 6493 | //Plug the x,y coordinates of the slope normal into the equation of the plane to get |
6527 | //the height of that point on the plane. The resulting vector gives the slope. | 6494 | //the height of that point on the plane. The resulting vector gives the slope. |
6528 | Vector3 vsl = new Vector3(); | 6495 | Vector3 vsl = vsn; |
6529 | vsl.X = (float)vsn.x; | ||
6530 | vsl.Y = (float)vsn.y; | ||
6531 | vsl.Z = (float)(((vsn.x * vsn.x) + (vsn.y * vsn.y)) / (-1 * vsn.z)); | 6496 | vsl.Z = (float)(((vsn.x * vsn.x) + (vsn.y * vsn.y)) / (-1 * vsn.z)); |
6532 | vsl.Normalize(); | 6497 | vsl.Normalize(); |
6533 | //Normalization might be overkill here | 6498 | //Normalization might be overkill here |
@@ -6538,9 +6503,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6538 | public LSL_Vector llGroundNormal(LSL_Vector offset) | 6503 | public LSL_Vector llGroundNormal(LSL_Vector offset) |
6539 | { | 6504 | { |
6540 | m_host.AddScriptLPS(1); | 6505 | m_host.AddScriptLPS(1); |
6541 | Vector3 pos = m_host.GetWorldPosition() + new Vector3((float)offset.x, | 6506 | Vector3 pos = m_host.GetWorldPosition() + (Vector3)offset; |
6542 | (float)offset.y, | ||
6543 | (float)offset.z); | ||
6544 | // Clamp to valid position | 6507 | // Clamp to valid position |
6545 | if (pos.X < 0) | 6508 | if (pos.X < 0) |
6546 | pos.X = 0; | 6509 | pos.X = 0; |
@@ -6994,8 +6957,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6994 | 6957 | ||
6995 | if (!m_host.ParentGroup.IsDeleted) | 6958 | if (!m_host.ParentGroup.IsDeleted) |
6996 | { | 6959 | { |
6997 | m_host.ParentGroup.RootPart.SetVehicleVectorParam(param, | 6960 | m_host.ParentGroup.RootPart.SetVehicleVectorParam(param, vec); |
6998 | new Vector3((float)vec.x, (float)vec.y, (float)vec.z)); | ||
6999 | } | 6961 | } |
7000 | } | 6962 | } |
7001 | 6963 | ||
@@ -7007,7 +6969,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7007 | 6969 | ||
7008 | if (!m_host.ParentGroup.IsDeleted) | 6970 | if (!m_host.ParentGroup.IsDeleted) |
7009 | { | 6971 | { |
7010 | m_host.ParentGroup.RootPart.SetVehicleRotationParam(param, Rot2Quaternion(rot)); | 6972 | m_host.ParentGroup.RootPart.SetVehicleRotationParam(param, rot); |
7011 | } | 6973 | } |
7012 | } | 6974 | } |
7013 | 6975 | ||
@@ -7037,8 +6999,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7037 | if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0) | 6999 | if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0) |
7038 | rot.s = 1; // ZERO_ROTATION = 0,0,0,1 | 7000 | rot.s = 1; // ZERO_ROTATION = 0,0,0,1 |
7039 | 7001 | ||
7040 | part.SitTargetPosition = new Vector3((float)offset.x, (float)offset.y, (float)offset.z); | 7002 | part.SitTargetPosition = offset; |
7041 | part.SitTargetOrientation = Rot2Quaternion(rot); | 7003 | part.SitTargetOrientation = rot; |
7042 | part.ParentGroup.HasGroupChanged = true; | 7004 | part.ParentGroup.HasGroupChanged = true; |
7043 | } | 7005 | } |
7044 | 7006 | ||
@@ -7141,13 +7103,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7141 | public void llSetCameraEyeOffset(LSL_Vector offset) | 7103 | public void llSetCameraEyeOffset(LSL_Vector offset) |
7142 | { | 7104 | { |
7143 | m_host.AddScriptLPS(1); | 7105 | m_host.AddScriptLPS(1); |
7144 | m_host.SetCameraEyeOffset(new Vector3((float)offset.x, (float)offset.y, (float)offset.z)); | 7106 | m_host.SetCameraEyeOffset(offset); |
7145 | } | 7107 | } |
7146 | 7108 | ||
7147 | public void llSetCameraAtOffset(LSL_Vector offset) | 7109 | public void llSetCameraAtOffset(LSL_Vector offset) |
7148 | { | 7110 | { |
7149 | m_host.AddScriptLPS(1); | 7111 | m_host.AddScriptLPS(1); |
7150 | m_host.SetCameraAtOffset(new Vector3((float)offset.x, (float)offset.y, (float)offset.z)); | 7112 | m_host.SetCameraAtOffset(offset); |
7151 | } | 7113 | } |
7152 | 7114 | ||
7153 | public LSL_String llDumpList2String(LSL_List src, string seperator) | 7115 | public LSL_String llDumpList2String(LSL_List src, string seperator) |
@@ -7169,7 +7131,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7169 | public LSL_Integer llScriptDanger(LSL_Vector pos) | 7131 | public LSL_Integer llScriptDanger(LSL_Vector pos) |
7170 | { | 7132 | { |
7171 | m_host.AddScriptLPS(1); | 7133 | m_host.AddScriptLPS(1); |
7172 | bool result = World.ScriptDanger(m_host.LocalId, new Vector3((float)pos.x, (float)pos.y, (float)pos.z)); | 7134 | bool result = World.ScriptDanger(m_host.LocalId, pos); |
7173 | if (result) | 7135 | if (result) |
7174 | { | 7136 | { |
7175 | return 1; | 7137 | return 1; |
@@ -8103,13 +8065,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8103 | if (rootPart == part) | 8065 | if (rootPart == part) |
8104 | { | 8066 | { |
8105 | // special case: If we are root, rotate complete SOG to new rotation | 8067 | // special case: If we are root, rotate complete SOG to new rotation |
8106 | SetRot(part, Rot2Quaternion(q)); | 8068 | SetRot(part, q); |
8107 | } | 8069 | } |
8108 | else | 8070 | else |
8109 | { | 8071 | { |
8110 | // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. | 8072 | // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. |
8111 | // sounds like sl bug that we need to replicate | 8073 | // sounds like sl bug that we need to replicate |
8112 | SetRot(part, rootPart.RotationOffset * Rot2Quaternion(q)); | 8074 | SetRot(part, rootPart.RotationOffset * (Quaternion)q); |
8113 | } | 8075 | } |
8114 | 8076 | ||
8115 | break; | 8077 | break; |
@@ -8283,8 +8245,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8283 | LSL_Vector color=rules.GetVector3Item(idx++); | 8245 | LSL_Vector color=rules.GetVector3Item(idx++); |
8284 | double alpha=(double)rules.GetLSLFloatItem(idx++); | 8246 | double alpha=(double)rules.GetLSLFloatItem(idx++); |
8285 | 8247 | ||
8286 | part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); | 8248 | part.SetFaceColorAlpha(face, color, alpha); |
8287 | SetAlpha(part, alpha, face); | ||
8288 | 8249 | ||
8289 | break; | 8250 | break; |
8290 | 8251 | ||
@@ -8432,9 +8393,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8432 | string primText = rules.GetLSLStringItem(idx++); | 8393 | string primText = rules.GetLSLStringItem(idx++); |
8433 | LSL_Vector primTextColor = rules.GetVector3Item(idx++); | 8394 | LSL_Vector primTextColor = rules.GetVector3Item(idx++); |
8434 | LSL_Float primTextAlpha = rules.GetLSLFloatItem(idx++); | 8395 | LSL_Float primTextAlpha = rules.GetLSLFloatItem(idx++); |
8435 | Vector3 av3 = new Vector3(Util.Clip((float)primTextColor.x, 0.0f, 1.0f), | 8396 | Vector3 av3 = Util.Clip(primTextColor, 0.0f, 1.0f); |
8436 | Util.Clip((float)primTextColor.y, 0.0f, 1.0f), | ||
8437 | Util.Clip((float)primTextColor.z, 0.0f, 1.0f)); | ||
8438 | part.SetText(primText, av3, Util.Clip((float)primTextAlpha, 0.0f, 1.0f)); | 8397 | part.SetText(primText, av3, Util.Clip((float)primTextAlpha, 0.0f, 1.0f)); |
8439 | 8398 | ||
8440 | break; | 8399 | break; |
@@ -8453,8 +8412,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8453 | case (int)ScriptBaseClass.PRIM_ROT_LOCAL: | 8412 | case (int)ScriptBaseClass.PRIM_ROT_LOCAL: |
8454 | if (remain < 1) | 8413 | if (remain < 1) |
8455 | return null; | 8414 | return null; |
8456 | LSL_Rotation lr = rules.GetQuaternionItem(idx++); | 8415 | SetRot(part, rules.GetQuaternionItem(idx++)); |
8457 | SetRot(part, Rot2Quaternion(lr)); | ||
8458 | break; | 8416 | break; |
8459 | case (int)ScriptBaseClass.PRIM_OMEGA: | 8417 | case (int)ScriptBaseClass.PRIM_OMEGA: |
8460 | if (remain < 3) | 8418 | if (remain < 3) |
@@ -8464,7 +8422,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8464 | LSL_Float gain = rules.GetLSLFloatItem(idx++); | 8422 | LSL_Float gain = rules.GetLSLFloatItem(idx++); |
8465 | TargetOmega(part, axis, (double)spinrate, (double)gain); | 8423 | TargetOmega(part, axis, (double)spinrate, (double)gain); |
8466 | break; | 8424 | break; |
8467 | 8425 | case (int)ScriptBaseClass.PRIM_SLICE: | |
8426 | if (remain < 1) | ||
8427 | return null; | ||
8428 | LSL_Vector slice = rules.GetVector3Item(idx++); | ||
8429 | part.UpdateSlice((float)slice.x, (float)slice.y); | ||
8430 | break; | ||
8468 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: | 8431 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: |
8469 | if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. | 8432 | if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. |
8470 | return null; | 8433 | return null; |
@@ -8473,6 +8436,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8473 | } | 8436 | } |
8474 | } | 8437 | } |
8475 | } | 8438 | } |
8439 | catch (InvalidCastException e) | ||
8440 | { | ||
8441 | ShoutError(e.Message); | ||
8442 | } | ||
8476 | finally | 8443 | finally |
8477 | { | 8444 | { |
8478 | if (positionChanged) | 8445 | if (positionChanged) |
@@ -8481,12 +8448,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8481 | { | 8448 | { |
8482 | SceneObjectGroup parent = part.ParentGroup; | 8449 | SceneObjectGroup parent = part.ParentGroup; |
8483 | Util.FireAndForget(delegate(object x) { | 8450 | Util.FireAndForget(delegate(object x) { |
8484 | parent.UpdateGroupPosition(new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z)); | 8451 | parent.UpdateGroupPosition(currentPosition); |
8485 | }); | 8452 | }); |
8486 | } | 8453 | } |
8487 | else | 8454 | else |
8488 | { | 8455 | { |
8489 | part.OffsetPosition = new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z); | 8456 | part.OffsetPosition = currentPosition; |
8490 | SceneObjectGroup parent = part.ParentGroup; | 8457 | SceneObjectGroup parent = part.ParentGroup; |
8491 | parent.HasGroupChanged = true; | 8458 | parent.HasGroupChanged = true; |
8492 | parent.ScheduleGroupForTerseUpdate(); | 8459 | parent.ScheduleGroupForTerseUpdate(); |
@@ -9570,7 +9537,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9570 | case (int)ScriptBaseClass.PRIM_POS_LOCAL: | 9537 | case (int)ScriptBaseClass.PRIM_POS_LOCAL: |
9571 | res.Add(new LSL_Vector(GetPartLocalPos(part))); | 9538 | res.Add(new LSL_Vector(GetPartLocalPos(part))); |
9572 | break; | 9539 | break; |
9573 | |||
9574 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: | 9540 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: |
9575 | if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. | 9541 | if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. |
9576 | return res; | 9542 | return res; |
@@ -9579,6 +9545,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9579 | LSL_List tres = llGetLinkPrimitiveParams((int)new_linknumber, new_rules); | 9545 | LSL_List tres = llGetLinkPrimitiveParams((int)new_linknumber, new_rules); |
9580 | res += tres; | 9546 | res += tres; |
9581 | return res; | 9547 | return res; |
9548 | case (int)ScriptBaseClass.PRIM_SLICE: | ||
9549 | PrimType prim_type = part.GetPrimType(); | ||
9550 | bool useProfileBeginEnd = (prim_type == PrimType.SPHERE || prim_type == PrimType.TORUS || prim_type == PrimType.TUBE || prim_type == PrimType.RING); | ||
9551 | res.Add(new LSL_Vector( | ||
9552 | (useProfileBeginEnd ? part.Shape.ProfileBegin : part.Shape.PathBegin) / 50000.0, | ||
9553 | 1 - (useProfileBeginEnd ? part.Shape.ProfileEnd : part.Shape.PathEnd) / 50000.0, | ||
9554 | 0 | ||
9555 | )); | ||
9556 | break; | ||
9582 | } | 9557 | } |
9583 | } | 9558 | } |
9584 | return res; | 9559 | return res; |
@@ -11164,9 +11139,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11164 | ScenePresence avatar = World.GetScenePresence(detectedParams.Key); | 11139 | ScenePresence avatar = World.GetScenePresence(detectedParams.Key); |
11165 | if (avatar != null) | 11140 | if (avatar != null) |
11166 | { | 11141 | { |
11167 | avatar.ControllingClient.SendScriptTeleportRequest(m_host.Name, simname, | 11142 | avatar.ControllingClient.SendScriptTeleportRequest(m_host.Name, |
11168 | new Vector3((float)pos.x, (float)pos.y, (float)pos.z), | 11143 | simname, pos, lookAt); |
11169 | new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z)); | ||
11170 | } | 11144 | } |
11171 | 11145 | ||
11172 | ScriptSleep(1000); | 11146 | ScriptSleep(1000); |
@@ -11901,13 +11875,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11901 | else | 11875 | else |
11902 | rot = obj.GetWorldRotation(); | 11876 | rot = obj.GetWorldRotation(); |
11903 | 11877 | ||
11904 | LSL_Rotation objrot = new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W); | 11878 | LSL_Rotation objrot = new LSL_Rotation(rot); |
11905 | ret.Add(objrot); | 11879 | ret.Add(objrot); |
11906 | } | 11880 | } |
11907 | break; | 11881 | break; |
11908 | case ScriptBaseClass.OBJECT_VELOCITY: | 11882 | case ScriptBaseClass.OBJECT_VELOCITY: |
11909 | Vector3 ovel = obj.Velocity; | 11883 | ret.Add(new LSL_Vector(obj.Velocity)); |
11910 | ret.Add(new LSL_Vector(ovel.X, ovel.Y, ovel.Z)); | ||
11911 | break; | 11884 | break; |
11912 | case ScriptBaseClass.OBJECT_OWNER: | 11885 | case ScriptBaseClass.OBJECT_OWNER: |
11913 | ret.Add(new LSL_String(obj.OwnerID.ToString())); | 11886 | ret.Add(new LSL_String(obj.OwnerID.ToString())); |
@@ -12513,8 +12486,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12513 | 12486 | ||
12514 | m_host.AddScriptLPS(1); | 12487 | m_host.AddScriptLPS(1); |
12515 | 12488 | ||
12516 | Vector3 rayStart = new Vector3((float)start.x, (float)start.y, (float)start.z); | 12489 | Vector3 rayStart = start; |
12517 | Vector3 rayEnd = new Vector3((float)end.x, (float)end.y, (float)end.z); | 12490 | Vector3 rayEnd = end; |
12518 | Vector3 dir = rayEnd - rayStart; | 12491 | Vector3 dir = rayEnd - rayStart; |
12519 | 12492 | ||
12520 | float dist = Vector3.Mag(dir); | 12493 | float dist = Vector3.Mag(dir); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs index 795de80..ceb4660 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs | |||
@@ -304,7 +304,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
304 | case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY: | 304 | case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY: |
305 | idx++; | 305 | idx++; |
306 | iV = rules.GetVector3Item(idx); | 306 | iV = rules.GetVector3Item(idx); |
307 | wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | 307 | wl.cloudDetailXYDensity = iV; |
308 | break; | 308 | break; |
309 | case (int)ScriptBaseClass.WL_CLOUD_SCALE: | 309 | case (int)ScriptBaseClass.WL_CLOUD_SCALE: |
310 | idx++; | 310 | idx++; |
@@ -329,7 +329,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
329 | case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY: | 329 | case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY: |
330 | idx++; | 330 | idx++; |
331 | iV = rules.GetVector3Item(idx); | 331 | iV = rules.GetVector3Item(idx); |
332 | wl.cloudXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | 332 | wl.cloudXYDensity = iV; |
333 | break; | 333 | break; |
334 | case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER: | 334 | case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER: |
335 | idx++; | 335 | idx++; |
@@ -384,7 +384,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
384 | case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE: | 384 | case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE: |
385 | idx++; | 385 | idx++; |
386 | iV = rules.GetVector3Item(idx); | 386 | iV = rules.GetVector3Item(idx); |
387 | wl.reflectionWaveletScale = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | 387 | wl.reflectionWaveletScale = iV; |
388 | break; | 388 | break; |
389 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE: | 389 | case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE: |
390 | idx++; | 390 | idx++; |
@@ -422,7 +422,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
422 | case (int)ScriptBaseClass.WL_WATER_COLOR: | 422 | case (int)ScriptBaseClass.WL_WATER_COLOR: |
423 | idx++; | 423 | idx++; |
424 | iV = rules.GetVector3Item(idx); | 424 | iV = rules.GetVector3Item(idx); |
425 | wl.waterColor = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); | 425 | wl.waterColor = iV; |
426 | break; | 426 | break; |
427 | case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT: | 427 | case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT: |
428 | idx++; | 428 | idx++; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs index 7844c75..84cf6ca 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs | |||
@@ -333,8 +333,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
333 | { | 333 | { |
334 | if (type == typeof(OpenMetaverse.Quaternion)) | 334 | if (type == typeof(OpenMetaverse.Quaternion)) |
335 | { | 335 | { |
336 | LSL_Rotation rot = (LSL_Rotation)lslparm; | 336 | return (OpenMetaverse.Quaternion)((LSL_Rotation)lslparm); |
337 | return new OpenMetaverse.Quaternion((float)rot.x,(float)rot.y,(float)rot.z,(float)rot.s); | ||
338 | } | 337 | } |
339 | } | 338 | } |
340 | 339 | ||
@@ -343,8 +342,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
343 | { | 342 | { |
344 | if (type == typeof(OpenMetaverse.Vector3)) | 343 | if (type == typeof(OpenMetaverse.Vector3)) |
345 | { | 344 | { |
346 | LSL_Vector vect = (LSL_Vector)lslparm; | 345 | return (OpenMetaverse.Vector3)((LSL_Vector)lslparm); |
347 | return new OpenMetaverse.Vector3((float)vect.x,(float)vect.y,(float)vect.z); | ||
348 | } | 346 | } |
349 | } | 347 | } |
350 | 348 | ||
@@ -367,13 +365,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
367 | result[i] = new UUID((LSL_Key)plist[i]); | 365 | result[i] = new UUID((LSL_Key)plist[i]); |
368 | else if (plist[i] is LSL_Rotation) | 366 | else if (plist[i] is LSL_Rotation) |
369 | { | 367 | { |
370 | LSL_Rotation rot = (LSL_Rotation)plist[i]; | 368 | result[i] = (OpenMetaverse.Quaternion)( |
371 | result[i] = new OpenMetaverse.Quaternion((float)rot.x,(float)rot.y,(float)rot.z,(float)rot.s); | 369 | (LSL_Rotation)plist[i]); |
372 | } | 370 | } |
373 | else if (plist[i] is LSL_Vector) | 371 | else if (plist[i] is LSL_Vector) |
374 | { | 372 | { |
375 | LSL_Vector vect = (LSL_Vector)plist[i]; | 373 | result[i] = (OpenMetaverse.Vector3)( |
376 | result[i] = new OpenMetaverse.Vector3((float)vect.x,(float)vect.y,(float)vect.z); | 374 | (LSL_Vector)plist[i]); |
377 | } | 375 | } |
378 | else | 376 | else |
379 | MODError("unknown LSL list element type"); | 377 | MODError("unknown LSL list element type"); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 2f02f1f..04c3184 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -782,10 +782,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
782 | 782 | ||
783 | // We will launch the teleport on a new thread so that when the script threads are terminated | 783 | // We will launch the teleport on a new thread so that when the script threads are terminated |
784 | // before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting. | 784 | // before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting. |
785 | Util.FireAndForget( | 785 | Util.FireAndForget(o => World.RequestTeleportLocation( |
786 | o => World.RequestTeleportLocation(presence.ControllingClient, regionName, | 786 | presence.ControllingClient, regionName, position, |
787 | new Vector3((float)position.x, (float)position.y, (float)position.z), | 787 | lookat, (uint)TPFlags.ViaLocation)); |
788 | new Vector3((float)lookat.x, (float)lookat.y, (float)lookat.z), (uint)TPFlags.ViaLocation)); | ||
789 | 788 | ||
790 | ScriptSleep(5000); | 789 | ScriptSleep(5000); |
791 | 790 | ||
@@ -828,10 +827,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
828 | 827 | ||
829 | // We will launch the teleport on a new thread so that when the script threads are terminated | 828 | // We will launch the teleport on a new thread so that when the script threads are terminated |
830 | // before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting. | 829 | // before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting. |
831 | Util.FireAndForget( | 830 | Util.FireAndForget(o => World.RequestTeleportLocation( |
832 | o => World.RequestTeleportLocation(presence.ControllingClient, regionHandle, | 831 | presence.ControllingClient, regionHandle, |
833 | new Vector3((float)position.x, (float)position.y, (float)position.z), | 832 | position, lookat, (uint)TPFlags.ViaLocation)); |
834 | new Vector3((float)lookat.x, (float)lookat.y, (float)lookat.z), (uint)TPFlags.ViaLocation)); | ||
835 | 833 | ||
836 | ScriptSleep(5000); | 834 | ScriptSleep(5000); |
837 | 835 | ||
@@ -2355,7 +2353,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2355 | ownerID = m_host.OwnerID; | 2353 | ownerID = m_host.OwnerID; |
2356 | UUID x = module.CreateNPC(firstname, | 2354 | UUID x = module.CreateNPC(firstname, |
2357 | lastname, | 2355 | lastname, |
2358 | new Vector3((float) position.x, (float) position.y, (float) position.z), | 2356 | position, |
2359 | ownerID, | 2357 | ownerID, |
2360 | senseAsAgent, | 2358 | senseAsAgent, |
2361 | World, | 2359 | World, |
@@ -2478,7 +2476,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2478 | return new LSL_Vector(0, 0, 0); | 2476 | return new LSL_Vector(0, 0, 0); |
2479 | } | 2477 | } |
2480 | 2478 | ||
2481 | public void osNpcMoveTo(LSL_Key npc, LSL_Vector position) | 2479 | public void osNpcMoveTo(LSL_Key npc, LSL_Vector pos) |
2482 | { | 2480 | { |
2483 | CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo"); | 2481 | CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo"); |
2484 | m_host.AddScriptLPS(1); | 2482 | m_host.AddScriptLPS(1); |
@@ -2493,7 +2491,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2493 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) | 2491 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) |
2494 | return; | 2492 | return; |
2495 | 2493 | ||
2496 | Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z); | ||
2497 | module.MoveToTarget(npcId, World, pos, false, true, false); | 2494 | module.MoveToTarget(npcId, World, pos, false, true, false); |
2498 | } | 2495 | } |
2499 | } | 2496 | } |
@@ -2513,11 +2510,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2513 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) | 2510 | if (!module.CheckPermissions(npcId, m_host.OwnerID)) |
2514 | return; | 2511 | return; |
2515 | 2512 | ||
2516 | Vector3 pos = new Vector3((float)target.x, (float)target.y, (float)target.z); | ||
2517 | module.MoveToTarget( | 2513 | module.MoveToTarget( |
2518 | new UUID(npc.m_string), | 2514 | new UUID(npc.m_string), |
2519 | World, | 2515 | World, |
2520 | pos, | 2516 | target, |
2521 | (options & ScriptBaseClass.OS_NPC_NO_FLY) != 0, | 2517 | (options & ScriptBaseClass.OS_NPC_NO_FLY) != 0, |
2522 | (options & ScriptBaseClass.OS_NPC_LAND_AT_TARGET) != 0, | 2518 | (options & ScriptBaseClass.OS_NPC_LAND_AT_TARGET) != 0, |
2523 | (options & ScriptBaseClass.OS_NPC_RUNNING) != 0); | 2519 | (options & ScriptBaseClass.OS_NPC_RUNNING) != 0); |
@@ -2569,7 +2565,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2569 | ScenePresence sp = World.GetScenePresence(npcId); | 2565 | ScenePresence sp = World.GetScenePresence(npcId); |
2570 | 2566 | ||
2571 | if (sp != null) | 2567 | if (sp != null) |
2572 | sp.Rotation = LSL_Api.Rot2Quaternion(rotation); | 2568 | sp.Rotation = rotation; |
2573 | } | 2569 | } |
2574 | } | 2570 | } |
2575 | 2571 | ||
@@ -2929,7 +2925,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2929 | avatar.SpeedModifier = (float)SpeedModifier; | 2925 | avatar.SpeedModifier = (float)SpeedModifier; |
2930 | } | 2926 | } |
2931 | 2927 | ||
2932 | public void osKickAvatar(string FirstName,string SurName,string alert) | 2928 | public void osKickAvatar(string FirstName, string SurName, string alert) |
2933 | { | 2929 | { |
2934 | CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar"); | 2930 | CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar"); |
2935 | m_host.AddScriptLPS(1); | 2931 | m_host.AddScriptLPS(1); |
@@ -2943,7 +2939,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2943 | sp.ControllingClient.Kick(alert); | 2939 | sp.ControllingClient.Kick(alert); |
2944 | 2940 | ||
2945 | // ...and close on our side | 2941 | // ...and close on our side |
2946 | sp.Scene.IncomingCloseAgent(sp.UUID); | 2942 | sp.Scene.IncomingCloseAgent(sp.UUID, false); |
2947 | } | 2943 | } |
2948 | }); | 2944 | }); |
2949 | } | 2945 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index 678f9d5..4dd795d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs | |||
@@ -352,7 +352,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
352 | q = avatar.Rotation; | 352 | q = avatar.Rotation; |
353 | } | 353 | } |
354 | 354 | ||
355 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); | 355 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q); |
356 | LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); | 356 | LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); |
357 | double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); | 357 | double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); |
358 | 358 | ||
@@ -429,9 +429,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
429 | try | 429 | try |
430 | { | 430 | { |
431 | Vector3 diff = toRegionPos - fromRegionPos; | 431 | Vector3 diff = toRegionPos - fromRegionPos; |
432 | LSL_Types.Vector3 obj_dir = new LSL_Types.Vector3(diff.X, diff.Y, diff.Z); | 432 | double dot = LSL_Types.Vector3.Dot(forward_dir, diff); |
433 | double dot = LSL_Types.Vector3.Dot(forward_dir, obj_dir); | 433 | double mag_obj = LSL_Types.Vector3.Mag(diff); |
434 | double mag_obj = LSL_Types.Vector3.Mag(obj_dir); | ||
435 | ang_obj = Math.Acos(dot / (mag_fwd * mag_obj)); | 434 | ang_obj = Math.Acos(dot / (mag_fwd * mag_obj)); |
436 | } | 435 | } |
437 | catch | 436 | catch |
@@ -483,7 +482,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
483 | q = avatar.Rotation; | 482 | q = avatar.Rotation; |
484 | } | 483 | } |
485 | 484 | ||
486 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); | 485 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q); |
487 | LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); | 486 | LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); |
488 | double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); | 487 | double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); |
489 | bool attached = (SensePoint.ParentGroup.AttachmentPoint != 0); | 488 | bool attached = (SensePoint.ParentGroup.AttachmentPoint != 0); |
@@ -564,8 +563,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
564 | double ang_obj = 0; | 563 | double ang_obj = 0; |
565 | try | 564 | try |
566 | { | 565 | { |
567 | Vector3 diff = toRegionPos - fromRegionPos; | 566 | LSL_Types.Vector3 obj_dir = new LSL_Types.Vector3( |
568 | LSL_Types.Vector3 obj_dir = new LSL_Types.Vector3(diff.X, diff.Y, diff.Z); | 567 | toRegionPos - fromRegionPos); |
569 | double dot = LSL_Types.Vector3.Dot(forward_dir, obj_dir); | 568 | double dot = LSL_Types.Vector3.Dot(forward_dir, obj_dir); |
570 | double mag_obj = LSL_Types.Vector3.Mag(obj_dir); | 569 | double mag_obj = LSL_Types.Vector3.Mag(obj_dir); |
571 | ang_obj = Math.Acos(dot / (mag_fwd * mag_obj)); | 570 | ang_obj = Math.Acos(dot / (mag_fwd * mag_obj)); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index f989cc6..05ba222 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | |||
@@ -329,6 +329,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
329 | public const int PRIM_OMEGA = 32; | 329 | public const int PRIM_OMEGA = 32; |
330 | public const int PRIM_POS_LOCAL = 33; | 330 | public const int PRIM_POS_LOCAL = 33; |
331 | public const int PRIM_LINK_TARGET = 34; | 331 | public const int PRIM_LINK_TARGET = 34; |
332 | public const int PRIM_SLICE = 35; | ||
332 | public const int PRIM_TEXGEN_DEFAULT = 0; | 333 | public const int PRIM_TEXGEN_DEFAULT = 0; |
333 | public const int PRIM_TEXGEN_PLANAR = 1; | 334 | public const int PRIM_TEXGEN_PLANAR = 1; |
334 | 335 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs index 17a0d69..03be2ab 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs | |||
@@ -546,6 +546,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
546 | "OpenSim.Region.ScriptEngine.Shared.dll")); | 546 | "OpenSim.Region.ScriptEngine.Shared.dll")); |
547 | parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, | 547 | parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, |
548 | "OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll")); | 548 | "OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll")); |
549 | parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, | ||
550 | "OpenMetaverseTypes.dll")); | ||
549 | 551 | ||
550 | if (lang == enumCompileType.yp) | 552 | if (lang == enumCompileType.yp) |
551 | { | 553 | { |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs index 9e5fb24..22804f5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs | |||
@@ -164,11 +164,11 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
164 | else | 164 | else |
165 | { | 165 | { |
166 | // Set the values from the touch data provided by the client | 166 | // Set the values from the touch data provided by the client |
167 | touchST = new LSL_Types.Vector3(value.STCoord.X, value.STCoord.Y, value.STCoord.Z); | 167 | touchST = new LSL_Types.Vector3(value.STCoord); |
168 | touchUV = new LSL_Types.Vector3(value.UVCoord.X, value.UVCoord.Y, value.UVCoord.Z); | 168 | touchUV = new LSL_Types.Vector3(value.UVCoord); |
169 | touchNormal = new LSL_Types.Vector3(value.Normal.X, value.Normal.Y, value.Normal.Z); | 169 | touchNormal = new LSL_Types.Vector3(value.Normal); |
170 | touchBinormal = new LSL_Types.Vector3(value.Binormal.X, value.Binormal.Y, value.Binormal.Z); | 170 | touchBinormal = new LSL_Types.Vector3(value.Binormal); |
171 | touchPos = new LSL_Types.Vector3(value.Position.X, value.Position.Y, value.Position.Z); | 171 | touchPos = new LSL_Types.Vector3(value.Position); |
172 | touchFace = value.FaceIndex; | 172 | touchFace = value.FaceIndex; |
173 | } | 173 | } |
174 | } | 174 | } |
@@ -189,19 +189,13 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
189 | Country = account.UserCountry; | 189 | Country = account.UserCountry; |
190 | 190 | ||
191 | Owner = Key; | 191 | Owner = Key; |
192 | Position = new LSL_Types.Vector3( | 192 | Position = new LSL_Types.Vector3(presence.AbsolutePosition); |
193 | presence.AbsolutePosition.X, | ||
194 | presence.AbsolutePosition.Y, | ||
195 | presence.AbsolutePosition.Z); | ||
196 | Rotation = new LSL_Types.Quaternion( | 193 | Rotation = new LSL_Types.Quaternion( |
197 | presence.Rotation.X, | 194 | presence.Rotation.X, |
198 | presence.Rotation.Y, | 195 | presence.Rotation.Y, |
199 | presence.Rotation.Z, | 196 | presence.Rotation.Z, |
200 | presence.Rotation.W); | 197 | presence.Rotation.W); |
201 | Velocity = new LSL_Types.Vector3( | 198 | Velocity = new LSL_Types.Vector3(presence.Velocity); |
202 | presence.Velocity.X, | ||
203 | presence.Velocity.Y, | ||
204 | presence.Velocity.Z); | ||
205 | 199 | ||
206 | Type = 0x01; // Avatar | 200 | Type = 0x01; // Avatar |
207 | if (presence.PresenceType == PresenceType.Npc) | 201 | if (presence.PresenceType == PresenceType.Npc) |
@@ -254,16 +248,12 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
254 | } | 248 | } |
255 | } | 249 | } |
256 | 250 | ||
257 | Position = new LSL_Types.Vector3(part.AbsolutePosition.X, | 251 | Position = new LSL_Types.Vector3(part.AbsolutePosition); |
258 | part.AbsolutePosition.Y, | ||
259 | part.AbsolutePosition.Z); | ||
260 | 252 | ||
261 | Quaternion wr = part.ParentGroup.GroupRotation; | 253 | Quaternion wr = part.ParentGroup.GroupRotation; |
262 | Rotation = new LSL_Types.Quaternion(wr.X, wr.Y, wr.Z, wr.W); | 254 | Rotation = new LSL_Types.Quaternion(wr.X, wr.Y, wr.Z, wr.W); |
263 | 255 | ||
264 | Velocity = new LSL_Types.Vector3(part.Velocity.X, | 256 | Velocity = new LSL_Types.Vector3(part.Velocity); |
265 | part.Velocity.Y, | ||
266 | part.Velocity.Z); | ||
267 | } | 257 | } |
268 | } | 258 | } |
269 | 259 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index 8adf4c5..c9c4753 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | |||
@@ -31,6 +31,11 @@ using System.Globalization; | |||
31 | using System.Text.RegularExpressions; | 31 | using System.Text.RegularExpressions; |
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | 33 | ||
34 | using OpenMetaverse; | ||
35 | using OMV_Vector3 = OpenMetaverse.Vector3; | ||
36 | using OMV_Vector3d = OpenMetaverse.Vector3d; | ||
37 | using OMV_Quaternion = OpenMetaverse.Quaternion; | ||
38 | |||
34 | namespace OpenSim.Region.ScriptEngine.Shared | 39 | namespace OpenSim.Region.ScriptEngine.Shared |
35 | { | 40 | { |
36 | [Serializable] | 41 | [Serializable] |
@@ -54,6 +59,20 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
54 | z = (float)vector.z; | 59 | z = (float)vector.z; |
55 | } | 60 | } |
56 | 61 | ||
62 | public Vector3(OMV_Vector3 vector) | ||
63 | { | ||
64 | x = vector.X; | ||
65 | y = vector.Y; | ||
66 | z = vector.Z; | ||
67 | } | ||
68 | |||
69 | public Vector3(OMV_Vector3d vector) | ||
70 | { | ||
71 | x = vector.X; | ||
72 | y = vector.Y; | ||
73 | z = vector.Z; | ||
74 | } | ||
75 | |||
57 | public Vector3(double X, double Y, double Z) | 76 | public Vector3(double X, double Y, double Z) |
58 | { | 77 | { |
59 | x = X; | 78 | x = X; |
@@ -109,6 +128,26 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
109 | return new list(new object[] { vec }); | 128 | return new list(new object[] { vec }); |
110 | } | 129 | } |
111 | 130 | ||
131 | public static implicit operator OMV_Vector3(Vector3 vec) | ||
132 | { | ||
133 | return new OMV_Vector3((float)vec.x, (float)vec.y, (float)vec.z); | ||
134 | } | ||
135 | |||
136 | public static implicit operator Vector3(OMV_Vector3 vec) | ||
137 | { | ||
138 | return new Vector3(vec); | ||
139 | } | ||
140 | |||
141 | public static implicit operator OMV_Vector3d(Vector3 vec) | ||
142 | { | ||
143 | return new OMV_Vector3d(vec.x, vec.y, vec.z); | ||
144 | } | ||
145 | |||
146 | public static implicit operator Vector3(OMV_Vector3d vec) | ||
147 | { | ||
148 | return new Vector3(vec); | ||
149 | } | ||
150 | |||
112 | public static bool operator ==(Vector3 lhs, Vector3 rhs) | 151 | public static bool operator ==(Vector3 lhs, Vector3 rhs) |
113 | { | 152 | { |
114 | return (lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z); | 153 | return (lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z); |
@@ -322,6 +361,14 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
322 | s = 1; | 361 | s = 1; |
323 | } | 362 | } |
324 | 363 | ||
364 | public Quaternion(OMV_Quaternion rot) | ||
365 | { | ||
366 | x = rot.X; | ||
367 | y = rot.Y; | ||
368 | z = rot.Z; | ||
369 | s = rot.W; | ||
370 | } | ||
371 | |||
325 | #endregion | 372 | #endregion |
326 | 373 | ||
327 | #region Overriders | 374 | #region Overriders |
@@ -368,6 +415,21 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
368 | return new list(new object[] { r }); | 415 | return new list(new object[] { r }); |
369 | } | 416 | } |
370 | 417 | ||
418 | public static implicit operator OMV_Quaternion(Quaternion rot) | ||
419 | { | ||
420 | // LSL quaternions can normalize to 0, normal Quaternions can't. | ||
421 | if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0) | ||
422 | rot.z = 1; // ZERO_ROTATION = 0,0,0,1 | ||
423 | OMV_Quaternion omvrot = new OMV_Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); | ||
424 | omvrot.Normalize(); | ||
425 | return omvrot; | ||
426 | } | ||
427 | |||
428 | public static implicit operator Quaternion(OMV_Quaternion rot) | ||
429 | { | ||
430 | return new Quaternion(rot); | ||
431 | } | ||
432 | |||
371 | public static bool operator ==(Quaternion lhs, Quaternion rhs) | 433 | public static bool operator ==(Quaternion lhs, Quaternion rhs) |
372 | { | 434 | { |
373 | // Return true if the fields match: | 435 | // Return true if the fields match: |
@@ -562,12 +624,23 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
562 | else if (m_data[itemIndex] is LSL_Types.LSLString) | 624 | else if (m_data[itemIndex] is LSL_Types.LSLString) |
563 | return new LSLInteger(m_data[itemIndex].ToString()); | 625 | return new LSLInteger(m_data[itemIndex].ToString()); |
564 | else | 626 | else |
565 | throw new InvalidCastException(); | 627 | throw new InvalidCastException(string.Format( |
628 | "{0} expected but {1} given", | ||
629 | typeof(LSL_Types.LSLInteger).Name, | ||
630 | m_data[itemIndex] != null ? | ||
631 | m_data[itemIndex].GetType().Name : "null")); | ||
566 | } | 632 | } |
567 | 633 | ||
568 | public LSL_Types.Vector3 GetVector3Item(int itemIndex) | 634 | public LSL_Types.Vector3 GetVector3Item(int itemIndex) |
569 | { | 635 | { |
570 | return (LSL_Types.Vector3)m_data[itemIndex]; | 636 | if(m_data[itemIndex] is LSL_Types.Vector3) |
637 | return (LSL_Types.Vector3)m_data[itemIndex]; | ||
638 | else | ||
639 | throw new InvalidCastException(string.Format( | ||
640 | "{0} expected but {1} given", | ||
641 | typeof(LSL_Types.Vector3).Name, | ||
642 | m_data[itemIndex] != null ? | ||
643 | m_data[itemIndex].GetType().Name : "null")); | ||
571 | } | 644 | } |
572 | 645 | ||
573 | public LSL_Types.Quaternion GetQuaternionItem(int itemIndex) | 646 | public LSL_Types.Quaternion GetQuaternionItem(int itemIndex) |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs index 5c4174e..cee10df 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs | |||
@@ -152,9 +152,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
152 | det[0] = new DetectParams(); | 152 | det[0] = new DetectParams(); |
153 | det[0].Key = remoteClient.AgentId; | 153 | det[0].Key = remoteClient.AgentId; |
154 | det[0].Populate(myScriptEngine.World); | 154 | det[0].Populate(myScriptEngine.World); |
155 | det[0].OffsetPos = new LSL_Types.Vector3(offsetPos.X, | 155 | det[0].OffsetPos = offsetPos; |
156 | offsetPos.Y, | ||
157 | offsetPos.Z); | ||
158 | 156 | ||
159 | if (originalID == 0) | 157 | if (originalID == 0) |
160 | { | 158 | { |
@@ -298,9 +296,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
298 | foreach (DetectedObject detobj in col.Colliders) | 296 | foreach (DetectedObject detobj in col.Colliders) |
299 | { | 297 | { |
300 | DetectParams d = new DetectParams(); | 298 | DetectParams d = new DetectParams(); |
301 | d.Position = new LSL_Types.Vector3(detobj.posVector.X, | 299 | d.Position = detobj.posVector; |
302 | detobj.posVector.Y, | ||
303 | detobj.posVector.Z); | ||
304 | d.Populate(myScriptEngine.World); | 300 | d.Populate(myScriptEngine.World); |
305 | det.Add(d); | 301 | det.Add(d); |
306 | myScriptEngine.PostObjectEvent(localID, new EventParams( | 302 | myScriptEngine.PostObjectEvent(localID, new EventParams( |
@@ -318,9 +314,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
318 | foreach (DetectedObject detobj in col.Colliders) | 314 | foreach (DetectedObject detobj in col.Colliders) |
319 | { | 315 | { |
320 | DetectParams d = new DetectParams(); | 316 | DetectParams d = new DetectParams(); |
321 | d.Position = new LSL_Types.Vector3(detobj.posVector.X, | 317 | d.Position = detobj.posVector; |
322 | detobj.posVector.Y, | ||
323 | detobj.posVector.Z); | ||
324 | d.Populate(myScriptEngine.World); | 318 | d.Populate(myScriptEngine.World); |
325 | det.Add(d); | 319 | det.Add(d); |
326 | myScriptEngine.PostObjectEvent(localID, new EventParams( | 320 | myScriptEngine.PostObjectEvent(localID, new EventParams( |
@@ -337,9 +331,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
337 | foreach (DetectedObject detobj in col.Colliders) | 331 | foreach (DetectedObject detobj in col.Colliders) |
338 | { | 332 | { |
339 | DetectParams d = new DetectParams(); | 333 | DetectParams d = new DetectParams(); |
340 | d.Position = new LSL_Types.Vector3(detobj.posVector.X, | 334 | d.Position = detobj.posVector; |
341 | detobj.posVector.Y, | ||
342 | detobj.posVector.Z); | ||
343 | d.Populate(myScriptEngine.World); | 335 | d.Populate(myScriptEngine.World); |
344 | det.Add(d); | 336 | det.Add(d); |
345 | myScriptEngine.PostObjectEvent(localID, new EventParams( | 337 | myScriptEngine.PostObjectEvent(localID, new EventParams( |
@@ -381,8 +373,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
381 | myScriptEngine.PostObjectEvent(localID, new EventParams( | 373 | myScriptEngine.PostObjectEvent(localID, new EventParams( |
382 | "at_target", new object[] { | 374 | "at_target", new object[] { |
383 | new LSL_Types.LSLInteger(handle), | 375 | new LSL_Types.LSLInteger(handle), |
384 | new LSL_Types.Vector3(targetpos.X,targetpos.Y,targetpos.Z), | 376 | new LSL_Types.Vector3(targetpos), |
385 | new LSL_Types.Vector3(atpos.X,atpos.Y,atpos.Z) }, | 377 | new LSL_Types.Vector3(atpos) }, |
386 | new DetectParams[0])); | 378 | new DetectParams[0])); |
387 | } | 379 | } |
388 | 380 | ||
@@ -399,8 +391,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
399 | myScriptEngine.PostObjectEvent(localID, new EventParams( | 391 | myScriptEngine.PostObjectEvent(localID, new EventParams( |
400 | "at_rot_target", new object[] { | 392 | "at_rot_target", new object[] { |
401 | new LSL_Types.LSLInteger(handle), | 393 | new LSL_Types.LSLInteger(handle), |
402 | new LSL_Types.Quaternion(targetrot.X,targetrot.Y,targetrot.Z,targetrot.W), | 394 | new LSL_Types.Quaternion(targetrot), |
403 | new LSL_Types.Quaternion(atrot.X,atrot.Y,atrot.Z,atrot.W) }, | 395 | new LSL_Types.Quaternion(atrot) }, |
404 | new DetectParams[0])); | 396 | new DetectParams[0])); |
405 | } | 397 | } |
406 | 398 | ||
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index f6cb7df..2d17977 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -656,7 +656,19 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
656 | if (m_Assemblies.ContainsKey(instance.AssetID)) | 656 | if (m_Assemblies.ContainsKey(instance.AssetID)) |
657 | { | 657 | { |
658 | string assembly = m_Assemblies[instance.AssetID]; | 658 | string assembly = m_Assemblies[instance.AssetID]; |
659 | instance.SaveState(assembly); | 659 | |
660 | try | ||
661 | { | ||
662 | instance.SaveState(assembly); | ||
663 | } | ||
664 | catch (Exception e) | ||
665 | { | ||
666 | m_log.Error( | ||
667 | string.Format( | ||
668 | "[XEngine]: Failed final state save for script {0}.{1}, item UUID {2}, prim UUID {3} in {4}. Exception ", | ||
669 | instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, World.Name) | ||
670 | , e); | ||
671 | } | ||
660 | } | 672 | } |
661 | 673 | ||
662 | // Clear the event queue and abort the instance thread | 674 | // Clear the event queue and abort the instance thread |
@@ -778,7 +790,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
778 | assembly = m_Assemblies[i.AssetID]; | 790 | assembly = m_Assemblies[i.AssetID]; |
779 | 791 | ||
780 | 792 | ||
781 | i.SaveState(assembly); | 793 | try |
794 | { | ||
795 | i.SaveState(assembly); | ||
796 | } | ||
797 | catch (Exception e) | ||
798 | { | ||
799 | m_log.Error( | ||
800 | string.Format( | ||
801 | "[XEngine]: Failed to save state of script {0}.{1}, item UUID {2}, prim UUID {3} in {4}. Exception ", | ||
802 | i.PrimName, i.ScriptName, i.ItemID, i.ObjectID, World.Name) | ||
803 | , e); | ||
804 | } | ||
782 | } | 805 | } |
783 | 806 | ||
784 | instances.Clear(); | 807 | instances.Clear(); |
@@ -1053,10 +1076,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1053 | return false; | 1076 | return false; |
1054 | } | 1077 | } |
1055 | 1078 | ||
1056 | UUID assetID = item.AssetID; | 1079 | m_log.DebugFormat( |
1080 | "[XEngine] Loading script {0}.{1}, item UUID {2}, prim UUID {3} @ {4}.{5}", | ||
1081 | part.ParentGroup.RootPart.Name, item.Name, itemID, part.UUID, | ||
1082 | part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName); | ||
1057 | 1083 | ||
1058 | //m_log.DebugFormat("[XEngine] Compiling script {0} ({1} on object {2})", | 1084 | UUID assetID = item.AssetID; |
1059 | // item.Name, itemID.ToString(), part.ParentGroup.RootPart.Name); | ||
1060 | 1085 | ||
1061 | ScenePresence presence = m_Scene.GetScenePresence(item.OwnerID); | 1086 | ScenePresence presence = m_Scene.GetScenePresence(item.OwnerID); |
1062 | 1087 | ||
@@ -1235,10 +1260,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1235 | item.Name, startParam, postOnRez, | 1260 | item.Name, startParam, postOnRez, |
1236 | stateSource, m_MaxScriptQueue); | 1261 | stateSource, m_MaxScriptQueue); |
1237 | 1262 | ||
1238 | m_log.DebugFormat( | 1263 | // m_log.DebugFormat( |
1239 | "[XEngine] Loaded script {0}.{1}, script UUID {2}, prim UUID {3} @ {4}.{5}", | 1264 | // "[XEngine] Loaded script {0}.{1}, script UUID {2}, prim UUID {3} @ {4}.{5}", |
1240 | part.ParentGroup.RootPart.Name, item.Name, assetID, part.UUID, | 1265 | // part.ParentGroup.RootPart.Name, item.Name, assetID, part.UUID, |
1241 | part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName); | 1266 | // part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName); |
1242 | 1267 | ||
1243 | if (presence != null) | 1268 | if (presence != null) |
1244 | { | 1269 | { |
@@ -1554,9 +1579,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1554 | else if (p[i] is string) | 1579 | else if (p[i] is string) |
1555 | lsl_p[i] = new LSL_Types.LSLString((string)p[i]); | 1580 | lsl_p[i] = new LSL_Types.LSLString((string)p[i]); |
1556 | else if (p[i] is Vector3) | 1581 | else if (p[i] is Vector3) |
1557 | lsl_p[i] = new LSL_Types.Vector3(((Vector3)p[i]).X, ((Vector3)p[i]).Y, ((Vector3)p[i]).Z); | 1582 | lsl_p[i] = new LSL_Types.Vector3((Vector3)p[i]); |
1558 | else if (p[i] is Quaternion) | 1583 | else if (p[i] is Quaternion) |
1559 | lsl_p[i] = new LSL_Types.Quaternion(((Quaternion)p[i]).X, ((Quaternion)p[i]).Y, ((Quaternion)p[i]).Z, ((Quaternion)p[i]).W); | 1584 | lsl_p[i] = new LSL_Types.Quaternion((Quaternion)p[i]); |
1560 | else if (p[i] is float) | 1585 | else if (p[i] is float) |
1561 | lsl_p[i] = new LSL_Types.LSLFloat((float)p[i]); | 1586 | lsl_p[i] = new LSL_Types.LSLFloat((float)p[i]); |
1562 | else | 1587 | else |
@@ -1580,9 +1605,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1580 | else if (p[i] is string) | 1605 | else if (p[i] is string) |
1581 | lsl_p[i] = new LSL_Types.LSLString((string)p[i]); | 1606 | lsl_p[i] = new LSL_Types.LSLString((string)p[i]); |
1582 | else if (p[i] is Vector3) | 1607 | else if (p[i] is Vector3) |
1583 | lsl_p[i] = new LSL_Types.Vector3(((Vector3)p[i]).X, ((Vector3)p[i]).Y, ((Vector3)p[i]).Z); | 1608 | lsl_p[i] = new LSL_Types.Vector3((Vector3)p[i]); |
1584 | else if (p[i] is Quaternion) | 1609 | else if (p[i] is Quaternion) |
1585 | lsl_p[i] = new LSL_Types.Quaternion(((Quaternion)p[i]).X, ((Quaternion)p[i]).Y, ((Quaternion)p[i]).Z, ((Quaternion)p[i]).W); | 1610 | lsl_p[i] = new LSL_Types.Quaternion((Quaternion)p[i]); |
1586 | else if (p[i] is float) | 1611 | else if (p[i] is float) |
1587 | lsl_p[i] = new LSL_Types.LSLFloat((float)p[i]); | 1612 | lsl_p[i] = new LSL_Types.LSLFloat((float)p[i]); |
1588 | else | 1613 | else |