From 6ed5283bc06a62f38eb517e67b975832b603bf61 Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Tue, 5 Feb 2008 19:44:27 +0000 Subject: Converted logging to use log4net. Changed LogBase to ConsoleBase, which handles console I/O. This is mostly an in-place conversion, so lots of refactoring can still be done. --- OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 8 +-- OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 10 ++-- OpenSim/Region/Physics/OdePlugin/OdePlugin.cs | 68 +++++++++++------------- 3 files changed, 42 insertions(+), 44 deletions(-) (limited to 'OpenSim/Region/Physics/OdePlugin') diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index a21b7eb..98069a0 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -56,6 +56,8 @@ namespace OpenSim.Region.Physics.OdePlugin } public class OdeCharacter : PhysicsActor { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private PhysicsVector _position; private d.Vector3 _zeroPosition; private d.Matrix3 m_StandUpRotation; @@ -357,7 +359,7 @@ namespace OpenSim.Region.Physics.OdePlugin //capsuleradius = 0.2f; CAPSULE_LENGTH = (SetSize.Z - ((SetSize.Z*0.52f))); // subtract 43% of the size - OpenSim.Framework.Console.MainLog.Instance.Verbose("SIZE", CAPSULE_LENGTH.ToString()); + m_log.Info("[SIZE]: " + CAPSULE_LENGTH.ToString()); d.BodyDestroy(Body); _parent_scene.waitForSpaceUnlock(_parent_scene.space); @@ -440,7 +442,7 @@ namespace OpenSim.Region.Physics.OdePlugin //d.QfromR( //d.Matrix3 checkrotation = new d.Matrix3(0.7071068,0.5, -0.7071068, // - //OpenSim.Framework.Console.MainLog.Instance.Verbose("PHYSICSAV", "Rotation: " + bodyrotation.M00 + " : " + bodyrotation.M01 + " : " + bodyrotation.M02 + " : " + bodyrotation.M10 + " : " + bodyrotation.M11 + " : " + bodyrotation.M12 + " : " + bodyrotation.M20 + " : " + bodyrotation.M21 + " : " + bodyrotation.M22); + //m_log.Info("[PHYSICSAV]: Rotation: " + bodyrotation.M00 + " : " + bodyrotation.M01 + " : " + bodyrotation.M02 + " : " + bodyrotation.M10 + " : " + bodyrotation.M11 + " : " + bodyrotation.M12 + " : " + bodyrotation.M20 + " : " + bodyrotation.M21 + " : " + bodyrotation.M22); //standupStraight(); @@ -479,7 +481,7 @@ namespace OpenSim.Region.Physics.OdePlugin d.BodyAddForceAtRelPos(Body, 0.0f, 0.0f, servo, 0.0f, 0.0f, 1.0f); d.BodyAddForceAtRelPos(Body, 0.0f, 0.0f, -servo, 0.0f, 0.0f, -1.0f); //d.Matrix3 bodyrotation = d.BodyGetRotation(Body); - //OpenSim.Framework.Console.MainLog.Instance.Verbose("PHYSICSAV", "Rotation: " + bodyrotation.M00 + " : " + bodyrotation.M01 + " : " + bodyrotation.M02 + " : " + bodyrotation.M10 + " : " + bodyrotation.M11 + " : " + bodyrotation.M12 + " : " + bodyrotation.M20 + " : " + bodyrotation.M21 + " : " + bodyrotation.M22); + //m_log.Info("[PHYSICSAV]: Rotation: " + bodyrotation.M00 + " : " + bodyrotation.M01 + " : " + bodyrotation.M02 + " : " + bodyrotation.M10 + " : " + bodyrotation.M11 + " : " + bodyrotation.M12 + " : " + bodyrotation.M20 + " : " + bodyrotation.M21 + " : " + bodyrotation.M22); } public override PhysicsVector Force diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 93ba29e..690e9d3 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -37,6 +37,8 @@ namespace OpenSim.Region.Physics.OdePlugin { public class OdePrim : PhysicsActor { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + public PhysicsVector _position; private PhysicsVector _velocity; private PhysicsVector m_lastVelocity = new PhysicsVector(0.0f, 0.0f, 0.0f); @@ -530,7 +532,7 @@ namespace OpenSim.Region.Physics.OdePlugin } else { - OpenSim.Framework.Console.MainLog.Instance.Verbose("PHYSICS", "Failed to load a sphere bad size"); + m_log.Info("[PHYSICS]: Failed to load a sphere bad size"); _parent_scene.waitForSpaceUnlock(m_targetSpace); prim_geom = d.CreateBox(m_targetSpace, _size.X, _size.Y, _size.Z); } @@ -683,7 +685,7 @@ namespace OpenSim.Region.Physics.OdePlugin { lock (m_forcelist) { - //OpenSim.Framework.Console.MainLog.Instance.Verbose("PHYSICS", "dequeing forcelist"); + //m_log.Info("[PHYSICS]: dequeing forcelist"); if (IsPhysical) { PhysicsVector iforce = new PhysicsVector(); @@ -747,7 +749,7 @@ namespace OpenSim.Region.Physics.OdePlugin get { return _position; } set { _position = value; - //OpenSim.Framework.Console.MainLog.Instance.Verbose("PHYSICS", _position.ToString()); + //m_log.Info("[PHYSICS]: " + _position.ToString()); } } @@ -824,7 +826,7 @@ namespace OpenSim.Region.Physics.OdePlugin { m_forcelist.Add(force); m_taintforce = true; - //OpenSim.Framework.Console.MainLog.Instance.Verbose("PHYSICS", "Added Force:" + force.ToString() + " to prim at " + Position.ToString()); + //m_log.Info("[PHYSICS]: Added Force:" + force.ToString() + " to prim at " + Position.ToString()); } public override PhysicsVector RotationalVelocity diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs index bff2c80..9cf6d50 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs @@ -44,6 +44,8 @@ namespace OpenSim.Region.Physics.OdePlugin /// public class OdePlugin : IPhysicsPlugin { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + private OdeScene _mScene; public OdePlugin() @@ -76,6 +78,8 @@ namespace OpenSim.Region.Physics.OdePlugin public class OdeScene : PhysicsScene { + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); + // TODO: this should be hard-coded in some common place private const uint m_regionWidth = 256; private const uint m_regionHeight = 256; @@ -284,7 +288,7 @@ namespace OpenSim.Region.Physics.OdePlugin //if (id == d.GeomClassID.TriMeshClass) //{ - // MainLog.Instance.Verbose("near: A collision was detected between {1} and {2}", 0, name1, name2); + // m_log.Info("near: A collision was detected between {1} and {2}", 0, name1, name2); //System.Console.WriteLine("near: A collision was detected between {1} and {2}", 0, name1, name2); //} @@ -296,8 +300,7 @@ namespace OpenSim.Region.Physics.OdePlugin } catch (SEHException) { - MainLog.Instance.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."); + 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."); base.TriggerPhysicsBasedRestart(); } @@ -352,7 +355,7 @@ namespace OpenSim.Region.Physics.OdePlugin if (contacts[i].depth >= 1.00f) { - //MainLog.Instance.Debug("PHYSICS",contacts[i].depth.ToString()); + //m_log.Debug("[PHYSICS]: " +contacts[i].depth.ToString()); } //If you interpenetrate a prim with an agent @@ -405,7 +408,7 @@ namespace OpenSim.Region.Physics.OdePlugin } if (contacts[i].depth >= 1.00f) { - //OpenSim.Framework.Console.MainLog.Instance.Verbose("P", contacts[i].depth.ToString()); + //m_log.Info("[P]: " + contacts[i].depth.ToString()); if ((p2.PhysicsActorType == (int) ActorTypes.Agent && p1.PhysicsActorType == (int) ActorTypes.Unknown) || (p1.PhysicsActorType == (int) ActorTypes.Agent && @@ -654,9 +657,8 @@ namespace OpenSim.Region.Physics.OdePlugin } else { - MainLog.Instance.Verbose("Physics", - "Invalid Scene passed to 'removeprim from scene':" + - ((OdePrim) prim).m_targetSpace.ToString()); + m_log.Info("[Physics]: Invalid Scene passed to 'removeprim from scene':" + + ((OdePrim) prim).m_targetSpace.ToString()); } } } @@ -678,9 +680,8 @@ namespace OpenSim.Region.Physics.OdePlugin } else { - MainLog.Instance.Verbose("Physics", - "Invalid Scene passed to 'removeprim from scene':" + - ((OdePrim) prim).m_targetSpace.ToString()); + m_log.Info("[Physics]: Invalid Scene passed to 'removeprim from scene':" + + ((OdePrim) prim).m_targetSpace.ToString()); } } } @@ -742,9 +743,8 @@ namespace OpenSim.Region.Physics.OdePlugin } else { - MainLog.Instance.Verbose("Physics", - "Invalid Scene passed to 'recalculatespace':" + currentspace.ToString() + - " Geom:" + geom.ToString()); + m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" + currentspace.ToString() + + " Geom:" + geom.ToString()); } } else @@ -761,9 +761,8 @@ namespace OpenSim.Region.Physics.OdePlugin } else { - MainLog.Instance.Verbose("Physics", - "Invalid Scene passed to 'recalculatespace':" + - sGeomIsIn.ToString() + " Geom:" + geom.ToString()); + m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" + + sGeomIsIn.ToString() + " Geom:" + geom.ToString()); } } } @@ -787,9 +786,8 @@ namespace OpenSim.Region.Physics.OdePlugin } else { - MainLog.Instance.Verbose("Physics", - "Invalid Scene passed to 'recalculatespace':" + - currentspace.ToString() + " Geom:" + geom.ToString()); + m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" + + currentspace.ToString() + " Geom:" + geom.ToString()); } } } @@ -807,9 +805,8 @@ namespace OpenSim.Region.Physics.OdePlugin } else { - MainLog.Instance.Verbose("Physics", - "Invalid Scene passed to 'recalculatespace':" + - currentspace.ToString() + " Geom:" + geom.ToString()); + m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" + + currentspace.ToString() + " Geom:" + geom.ToString()); } } else @@ -826,9 +823,8 @@ namespace OpenSim.Region.Physics.OdePlugin } else { - MainLog.Instance.Verbose("Physics", - "Invalid Scene passed to 'recalculatespace':" + - sGeomIsIn.ToString() + " Geom:" + geom.ToString()); + m_log.Info("[Physics]: Invalid Scene passed to 'recalculatespace':" + + sGeomIsIn.ToString() + " Geom:" + geom.ToString()); } } } @@ -876,7 +872,7 @@ namespace OpenSim.Region.Physics.OdePlugin IntPtr locationbasedspace =IntPtr.Zero; int[] xyspace = calculateSpaceArrayItemFromPos(pos); - //MainLog.Instance.Verbose("Physics", "Attempting to use arrayItem: " + xyspace[0].ToString() + "," + xyspace[1].ToString()); + //m_log.Info("[Physics]: Attempting to use arrayItem: " + xyspace[0].ToString() + "," + xyspace[1].ToString()); locationbasedspace = staticPrimspace[xyspace[0], xyspace[1]]; //locationbasedspace = space; @@ -970,7 +966,7 @@ namespace OpenSim.Region.Physics.OdePlugin name2 = "null"; } - MainLog.Instance.Verbose("TriArrayCallback: A collision was detected between {1} and {2}", 0, name1, name2); + m_log.Info("TriArrayCallback: A collision was detected between {1} and {2}", 0, name1, name2); */ return 1; } @@ -984,19 +980,20 @@ namespace OpenSim.Region.Physics.OdePlugin { name1 = "null"; } + if (!geom_name_map.TryGetValue(refObject, out name2)) { name2 = "null"; } -// MainLog.Instance.Verbose("TriCallback: A collision was detected between {1} and {2}. Index was {3}", 0, name1, name2, triangleIndex); +// m_log.Info("TriCallback: A collision was detected between {1} and {2}. Index was {3}", 0, name1, name2, triangleIndex); d.Vector3 v0 = new d.Vector3(); d.Vector3 v1 = new d.Vector3(); d.Vector3 v2 = new d.Vector3(); d.GeomTriMeshGetTriangle(trimesh, 0, ref v0, ref v1, ref v2); -// MainLog.Instance.Debug("Triangle {0} is <{1},{2},{3}>, <{4},{5},{6}>, <{7},{8},{9}>", triangleIndex, v0.X, v0.Y, v0.Z, v1.X, v1.Y, v1.Z, v2.X, v2.Y, v2.Z); +// m_log.Debug("Triangle {0} is <{1},{2},{3}>, <{4},{5},{6}>, <{7},{8},{9}>", triangleIndex, v0.X, v0.Y, v0.Z, v1.X, v1.Y, v1.Z, v2.X, v2.Y, v2.Z); return 1; } @@ -1105,19 +1102,16 @@ namespace OpenSim.Region.Physics.OdePlugin } catch (StackOverflowException) { - MainLog.Instance.Error("PHYSICS", - "The operating system wasn't able to allocate enough memory for the simulation. Restarting the sim."); + m_log.Error("[PHYSICS]: The operating system wasn't able to allocate enough memory for the simulation. Restarting the sim."); base.TriggerPhysicsBasedRestart(); } int i = 0; - // Figure out the Frames Per Second we're going at. //(step_time == 0.004f, there's 250 of those per second. Times the step time/step size fps = (step_time/ODE_STEPSIZE) * 1000; - while (step_time > 0.0f) { foreach (OdeCharacter actor in _characters) @@ -1126,7 +1120,6 @@ namespace OpenSim.Region.Physics.OdePlugin actor.collidelock = true; } - collision_optimized(timeStep); d.WorldQuickStep(world, ODE_STEPSIZE); d.JointGroupEmpty(contactgroup); @@ -1178,8 +1171,8 @@ namespace OpenSim.Region.Physics.OdePlugin public override bool IsThreaded { - get { return (false); // for now we won't be multithreaded - } + // for now we won't be multithreaded + get { return (false); } } public float[] ResizeTerrain512NearestNeighbour(float[] heightMap) { @@ -1275,6 +1268,7 @@ namespace OpenSim.Region.Physics.OdePlugin } } } + //Flatten out the array int i = 0; for (int y = 0; y < 512; y++) -- cgit v1.1