Log error if we attempt to add/remove an OdeCharacter from the _characters list inappropriately

0.7.2-post-fixes
Justin Clark-Casey (justincc) 2011-11-22 22:46:25 +00:00
parent 754d6036ea
commit 9730a862db
1 changed files with 37 additions and 21 deletions

View File

@ -374,8 +374,7 @@ namespace OpenSim.Region.Physics.OdePlugin
/// <param value="name">Name of the scene. Useful in debug messages.</param> /// <param value="name">Name of the scene. Useful in debug messages.</param>
public OdeScene(string name) public OdeScene(string name)
{ {
m_log m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.ToString() + "." + name);
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType.ToString() + "." + name);
Name = name; Name = name;
@ -766,7 +765,7 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
catch (AccessViolationException) catch (AccessViolationException)
{ {
m_log.Warn("[PHYSICS]: Unable to collide test a space"); m_log.Warn("[ODE SCENE]: Unable to collide test a space");
return; return;
} }
//Colliding a space or a geom with a space or a geom. so drill down //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); count = d.Collide(g1, g2, contacts.Length, contacts, d.ContactGeom.SizeOf);
if (count > contacts.Length) 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) catch (SEHException)
{ {
m_log.Error( 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(); base.TriggerPhysicsBasedRestart();
} }
catch (Exception e) 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; return;
} }
@ -1553,7 +1552,7 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
catch (AccessViolationException) 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); //float terrainheight = GetTerrainHeightAtXY(chr.Position.X, chr.Position.Y);
@ -1584,13 +1583,13 @@ namespace OpenSim.Region.Physics.OdePlugin
removeprims = new List<OdePrim>(); removeprims = new List<OdePrim>();
} }
removeprims.Add(chr); 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) 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); _characters.Add(chr);
if (chr.bad) 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) internal void RemoveCharacter(OdeCharacter chr)
{ {
if (_characters.Contains(chr))
_characters.Remove(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, 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); //m_log.Warn(prim.prim_geom);
if (!prim.RemoveGeom()) 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) lock (_prims)
_prims.Remove(prim); _prims.Remove(prim);
@ -2316,7 +2326,7 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
else else
{ {
m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" + currentspace + m_log.Info("[ODE SCENE]: Invalid Scene passed to 'recalculatespace':" + currentspace +
" Geom:" + geom); " Geom:" + geom);
} }
} }
@ -2332,7 +2342,7 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
else else
{ {
m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" + m_log.Info("[ODE SCENE]: Invalid Scene passed to 'recalculatespace':" +
sGeomIsIn + " Geom:" + geom); sGeomIsIn + " Geom:" + geom);
} }
} }
@ -2355,7 +2365,7 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
else else
{ {
m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" + m_log.Info("[ODE SCENE]: Invalid Scene passed to 'recalculatespace':" +
currentspace + " Geom:" + geom); currentspace + " Geom:" + geom);
} }
} }
@ -2375,7 +2385,7 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
else else
{ {
m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" + m_log.Info("[ODE SCENE]: Invalid Scene passed to 'recalculatespace':" +
currentspace + " Geom:" + geom); currentspace + " Geom:" + geom);
} }
} }
@ -2391,7 +2401,7 @@ namespace OpenSim.Region.Physics.OdePlugin
} }
else else
{ {
m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" + m_log.Info("[ODE SCENE]: Invalid Scene passed to 'recalculatespace':" +
sGeomIsIn + " Geom:" + geom); sGeomIsIn + " Geom:" + geom);
} }
} }
@ -2635,7 +2645,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
{ {
_taintedActors.Add(taintedchar); _taintedActors.Add(taintedchar);
if (taintedchar.bad) 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) 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; timeLeft -= ODE_STEPSIZE;
@ -2834,7 +2844,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
foreach (OdeCharacter actor in _characters) foreach (OdeCharacter actor in _characters)
{ {
if (actor.bad) 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); actor.UpdatePositionAndVelocity(defects);
} }
@ -3394,7 +3404,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
{ {
if (Single.IsNaN(resultarr2[y, x]) || Single.IsInfinity(resultarr2[y, x])) 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; resultarr2[y, x] = 0;
} }
returnarr[i] = resultarr2[y, x]; returnarr[i] = resultarr2[y, x];
@ -3424,6 +3434,9 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
private void SetTerrain(float[] heightMap, Vector3 pOffset) 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]; // this._heightmap[i] = (double)heightMap[i];
// dbm (danx0r) -- creating a buffer zone of one extra sample all around // dbm (danx0r) -- creating a buffer zone of one extra sample all around
//_origheightmap = heightMap; //_origheightmap = heightMap;
@ -3545,6 +3558,9 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name);
RegionTerrain.Add(pOffset, GroundGeom, GroundGeom); RegionTerrain.Add(pOffset, GroundGeom, GroundGeom);
TerrainHeightFieldHeights.Add(GroundGeom,_heightmap); TerrainHeightFieldHeights.Add(GroundGeom,_heightmap);
} }
m_log.DebugFormat(
"[ODE SCENE]: Setting terrain for {0} took {1}ms", Name, Util.EnvironmentTickCountSubtract(startTime));
} }
public override void DeleteTerrain() public override void DeleteTerrain()