aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs107
1 files changed, 53 insertions, 54 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index a2e13ce..948518a 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -107,6 +107,13 @@ namespace OpenSim.Region.Framework.Scenes
107 SCULPT = 7 107 SCULPT = 7
108 } 108 }
109 109
110 public enum UpdateRequired : byte
111 {
112 NONE = 0,
113 TERSE = 1,
114 FULL = 2
115 }
116
110 #endregion Enumerations 117 #endregion Enumerations
111 118
112 public class SceneObjectPart : IScriptHost, ISceneEntity 119 public class SceneObjectPart : IScriptHost, ISceneEntity
@@ -265,15 +272,7 @@ namespace OpenSim.Region.Framework.Scenes
265 272
266 private bool m_passTouches; 273 private bool m_passTouches;
267 274
268 /// <summary> 275 private UpdateRequired m_updateFlag;
269 /// Only used internally to schedule client updates.
270 /// 0 - no update is scheduled
271 /// 1 - terse update scheduled
272 /// 2 - full update scheduled
273 ///
274 /// TODO - This should be an enumeration
275 /// </summary>
276 private byte m_updateFlag;
277 276
278 private PhysicsActor m_physActor; 277 private PhysicsActor m_physActor;
279 protected Vector3 m_acceleration; 278 protected Vector3 m_acceleration;
@@ -908,7 +907,15 @@ namespace OpenSim.Region.Framework.Scenes
908 } 907 }
909 } 908 }
910 909
911 /// <summary></summary> 910 /// <summary>Update angular velocity and schedule terse update.</summary>
911 public void UpdateAngularVelocity(Vector3 avel)
912 {
913 AngularVelocity = avel;
914 ScheduleTerseUpdate();
915 ParentGroup.HasGroupChanged = true;
916 }
917
918 /// <summary>Get or set angular velocity. Does not schedule update.</summary>
912 public Vector3 AngularVelocity 919 public Vector3 AngularVelocity
913 { 920 {
914 get 921 get
@@ -1056,8 +1063,8 @@ namespace OpenSim.Region.Framework.Scenes
1056 TriggerScriptChangedEvent(Changed.SCALE); 1063 TriggerScriptChangedEvent(Changed.SCALE);
1057 } 1064 }
1058 } 1065 }
1059 1066
1060 public byte UpdateFlag 1067 public UpdateRequired UpdateFlag
1061 { 1068 {
1062 get { return m_updateFlag; } 1069 get { return m_updateFlag; }
1063 set { m_updateFlag = value; } 1070 set { m_updateFlag = value; }
@@ -1362,9 +1369,9 @@ namespace OpenSim.Region.Framework.Scenes
1362 /// <summary> 1369 /// <summary>
1363 /// Clear all pending updates of parts to clients 1370 /// Clear all pending updates of parts to clients
1364 /// </summary> 1371 /// </summary>
1365 private void ClearUpdateSchedule() 1372 public void ClearUpdateSchedule()
1366 { 1373 {
1367 m_updateFlag = 0; 1374 UpdateFlag = UpdateRequired.NONE;
1368 } 1375 }
1369 1376
1370 /// <summary> 1377 /// <summary>
@@ -2884,7 +2891,7 @@ namespace OpenSim.Region.Framework.Scenes
2884 TimeStampFull = (uint)timeNow; 2891 TimeStampFull = (uint)timeNow;
2885 } 2892 }
2886 2893
2887 m_updateFlag = 2; 2894 UpdateFlag = UpdateRequired.FULL;
2888 2895
2889 // m_log.DebugFormat( 2896 // m_log.DebugFormat(
2890 // "[SCENE OBJECT PART]: Scheduling full update for {0}, {1} at {2}", 2897 // "[SCENE OBJECT PART]: Scheduling full update for {0}, {1} at {2}",
@@ -2900,13 +2907,13 @@ namespace OpenSim.Region.Framework.Scenes
2900 if (m_parentGroup == null) 2907 if (m_parentGroup == null)
2901 return; 2908 return;
2902 2909
2903 if (m_updateFlag < 1) 2910 if (UpdateFlag == UpdateRequired.NONE)
2904 { 2911 {
2905 m_parentGroup.HasGroupChanged = true; 2912 m_parentGroup.HasGroupChanged = true;
2906 m_parentGroup.QueueForUpdateCheck(); 2913 m_parentGroup.QueueForUpdateCheck();
2907 2914
2908 TimeStampTerse = (uint) Util.UnixTimeSinceEpoch(); 2915 TimeStampTerse = (uint) Util.UnixTimeSinceEpoch();
2909 m_updateFlag = 1; 2916 UpdateFlag = UpdateRequired.TERSE;
2910 2917
2911 // m_log.DebugFormat( 2918 // m_log.DebugFormat(
2912 // "[SCENE OBJECT PART]: Scheduling terse update for {0}, {1} at {2}", 2919 // "[SCENE OBJECT PART]: Scheduling terse update for {0}, {1} at {2}",
@@ -3073,48 +3080,40 @@ namespace OpenSim.Region.Framework.Scenes
3073 const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary 3080 const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary
3074 const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds. 3081 const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds.
3075 3082
3076 if (m_updateFlag == 1) 3083 switch (UpdateFlag)
3077 { 3084 {
3078 // Throw away duplicate or insignificant updates 3085 case UpdateRequired.TERSE:
3079 if (!RotationOffset.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) ||
3080 !Acceleration.Equals(m_lastAcceleration) ||
3081 !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) ||
3082 Velocity.ApproxEquals(Vector3.Zero, VELOCITY_TOLERANCE) ||
3083 !AngularVelocity.ApproxEquals(m_lastAngularVelocity, VELOCITY_TOLERANCE) ||
3084 !OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) ||
3085 Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE)
3086 { 3086 {
3087 AddTerseUpdateToAllAvatars(); 3087 // Throw away duplicate or insignificant updates
3088 3088 if (!RotationOffset.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) ||
3089 3089 !Acceleration.Equals(m_lastAcceleration) ||
3090 // This causes the Scene to 'poll' physical objects every couple of frames 3090 !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) ||
3091 // bad, so it's been replaced by an event driven method. 3091 Velocity.ApproxEquals(Vector3.Zero, VELOCITY_TOLERANCE) ||
3092 //if ((ObjectFlags & (uint)PrimFlags.Physics) != 0) 3092 !AngularVelocity.ApproxEquals(m_lastAngularVelocity, VELOCITY_TOLERANCE) ||
3093 //{ 3093 !OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) ||
3094 // Only send the constant terse updates on physical objects! 3094 Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE)
3095 //ScheduleTerseUpdate(); 3095 {
3096 //} 3096 AddTerseUpdateToAllAvatars();
3097 3097 ClearUpdateSchedule();
3098 // Update the "last" values 3098
3099 m_lastPosition = OffsetPosition; 3099 // Update the "last" values
3100 m_lastRotation = RotationOffset; 3100 m_lastPosition = OffsetPosition;
3101 m_lastVelocity = Velocity; 3101 m_lastRotation = RotationOffset;
3102 m_lastAcceleration = Acceleration; 3102 m_lastVelocity = Velocity;
3103 m_lastAngularVelocity = AngularVelocity; 3103 m_lastAcceleration = Acceleration;
3104 m_lastTerseSent = Environment.TickCount; 3104 m_lastAngularVelocity = AngularVelocity;
3105 m_lastTerseSent = Environment.TickCount;
3106 }
3107 break;
3105 } 3108 }
3106 //Moved this outside of the if clause so updates don't get blocked.. *sigh* 3109 case UpdateRequired.FULL:
3107 m_updateFlag = 0; //Why were we calling a function to do this? Inefficient! *screams*
3108 }
3109 else
3110 {
3111 if (m_updateFlag == 2) // is a new prim, just created/reloaded or has major changes
3112 { 3110 {
3113 AddFullUpdateToAllAvatars(); 3111 AddFullUpdateToAllAvatars();
3114 m_updateFlag = 0; //Same here 3112 break;
3115 } 3113 }
3116 } 3114 }
3117 m_updateFlag = 0; 3115
3116 ClearUpdateSchedule();
3118 } 3117 }
3119 3118
3120 /// <summary> 3119 /// <summary>
@@ -3492,7 +3491,7 @@ namespace OpenSim.Region.Framework.Scenes
3492 _groupID = groupID; 3491 _groupID = groupID;
3493 if (client != null) 3492 if (client != null)
3494 SendPropertiesToClient(client); 3493 SendPropertiesToClient(client);
3495 m_updateFlag = 2; 3494 UpdateFlag = UpdateRequired.FULL;
3496 } 3495 }
3497 3496
3498 /// <summary> 3497 /// <summary>
@@ -4699,7 +4698,7 @@ namespace OpenSim.Region.Framework.Scenes
4699 { 4698 {
4700 m_shape.TextureEntry = textureEntry; 4699 m_shape.TextureEntry = textureEntry;
4701 TriggerScriptChangedEvent(Changed.TEXTURE); 4700 TriggerScriptChangedEvent(Changed.TEXTURE);
4702 m_updateFlag = 1; 4701 UpdateFlag = UpdateRequired.FULL;
4703 ParentGroup.HasGroupChanged = true; 4702 ParentGroup.HasGroupChanged = true;
4704 4703
4705 //This is madness.. 4704 //This is madness..