aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/Framework/Scenes/EventManager.cs32
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs130
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs17
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs9
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs7
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/EventManager.cs22
6 files changed, 196 insertions, 21 deletions
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index 3e49691..f1d8cb4 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -181,7 +181,15 @@ namespace OpenSim.Region.Framework.Scenes
181 181
182 public delegate void ScriptNotAtTargetEvent(uint localID); 182 public delegate void ScriptNotAtTargetEvent(uint localID);
183 183
184 public event ScriptNotAtTargetEvent OnScriptNotAtTargetEvent; 184 public event ScriptNotAtTargetEvent OnScriptNotAtTargetEvent;
185
186 public delegate void ScriptAtRotTargetEvent(uint localID, uint handle, Quaternion targetrot, Quaternion atrot);
187
188 public event ScriptAtRotTargetEvent OnScriptAtRotTargetEvent;
189
190 public delegate void ScriptNotAtRotTargetEvent(uint localID);
191
192 public event ScriptNotAtRotTargetEvent OnScriptNotAtRotTargetEvent;
185 193
186 public delegate void ScriptColliding(uint localID, ColliderArgs colliders); 194 public delegate void ScriptColliding(uint localID, ColliderArgs colliders);
187 195
@@ -387,7 +395,9 @@ namespace OpenSim.Region.Framework.Scenes
387 395
388 private ScriptChangedEvent handlerScriptChangedEvent = null; //OnScriptChangedEvent; 396 private ScriptChangedEvent handlerScriptChangedEvent = null; //OnScriptChangedEvent;
389 private ScriptAtTargetEvent handlerScriptAtTargetEvent = null; 397 private ScriptAtTargetEvent handlerScriptAtTargetEvent = null;
390 private ScriptNotAtTargetEvent handlerScriptNotAtTargetEvent = null; 398 private ScriptNotAtTargetEvent handlerScriptNotAtTargetEvent = null;
399 private ScriptAtRotTargetEvent handlerScriptAtRotTargetEvent = null;
400 private ScriptNotAtRotTargetEvent handlerScriptNotAtRotTargetEvent = null;
391 private ClientMovement handlerClientMovement = null; //OnClientMovement; 401 private ClientMovement handlerClientMovement = null; //OnClientMovement;
392 private OnPermissionErrorDelegate handlerPermissionError = null; //OnPermissionError; 402 private OnPermissionErrorDelegate handlerPermissionError = null; //OnPermissionError;
393 private OnPluginConsoleDelegate handlerPluginConsole = null; //OnPluginConsole; 403 private OnPluginConsoleDelegate handlerPluginConsole = null; //OnPluginConsole;
@@ -873,6 +883,24 @@ namespace OpenSim.Region.Framework.Scenes
873 { 883 {
874 handlerScriptNotAtTargetEvent(localID); 884 handlerScriptNotAtTargetEvent(localID);
875 } 885 }
886 }
887
888 public void TriggerAtRotTargetEvent(uint localID, uint handle, Quaternion targetrot, Quaternion currentrot)
889 {
890 handlerScriptAtRotTargetEvent = OnScriptAtRotTargetEvent;
891 if (handlerScriptAtRotTargetEvent != null)
892 {
893 handlerScriptAtRotTargetEvent(localID, handle, targetrot, currentrot);
894 }
895 }
896
897 public void TriggerNotAtRotTargetEvent(uint localID)
898 {
899 handlerScriptNotAtRotTargetEvent = OnScriptNotAtRotTargetEvent;
900 if (handlerScriptNotAtRotTargetEvent != null)
901 {
902 handlerScriptNotAtRotTargetEvent(localID);
903 }
876 } 904 }
877 905
878 public void TriggerRequestChangeWaterHeight(float height) 906 public void TriggerRequestChangeWaterHeight(float height)
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index e63e8d9..bc16a93 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -56,7 +56,8 @@ namespace OpenSim.Region.Framework.Scenes
56 land_collision = 2048, 56 land_collision = 2048,
57 land_collision_end = 4096, 57 land_collision_end = 4096,
58 land_collision_start = 8192, 58 land_collision_start = 8192,
59 at_target = 16384, 59 at_target = 16384,
60 at_rot_target = 16777216,
60 listen = 32768, 61 listen = 32768,
61 money = 65536, 62 money = 65536,
62 moving_end = 131072, 63 moving_end = 131072,
@@ -79,6 +80,13 @@ namespace OpenSim.Region.Framework.Scenes
79 public Vector3 targetPos; 80 public Vector3 targetPos;
80 public float tolerance; 81 public float tolerance;
81 public uint handle; 82 public uint handle;
83 }
84
85 struct scriptRotTarget
86 {
87 public Quaternion targetRot;
88 public float tolerance;
89 public uint handle;
82 } 90 }
83 91
84 public delegate void PrimCountTaintedDelegate(); 92 public delegate void PrimCountTaintedDelegate();
@@ -231,10 +239,14 @@ namespace OpenSim.Region.Framework.Scenes
231 protected SceneObjectPart m_rootPart; 239 protected SceneObjectPart m_rootPart;
232 // private Dictionary<UUID, scriptEvents> m_scriptEvents = new Dictionary<UUID, scriptEvents>(); 240 // private Dictionary<UUID, scriptEvents> m_scriptEvents = new Dictionary<UUID, scriptEvents>();
233 241
234 private Dictionary<uint, scriptPosTarget> m_targets = new Dictionary<uint, scriptPosTarget>(); 242 private Dictionary<uint, scriptPosTarget> m_targets = new Dictionary<uint, scriptPosTarget>();
243 private Dictionary<uint, scriptRotTarget> m_rotTargets = new Dictionary<uint, scriptRotTarget>();
235 244
236 private bool m_scriptListens_atTarget = false; 245 private bool m_scriptListens_atTarget = false;
237 private bool m_scriptListens_notAtTarget = false; 246 private bool m_scriptListens_notAtTarget = false;
247
248 private bool m_scriptListens_atRotTarget = false;
249 private bool m_scriptListens_notAtRotTarget = false;
238 250
239 internal Dictionary<UUID, string> m_savedScriptState = null; 251 internal Dictionary<UUID, string> m_savedScriptState = null;
240 252
@@ -1366,6 +1378,15 @@ namespace OpenSim.Region.Framework.Scenes
1366 lock (m_targets) 1378 lock (m_targets)
1367 m_targets.Clear(); 1379 m_targets.Clear();
1368 m_scene.RemoveGroupTarget(this); 1380 m_scene.RemoveGroupTarget(this);
1381 }
1382 m_scriptListens_atRotTarget = ((aggregateScriptEvents & scriptEvents.at_rot_target) != 0);
1383 m_scriptListens_notAtRotTarget = ((aggregateScriptEvents & scriptEvents.not_at_rot_target) != 0);
1384
1385 if (!m_scriptListens_atRotTarget && !m_scriptListens_notAtRotTarget)
1386 {
1387 lock (m_rotTargets)
1388 m_rotTargets.Clear();
1389 m_scene.RemoveGroupTarget(this);
1369 } 1390 }
1370 1391
1371 ScheduleGroupForFullUpdate(); 1392 ScheduleGroupForFullUpdate();
@@ -3313,6 +3334,30 @@ namespace OpenSim.Region.Framework.Scenes
3313 } 3334 }
3314 3335
3315 } 3336 }
3337 }
3338 public int registerRotTargetWaypoint(Quaternion target, float tolerance)
3339 {
3340 scriptRotTarget waypoint = new scriptRotTarget();
3341 waypoint.targetRot = target;
3342 waypoint.tolerance = tolerance;
3343 uint handle = m_scene.AllocateLocalId();
3344 waypoint.handle = handle;
3345 lock (m_rotTargets)
3346 {
3347 m_rotTargets.Add(handle, waypoint);
3348 }
3349 m_scene.AddGroupTarget(this);
3350 return (int)handle;
3351 }
3352
3353 public void unregisterRotTargetWaypoint(int handle)
3354 {
3355 lock (m_targets)
3356 {
3357 m_rotTargets.Remove((uint)handle);
3358 if (m_targets.Count == 0)
3359 m_scene.RemoveGroupTarget(this);
3360 }
3316 } 3361 }
3317 3362
3318 public int registerTargetWaypoint(Vector3 target, float tolerance) 3363 public int registerTargetWaypoint(Vector3 target, float tolerance)
@@ -3421,6 +3466,85 @@ namespace OpenSim.Region.Framework.Scenes
3421 } 3466 }
3422 } 3467 }
3423 } 3468 }
3469 }
3470 if (m_scriptListens_atRotTarget || m_scriptListens_notAtRotTarget)
3471 {
3472 if (m_rotTargets.Count > 0)
3473 {
3474 bool at_Rottarget = false;
3475 Dictionary<uint, scriptRotTarget> atRotTargets = new Dictionary<uint, scriptRotTarget>();
3476 lock (m_rotTargets)
3477 {
3478 foreach (uint idx in m_rotTargets.Keys)
3479 {
3480 scriptRotTarget target = m_rotTargets[idx];
3481 double angle = Math.Acos(target.targetRot.X * m_rootPart.RotationOffset.X + target.targetRot.Y * m_rootPart.RotationOffset.Y + target.targetRot.Z * m_rootPart.RotationOffset.Z + target.targetRot.W * m_rootPart.RotationOffset.W) * 2;
3482 if (angle < 0) angle = -angle;
3483 if (angle > Math.PI) angle = (Math.PI * 2 - angle);
3484 if (angle <= target.tolerance)
3485 {
3486 // trigger at_rot_target
3487 if (m_scriptListens_atRotTarget)
3488 {
3489 at_Rottarget = true;
3490 scriptRotTarget att = new scriptRotTarget();
3491 att.targetRot = target.targetRot;
3492 att.tolerance = target.tolerance;
3493 att.handle = target.handle;
3494 atRotTargets.Add(idx, att);
3495 }
3496 }
3497 }
3498 }
3499
3500 if (atRotTargets.Count > 0)
3501 {
3502 uint[] localids = new uint[0];
3503 lock (m_parts)
3504 {
3505 localids = new uint[m_parts.Count];
3506 int cntr = 0;
3507 foreach (SceneObjectPart part in m_parts.Values)
3508 {
3509 localids[cntr] = part.LocalId;
3510 cntr++;
3511 }
3512 }
3513
3514 for (int ctr = 0; ctr < localids.Length; ctr++)
3515 {
3516 foreach (uint target in atRotTargets.Keys)
3517 {
3518 scriptRotTarget att = atRotTargets[target];
3519 m_scene.EventManager.TriggerAtRotTargetEvent(
3520 localids[ctr], att.handle, att.targetRot, m_rootPart.RotationOffset);
3521 }
3522 }
3523
3524 return;
3525 }
3526
3527 if (m_scriptListens_notAtRotTarget && !at_Rottarget)
3528 {
3529 //trigger not_at_target
3530 uint[] localids = new uint[0];
3531 lock (m_parts)
3532 {
3533 localids = new uint[m_parts.Count];
3534 int cntr = 0;
3535 foreach (SceneObjectPart part in m_parts.Values)
3536 {
3537 localids[cntr] = part.LocalId;
3538 cntr++;
3539 }
3540 }
3541
3542 for (int ctr = 0; ctr < localids.Length; ctr++)
3543 {
3544 m_scene.EventManager.TriggerNotAtRotTargetEvent(localids[ctr]);
3545 }
3546 }
3547 }
3424 } 3548 }
3425 } 3549 }
3426 3550
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 7906138..680a544 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -4089,6 +4089,23 @@ namespace OpenSim.Region.Framework.Scenes
4089 { 4089 {
4090 m_parentGroup.unregisterTargetWaypoint(handle); 4090 m_parentGroup.unregisterTargetWaypoint(handle);
4091 } 4091 }
4092 }
4093
4094 public int registerRotTargetWaypoint(Quaternion target, float tolerance)
4095 {
4096 if (m_parentGroup != null)
4097 {
4098 return m_parentGroup.registerRotTargetWaypoint(target, tolerance);
4099 }
4100 return 0;
4101 }
4102
4103 public void unregisterRotTargetWaypoint(int handle)
4104 {
4105 if (m_parentGroup != null)
4106 {
4107 m_parentGroup.unregisterRotTargetWaypoint(handle);
4108 }
4092 } 4109 }
4093 4110
4094 public void SetCameraAtOffset(Vector3 v) 4111 public void SetCameraAtOffset(Vector3 v)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 1469e7e..92e33b8 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2214,15 +2214,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2214 2214
2215 public LSL_Integer llRotTarget(LSL_Rotation rot, double error) 2215 public LSL_Integer llRotTarget(LSL_Rotation rot, double error)
2216 { 2216 {
2217 m_host.AddScriptLPS(1); 2217 m_host.AddScriptLPS(1);
2218 NotImplemented("llRotTarget"); 2218 return m_host.registerRotTargetWaypoint(new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s), (float)error);
2219 return 0;
2220 } 2219 }
2221 2220
2222 public void llRotTargetRemove(int number) 2221 public void llRotTargetRemove(int number)
2223 { 2222 {
2224 m_host.AddScriptLPS(1); 2223 m_host.AddScriptLPS(1);
2225 NotImplemented("llRotTargetRemove"); 2224 m_host.unregisterRotTargetWaypoint(number);
2226 } 2225 }
2227 2226
2228 public void llMoveToTarget(LSL_Vector target, double tau) 2227 public void llMoveToTarget(LSL_Vector target, double tau)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs
index 15e0408..3456a3c 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs
@@ -62,7 +62,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
62 land_collision = 2048, 62 land_collision = 2048,
63 land_collision_end = 4096, 63 land_collision_end = 4096,
64 land_collision_start = 8192, 64 land_collision_start = 8192,
65 at_target = 16384, 65 at_target = 16384,
66 at_rot_target = 16777216,
66 listen = 32768, 67 listen = 32768,
67 money = 65536, 68 money = 65536,
68 moving_end = 131072, 69 moving_end = 131072,
@@ -204,8 +205,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
204 return; 205 return;
205 } 206 }
206 207
207 m_eventFlagsMap.Add("attach", scriptEvents.attach); 208 m_eventFlagsMap.Add("attach", scriptEvents.attach);
208 // m_eventFlagsMap.Add("at_rot_target",(long)scriptEvents.at_rot_target); 209 m_eventFlagsMap.Add("at_rot_target", scriptEvents.at_rot_target);
209 m_eventFlagsMap.Add("at_target", scriptEvents.at_target); 210 m_eventFlagsMap.Add("at_target", scriptEvents.at_target);
210 // m_eventFlagsMap.Add("changed",(long)scriptEvents.changed); 211 // m_eventFlagsMap.Add("changed",(long)scriptEvents.changed);
211 m_eventFlagsMap.Add("collision", scriptEvents.collision); 212 m_eventFlagsMap.Add("collision", scriptEvents.collision);
diff --git a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
index b2eab45..ce22ba5 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
@@ -58,7 +58,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
58 myScriptEngine.World.EventManager.OnObjectDeGrab += touch_end; 58 myScriptEngine.World.EventManager.OnObjectDeGrab += touch_end;
59 myScriptEngine.World.EventManager.OnScriptChangedEvent += changed; 59 myScriptEngine.World.EventManager.OnScriptChangedEvent += changed;
60 myScriptEngine.World.EventManager.OnScriptAtTargetEvent += at_target; 60 myScriptEngine.World.EventManager.OnScriptAtTargetEvent += at_target;
61 myScriptEngine.World.EventManager.OnScriptNotAtTargetEvent += not_at_target; 61 myScriptEngine.World.EventManager.OnScriptNotAtTargetEvent += not_at_target;
62 myScriptEngine.World.EventManager.OnScriptAtRotTargetEvent += at_rot_target;
63 myScriptEngine.World.EventManager.OnScriptNotAtRotTargetEvent += not_at_rot_target;
62 myScriptEngine.World.EventManager.OnScriptControlEvent += control; 64 myScriptEngine.World.EventManager.OnScriptControlEvent += control;
63 myScriptEngine.World.EventManager.OnScriptColliderStart += collision_start; 65 myScriptEngine.World.EventManager.OnScriptColliderStart += collision_start;
64 myScriptEngine.World.EventManager.OnScriptColliding += collision; 66 myScriptEngine.World.EventManager.OnScriptColliding += collision;
@@ -388,16 +390,20 @@ namespace OpenSim.Region.ScriptEngine.XEngine
388 myScriptEngine.PostObjectEvent(localID, new EventParams( 390 myScriptEngine.PostObjectEvent(localID, new EventParams(
389 "not_at_target",new object[0], 391 "not_at_target",new object[0],
390 new DetectParams[0])); 392 new DetectParams[0]));
391 } 393 }
392 394
393 public void at_rot_target(uint localID, UUID itemID) 395 public void at_rot_target(uint localID, uint handle, Quaternion targetrot,
394 { 396 Quaternion atrot)
395 myScriptEngine.PostObjectEvent(localID, new EventParams( 397 {
396 "at_rot_target",new object[0], 398 myScriptEngine.PostObjectEvent(localID, new EventParams(
399 "at_rot_target", new object[] {
400 new LSL_Types.LSLInteger(handle),
401 new LSL_Types.Quaternion(targetrot.X,targetrot.Y,targetrot.Z,targetrot.W),
402 new LSL_Types.Quaternion(atrot.X,atrot.Y,atrot.Z,atrot.W) },
397 new DetectParams[0])); 403 new DetectParams[0]));
398 } 404 }
399 405
400 public void not_at_rot_target(uint localID, UUID itemID) 406 public void not_at_rot_target(uint localID)
401 { 407 {
402 myScriptEngine.PostObjectEvent(localID, new EventParams( 408 myScriptEngine.PostObjectEvent(localID, new EventParams(
403 "not_at_rot_target",new object[0], 409 "not_at_rot_target",new object[0],