aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
diff options
context:
space:
mode:
authorDan Lake2011-11-02 14:59:00 -0700
committerDan Lake2011-11-02 14:59:00 -0700
commite2c51a977d42822fe78ae0744117afb7bf509d35 (patch)
treebf145756d32fec7dc295510269447f458ccaf1ea /OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
parentRemoved redundant SceneContents property from Scene. It's the same as SceneGr... (diff)
downloadopensim-SC_OLD-e2c51a977d42822fe78ae0744117afb7bf509d35.zip
opensim-SC_OLD-e2c51a977d42822fe78ae0744117afb7bf509d35.tar.gz
opensim-SC_OLD-e2c51a977d42822fe78ae0744117afb7bf509d35.tar.bz2
opensim-SC_OLD-e2c51a977d42822fe78ae0744117afb7bf509d35.tar.xz
Changes UpdateFlag in SOP to an enumeration of NONE, TERSE and FULL.
UpdateFlag is now referenced/used only within SOP and SOG. Outsiders are using ScheduleFullUpdate, ScheduleTerseUpdate or ClearUpdateSchedule on SOP consistently now. Also started working toward eliminating those calls to ScheduleFullUpdate, ScheduleTerseUpdate or ClearUpdateSchedule from outside SOP in favor of just setting properties on SOP and let SOP decide if an update should be scheduled. This consolidates the update policy within SOP and the client rather than everywhere that makes changes to SOP. Some places forget to call update while others call it multiple times, "just to be sure". UpdateFlag and Schedule*Update will both be made private shortly. UpdateFlag is intended to be transient and internal to SOP so it has been removed from XML serializer for SOPs.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs101
1 files changed, 51 insertions, 50 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index b68cc9f..44f822c 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -106,6 +106,13 @@ namespace OpenSim.Region.Framework.Scenes
106 SCULPT = 7 106 SCULPT = 7
107 } 107 }
108 108
109 public enum UpdateRequired : byte
110 {
111 NONE = 0,
112 TERSE = 1,
113 FULL = 2
114 }
115
109 #endregion Enumerations 116 #endregion Enumerations
110 117
111 public class SceneObjectPart : IScriptHost, ISceneEntity 118 public class SceneObjectPart : IScriptHost, ISceneEntity
@@ -254,15 +261,7 @@ namespace OpenSim.Region.Framework.Scenes
254 261
255 private bool m_passTouches; 262 private bool m_passTouches;
256 263
257 /// <summary> 264 private UpdateRequired m_updateFlag;
258 /// Only used internally to schedule client updates.
259 /// 0 - no update is scheduled
260 /// 1 - terse update scheduled
261 /// 2 - full update scheduled
262 ///
263 /// TODO - This should be an enumeration
264 /// </summary>
265 private byte m_updateFlag;
266 265
267 private PhysicsActor m_physActor; 266 private PhysicsActor m_physActor;
268 protected Vector3 m_acceleration; 267 protected Vector3 m_acceleration;
@@ -884,7 +883,15 @@ namespace OpenSim.Region.Framework.Scenes
884 } 883 }
885 } 884 }
886 885
887 /// <summary></summary> 886 /// <summary>Update angular velocity and schedule terse update.</summary>
887 public void UpdateAngularVelocity(Vector3 avel)
888 {
889 AngularVelocity = avel;
890 ScheduleTerseUpdate();
891 ParentGroup.HasGroupChanged = true;
892 }
893
894 /// <summary>Get or set angular velocity. Does not schedule update.</summary>
888 public Vector3 AngularVelocity 895 public Vector3 AngularVelocity
889 { 896 {
890 get 897 get
@@ -1023,8 +1030,8 @@ namespace OpenSim.Region.Framework.Scenes
1023 TriggerScriptChangedEvent(Changed.SCALE); 1030 TriggerScriptChangedEvent(Changed.SCALE);
1024 } 1031 }
1025 } 1032 }
1026 1033
1027 public byte UpdateFlag 1034 public UpdateRequired UpdateFlag
1028 { 1035 {
1029 get { return m_updateFlag; } 1036 get { return m_updateFlag; }
1030 set { m_updateFlag = value; } 1037 set { m_updateFlag = value; }
@@ -1309,9 +1316,9 @@ namespace OpenSim.Region.Framework.Scenes
1309 /// <summary> 1316 /// <summary>
1310 /// Clear all pending updates of parts to clients 1317 /// Clear all pending updates of parts to clients
1311 /// </summary> 1318 /// </summary>
1312 private void ClearUpdateSchedule() 1319 public void ClearUpdateSchedule()
1313 { 1320 {
1314 m_updateFlag = 0; 1321 UpdateFlag = UpdateRequired.NONE;
1315 } 1322 }
1316 1323
1317 /// <summary> 1324 /// <summary>
@@ -2829,7 +2836,7 @@ namespace OpenSim.Region.Framework.Scenes
2829 TimeStampFull = (uint)timeNow; 2836 TimeStampFull = (uint)timeNow;
2830 } 2837 }
2831 2838
2832 m_updateFlag = 2; 2839 UpdateFlag = UpdateRequired.FULL;
2833 2840
2834 // m_log.DebugFormat( 2841 // m_log.DebugFormat(
2835 // "[SCENE OBJECT PART]: Scheduling full update for {0}, {1} at {2}", 2842 // "[SCENE OBJECT PART]: Scheduling full update for {0}, {1} at {2}",
@@ -2845,13 +2852,13 @@ namespace OpenSim.Region.Framework.Scenes
2845 if (m_parentGroup == null) 2852 if (m_parentGroup == null)
2846 return; 2853 return;
2847 2854
2848 if (m_updateFlag < 1) 2855 if (UpdateFlag == UpdateRequired.NONE)
2849 { 2856 {
2850 m_parentGroup.HasGroupChanged = true; 2857 m_parentGroup.HasGroupChanged = true;
2851 m_parentGroup.QueueForUpdateCheck(); 2858 m_parentGroup.QueueForUpdateCheck();
2852 2859
2853 TimeStampTerse = (uint) Util.UnixTimeSinceEpoch(); 2860 TimeStampTerse = (uint) Util.UnixTimeSinceEpoch();
2854 m_updateFlag = 1; 2861 UpdateFlag = UpdateRequired.TERSE;
2855 2862
2856 // m_log.DebugFormat( 2863 // m_log.DebugFormat(
2857 // "[SCENE OBJECT PART]: Scheduling terse update for {0}, {1} at {2}", 2864 // "[SCENE OBJECT PART]: Scheduling terse update for {0}, {1} at {2}",
@@ -3018,45 +3025,39 @@ namespace OpenSim.Region.Framework.Scenes
3018 const float POSITION_TOLERANCE = 0.05f; 3025 const float POSITION_TOLERANCE = 0.05f;
3019 const int TIME_MS_TOLERANCE = 3000; 3026 const int TIME_MS_TOLERANCE = 3000;
3020 3027
3021 if (m_updateFlag == 1) 3028 switch (UpdateFlag)
3022 { 3029 {
3023 // Throw away duplicate or insignificant updates 3030 case UpdateRequired.TERSE:
3024 if (!RotationOffset.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) ||
3025 !Acceleration.Equals(m_lastAcceleration) ||
3026 !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) ||
3027 Velocity.ApproxEquals(Vector3.Zero, VELOCITY_TOLERANCE) ||
3028 !AngularVelocity.ApproxEquals(m_lastAngularVelocity, VELOCITY_TOLERANCE) ||
3029 !OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) ||
3030 Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE)
3031 { 3031 {
3032 AddTerseUpdateToAllAvatars(); 3032 // Throw away duplicate or insignificant updates
3033 ClearUpdateSchedule(); 3033 if (!RotationOffset.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) ||
3034 3034 !Acceleration.Equals(m_lastAcceleration) ||
3035 // This causes the Scene to 'poll' physical objects every couple of frames 3035 !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) ||
3036 // bad, so it's been replaced by an event driven method. 3036 Velocity.ApproxEquals(Vector3.Zero, VELOCITY_TOLERANCE) ||
3037 //if ((ObjectFlags & (uint)PrimFlags.Physics) != 0) 3037 !AngularVelocity.ApproxEquals(m_lastAngularVelocity, VELOCITY_TOLERANCE) ||
3038 //{ 3038 !OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) ||
3039 // Only send the constant terse updates on physical objects! 3039 Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE)
3040 //ScheduleTerseUpdate(); 3040 {
3041 //} 3041 AddTerseUpdateToAllAvatars();
3042 3042 ClearUpdateSchedule();
3043 // Update the "last" values 3043
3044 m_lastPosition = OffsetPosition; 3044 // Update the "last" values
3045 m_lastRotation = RotationOffset; 3045 m_lastPosition = OffsetPosition;
3046 m_lastVelocity = Velocity; 3046 m_lastRotation = RotationOffset;
3047 m_lastAcceleration = Acceleration; 3047 m_lastVelocity = Velocity;
3048 m_lastAngularVelocity = AngularVelocity; 3048 m_lastAcceleration = Acceleration;
3049 m_lastTerseSent = Environment.TickCount; 3049 m_lastAngularVelocity = AngularVelocity;
3050 m_lastTerseSent = Environment.TickCount;
3051 }
3052 break;
3050 } 3053 }
3051 } 3054 case UpdateRequired.FULL:
3052 else
3053 {
3054 if (m_updateFlag == 2) // is a new prim, just created/reloaded or has major changes
3055 { 3055 {
3056 AddFullUpdateToAllAvatars(); 3056 AddFullUpdateToAllAvatars();
3057 ClearUpdateSchedule(); 3057 break;
3058 } 3058 }
3059 } 3059 }
3060
3060 ClearUpdateSchedule(); 3061 ClearUpdateSchedule();
3061 } 3062 }
3062 3063
@@ -3436,7 +3437,7 @@ namespace OpenSim.Region.Framework.Scenes
3436 _groupID = groupID; 3437 _groupID = groupID;
3437 if (client != null) 3438 if (client != null)
3438 SendPropertiesToClient(client); 3439 SendPropertiesToClient(client);
3439 m_updateFlag = 2; 3440 UpdateFlag = UpdateRequired.FULL;
3440 } 3441 }
3441 3442
3442 /// <summary> 3443 /// <summary>