aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorRevolution2010-01-10 20:20:00 -0600
committerMelanie2010-01-11 02:00:40 +0000
commita0859754c03324be9a4a2b9c9f26928e64cb5a6f (patch)
treede452818c3a8bae329760d3012e07c467479845b
parentClean CRs from previous patch (diff)
downloadopensim-SC-a0859754c03324be9a4a2b9c9f26928e64cb5a6f.zip
opensim-SC-a0859754c03324be9a4a2b9c9f26928e64cb5a6f.tar.gz
opensim-SC-a0859754c03324be9a4a2b9c9f26928e64cb5a6f.tar.bz2
opensim-SC-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 '')
-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 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)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 39b597e..856f8b6 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2108,15 +2108,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2108 2108
2109 public LSL_Integer llRotTarget(LSL_Rotation rot, double error) 2109 public LSL_Integer llRotTarget(LSL_Rotation rot, double error)
2110 { 2110 {
2111 m_host.AddScriptLPS(1); 2111 m_host.AddScriptLPS(1);
2112 NotImplemented("llRotTarget"); 2112 return m_host.registerRotTargetWaypoint(new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s), (float)error);
2113 return 0;
2114 } 2113 }
2115 2114
2116 public void llRotTargetRemove(int number) 2115 public void llRotTargetRemove(int number)
2117 { 2116 {
2118 m_host.AddScriptLPS(1); 2117 m_host.AddScriptLPS(1);
2119 NotImplemented("llRotTargetRemove"); 2118 m_host.unregisterRotTargetWaypoint(number);
2120 } 2119 }
2121 2120
2122 public void llMoveToTarget(LSL_Vector target, double tau) 2121 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 7f67599..fb86850 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Executor.cs
@@ -61,7 +61,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
61 land_collision = 2048, 61 land_collision = 2048,
62 land_collision_end = 4096, 62 land_collision_end = 4096,
63 land_collision_start = 8192, 63 land_collision_start = 8192,
64 at_target = 16384, 64 at_target = 16384,
65 at_rot_target = 16777216,
65 listen = 32768, 66 listen = 32768,
66 money = 65536, 67 money = 65536,
67 moving_end = 131072, 68 moving_end = 131072,
@@ -202,8 +203,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
202 return; 203 return;
203 } 204 }
204 205
205 m_eventFlagsMap.Add("attach", scriptEvents.attach); 206 m_eventFlagsMap.Add("attach", scriptEvents.attach);
206 // m_eventFlagsMap.Add("at_rot_target",(long)scriptEvents.at_rot_target); 207 m_eventFlagsMap.Add("at_rot_target", scriptEvents.at_rot_target);
207 m_eventFlagsMap.Add("at_target", scriptEvents.at_target); 208 m_eventFlagsMap.Add("at_target", scriptEvents.at_target);
208 // m_eventFlagsMap.Add("changed",(long)scriptEvents.changed); 209 // m_eventFlagsMap.Add("changed",(long)scriptEvents.changed);
209 m_eventFlagsMap.Add("collision", scriptEvents.collision); 210 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],