diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 248 |
1 files changed, 124 insertions, 124 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index bc16a93..768ceb5 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -56,7 +56,7 @@ 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 | at_rot_target = 16777216, |
61 | listen = 32768, | 61 | listen = 32768, |
62 | money = 65536, | 62 | money = 65536, |
@@ -80,13 +80,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
80 | public Vector3 targetPos; | 80 | public Vector3 targetPos; |
81 | public float tolerance; | 81 | public float tolerance; |
82 | public uint handle; | 82 | public uint handle; |
83 | } | 83 | } |
84 | 84 | ||
85 | struct scriptRotTarget | 85 | struct scriptRotTarget |
86 | { | 86 | { |
87 | public Quaternion targetRot; | 87 | public Quaternion targetRot; |
88 | public float tolerance; | 88 | public float tolerance; |
89 | public uint handle; | 89 | public uint handle; |
90 | } | 90 | } |
91 | 91 | ||
92 | public delegate void PrimCountTaintedDelegate(); | 92 | public delegate void PrimCountTaintedDelegate(); |
@@ -239,13 +239,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
239 | protected SceneObjectPart m_rootPart; | 239 | protected SceneObjectPart m_rootPart; |
240 | // private Dictionary<UUID, scriptEvents> m_scriptEvents = new Dictionary<UUID, scriptEvents>(); | 240 | // private Dictionary<UUID, scriptEvents> m_scriptEvents = new Dictionary<UUID, scriptEvents>(); |
241 | 241 | ||
242 | 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>(); | 243 | private Dictionary<uint, scriptRotTarget> m_rotTargets = new Dictionary<uint, scriptRotTarget>(); |
244 | 244 | ||
245 | private bool m_scriptListens_atTarget = false; | 245 | private bool m_scriptListens_atTarget = false; |
246 | private bool m_scriptListens_notAtTarget = false; | 246 | private bool m_scriptListens_notAtTarget = false; |
247 | 247 | ||
248 | private bool m_scriptListens_atRotTarget = false; | 248 | private bool m_scriptListens_atRotTarget = false; |
249 | private bool m_scriptListens_notAtRotTarget = false; | 249 | private bool m_scriptListens_notAtRotTarget = false; |
250 | 250 | ||
251 | internal Dictionary<UUID, string> m_savedScriptState = null; | 251 | internal Dictionary<UUID, string> m_savedScriptState = null; |
@@ -1378,15 +1378,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1378 | lock (m_targets) | 1378 | lock (m_targets) |
1379 | m_targets.Clear(); | 1379 | m_targets.Clear(); |
1380 | m_scene.RemoveGroupTarget(this); | 1380 | m_scene.RemoveGroupTarget(this); |
1381 | } | 1381 | } |
1382 | m_scriptListens_atRotTarget = ((aggregateScriptEvents & scriptEvents.at_rot_target) != 0); | 1382 | m_scriptListens_atRotTarget = ((aggregateScriptEvents & scriptEvents.at_rot_target) != 0); |
1383 | m_scriptListens_notAtRotTarget = ((aggregateScriptEvents & scriptEvents.not_at_rot_target) != 0); | 1383 | m_scriptListens_notAtRotTarget = ((aggregateScriptEvents & scriptEvents.not_at_rot_target) != 0); |
1384 | 1384 | ||
1385 | if (!m_scriptListens_atRotTarget && !m_scriptListens_notAtRotTarget) | 1385 | if (!m_scriptListens_atRotTarget && !m_scriptListens_notAtRotTarget) |
1386 | { | 1386 | { |
1387 | lock (m_rotTargets) | 1387 | lock (m_rotTargets) |
1388 | m_rotTargets.Clear(); | 1388 | m_rotTargets.Clear(); |
1389 | m_scene.RemoveGroupTarget(this); | 1389 | m_scene.RemoveGroupTarget(this); |
1390 | } | 1390 | } |
1391 | 1391 | ||
1392 | ScheduleGroupForFullUpdate(); | 1392 | ScheduleGroupForFullUpdate(); |
@@ -3334,30 +3334,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
3334 | } | 3334 | } |
3335 | 3335 | ||
3336 | } | 3336 | } |
3337 | } | 3337 | } |
3338 | public int registerRotTargetWaypoint(Quaternion target, float tolerance) | 3338 | public int registerRotTargetWaypoint(Quaternion target, float tolerance) |
3339 | { | 3339 | { |
3340 | scriptRotTarget waypoint = new scriptRotTarget(); | 3340 | scriptRotTarget waypoint = new scriptRotTarget(); |
3341 | waypoint.targetRot = target; | 3341 | waypoint.targetRot = target; |
3342 | waypoint.tolerance = tolerance; | 3342 | waypoint.tolerance = tolerance; |
3343 | uint handle = m_scene.AllocateLocalId(); | 3343 | uint handle = m_scene.AllocateLocalId(); |
3344 | waypoint.handle = handle; | 3344 | waypoint.handle = handle; |
3345 | lock (m_rotTargets) | 3345 | lock (m_rotTargets) |
3346 | { | 3346 | { |
3347 | m_rotTargets.Add(handle, waypoint); | 3347 | m_rotTargets.Add(handle, waypoint); |
3348 | } | 3348 | } |
3349 | m_scene.AddGroupTarget(this); | 3349 | m_scene.AddGroupTarget(this); |
3350 | return (int)handle; | 3350 | return (int)handle; |
3351 | } | 3351 | } |
3352 | 3352 | ||
3353 | public void unregisterRotTargetWaypoint(int handle) | 3353 | public void unregisterRotTargetWaypoint(int handle) |
3354 | { | 3354 | { |
3355 | lock (m_targets) | 3355 | lock (m_targets) |
3356 | { | 3356 | { |
3357 | m_rotTargets.Remove((uint)handle); | 3357 | m_rotTargets.Remove((uint)handle); |
3358 | if (m_targets.Count == 0) | 3358 | if (m_targets.Count == 0) |
3359 | m_scene.RemoveGroupTarget(this); | 3359 | m_scene.RemoveGroupTarget(this); |
3360 | } | 3360 | } |
3361 | } | 3361 | } |
3362 | 3362 | ||
3363 | public int registerTargetWaypoint(Vector3 target, float tolerance) | 3363 | public int registerTargetWaypoint(Vector3 target, float tolerance) |
@@ -3466,85 +3466,85 @@ namespace OpenSim.Region.Framework.Scenes | |||
3466 | } | 3466 | } |
3467 | } | 3467 | } |
3468 | } | 3468 | } |
3469 | } | 3469 | } |
3470 | if (m_scriptListens_atRotTarget || m_scriptListens_notAtRotTarget) | 3470 | if (m_scriptListens_atRotTarget || m_scriptListens_notAtRotTarget) |
3471 | { | 3471 | { |
3472 | if (m_rotTargets.Count > 0) | 3472 | if (m_rotTargets.Count > 0) |
3473 | { | 3473 | { |
3474 | bool at_Rottarget = false; | 3474 | bool at_Rottarget = false; |
3475 | Dictionary<uint, scriptRotTarget> atRotTargets = new Dictionary<uint, scriptRotTarget>(); | 3475 | Dictionary<uint, scriptRotTarget> atRotTargets = new Dictionary<uint, scriptRotTarget>(); |
3476 | lock (m_rotTargets) | 3476 | lock (m_rotTargets) |
3477 | { | 3477 | { |
3478 | foreach (uint idx in m_rotTargets.Keys) | 3478 | foreach (uint idx in m_rotTargets.Keys) |
3479 | { | 3479 | { |
3480 | scriptRotTarget target = m_rotTargets[idx]; | 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; | 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; | 3482 | if (angle < 0) angle = -angle; |
3483 | if (angle > Math.PI) angle = (Math.PI * 2 - angle); | 3483 | if (angle > Math.PI) angle = (Math.PI * 2 - angle); |
3484 | if (angle <= target.tolerance) | 3484 | if (angle <= target.tolerance) |
3485 | { | 3485 | { |
3486 | // trigger at_rot_target | 3486 | // trigger at_rot_target |
3487 | if (m_scriptListens_atRotTarget) | 3487 | if (m_scriptListens_atRotTarget) |
3488 | { | 3488 | { |
3489 | at_Rottarget = true; | 3489 | at_Rottarget = true; |
3490 | scriptRotTarget att = new scriptRotTarget(); | 3490 | scriptRotTarget att = new scriptRotTarget(); |
3491 | att.targetRot = target.targetRot; | 3491 | att.targetRot = target.targetRot; |
3492 | att.tolerance = target.tolerance; | 3492 | att.tolerance = target.tolerance; |
3493 | att.handle = target.handle; | 3493 | att.handle = target.handle; |
3494 | atRotTargets.Add(idx, att); | 3494 | atRotTargets.Add(idx, att); |
3495 | } | 3495 | } |
3496 | } | 3496 | } |
3497 | } | 3497 | } |
3498 | } | 3498 | } |
3499 | 3499 | ||
3500 | if (atRotTargets.Count > 0) | 3500 | if (atRotTargets.Count > 0) |
3501 | { | 3501 | { |
3502 | uint[] localids = new uint[0]; | 3502 | uint[] localids = new uint[0]; |
3503 | lock (m_parts) | 3503 | lock (m_parts) |
3504 | { | 3504 | { |
3505 | localids = new uint[m_parts.Count]; | 3505 | localids = new uint[m_parts.Count]; |
3506 | int cntr = 0; | 3506 | int cntr = 0; |
3507 | foreach (SceneObjectPart part in m_parts.Values) | 3507 | foreach (SceneObjectPart part in m_parts.Values) |
3508 | { | 3508 | { |
3509 | localids[cntr] = part.LocalId; | 3509 | localids[cntr] = part.LocalId; |
3510 | cntr++; | 3510 | cntr++; |
3511 | } | 3511 | } |
3512 | } | 3512 | } |
3513 | 3513 | ||
3514 | for (int ctr = 0; ctr < localids.Length; ctr++) | 3514 | for (int ctr = 0; ctr < localids.Length; ctr++) |
3515 | { | 3515 | { |
3516 | foreach (uint target in atRotTargets.Keys) | 3516 | foreach (uint target in atRotTargets.Keys) |
3517 | { | 3517 | { |
3518 | scriptRotTarget att = atRotTargets[target]; | 3518 | scriptRotTarget att = atRotTargets[target]; |
3519 | m_scene.EventManager.TriggerAtRotTargetEvent( | 3519 | m_scene.EventManager.TriggerAtRotTargetEvent( |
3520 | localids[ctr], att.handle, att.targetRot, m_rootPart.RotationOffset); | 3520 | localids[ctr], att.handle, att.targetRot, m_rootPart.RotationOffset); |
3521 | } | 3521 | } |
3522 | } | 3522 | } |
3523 | 3523 | ||
3524 | return; | 3524 | return; |
3525 | } | 3525 | } |
3526 | 3526 | ||
3527 | if (m_scriptListens_notAtRotTarget && !at_Rottarget) | 3527 | if (m_scriptListens_notAtRotTarget && !at_Rottarget) |
3528 | { | 3528 | { |
3529 | //trigger not_at_target | 3529 | //trigger not_at_target |
3530 | uint[] localids = new uint[0]; | 3530 | uint[] localids = new uint[0]; |
3531 | lock (m_parts) | 3531 | lock (m_parts) |
3532 | { | 3532 | { |
3533 | localids = new uint[m_parts.Count]; | 3533 | localids = new uint[m_parts.Count]; |
3534 | int cntr = 0; | 3534 | int cntr = 0; |
3535 | foreach (SceneObjectPart part in m_parts.Values) | 3535 | foreach (SceneObjectPart part in m_parts.Values) |
3536 | { | 3536 | { |
3537 | localids[cntr] = part.LocalId; | 3537 | localids[cntr] = part.LocalId; |
3538 | cntr++; | 3538 | cntr++; |
3539 | } | 3539 | } |
3540 | } | 3540 | } |
3541 | 3541 | ||
3542 | for (int ctr = 0; ctr < localids.Length; ctr++) | 3542 | for (int ctr = 0; ctr < localids.Length; ctr++) |
3543 | { | 3543 | { |
3544 | m_scene.EventManager.TriggerNotAtRotTargetEvent(localids[ctr]); | 3544 | m_scene.EventManager.TriggerNotAtRotTargetEvent(localids[ctr]); |
3545 | } | 3545 | } |
3546 | } | 3546 | } |
3547 | } | 3547 | } |
3548 | } | 3548 | } |
3549 | } | 3549 | } |
3550 | 3550 | ||