aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs226
1 files changed, 226 insertions, 0 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index ce638e0..76bc390 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,62 @@ namespace OpenSim.Region.Framework.Scenes
919 pos.Y = crossedBorder.BorderLine.Z - 1; 920 pos.Y = crossedBorder.BorderLine.Z - 1;
920 } 921 }
921 922
923 ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
924 if (land != null)
925 {
926 // If we come in via login, landmark or map, we want to
927 // honor landing points. If we come in via Lure, we want
928 // to ignore them.
929 if ((m_teleportFlags & (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID)) == (TeleportFlags.ViaLogin | TeleportFlags.ViaRegionID) ||
930 (m_teleportFlags & TeleportFlags.ViaLandmark) != 0 ||
931 (m_teleportFlags & TeleportFlags.ViaLocation) != 0)
932 {
933 // Don't restrict gods, estate managers, or land owners to
934 // the TP point. This behaviour mimics agni.
935 if (land.LandData.LandingType == (byte)LandingType.LandingPoint &&
936 land.LandData.UserLocation != Vector3.Zero &&
937 GodLevel < 200 &&
938 ((land.LandData.OwnerID != m_uuid &&
939 (!m_scene.Permissions.IsGod(m_uuid)) &&
940 (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) || (m_teleportFlags & TeleportFlags.ViaLocation) != 0))
941 {
942 pos = land.LandData.UserLocation;
943 }
944 }
945
946 land.SendLandUpdateToClient(ControllingClient);
947 }
948
949 if (pos.X < 0 || pos.Y < 0 || pos.Z < 0)
950 {
951 Vector3 emergencyPos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 128);
952
953 if (pos.X < 0)
954 {
955 emergencyPos.X = (int)Constants.RegionSize + pos.X;
956 if (!(pos.Y < 0))
957 emergencyPos.Y = pos.Y;
958 if (!(pos.Z < 0))
959 emergencyPos.Z = pos.Z;
960 }
961 if (pos.Y < 0)
962 {
963 emergencyPos.Y = (int)Constants.RegionSize + pos.Y;
964 if (!(pos.X < 0))
965 emergencyPos.X = pos.X;
966 if (!(pos.Z < 0))
967 emergencyPos.Z = pos.Z;
968 }
969 if (pos.Z < 0)
970 {
971 emergencyPos.Z = 128;
972 if (!(pos.Y < 0))
973 emergencyPos.Y = pos.Y;
974 if (!(pos.X < 0))
975 emergencyPos.X = pos.X;
976 }
977 }
978
922 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) 979 if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f)
923 { 980 {
924 m_log.WarnFormat( 981 m_log.WarnFormat(
@@ -1081,6 +1138,7 @@ namespace OpenSim.Region.Framework.Scenes
1081 1138
1082 RemoveFromPhysicalScene(); 1139 RemoveFromPhysicalScene();
1083 Velocity = Vector3.Zero; 1140 Velocity = Vector3.Zero;
1141 CheckLandingPoint(ref pos);
1084 AbsolutePosition = pos; 1142 AbsolutePosition = pos;
1085 AddToPhysicalScene(isFlying); 1143 AddToPhysicalScene(isFlying);
1086 1144
@@ -1094,6 +1152,7 @@ namespace OpenSim.Region.Framework.Scenes
1094 isFlying = PhysicsActor.Flying; 1152 isFlying = PhysicsActor.Flying;
1095 1153
1096 RemoveFromPhysicalScene(); 1154 RemoveFromPhysicalScene();
1155 CheckLandingPoint(ref pos);
1097 AbsolutePosition = pos; 1156 AbsolutePosition = pos;
1098 AddToPhysicalScene(isFlying); 1157 AddToPhysicalScene(isFlying);
1099 1158
@@ -3398,6 +3457,148 @@ namespace OpenSim.Region.Framework.Scenes
3398 } 3457 }
3399 } 3458 }
3400 3459
3460 List<uint> thisHitColliders = new List<uint>();
3461 List<uint> endedColliders = new List<uint>();
3462 List<uint> startedColliders = new List<uint>();
3463
3464 foreach (uint localid in coldata.Keys)
3465 {
3466 thisHitColliders.Add(localid);
3467 if (!m_lastColliders.Contains(localid))
3468 {
3469 startedColliders.Add(localid);
3470 }
3471 //m_log.Debug("[SCENE PRESENCE]: Collided with:" + localid.ToString() + " at depth of: " + collissionswith[localid].ToString());
3472 }
3473
3474 // calculate things that ended colliding
3475 foreach (uint localID in m_lastColliders)
3476 {
3477 if (!thisHitColliders.Contains(localID))
3478 {
3479 endedColliders.Add(localID);
3480 }
3481 }
3482 //add the items that started colliding this time to the last colliders list.
3483 foreach (uint localID in startedColliders)
3484 {
3485 m_lastColliders.Add(localID);
3486 }
3487 // remove things that ended colliding from the last colliders list
3488 foreach (uint localID in endedColliders)
3489 {
3490 m_lastColliders.Remove(localID);
3491 }
3492
3493 // do event notification
3494 if (startedColliders.Count > 0)
3495 {
3496 ColliderArgs StartCollidingMessage = new ColliderArgs();
3497 List<DetectedObject> colliding = new List<DetectedObject>();
3498 foreach (uint localId in startedColliders)
3499 {
3500 if (localId == 0)
3501 continue;
3502
3503 SceneObjectPart obj = Scene.GetSceneObjectPart(localId);
3504 string data = "";
3505 if (obj != null)
3506 {
3507 DetectedObject detobj = new DetectedObject();
3508 detobj.keyUUID = obj.UUID;
3509 detobj.nameStr = obj.Name;
3510 detobj.ownerUUID = obj.OwnerID;
3511 detobj.posVector = obj.AbsolutePosition;
3512 detobj.rotQuat = obj.GetWorldRotation();
3513 detobj.velVector = obj.Velocity;
3514 detobj.colliderType = 0;
3515 detobj.groupUUID = obj.GroupID;
3516 colliding.Add(detobj);
3517 }
3518 }
3519
3520 if (colliding.Count > 0)
3521 {
3522 StartCollidingMessage.Colliders = colliding;
3523
3524 foreach (SceneObjectGroup att in GetAttachments())
3525 Scene.EventManager.TriggerScriptCollidingStart(att.LocalId, StartCollidingMessage);
3526 }
3527 }
3528
3529 if (endedColliders.Count > 0)
3530 {
3531 ColliderArgs EndCollidingMessage = new ColliderArgs();
3532 List<DetectedObject> colliding = new List<DetectedObject>();
3533 foreach (uint localId in endedColliders)
3534 {
3535 if (localId == 0)
3536 continue;
3537
3538 SceneObjectPart obj = Scene.GetSceneObjectPart(localId);
3539 string data = "";
3540 if (obj != null)
3541 {
3542 DetectedObject detobj = new DetectedObject();
3543 detobj.keyUUID = obj.UUID;
3544 detobj.nameStr = obj.Name;
3545 detobj.ownerUUID = obj.OwnerID;
3546 detobj.posVector = obj.AbsolutePosition;
3547 detobj.rotQuat = obj.GetWorldRotation();
3548 detobj.velVector = obj.Velocity;
3549 detobj.colliderType = 0;
3550 detobj.groupUUID = obj.GroupID;
3551 colliding.Add(detobj);
3552 }
3553 }
3554
3555 if (colliding.Count > 0)
3556 {
3557 EndCollidingMessage.Colliders = colliding;
3558
3559 foreach (SceneObjectGroup att in GetAttachments())
3560 Scene.EventManager.TriggerScriptCollidingEnd(att.LocalId, EndCollidingMessage);
3561 }
3562 }
3563
3564 if (thisHitColliders.Count > 0)
3565 {
3566 ColliderArgs CollidingMessage = new ColliderArgs();
3567 List<DetectedObject> colliding = new List<DetectedObject>();
3568 foreach (uint localId in thisHitColliders)
3569 {
3570 if (localId == 0)
3571 continue;
3572
3573 SceneObjectPart obj = Scene.GetSceneObjectPart(localId);
3574 string data = "";
3575 if (obj != null)
3576 {
3577 DetectedObject detobj = new DetectedObject();
3578 detobj.keyUUID = obj.UUID;
3579 detobj.nameStr = obj.Name;
3580 detobj.ownerUUID = obj.OwnerID;
3581 detobj.posVector = obj.AbsolutePosition;
3582 detobj.rotQuat = obj.GetWorldRotation();
3583 detobj.velVector = obj.Velocity;
3584 detobj.colliderType = 0;
3585 detobj.groupUUID = obj.GroupID;
3586 colliding.Add(detobj);
3587 }
3588 }
3589
3590 if (colliding.Count > 0)
3591 {
3592 CollidingMessage.Colliders = colliding;
3593
3594 lock (m_attachments)
3595 {
3596 foreach (SceneObjectGroup att in m_attachments)
3597 Scene.EventManager.TriggerScriptColliding(att.LocalId, CollidingMessage);
3598 }
3599 }
3600 }
3601
3401 if (Invulnerable) 3602 if (Invulnerable)
3402 return; 3603 return;
3403 3604
@@ -3836,5 +4037,30 @@ namespace OpenSim.Region.Framework.Scenes
3836 m_reprioritization_called = false; 4037 m_reprioritization_called = false;
3837 } 4038 }
3838 } 4039 }
4040
4041 private void CheckLandingPoint(ref Vector3 pos)
4042 {
4043 // Never constrain lures
4044 if ((TeleportFlags & TeleportFlags.ViaLure) != 0)
4045 return;
4046
4047 if (m_scene.RegionInfo.EstateSettings.AllowDirectTeleport)
4048 return;
4049
4050 ILandObject land = m_scene.LandChannel.GetLandObject(pos.X, pos.Y);
4051
4052 if (land.LandData.LandingType == (byte)LandingType.LandingPoint &&
4053 land.LandData.UserLocation != Vector3.Zero &&
4054 land.LandData.OwnerID != m_uuid &&
4055 (!m_scene.Permissions.IsGod(m_uuid)) &&
4056 (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)))
4057 {
4058 float curr = Vector3.Distance(AbsolutePosition, pos);
4059 if (Vector3.Distance(land.LandData.UserLocation, pos) < curr)
4060 pos = land.LandData.UserLocation;
4061 else
4062 ControllingClient.SendAlertMessage("Can't teleport closer to destination");
4063 }
4064 }
3839 } 4065 }
3840} 4066}