diff options
author | Melanie | 2010-01-11 02:01:23 +0000 |
---|---|---|
committer | Melanie | 2010-01-11 02:01:23 +0000 |
commit | 0ae861d7d7055e8765bcc2ff6c592a65a5d6510d (patch) | |
tree | d3b9c168f3c78fdf5ae9ec19684f4a460bdc5368 /OpenSim/Region/Framework | |
parent | Merge branch 'master' into careminster (diff) | |
parent | Adds llRotTarget and the events at_rot_target and not_at_rot_target. (diff) | |
download | opensim-SC_OLD-0ae861d7d7055e8765bcc2ff6c592a65a5d6510d.zip opensim-SC_OLD-0ae861d7d7055e8765bcc2ff6c592a65a5d6510d.tar.gz opensim-SC_OLD-0ae861d7d7055e8765bcc2ff6c592a65a5d6510d.tar.bz2 opensim-SC_OLD-0ae861d7d7055e8765bcc2ff6c592a65a5d6510d.tar.xz |
Merge branch 'master' into careminster
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/EventManager.cs | 32 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 130 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 17 |
3 files changed, 174 insertions, 5 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) |