aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework
diff options
context:
space:
mode:
authorKitto Flora2010-04-05 16:15:23 -0400
committerKitto Flora2010-04-05 16:15:23 -0400
commit4bf15989309b79e913a00ed8dcc19e35b7ebb9ce (patch)
tree93b1b5ec1ba53da1f2049df701e3230daab6c232 /OpenSim/Region/Framework
parentMerge branch 'master' of ssh://3dhosting.de/var/git/careminster (diff)
parentMerge branch 'master' of ssh://TOR/var/git/careminster (diff)
downloadopensim-SC-4bf15989309b79e913a00ed8dcc19e35b7ebb9ce.zip
opensim-SC-4bf15989309b79e913a00ed8dcc19e35b7ebb9ce.tar.gz
opensim-SC-4bf15989309b79e913a00ed8dcc19e35b7ebb9ce.tar.bz2
opensim-SC-4bf15989309b79e913a00ed8dcc19e35b7ebb9ce.tar.xz
Merge branch 'master' of ssh://3dhosting.de/var/git/careminster
Diffstat (limited to 'OpenSim/Region/Framework')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs10
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs56
2 files changed, 51 insertions, 15 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index fec8aa7..55f4550 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -1523,7 +1523,7 @@ namespace OpenSim.Region.Framework.Scenes
1523 public void SaveTerrain() 1523 public void SaveTerrain()
1524 { 1524 {
1525 m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); 1525 m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID);
1526 } 1526 }
1527 1527
1528 public void StoreWindlightProfile(RegionMeta7WindlightData wl) 1528 public void StoreWindlightProfile(RegionMeta7WindlightData wl)
1529 { 1529 {
@@ -4363,6 +4363,14 @@ namespace OpenSim.Region.Framework.Scenes
4363 } 4363 }
4364 4364
4365 /// <summary> 4365 /// <summary>
4366 /// Cheaply return the number of avatars in a region (without fetching a list object)
4367 /// </summary>
4368 public int GetRootAgentCount()
4369 {
4370 return m_sceneGraph.GetRootAgentCount();
4371 }
4372
4373 /// <summary>
4366 /// Return a list of all ScenePresences in this region. This returns child agents as well as root agents. 4374 /// Return a list of all ScenePresences in this region. This returns child agents as well as root agents.
4367 /// This list is a new object, so it can be iterated over without locking. 4375 /// This list is a new object, so it can be iterated over without locking.
4368 /// </summary> 4376 /// </summary>
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 5951a92..0277ed8 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -104,8 +104,12 @@ namespace OpenSim.Region.Framework.Scenes
104 /// since the group's last persistent backup 104 /// since the group's last persistent backup
105 /// </summary> 105 /// </summary>
106 private bool m_hasGroupChanged = false; 106 private bool m_hasGroupChanged = false;
107 private long timeFirstChanged; 107 private long timeFirstChanged = 0;
108 private long timeLastChanged; 108 private long timeLastChanged = 0;
109 long m_maxPersistTime = 0;
110 long m_minPersistTime = 0;
111 Random m_rand;
112
109 private System.Threading.ReaderWriterLockSlim m_partsLock = new System.Threading.ReaderWriterLockSlim(); 113 private System.Threading.ReaderWriterLockSlim m_partsLock = new System.Threading.ReaderWriterLockSlim();
110 114
111 public void lockPartsForRead(bool locked) 115 public void lockPartsForRead(bool locked)
@@ -182,6 +186,28 @@ namespace OpenSim.Region.Framework.Scenes
182 timeLastChanged = DateTime.Now.Ticks; 186 timeLastChanged = DateTime.Now.Ticks;
183 if (!m_hasGroupChanged) 187 if (!m_hasGroupChanged)
184 timeFirstChanged = DateTime.Now.Ticks; 188 timeFirstChanged = DateTime.Now.Ticks;
189 if (m_rand == null)
190 {
191 byte[] val = new byte[16];
192 m_rootPart.UUID.ToBytes(val, 0);
193 m_rand = new Random(BitConverter.ToInt32(val, 0));
194 }
195 if (Scene.GetRootAgentCount() == 0)
196 {
197 //If the region is empty, this change has been made by an automated process
198 //and thus we delay the persist time by a random amount between 1.5 and 2.5.
199
200 float factor = 1.5f + (float)(m_rand.NextDouble());
201 m_maxPersistTime = (long)((float)Scene.m_persistAfter * factor);
202 m_minPersistTime = (long)((float)Scene.m_dontPersistBefore * factor);
203 }
204 else
205 {
206 //If the region is not empty, we want to obey the minimum and maximum persist times
207 //but add a random factor so we stagger the object persistance a little
208 m_maxPersistTime = (long)((float)Scene.m_persistAfter * (1.0d - (m_rand.NextDouble() / 5.0d))); //Multiply by 1.0-1.5
209 m_minPersistTime = (long)((float)Scene.m_dontPersistBefore * (1.0d + (m_rand.NextDouble() / 2.0d))); //Multiply by 0.8-1.0
210 }
185 } 211 }
186 m_hasGroupChanged = value; 212 m_hasGroupChanged = value;
187 } 213 }
@@ -197,8 +223,19 @@ namespace OpenSim.Region.Framework.Scenes
197 return false; 223 return false;
198 if (m_scene.ShuttingDown) 224 if (m_scene.ShuttingDown)
199 return true; 225 return true;
226
227 if (m_minPersistTime == 0 || m_maxPersistTime == 0)
228 {
229 m_maxPersistTime = m_scene.m_persistAfter;
230 m_minPersistTime = m_scene.m_dontPersistBefore;
231 }
232
200 long currentTime = DateTime.Now.Ticks; 233 long currentTime = DateTime.Now.Ticks;
201 if (currentTime - timeLastChanged > m_scene.m_dontPersistBefore || currentTime - timeFirstChanged > m_scene.m_persistAfter) 234
235 if (timeLastChanged == 0) timeLastChanged = currentTime;
236 if (timeFirstChanged == 0) timeFirstChanged = currentTime;
237
238 if (currentTime - timeLastChanged > m_minPersistTime || currentTime - timeFirstChanged > m_maxPersistTime)
202 return true; 239 return true;
203 return false; 240 return false;
204 } 241 }
@@ -529,6 +566,7 @@ namespace OpenSim.Region.Framework.Scenes
529 /// </summary> 566 /// </summary>
530 public SceneObjectGroup() 567 public SceneObjectGroup()
531 { 568 {
569
532 } 570 }
533 571
534 /// <summary> 572 /// <summary>
@@ -545,7 +583,7 @@ namespace OpenSim.Region.Framework.Scenes
545 /// Constructor. This object is added to the scene later via AttachToScene() 583 /// Constructor. This object is added to the scene later via AttachToScene()
546 /// </summary> 584 /// </summary>
547 public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape) 585 public SceneObjectGroup(UUID ownerID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape)
548 { 586 {
549 SetRootPart(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero)); 587 SetRootPart(new SceneObjectPart(ownerID, shape, pos, rot, Vector3.Zero));
550 } 588 }
551 589
@@ -2203,13 +2241,7 @@ namespace OpenSim.Region.Framework.Scenes
2203 /// </summary> 2241 /// </summary>
2204 public void ScheduleGroupForTerseUpdate() 2242 public void ScheduleGroupForTerseUpdate()
2205 { 2243 {
2206<<<<<<< HEAD:OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
2207 lockPartsForRead(true); 2244 lockPartsForRead(true);
2208=======
2209// m_log.DebugFormat("[SOG]: Scheduling terse update for {0} {1}", Name, UUID);
2210
2211 lock (m_parts)
2212>>>>>>> 0.6.9-post-fixes:OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
2213 { 2245 {
2214 foreach (SceneObjectPart part in m_parts.Values) 2246 foreach (SceneObjectPart part in m_parts.Values)
2215 { 2247 {
@@ -3765,15 +3797,11 @@ namespace OpenSim.Region.Framework.Scenes
3765 3797
3766 HasGroupChanged = true; 3798 HasGroupChanged = true;
3767 } 3799 }
3768<<<<<<< HEAD:OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
3769 lockPartsForRead(false); 3800 lockPartsForRead(false);
3770 ScheduleGroupForFullUpdate();
3771=======
3772 3801
3773 // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled 3802 // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled
3774 // for the same object with very different properties. The caller must schedule the update. 3803 // for the same object with very different properties. The caller must schedule the update.
3775 //ScheduleGroupForFullUpdate(); 3804 //ScheduleGroupForFullUpdate();
3776>>>>>>> 0.6.9-post-fixes:OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
3777 } 3805 }
3778 3806
3779 public void TriggerScriptChangedEvent(Changed val) 3807 public void TriggerScriptChangedEvent(Changed val)