diff options
author | mingchen | 2007-07-14 15:11:36 +0000 |
---|---|---|
committer | mingchen | 2007-07-14 15:11:36 +0000 |
commit | 423d03eaefcae1bcaff8e4d16da014d350c91c42 (patch) | |
tree | 1caf9a940dc856be765b7b000d4360d954b6741a /OpenSim/Region/Environment | |
parent | Set up parcel manager and the master avatar in SimpleApp. (diff) | |
download | opensim-SC-423d03eaefcae1bcaff8e4d16da014d350c91c42.zip opensim-SC-423d03eaefcae1bcaff8e4d16da014d350c91c42.tar.gz opensim-SC-423d03eaefcae1bcaff8e4d16da014d350c91c42.tar.bz2 opensim-SC-423d03eaefcae1bcaff8e4d16da014d350c91c42.tar.xz |
*Added support for prim counting on parcels
**No restrictions yet in place, or total prim count
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/ParcelManager.cs | 117 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Primitive.cs | 26 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.cs | 23 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneEvents.cs | 11 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneObject.cs | 60 |
5 files changed, 217 insertions, 20 deletions
diff --git a/OpenSim/Region/Environment/ParcelManager.cs b/OpenSim/Region/Environment/ParcelManager.cs index b9c4067..981898f 100644 --- a/OpenSim/Region/Environment/ParcelManager.cs +++ b/OpenSim/Region/Environment/ParcelManager.cs | |||
@@ -75,6 +75,11 @@ namespace OpenSim.Region.Environment | |||
75 | private int lastParcelLocalID = START_PARCEL_LOCAL_ID - 1; | 75 | private int lastParcelLocalID = START_PARCEL_LOCAL_ID - 1; |
76 | private int[,] parcelIDList = new int[64, 64]; | 76 | private int[,] parcelIDList = new int[64, 64]; |
77 | 77 | ||
78 | /// <summary> | ||
79 | /// Set to true when a prim is moved, created, added. Performs a prim count update | ||
80 | /// </summary> | ||
81 | public bool parcelPrimCountTainted = false; | ||
82 | |||
78 | private Scene m_world; | 83 | private Scene m_world; |
79 | private RegionInfo m_regInfo; | 84 | private RegionInfo m_regInfo; |
80 | 85 | ||
@@ -190,6 +195,13 @@ namespace OpenSim.Region.Environment | |||
190 | /// <param name="x">Value between 0 - 256 on the x axis of the point</param> | 195 | /// <param name="x">Value between 0 - 256 on the x axis of the point</param> |
191 | /// <param name="y">Value between 0 - 256 on the y axis of the point</param> | 196 | /// <param name="y">Value between 0 - 256 on the y axis of the point</param> |
192 | /// <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) | ||
199 | { | ||
200 | int x = Convert.ToInt32(Math.Floor(Convert.ToDouble(x_float))); | ||
201 | int y = Convert.ToInt32(Math.Floor(Convert.ToDouble(y_float))); | ||
202 | |||
203 | return getParcel(x, y); | ||
204 | } | ||
193 | public Parcel getParcel(int x, int y) | 205 | public Parcel getParcel(int x, int y) |
194 | { | 206 | { |
195 | if (x > 256 || y > 256 || x < 0 || y < 0) | 207 | if (x > 256 || y > 256 || x < 0 || y < 0) |
@@ -200,7 +212,6 @@ namespace OpenSim.Region.Environment | |||
200 | { | 212 | { |
201 | return parcelList[parcelIDList[x / 4, y / 4]]; | 213 | return parcelList[parcelIDList[x / 4, y / 4]]; |
202 | } | 214 | } |
203 | |||
204 | } | 215 | } |
205 | #endregion | 216 | #endregion |
206 | 217 | ||
@@ -262,9 +273,11 @@ namespace OpenSim.Region.Environment | |||
262 | parcelList[startParcelIndex].setParcelBitmap(Parcel.modifyParcelBitmapSquare(startParcel.getParcelBitmap(), start_x, start_y, end_x, end_y, false)); | 273 | parcelList[startParcelIndex].setParcelBitmap(Parcel.modifyParcelBitmapSquare(startParcel.getParcelBitmap(), start_x, start_y, end_x, end_y, false)); |
263 | parcelList[startParcelIndex].forceUpdateParcelInfo(); | 274 | parcelList[startParcelIndex].forceUpdateParcelInfo(); |
264 | 275 | ||
276 | |||
277 | this.setPrimsTainted(); | ||
278 | |||
265 | //Now add the new parcel | 279 | //Now add the new parcel |
266 | Parcel result = addParcel(newParcel); | 280 | Parcel result = addParcel(newParcel); |
267 | |||
268 | result.sendParcelUpdateToAvatarsOverMe(); | 281 | result.sendParcelUpdateToAvatarsOverMe(); |
269 | 282 | ||
270 | 283 | ||
@@ -326,6 +339,8 @@ namespace OpenSim.Region.Environment | |||
326 | } | 339 | } |
327 | 340 | ||
328 | 341 | ||
342 | this.setPrimsTainted(); | ||
343 | |||
329 | masterParcel.sendParcelUpdateToAvatarsOverMe(); | 344 | masterParcel.sendParcelUpdateToAvatarsOverMe(); |
330 | 345 | ||
331 | return true; | 346 | return true; |
@@ -493,13 +508,46 @@ namespace OpenSim.Region.Environment | |||
493 | Avatar clientAvatar = m_world.RequestAvatar(remote_client.AgentId); | 508 | Avatar clientAvatar = m_world.RequestAvatar(remote_client.AgentId); |
494 | if (clientAvatar != null) | 509 | if (clientAvatar != null) |
495 | { | 510 | { |
496 | Parcel over = getParcel(Convert.ToInt32(clientAvatar.Pos.X), Convert.ToInt32(clientAvatar.Pos.Y)); | 511 | Parcel over = getParcel(clientAvatar.Pos.X,clientAvatar.Pos.Y); |
497 | if (over != null) | 512 | if (over != null) |
498 | { | 513 | { |
499 | over.sendParcelProperties(0, false, 0, remote_client); | 514 | over.sendParcelProperties(0, false, 0, remote_client); |
500 | } | 515 | } |
501 | } | 516 | } |
502 | } | 517 | } |
518 | |||
519 | public void resetAllParcelPrimCounts() | ||
520 | { | ||
521 | foreach (Parcel p in parcelList.Values) | ||
522 | { | ||
523 | p.resetParcelPrimCounts(); | ||
524 | } | ||
525 | } | ||
526 | |||
527 | public void addPrimToParcelCounts(SceneObject obj) | ||
528 | { | ||
529 | LLVector3 position = obj.rootPrimitive.Pos; | ||
530 | int pos_x = Convert.ToInt32(Math.Round(position.X)); | ||
531 | int pos_y = Convert.ToInt32(Math.Round(position.Y)); | ||
532 | Parcel parcelUnderPrim = getParcel(pos_x, pos_y); | ||
533 | if (parcelUnderPrim != null) | ||
534 | { | ||
535 | parcelUnderPrim.addPrimToCount(obj); | ||
536 | } | ||
537 | } | ||
538 | |||
539 | public void removePrimFromParcelCounts(SceneObject obj) | ||
540 | { | ||
541 | foreach (Parcel p in parcelList.Values) | ||
542 | { | ||
543 | p.removePrimFromCount(obj); | ||
544 | } | ||
545 | } | ||
546 | |||
547 | public void setPrimsTainted() | ||
548 | { | ||
549 | this.parcelPrimCountTainted = true; | ||
550 | } | ||
503 | #endregion | 551 | #endregion |
504 | } | 552 | } |
505 | #endregion | 553 | #endregion |
@@ -513,6 +561,8 @@ namespace OpenSim.Region.Environment | |||
513 | { | 561 | { |
514 | #region Member Variables | 562 | #region Member Variables |
515 | public ParcelData parcelData = new ParcelData(); | 563 | public ParcelData parcelData = new ParcelData(); |
564 | public List<SceneObject> primsOverMe = new List<SceneObject>(); | ||
565 | |||
516 | public Scene m_world; | 566 | public Scene m_world; |
517 | 567 | ||
518 | private bool[,] parcelBitmap = new bool[64, 64]; | 568 | private bool[,] parcelBitmap = new bool[64, 64]; |
@@ -602,9 +652,9 @@ namespace OpenSim.Region.Environment | |||
602 | updatePacket.ParcelData.Name = Helpers.StringToField(parcelData.parcelName); | 652 | updatePacket.ParcelData.Name = Helpers.StringToField(parcelData.parcelName); |
603 | updatePacket.ParcelData.OtherCleanTime = 0; //unemplemented | 653 | updatePacket.ParcelData.OtherCleanTime = 0; //unemplemented |
604 | updatePacket.ParcelData.OtherCount = 0; //unemplemented | 654 | updatePacket.ParcelData.OtherCount = 0; //unemplemented |
605 | updatePacket.ParcelData.OtherPrims = 0; //unemplented | 655 | updatePacket.ParcelData.OtherPrims = parcelData.groupPrims; |
606 | updatePacket.ParcelData.OwnerID = parcelData.ownerID; | 656 | updatePacket.ParcelData.OwnerID = parcelData.ownerID; |
607 | updatePacket.ParcelData.OwnerPrims = 0; //unemplemented | 657 | updatePacket.ParcelData.OwnerPrims = parcelData.ownerPrims; |
608 | updatePacket.ParcelData.ParcelFlags = parcelData.parcelFlags; | 658 | updatePacket.ParcelData.ParcelFlags = parcelData.parcelFlags; |
609 | updatePacket.ParcelData.ParcelPrimBonus = m_world.RegionInfo.estateSettings.objectBonusFactor; | 659 | updatePacket.ParcelData.ParcelPrimBonus = m_world.RegionInfo.estateSettings.objectBonusFactor; |
610 | updatePacket.ParcelData.PassHours = parcelData.passHours; | 660 | updatePacket.ParcelData.PassHours = parcelData.passHours; |
@@ -616,7 +666,7 @@ namespace OpenSim.Region.Environment | |||
616 | updatePacket.ParcelData.RegionPushOverride = (((uint)m_world.RegionInfo.estateSettings.regionFlags & (uint)Simulator.RegionFlags.RestrictPushObject) > 0); | 666 | updatePacket.ParcelData.RegionPushOverride = (((uint)m_world.RegionInfo.estateSettings.regionFlags & (uint)Simulator.RegionFlags.RestrictPushObject) > 0); |
617 | updatePacket.ParcelData.RentPrice = 0; | 667 | updatePacket.ParcelData.RentPrice = 0; |
618 | updatePacket.ParcelData.RequestResult = request_result; | 668 | updatePacket.ParcelData.RequestResult = request_result; |
619 | updatePacket.ParcelData.SalePrice = parcelData.salePrice; //unemplemented | 669 | updatePacket.ParcelData.SalePrice = parcelData.salePrice; |
620 | updatePacket.ParcelData.SelectedPrims = 0; //unemeplemented | 670 | updatePacket.ParcelData.SelectedPrims = 0; //unemeplemented |
621 | updatePacket.ParcelData.SelfCount = 0;//unemplemented | 671 | updatePacket.ParcelData.SelfCount = 0;//unemplemented |
622 | updatePacket.ParcelData.SequenceID = sequence_id; | 672 | updatePacket.ParcelData.SequenceID = sequence_id; |
@@ -625,7 +675,7 @@ namespace OpenSim.Region.Environment | |||
625 | updatePacket.ParcelData.SnapSelection = snap_selection; | 675 | updatePacket.ParcelData.SnapSelection = snap_selection; |
626 | updatePacket.ParcelData.SnapshotID = parcelData.snapshotID; | 676 | updatePacket.ParcelData.SnapshotID = parcelData.snapshotID; |
627 | updatePacket.ParcelData.Status = (byte)parcelData.parcelStatus; | 677 | updatePacket.ParcelData.Status = (byte)parcelData.parcelStatus; |
628 | updatePacket.ParcelData.TotalPrims = 0; //unemplemented | 678 | updatePacket.ParcelData.TotalPrims = parcelData.ownerPrims + parcelData.groupPrims + parcelData.otherPrims; |
629 | updatePacket.ParcelData.UserLocation = parcelData.userLocation; | 679 | updatePacket.ParcelData.UserLocation = parcelData.userLocation; |
630 | updatePacket.ParcelData.UserLookAt = parcelData.userLookAt; | 680 | updatePacket.ParcelData.UserLookAt = parcelData.userLookAt; |
631 | remote_client.OutPacket((Packet)updatePacket); | 681 | remote_client.OutPacket((Packet)updatePacket); |
@@ -900,6 +950,59 @@ namespace OpenSim.Region.Environment | |||
900 | } | 950 | } |
901 | #endregion | 951 | #endregion |
902 | 952 | ||
953 | public void resetParcelPrimCounts() | ||
954 | { | ||
955 | parcelData.groupPrims = 0; | ||
956 | parcelData.ownerPrims = 0; | ||
957 | parcelData.groupPrims = 0; | ||
958 | primsOverMe.Clear(); | ||
959 | } | ||
960 | |||
961 | public void addPrimToCount(SceneObject obj) | ||
962 | { | ||
963 | LLUUID prim_owner = obj.rootPrimitive.OwnerID; | ||
964 | int prim_count = obj.primCount; | ||
965 | |||
966 | if(prim_owner == parcelData.ownerID) | ||
967 | { | ||
968 | parcelData.ownerPrims += prim_count; | ||
969 | } | ||
970 | else if (prim_owner == parcelData.groupID) | ||
971 | { | ||
972 | parcelData.groupPrims += prim_count; | ||
973 | } | ||
974 | else | ||
975 | { | ||
976 | parcelData.otherPrims += prim_count; | ||
977 | } | ||
978 | primsOverMe.Add(obj); | ||
979 | |||
980 | } | ||
981 | |||
982 | public void removePrimFromCount(SceneObject obj) | ||
983 | { | ||
984 | if (primsOverMe.Contains(obj)) | ||
985 | { | ||
986 | LLUUID prim_owner = obj.rootPrimitive.OwnerID; | ||
987 | int prim_count = obj.primCount; | ||
988 | |||
989 | if (prim_owner == parcelData.ownerID) | ||
990 | { | ||
991 | parcelData.ownerPrims -= prim_count; | ||
992 | } | ||
993 | else if (prim_owner == parcelData.groupID) | ||
994 | { | ||
995 | parcelData.groupPrims -= prim_count; | ||
996 | } | ||
997 | else | ||
998 | { | ||
999 | parcelData.otherPrims -= prim_count; | ||
1000 | } | ||
1001 | |||
1002 | primsOverMe.Remove(obj); | ||
1003 | } | ||
1004 | } | ||
1005 | |||
903 | #endregion | 1006 | #endregion |
904 | 1007 | ||
905 | 1008 | ||
diff --git a/OpenSim/Region/Environment/Scenes/Primitive.cs b/OpenSim/Region/Environment/Scenes/Primitive.cs index e20870f..79d5785 100644 --- a/OpenSim/Region/Environment/Scenes/Primitive.cs +++ b/OpenSim/Region/Environment/Scenes/Primitive.cs | |||
@@ -45,6 +45,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
45 | public bool m_isRootPrim; | 45 | public bool m_isRootPrim; |
46 | public EntityBase m_Parent; | 46 | public EntityBase m_Parent; |
47 | 47 | ||
48 | private ParcelManager m_parcelManager; | ||
49 | |||
48 | #region Properties | 50 | #region Properties |
49 | /// <summary> | 51 | /// <summary> |
50 | /// If rootprim, will return world position | 52 | /// If rootprim, will return world position |
@@ -130,10 +132,12 @@ namespace OpenSim.Region.Environment.Scenes | |||
130 | /// <param name="isRoot"></param> | 132 | /// <param name="isRoot"></param> |
131 | /// <param name="parent"></param> | 133 | /// <param name="parent"></param> |
132 | /// <param name="rootObject"></param> | 134 | /// <param name="rootObject"></param> |
133 | public Primitive(ulong regionHandle, Scene world, LLUUID ownerID, uint localID, bool isRoot, EntityBase parent, SceneObject rootObject, PrimitiveBaseShape shape, LLVector3 pos) | 135 | public Primitive(ulong regionHandle, Scene world, ParcelManager parcelManager, LLUUID ownerID, uint localID, bool isRoot, EntityBase parent, SceneObject rootObject, PrimitiveBaseShape shape, LLVector3 pos) |
134 | { | 136 | { |
137 | |||
135 | m_regionHandle = regionHandle; | 138 | m_regionHandle = regionHandle; |
136 | m_world = world; | 139 | m_world = world; |
140 | m_parcelManager = parcelManager; | ||
137 | inventoryItems = new Dictionary<LLUUID, InventoryItem>(); | 141 | inventoryItems = new Dictionary<LLUUID, InventoryItem>(); |
138 | this.m_Parent = parent; | 142 | this.m_Parent = parent; |
139 | this.m_isRootPrim = isRoot; | 143 | this.m_isRootPrim = isRoot; |
@@ -141,6 +145,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
141 | 145 | ||
142 | this.CreateFromShape(ownerID, localID, pos, shape); | 146 | this.CreateFromShape(ownerID, localID, pos, shape); |
143 | this.Rotation = Axiom.Math.Quaternion.Identity; | 147 | this.Rotation = Axiom.Math.Quaternion.Identity; |
148 | |||
149 | |||
150 | m_parcelManager.setPrimsTainted(); | ||
144 | } | 151 | } |
145 | 152 | ||
146 | /// <summary> | 153 | /// <summary> |
@@ -149,11 +156,19 @@ namespace OpenSim.Region.Environment.Scenes | |||
149 | /// <remarks>Empty constructor for duplication</remarks> | 156 | /// <remarks>Empty constructor for duplication</remarks> |
150 | public Primitive() | 157 | public Primitive() |
151 | { | 158 | { |
152 | 159 | m_parcelManager.setPrimsTainted(); | |
153 | } | 160 | } |
154 | 161 | ||
155 | #endregion | 162 | #endregion |
156 | 163 | ||
164 | #region Destructors | ||
165 | |||
166 | ~Primitive() | ||
167 | { | ||
168 | m_parcelManager.setPrimsTainted(); | ||
169 | } | ||
170 | #endregion | ||
171 | |||
157 | #region Duplication | 172 | #region Duplication |
158 | 173 | ||
159 | public Primitive Copy(EntityBase parent, SceneObject rootParent) | 174 | public Primitive Copy(EntityBase parent, SceneObject rootParent) |
@@ -260,6 +275,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
260 | 275 | ||
261 | this.m_world.DeleteEntity(linkObject.rootUUID); | 276 | this.m_world.DeleteEntity(linkObject.rootUUID); |
262 | linkObject.DeleteAllChildren(); | 277 | linkObject.DeleteAllChildren(); |
278 | |||
279 | m_parcelManager.setPrimsTainted(); | ||
263 | } | 280 | } |
264 | 281 | ||
265 | /// <summary> | 282 | /// <summary> |
@@ -335,6 +352,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
335 | prim.m_pos += offset; | 352 | prim.m_pos += offset; |
336 | prim.updateFlag = 2; | 353 | prim.updateFlag = 2; |
337 | } | 354 | } |
355 | m_parcelManager.setPrimsTainted(); | ||
338 | } | 356 | } |
339 | 357 | ||
340 | /// <summary> | 358 | /// <summary> |
@@ -385,6 +403,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
385 | 403 | ||
386 | this.Pos = newPos; | 404 | this.Pos = newPos; |
387 | this.updateFlag = 2; | 405 | this.updateFlag = 2; |
406 | |||
407 | m_parcelManager.setPrimsTainted(); | ||
388 | } | 408 | } |
389 | 409 | ||
390 | /// <summary> | 410 | /// <summary> |
@@ -419,6 +439,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
419 | this.m_pos = newPos; | 439 | this.m_pos = newPos; |
420 | this.updateFlag = 2; | 440 | this.updateFlag = 2; |
421 | } | 441 | } |
442 | |||
443 | m_parcelManager.setPrimsTainted(); | ||
422 | } | 444 | } |
423 | 445 | ||
424 | #endregion | 446 | #endregion |
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 01e6752..81bab9a 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -59,6 +59,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
59 | private uint _primCount = 702000; | 59 | private uint _primCount = 702000; |
60 | private System.Threading.Mutex _primAllocateMutex = new Mutex(false); | 60 | private System.Threading.Mutex _primAllocateMutex = new Mutex(false); |
61 | private int storageCount; | 61 | private int storageCount; |
62 | private int parcelPrimCheckCount; | ||
62 | private Mutex updateLock; | 63 | private Mutex updateLock; |
63 | 64 | ||
64 | protected AuthenticateSessionsBase authenticateHandler; | 65 | protected AuthenticateSessionsBase authenticateHandler; |
@@ -144,6 +145,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
144 | Terrain = new TerrainEngine(); | 145 | Terrain = new TerrainEngine(); |
145 | 146 | ||
146 | ScenePresence.LoadAnims(); | 147 | ScenePresence.LoadAnims(); |
148 | |||
149 | this.performParcelPrimCountUpdate(); | ||
147 | this.httpListener = httpServer; | 150 | this.httpListener = httpServer; |
148 | } | 151 | } |
149 | #endregion | 152 | #endregion |
@@ -211,6 +214,18 @@ namespace OpenSim.Region.Environment.Scenes | |||
211 | this.Backup(); | 214 | this.Backup(); |
212 | storageCount = 0; | 215 | storageCount = 0; |
213 | } | 216 | } |
217 | |||
218 | this.parcelPrimCheckCount++; | ||
219 | if (this.parcelPrimCheckCount > 50) //check every 5 seconds for tainted prims | ||
220 | { | ||
221 | if (m_parcelManager.parcelPrimCountTainted) | ||
222 | { | ||
223 | //Perform parcel update of prim count | ||
224 | performParcelPrimCountUpdate(); | ||
225 | this.parcelPrimCheckCount = 0; | ||
226 | } | ||
227 | } | ||
228 | |||
214 | } | 229 | } |
215 | catch (Exception e) | 230 | catch (Exception e) |
216 | { | 231 | { |
@@ -441,7 +456,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
441 | { | 456 | { |
442 | try | 457 | try |
443 | { | 458 | { |
444 | SceneObject sceneOb = new SceneObject(m_regionHandle, this, ownerID, this.PrimIDAllocate(), pos, shape); | 459 | SceneObject sceneOb = new SceneObject(m_regionHandle, this, this.m_eventManager,this.m_parcelManager, ownerID, this.PrimIDAllocate(), pos, shape); |
445 | this.Entities.Add(sceneOb.rootUUID, sceneOb); | 460 | this.Entities.Add(sceneOb.rootUUID, sceneOb); |
446 | 461 | ||
447 | // Trigger event for listeners | 462 | // Trigger event for listeners |
@@ -809,6 +824,12 @@ namespace OpenSim.Region.Environment.Scenes | |||
809 | return this.commsManager.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position); | 824 | return this.commsManager.InterRegion.ExpectAvatarCrossing(regionhandle, agentID, position); |
810 | } | 825 | } |
811 | 826 | ||
827 | public void performParcelPrimCountUpdate() | ||
828 | { | ||
829 | m_parcelManager.resetAllParcelPrimCounts(); | ||
830 | m_eventManager.TriggerParcelPrimCountUpdate(); | ||
831 | m_parcelManager.parcelPrimCountTainted = false; | ||
832 | } | ||
812 | #endregion | 833 | #endregion |
813 | 834 | ||
814 | } | 835 | } |
diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs index deecfd5..685ed8c 100644 --- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs +++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs | |||
@@ -19,6 +19,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
19 | public delegate void OnRemovePresenceDelegate(LLUUID uuid); | 19 | public delegate void OnRemovePresenceDelegate(LLUUID uuid); |
20 | public event OnRemovePresenceDelegate OnRemovePresence; | 20 | public event OnRemovePresenceDelegate OnRemovePresence; |
21 | 21 | ||
22 | public delegate void OnParcelPrimCountUpdateDelegate(); | ||
23 | public event OnParcelPrimCountUpdateDelegate OnParcelPrimCountUpdate; | ||
24 | |||
22 | public void TriggerOnFrame() | 25 | public void TriggerOnFrame() |
23 | { | 26 | { |
24 | if (OnFrame != null) | 27 | if (OnFrame != null) |
@@ -48,5 +51,13 @@ namespace OpenSim.Region.Environment.Scenes | |||
48 | OnBackup(dstore); | 51 | OnBackup(dstore); |
49 | } | 52 | } |
50 | } | 53 | } |
54 | |||
55 | public void TriggerParcelPrimCountUpdate() | ||
56 | { | ||
57 | if (OnParcelPrimCountUpdate != null) | ||
58 | { | ||
59 | OnParcelPrimCountUpdate(); | ||
60 | } | ||
61 | } | ||
51 | } | 62 | } |
52 | } | 63 | } |
diff --git a/OpenSim/Region/Environment/Scenes/SceneObject.cs b/OpenSim/Region/Environment/Scenes/SceneObject.cs index d1a3e70..f4c4083 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObject.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObject.cs | |||
@@ -47,6 +47,9 @@ namespace OpenSim.Region.Environment.Scenes | |||
47 | private PhysicsScene m_PhysScene; | 47 | private PhysicsScene m_PhysScene; |
48 | private PhysicsActor m_PhysActor; | 48 | private PhysicsActor m_PhysActor; |
49 | 49 | ||
50 | private EventManager m_eventManager; | ||
51 | private ParcelManager m_parcelManager; | ||
52 | |||
50 | public LLUUID rootUUID | 53 | public LLUUID rootUUID |
51 | { | 54 | { |
52 | get | 55 | get |
@@ -65,38 +68,71 @@ namespace OpenSim.Region.Environment.Scenes | |||
65 | } | 68 | } |
66 | } | 69 | } |
67 | 70 | ||
71 | public int primCount | ||
72 | { | ||
73 | get | ||
74 | { | ||
75 | return this.ChildPrimitives.Count; | ||
76 | } | ||
77 | } | ||
78 | |||
68 | /// <summary> | 79 | /// <summary> |
69 | /// | 80 | /// |
70 | /// </summary> | 81 | /// </summary> |
71 | public SceneObject(ulong regionHandle, Scene world, LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape) | 82 | public SceneObject(ulong regionHandle, Scene world, EventManager eventManager, ParcelManager parcelManager, LLUUID ownerID, uint localID, LLVector3 pos, PrimitiveBaseShape shape) |
72 | { | 83 | { |
73 | m_regionHandle = regionHandle; | 84 | m_regionHandle = regionHandle; |
74 | m_world = world; | 85 | m_world = world; |
86 | m_eventManager = eventManager; | ||
87 | m_parcelManager = parcelManager; | ||
88 | |||
75 | this.Pos = pos; | 89 | this.Pos = pos; |
76 | this.CreateRootFromShape(ownerID, localID, shape, pos); | 90 | this.CreateRootFromShape(ownerID, localID, shape, pos); |
77 | 91 | ||
78 | // Setup a backup event listener | 92 | registerEvents(); |
79 | world.EventManager.OnBackup += new EventManager.OnBackupDelegate(ProcessBackup); | 93 | |
94 | } | ||
95 | |||
96 | /// <summary> | ||
97 | /// | ||
98 | /// </summary> | ||
99 | /// <remarks>Need a null constructor for duplication</remarks> | ||
100 | public SceneObject() | ||
101 | { | ||
102 | |||
80 | } | 103 | } |
81 | 104 | ||
105 | public void registerEvents() | ||
106 | { | ||
107 | m_eventManager.OnBackup += new EventManager.OnBackupDelegate(ProcessBackup); | ||
108 | m_eventManager.OnParcelPrimCountUpdate += new EventManager.OnParcelPrimCountUpdateDelegate(ProcessParcelPrimCountUpdate); | ||
109 | } | ||
110 | public void unregisterEvents() | ||
111 | { | ||
112 | m_eventManager.OnBackup -= new EventManager.OnBackupDelegate(ProcessBackup); | ||
113 | m_eventManager.OnParcelPrimCountUpdate -= new EventManager.OnParcelPrimCountUpdateDelegate(ProcessParcelPrimCountUpdate); | ||
114 | } | ||
82 | /// <summary> | 115 | /// <summary> |
83 | /// Processes backup | 116 | /// Processes backup |
84 | /// </summary> | 117 | /// </summary> |
85 | /// <param name="datastore"></param> | 118 | /// <param name="datastore"></param> |
86 | void ProcessBackup(OpenSim.Region.Interfaces.IRegionDataStore datastore) | 119 | public void ProcessBackup(OpenSim.Region.Interfaces.IRegionDataStore datastore) |
87 | { | 120 | { |
88 | datastore.StoreObject(this); | 121 | datastore.StoreObject(this); |
89 | } | 122 | } |
90 | 123 | ||
124 | |||
91 | /// <summary> | 125 | /// <summary> |
92 | /// | 126 | /// Sends my primitive info to the parcel manager for it to keep tally of all of the prims! |
93 | /// </summary> | 127 | /// </summary> |
94 | /// <remarks>Need a null constructor for duplication</remarks> | 128 | private void ProcessParcelPrimCountUpdate() |
95 | public SceneObject() | ||
96 | { | 129 | { |
97 | 130 | m_parcelManager.addPrimToParcelCounts(this); | |
98 | } | 131 | } |
99 | 132 | ||
133 | |||
134 | |||
135 | |||
100 | /// <summary> | 136 | /// <summary> |
101 | /// | 137 | /// |
102 | /// </summary> | 138 | /// </summary> |
@@ -105,7 +141,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
105 | /// <param name="localID"></param> | 141 | /// <param name="localID"></param> |
106 | public void CreateRootFromShape(LLUUID agentID, uint localID, PrimitiveBaseShape shape, LLVector3 pos) | 142 | public void CreateRootFromShape(LLUUID agentID, uint localID, PrimitiveBaseShape shape, LLVector3 pos) |
107 | { | 143 | { |
108 | this.rootPrimitive = new Primitive(this.m_regionHandle, this.m_world, agentID, localID, true, this, this, shape, pos); | 144 | this.rootPrimitive = new Primitive(this.m_regionHandle, this.m_world,this.m_parcelManager, agentID, localID, true, this, this, shape, pos); |
109 | this.children.Add(rootPrimitive); | 145 | this.children.Add(rootPrimitive); |
110 | this.ChildPrimitives.Add(this.rootUUID, this.rootPrimitive); | 146 | this.ChildPrimitives.Add(this.rootUUID, this.rootPrimitive); |
111 | } | 147 | } |
@@ -120,7 +156,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
120 | } | 156 | } |
121 | 157 | ||
122 | /// <summary> | 158 | /// <summary> |
123 | /// | 159 | /// Copies a prim or group of prims (SceneObject) -- TODO: cleanup code |
124 | /// </summary> | 160 | /// </summary> |
125 | /// <returns>A complete copy of the object</returns> | 161 | /// <returns>A complete copy of the object</returns> |
126 | public new SceneObject Copy() | 162 | public new SceneObject Copy() |
@@ -136,6 +172,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
136 | dupe.Rotation = this.Rotation; | 172 | dupe.Rotation = this.Rotation; |
137 | LLUUID rootu= dupe.rootUUID; | 173 | LLUUID rootu= dupe.rootUUID; |
138 | uint rooti = dupe.rootLocalID; | 174 | uint rooti = dupe.rootLocalID; |
175 | |||
176 | dupe.registerEvents(); | ||
139 | return dupe; | 177 | return dupe; |
140 | } | 178 | } |
141 | 179 | ||
@@ -147,6 +185,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
147 | this.children.Clear(); | 185 | this.children.Clear(); |
148 | this.ChildPrimitives.Clear(); | 186 | this.ChildPrimitives.Clear(); |
149 | this.rootPrimitive = null; | 187 | this.rootPrimitive = null; |
188 | unregisterEvents(); | ||
150 | } | 189 | } |
151 | 190 | ||
152 | /// <summary> | 191 | /// <summary> |
@@ -256,5 +295,6 @@ namespace OpenSim.Region.Environment.Scenes | |||
256 | 295 | ||
257 | client.OutPacket(proper); | 296 | client.OutPacket(proper); |
258 | } | 297 | } |
298 | |||
259 | } | 299 | } |
260 | } | 300 | } |