diff options
author | John Hurliman | 2009-10-28 23:10:16 -0700 |
---|---|---|
committer | John Hurliman | 2009-10-28 23:10:16 -0700 |
commit | 59eb378d16fd8a9e887560a2744cc798fef08263 (patch) | |
tree | 4bcb0d1f3b00ecbc17ee220928646aaba09d334c /OpenSim/Region/Framework/Scenes/ScenePresence.cs | |
parent | Always send a time dilation of 1.0 while we debug rubberbanding issues (diff) | |
download | opensim-SC_OLD-59eb378d16fd8a9e887560a2744cc798fef08263.zip opensim-SC_OLD-59eb378d16fd8a9e887560a2744cc798fef08263.tar.gz opensim-SC_OLD-59eb378d16fd8a9e887560a2744cc798fef08263.tar.bz2 opensim-SC_OLD-59eb378d16fd8a9e887560a2744cc798fef08263.tar.xz |
Small performance tweaks to code called by the heartbeat loop
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 79 |
1 files changed, 17 insertions, 62 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 63c979f..1ea4585 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -76,8 +76,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
76 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 76 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
77 | 77 | ||
78 | private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 }; | 78 | private static readonly byte[] BAKE_INDICES = new byte[] { 8, 9, 10, 11, 19, 20 }; |
79 | 79 | public static readonly byte[] DEFAULT_TEXTURE = AvatarAppearance.GetDefaultTexture().GetBytes(); | |
80 | public static byte[] DefaultTexture; | ||
81 | 80 | ||
82 | public UUID currentParcelUUID = UUID.Zero; | 81 | public UUID currentParcelUUID = UUID.Zero; |
83 | 82 | ||
@@ -100,9 +99,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
100 | 99 | ||
101 | private bool m_updateflag; | 100 | private bool m_updateflag; |
102 | private byte m_movementflag; | 101 | private byte m_movementflag; |
103 | private readonly List<NewForce> m_forcesList = new List<NewForce>(); | 102 | private Vector3? m_forceToApply; |
104 | private uint m_requestedSitTargetID; | 103 | private uint m_requestedSitTargetID; |
105 | private UUID m_requestedSitTargetUUID = UUID.Zero; | 104 | private UUID m_requestedSitTargetUUID; |
106 | private SendCourseLocationsMethod m_sendCourseLocationsMethod; | 105 | private SendCourseLocationsMethod m_sendCourseLocationsMethod; |
107 | 106 | ||
108 | private bool m_startAnimationSet; | 107 | private bool m_startAnimationSet; |
@@ -456,12 +455,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
456 | { | 455 | { |
457 | get | 456 | get |
458 | { | 457 | { |
459 | if (m_physicsActor != null) | 458 | PhysicsActor actor = m_physicsActor; |
460 | { | 459 | if (actor != null) |
461 | m_velocity.X = m_physicsActor.Velocity.X; | 460 | m_velocity = m_physicsActor.Velocity; |
462 | m_velocity.Y = m_physicsActor.Velocity.Y; | ||
463 | m_velocity.Z = m_physicsActor.Velocity.Z; | ||
464 | } | ||
465 | 461 | ||
466 | return m_velocity; | 462 | return m_velocity; |
467 | } | 463 | } |
@@ -2278,7 +2274,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2278 | { | 2274 | { |
2279 | if (m_isChildAgent) | 2275 | if (m_isChildAgent) |
2280 | { | 2276 | { |
2281 | m_log.Debug("DEBUG: AddNewMovement: child agent, Making root agent!"); | 2277 | m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!"); |
2282 | 2278 | ||
2283 | // we have to reset the user's child agent connections. | 2279 | // we have to reset the user's child agent connections. |
2284 | // Likely, here they've lost the eventqueue for other regions so border | 2280 | // Likely, here they've lost the eventqueue for other regions so border |
@@ -2287,7 +2283,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2287 | List<ulong> regions = new List<ulong>(KnownChildRegionHandles); | 2283 | List<ulong> regions = new List<ulong>(KnownChildRegionHandles); |
2288 | regions.Remove(m_scene.RegionInfo.RegionHandle); | 2284 | regions.Remove(m_scene.RegionInfo.RegionHandle); |
2289 | 2285 | ||
2290 | MakeRootAgent(new Vector3(127, 127, 127), true); | 2286 | MakeRootAgent(new Vector3(127f, 127f, 127f), true); |
2291 | 2287 | ||
2292 | // Async command | 2288 | // Async command |
2293 | if (m_scene.SceneGridService != null) | 2289 | if (m_scene.SceneGridService != null) |
@@ -2299,28 +2295,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2299 | System.Threading.Thread.Sleep(500); | 2295 | System.Threading.Thread.Sleep(500); |
2300 | } | 2296 | } |
2301 | 2297 | ||
2302 | |||
2303 | if (m_scene.SceneGridService != null) | 2298 | if (m_scene.SceneGridService != null) |
2304 | { | 2299 | { |
2305 | m_scene.SceneGridService.EnableNeighbourChildAgents(this, new List<RegionInfo>()); | 2300 | m_scene.SceneGridService.EnableNeighbourChildAgents(this, new List<RegionInfo>()); |
2306 | } | 2301 | } |
2307 | 2302 | ||
2308 | |||
2309 | |||
2310 | return; | 2303 | return; |
2311 | } | 2304 | } |
2312 | 2305 | ||
2313 | m_perfMonMS = Environment.TickCount; | 2306 | m_perfMonMS = Environment.TickCount; |
2314 | 2307 | ||
2315 | m_rotation = rotation; | 2308 | m_rotation = rotation; |
2316 | NewForce newVelocity = new NewForce(); | ||
2317 | Vector3 direc = vec * rotation; | 2309 | Vector3 direc = vec * rotation; |
2318 | direc.Normalize(); | 2310 | direc.Normalize(); |
2319 | 2311 | ||
2320 | direc *= 0.03f * 128f * m_speedModifier; | 2312 | direc *= 0.03f * 128f * m_speedModifier; |
2321 | if (m_physicsActor.Flying) | 2313 | if (m_physicsActor.Flying) |
2322 | { | 2314 | { |
2323 | direc *= 4; | 2315 | direc *= 4.0f; |
2324 | //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); | 2316 | //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); |
2325 | //bool colliding = (m_physicsActor.IsColliding==true); | 2317 | //bool colliding = (m_physicsActor.IsColliding==true); |
2326 | //if (controlland) | 2318 | //if (controlland) |
@@ -2348,10 +2340,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2348 | } | 2340 | } |
2349 | } | 2341 | } |
2350 | 2342 | ||
2351 | newVelocity.X = direc.X; | 2343 | // TODO: Add the force instead of only setting it to support multiple forces per frame? |
2352 | newVelocity.Y = direc.Y; | 2344 | m_forceToApply = direc; |
2353 | newVelocity.Z = direc.Z; | ||
2354 | m_forcesList.Add(newVelocity); | ||
2355 | 2345 | ||
2356 | m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); | 2346 | m_scene.StatsReporter.AddAgentTime(Environment.TickCount - m_perfMonMS); |
2357 | } | 2347 | } |
@@ -3298,47 +3288,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
3298 | /// </summary> | 3288 | /// </summary> |
3299 | public override void UpdateMovement() | 3289 | public override void UpdateMovement() |
3300 | { | 3290 | { |
3301 | lock (m_forcesList) | 3291 | if (m_forceToApply.HasValue) |
3302 | { | 3292 | { |
3303 | if (m_forcesList.Count > 0) | 3293 | Vector3 force = m_forceToApply.Value; |
3304 | { | ||
3305 | //we are only interested in the last velocity added to the list [Although they are called forces, they are actually velocities] | ||
3306 | NewForce force = m_forcesList[m_forcesList.Count - 1]; | ||
3307 | 3294 | ||
3308 | m_updateflag = true; | 3295 | m_updateflag = true; |
3309 | try | 3296 | movementvector = force; |
3310 | { | 3297 | Velocity = force; |
3311 | movementvector.X = force.X; | ||
3312 | movementvector.Y = force.Y; | ||
3313 | movementvector.Z = force.Z; | ||
3314 | Velocity = movementvector; | ||
3315 | } | ||
3316 | catch (NullReferenceException) | ||
3317 | { | ||
3318 | // Under extreme load, this returns a NullReference Exception that we can ignore. | ||
3319 | // Ignoring this causes no movement to be sent to the physics engine... | ||
3320 | // which when the scene is moving at 1 frame every 10 seconds, it doesn't really matter! | ||
3321 | } | ||
3322 | 3298 | ||
3323 | m_forcesList.Clear(); | 3299 | m_forceToApply = null; |
3324 | } | ||
3325 | } | 3300 | } |
3326 | } | 3301 | } |
3327 | 3302 | ||
3328 | static ScenePresence() | ||
3329 | { | ||
3330 | Primitive.TextureEntry textu = AvatarAppearance.GetDefaultTexture(); | ||
3331 | DefaultTexture = textu.GetBytes(); | ||
3332 | |||
3333 | } | ||
3334 | |||
3335 | public class NewForce | ||
3336 | { | ||
3337 | public float X; | ||
3338 | public float Y; | ||
3339 | public float Z; | ||
3340 | } | ||
3341 | |||
3342 | public override void SetText(string text, Vector3 color, double alpha) | 3303 | public override void SetText(string text, Vector3 color, double alpha) |
3343 | { | 3304 | { |
3344 | throw new Exception("Can't set Text on avatar."); | 3305 | throw new Exception("Can't set Text on avatar."); |
@@ -3349,7 +3310,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3349 | /// </summary> | 3310 | /// </summary> |
3350 | public void AddToPhysicalScene(bool isFlying) | 3311 | public void AddToPhysicalScene(bool isFlying) |
3351 | { | 3312 | { |
3352 | |||
3353 | PhysicsScene scene = m_scene.PhysicsScene; | 3313 | PhysicsScene scene = m_scene.PhysicsScene; |
3354 | 3314 | ||
3355 | Vector3 pVec = AbsolutePosition; | 3315 | Vector3 pVec = AbsolutePosition; |
@@ -3478,11 +3438,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3478 | 3438 | ||
3479 | public ScenePresence() | 3439 | public ScenePresence() |
3480 | { | 3440 | { |
3481 | if (DefaultTexture == null) | ||
3482 | { | ||
3483 | Primitive.TextureEntry textu = AvatarAppearance.GetDefaultTexture(); | ||
3484 | DefaultTexture = textu.GetBytes(); | ||
3485 | } | ||
3486 | m_sendCourseLocationsMethod = SendCoarseLocationsDefault; | 3441 | m_sendCourseLocationsMethod = SendCoarseLocationsDefault; |
3487 | CreateSceneViewer(); | 3442 | CreateSceneViewer(); |
3488 | } | 3443 | } |