aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
authorRevolution2010-01-10 20:20:00 -0600
committerMelanie2010-01-11 02:00:40 +0000
commita0859754c03324be9a4a2b9c9f26928e64cb5a6f (patch)
treede452818c3a8bae329760d3012e07c467479845b /OpenSim/Region/Framework
parentClean CRs from previous patch (diff)
downloadopensim-SC_OLD-a0859754c03324be9a4a2b9c9f26928e64cb5a6f.zip
opensim-SC_OLD-a0859754c03324be9a4a2b9c9f26928e64cb5a6f.tar.gz
opensim-SC_OLD-a0859754c03324be9a4a2b9c9f26928e64cb5a6f.tar.bz2
opensim-SC_OLD-a0859754c03324be9a4a2b9c9f26928e64cb5a6f.tar.xz
Adds llRotTarget and the events at_rot_target and not_at_rot_target.
Signed-off-by: Melanie <melanie@t-data.com>
Diffstat (limited to 'OpenSim/Region/Framework')
-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
3 files changed, 174 insertions, 5 deletions
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index 4dd6f32..76d5cb6 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
@@ -383,7 +391,9 @@ namespace OpenSim.Region.Framework.Scenes
383 391
384 private ScriptChangedEvent handlerScriptChangedEvent = null; //OnScriptChangedEvent; 392 private ScriptChangedEvent handlerScriptChangedEvent = null; //OnScriptChangedEvent;
385 private ScriptAtTargetEvent handlerScriptAtTargetEvent = null; 393 private ScriptAtTargetEvent handlerScriptAtTargetEvent = null;
386 private ScriptNotAtTargetEvent handlerScriptNotAtTargetEvent = null; 394 private ScriptNotAtTargetEvent handlerScriptNotAtTargetEvent = null;
395 private ScriptAtRotTargetEvent handlerScriptAtRotTargetEvent = null;
396 private ScriptNotAtRotTargetEvent handlerScriptNotAtRotTargetEvent = null;
387 private ClientMovement handlerClientMovement = null; //OnClientMovement; 397 private ClientMovement handlerClientMovement = null; //OnClientMovement;
388 private OnPermissionErrorDelegate handlerPermissionError = null; //OnPermissionError; 398 private OnPermissionErrorDelegate handlerPermissionError = null; //OnPermissionError;
389 private OnPluginConsoleDelegate handlerPluginConsole = null; //OnPluginConsole; 399 private OnPluginConsoleDelegate handlerPluginConsole = null; //OnPluginConsole;
@@ -849,6 +859,24 @@ namespace OpenSim.Region.Framework.Scenes
849 { 859 {
850 handlerScriptNotAtTargetEvent(localID); 860 handlerScriptNotAtTargetEvent(localID);
851 } 861 }
862 }
863
864 public void TriggerAtRotTargetEvent(uint localID, uint handle, Quaternion targetrot, Quaternion currentrot)
865 {
866 handlerScriptAtRotTargetEvent = OnScriptAtRotTargetEvent;
867 if (handlerScriptAtRotTargetEvent != null)
868 {
869 handlerScriptAtRotTargetEvent(localID, handle, targetrot, currentrot);
870 }
871 }
872
873 public void TriggerNotAtRotTargetEvent(uint localID)
874 {
875 handlerScriptNotAtRotTargetEvent = OnScriptNotAtRotTargetEvent;
876 if (handlerScriptNotAtRotTargetEvent != null)
877 {
878 handlerScriptNotAtRotTargetEvent(localID);
879 }
852 } 880 }
853 881
854 public void TriggerRequestChangeWaterHeight(float height) 882 public void TriggerRequestChangeWaterHeight(float height)
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 34d8b49..8050bf6 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();
@@ -165,10 +173,14 @@ namespace OpenSim.Region.Framework.Scenes
165 protected SceneObjectPart m_rootPart; 173 protected SceneObjectPart m_rootPart;
166 // private Dictionary<UUID, scriptEvents> m_scriptEvents = new Dictionary<UUID, scriptEvents>(); 174 // private Dictionary<UUID, scriptEvents> m_scriptEvents = new Dictionary<UUID, scriptEvents>();
167 175
168 private Dictionary<uint, scriptPosTarget> m_targets = new Dictionary<uint, scriptPosTarget>(); 176 private Dictionary<uint, scriptPosTarget> m_targets = new Dictionary<uint, scriptPosTarget>();
177 private Dictionary<uint, scriptRotTarget> m_rotTargets = new Dictionary<uint, scriptRotTarget>();
169 178
170 private bool m_scriptListens_atTarget = false; 179 private bool m_scriptListens_atTarget = false;
171 private bool m_scriptListens_notAtTarget = false; 180 private bool m_scriptListens_notAtTarget = false;
181
182 private bool m_scriptListens_atRotTarget = false;
183 private bool m_scriptListens_notAtRotTarget = false;
172 184
173 internal Dictionary<UUID, string> m_savedScriptState = null; 185 internal Dictionary<UUID, string> m_savedScriptState = null;
174 186
@@ -1261,6 +1273,15 @@ namespace OpenSim.Region.Framework.Scenes
1261 lock (m_targets) 1273 lock (m_targets)
1262 m_targets.Clear(); 1274 m_targets.Clear();
1263 m_scene.RemoveGroupTarget(this); 1275 m_scene.RemoveGroupTarget(this);
1276 }
1277 m_scriptListens_atRotTarget = ((aggregateScriptEvents & scriptEvents.at_rot_target) != 0);
1278 m_scriptListens_notAtRotTarget = ((aggregateScriptEvents & scriptEvents.not_at_rot_target) != 0);
1279
1280 if (!m_scriptListens_atRotTarget && !m_scriptListens_notAtRotTarget)
1281 {
1282 lock (m_rotTargets)
1283 m_rotTargets.Clear();
1284 m_scene.RemoveGroupTarget(this);
1264 } 1285 }
1265 1286
1266 ScheduleGroupForFullUpdate(); 1287 ScheduleGroupForFullUpdate();
@@ -3157,6 +3178,30 @@ namespace OpenSim.Region.Framework.Scenes
3157 } 3178 }
3158 3179
3159 } 3180 }
3181 }
3182 public int registerRotTargetWaypoint(Quaternion target, float tolerance)
3183 {
3184 scriptRotTarget waypoint = new scriptRotTarget();
3185 waypoint.targetRot = target;
3186 waypoint.tolerance = tolerance;
3187 uint handle = m_scene.AllocateLocalId();
3188 waypoint.handle = handle;
3189 lock (m_rotTargets)
3190 {
3191 m_rotTargets.Add(handle, waypoint);
3192 }
3193 m_scene.AddGroupTarget(this);
3194 return (int)handle;
3195 }
3196
3197 public void unregisterRotTargetWaypoint(int handle)
3198 {
3199 lock (m_targets)
3200 {
3201 m_rotTargets.Remove((uint)handle);
3202 if (m_targets.Count == 0)
3203 m_scene.RemoveGroupTarget(this);
3204 }
3160 } 3205 }
3161 3206
3162 public int registerTargetWaypoint(Vector3 target, float tolerance) 3207 public int registerTargetWaypoint(Vector3 target, float tolerance)
@@ -3263,6 +3308,85 @@ namespace OpenSim.Region.Framework.Scenes
3263 } 3308 }
3264 } 3309 }
3265 } 3310 }
3311 }
3312 if (m_scriptListens_atRotTarget || m_scriptListens_notAtRotTarget)
3313 {
3314 if (m_rotTargets.Count > 0)
3315 {
3316 bool at_Rottarget = false;
3317 Dictionary<uint, scriptRotTarget> atRotTargets = new Dictionary<uint, scriptRotTarget>();
3318 lock (m_rotTargets)
3319 {
3320 foreach (uint idx in m_rotTargets.Keys)
3321 {
3322 scriptRotTarget target = m_rotTargets[idx];
3323 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;
3324 if (angle < 0) angle = -angle;
3325 if (angle > Math.PI) angle = (Math.PI * 2 - angle);
3326 if (angle <= target.tolerance)
3327 {
3328 // trigger at_rot_target
3329 if (m_scriptListens_atRotTarget)
3330 {
3331 at_Rottarget = true;
3332 scriptRotTarget att = new scriptRotTarget();
3333 att.targetRot = target.targetRot;
3334 att.tolerance = target.tolerance;
3335 att.handle = target.handle;
3336 atRotTargets.Add(idx, att);
3337 }
3338 }
3339 }
3340 }
3341
3342 if (atRotTargets.Count > 0)
3343 {
3344 uint[] localids = new uint[0];
3345 lock (m_parts)
3346 {
3347 localids = new uint[m_parts.Count];
3348 int cntr = 0;
3349 foreach (SceneObjectPart part in m_parts.Values)
3350 {
3351 localids[cntr] = part.LocalId;
3352 cntr++;
3353 }
3354 }
3355
3356 for (int ctr = 0; ctr < localids.Length; ctr++)
3357 {
3358 foreach (uint target in atRotTargets.Keys)
3359 {
3360 scriptRotTarget att = atRotTargets[target];
3361 m_scene.EventManager.TriggerAtRotTargetEvent(
3362 localids[ctr], att.handle, att.targetRot, m_rootPart.RotationOffset);
3363 }
3364 }
3365
3366 return;
3367 }
3368
3369 if (m_scriptListens_notAtRotTarget && !at_Rottarget)
3370 {
3371 //trigger not_at_target
3372 uint[] localids = new uint[0];
3373 lock (m_parts)
3374 {
3375 localids = new uint[m_parts.Count];
3376 int cntr = 0;
3377 foreach (SceneObjectPart part in m_parts.Values)
3378 {
3379 localids[cntr] = part.LocalId;
3380 cntr++;
3381 }
3382 }
3383
3384 for (int ctr = 0; ctr < localids.Length; ctr++)
3385 {
3386 m_scene.EventManager.TriggerNotAtRotTargetEvent(localids[ctr]);
3387 }
3388 }
3389 }
3266 } 3390 }
3267 } 3391 }
3268 3392
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 73f79b3..177de47 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -4078,6 +4078,23 @@ namespace OpenSim.Region.Framework.Scenes
4078 { 4078 {
4079 m_parentGroup.unregisterTargetWaypoint(handle); 4079 m_parentGroup.unregisterTargetWaypoint(handle);
4080 } 4080 }
4081 }
4082
4083 public int registerRotTargetWaypoint(Quaternion target, float tolerance)
4084 {
4085 if (m_parentGroup != null)
4086 {
4087 return m_parentGroup.registerRotTargetWaypoint(target, tolerance);
4088 }
4089 return 0;
4090 }
4091
4092 public void unregisterRotTargetWaypoint(int handle)
4093 {
4094 if (m_parentGroup != null)
4095 {
4096 m_parentGroup.unregisterRotTargetWaypoint(handle);
4097 }
4081 } 4098 }
4082 4099
4083 public void SetCameraAtOffset(Vector3 v) 4100 public void SetCameraAtOffset(Vector3 v)