diff options
author | UbitUmarov | 2017-07-20 11:30:12 +0100 |
---|---|---|
committer | UbitUmarov | 2017-07-20 11:30:12 +0100 |
commit | fe6ad384e43c11c3bf6268f5ab6fe3ea37c74540 (patch) | |
tree | 44ae3d8b00f3d2f6bf78bc0226a779f99ed6dc48 /OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |
parent | Merge branch 'master' into httptests (diff) | |
parent | fix object updates throttle for scripts doing motion by direct change of posi... (diff) | |
download | opensim-SC-fe6ad384e43c11c3bf6268f5ab6fe3ea37c74540.zip opensim-SC-fe6ad384e43c11c3bf6268f5ab6fe3ea37c74540.tar.gz opensim-SC-fe6ad384e43c11c3bf6268f5ab6fe3ea37c74540.tar.bz2 opensim-SC-fe6ad384e43c11c3bf6268f5ab6fe3ea37c74540.tar.xz |
merge
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 300 |
1 files changed, 215 insertions, 85 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index c2eac24..f0a3fab 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -329,7 +329,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
329 | private byte[] m_TextureAnimation; | 329 | private byte[] m_TextureAnimation; |
330 | private byte m_clickAction; | 330 | private byte m_clickAction; |
331 | private Color m_color = Color.Black; | 331 | private Color m_color = Color.Black; |
332 | private readonly List<uint> m_lastColliders = new List<uint>(); | 332 | private List<uint> m_lastColliders = new List<uint>(); |
333 | private bool m_lastLandCollide; | ||
333 | private int m_linkNum; | 334 | private int m_linkNum; |
334 | 335 | ||
335 | private int m_scriptAccessPin; | 336 | private int m_scriptAccessPin; |
@@ -369,9 +370,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
369 | protected Vector3 m_lastPosition; | 370 | protected Vector3 m_lastPosition; |
370 | protected Quaternion m_lastRotation; | 371 | protected Quaternion m_lastRotation; |
371 | protected Vector3 m_lastVelocity; | 372 | protected Vector3 m_lastVelocity; |
372 | protected Vector3 m_lastAcceleration; | 373 | protected Vector3 m_lastAcceleration; // acceleration is a derived var with high noise |
373 | protected Vector3 m_lastAngularVelocity; | 374 | protected Vector3 m_lastAngularVelocity; |
374 | protected int m_lastUpdateSentTime; | 375 | protected double m_lastUpdateSentTime; |
375 | protected float m_buoyancy = 0.0f; | 376 | protected float m_buoyancy = 0.0f; |
376 | protected Vector3 m_force; | 377 | protected Vector3 m_force; |
377 | protected Vector3 m_torque; | 378 | protected Vector3 m_torque; |
@@ -809,7 +810,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
809 | { | 810 | { |
810 | // If this is a linkset, we don't want the physics engine mucking up our group position here. | 811 | // If this is a linkset, we don't want the physics engine mucking up our group position here. |
811 | PhysicsActor actor = PhysActor; | 812 | PhysicsActor actor = PhysActor; |
812 | if (ParentID == 0) | 813 | if (_parentID == 0) |
813 | { | 814 | { |
814 | if (actor != null) | 815 | if (actor != null) |
815 | m_groupPosition = actor.Position; | 816 | m_groupPosition = actor.Position; |
@@ -838,7 +839,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
838 | try | 839 | try |
839 | { | 840 | { |
840 | // Root prim actually goes at Position | 841 | // Root prim actually goes at Position |
841 | if (ParentID == 0) | 842 | if (_parentID == 0) |
842 | { | 843 | { |
843 | actor.Position = value; | 844 | actor.Position = value; |
844 | } | 845 | } |
@@ -880,7 +881,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
880 | ParentGroup.InvalidBoundsRadius(); | 881 | ParentGroup.InvalidBoundsRadius(); |
881 | 882 | ||
882 | PhysicsActor actor = PhysActor; | 883 | PhysicsActor actor = PhysActor; |
883 | if (ParentID != 0 && actor != null) | 884 | if (_parentID != 0 && actor != null) |
884 | { | 885 | { |
885 | actor.Position = GetWorldPosition(); | 886 | actor.Position = GetWorldPosition(); |
886 | actor.Orientation = GetWorldRotation(); | 887 | actor.Orientation = GetWorldRotation(); |
@@ -940,7 +941,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
940 | PhysicsActor actor = PhysActor; | 941 | PhysicsActor actor = PhysActor; |
941 | // If this is a root of a linkset, the real rotation is what the physics engine thinks. | 942 | // If this is a root of a linkset, the real rotation is what the physics engine thinks. |
942 | // If not a root prim, the offset rotation is computed by SOG and is relative to the root. | 943 | // If not a root prim, the offset rotation is computed by SOG and is relative to the root. |
943 | if (ParentID == 0 && (Shape.PCode != 9 || Shape.State == 0) && actor != null) | 944 | if (_parentID == 0 && (Shape.PCode != 9 || Shape.State == 0) && actor != null) |
944 | m_rotationOffset = actor.Orientation; | 945 | m_rotationOffset = actor.Orientation; |
945 | 946 | ||
946 | return m_rotationOffset; | 947 | return m_rotationOffset; |
@@ -957,7 +958,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
957 | try | 958 | try |
958 | { | 959 | { |
959 | // Root prim gets value directly | 960 | // Root prim gets value directly |
960 | if (ParentID == 0) | 961 | if (_parentID == 0) |
961 | { | 962 | { |
962 | actor.Orientation = value; | 963 | actor.Orientation = value; |
963 | //m_log.Info("[PART]: RO1:" + actor.Orientation.ToString()); | 964 | //m_log.Info("[PART]: RO1:" + actor.Orientation.ToString()); |
@@ -1103,8 +1104,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1103 | { | 1104 | { |
1104 | get | 1105 | get |
1105 | { | 1106 | { |
1106 | if (m_text.Length > 255) | 1107 | if (m_text.Length > 256) // yes > 254 |
1107 | return m_text.Substring(0, 254); | 1108 | return m_text.Substring(0, 256); |
1108 | return m_text; | 1109 | return m_text; |
1109 | } | 1110 | } |
1110 | set { m_text = value; } | 1111 | set { m_text = value; } |
@@ -1258,6 +1259,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1258 | { | 1259 | { |
1259 | get | 1260 | get |
1260 | { | 1261 | { |
1262 | if (_parentID == 0) | ||
1263 | return GroupPosition; | ||
1264 | |||
1261 | return GroupPosition + (m_offsetPosition * ParentGroup.RootPart.RotationOffset); | 1265 | return GroupPosition + (m_offsetPosition * ParentGroup.RootPart.RotationOffset); |
1262 | } | 1266 | } |
1263 | } | 1267 | } |
@@ -1379,7 +1383,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1379 | public UUID LastOwnerID | 1383 | public UUID LastOwnerID |
1380 | { | 1384 | { |
1381 | get { return _lastOwnerID; } | 1385 | get { return _lastOwnerID; } |
1382 | set { _lastOwnerID = value; } | 1386 | set { |
1387 | _lastOwnerID = value; } | ||
1383 | } | 1388 | } |
1384 | 1389 | ||
1385 | public UUID RezzerID | 1390 | public UUID RezzerID |
@@ -2422,7 +2427,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2422 | PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; | 2427 | PhysActor.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; |
2423 | PhysActor.OnOutOfBounds += PhysicsOutOfBounds; | 2428 | PhysActor.OnOutOfBounds += PhysicsOutOfBounds; |
2424 | 2429 | ||
2425 | if (ParentID != 0 && ParentID != LocalId) | 2430 | if (_parentID != 0 && _parentID != LocalId) |
2426 | { | 2431 | { |
2427 | PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; | 2432 | PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; |
2428 | 2433 | ||
@@ -2788,12 +2793,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2788 | { | 2793 | { |
2789 | ColliderArgs colliderArgs = new ColliderArgs(); | 2794 | ColliderArgs colliderArgs = new ColliderArgs(); |
2790 | List<DetectedObject> colliding = new List<DetectedObject>(); | 2795 | List<DetectedObject> colliding = new List<DetectedObject>(); |
2796 | Scene parentScene = ParentGroup.Scene; | ||
2791 | foreach (uint localId in colliders) | 2797 | foreach (uint localId in colliders) |
2792 | { | 2798 | { |
2793 | if (localId == 0) | 2799 | if (localId == 0) |
2794 | continue; | 2800 | continue; |
2795 | 2801 | ||
2796 | SceneObjectPart obj = ParentGroup.Scene.GetSceneObjectPart(localId); | 2802 | SceneObjectPart obj = parentScene.GetSceneObjectPart(localId); |
2797 | if (obj != null) | 2803 | if (obj != null) |
2798 | { | 2804 | { |
2799 | if (!dest.CollisionFilteredOut(obj.UUID, obj.Name)) | 2805 | if (!dest.CollisionFilteredOut(obj.UUID, obj.Name)) |
@@ -2801,7 +2807,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2801 | } | 2807 | } |
2802 | else | 2808 | else |
2803 | { | 2809 | { |
2804 | ScenePresence av = ParentGroup.Scene.GetScenePresence(localId); | 2810 | ScenePresence av = parentScene.GetScenePresence(localId); |
2805 | if (av != null && (!av.IsChildAgent)) | 2811 | if (av != null && (!av.IsChildAgent)) |
2806 | { | 2812 | { |
2807 | if (!dest.CollisionFilteredOut(av.UUID, av.Name)) | 2813 | if (!dest.CollisionFilteredOut(av.UUID, av.Name)) |
@@ -2874,10 +2880,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2874 | 2880 | ||
2875 | public void PhysicsCollision(EventArgs e) | 2881 | public void PhysicsCollision(EventArgs e) |
2876 | { | 2882 | { |
2877 | if (ParentGroup.Scene == null || ParentGroup.IsDeleted) | 2883 | if (ParentGroup.Scene == null || ParentGroup.IsDeleted || ParentGroup.inTransit) |
2878 | return; | 2884 | return; |
2879 | 2885 | ||
2880 | // this a thread from physics ( heartbeat ) | 2886 | // this a thread from physics ( heartbeat ) |
2887 | bool thisHitLand = false; | ||
2888 | bool startLand = false; | ||
2889 | bool endedLand = false; | ||
2881 | 2890 | ||
2882 | CollisionEventUpdate a = (CollisionEventUpdate)e; | 2891 | CollisionEventUpdate a = (CollisionEventUpdate)e; |
2883 | Dictionary<uint, ContactPoint> collissionswith = a.m_objCollisionList; | 2892 | Dictionary<uint, ContactPoint> collissionswith = a.m_objCollisionList; |
@@ -2887,13 +2896,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2887 | 2896 | ||
2888 | if (collissionswith.Count == 0) | 2897 | if (collissionswith.Count == 0) |
2889 | { | 2898 | { |
2890 | if (m_lastColliders.Count == 0) | 2899 | if (m_lastColliders.Count == 0 && !m_lastLandCollide) |
2891 | return; // nothing to do | 2900 | return; // nothing to do |
2892 | 2901 | ||
2902 | endedLand = m_lastLandCollide; | ||
2903 | m_lastLandCollide = false; | ||
2904 | |||
2893 | foreach (uint localID in m_lastColliders) | 2905 | foreach (uint localID in m_lastColliders) |
2894 | { | 2906 | { |
2895 | endedColliders.Add(localID); | 2907 | endedColliders.Add(localID); |
2896 | } | 2908 | } |
2909 | |||
2897 | m_lastColliders.Clear(); | 2910 | m_lastColliders.Clear(); |
2898 | } | 2911 | } |
2899 | else | 2912 | else |
@@ -2909,19 +2922,39 @@ namespace OpenSim.Region.Framework.Scenes | |||
2909 | 2922 | ||
2910 | foreach (uint id in collissionswith.Keys) | 2923 | foreach (uint id in collissionswith.Keys) |
2911 | { | 2924 | { |
2912 | thisHitColliders.Add(id); | 2925 | if(id == 0) |
2913 | if (!m_lastColliders.Contains(id)) | ||
2914 | { | 2926 | { |
2915 | startedColliders.Add(id); | 2927 | thisHitLand = true; |
2916 | 2928 | if (!m_lastLandCollide) | |
2917 | curcontact = collissionswith[id]; | 2929 | { |
2918 | if (Math.Abs(curcontact.RelativeSpeed) > 0.2) | 2930 | startLand = true; |
2931 | curcontact = collissionswith[id]; | ||
2932 | if (Math.Abs(curcontact.RelativeSpeed) > 0.2) | ||
2933 | { | ||
2934 | soundinfo = new CollisionForSoundInfo(); | ||
2935 | soundinfo.colliderID = id; | ||
2936 | soundinfo.position = curcontact.Position; | ||
2937 | soundinfo.relativeVel = curcontact.RelativeSpeed; | ||
2938 | soundinfolist.Add(soundinfo); | ||
2939 | } | ||
2940 | } | ||
2941 | } | ||
2942 | else | ||
2943 | { | ||
2944 | thisHitColliders.Add(id); | ||
2945 | if (!m_lastColliders.Contains(id)) | ||
2919 | { | 2946 | { |
2920 | soundinfo = new CollisionForSoundInfo(); | 2947 | startedColliders.Add(id); |
2921 | soundinfo.colliderID = id; | 2948 | |
2922 | soundinfo.position = curcontact.Position; | 2949 | curcontact = collissionswith[id]; |
2923 | soundinfo.relativeVel = curcontact.RelativeSpeed; | 2950 | if (Math.Abs(curcontact.RelativeSpeed) > 0.2) |
2924 | soundinfolist.Add(soundinfo); | 2951 | { |
2952 | soundinfo = new CollisionForSoundInfo(); | ||
2953 | soundinfo.colliderID = id; | ||
2954 | soundinfo.position = curcontact.Position; | ||
2955 | soundinfo.relativeVel = curcontact.RelativeSpeed; | ||
2956 | soundinfolist.Add(soundinfo); | ||
2957 | } | ||
2925 | } | 2958 | } |
2926 | } | 2959 | } |
2927 | } | 2960 | } |
@@ -2930,9 +2963,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
2930 | { | 2963 | { |
2931 | foreach (uint id in collissionswith.Keys) | 2964 | foreach (uint id in collissionswith.Keys) |
2932 | { | 2965 | { |
2933 | thisHitColliders.Add(id); | 2966 | if(id == 0) |
2934 | if (!m_lastColliders.Contains(id)) | 2967 | { |
2935 | startedColliders.Add(id); | 2968 | thisHitLand = true; |
2969 | if (!m_lastLandCollide) | ||
2970 | startLand = true; | ||
2971 | } | ||
2972 | else | ||
2973 | { | ||
2974 | thisHitColliders.Add(id); | ||
2975 | if (!m_lastColliders.Contains(id)) | ||
2976 | startedColliders.Add(id); | ||
2977 | } | ||
2936 | } | 2978 | } |
2937 | } | 2979 | } |
2938 | 2980 | ||
@@ -2951,22 +2993,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
2951 | foreach (uint localID in endedColliders) | 2993 | foreach (uint localID in endedColliders) |
2952 | m_lastColliders.Remove(localID); | 2994 | m_lastColliders.Remove(localID); |
2953 | 2995 | ||
2996 | if(m_lastLandCollide && !thisHitLand) | ||
2997 | endedLand = true; | ||
2998 | |||
2999 | m_lastLandCollide = thisHitLand; | ||
3000 | |||
2954 | // play sounds. | 3001 | // play sounds. |
2955 | if (soundinfolist.Count > 0) | 3002 | if (soundinfolist.Count > 0) |
2956 | CollisionSounds.PartCollisionSound(this, soundinfolist); | 3003 | CollisionSounds.PartCollisionSound(this, soundinfolist); |
2957 | } | 3004 | } |
3005 | |||
3006 | EventManager eventmanager = ParentGroup.Scene.EventManager; | ||
2958 | 3007 | ||
2959 | SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); | 3008 | SendCollisionEvent(scriptEvents.collision_start, startedColliders, eventmanager.TriggerScriptCollidingStart); |
2960 | if (!VolumeDetectActive) | 3009 | if (!VolumeDetectActive) |
2961 | SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); | 3010 | SendCollisionEvent(scriptEvents.collision , m_lastColliders , eventmanager.TriggerScriptColliding); |
2962 | SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); | 3011 | SendCollisionEvent(scriptEvents.collision_end , endedColliders , eventmanager.TriggerScriptCollidingEnd); |
2963 | 3012 | ||
2964 | if (startedColliders.Contains(0)) | 3013 | if (!VolumeDetectActive) |
2965 | SendLandCollisionEvent(scriptEvents.land_collision_start, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingStart); | 3014 | { |
2966 | if (m_lastColliders.Contains(0)) | 3015 | if (startLand) |
2967 | SendLandCollisionEvent(scriptEvents.land_collision, ParentGroup.Scene.EventManager.TriggerScriptLandColliding); | 3016 | SendLandCollisionEvent(scriptEvents.land_collision_start, eventmanager.TriggerScriptLandCollidingStart); |
2968 | if (endedColliders.Contains(0)) | 3017 | if (m_lastLandCollide) |
2969 | SendLandCollisionEvent(scriptEvents.land_collision_end, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd); | 3018 | SendLandCollisionEvent(scriptEvents.land_collision, eventmanager.TriggerScriptLandColliding); |
3019 | if (endedLand) | ||
3020 | SendLandCollisionEvent(scriptEvents.land_collision_end, eventmanager.TriggerScriptLandCollidingEnd); | ||
3021 | } | ||
2970 | } | 3022 | } |
2971 | 3023 | ||
2972 | // The Collision sounds code calls this | 3024 | // The Collision sounds code calls this |
@@ -2985,7 +3037,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2985 | volume = 0; | 3037 | volume = 0; |
2986 | 3038 | ||
2987 | int now = Util.EnvironmentTickCount(); | 3039 | int now = Util.EnvironmentTickCount(); |
2988 | if(Util.EnvironmentTickCountSubtract(now,LastColSoundSentTime) <200) | 3040 | if(Util.EnvironmentTickCountSubtract(now, LastColSoundSentTime) < 200) |
2989 | return; | 3041 | return; |
2990 | 3042 | ||
2991 | LastColSoundSentTime = now; | 3043 | LastColSoundSentTime = now; |
@@ -3026,7 +3078,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3026 | //ParentGroup.RootPart.m_groupPosition = newpos; | 3078 | //ParentGroup.RootPart.m_groupPosition = newpos; |
3027 | } | 3079 | } |
3028 | /* | 3080 | /* |
3029 | if (pa != null && ParentID != 0 && ParentGroup != null) | 3081 | if (pa != null && _parentID != 0 && ParentGroup != null) |
3030 | { | 3082 | { |
3031 | // Special case where a child object is requesting property updates. | 3083 | // Special case where a child object is requesting property updates. |
3032 | // This happens when linksets are modified to use flexible links rather than | 3084 | // This happens when linksets are modified to use flexible links rather than |
@@ -3236,7 +3288,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3236 | 3288 | ||
3237 | /// <summary> | 3289 | /// <summary> |
3238 | /// Schedule a terse update for this prim. Terse updates only send position, | 3290 | /// Schedule a terse update for this prim. Terse updates only send position, |
3239 | /// rotation, velocity and rotational velocity information. | 3291 | /// rotation, velocity and rotational velocity information. WRONG!!!! |
3240 | /// </summary> | 3292 | /// </summary> |
3241 | public void ScheduleTerseUpdate() | 3293 | public void ScheduleTerseUpdate() |
3242 | { | 3294 | { |
@@ -3295,21 +3347,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3295 | sp.SendAttachmentUpdate(this, UpdateRequired.FULL); | 3347 | sp.SendAttachmentUpdate(this, UpdateRequired.FULL); |
3296 | } | 3348 | } |
3297 | } | 3349 | } |
3298 | |||
3299 | /* this does nothing | ||
3300 | SendFullUpdateToClient(remoteClient, Position) ignores position parameter | ||
3301 | if (IsRoot) | ||
3302 | { | ||
3303 | if (ParentGroup.IsAttachment) | ||
3304 | { | ||
3305 | SendFullUpdateToClient(remoteClient, AttachedPos); | ||
3306 | } | ||
3307 | else | ||
3308 | { | ||
3309 | SendFullUpdateToClient(remoteClient, AbsolutePosition); | ||
3310 | } | ||
3311 | } | ||
3312 | */ | ||
3313 | else | 3350 | else |
3314 | { | 3351 | { |
3315 | SendFullUpdateToClient(remoteClient); | 3352 | SendFullUpdateToClient(remoteClient); |
@@ -3325,12 +3362,12 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter | |||
3325 | return; | 3362 | return; |
3326 | 3363 | ||
3327 | // Update the "last" values | 3364 | // Update the "last" values |
3328 | m_lastPosition = OffsetPosition; | 3365 | m_lastPosition = AbsolutePosition; |
3329 | m_lastRotation = RotationOffset; | 3366 | m_lastRotation = RotationOffset; |
3330 | m_lastVelocity = Velocity; | 3367 | m_lastVelocity = Velocity; |
3331 | m_lastAcceleration = Acceleration; | 3368 | m_lastAcceleration = Acceleration; |
3332 | m_lastAngularVelocity = AngularVelocity; | 3369 | m_lastAngularVelocity = AngularVelocity; |
3333 | m_lastUpdateSentTime = Environment.TickCount; | 3370 | m_lastUpdateSentTime = Util.GetTimeStampMS(); |
3334 | 3371 | ||
3335 | ParentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) | 3372 | ParentGroup.Scene.ForEachScenePresence(delegate(ScenePresence avatar) |
3336 | { | 3373 | { |
@@ -3344,12 +3381,12 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter | |||
3344 | return; | 3381 | return; |
3345 | 3382 | ||
3346 | // Update the "last" values | 3383 | // Update the "last" values |
3347 | m_lastPosition = OffsetPosition; | 3384 | m_lastPosition = AbsolutePosition; |
3348 | m_lastRotation = RotationOffset; | 3385 | m_lastRotation = RotationOffset; |
3349 | m_lastVelocity = Velocity; | 3386 | m_lastVelocity = Velocity; |
3350 | m_lastAcceleration = Acceleration; | 3387 | m_lastAcceleration = Acceleration; |
3351 | m_lastAngularVelocity = AngularVelocity; | 3388 | m_lastAngularVelocity = AngularVelocity; |
3352 | m_lastUpdateSentTime = Environment.TickCount; | 3389 | m_lastUpdateSentTime = Util.GetTimeStampMS(); |
3353 | 3390 | ||
3354 | if (ParentGroup.IsAttachment) | 3391 | if (ParentGroup.IsAttachment) |
3355 | { | 3392 | { |
@@ -3395,40 +3432,129 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter | |||
3395 | ParentGroup.Scene.StatsReporter.AddObjectUpdates(1); | 3432 | ParentGroup.Scene.StatsReporter.AddObjectUpdates(1); |
3396 | } | 3433 | } |
3397 | 3434 | ||
3435 | |||
3436 | private const float ROTATION_TOLERANCE = 0.01f; | ||
3437 | private const float VELOCITY_TOLERANCE = 0.1f; // terse update vel has low resolution | ||
3438 | private const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary | ||
3439 | private const double TIME_MS_TOLERANCE = 200f; //llSetPos has a 200ms delay. This should NOT be 3 seconds. | ||
3440 | |||
3398 | /// <summary> | 3441 | /// <summary> |
3399 | /// Tell all the prims which have had updates scheduled | 3442 | /// Tell all the prims which have had updates scheduled |
3400 | /// </summary> | 3443 | /// </summary> |
3401 | public void SendScheduledUpdates() | 3444 | public void SendScheduledUpdates() |
3402 | { | 3445 | { |
3403 | const float ROTATION_TOLERANCE = 0.01f; | ||
3404 | const float VELOCITY_TOLERANCE = 0.001f; | ||
3405 | const float POSITION_TOLERANCE = 0.05f; // I don't like this, but I suppose it's necessary | ||
3406 | const int TIME_MS_TOLERANCE = 200; //llSetPos has a 200ms delay. This should NOT be 3 seconds. | ||
3407 | |||
3408 | switch (UpdateFlag) | 3446 | switch (UpdateFlag) |
3409 | { | 3447 | { |
3448 | case UpdateRequired.NONE: | ||
3449 | ClearUpdateSchedule(); | ||
3450 | break; | ||
3451 | |||
3410 | case UpdateRequired.TERSE: | 3452 | case UpdateRequired.TERSE: |
3411 | { | 3453 | |
3412 | ClearUpdateSchedule(); | 3454 | ClearUpdateSchedule(); |
3413 | // Throw away duplicate or insignificant updates | 3455 | bool needupdate = true; |
3414 | if (!RotationOffset.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || | 3456 | double now = Util.GetTimeStampMS(); |
3415 | !Acceleration.Equals(m_lastAcceleration) || | 3457 | Vector3 curvel = Velocity; |
3416 | !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || | 3458 | Vector3 curacc = Acceleration; |
3417 | Velocity.ApproxEquals(Vector3.Zero, VELOCITY_TOLERANCE) || | 3459 | Vector3 angvel = AngularVelocity; |
3418 | !AngularVelocity.ApproxEquals(m_lastAngularVelocity, VELOCITY_TOLERANCE) || | 3460 | |
3419 | !OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) || | 3461 | while(true) // just to avoid ugly goto |
3420 | Environment.TickCount - m_lastUpdateSentTime > TIME_MS_TOLERANCE) | 3462 | { |
3463 | double elapsed = now - m_lastUpdateSentTime; | ||
3464 | if (elapsed > TIME_MS_TOLERANCE) | ||
3465 | break; | ||
3466 | |||
3467 | if( Math.Abs(curacc.X - m_lastAcceleration.X) > VELOCITY_TOLERANCE || | ||
3468 | Math.Abs(curacc.Y - m_lastAcceleration.Y) > VELOCITY_TOLERANCE || | ||
3469 | Math.Abs(curacc.Z - m_lastAcceleration.Z) > VELOCITY_TOLERANCE) | ||
3470 | break; | ||
3471 | |||
3472 | // velocity change is also direction not only norm) | ||
3473 | if( Math.Abs(curvel.X - m_lastVelocity.X) > VELOCITY_TOLERANCE || | ||
3474 | Math.Abs(curvel.Y - m_lastVelocity.Y) > VELOCITY_TOLERANCE || | ||
3475 | Math.Abs(curvel.Z - m_lastVelocity.Z) > VELOCITY_TOLERANCE) | ||
3476 | break; | ||
3477 | |||
3478 | float vx = Math.Abs(curvel.X); | ||
3479 | if(vx > 128.0) | ||
3480 | break; | ||
3481 | float vy = Math.Abs(curvel.Y); | ||
3482 | if(vy > 128.0) | ||
3483 | break; | ||
3484 | float vz = Math.Abs(curvel.Z); | ||
3485 | if(vz > 128.0) | ||
3486 | break; | ||
3487 | |||
3488 | if ( | ||
3489 | vx < VELOCITY_TOLERANCE && | ||
3490 | vy < VELOCITY_TOLERANCE && | ||
3491 | vz < VELOCITY_TOLERANCE | ||
3492 | ) | ||
3493 | { | ||
3494 | if(!AbsolutePosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) | ||
3495 | break; | ||
3496 | |||
3497 | if (vx < 1e-4 && | ||
3498 | vy < 1e-4 && | ||
3499 | vz < 1e-4 && | ||
3500 | ( | ||
3501 | Math.Abs(m_lastVelocity.X) > 1e-4 || | ||
3502 | Math.Abs(m_lastVelocity.Y) > 1e-4 || | ||
3503 | Math.Abs(m_lastVelocity.Z) > 1e-4 | ||
3504 | )) | ||
3505 | break; | ||
3506 | } | ||
3507 | |||
3508 | if( Math.Abs(angvel.X - m_lastAngularVelocity.X) > VELOCITY_TOLERANCE || | ||
3509 | Math.Abs(angvel.Y - m_lastAngularVelocity.Y) > VELOCITY_TOLERANCE || | ||
3510 | Math.Abs(angvel.Z - m_lastAngularVelocity.Z) > VELOCITY_TOLERANCE) | ||
3511 | break; | ||
3512 | |||
3513 | // viewer interpolators have a limit of 128m/s | ||
3514 | float ax = Math.Abs(angvel.X); | ||
3515 | if(ax > 64.0) | ||
3516 | break; | ||
3517 | float ay = Math.Abs(angvel.Y); | ||
3518 | if(ay > 64.0) | ||
3519 | break; | ||
3520 | float az = Math.Abs(angvel.Z); | ||
3521 | if(az > 64.0) | ||
3522 | break; | ||
3523 | |||
3524 | if ( | ||
3525 | ax < VELOCITY_TOLERANCE && | ||
3526 | ay < VELOCITY_TOLERANCE && | ||
3527 | az < VELOCITY_TOLERANCE && | ||
3528 | !RotationOffset.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) | ||
3529 | ) | ||
3530 | break; | ||
3531 | |||
3532 | needupdate = false; | ||
3533 | break; | ||
3534 | } | ||
3535 | |||
3536 | if(needupdate) | ||
3421 | { | 3537 | { |
3422 | SendTerseUpdateToAllClientsInternal(); | 3538 | |
3539 | // Update the "last" values | ||
3540 | m_lastPosition = AbsolutePosition; | ||
3541 | m_lastRotation = RotationOffset; | ||
3542 | m_lastVelocity = curvel; | ||
3543 | m_lastAcceleration = curacc; | ||
3544 | m_lastAngularVelocity = angvel; | ||
3545 | m_lastUpdateSentTime = now; | ||
3546 | |||
3547 | ParentGroup.Scene.ForEachClient(delegate(IClientAPI client) | ||
3548 | { | ||
3549 | SendTerseUpdateToClient(client); | ||
3550 | }); | ||
3423 | } | 3551 | } |
3424 | break; | 3552 | break; |
3425 | } | 3553 | |
3426 | case UpdateRequired.FULL: | 3554 | case UpdateRequired.FULL: |
3427 | { | ||
3428 | ClearUpdateSchedule(); | 3555 | ClearUpdateSchedule(); |
3429 | SendFullUpdateToAllClientsInternal(); | 3556 | SendFullUpdateToAllClientsInternal(); |
3430 | break; | 3557 | break; |
3431 | } | ||
3432 | } | 3558 | } |
3433 | } | 3559 | } |
3434 | 3560 | ||
@@ -3441,13 +3567,15 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter | |||
3441 | if (ParentGroup == null || ParentGroup.Scene == null) | 3567 | if (ParentGroup == null || ParentGroup.Scene == null) |
3442 | return; | 3568 | return; |
3443 | 3569 | ||
3570 | ClearUpdateSchedule(); | ||
3571 | |||
3444 | // Update the "last" values | 3572 | // Update the "last" values |
3445 | m_lastPosition = OffsetPosition; | 3573 | m_lastPosition = AbsolutePosition; |
3446 | m_lastRotation = RotationOffset; | 3574 | m_lastRotation = RotationOffset; |
3447 | m_lastVelocity = Velocity; | 3575 | m_lastVelocity = Velocity; |
3448 | m_lastAcceleration = Acceleration; | 3576 | m_lastAcceleration = Acceleration; |
3449 | m_lastAngularVelocity = AngularVelocity; | 3577 | m_lastAngularVelocity = AngularVelocity; |
3450 | m_lastUpdateSentTime = Environment.TickCount; | 3578 | m_lastUpdateSentTime = Util.GetTimeStampMS(); |
3451 | 3579 | ||
3452 | ParentGroup.Scene.ForEachClient(delegate(IClientAPI client) | 3580 | ParentGroup.Scene.ForEachClient(delegate(IClientAPI client) |
3453 | { | 3581 | { |
@@ -3460,13 +3588,15 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter | |||
3460 | if (ParentGroup == null || ParentGroup.Scene == null) | 3588 | if (ParentGroup == null || ParentGroup.Scene == null) |
3461 | return; | 3589 | return; |
3462 | 3590 | ||
3591 | ClearUpdateSchedule(); | ||
3592 | |||
3463 | // Update the "last" values | 3593 | // Update the "last" values |
3464 | m_lastPosition = OffsetPosition; | 3594 | m_lastPosition = AbsolutePosition; |
3465 | m_lastRotation = RotationOffset; | 3595 | m_lastRotation = RotationOffset; |
3466 | m_lastVelocity = Velocity; | 3596 | m_lastVelocity = Velocity; |
3467 | m_lastAcceleration = Acceleration; | 3597 | m_lastAcceleration = Acceleration; |
3468 | m_lastAngularVelocity = AngularVelocity; | 3598 | m_lastAngularVelocity = AngularVelocity; |
3469 | m_lastUpdateSentTime = Environment.TickCount; | 3599 | m_lastUpdateSentTime = Util.GetTimeStampMS(); |
3470 | 3600 | ||
3471 | if (ParentGroup.IsAttachment) | 3601 | if (ParentGroup.IsAttachment) |
3472 | { | 3602 | { |
@@ -4783,7 +4913,7 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter | |||
4783 | pa.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; | 4913 | pa.OnRequestTerseUpdate += PhysicsRequestingTerseUpdate; |
4784 | pa.OnOutOfBounds += PhysicsOutOfBounds; | 4914 | pa.OnOutOfBounds += PhysicsOutOfBounds; |
4785 | 4915 | ||
4786 | if (ParentID != 0 && ParentID != LocalId) | 4916 | if (_parentID != 0 && _parentID != LocalId) |
4787 | { | 4917 | { |
4788 | PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; | 4918 | PhysicsActor parentPa = ParentGroup.RootPart.PhysActor; |
4789 | 4919 | ||