aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs130
1 files changed, 127 insertions, 3 deletions
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