diff options
author | onefang | 2019-09-11 16:36:50 +1000 |
---|---|---|
committer | onefang | 2019-09-11 16:36:50 +1000 |
commit | 50cd1ffd32f69228e566f2b0b89f86ea0d9fe489 (patch) | |
tree | 52f2ab0c04f1a5d7d6ac5dc872981b4b156447e7 /OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs | |
parent | Renamed branch to SledjChisl. (diff) | |
parent | Bump to release flavour, build 0. (diff) | |
download | opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.zip opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.gz opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.bz2 opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.xz |
Merge branch 'SledjChisl'
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs | 62 |
1 files changed, 40 insertions, 22 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index 64dc2e2..cc98bbb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs | |||
@@ -93,7 +93,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
93 | private const int AGENT = 1; | 93 | private const int AGENT = 1; |
94 | private const int AGENT_BY_USERNAME = 0x10; | 94 | private const int AGENT_BY_USERNAME = 0x10; |
95 | private const int NPC = 0x20; | 95 | private const int NPC = 0x20; |
96 | private const int OS_NPC = 0x01000000; | ||
97 | private const int ACTIVE = 2; | 96 | private const int ACTIVE = 2; |
98 | private const int PASSIVE = 4; | 97 | private const int PASSIVE = 4; |
99 | private const int SCRIPTED = 8; | 98 | private const int SCRIPTED = 8; |
@@ -161,7 +160,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
161 | ts.arc = arc; | 160 | ts.arc = arc; |
162 | ts.host = host; | 161 | ts.host = host; |
163 | 162 | ||
164 | ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); | 163 | ts.next = DateTime.UtcNow.AddSeconds(ts.interval); |
165 | 164 | ||
166 | AddSenseRepeater(ts); | 165 | AddSenseRepeater(ts); |
167 | } | 166 | } |
@@ -197,14 +196,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
197 | public void CheckSenseRepeaterEvents() | 196 | public void CheckSenseRepeaterEvents() |
198 | { | 197 | { |
199 | // Go through all timers | 198 | // Go through all timers |
200 | foreach (SensorInfo ts in SenseRepeaters) | 199 | |
200 | List<SensorInfo> curSensors; | ||
201 | lock(SenseRepeatListLock) | ||
202 | curSensors = SenseRepeaters; | ||
203 | |||
204 | DateTime now = DateTime.UtcNow; | ||
205 | foreach (SensorInfo ts in curSensors) | ||
201 | { | 206 | { |
202 | // Time has passed? | 207 | // Time has passed? |
203 | if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime()) | 208 | if (ts.next < now) |
204 | { | 209 | { |
205 | SensorSweep(ts); | 210 | SensorSweep(ts); |
206 | // set next interval | 211 | // set next interval |
207 | ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); | 212 | ts.next = now.AddSeconds(ts.interval); |
208 | } | 213 | } |
209 | } | 214 | } |
210 | } | 215 | } |
@@ -240,7 +245,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
240 | List<SensedEntity> sensedEntities = new List<SensedEntity>(); | 245 | List<SensedEntity> sensedEntities = new List<SensedEntity>(); |
241 | 246 | ||
242 | // Is the sensor type is AGENT and not SCRIPTED then include agents | 247 | // Is the sensor type is AGENT and not SCRIPTED then include agents |
243 | if ((ts.type & (AGENT | AGENT_BY_USERNAME | NPC | OS_NPC)) != 0 && (ts.type & SCRIPTED) == 0) | 248 | if ((ts.type & (AGENT | AGENT_BY_USERNAME | NPC)) != 0 && (ts.type & SCRIPTED) == 0) |
244 | { | 249 | { |
245 | sensedEntities.AddRange(doAgentSensor(ts)); | 250 | sensedEntities.AddRange(doAgentSensor(ts)); |
246 | } | 251 | } |
@@ -339,7 +344,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
339 | float dy; | 344 | float dy; |
340 | float dz; | 345 | float dz; |
341 | 346 | ||
342 | Quaternion q = SensePoint.GetWorldRotation(); | 347 | // Quaternion q = SensePoint.RotationOffset; |
348 | Quaternion q = SensePoint.GetWorldRotation(); // non-attached prim Sensor *always* uses World rotation! | ||
343 | if (SensePoint.ParentGroup.IsAttachment) | 349 | if (SensePoint.ParentGroup.IsAttachment) |
344 | { | 350 | { |
345 | // In attachments, rotate the sensor cone with the | 351 | // In attachments, rotate the sensor cone with the |
@@ -351,14 +357,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
351 | // your head but the sensor will stay with your (global) | 357 | // your head but the sensor will stay with your (global) |
352 | // avatar rotation and position. | 358 | // avatar rotation and position. |
353 | // Position of a sensor in a child prim attached to an avatar | 359 | // Position of a sensor in a child prim attached to an avatar |
354 | // will be still wrong. | 360 | // will be still wrong. |
355 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); | 361 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); |
356 | 362 | ||
357 | // Don't proceed if the avatar for this attachment has since been removed from the scene. | 363 | // Don't proceed if the avatar for this attachment has since been removed from the scene. |
358 | if (avatar == null) | 364 | if (avatar == null) |
359 | return sensedEntities; | 365 | return sensedEntities; |
360 | 366 | ||
361 | q = avatar.GetWorldRotation() * q; | 367 | fromRegionPos = avatar.AbsolutePosition; |
368 | q = avatar.Rotation; | ||
362 | } | 369 | } |
363 | 370 | ||
364 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q); | 371 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q); |
@@ -402,7 +409,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
402 | objtype = 0; | 409 | objtype = 0; |
403 | 410 | ||
404 | part = ((SceneObjectGroup)ent).RootPart; | 411 | part = ((SceneObjectGroup)ent).RootPart; |
405 | if (part.ParentGroup.AttachmentPoint != 0) // Attached so ignore | 412 | if (part.ParentGroup.RootPart.Shape.PCode != (byte)PCode.Tree && |
413 | part.ParentGroup.RootPart.Shape.PCode != (byte)PCode.NewTree && | ||
414 | part.ParentGroup.AttachmentPoint != 0) // Attached so ignore | ||
406 | continue; | 415 | continue; |
407 | 416 | ||
408 | if (part.Inventory.ContainsScripts()) | 417 | if (part.Inventory.ContainsScripts()) |
@@ -470,7 +479,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
470 | 479 | ||
471 | SceneObjectPart SensePoint = ts.host; | 480 | SceneObjectPart SensePoint = ts.host; |
472 | Vector3 fromRegionPos = SensePoint.GetWorldPosition(); | 481 | Vector3 fromRegionPos = SensePoint.GetWorldPosition(); |
473 | 482 | ||
474 | Quaternion q = SensePoint.GetWorldRotation(); | 483 | Quaternion q = SensePoint.GetWorldRotation(); |
475 | if (SensePoint.ParentGroup.IsAttachment) | 484 | if (SensePoint.ParentGroup.IsAttachment) |
476 | { | 485 | { |
@@ -483,14 +492,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
483 | // your head but the sensor will stay with your (global) | 492 | // your head but the sensor will stay with your (global) |
484 | // avatar rotation and position. | 493 | // avatar rotation and position. |
485 | // Position of a sensor in a child prim attached to an avatar | 494 | // Position of a sensor in a child prim attached to an avatar |
486 | // will be still wrong. | 495 | // will be still wrong. |
487 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); | 496 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); |
488 | 497 | ||
489 | // Don't proceed if the avatar for this attachment has since been removed from the scene. | 498 | // Don't proceed if the avatar for this attachment has since been removed from the scene. |
490 | if (avatar == null) | 499 | if (avatar == null) |
491 | return sensedEntities; | 500 | return sensedEntities; |
492 | 501 | fromRegionPos = avatar.AbsolutePosition; | |
493 | q = avatar.GetWorldRotation() * q; | 502 | q = avatar.Rotation; |
494 | } | 503 | } |
495 | 504 | ||
496 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q); | 505 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q); |
@@ -499,14 +508,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
499 | bool attached = (SensePoint.ParentGroup.AttachmentPoint != 0); | 508 | bool attached = (SensePoint.ParentGroup.AttachmentPoint != 0); |
500 | Vector3 toRegionPos; | 509 | Vector3 toRegionPos; |
501 | double dis; | 510 | double dis; |
502 | 511 | ||
503 | Action<ScenePresence> senseEntity = new Action<ScenePresence>(presence => | 512 | Action<ScenePresence> senseEntity = new Action<ScenePresence>(presence => |
504 | { | 513 | { |
505 | // m_log.DebugFormat( | 514 | // m_log.DebugFormat( |
506 | // "[SENSOR REPEAT]: Inspecting scene presence {0}, type {1} on sensor sweep for {2}, type {3}", | 515 | // "[SENSOR REPEAT]: Inspecting scene presence {0}, type {1} on sensor sweep for {2}, type {3}", |
507 | // presence.Name, presence.PresenceType, ts.name, ts.type); | 516 | // presence.Name, presence.PresenceType, ts.name, ts.type); |
508 | 517 | ||
509 | if ((ts.type & NPC) == 0 && (ts.type & OS_NPC) == 0 && presence.PresenceType == PresenceType.Npc) | 518 | if ((ts.type & NPC) == 0 && presence.PresenceType == PresenceType.Npc) |
510 | { | 519 | { |
511 | INPC npcData = m_npcModule.GetNPC(presence.UUID, presence.Scene); | 520 | INPC npcData = m_npcModule.GetNPC(presence.UUID, presence.Scene); |
512 | if (npcData == null || !npcData.SenseAsAgent) | 521 | if (npcData == null || !npcData.SenseAsAgent) |
@@ -537,16 +546,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
537 | } | 546 | } |
538 | } | 547 | } |
539 | 548 | ||
540 | if (presence.IsDeleted || presence.IsChildAgent || presence.GodLevel > 0.0) | 549 | if (presence.IsDeleted || presence.IsChildAgent || presence.IsViewerUIGod) |
541 | return; | 550 | return; |
542 | 551 | ||
543 | // if the object the script is in is attached and the avatar is the owner | 552 | // if the object the script is in is attached and the avatar is the owner |
544 | // then this one is not wanted | 553 | // then this one is not wanted |
545 | if (attached && presence.UUID == SensePoint.OwnerID) | 554 | if (attached && presence.UUID == SensePoint.OwnerID) |
546 | return; | 555 | return; |
547 | 556 | ||
548 | toRegionPos = presence.AbsolutePosition; | 557 | toRegionPos = presence.AbsolutePosition; |
549 | dis = Math.Abs(Util.GetDistanceTo(toRegionPos, fromRegionPos)); | 558 | dis = Util.GetDistanceTo(toRegionPos, fromRegionPos); |
559 | if (presence.IsSatOnObject && presence.ParentPart != null && | ||
560 | presence.ParentPart.ParentGroup != null && | ||
561 | presence.ParentPart.ParentGroup.RootPart != null) | ||
562 | { | ||
563 | Vector3 rpos = presence.ParentPart.ParentGroup.RootPart.AbsolutePosition; | ||
564 | double dis2 = Util.GetDistanceTo(rpos, fromRegionPos); | ||
565 | if (dis > dis2) | ||
566 | dis = dis2; | ||
567 | } | ||
550 | 568 | ||
551 | // Disabled for now since all osNpc* methods check for appropriate ownership permission. | 569 | // Disabled for now since all osNpc* methods check for appropriate ownership permission. |
552 | // Perhaps could be re-enabled as an NPC setting at some point since being able to make NPCs not | 570 | // Perhaps could be re-enabled as an NPC setting at some point since being able to make NPCs not |
@@ -688,7 +706,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
688 | DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); | 706 | DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); |
689 | 707 | ||
690 | AddSenseRepeater(ts); | 708 | AddSenseRepeater(ts); |
691 | 709 | ||
692 | idx += 6; | 710 | idx += 6; |
693 | } | 711 | } |
694 | } | 712 | } |
@@ -704,6 +722,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
704 | } | 722 | } |
705 | 723 | ||
706 | return retList; | 724 | return retList; |
707 | } | 725 | } |
708 | } | 726 | } |
709 | } \ No newline at end of file | 727 | } |