aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Util.cs9
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs104
-rw-r--r--OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs4
-rw-r--r--OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs34
4 files changed, 104 insertions, 47 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index ed24452..a42dcc6 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -156,12 +156,14 @@ namespace OpenSim.Framework
156 public static readonly int MAX_THREADPOOL_LEVEL = 3; 156 public static readonly int MAX_THREADPOOL_LEVEL = 3;
157 157
158 public static double TimeStampClockPeriodMS; 158 public static double TimeStampClockPeriodMS;
159 public static double TimeStampClockPeriod;
159 160
160 static Util() 161 static Util()
161 { 162 {
162 LogThreadPool = 0; 163 LogThreadPool = 0;
163 LogOverloads = true; 164 LogOverloads = true;
164 TimeStampClockPeriodMS = 1000.0D / (double)Stopwatch.Frequency; 165 TimeStampClockPeriod = 1.0D/ (double)Stopwatch.Frequency;
166 TimeStampClockPeriodMS = 1e3 * TimeStampClockPeriod;
165 m_log.InfoFormat("[UTIL] TimeStamp clock with period of {0}ms", Math.Round(TimeStampClockPeriodMS,6,MidpointRounding.AwayFromZero)); 167 m_log.InfoFormat("[UTIL] TimeStamp clock with period of {0}ms", Math.Round(TimeStampClockPeriodMS,6,MidpointRounding.AwayFromZero));
166 } 168 }
167 169
@@ -3016,6 +3018,11 @@ namespace OpenSim.Framework
3016 3018
3017 // returns a timestamp in ms as double 3019 // returns a timestamp in ms as double
3018 // using the time resolution avaiable to StopWatch 3020 // using the time resolution avaiable to StopWatch
3021 public static double GetTimeStamp()
3022 {
3023 return (double)Stopwatch.GetTimestamp() * TimeStampClockPeriod;
3024 }
3025
3019 public static double GetTimeStampMS() 3026 public static double GetTimeStampMS()
3020 { 3027 {
3021 return (double)Stopwatch.GetTimestamp() * TimeStampClockPeriodMS; 3028 return (double)Stopwatch.GetTimestamp() * TimeStampClockPeriodMS;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 2e16663..2384143 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;
@@ -2789,12 +2790,13 @@ namespace OpenSim.Region.Framework.Scenes
2789 { 2790 {
2790 ColliderArgs colliderArgs = new ColliderArgs(); 2791 ColliderArgs colliderArgs = new ColliderArgs();
2791 List<DetectedObject> colliding = new List<DetectedObject>(); 2792 List<DetectedObject> colliding = new List<DetectedObject>();
2793 Scene parentScene = ParentGroup.Scene;
2792 foreach (uint localId in colliders) 2794 foreach (uint localId in colliders)
2793 { 2795 {
2794 if (localId == 0) 2796 if (localId == 0)
2795 continue; 2797 continue;
2796 2798
2797 SceneObjectPart obj = ParentGroup.Scene.GetSceneObjectPart(localId); 2799 SceneObjectPart obj = parentScene.GetSceneObjectPart(localId);
2798 if (obj != null) 2800 if (obj != null)
2799 { 2801 {
2800 if (!dest.CollisionFilteredOut(obj.UUID, obj.Name)) 2802 if (!dest.CollisionFilteredOut(obj.UUID, obj.Name))
@@ -2802,7 +2804,7 @@ namespace OpenSim.Region.Framework.Scenes
2802 } 2804 }
2803 else 2805 else
2804 { 2806 {
2805 ScenePresence av = ParentGroup.Scene.GetScenePresence(localId); 2807 ScenePresence av = parentScene.GetScenePresence(localId);
2806 if (av != null && (!av.IsChildAgent)) 2808 if (av != null && (!av.IsChildAgent))
2807 { 2809 {
2808 if (!dest.CollisionFilteredOut(av.UUID, av.Name)) 2810 if (!dest.CollisionFilteredOut(av.UUID, av.Name))
@@ -2879,6 +2881,9 @@ namespace OpenSim.Region.Framework.Scenes
2879 return; 2881 return;
2880 2882
2881 // this a thread from physics ( heartbeat ) 2883 // this a thread from physics ( heartbeat )
2884 bool thisHitLand = false;
2885 bool startLand = false;
2886 bool endedLand = false;
2882 2887
2883 CollisionEventUpdate a = (CollisionEventUpdate)e; 2888 CollisionEventUpdate a = (CollisionEventUpdate)e;
2884 Dictionary<uint, ContactPoint> collissionswith = a.m_objCollisionList; 2889 Dictionary<uint, ContactPoint> collissionswith = a.m_objCollisionList;
@@ -2888,13 +2893,17 @@ namespace OpenSim.Region.Framework.Scenes
2888 2893
2889 if (collissionswith.Count == 0) 2894 if (collissionswith.Count == 0)
2890 { 2895 {
2891 if (m_lastColliders.Count == 0) 2896 if (m_lastColliders.Count == 0 && !m_lastLandCollide)
2892 return; // nothing to do 2897 return; // nothing to do
2893 2898
2899 endedLand = m_lastLandCollide;
2900 m_lastLandCollide = false;
2901
2894 foreach (uint localID in m_lastColliders) 2902 foreach (uint localID in m_lastColliders)
2895 { 2903 {
2896 endedColliders.Add(localID); 2904 endedColliders.Add(localID);
2897 } 2905 }
2906
2898 m_lastColliders.Clear(); 2907 m_lastColliders.Clear();
2899 } 2908 }
2900 else 2909 else
@@ -2910,19 +2919,39 @@ namespace OpenSim.Region.Framework.Scenes
2910 2919
2911 foreach (uint id in collissionswith.Keys) 2920 foreach (uint id in collissionswith.Keys)
2912 { 2921 {
2913 thisHitColliders.Add(id); 2922 if(id == 0)
2914 if (!m_lastColliders.Contains(id))
2915 { 2923 {
2916 startedColliders.Add(id); 2924 thisHitLand = true;
2917 2925 if (!m_lastLandCollide)
2918 curcontact = collissionswith[id]; 2926 {
2919 if (Math.Abs(curcontact.RelativeSpeed) > 0.2) 2927 startLand = true;
2928 curcontact = collissionswith[id];
2929 if (Math.Abs(curcontact.RelativeSpeed) > 0.2)
2930 {
2931 soundinfo = new CollisionForSoundInfo();
2932 soundinfo.colliderID = id;
2933 soundinfo.position = curcontact.Position;
2934 soundinfo.relativeVel = curcontact.RelativeSpeed;
2935 soundinfolist.Add(soundinfo);
2936 }
2937 }
2938 }
2939 else
2940 {
2941 thisHitColliders.Add(id);
2942 if (!m_lastColliders.Contains(id))
2920 { 2943 {
2921 soundinfo = new CollisionForSoundInfo(); 2944 startedColliders.Add(id);
2922 soundinfo.colliderID = id; 2945
2923 soundinfo.position = curcontact.Position; 2946 curcontact = collissionswith[id];
2924 soundinfo.relativeVel = curcontact.RelativeSpeed; 2947 if (Math.Abs(curcontact.RelativeSpeed) > 0.2)
2925 soundinfolist.Add(soundinfo); 2948 {
2949 soundinfo = new CollisionForSoundInfo();
2950 soundinfo.colliderID = id;
2951 soundinfo.position = curcontact.Position;
2952 soundinfo.relativeVel = curcontact.RelativeSpeed;
2953 soundinfolist.Add(soundinfo);
2954 }
2926 } 2955 }
2927 } 2956 }
2928 } 2957 }
@@ -2931,9 +2960,18 @@ namespace OpenSim.Region.Framework.Scenes
2931 { 2960 {
2932 foreach (uint id in collissionswith.Keys) 2961 foreach (uint id in collissionswith.Keys)
2933 { 2962 {
2934 thisHitColliders.Add(id); 2963 if(id == 0)
2935 if (!m_lastColliders.Contains(id)) 2964 {
2936 startedColliders.Add(id); 2965 thisHitLand = true;
2966 if (!m_lastLandCollide)
2967 startLand = true;
2968 }
2969 else
2970 {
2971 thisHitColliders.Add(id);
2972 if (!m_lastColliders.Contains(id))
2973 startedColliders.Add(id);
2974 }
2937 } 2975 }
2938 } 2976 }
2939 2977
@@ -2952,22 +2990,32 @@ namespace OpenSim.Region.Framework.Scenes
2952 foreach (uint localID in endedColliders) 2990 foreach (uint localID in endedColliders)
2953 m_lastColliders.Remove(localID); 2991 m_lastColliders.Remove(localID);
2954 2992
2993 if(m_lastLandCollide && !thisHitLand)
2994 endedLand = true;
2995
2996 m_lastLandCollide = thisHitLand;
2997
2955 // play sounds. 2998 // play sounds.
2956 if (soundinfolist.Count > 0) 2999 if (soundinfolist.Count > 0)
2957 CollisionSounds.PartCollisionSound(this, soundinfolist); 3000 CollisionSounds.PartCollisionSound(this, soundinfolist);
2958 } 3001 }
3002
3003 EventManager eventmanager = ParentGroup.Scene.EventManager;
2959 3004
2960 SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); 3005 SendCollisionEvent(scriptEvents.collision_start, startedColliders, eventmanager.TriggerScriptCollidingStart);
2961 if (!VolumeDetectActive) 3006 if (!VolumeDetectActive)
2962 SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); 3007 SendCollisionEvent(scriptEvents.collision , m_lastColliders , eventmanager.TriggerScriptColliding);
2963 SendCollisionEvent(scriptEvents.collision_end , endedColliders , ParentGroup.Scene.EventManager.TriggerScriptCollidingEnd); 3008 SendCollisionEvent(scriptEvents.collision_end , endedColliders , eventmanager.TriggerScriptCollidingEnd);
2964 3009
2965 if (startedColliders.Contains(0)) 3010 if (!VolumeDetectActive)
2966 SendLandCollisionEvent(scriptEvents.land_collision_start, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingStart); 3011 {
2967 if (m_lastColliders.Contains(0)) 3012 if (startLand)
2968 SendLandCollisionEvent(scriptEvents.land_collision, ParentGroup.Scene.EventManager.TriggerScriptLandColliding); 3013 SendLandCollisionEvent(scriptEvents.land_collision_start, eventmanager.TriggerScriptLandCollidingStart);
2969 if (endedColliders.Contains(0)) 3014 if (m_lastLandCollide)
2970 SendLandCollisionEvent(scriptEvents.land_collision_end, ParentGroup.Scene.EventManager.TriggerScriptLandCollidingEnd); 3015 SendLandCollisionEvent(scriptEvents.land_collision, eventmanager.TriggerScriptLandColliding);
3016 if (endedLand)
3017 SendLandCollisionEvent(scriptEvents.land_collision_end, eventmanager.TriggerScriptLandCollidingEnd);
3018 }
2971 } 3019 }
2972 3020
2973 // The Collision sounds code calls this 3021 // The Collision sounds code calls this
@@ -2986,7 +3034,7 @@ namespace OpenSim.Region.Framework.Scenes
2986 volume = 0; 3034 volume = 0;
2987 3035
2988 int now = Util.EnvironmentTickCount(); 3036 int now = Util.EnvironmentTickCount();
2989 if(Util.EnvironmentTickCountSubtract(now,LastColSoundSentTime) <200) 3037 if(Util.EnvironmentTickCountSubtract(now, LastColSoundSentTime) < 200)
2990 return; 3038 return;
2991 3039
2992 LastColSoundSentTime = now; 3040 LastColSoundSentTime = now;
diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs
index 005caee..44e722c 100644
--- a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs
+++ b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs
@@ -1240,7 +1240,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1240 SentEmptyCollisionsEvent = true; 1240 SentEmptyCollisionsEvent = true;
1241// _parent_scene.RemoveCollisionEventReporting(this); 1241// _parent_scene.RemoveCollisionEventReporting(this);
1242 } 1242 }
1243 else if(Body == IntPtr.Zero || d.BodyIsEnabled(Body)) 1243 else if(Body == IntPtr.Zero || (d.BodyIsEnabled(Body) && m_bodydisablecontrol >= 0 ))
1244 { 1244 {
1245 SentEmptyCollisionsEvent = false; 1245 SentEmptyCollisionsEvent = false;
1246 CollisionEventsThisFrame.Clear(); 1246 CollisionEventsThisFrame.Clear();
@@ -3595,7 +3595,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
3595 _zeroFlag = true; 3595 _zeroFlag = true;
3596 d.BodySetAutoDisableSteps(Body, 1); 3596 d.BodySetAutoDisableSteps(Body, 1);
3597 d.BodyEnable(Body); 3597 d.BodyEnable(Body);
3598 m_bodydisablecontrol = -4; 3598 m_bodydisablecontrol = -3;
3599 } 3599 }
3600 3600
3601 if(m_bodydisablecontrol < 0) 3601 if(m_bodydisablecontrol < 0)
diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs
index 5758e0a..004ee7f 100644
--- a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs
+++ b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs
@@ -203,8 +203,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde
203 private float metersInSpace = 25.6f; 203 private float metersInSpace = 25.6f;
204 private float m_timeDilation = 1.0f; 204 private float m_timeDilation = 1.0f;
205 205
206 private DateTime m_lastframe; 206 private double m_lastframe;
207 private DateTime m_lastMeshExpire; 207 private double m_lastMeshExpire;
208 208
209 public float gravityx = 0f; 209 public float gravityx = 0f;
210 public float gravityy = 0f; 210 public float gravityy = 0f;
@@ -629,8 +629,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde
629 staticPrimspaceOffRegion[i] = newspace; 629 staticPrimspaceOffRegion[i] = newspace;
630 } 630 }
631 631
632 m_lastframe = DateTime.UtcNow; 632 m_lastframe = Util.GetTimeStamp();
633 m_lastMeshExpire = m_lastframe; 633 m_lastMeshExpire = m_lastframe;
634 step_time = -1;
634 } 635 }
635 636
636 internal void waitForSpaceUnlock(IntPtr space) 637 internal void waitForSpaceUnlock(IntPtr space)
@@ -1625,6 +1626,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1625 } 1626 }
1626 m_log.InfoFormat("[ubOde] {0} prim actors loaded",_prims.Count); 1627 m_log.InfoFormat("[ubOde] {0} prim actors loaded",_prims.Count);
1627 } 1628 }
1629 m_lastframe = Util.GetTimeStamp() + 0.5;
1630 step_time = -0.5f;
1628 } 1631 }
1629 1632
1630 /// <summary> 1633 /// <summary>
@@ -1638,13 +1641,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1638 /// <returns></returns> 1641 /// <returns></returns>
1639 public override float Simulate(float reqTimeStep) 1642 public override float Simulate(float reqTimeStep)
1640 { 1643 {
1641 DateTime now = DateTime.UtcNow; 1644 double now = Util.GetTimeStamp();
1642 TimeSpan timedif = now - m_lastframe; 1645 double timeStep = now - m_lastframe;
1643 float timeStep = (float)timedif.TotalSeconds;
1644 m_lastframe = now; 1646 m_lastframe = now;
1645 1647
1646 // acumulate time so we can reduce error 1648 // acumulate time so we can reduce error
1647 step_time += timeStep; 1649 step_time += (float)timeStep;
1648 1650
1649 if (step_time < HalfOdeStep) 1651 if (step_time < HalfOdeStep)
1650 return 0; 1652 return 0;
@@ -1853,14 +1855,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1853 } 1855 }
1854 } 1856 }
1855 1857
1856 timedif = now - m_lastMeshExpire;
1857
1858 if (timedif.Seconds > 10)
1859 {
1860 mesher.ExpireReleaseMeshs();
1861 m_lastMeshExpire = now;
1862 }
1863
1864// information block for in debug breakpoint only 1858// information block for in debug breakpoint only
1865/* 1859/*
1866 int ntopactivegeoms = d.SpaceGetNumGeoms(ActiveSpace); 1860 int ntopactivegeoms = d.SpaceGetNumGeoms(ActiveSpace);
@@ -1940,7 +1934,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1940 // if we lag too much skip frames 1934 // if we lag too much skip frames
1941 m_timeDilation = 0.0f; 1935 m_timeDilation = 0.0f;
1942 step_time = 0; 1936 step_time = 0;
1943 m_lastframe = DateTime.UtcNow; // skip also the time lost 1937 m_lastframe = Util.GetTimeStamp(); // skip also the time lost
1944 } 1938 }
1945 else 1939 else
1946 { 1940 {
@@ -1948,6 +1942,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1948 if (m_timeDilation > 1) 1942 if (m_timeDilation > 1)
1949 m_timeDilation = 1; 1943 m_timeDilation = 1;
1950 } 1944 }
1945
1946 if (m_timeDilation == 1 && now - m_lastMeshExpire > 30)
1947 {
1948 mesher.ExpireReleaseMeshs();
1949 m_lastMeshExpire = now;
1950 }
1951
1952
1951 } 1953 }
1952 1954
1953 return fps; 1955 return fps;