diff options
author | Teravus Ovares | 2008-04-25 01:00:55 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-04-25 01:00:55 +0000 |
commit | 9468917b5f6ba6556bd9605e88227ea79e43d94e (patch) | |
tree | 7e175b228a221dfcf2f16a2d86a5f3f50f0b2a1e /OpenSim/Region/Environment/Scenes | |
parent | * Tuned the llMove2Target PID controller to be more reasonable and not oversh... (diff) | |
download | opensim-SC_OLD-9468917b5f6ba6556bd9605e88227ea79e43d94e.zip opensim-SC_OLD-9468917b5f6ba6556bd9605e88227ea79e43d94e.tar.gz opensim-SC_OLD-9468917b5f6ba6556bd9605e88227ea79e43d94e.tar.bz2 opensim-SC_OLD-9468917b5f6ba6556bd9605e88227ea79e43d94e.tar.xz |
* Implements llTarget, llTargetRemove, at_target(), not_at_target()
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.cs | 11 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneEvents.cs | 30 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs | 152 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneObjectPart.cs | 16 |
4 files changed, 204 insertions, 5 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 21c8991..ae914b3 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -2772,6 +2772,17 @@ namespace OpenSim.Region.Environment.Scenes | |||
2772 | m_eventManager.TriggerOnScriptChangedEvent(localID, change); | 2772 | m_eventManager.TriggerOnScriptChangedEvent(localID, change); |
2773 | } | 2773 | } |
2774 | 2774 | ||
2775 | public void TriggerAtTargetEvent(uint localID, uint handle, LLVector3 targetpos, LLVector3 currentpos) | ||
2776 | { | ||
2777 | |||
2778 | m_eventManager.TriggerAtTargetEvent(localID, handle, targetpos, currentpos); | ||
2779 | } | ||
2780 | |||
2781 | public void TriggerNotAtTargetEvent(uint localID) | ||
2782 | { | ||
2783 | m_eventManager.TriggerNotAtTargetEvent(localID); | ||
2784 | } | ||
2785 | |||
2775 | private bool scriptDanger(SceneObjectPart part,LLVector3 pos) | 2786 | private bool scriptDanger(SceneObjectPart part,LLVector3 pos) |
2776 | { | 2787 | { |
2777 | ILandObject parcel = LandChannel.getLandObject(pos.X, pos.Y); | 2788 | ILandObject parcel = LandChannel.getLandObject(pos.X, pos.Y); |
diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs index c9c0ad6..74554c3 100644 --- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs +++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs | |||
@@ -132,9 +132,17 @@ namespace OpenSim.Region.Environment.Scenes | |||
132 | public event ClientClosed OnClientClosed; | 132 | public event ClientClosed OnClientClosed; |
133 | 133 | ||
134 | public delegate void ScriptChangedEvent(uint localID, uint change); | 134 | public delegate void ScriptChangedEvent(uint localID, uint change); |
135 | 135 | ||
136 | public event ScriptChangedEvent OnScriptChangedEvent; | 136 | public event ScriptChangedEvent OnScriptChangedEvent; |
137 | 137 | ||
138 | public delegate void ScriptAtTargetEvent(uint localID, uint handle, LLVector3 targetpos, LLVector3 atpos); | ||
139 | |||
140 | public event ScriptAtTargetEvent OnScriptAtTargetEvent; | ||
141 | |||
142 | public delegate void ScriptNotAtTargetEvent(uint localID); | ||
143 | |||
144 | public event ScriptNotAtTargetEvent OnScriptNotAtTargetEvent; | ||
145 | |||
138 | public event OnNewPresenceDelegate OnMakeChildAgent; | 146 | public event OnNewPresenceDelegate OnMakeChildAgent; |
139 | 147 | ||
140 | public delegate void NewInventoryItemUploadComplete(LLUUID avatarID, LLUUID assetID, string name, int userlevel); | 148 | public delegate void NewInventoryItemUploadComplete(LLUUID avatarID, LLUUID assetID, string name, int userlevel); |
@@ -224,6 +232,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
224 | /* Designated Event Deletage Instances */ | 232 | /* Designated Event Deletage Instances */ |
225 | 233 | ||
226 | private ScriptChangedEvent handlerScriptChangedEvent = null; //OnScriptChangedEvent; | 234 | private ScriptChangedEvent handlerScriptChangedEvent = null; //OnScriptChangedEvent; |
235 | private ScriptAtTargetEvent handlerScriptAtTargetEvent = null; | ||
236 | private ScriptNotAtTargetEvent handlerScriptNotAtTargetEvent = null; | ||
227 | private ClientMovement handlerClientMovement = null; //OnClientMovement; | 237 | private ClientMovement handlerClientMovement = null; //OnClientMovement; |
228 | private OnPermissionErrorDelegate handlerPermissionError = null; //OnPermissionError; | 238 | private OnPermissionErrorDelegate handlerPermissionError = null; //OnPermissionError; |
229 | private OnPluginConsoleDelegate handlerPluginConsole = null; //OnPluginConsole; | 239 | private OnPluginConsoleDelegate handlerPluginConsole = null; //OnPluginConsole; |
@@ -534,5 +544,23 @@ namespace OpenSim.Region.Environment.Scenes | |||
534 | handlerValidateLandBuy(sender, e); | 544 | handlerValidateLandBuy(sender, e); |
535 | } | 545 | } |
536 | } | 546 | } |
547 | |||
548 | public void TriggerAtTargetEvent(uint localID, uint handle, LLVector3 targetpos, LLVector3 currentpos) | ||
549 | { | ||
550 | handlerScriptAtTargetEvent = OnScriptAtTargetEvent; | ||
551 | if (handlerScriptAtTargetEvent != null) | ||
552 | { | ||
553 | handlerScriptAtTargetEvent(localID, handle, targetpos, currentpos); | ||
554 | } | ||
555 | } | ||
556 | |||
557 | public void TriggerNotAtTargetEvent(uint localID) | ||
558 | { | ||
559 | handlerScriptNotAtTargetEvent = OnScriptNotAtTargetEvent; | ||
560 | if (handlerScriptNotAtTargetEvent != null) | ||
561 | { | ||
562 | handlerScriptNotAtTargetEvent(localID); | ||
563 | } | ||
564 | } | ||
537 | } | 565 | } |
538 | } | 566 | } |
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 27639ea..bd75e6f 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs | |||
@@ -54,7 +54,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
54 | land_collision = 2048, | 54 | land_collision = 2048, |
55 | land_collision_end = 4096, | 55 | land_collision_end = 4096, |
56 | land_collision_start = 8192, | 56 | land_collision_start = 8192, |
57 | link_message = 16384, | 57 | at_target = 16384, |
58 | listen = 32768, | 58 | listen = 32768, |
59 | money = 65536, | 59 | money = 65536, |
60 | moving_end = 131072, | 60 | moving_end = 131072, |
@@ -72,6 +72,12 @@ namespace OpenSim.Region.Environment.Scenes | |||
72 | object_rez = 4194304 | 72 | object_rez = 4194304 |
73 | } | 73 | } |
74 | 74 | ||
75 | struct scriptPosTarget | ||
76 | { | ||
77 | public LLVector3 targetPos; | ||
78 | public float tolerance; | ||
79 | } | ||
80 | |||
75 | public delegate void PrimCountTaintedDelegate(); | 81 | public delegate void PrimCountTaintedDelegate(); |
76 | 82 | ||
77 | public partial class SceneObjectGroup : EntityBase | 83 | public partial class SceneObjectGroup : EntityBase |
@@ -99,6 +105,12 @@ namespace OpenSim.Region.Environment.Scenes | |||
99 | protected SceneObjectPart m_rootPart; | 105 | protected SceneObjectPart m_rootPart; |
100 | private Dictionary<LLUUID, scriptEvents> m_scriptEvents = new Dictionary<LLUUID, scriptEvents>(); | 106 | private Dictionary<LLUUID, scriptEvents> m_scriptEvents = new Dictionary<LLUUID, scriptEvents>(); |
101 | 107 | ||
108 | private Dictionary<uint, scriptPosTarget> m_targets = new Dictionary<uint, scriptPosTarget>(); | ||
109 | |||
110 | private bool m_scriptListens_atTarget = false; | ||
111 | private bool m_scriptListens_notAtTarget = false; | ||
112 | |||
113 | |||
102 | #region Properties | 114 | #region Properties |
103 | 115 | ||
104 | /// <summary> | 116 | /// <summary> |
@@ -175,6 +187,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
175 | string.Format("[SCENE OBJECT GROUP]: Object {0} has no root part.", m_uuid)); | 187 | string.Format("[SCENE OBJECT GROUP]: Object {0} has no root part.", m_uuid)); |
176 | } | 188 | } |
177 | 189 | ||
190 | |||
191 | |||
178 | return m_rootPart.GroupPosition; | 192 | return m_rootPart.GroupPosition; |
179 | } | 193 | } |
180 | set | 194 | set |
@@ -193,6 +207,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
193 | part.GroupPosition = val; | 207 | part.GroupPosition = val; |
194 | } | 208 | } |
195 | } | 209 | } |
210 | |||
196 | //if (m_rootPart.PhysActor != null) | 211 | //if (m_rootPart.PhysActor != null) |
197 | //{ | 212 | //{ |
198 | //m_rootPart.PhysActor.Position = | 213 | //m_rootPart.PhysActor.Position = |
@@ -202,7 +217,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
202 | //} | 217 | //} |
203 | } | 218 | } |
204 | } | 219 | } |
205 | 220 | ||
206 | public override uint LocalId | 221 | public override uint LocalId |
207 | { | 222 | { |
208 | get | 223 | get |
@@ -928,6 +943,33 @@ namespace OpenSim.Region.Environment.Scenes | |||
928 | part.ObjectFlags = objectflagupdate; | 943 | part.ObjectFlags = objectflagupdate; |
929 | } | 944 | } |
930 | } | 945 | } |
946 | |||
947 | if ((m_aggregateScriptEvents & scriptEvents.at_target) != 0) | ||
948 | { | ||
949 | m_scriptListens_atTarget = true; | ||
950 | } | ||
951 | else | ||
952 | { | ||
953 | m_scriptListens_atTarget = false; | ||
954 | } | ||
955 | |||
956 | if ((m_aggregateScriptEvents & scriptEvents.not_at_target) != 0) | ||
957 | { | ||
958 | m_scriptListens_notAtTarget = true; | ||
959 | } | ||
960 | else | ||
961 | { | ||
962 | m_scriptListens_notAtTarget = false; | ||
963 | } | ||
964 | |||
965 | if (m_scriptListens_atTarget || m_scriptListens_notAtTarget) | ||
966 | { | ||
967 | } | ||
968 | else | ||
969 | { | ||
970 | lock (m_targets) | ||
971 | m_targets.Clear(); | ||
972 | } | ||
931 | ScheduleGroupForFullUpdate(); | 973 | ScheduleGroupForFullUpdate(); |
932 | } | 974 | } |
933 | 975 | ||
@@ -1336,6 +1378,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1336 | /// </summary> | 1378 | /// </summary> |
1337 | public override void Update() | 1379 | public override void Update() |
1338 | { | 1380 | { |
1381 | |||
1339 | lock (m_parts) | 1382 | lock (m_parts) |
1340 | { | 1383 | { |
1341 | if (Util.GetDistanceTo(lastPhysGroupPos, AbsolutePosition) > 0.02) | 1384 | if (Util.GetDistanceTo(lastPhysGroupPos, AbsolutePosition) > 0.02) |
@@ -1346,6 +1389,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1346 | } | 1389 | } |
1347 | 1390 | ||
1348 | lastPhysGroupPos = AbsolutePosition; | 1391 | lastPhysGroupPos = AbsolutePosition; |
1392 | checkAtTargets(); | ||
1349 | } | 1393 | } |
1350 | 1394 | ||
1351 | if ((Math.Abs(lastPhysGroupRot.W - GroupRotation.W) > 0.1) | 1395 | if ((Math.Abs(lastPhysGroupRot.W - GroupRotation.W) > 0.1) |
@@ -1396,7 +1440,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
1396 | public void ScheduleGroupForFullUpdate() | 1440 | public void ScheduleGroupForFullUpdate() |
1397 | { | 1441 | { |
1398 | HasGroupChanged = true; | 1442 | HasGroupChanged = true; |
1399 | 1443 | checkAtTargets(); | |
1400 | lock (m_parts) | 1444 | lock (m_parts) |
1401 | { | 1445 | { |
1402 | foreach (SceneObjectPart part in m_parts.Values) | 1446 | foreach (SceneObjectPart part in m_parts.Values) |
@@ -2301,5 +2345,107 @@ namespace OpenSim.Region.Environment.Scenes | |||
2301 | 2345 | ||
2302 | } | 2346 | } |
2303 | } | 2347 | } |
2348 | |||
2349 | public int registerTargetWaypoint(LLVector3 target, float tolerance) | ||
2350 | { | ||
2351 | scriptPosTarget waypoint = new scriptPosTarget(); | ||
2352 | waypoint.targetPos = target; | ||
2353 | waypoint.tolerance = tolerance; | ||
2354 | uint handle = m_scene.PrimIDAllocate(); | ||
2355 | lock (m_targets) | ||
2356 | { | ||
2357 | m_targets.Add(handle, waypoint); | ||
2358 | } | ||
2359 | return (int)handle; | ||
2360 | } | ||
2361 | public void unregisterTargetWaypoint(int handle) | ||
2362 | { | ||
2363 | lock (m_targets) | ||
2364 | { | ||
2365 | if (m_targets.ContainsKey((uint)handle)) | ||
2366 | m_targets.Remove((uint)handle); | ||
2367 | } | ||
2368 | } | ||
2369 | |||
2370 | private void checkAtTargets() | ||
2371 | { | ||
2372 | if (m_scriptListens_atTarget || m_scriptListens_notAtTarget) | ||
2373 | { | ||
2374 | if (m_targets.Count > 0) | ||
2375 | { | ||
2376 | bool at_target = false; | ||
2377 | //LLVector3 targetPos; | ||
2378 | //uint targetHandle; | ||
2379 | Dictionary<uint, scriptPosTarget> atTargets = new Dictionary<uint, scriptPosTarget>(); | ||
2380 | lock (m_targets) | ||
2381 | { | ||
2382 | foreach (uint idx in m_targets.Keys) | ||
2383 | { | ||
2384 | scriptPosTarget target = m_targets[idx]; | ||
2385 | if (Util.GetDistanceTo(target.targetPos, m_rootPart.GroupPosition) <= target.tolerance) | ||
2386 | { | ||
2387 | // trigger at_target | ||
2388 | if (m_scriptListens_atTarget) | ||
2389 | { | ||
2390 | // Reusing att.tolerance to hold the index of the target in the targets dictionary | ||
2391 | // to avoid deadlocking the sim. | ||
2392 | at_target = true; | ||
2393 | scriptPosTarget att = new scriptPosTarget(); | ||
2394 | att.targetPos = target.targetPos; | ||
2395 | att.tolerance = (float)idx; | ||
2396 | atTargets.Add(idx, att); | ||
2397 | } | ||
2398 | } | ||
2399 | } | ||
2400 | } | ||
2401 | if (atTargets.Count > 0) | ||
2402 | { | ||
2403 | uint[] localids = new uint[0]; | ||
2404 | lock (m_parts) | ||
2405 | { | ||
2406 | localids = new uint[m_parts.Count]; | ||
2407 | int cntr = 0; | ||
2408 | foreach (SceneObjectPart part in m_parts.Values) | ||
2409 | { | ||
2410 | localids[cntr] = part.LocalId; | ||
2411 | cntr++; | ||
2412 | } | ||
2413 | } | ||
2414 | for (int ctr = 0; ctr < localids.Length; ctr++) | ||
2415 | { | ||
2416 | foreach (uint target in atTargets.Keys) | ||
2417 | { | ||
2418 | scriptPosTarget att = atTargets[target]; | ||
2419 | // Reusing att.tolerance to hold the index of the target in the targets dictionary | ||
2420 | // to avoid deadlocking the sim. | ||
2421 | m_scene.TriggerAtTargetEvent(localids[ctr], (uint)att.tolerance, att.targetPos, m_rootPart.GroupPosition); | ||
2422 | |||
2423 | |||
2424 | } | ||
2425 | } | ||
2426 | return; | ||
2427 | } | ||
2428 | if (m_scriptListens_notAtTarget && !at_target) | ||
2429 | { | ||
2430 | //trigger not_at_target | ||
2431 | uint[] localids = new uint[0]; | ||
2432 | lock (m_parts) | ||
2433 | { | ||
2434 | localids = new uint[m_parts.Count]; | ||
2435 | int cntr = 0; | ||
2436 | foreach (SceneObjectPart part in m_parts.Values) | ||
2437 | { | ||
2438 | localids[cntr] = part.LocalId; | ||
2439 | cntr++; | ||
2440 | } | ||
2441 | } | ||
2442 | for (int ctr = 0; ctr < localids.Length; ctr++) | ||
2443 | { | ||
2444 | m_scene.TriggerNotAtTargetEvent(localids[ctr]); | ||
2445 | } | ||
2446 | } | ||
2447 | } | ||
2448 | } | ||
2449 | } | ||
2304 | } | 2450 | } |
2305 | } \ No newline at end of file | 2451 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs index 0608fa7..f345dab 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectPart.cs | |||
@@ -2367,7 +2367,21 @@ namespace OpenSim.Region.Environment.Scenes | |||
2367 | m_parentGroup.SetScriptEvents(scriptID, events); | 2367 | m_parentGroup.SetScriptEvents(scriptID, events); |
2368 | } | 2368 | } |
2369 | } | 2369 | } |
2370 | 2370 | public int registerTargetWaypoint(LLVector3 target, float tolerance) | |
2371 | { | ||
2372 | if (m_parentGroup != null) | ||
2373 | { | ||
2374 | return m_parentGroup.registerTargetWaypoint(target, tolerance); | ||
2375 | } | ||
2376 | return 0; | ||
2377 | } | ||
2378 | public void unregisterTargetWaypoint(int handle) | ||
2379 | { | ||
2380 | if (m_parentGroup != null) | ||
2381 | { | ||
2382 | m_parentGroup.unregisterTargetWaypoint(handle); | ||
2383 | } | ||
2384 | } | ||
2371 | protected SceneObjectPart(SerializationInfo info, StreamingContext context) | 2385 | protected SceneObjectPart(SerializationInfo info, StreamingContext context) |
2372 | { | 2386 | { |
2373 | //System.Console.WriteLine("SceneObjectPart Deserialize BGN"); | 2387 | //System.Console.WriteLine("SceneObjectPart Deserialize BGN"); |