aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authormingchen2007-07-14 19:09:00 +0000
committermingchen2007-07-14 19:09:00 +0000
commit4f5c1e40b4852943d4657a93ae15351e413c5a87 (patch)
treec1736422da71fa611548e6b312d246c830878713 /OpenSim
parent* Added "quit" alias for the "shutdown" console command in RegionServer (diff)
downloadopensim-SC-4f5c1e40b4852943d4657a93ae15351e413c5a87.zip
opensim-SC-4f5c1e40b4852943d4657a93ae15351e413c5a87.tar.gz
opensim-SC-4f5c1e40b4852943d4657a93ae15351e413c5a87.tar.bz2
opensim-SC-4f5c1e40b4852943d4657a93ae15351e413c5a87.tar.xz
*Updated getParcel to accept floats as well. This helps in finding the parcel under an exact point (when precision matters)
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Environment/ParcelManager.cs21
1 files changed, 14 insertions, 7 deletions
diff --git a/OpenSim/Region/Environment/ParcelManager.cs b/OpenSim/Region/Environment/ParcelManager.cs
index 3603caa..1b8b16f 100644
--- a/OpenSim/Region/Environment/ParcelManager.cs
+++ b/OpenSim/Region/Environment/ParcelManager.cs
@@ -197,11 +197,20 @@ namespace OpenSim.Region.Environment
197 /// <returns>Parcel at the point supplied</returns> 197 /// <returns>Parcel at the point supplied</returns>
198 public Parcel getParcel(float x_float, float y_float) 198 public Parcel getParcel(float x_float, float y_float)
199 { 199 {
200 int x = Convert.ToInt32(Math.Floor(Convert.ToDouble(x_float))); 200 int x = Convert.ToInt32(Math.Floor(Convert.ToDecimal(x_float) / Convert.ToDecimal(4.0)));
201 int y = Convert.ToInt32(Math.Floor(Convert.ToDouble(y_float))); 201 int y = Convert.ToInt32(Math.Floor(Convert.ToDecimal(y_float) / Convert.ToDecimal(4.0)));
202 202
203 return getParcel(x, y); 203 if (x > 63 || y > 63 || x < 0 || y < 0)
204 {
205 throw new Exception("Error: Parcel not found at point " + x + ", " + y);
206 }
207 else
208 {
209 Console.WriteLine("Point (" + x + ", " + y + ") determined from point (" + x_float + ", " + y_float + ")");
210 return parcelList[parcelIDList[x, y]];
211 }
204 } 212 }
213
205 public Parcel getParcel(int x, int y) 214 public Parcel getParcel(int x, int y)
206 { 215 {
207 if (x > 256 || y > 256 || x < 0 || y < 0) 216 if (x > 256 || y > 256 || x < 0 || y < 0)
@@ -527,9 +536,7 @@ namespace OpenSim.Region.Environment
527 public void addPrimToParcelCounts(SceneObject obj) 536 public void addPrimToParcelCounts(SceneObject obj)
528 { 537 {
529 LLVector3 position = obj.rootPrimitive.Pos; 538 LLVector3 position = obj.rootPrimitive.Pos;
530 int pos_x = Convert.ToInt32(Math.Round(position.X)); 539 Parcel parcelUnderPrim = getParcel(position.X, position.Y);
531 int pos_y = Convert.ToInt32(Math.Round(position.Y));
532 Parcel parcelUnderPrim = getParcel(pos_x, pos_y);
533 if (parcelUnderPrim != null) 540 if (parcelUnderPrim != null)
534 { 541 {
535 parcelUnderPrim.addPrimToCount(obj); 542 parcelUnderPrim.addPrimToCount(obj);