diff options
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs | 152 |
1 files changed, 149 insertions, 3 deletions
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 |