diff options
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 5 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SimStatsReporter.cs | 42 | ||||
-rw-r--r-- | OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 316 |
3 files changed, 270 insertions, 93 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 32c7262..b79892d 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -1512,10 +1512,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1512 | StatsReporter.AddPhysicsFPS(physicsFPS); | 1512 | StatsReporter.AddPhysicsFPS(physicsFPS); |
1513 | StatsReporter.AddTimeDilation(TimeDilation); | 1513 | StatsReporter.AddTimeDilation(TimeDilation); |
1514 | StatsReporter.AddFPS(1); | 1514 | StatsReporter.AddFPS(1); |
1515 | StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount()); | ||
1516 | StatsReporter.SetChildAgents(m_sceneGraph.GetChildAgentCount()); | ||
1517 | StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount()); | ||
1518 | StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount()); | ||
1519 | 1515 | ||
1520 | // frameMS currently records work frame times, not total frame times (work + any required sleep to | 1516 | // frameMS currently records work frame times, not total frame times (work + any required sleep to |
1521 | // reach min frame time. | 1517 | // reach min frame time. |
@@ -1524,7 +1520,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1524 | StatsReporter.addAgentMS(agentMS); | 1520 | StatsReporter.addAgentMS(agentMS); |
1525 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); | 1521 | StatsReporter.addPhysicsMS(physicsMS + physicsMS2); |
1526 | StatsReporter.addOtherMS(otherMS); | 1522 | StatsReporter.addOtherMS(otherMS); |
1527 | StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount()); | ||
1528 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); | 1523 | StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); |
1529 | 1524 | ||
1530 | if (LoginsDisabled && Frame == 20) | 1525 | if (LoginsDisabled && Frame == 20) |
diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs index cb102d0..0efe4c4 100644 --- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs | |||
@@ -222,6 +222,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
222 | m_report.Close(); | 222 | m_report.Close(); |
223 | } | 223 | } |
224 | 224 | ||
225 | /// <summary> | ||
226 | /// Sets the number of milliseconds between stat updates. | ||
227 | /// </summary> | ||
228 | /// <param name='ms'></param> | ||
225 | public void SetUpdateMS(int ms) | 229 | public void SetUpdateMS(int ms) |
226 | { | 230 | { |
227 | statsUpdatesEveryMS = ms; | 231 | statsUpdatesEveryMS = ms; |
@@ -296,6 +300,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
296 | sparetime = TotalFrameTime; | 300 | sparetime = TotalFrameTime; |
297 | sleeptime = m_sleeptimeMS * perframe; | 301 | sleeptime = m_sleeptimeMS * perframe; |
298 | } | 302 | } |
303 | |||
304 | m_rootAgents = m_scene.SceneGraph.GetRootAgentCount(); | ||
305 | m_childAgents = m_scene.SceneGraph.GetChildAgentCount(); | ||
306 | m_numPrim = m_scene.SceneGraph.GetTotalObjectsCount(); | ||
307 | m_activePrim = m_scene.SceneGraph.GetActiveObjectsCount(); | ||
308 | m_activeScripts = m_scene.SceneGraph.GetActiveScriptsCount(); | ||
309 | |||
310 | // FIXME: Checking for stat sanity is a complex approach. What we really need to do is fix the code | ||
311 | // so that stat numbers are always consistent. | ||
312 | CheckStatSanity(); | ||
299 | 313 | ||
300 | // other MS is actually simulation time | 314 | // other MS is actually simulation time |
301 | // m_otherMS = m_frameMS - m_physicsMS - m_imageMS - m_netMS - m_agentMS; | 315 | // m_otherMS = m_frameMS - m_physicsMS - m_imageMS - m_netMS - m_agentMS; |
@@ -462,13 +476,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
462 | m_timeDilation = td; | 476 | m_timeDilation = td; |
463 | } | 477 | } |
464 | 478 | ||
465 | public void SetRootAgents(int rootAgents) | ||
466 | { | ||
467 | m_rootAgents = rootAgents; | ||
468 | CheckStatSanity(); | ||
469 | |||
470 | } | ||
471 | |||
472 | internal void CheckStatSanity() | 479 | internal void CheckStatSanity() |
473 | { | 480 | { |
474 | if (m_rootAgents < 0 || m_childAgents < 0) | 481 | if (m_rootAgents < 0 || m_childAgents < 0) |
@@ -485,22 +492,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
485 | } | 492 | } |
486 | } | 493 | } |
487 | 494 | ||
488 | public void SetChildAgents(int childAgents) | ||
489 | { | ||
490 | m_childAgents = childAgents; | ||
491 | CheckStatSanity(); | ||
492 | } | ||
493 | |||
494 | public void SetObjects(int objects) | ||
495 | { | ||
496 | m_numPrim = objects; | ||
497 | } | ||
498 | |||
499 | public void SetActiveObjects(int objects) | ||
500 | { | ||
501 | m_activePrim = objects; | ||
502 | } | ||
503 | |||
504 | public void AddFPS(int frames) | 495 | public void AddFPS(int frames) |
505 | { | 496 | { |
506 | m_fps += frames; | 497 | m_fps += frames; |
@@ -587,11 +578,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
587 | m_scriptLinesPerSecond += count; | 578 | m_scriptLinesPerSecond += count; |
588 | } | 579 | } |
589 | 580 | ||
590 | public void SetActiveScripts(int count) | ||
591 | { | ||
592 | m_activeScripts = count; | ||
593 | } | ||
594 | |||
595 | public void AddPacketsStats(int inPackets, int outPackets, int unAckedBytes) | 581 | public void AddPacketsStats(int inPackets, int outPackets, int unAckedBytes) |
596 | { | 582 | { |
597 | AddInPackets(inPackets); | 583 | AddInPackets(inPackets); |
diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs index fa65945..c6ecc68 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs | |||
@@ -30,20 +30,21 @@ | |||
30 | 30 | ||
31 | using System; | 31 | using System; |
32 | using System.Collections.Generic; | 32 | using System.Collections.Generic; |
33 | using System.Diagnostics; | ||
34 | using System.IO; | ||
35 | using System.Linq; | ||
33 | using System.Reflection; | 36 | using System.Reflection; |
34 | using System.Runtime.InteropServices; | 37 | using System.Runtime.InteropServices; |
35 | using System.Threading; | 38 | using System.Threading; |
36 | using System.IO; | ||
37 | using System.Diagnostics; | ||
38 | using log4net; | 39 | using log4net; |
39 | using Nini.Config; | 40 | using Nini.Config; |
40 | using Ode.NET; | 41 | using Ode.NET; |
42 | using OpenMetaverse; | ||
41 | #if USE_DRAWSTUFF | 43 | #if USE_DRAWSTUFF |
42 | using Drawstuff.NET; | 44 | using Drawstuff.NET; |
43 | #endif | 45 | #endif |
44 | using OpenSim.Framework; | 46 | using OpenSim.Framework; |
45 | using OpenSim.Region.Physics.Manager; | 47 | using OpenSim.Region.Physics.Manager; |
46 | using OpenMetaverse; | ||
47 | 48 | ||
48 | namespace OpenSim.Region.Physics.OdePlugin | 49 | namespace OpenSim.Region.Physics.OdePlugin |
49 | { | 50 | { |
@@ -54,15 +55,15 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
54 | End = 2 | 55 | End = 2 |
55 | } | 56 | } |
56 | 57 | ||
57 | public struct sCollisionData | 58 | // public struct sCollisionData |
58 | { | 59 | // { |
59 | public uint ColliderLocalId; | 60 | // public uint ColliderLocalId; |
60 | public uint CollidedWithLocalId; | 61 | // public uint CollidedWithLocalId; |
61 | public int NumberOfCollisions; | 62 | // public int NumberOfCollisions; |
62 | public int CollisionType; | 63 | // public int CollisionType; |
63 | public int StatusIndicator; | 64 | // public int StatusIndicator; |
64 | public int lastframe; | 65 | // public int lastframe; |
65 | } | 66 | // } |
66 | 67 | ||
67 | [Flags] | 68 | [Flags] |
68 | public enum CollisionCategories : int | 69 | public enum CollisionCategories : int |
@@ -142,14 +143,102 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
142 | private Dictionary<string, float> m_stats = new Dictionary<string, float>(); | 143 | private Dictionary<string, float> m_stats = new Dictionary<string, float>(); |
143 | 144 | ||
144 | /// <summary> | 145 | /// <summary> |
145 | /// Stat name for recording the number of milliseconds that ODE spends in native collision code. | 146 | /// Stat name for total number of avatars in this ODE scene. |
147 | /// </summary> | ||
148 | public const string ODETotalAvatarsStatName = "ODETotalAvatars"; | ||
149 | |||
150 | /// <summary> | ||
151 | /// Stat name for total number of prims in this ODE scene. | ||
152 | /// </summary> | ||
153 | public const string ODETotalPrimsStatName = "ODETotalPrims"; | ||
154 | |||
155 | /// <summary> | ||
156 | /// Stat name for total number of prims with active physics in this ODE scene. | ||
157 | /// </summary> | ||
158 | public const string ODEActivePrimsStatName = "ODEActivePrims"; | ||
159 | |||
160 | /// <summary> | ||
161 | /// Stat name for the total time spent in ODE frame processing. | ||
162 | /// </summary> | ||
163 | /// <remarks> | ||
164 | /// A sanity check for the main scene loop physics time. | ||
165 | /// </remarks> | ||
166 | public const string ODETotalFrameMsStatName = "ODETotalFrameMS"; | ||
167 | |||
168 | /// <summary> | ||
169 | /// Stat name for time spent processing avatar taints per frame | ||
170 | /// </summary> | ||
171 | public const string ODEAvatarTaintMsStatName = "ODEAvatarTaintFrameMS"; | ||
172 | |||
173 | /// <summary> | ||
174 | /// Stat name for time spent processing prim taints per frame | ||
175 | /// </summary> | ||
176 | public const string ODEPrimTaintMsStatName = "ODEPrimTaintFrameMS"; | ||
177 | |||
178 | /// <summary> | ||
179 | /// Stat name for time spent calculating avatar forces per frame. | ||
180 | /// </summary> | ||
181 | public const string ODEAvatarForcesFrameMsStatName = "ODEAvatarForcesFrameMS"; | ||
182 | |||
183 | /// <summary> | ||
184 | /// Stat name for time spent calculating prim forces per frame | ||
185 | /// </summary> | ||
186 | public const string ODEPrimForcesFrameMsStatName = "ODEPrimForcesFrameMS"; | ||
187 | |||
188 | /// <summary> | ||
189 | /// Stat name for time spent fulfilling raycasting requests per frame | ||
190 | /// </summary> | ||
191 | public const string ODERaycastingFrameMsStatName = "ODERaycastingFrameMS"; | ||
192 | |||
193 | /// <summary> | ||
194 | /// Stat name for time spent in native code that actually steps through the simulation. | ||
195 | /// </summary> | ||
196 | public const string ODENativeStepFrameMsStatName = "ODENativeStepFrameMS"; | ||
197 | |||
198 | /// <summary> | ||
199 | /// Stat name for the number of milliseconds that ODE spends in native space collision code. | ||
200 | /// </summary> | ||
201 | public const string ODENativeSpaceCollisionFrameMsStatName = "ODENativeSpaceCollisionFrameMS"; | ||
202 | |||
203 | /// <summary> | ||
204 | /// Stat name for milliseconds that ODE spends in native geom collision code. | ||
205 | /// </summary> | ||
206 | public const string ODENativeGeomCollisionFrameMsStatName = "ODENativeGeomCollisionFrameMS"; | ||
207 | |||
208 | /// <summary> | ||
209 | /// Time spent in collision processing that is not spent in native space or geom collision code. | ||
210 | /// </summary> | ||
211 | public const string ODEOtherCollisionFrameMsStatName = "ODEOtherCollisionFrameMS"; | ||
212 | |||
213 | /// <summary> | ||
214 | /// Stat name for time spent notifying listeners of collisions | ||
215 | /// </summary> | ||
216 | public const string ODECollisionNotificationFrameMsStatName = "ODECollisionNotificationFrameMS"; | ||
217 | |||
218 | /// <summary> | ||
219 | /// Stat name for milliseconds spent updating avatar position and velocity | ||
220 | /// </summary> | ||
221 | public const string ODEAvatarUpdateFrameMsStatName = "ODEAvatarUpdateFrameMS"; | ||
222 | |||
223 | /// <summary> | ||
224 | /// Stat name for the milliseconds spent updating prim position and velocity | ||
225 | /// </summary> | ||
226 | public const string ODEPrimUpdateFrameMsStatName = "ODEPrimUpdateFrameMS"; | ||
227 | |||
228 | /// <summary> | ||
229 | /// Stat name for avatar collisions with another entity. | ||
230 | /// </summary> | ||
231 | public const string ODEAvatarContactsStatsName = "ODEAvatarContacts"; | ||
232 | |||
233 | /// <summary> | ||
234 | /// Stat name for prim collisions with another entity. | ||
146 | /// </summary> | 235 | /// </summary> |
147 | public const string ODENativeCollisionFrameMsStatName = "ODENativeCollisionFrameMS"; | 236 | public const string ODEPrimContactsStatName = "ODEPrimContacts"; |
148 | 237 | ||
149 | /// <summary> | 238 | /// <summary> |
150 | /// Used to hold tick numbers for stat collection purposes. | 239 | /// Used to hold tick numbers for stat collection purposes. |
151 | /// </summary> | 240 | /// </summary> |
152 | private int m_nativeCollisionTickRecorder; | 241 | private int m_nativeCollisionStartTick; |
153 | 242 | ||
154 | /// <summary> | 243 | /// <summary> |
155 | /// A messy way to tell if we need to avoid adding a collision time because this was already done in the callback. | 244 | /// A messy way to tell if we need to avoid adding a collision time because this was already done in the callback. |
@@ -157,6 +246,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
157 | private bool m_inCollisionTiming; | 246 | private bool m_inCollisionTiming; |
158 | 247 | ||
159 | /// <summary> | 248 | /// <summary> |
249 | /// A temporary holder for the number of avatar collisions in a frame, so we can work out how many object | ||
250 | /// collisions occured using the _perloopcontact if stats collection is enabled. | ||
251 | /// </summary> | ||
252 | private int m_tempAvatarCollisionsThisFrame; | ||
253 | |||
254 | /// <summary> | ||
160 | /// Used in calculating physics frame time dilation | 255 | /// Used in calculating physics frame time dilation |
161 | /// </summary> | 256 | /// </summary> |
162 | private int tickCountFrameRun; | 257 | private int tickCountFrameRun; |
@@ -472,7 +567,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
472 | // Initialize the mesh plugin | 567 | // Initialize the mesh plugin |
473 | public override void Initialise(IMesher meshmerizer, IConfigSource config) | 568 | public override void Initialise(IMesher meshmerizer, IConfigSource config) |
474 | { | 569 | { |
475 | m_stats[ODENativeCollisionFrameMsStatName] = 0; | 570 | InitializeExtraStats(); |
476 | 571 | ||
477 | mesher = meshmerizer; | 572 | mesher = meshmerizer; |
478 | m_config = config; | 573 | m_config = config; |
@@ -818,7 +913,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
818 | { | 913 | { |
819 | // We do this inside the lock so that we don't count any delay in acquiring it | 914 | // We do this inside the lock so that we don't count any delay in acquiring it |
820 | if (CollectStats) | 915 | if (CollectStats) |
821 | m_nativeCollisionTickRecorder = Util.EnvironmentTickCount(); | 916 | m_nativeCollisionStartTick = Util.EnvironmentTickCount(); |
822 | 917 | ||
823 | count = d.Collide(geom1, geom2, maxContacts, contactsArray, contactGeomSize); | 918 | count = d.Collide(geom1, geom2, maxContacts, contactsArray, contactGeomSize); |
824 | } | 919 | } |
@@ -826,8 +921,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
826 | // We do this outside the lock so that any waiting threads aren't held up, though the effect is probably | 921 | // We do this outside the lock so that any waiting threads aren't held up, though the effect is probably |
827 | // negligable | 922 | // negligable |
828 | if (CollectStats) | 923 | if (CollectStats) |
829 | m_stats[ODENativeCollisionFrameMsStatName] | 924 | m_stats[ODENativeGeomCollisionFrameMsStatName] |
830 | += Util.EnvironmentTickCountSubtract(m_nativeCollisionTickRecorder); | 925 | += Util.EnvironmentTickCountSubtract(m_nativeCollisionStartTick); |
831 | 926 | ||
832 | return count; | 927 | return count; |
833 | } | 928 | } |
@@ -843,15 +938,15 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
843 | if (CollectStats) | 938 | if (CollectStats) |
844 | { | 939 | { |
845 | m_inCollisionTiming = true; | 940 | m_inCollisionTiming = true; |
846 | m_nativeCollisionTickRecorder = Util.EnvironmentTickCount(); | 941 | m_nativeCollisionStartTick = Util.EnvironmentTickCount(); |
847 | } | 942 | } |
848 | 943 | ||
849 | d.SpaceCollide2(space1, space2, data, nearCallback); | 944 | d.SpaceCollide2(space1, space2, data, nearCallback); |
850 | 945 | ||
851 | if (CollectStats && m_inCollisionTiming) | 946 | if (CollectStats && m_inCollisionTiming) |
852 | { | 947 | { |
853 | m_stats[ODENativeCollisionFrameMsStatName] | 948 | m_stats[ODENativeSpaceCollisionFrameMsStatName] |
854 | += Util.EnvironmentTickCountSubtract(m_nativeCollisionTickRecorder); | 949 | += Util.EnvironmentTickCountSubtract(m_nativeCollisionStartTick); |
855 | m_inCollisionTiming = false; | 950 | m_inCollisionTiming = false; |
856 | } | 951 | } |
857 | } | 952 | } |
@@ -866,8 +961,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
866 | { | 961 | { |
867 | if (CollectStats && m_inCollisionTiming) | 962 | if (CollectStats && m_inCollisionTiming) |
868 | { | 963 | { |
869 | m_stats[ODENativeCollisionFrameMsStatName] | 964 | m_stats[ODENativeSpaceCollisionFrameMsStatName] |
870 | += Util.EnvironmentTickCountSubtract(m_nativeCollisionTickRecorder); | 965 | += Util.EnvironmentTickCountSubtract(m_nativeCollisionStartTick); |
871 | m_inCollisionTiming = false; | 966 | m_inCollisionTiming = false; |
872 | } | 967 | } |
873 | 968 | ||
@@ -945,6 +1040,10 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
945 | 1040 | ||
946 | count = CollideGeoms(g1, g2, contacts.Length, contacts, d.ContactGeom.SizeOf); | 1041 | count = CollideGeoms(g1, g2, contacts.Length, contacts, d.ContactGeom.SizeOf); |
947 | 1042 | ||
1043 | // All code after this is only relevant if we have any collisions | ||
1044 | if (count <= 0) | ||
1045 | return; | ||
1046 | |||
948 | if (count > contacts.Length) | 1047 | if (count > contacts.Length) |
949 | m_log.Error("[ODE SCENE]: Got " + count + " contacts when we asked for a maximum of " + contacts.Length); | 1048 | m_log.Error("[ODE SCENE]: Got " + count + " contacts when we asked for a maximum of " + contacts.Length); |
950 | } | 1049 | } |
@@ -1212,14 +1311,12 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1212 | { | 1311 | { |
1213 | _perloopContact.Add(curContact); | 1312 | _perloopContact.Add(curContact); |
1214 | 1313 | ||
1215 | // If we're colliding against terrain | ||
1216 | if (name1 == "Terrain" || name2 == "Terrain") | 1314 | if (name1 == "Terrain" || name2 == "Terrain") |
1217 | { | 1315 | { |
1218 | // If we're moving | ||
1219 | if ((p2.PhysicsActorType == (int) ActorTypes.Agent) && | 1316 | if ((p2.PhysicsActorType == (int) ActorTypes.Agent) && |
1220 | (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f)) | 1317 | (Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f)) |
1221 | { | 1318 | { |
1222 | // Use the movement terrain contact | 1319 | // Avatar is moving on terrain, use the movement terrain contact |
1223 | AvatarMovementTerrainContact.geom = curContact; | 1320 | AvatarMovementTerrainContact.geom = curContact; |
1224 | 1321 | ||
1225 | if (m_global_contactcount < maxContactsbeforedeath) | 1322 | if (m_global_contactcount < maxContactsbeforedeath) |
@@ -1232,7 +1329,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1232 | { | 1329 | { |
1233 | if (p2.PhysicsActorType == (int)ActorTypes.Agent) | 1330 | if (p2.PhysicsActorType == (int)ActorTypes.Agent) |
1234 | { | 1331 | { |
1235 | // Use the non moving terrain contact | 1332 | // Avatar is standing on terrain, use the non moving terrain contact |
1236 | TerrainContact.geom = curContact; | 1333 | TerrainContact.geom = curContact; |
1237 | 1334 | ||
1238 | if (m_global_contactcount < maxContactsbeforedeath) | 1335 | if (m_global_contactcount < maxContactsbeforedeath) |
@@ -1327,13 +1424,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1327 | } | 1424 | } |
1328 | else | 1425 | else |
1329 | { | 1426 | { |
1330 | // we're colliding with prim or avatar | ||
1331 | // check if we're moving | ||
1332 | if ((p2.PhysicsActorType == (int)ActorTypes.Agent)) | 1427 | if ((p2.PhysicsActorType == (int)ActorTypes.Agent)) |
1333 | { | 1428 | { |
1334 | if ((Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f)) | 1429 | if ((Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f)) |
1335 | { | 1430 | { |
1336 | // Use the Movement prim contact | 1431 | // Avatar is moving on a prim, use the Movement prim contact |
1337 | AvatarMovementprimContact.geom = curContact; | 1432 | AvatarMovementprimContact.geom = curContact; |
1338 | 1433 | ||
1339 | if (m_global_contactcount < maxContactsbeforedeath) | 1434 | if (m_global_contactcount < maxContactsbeforedeath) |
@@ -1344,9 +1439,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1344 | } | 1439 | } |
1345 | else | 1440 | else |
1346 | { | 1441 | { |
1347 | // Use the non movement contact | 1442 | // Avatar is standing still on a prim, use the non movement contact |
1348 | contact.geom = curContact; | 1443 | contact.geom = curContact; |
1349 | _perloopContact.Add(curContact); | ||
1350 | 1444 | ||
1351 | if (m_global_contactcount < maxContactsbeforedeath) | 1445 | if (m_global_contactcount < maxContactsbeforedeath) |
1352 | { | 1446 | { |
@@ -1454,7 +1548,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1454 | break; | 1548 | break; |
1455 | } | 1549 | } |
1456 | } | 1550 | } |
1457 | //m_log.DebugFormat("[Collsion]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth)); | 1551 | //m_log.DebugFormat("[Collision]: Depth {0}", Math.Abs(contact.depth - contactGeom.depth)); |
1458 | //m_log.DebugFormat("[Collision]: <{0},{1},{2}>", Math.Abs(contactGeom.normal.X - contact.normal.X), Math.Abs(contactGeom.normal.Y - contact.normal.Y), Math.Abs(contactGeom.normal.Z - contact.normal.Z)); | 1552 | //m_log.DebugFormat("[Collision]: <{0},{1},{2}>", Math.Abs(contactGeom.normal.X - contact.normal.X), Math.Abs(contactGeom.normal.Y - contact.normal.Y), Math.Abs(contactGeom.normal.Z - contact.normal.Z)); |
1459 | } | 1553 | } |
1460 | } | 1554 | } |
@@ -1692,8 +1786,11 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1692 | //} | 1786 | //} |
1693 | } | 1787 | } |
1694 | 1788 | ||
1695 | // if (framecount % 55 == 0) | 1789 | if (CollectStats) |
1696 | // m_log.DebugFormat("Processed {0} collisions", _perloopContact.Count); | 1790 | { |
1791 | m_tempAvatarCollisionsThisFrame = _perloopContact.Count; | ||
1792 | m_stats[ODEAvatarContactsStatsName] += m_tempAvatarCollisionsThisFrame; | ||
1793 | } | ||
1697 | 1794 | ||
1698 | List<OdePrim> removeprims = null; | 1795 | List<OdePrim> removeprims = null; |
1699 | foreach (OdePrim chr in _activeprims) | 1796 | foreach (OdePrim chr in _activeprims) |
@@ -1727,6 +1824,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1727 | } | 1824 | } |
1728 | } | 1825 | } |
1729 | 1826 | ||
1827 | if (CollectStats) | ||
1828 | m_stats[ODEPrimContactsStatName] += _perloopContact.Count - m_tempAvatarCollisionsThisFrame; | ||
1829 | |||
1730 | if (removeprims != null) | 1830 | if (removeprims != null) |
1731 | { | 1831 | { |
1732 | foreach (OdePrim chr in removeprims) | 1832 | foreach (OdePrim chr in removeprims) |
@@ -2785,21 +2885,23 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2785 | 2885 | ||
2786 | /// <summary> | 2886 | /// <summary> |
2787 | /// This is our main simulate loop | 2887 | /// This is our main simulate loop |
2888 | /// </summary> | ||
2889 | /// <remarks> | ||
2788 | /// It's thread locked by a Mutex in the scene. | 2890 | /// It's thread locked by a Mutex in the scene. |
2789 | /// It holds Collisions, it instructs ODE to step through the physical reactions | 2891 | /// It holds Collisions, it instructs ODE to step through the physical reactions |
2790 | /// It moves the objects around in memory | 2892 | /// It moves the objects around in memory |
2791 | /// It calls the methods that report back to the object owners.. (scenepresence, SceneObjectGroup) | 2893 | /// It calls the methods that report back to the object owners.. (scenepresence, SceneObjectGroup) |
2792 | /// </summary> | 2894 | /// </remarks> |
2793 | /// <param name="timeStep"></param> | 2895 | /// <param name="timeStep"></param> |
2794 | /// <returns>The number of frames simulated over that period.</returns> | 2896 | /// <returns>The number of frames simulated over that period.</returns> |
2795 | public override float Simulate(float timeStep) | 2897 | public override float Simulate(float timeStep) |
2796 | { | 2898 | { |
2899 | int startFrameTick = CollectStats ? Util.EnvironmentTickCount() : 0; | ||
2900 | int tempTick = 0, tempTick2 = 0; | ||
2901 | |||
2797 | if (framecount >= int.MaxValue) | 2902 | if (framecount >= int.MaxValue) |
2798 | framecount = 0; | 2903 | framecount = 0; |
2799 | 2904 | ||
2800 | //if (m_worldOffset != Vector3.Zero) | ||
2801 | // return 0; | ||
2802 | |||
2803 | framecount++; | 2905 | framecount++; |
2804 | 2906 | ||
2805 | float fps = 0; | 2907 | float fps = 0; |
@@ -2807,7 +2909,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2807 | float timeLeft = timeStep; | 2909 | float timeLeft = timeStep; |
2808 | 2910 | ||
2809 | //m_log.Info(timeStep.ToString()); | 2911 | //m_log.Info(timeStep.ToString()); |
2810 | // step_time += timeStep; | 2912 | // step_time += timeSte |
2811 | // | 2913 | // |
2812 | // // If We're loaded down by something else, | 2914 | // // If We're loaded down by something else, |
2813 | // // or debugging with the Visual Studio project on pause | 2915 | // // or debugging with the Visual Studio project on pause |
@@ -2873,6 +2975,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2873 | { | 2975 | { |
2874 | try | 2976 | try |
2875 | { | 2977 | { |
2978 | if (CollectStats) | ||
2979 | tempTick = Util.EnvironmentTickCount(); | ||
2980 | |||
2876 | lock (_taintedActors) | 2981 | lock (_taintedActors) |
2877 | { | 2982 | { |
2878 | foreach (OdeCharacter character in _taintedActors) | 2983 | foreach (OdeCharacter character in _taintedActors) |
@@ -2881,6 +2986,13 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2881 | _taintedActors.Clear(); | 2986 | _taintedActors.Clear(); |
2882 | } | 2987 | } |
2883 | 2988 | ||
2989 | if (CollectStats) | ||
2990 | { | ||
2991 | tempTick2 = Util.EnvironmentTickCount(); | ||
2992 | m_stats[ODEAvatarTaintMsStatName] += Util.EnvironmentTickCountSubtract(tempTick2, tempTick); | ||
2993 | tempTick = tempTick2; | ||
2994 | } | ||
2995 | |||
2884 | lock (_taintedPrims) | 2996 | lock (_taintedPrims) |
2885 | { | 2997 | { |
2886 | foreach (OdePrim prim in _taintedPrims) | 2998 | foreach (OdePrim prim in _taintedPrims) |
@@ -2911,6 +3023,13 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2911 | _taintedPrims.Clear(); | 3023 | _taintedPrims.Clear(); |
2912 | } | 3024 | } |
2913 | 3025 | ||
3026 | if (CollectStats) | ||
3027 | { | ||
3028 | tempTick2 = Util.EnvironmentTickCount(); | ||
3029 | m_stats[ODEPrimTaintMsStatName] += Util.EnvironmentTickCountSubtract(tempTick2, tempTick); | ||
3030 | tempTick = tempTick2; | ||
3031 | } | ||
3032 | |||
2914 | // Move characters | 3033 | // Move characters |
2915 | foreach (OdeCharacter actor in _characters) | 3034 | foreach (OdeCharacter actor in _characters) |
2916 | actor.Move(defects); | 3035 | actor.Move(defects); |
@@ -2930,6 +3049,13 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2930 | defects.Clear(); | 3049 | defects.Clear(); |
2931 | } | 3050 | } |
2932 | 3051 | ||
3052 | if (CollectStats) | ||
3053 | { | ||
3054 | tempTick2 = Util.EnvironmentTickCount(); | ||
3055 | m_stats[ODEAvatarForcesFrameMsStatName] += Util.EnvironmentTickCountSubtract(tempTick2, tempTick); | ||
3056 | tempTick = tempTick2; | ||
3057 | } | ||
3058 | |||
2933 | // Move other active objects | 3059 | // Move other active objects |
2934 | foreach (OdePrim prim in _activeprims) | 3060 | foreach (OdePrim prim in _activeprims) |
2935 | { | 3061 | { |
@@ -2937,14 +3063,35 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2937 | prim.Move(timeStep); | 3063 | prim.Move(timeStep); |
2938 | } | 3064 | } |
2939 | 3065 | ||
3066 | if (CollectStats) | ||
3067 | { | ||
3068 | tempTick2 = Util.EnvironmentTickCount(); | ||
3069 | m_stats[ODEPrimForcesFrameMsStatName] += Util.EnvironmentTickCountSubtract(tempTick2, tempTick); | ||
3070 | tempTick = tempTick2; | ||
3071 | } | ||
3072 | |||
2940 | //if ((framecount % m_randomizeWater) == 0) | 3073 | //if ((framecount % m_randomizeWater) == 0) |
2941 | // randomizeWater(waterlevel); | 3074 | // randomizeWater(waterlevel); |
2942 | 3075 | ||
2943 | //int RayCastTimeMS = m_rayCastManager.ProcessQueuedRequests(); | 3076 | //int RayCastTimeMS = m_rayCastManager.ProcessQueuedRequests(); |
2944 | m_rayCastManager.ProcessQueuedRequests(); | 3077 | m_rayCastManager.ProcessQueuedRequests(); |
2945 | 3078 | ||
3079 | if (CollectStats) | ||
3080 | { | ||
3081 | tempTick2 = Util.EnvironmentTickCount(); | ||
3082 | m_stats[ODERaycastingFrameMsStatName] += Util.EnvironmentTickCountSubtract(tempTick2, tempTick); | ||
3083 | tempTick = tempTick2; | ||
3084 | } | ||
3085 | |||
2946 | collision_optimized(); | 3086 | collision_optimized(); |
2947 | 3087 | ||
3088 | if (CollectStats) | ||
3089 | { | ||
3090 | tempTick2 = Util.EnvironmentTickCount(); | ||
3091 | m_stats[ODEOtherCollisionFrameMsStatName] += Util.EnvironmentTickCountSubtract(tempTick2, tempTick); | ||
3092 | tempTick = tempTick2; | ||
3093 | } | ||
3094 | |||
2948 | foreach (PhysicsActor obj in _collisionEventPrim.Values) | 3095 | foreach (PhysicsActor obj in _collisionEventPrim.Values) |
2949 | { | 3096 | { |
2950 | // m_log.DebugFormat("[PHYSICS]: Assessing {0} {1} for collision events", obj.SOPName, obj.LocalID); | 3097 | // m_log.DebugFormat("[PHYSICS]: Assessing {0} {1} for collision events", obj.SOPName, obj.LocalID); |
@@ -2969,9 +3116,19 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2969 | // "[PHYSICS]: Collision contacts to process this frame = {0}", m_global_contactcount); | 3116 | // "[PHYSICS]: Collision contacts to process this frame = {0}", m_global_contactcount); |
2970 | 3117 | ||
2971 | m_global_contactcount = 0; | 3118 | m_global_contactcount = 0; |
2972 | 3119 | ||
3120 | if (CollectStats) | ||
3121 | { | ||
3122 | tempTick2 = Util.EnvironmentTickCount(); | ||
3123 | m_stats[ODECollisionNotificationFrameMsStatName] += Util.EnvironmentTickCountSubtract(tempTick2, tempTick); | ||
3124 | tempTick = tempTick2; | ||
3125 | } | ||
3126 | |||
2973 | d.WorldQuickStep(world, ODE_STEPSIZE); | 3127 | d.WorldQuickStep(world, ODE_STEPSIZE); |
2974 | 3128 | ||
3129 | if (CollectStats) | ||
3130 | m_stats[ODENativeStepFrameMsStatName] += Util.EnvironmentTickCountSubtract(tempTick); | ||
3131 | |||
2975 | d.JointGroupEmpty(contactgroup); | 3132 | d.JointGroupEmpty(contactgroup); |
2976 | } | 3133 | } |
2977 | catch (Exception e) | 3134 | catch (Exception e) |
@@ -2982,6 +3139,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2982 | timeLeft -= ODE_STEPSIZE; | 3139 | timeLeft -= ODE_STEPSIZE; |
2983 | } | 3140 | } |
2984 | 3141 | ||
3142 | if (CollectStats) | ||
3143 | tempTick = Util.EnvironmentTickCount(); | ||
3144 | |||
2985 | foreach (OdeCharacter actor in _characters) | 3145 | foreach (OdeCharacter actor in _characters) |
2986 | { | 3146 | { |
2987 | if (actor.bad) | 3147 | if (actor.bad) |
@@ -3005,6 +3165,13 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3005 | defects.Clear(); | 3165 | defects.Clear(); |
3006 | } | 3166 | } |
3007 | 3167 | ||
3168 | if (CollectStats) | ||
3169 | { | ||
3170 | tempTick2 = Util.EnvironmentTickCount(); | ||
3171 | m_stats[ODEAvatarUpdateFrameMsStatName] += Util.EnvironmentTickCountSubtract(tempTick2, tempTick); | ||
3172 | tempTick = tempTick2; | ||
3173 | } | ||
3174 | |||
3008 | //if (timeStep < 0.2f) | 3175 | //if (timeStep < 0.2f) |
3009 | 3176 | ||
3010 | foreach (OdePrim prim in _activeprims) | 3177 | foreach (OdePrim prim in _activeprims) |
@@ -3018,6 +3185,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3018 | } | 3185 | } |
3019 | } | 3186 | } |
3020 | 3187 | ||
3188 | if (CollectStats) | ||
3189 | m_stats[ODEPrimUpdateFrameMsStatName] += Util.EnvironmentTickCountSubtract(tempTick); | ||
3190 | |||
3021 | //DumpJointInfo(); | 3191 | //DumpJointInfo(); |
3022 | 3192 | ||
3023 | // Finished with all sim stepping. If requested, dump world state to file for debugging. | 3193 | // Finished with all sim stepping. If requested, dump world state to file for debugging. |
@@ -3039,7 +3209,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3039 | d.WorldExportDIF(world, fname, physics_logging_append_existing_logfile, prefix); | 3209 | d.WorldExportDIF(world, fname, physics_logging_append_existing_logfile, prefix); |
3040 | } | 3210 | } |
3041 | 3211 | ||
3042 | latertickcount = Util.EnvironmentTickCount() - tickCountFrameRun; | 3212 | latertickcount = Util.EnvironmentTickCountSubtract(tickCountFrameRun); |
3043 | 3213 | ||
3044 | // OpenSimulator above does 10 fps. 10 fps = means that the main thread loop and physics | 3214 | // OpenSimulator above does 10 fps. 10 fps = means that the main thread loop and physics |
3045 | // has a max of 100 ms to run theoretically. | 3215 | // has a max of 100 ms to run theoretically. |
@@ -3059,6 +3229,9 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3059 | tickCountFrameRun = Util.EnvironmentTickCount(); | 3229 | tickCountFrameRun = Util.EnvironmentTickCount(); |
3060 | } | 3230 | } |
3061 | 3231 | ||
3232 | if (CollectStats) | ||
3233 | m_stats[ODETotalFrameMsStatName] += Util.EnvironmentTickCountSubtract(startFrameTick); | ||
3234 | |||
3062 | return fps; | 3235 | return fps; |
3063 | } | 3236 | } |
3064 | 3237 | ||
@@ -3868,26 +4041,19 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
3868 | 4041 | ||
3869 | public override Dictionary<uint, float> GetTopColliders() | 4042 | public override Dictionary<uint, float> GetTopColliders() |
3870 | { | 4043 | { |
3871 | Dictionary<uint, float> returncolliders = new Dictionary<uint, float>(); | 4044 | Dictionary<uint, float> topColliders; |
3872 | int cnt = 0; | 4045 | |
3873 | lock (_prims) | 4046 | lock (_prims) |
3874 | { | 4047 | { |
3875 | foreach (OdePrim prm in _prims) | 4048 | List<OdePrim> orderedPrims = new List<OdePrim>(_prims); |
3876 | { | 4049 | orderedPrims.OrderByDescending(p => p.CollisionScore).Take(25); |
3877 | if (prm.CollisionScore > 0) | 4050 | topColliders = orderedPrims.ToDictionary(p => p.LocalID, p => p.CollisionScore); |
3878 | { | 4051 | |
3879 | returncolliders.Add(prm.LocalID, prm.CollisionScore); | 4052 | foreach (OdePrim p in _prims) |
3880 | cnt++; | 4053 | p.CollisionScore = 0; |
3881 | prm.CollisionScore = 0f; | ||
3882 | if (cnt > 25) | ||
3883 | { | ||
3884 | break; | ||
3885 | } | ||
3886 | } | ||
3887 | } | ||
3888 | } | 4054 | } |
3889 | 4055 | ||
3890 | return returncolliders; | 4056 | return topColliders; |
3891 | } | 4057 | } |
3892 | 4058 | ||
3893 | public override bool SupportsRayCast() | 4059 | public override bool SupportsRayCast() |
@@ -4069,10 +4235,40 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
4069 | { | 4235 | { |
4070 | returnStats = new Dictionary<string, float>(m_stats); | 4236 | returnStats = new Dictionary<string, float>(m_stats); |
4071 | 4237 | ||
4072 | m_stats[ODENativeCollisionFrameMsStatName] = 0; | 4238 | // FIXME: This is a SUPER DUMB HACK until we can establish stats that aren't subject to a division by |
4239 | // 3 from the SimStatsReporter. | ||
4240 | returnStats[ODETotalAvatarsStatName] = _characters.Count * 3; | ||
4241 | returnStats[ODETotalPrimsStatName] = _prims.Count * 3; | ||
4242 | returnStats[ODEActivePrimsStatName] = _activeprims.Count * 3; | ||
4243 | |||
4244 | InitializeExtraStats(); | ||
4073 | } | 4245 | } |
4074 | 4246 | ||
4247 | returnStats[ODEOtherCollisionFrameMsStatName] | ||
4248 | = returnStats[ODEOtherCollisionFrameMsStatName] | ||
4249 | - returnStats[ODENativeSpaceCollisionFrameMsStatName] | ||
4250 | - returnStats[ODENativeGeomCollisionFrameMsStatName]; | ||
4251 | |||
4075 | return returnStats; | 4252 | return returnStats; |
4076 | } | 4253 | } |
4254 | |||
4255 | private void InitializeExtraStats() | ||
4256 | { | ||
4257 | m_stats[ODETotalFrameMsStatName] = 0; | ||
4258 | m_stats[ODEAvatarTaintMsStatName] = 0; | ||
4259 | m_stats[ODEPrimTaintMsStatName] = 0; | ||
4260 | m_stats[ODEAvatarForcesFrameMsStatName] = 0; | ||
4261 | m_stats[ODEPrimForcesFrameMsStatName] = 0; | ||
4262 | m_stats[ODERaycastingFrameMsStatName] = 0; | ||
4263 | m_stats[ODENativeStepFrameMsStatName] = 0; | ||
4264 | m_stats[ODENativeSpaceCollisionFrameMsStatName] = 0; | ||
4265 | m_stats[ODENativeGeomCollisionFrameMsStatName] = 0; | ||
4266 | m_stats[ODEOtherCollisionFrameMsStatName] = 0; | ||
4267 | m_stats[ODECollisionNotificationFrameMsStatName] = 0; | ||
4268 | m_stats[ODEAvatarContactsStatsName] = 0; | ||
4269 | m_stats[ODEPrimContactsStatName] = 0; | ||
4270 | m_stats[ODEAvatarUpdateFrameMsStatName] = 0; | ||
4271 | m_stats[ODEPrimUpdateFrameMsStatName] = 0; | ||
4272 | } | ||
4077 | } | 4273 | } |
4078 | } \ No newline at end of file | 4274 | } \ No newline at end of file |