diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 201 |
1 files changed, 201 insertions, 0 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 6fbc410..f3af808 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -153,6 +153,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
153 | private int m_lastColCount = -1; //KF: Look for Collision chnages | 153 | private int m_lastColCount = -1; //KF: Look for Collision chnages |
154 | private int m_updateCount = 0; //KF: Update Anims for a while | 154 | private int m_updateCount = 0; //KF: Update Anims for a while |
155 | private static readonly int UPDATE_COUNT = 10; // how many frames to update for | 155 | private static readonly int UPDATE_COUNT = 10; // how many frames to update for |
156 | private List<uint> m_lastColliders = new List<uint>(); | ||
156 | 157 | ||
157 | private TeleportFlags m_teleportFlags; | 158 | private TeleportFlags m_teleportFlags; |
158 | public TeleportFlags TeleportFlags | 159 | public TeleportFlags TeleportFlags |
@@ -919,6 +920,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
919 | pos.Y = crossedBorder.BorderLine.Z - 1; | 920 | pos.Y = crossedBorder.BorderLine.Z - 1; |
920 | } | 921 | } |
921 | 922 | ||
923 | CheckAndAdjustLandingPoint(ref pos); | ||
924 | |||
922 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) | 925 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) |
923 | { | 926 | { |
924 | m_log.WarnFormat( | 927 | m_log.WarnFormat( |
@@ -1081,6 +1084,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1081 | 1084 | ||
1082 | RemoveFromPhysicalScene(); | 1085 | RemoveFromPhysicalScene(); |
1083 | Velocity = Vector3.Zero; | 1086 | Velocity = Vector3.Zero; |
1087 | CheckLandingPoint(ref pos); | ||
1084 | AbsolutePosition = pos; | 1088 | AbsolutePosition = pos; |
1085 | AddToPhysicalScene(isFlying); | 1089 | AddToPhysicalScene(isFlying); |
1086 | 1090 | ||
@@ -1094,6 +1098,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1094 | isFlying = PhysicsActor.Flying; | 1098 | isFlying = PhysicsActor.Flying; |
1095 | 1099 | ||
1096 | RemoveFromPhysicalScene(); | 1100 | RemoveFromPhysicalScene(); |
1101 | CheckLandingPoint(ref pos); | ||
1097 | AbsolutePosition = pos; | 1102 | AbsolutePosition = pos; |
1098 | AddToPhysicalScene(isFlying); | 1103 | AddToPhysicalScene(isFlying); |
1099 | 1104 | ||
@@ -3398,6 +3403,148 @@ namespace OpenSim.Region.Framework.Scenes | |||
3398 | } | 3403 | } |
3399 | } | 3404 | } |
3400 | 3405 | ||
3406 | List<uint> thisHitColliders = new List<uint>(); | ||
3407 | List<uint> endedColliders = new List<uint>(); | ||
3408 | List<uint> startedColliders = new List<uint>(); | ||
3409 | |||
3410 | foreach (uint localid in coldata.Keys) | ||
3411 | { | ||
3412 | thisHitColliders.Add(localid); | ||
3413 | if (!m_lastColliders.Contains(localid)) | ||
3414 | { | ||
3415 | startedColliders.Add(localid); | ||
3416 | } | ||
3417 | //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString()); | ||
3418 | } | ||
3419 | |||
3420 | // calculate things that ended colliding | ||
3421 | foreach (uint localID in m_lastColliders) | ||
3422 | { | ||
3423 | if (!thisHitColliders.Contains(localID)) | ||
3424 | { | ||
3425 | endedColliders.Add(localID); | ||
3426 | } | ||
3427 | } | ||
3428 | //add the items that started colliding this time to the last colliders list. | ||
3429 | foreach (uint localID in startedColliders) | ||
3430 | { | ||
3431 | m_lastColliders.Add(localID); | ||
3432 | } | ||
3433 | // remove things that ended colliding from the last colliders list | ||
3434 | foreach (uint localID in endedColliders) | ||
3435 | { | ||
3436 | m_lastColliders.Remove(localID); | ||
3437 | } | ||
3438 | |||
3439 | // do event notification | ||
3440 | if (startedColliders.Count > 0) | ||
3441 | { | ||
3442 | ColliderArgs StartCollidingMessage = new ColliderArgs(); | ||
3443 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3444 | foreach (uint localId in startedColliders) | ||
3445 | { | ||
3446 | if (localId == 0) | ||
3447 | continue; | ||
3448 | |||
3449 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3450 | string data = ""; | ||
3451 | if (obj != null) | ||
3452 | { | ||
3453 | DetectedObject detobj = new DetectedObject(); | ||
3454 | detobj.keyUUID = obj.UUID; | ||
3455 | detobj.nameStr = obj.Name; | ||
3456 | detobj.ownerUUID = obj.OwnerID; | ||
3457 | detobj.posVector = obj.AbsolutePosition; | ||
3458 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3459 | detobj.velVector = obj.Velocity; | ||
3460 | detobj.colliderType = 0; | ||
3461 | detobj.groupUUID = obj.GroupID; | ||
3462 | colliding.Add(detobj); | ||
3463 | } | ||
3464 | } | ||
3465 | |||
3466 | if (colliding.Count > 0) | ||
3467 | { | ||
3468 | StartCollidingMessage.Colliders = colliding; | ||
3469 | |||
3470 | foreach (SceneObjectGroup att in GetAttachments()) | ||
3471 | Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage); | ||
3472 | } | ||
3473 | } | ||
3474 | |||
3475 | if (endedColliders.Count > 0) | ||
3476 | { | ||
3477 | ColliderArgs EndCollidingMessage = new ColliderArgs(); | ||
3478 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3479 | foreach (uint localId in endedColliders) | ||
3480 | { | ||
3481 | if (localId == 0) | ||
3482 | continue; | ||
3483 | |||
3484 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3485 | string data = ""; | ||
3486 | if (obj != null) | ||
3487 | { | ||
3488 | DetectedObject detobj = new DetectedObject(); | ||
3489 | detobj.keyUUID = obj.UUID; | ||
3490 | detobj.nameStr = obj.Name; | ||
3491 | detobj.ownerUUID = obj.OwnerID; | ||
3492 | detobj.posVector = obj.AbsolutePosition; | ||
3493 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3494 | detobj.velVector = obj.Velocity; | ||
3495 | detobj.colliderType = 0; | ||
3496 | detobj.groupUUID = obj.GroupID; | ||
3497 | colliding.Add(detobj); | ||
3498 | } | ||
3499 | } | ||
3500 | |||
3501 | if (colliding.Count > 0) | ||
3502 | { | ||
3503 | EndCollidingMessage.Colliders = colliding; | ||
3504 | |||
3505 | foreach (SceneObjectGroup att in GetAttachments()) | ||
3506 | Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage); | ||
3507 | } | ||
3508 | } | ||
3509 | |||
3510 | if (thisHitColliders.Count > 0) | ||
3511 | { | ||
3512 | ColliderArgs CollidingMessage = new ColliderArgs(); | ||
3513 | List<DetectedObject> colliding = new List<DetectedObject>(); | ||
3514 | foreach (uint localId in thisHitColliders) | ||
3515 | { | ||
3516 | if (localId == 0) | ||
3517 | continue; | ||
3518 | |||
3519 | SceneObjectPart obj = Scene.GetSceneObjectPart(localId); | ||
3520 | string data = ""; | ||
3521 | if (obj != null) | ||
3522 | { | ||
3523 | DetectedObject detobj = new DetectedObject(); | ||
3524 | detobj.keyUUID = obj.UUID; | ||
3525 | detobj.nameStr = obj.Name; | ||
3526 | detobj.ownerUUID = obj.OwnerID; | ||
3527 | detobj.posVector = obj.AbsolutePosition; | ||
3528 | detobj.rotQuat = obj.GetWorldRotation(); | ||
3529 | detobj.velVector = obj.Velocity; | ||
3530 | detobj.colliderType = 0; | ||
3531 | detobj.groupUUID = obj.GroupID; | ||
3532 | colliding.Add(detobj); | ||
3533 | } | ||
3534 | } | ||
3535 | |||
3536 | if (colliding.Count > 0) | ||
3537 | { | ||
3538 | CollidingMessage.Colliders = colliding; | ||
3539 | |||
3540 | lock (m_attachments) | ||
3541 | { | ||
3542 | foreach (SceneObjectGroup att in m_attachments) | ||
3543 | Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage); | ||
3544 | } | ||
3545 | } | ||
3546 | } | ||
3547 | |||
3401 | if (Invulnerable) | 3548 | if (Invulnerable) |
3402 | return; | 3549 | return; |
3403 | 3550 | ||
@@ -3836,5 +3983,59 @@ namespace OpenSim.Region.Framework.Scenes | |||
3836 | m_reprioritization_called = false; | 3983 | m_reprioritization_called = false; |
3837 | } | 3984 | } |
3838 | } | 3985 | } |
3986 | |||
3987 | private void CheckLandingPoint(ref Vector3 pos) | ||
3988 | { | ||
3989 | // Never constrain lures | ||
3990 | if ((TeleportFlags & TeleportFlags.ViaLure) != 0) | ||
3991 | return; | ||
3992 | |||
3993 | if (m_scene.RegionInfo.EstateSettings.AllowDirectTeleport) | ||
3994 | return; | ||
3995 | |||
3996 | ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); | ||
3997 | |||
3998 | if (land.LandData.LandingType == (byte)LandingType.LandingPoint && | ||
3999 | land.LandData.UserLocation != Vector3.Zero && | ||
4000 | land.LandData.OwnerID != m_uuid && | ||
4001 | (!m_scene.Permissions.IsGod(m_uuid)) && | ||
4002 | (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) | ||
4003 | { | ||
4004 | float curr = Vector3.Distance(AbsolutePosition, pos); | ||
4005 | if (Vector3.Distance(land.LandData.UserLocation, pos) < curr) | ||
4006 | pos = land.LandData.UserLocation; | ||
4007 | else | ||
4008 | ControllingClient.SendAlertMessage("Can't teleport closer to destination"); | ||
4009 | } | ||
4010 | } | ||
4011 | |||
4012 | private void CheckAndAdjustLandingPoint(ref Vector3 pos) | ||
4013 | { | ||
4014 | ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); | ||
4015 | if (land != null) | ||
4016 | { | ||
4017 | // If we come in via login, landmark or map, we want to | ||
4018 | // honor landing points. If we come in via Lure, we want | ||
4019 | // to ignore them. | ||
4020 | if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) == (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) || | ||
4021 | (m_teleportFlags & TeleportFlags.ViaLandmark) != 0 || | ||
4022 | (m_teleportFlags & TeleportFlags.ViaLocation) != 0) | ||
4023 | { | ||
4024 | // Don't restrict gods, estate managers, or land owners to | ||
4025 | // the TP point. This behaviour mimics agni. | ||
4026 | if (land.LandData.LandingType == (byte)LandingType.LandingPoint && | ||
4027 | land.LandData.UserLocation != Vector3.Zero && | ||
4028 | GodLevel < 200 && | ||
4029 | ((land.LandData.OwnerID != m_uuid && | ||
4030 | (!m_scene.Permissions.IsGod(m_uuid)) && | ||
4031 | (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) || (m_teleportFlags & TeleportFlags.ViaLocation) != 0)) | ||
4032 | { | ||
4033 | pos = land.LandData.UserLocation; | ||
4034 | } | ||
4035 | } | ||
4036 | |||
4037 | land.SendLandUpdateToClient(ControllingClient); | ||
4038 | } | ||
4039 | } | ||
3839 | } | 4040 | } |
3840 | } | 4041 | } |