aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorUbitUmarov2015-12-15 18:19:08 +0000
committerUbitUmarov2015-12-15 18:19:08 +0000
commit9327bb25461bdd5d0e76c98756d3bace3d638af5 (patch)
tree27be2513740cebfdbc9042ac6671ac7c92c2c199 /OpenSim
parentremove replaced code (diff)
downloadopensim-SC-9327bb25461bdd5d0e76c98756d3bace3d638af5.zip
opensim-SC-9327bb25461bdd5d0e76c98756d3bace3d638af5.tar.gz
opensim-SC-9327bb25461bdd5d0e76c98756d3bace3d638af5.tar.bz2
opensim-SC-9327bb25461bdd5d0e76c98756d3bace3d638af5.tar.xz
a few more changes on parcels location finding
Diffstat (limited to 'OpenSim')
-rwxr-xr-xOpenSim/Region/Framework/Scenes/Scene.cs89
1 files changed, 44 insertions, 45 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 1dbfa6d..5c5e4b3 100755
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -5787,8 +5787,6 @@ Environment.Exit(1);
5787 5787
5788 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, pos.X, pos.Y, excludeParcel); 5788 ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, pos.X, pos.Y, excludeParcel);
5789 5789
5790 Vector3 retPos = Vector3.Zero;
5791
5792 if (nearestParcel != null) 5790 if (nearestParcel != null)
5793 { 5791 {
5794 Vector2? nearestPoint = null; 5792 Vector2? nearestPoint = null;
@@ -5803,14 +5801,8 @@ Environment.Exit(1);
5803 5801
5804 if (nearestPoint != null) 5802 if (nearestPoint != null)
5805 { 5803 {
5806 retPos.X = nearestPoint.Value.X; 5804 return GetPositionAtAvatarHeightOrGroundHeight(avatar,
5807 retPos.Y = nearestPoint.Value.Y; 5805 nearestPoint.Value.X, nearestPoint.Value.Y);
5808 float h = GetGroundHeight(retPos.X, retPos.Y) + 0.8f;
5809 if(pos.Z > h)
5810 retPos.Z = pos.Z;
5811 else
5812 retPos.Z = h;
5813 return retPos;
5814 } 5806 }
5815 5807
5816 ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y); 5808 ILandObject dest = LandChannel.GetLandObject(avatar.lastKnownAllowedPosition.X, avatar.lastKnownAllowedPosition.Y);
@@ -5845,18 +5837,30 @@ Environment.Exit(1);
5845 5837
5846 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel) 5838 public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel)
5847 { 5839 {
5848 List<ILandObject> all = AllParcels(); 5840 if(LandChannel == null)
5849 float minParcelDistance = float.MaxValue; 5841 return null;
5842
5843 List<ILandObject> all = LandChannel.AllParcels();
5844
5845 if(all == null || all.Count == 0)
5846 return null;
5847
5848 float minParcelDistanceSQ = float.MaxValue;
5850 ILandObject nearestParcel = null; 5849 ILandObject nearestParcel = null;
5850 Vector2 curCenter;
5851 float parcelDistanceSQ;
5851 5852
5852 foreach (var parcel in all) 5853 foreach (var parcel in all)
5853 { 5854 {
5854 if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel) 5855 if (parcel != excludeParcel && !parcel.IsEitherBannedOrRestricted(avatarId))
5855 { 5856 {
5856 float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); 5857 curCenter = parcel.CenterPoint;
5857 if (parcelDistance < minParcelDistance) 5858 curCenter.X -= x;
5859 curCenter.Y -= y;
5860 parcelDistanceSQ = curCenter.LengthSquared();
5861 if (parcelDistanceSQ < minParcelDistanceSQ)
5858 { 5862 {
5859 minParcelDistance = parcelDistance; 5863 minParcelDistanceSQ = parcelDistanceSQ;
5860 nearestParcel = parcel; 5864 nearestParcel = parcel;
5861 } 5865 }
5862 } 5866 }
@@ -5865,57 +5869,52 @@ Environment.Exit(1);
5865 return nearestParcel; 5869 return nearestParcel;
5866 } 5870 }
5867 5871
5868 private List<ILandObject> AllParcels()
5869 {
5870 return LandChannel.AllParcels();
5871 }
5872
5873 private Vector2 GetParcelSafeCorner(ILandObject parcel) 5872 private Vector2 GetParcelSafeCorner(ILandObject parcel)
5874 { 5873 {
5875 return parcel.StartPoint; 5874 Vector2 place = parcel.StartPoint;
5876 } 5875 place.X += 2f;
5877 5876 place.Y += 2f;
5878 private float GetParcelDistancefromPoint(ILandObject parcel, float x, float y) 5877 return place;
5879 {
5880 return Vector2.Distance(new Vector2(x, y), parcel.CenterPoint);
5881 } 5878 }
5882 5879
5883 private Vector3 GetNearestRegionEdgePosition(ScenePresence avatar) 5880 private Vector3 GetNearestRegionEdgePosition(ScenePresence avatar)
5884 { 5881 {
5885 float xdistance = avatar.AbsolutePosition.X < RegionInfo.RegionSizeX / 2 5882 float posX = avatar.AbsolutePosition.X;
5886 ? avatar.AbsolutePosition.X : RegionInfo.RegionSizeX - avatar.AbsolutePosition.X; 5883 float posY = avatar.AbsolutePosition.Y;
5887 float ydistance = avatar.AbsolutePosition.Y < RegionInfo.RegionSizeY / 2 5884 float regionSizeX = RegionInfo.RegionSizeX;
5888 ? avatar.AbsolutePosition.Y : RegionInfo.RegionSizeY - avatar.AbsolutePosition.Y; 5885 float halfRegionSizeX = regionSizeX * 0.5f;
5886 float regionSizeY = RegionInfo.RegionSizeY;
5887 float halfRegionSizeY = regionSizeY * 0.5f;
5888
5889 float xdistance = posX < halfRegionSizeX ? posX : regionSizeX - posX;
5890 float ydistance = posY < halfRegionSizeY ? posY : regionSizeY - posY;
5889 5891
5890 //find out what vertical edge to go to 5892 //find out what vertical edge to go to
5891 if (xdistance < ydistance) 5893 if (xdistance < ydistance)
5892 { 5894 {
5893 if (avatar.AbsolutePosition.X < RegionInfo.RegionSizeX / 2) 5895 if (posX < halfRegionSizeX)
5894 { 5896 return GetPositionAtAvatarHeightOrGroundHeight(avatar, 0.5f, posY);
5895 return GetPositionAtAvatarHeightOrGroundHeight(avatar, 0.0f, avatar.AbsolutePosition.Y);
5896 }
5897 else 5897 else
5898 { 5898 return GetPositionAtAvatarHeightOrGroundHeight(avatar, regionSizeX - 0.5f, posY);
5899 return GetPositionAtAvatarHeightOrGroundHeight(avatar, RegionInfo.RegionSizeY, avatar.AbsolutePosition.Y);
5900 }
5901 } 5899 }
5902 //find out what horizontal edge to go to 5900 //find out what horizontal edge to go to
5903 else 5901 else
5904 { 5902 {
5905 if (avatar.AbsolutePosition.Y < RegionInfo.RegionSizeY / 2) 5903 if (posY < halfRegionSizeY)
5906 { 5904 return GetPositionAtAvatarHeightOrGroundHeight(avatar, posX, 0.5f);
5907 return GetPositionAtAvatarHeightOrGroundHeight(avatar, avatar.AbsolutePosition.X, 0.0f);
5908 }
5909 else 5905 else
5910 { 5906 return GetPositionAtAvatarHeightOrGroundHeight(avatar, posX, regionSizeY - 0.5f);
5911 return GetPositionAtAvatarHeightOrGroundHeight(avatar, avatar.AbsolutePosition.X, RegionInfo.RegionSizeY);
5912 }
5913 } 5907 }
5914 } 5908 }
5915 5909
5916 private Vector3 GetPositionAtAvatarHeightOrGroundHeight(ScenePresence avatar, float x, float y) 5910 private Vector3 GetPositionAtAvatarHeightOrGroundHeight(ScenePresence avatar, float x, float y)
5917 { 5911 {
5918 Vector3 ground = GetPositionAtGround(x, y); 5912 Vector3 ground = GetPositionAtGround(x, y);
5913 if(avatar.Appearance != null)
5914 ground.Z += avatar.Appearance.AvatarHeight * 0.5f;
5915 else
5916 ground.Z += 0.8f;
5917
5919 if (avatar.AbsolutePosition.Z > ground.Z) 5918 if (avatar.AbsolutePosition.Z > ground.Z)
5920 { 5919 {
5921 ground.Z = avatar.AbsolutePosition.Z; 5920 ground.Z = avatar.AbsolutePosition.Z;