From 684286f097da943da8684db9b87b522a1c57754c Mon Sep 17 00:00:00 2001 From: MW Date: Thu, 25 Jun 2009 12:26:23 +0000 Subject: Applied patch from mantis #3820 which changed the clearing of the ScenePresence.m_forcesList, so it used the List.Clear method rather than doing a loop through the list and manually removing each item. Thanks dslake. I also fixed the issue where the code also loops through the m_forcesList and copies each force to the ScenePresence's movementVector. Which resulted in only the last force in the list actually be acted on. As each copy overrode the last one. So now it only copies the last force in the list. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 36 +++++++++++------------- 1 file changed, 16 insertions(+), 20 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index f4776e3..cc25f48 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3241,30 +3241,26 @@ namespace OpenSim.Region.Framework.Scenes { if (m_forcesList.Count > 0) { - for (int i = 0; i < m_forcesList.Count; i++) - { - NewForce force = m_forcesList[i]; + //we are only interested in the last force added to the list + NewForce force = m_forcesList[m_forcesList.Count - 1]; - m_updateflag = true; - try - { - movementvector.X = force.X; - movementvector.Y = force.Y; - movementvector.Z = force.Z; - Velocity = movementvector; - } - catch (NullReferenceException) - { - // Under extreme load, this returns a NullReference Exception that we can ignore. - // Ignoring this causes no movement to be sent to the physics engine... - // which when the scene is moving at 1 frame every 10 seconds, it doesn't really matter! - } - m_newForce = true; + m_updateflag = true; + try + { + movementvector.X = force.X; + movementvector.Y = force.Y; + movementvector.Z = force.Z; + Velocity = movementvector; } - for (int i = 0; i < m_forcesList.Count; i++) + catch (NullReferenceException) { - m_forcesList.RemoveAt(0); + // Under extreme load, this returns a NullReference Exception that we can ignore. + // Ignoring this causes no movement to be sent to the physics engine... + // which when the scene is moving at 1 frame every 10 seconds, it doesn't really matter! } + m_newForce = true; + + m_forcesList.Clear(); } } } -- cgit v1.1