From 84023c8162b5736ba2e9d492c5a569bb71eb255b Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Wed, 14 Dec 2011 16:43:49 +0000 Subject: [PATCH 1/3] Fix off by one bug in objects GrabbingBehaviour of pCampBot.exe Also fix usage message. --- OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs | 2 +- OpenSim/Tools/pCampBot/pCampBot.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs b/OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs index 6ad02b2436..701881e32f 100644 --- a/OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs +++ b/OpenSim/Tools/pCampBot/Behaviours/GrabbingBehaviour.cs @@ -47,7 +47,7 @@ namespace pCampBot { Dictionary objects = Bot.Objects; - Primitive prim = objects.ElementAt(Bot.Random.Next(0, objects.Count)).Value; + Primitive prim = objects.ElementAt(Bot.Random.Next(0, objects.Count - 1)).Value; // This appears to be a typical message sent when a viewer user clicks a clickable object Bot.Client.Self.Grab(prim.LocalID); diff --git a/OpenSim/Tools/pCampBot/pCampBot.cs b/OpenSim/Tools/pCampBot/pCampBot.cs index 3f43cff2b9..6249fae019 100644 --- a/OpenSim/Tools/pCampBot/pCampBot.cs +++ b/OpenSim/Tools/pCampBot/pCampBot.cs @@ -111,7 +111,7 @@ namespace pCampBot " -firstname first name for the bots\n" + " -lastname lastname for the bots. Each lastname will have _ appended, e.g. Ima Bot_0\n" + " -password password for the bots\n" + - " -b, behaviours behaviours for bots. Comma separated, e.g. p,g. Default is p\n", + " -b, behaviours behaviours for bots. Comma separated, e.g. p,g. Default is p\n" + " current options are:" + " p (physics)" + " g (grab)" + From a110a7bd6aceffd9d69efde7270870b6d33a65bc Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Wed, 14 Dec 2011 18:03:25 +0000 Subject: [PATCH 2/3] Eliminate _taintedPrimsH and _taintedPrimsL (and _taintedPrimLock) in favour of just a _taintedPrims HashSet. There's no point maintaining a list because any pending taint operations are all carried out in the same call anyway. --- OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 59 +++++--------------- 1 file changed, 14 insertions(+), 45 deletions(-) diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs index c1a3e61882..6ceb106924 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs @@ -205,27 +205,9 @@ namespace OpenSim.Region.Physics.OdePlugin private readonly HashSet _activeprims = new HashSet(); /// - /// Used to lock on manipulation of _taintedPrimL and _taintedPrimH + /// Prims that the simulator has created/deleted/updated and so need updating in ODE. /// - private readonly Object _taintedPrimLock = new Object(); - - /// - /// List of tainted prims. - /// - /// - /// A tainted prim is one that has taints to process before performing any other operations. The list is - /// cleared after processing. - /// - private readonly List _taintedPrimL = new List(); - - /// - /// HashSet of tainted prims. - /// - /// - /// A tainted prim is one that has taints to process before performing any other operations. The hashset is - /// cleared after processing. - /// - private readonly HashSet _taintedPrimH = new HashSet(); + private readonly HashSet _taintedPrims = new HashSet(); /// /// Record a character that has taints to be processed. @@ -767,7 +749,7 @@ namespace OpenSim.Region.Physics.OdePlugin } catch (AccessViolationException) { - m_log.Warn("[ODE SCENE]: Unable to collide test a space"); + m_log.Error("[ODE SCENE]: Unable to collide test a space"); return; } //Colliding a space or a geom with a space or a geom. so drill down @@ -829,7 +811,7 @@ namespace OpenSim.Region.Physics.OdePlugin } catch (Exception e) { - m_log.WarnFormat("[ODE SCENE]: Unable to collide test an object: {0}", e.Message); + m_log.ErrorFormat("[ODE SCENE]: Unable to collide test an object: {0}", e.Message); return; } @@ -1554,7 +1536,7 @@ namespace OpenSim.Region.Physics.OdePlugin } catch (AccessViolationException) { - m_log.WarnFormat("[ODE SCENE]: Unable to space collide {0}", Name); + m_log.ErrorFormat("[ODE SCENE]: Unable to space collide {0}", Name); } //float terrainheight = GetTerrainHeightAtXY(chr.Position.X, chr.Position.Y); @@ -1585,13 +1567,14 @@ namespace OpenSim.Region.Physics.OdePlugin removeprims = new List(); } removeprims.Add(chr); - m_log.Debug("[ODE SCENE]: unable to collide test active prim against space. The space was zero, the geom was zero or it was in the process of being removed. Removed it from the active prim list. This needs to be fixed!"); + m_log.Error( + "[ODE SCENE]: unable to collide test active prim against space. The space was zero, the geom was zero or it was in the process of being removed. Removed it from the active prim list. This needs to be fixed!"); } } } catch (AccessViolationException) { - m_log.Warn("[ODE SCENE]: Unable to space collide"); + m_log.Error("[ODE SCENE]: Unable to space collide"); } } } @@ -2621,17 +2604,8 @@ namespace OpenSim.Region.Physics.OdePlugin if (actor is OdePrim) { OdePrim taintedprim = ((OdePrim)actor); - lock (_taintedPrimLock) - { - if (!(_taintedPrimH.Contains(taintedprim))) - { -#if SPAM -Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); -#endif - _taintedPrimH.Add(taintedprim); // HashSet for searching - _taintedPrimL.Add(taintedprim); // List for ordered readout - } - } + lock (_taintedPrims) + _taintedPrims.Add(taintedprim); } else if (actor is OdeCharacter) { @@ -2750,9 +2724,9 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); } } - lock (_taintedPrimLock) + lock (_taintedPrims) { - foreach (OdePrim prim in _taintedPrimL) + foreach (OdePrim prim in _taintedPrims) { if (prim.m_taintremove) { @@ -2777,12 +2751,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); if (SupportsNINJAJoints) SimulatePendingNINJAJoints(); - if (_taintedPrimL.Count > 0) - { -//Console.WriteLine("Simulate calls Clear of _taintedPrim list"); - _taintedPrimH.Clear(); - _taintedPrimL.Clear(); - } + _taintedPrims.Clear(); } // Move characters @@ -2854,7 +2823,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); foreach (OdeCharacter actor in _characters) { if (actor.bad) - m_log.WarnFormat("[ODE SCENE]: BAD Actor {0} in _characters list was not removed?", actor.m_uuid); + m_log.ErrorFormat("[ODE SCENE]: BAD Actor {0} in _characters list was not removed?", actor.m_uuid); actor.UpdatePositionAndVelocity(defects); } From e830a778607337a6aab27dd29e5657e3f8aa6b76 Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Wed, 14 Dec 2011 18:33:44 +0000 Subject: [PATCH 3/3] Simplify some manipulation of _taintedActors in OdeScene --- OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs index 6ceb106924..a6c2ecafa4 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs @@ -2612,12 +2612,9 @@ namespace OpenSim.Region.Physics.OdePlugin OdeCharacter taintedchar = ((OdeCharacter)actor); lock (_taintedActors) { - if (!(_taintedActors.Contains(taintedchar))) - { - _taintedActors.Add(taintedchar); - if (taintedchar.bad) - m_log.DebugFormat("[ODE SCENE]: Added BAD actor {0} to tainted actors", taintedchar.m_uuid); - } + _taintedActors.Add(taintedchar); + if (taintedchar.bad) + m_log.ErrorFormat("[ODE SCENE]: Added BAD actor {0} to tainted actors", taintedchar.m_uuid); } } } @@ -2714,14 +2711,10 @@ namespace OpenSim.Region.Physics.OdePlugin { lock (_taintedActors) { - if (_taintedActors.Count > 0) - { - foreach (OdeCharacter character in _taintedActors) - character.ProcessTaints(); + foreach (OdeCharacter character in _taintedActors) + character.ProcessTaints(); - if (_taintedActors.Count > 0) - _taintedActors.Clear(); - } + _taintedActors.Clear(); } lock (_taintedPrims)