From 9730a862dbcae3dc4847aa5107632a099e06ca9c Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 22 Nov 2011 22:46:25 +0000 Subject: [PATCH] Log error if we attempt to add/remove an OdeCharacter from the _characters list inappropriately --- OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 58 +++++++++++++------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs index 7b67861292..561371b77d 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs @@ -374,8 +374,7 @@ namespace OpenSim.Region.Physics.OdePlugin /// Name of the scene. Useful in debug messages. public OdeScene(string name) { - m_log - = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.ToString() + "." + name); + m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.ToString() + "." + name); Name = name; @@ -766,7 +765,7 @@ namespace OpenSim.Region.Physics.OdePlugin } catch (AccessViolationException) { - m_log.Warn("[PHYSICS]: Unable to collide test a space"); + m_log.Warn("[ODE SCENE]: Unable to collide test a space"); return; } //Colliding a space or a geom with a space or a geom. so drill down @@ -818,17 +817,17 @@ namespace OpenSim.Region.Physics.OdePlugin count = d.Collide(g1, g2, contacts.Length, contacts, d.ContactGeom.SizeOf); if (count > contacts.Length) - m_log.Error("[PHYSICS]: Got " + count + " contacts when we asked for a maximum of " + contacts.Length); + m_log.Error("[ODE SCENE]: Got " + count + " contacts when we asked for a maximum of " + contacts.Length); } catch (SEHException) { m_log.Error( - "[PHYSICS]: The Operating system shut down ODE because of corrupt memory. This could be a result of really irregular terrain. If this repeats continuously, restart using Basic Physics and terrain fill your terrain. Restarting the sim."); + "[ODE SCENE]: The Operating system shut down ODE because of corrupt memory. This could be a result of really irregular terrain. If this repeats continuously, restart using Basic Physics and terrain fill your terrain. Restarting the sim."); base.TriggerPhysicsBasedRestart(); } catch (Exception e) { - m_log.WarnFormat("[PHYSICS]: Unable to collide test an object: {0}", e.Message); + m_log.WarnFormat("[ODE SCENE]: Unable to collide test an object: {0}", e.Message); return; } @@ -1553,7 +1552,7 @@ namespace OpenSim.Region.Physics.OdePlugin } catch (AccessViolationException) { - m_log.WarnFormat("[PHYSICS]: Unable to space collide {0}", Name); + m_log.WarnFormat("[ODE SCENE]: Unable to space collide {0}", Name); } //float terrainheight = GetTerrainHeightAtXY(chr.Position.X, chr.Position.Y); @@ -1584,13 +1583,13 @@ namespace OpenSim.Region.Physics.OdePlugin removeprims = new List(); } removeprims.Add(chr); - m_log.Debug("[PHYSICS]: 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.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!"); } } } catch (AccessViolationException) { - m_log.Warn("[PHYSICS]: Unable to space collide"); + m_log.Warn("[ODE SCENE]: Unable to space collide"); } } } @@ -1729,13 +1728,24 @@ namespace OpenSim.Region.Physics.OdePlugin _characters.Add(chr); if (chr.bad) - m_log.ErrorFormat("[PHYSICS] Added BAD actor {0} to characters list", chr.m_uuid); + m_log.ErrorFormat("[ODE SCENE]: Added BAD actor {0} to characters list", chr.m_uuid); + } + else + { + m_log.ErrorFormat( + "[ODE SCENE]: Tried to add character {0} {1} but they are already in the set!", + chr.Name, chr.LocalID); } } internal void RemoveCharacter(OdeCharacter chr) { - _characters.Remove(chr); + if (_characters.Contains(chr)) + _characters.Remove(chr); + else + m_log.ErrorFormat( + "[ODE SCENE]: Tried to remove character {0} {1} but they are not in the list!", + chr.Name, chr.LocalID); } private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation, @@ -2224,7 +2234,7 @@ namespace OpenSim.Region.Physics.OdePlugin //m_log.Warn(prim.prim_geom); if (!prim.RemoveGeom()) - m_log.Warn("[PHYSICS]: Unable to remove prim from physics scene"); + m_log.Warn("[ODE SCENE]: Unable to remove prim from physics scene"); lock (_prims) _prims.Remove(prim); @@ -2316,7 +2326,7 @@ namespace OpenSim.Region.Physics.OdePlugin } else { - m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" + currentspace + + m_log.Info("[ODE SCENE]: Invalid Scene passed to 'recalculatespace':" + currentspace + " Geom:" + geom); } } @@ -2332,7 +2342,7 @@ namespace OpenSim.Region.Physics.OdePlugin } else { - m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" + + m_log.Info("[ODE SCENE]: Invalid Scene passed to 'recalculatespace':" + sGeomIsIn + " Geom:" + geom); } } @@ -2355,7 +2365,7 @@ namespace OpenSim.Region.Physics.OdePlugin } else { - m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" + + m_log.Info("[ODE SCENE]: Invalid Scene passed to 'recalculatespace':" + currentspace + " Geom:" + geom); } } @@ -2375,7 +2385,7 @@ namespace OpenSim.Region.Physics.OdePlugin } else { - m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" + + m_log.Info("[ODE SCENE]: Invalid Scene passed to 'recalculatespace':" + currentspace + " Geom:" + geom); } } @@ -2391,7 +2401,7 @@ namespace OpenSim.Region.Physics.OdePlugin } else { - m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" + + m_log.Info("[ODE SCENE]: Invalid Scene passed to 'recalculatespace':" + sGeomIsIn + " Geom:" + geom); } } @@ -2635,7 +2645,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); { _taintedActors.Add(taintedchar); if (taintedchar.bad) - m_log.DebugFormat("[PHYSICS]: Added BAD actor {0} to tainted actors", taintedchar.m_uuid); + m_log.DebugFormat("[ODE SCENE]: Added BAD actor {0} to tainted actors", taintedchar.m_uuid); } } } @@ -2825,7 +2835,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); } catch (Exception e) { - m_log.ErrorFormat("[PHYSICS]: {0}, {1}, {2}", e.Message, e.TargetSite, e); + m_log.ErrorFormat("[ODE SCENE]: {0}, {1}, {2}", e.Message, e.TargetSite, e); } timeLeft -= ODE_STEPSIZE; @@ -2834,7 +2844,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); foreach (OdeCharacter actor in _characters) { if (actor.bad) - m_log.WarnFormat("[PHYSICS]: BAD Actor {0} in _characters list was not removed?", actor.m_uuid); + m_log.WarnFormat("[ODE SCENE]: BAD Actor {0} in _characters list was not removed?", actor.m_uuid); actor.UpdatePositionAndVelocity(defects); } @@ -3394,7 +3404,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); { if (Single.IsNaN(resultarr2[y, x]) || Single.IsInfinity(resultarr2[y, x])) { - m_log.Warn("[PHYSICS]: Non finite heightfield element detected. Setting it to 0"); + m_log.Warn("[ODE SCENE]: Non finite heightfield element detected. Setting it to 0"); resultarr2[y, x] = 0; } returnarr[i] = resultarr2[y, x]; @@ -3424,6 +3434,9 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); private void SetTerrain(float[] heightMap, Vector3 pOffset) { + int startTime = Util.EnvironmentTickCount(); + m_log.DebugFormat("[ODE SCENE]: Setting terrain for {0}", Name); + // this._heightmap[i] = (double)heightMap[i]; // dbm (danx0r) -- creating a buffer zone of one extra sample all around //_origheightmap = heightMap; @@ -3545,6 +3558,9 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); RegionTerrain.Add(pOffset, GroundGeom, GroundGeom); TerrainHeightFieldHeights.Add(GroundGeom,_heightmap); } + + m_log.DebugFormat( + "[ODE SCENE]: Setting terrain for {0} took {1}ms", Name, Util.EnvironmentTickCountSubtract(startTime)); } public override void DeleteTerrain()