From daf99f8c0ac874971c829b18a2372be1c4ee9541 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 22 Nov 2011 21:51:00 +0000 Subject: slightly simplify OdeScene.Simulate() by removing bool processtaints, since we can inspect count of taint lists instead. also groups OdeCharacter.CreateOdeStructures() and DestroyOdeStructures() together --- OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 234 +++++++++++------------ OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 1 - OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 34 ++-- 3 files changed, 128 insertions(+), 141 deletions(-) diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index cfe64f2..489a23a 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -542,123 +542,6 @@ namespace OpenSim.Region.Physics.OdePlugin } /// - /// This creates the Avatar's physical Surrogate in ODE at the position supplied - /// - /// - /// WARNING: This MUST NOT be called outside of ProcessTaints, else we can have unsynchronized access - /// to ODE internals. ProcessTaints is called from within thread-locked Simulate(), so it is the only - /// place that is safe to call this routine AvatarGeomAndBodyCreation. - /// - /// - /// - /// - /// - private void CreateOdeStructures(float npositionX, float npositionY, float npositionZ, float tensor) - { - int dAMotorEuler = 1; -// _parent_scene.waitForSpaceUnlock(_parent_scene.space); - if (CAPSULE_LENGTH <= 0) - { - m_log.Warn("[ODE CHARACTER]: The capsule size you specified in opensim.ini is invalid! Setting it to the smallest possible size!"); - CAPSULE_LENGTH = 0.01f; - } - - if (CAPSULE_RADIUS <= 0) - { - m_log.Warn("[ODE CHARACTER]: The capsule size you specified in opensim.ini is invalid! Setting it to the smallest possible size!"); - CAPSULE_RADIUS = 0.01f; - } - - Shell = d.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH); - - d.GeomSetCategoryBits(Shell, (int)m_collisionCategories); - d.GeomSetCollideBits(Shell, (int)m_collisionFlags); - - d.MassSetCapsuleTotal(out ShellMass, m_mass, 2, CAPSULE_RADIUS, CAPSULE_LENGTH); - Body = d.BodyCreate(_parent_scene.world); - d.BodySetPosition(Body, npositionX, npositionY, npositionZ); - - _position.X = npositionX; - _position.Y = npositionY; - _position.Z = npositionZ; - - m_taintPosition = _position; - - d.BodySetMass(Body, ref ShellMass); - d.Matrix3 m_caprot; - // 90 Stand up on the cap of the capped cyllinder - if (_parent_scene.IsAvCapsuleTilted) - { - d.RFromAxisAndAngle(out m_caprot, 1, 0, 1, (float)(Math.PI / 2)); - } - else - { - d.RFromAxisAndAngle(out m_caprot, 0, 0, 1, (float)(Math.PI / 2)); - } - - d.GeomSetRotation(Shell, ref m_caprot); - d.BodySetRotation(Body, ref m_caprot); - - d.GeomSetBody(Shell, Body); - - // The purpose of the AMotor here is to keep the avatar's physical - // surrogate from rotating while moving - Amotor = d.JointCreateAMotor(_parent_scene.world, IntPtr.Zero); - d.JointAttach(Amotor, Body, IntPtr.Zero); - d.JointSetAMotorMode(Amotor, dAMotorEuler); - d.JointSetAMotorNumAxes(Amotor, 3); - d.JointSetAMotorAxis(Amotor, 0, 0, 1, 0, 0); - d.JointSetAMotorAxis(Amotor, 1, 0, 0, 1, 0); - d.JointSetAMotorAxis(Amotor, 2, 0, 0, 0, 1); - d.JointSetAMotorAngle(Amotor, 0, 0); - d.JointSetAMotorAngle(Amotor, 1, 0); - d.JointSetAMotorAngle(Amotor, 2, 0); - - // These lowstops and high stops are effectively (no wiggle room) - if (_parent_scene.IsAvCapsuleTilted) - { - d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, -0.000000000001f); - d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0.000000000001f); - d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, -0.000000000001f); - d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 0.000000000001f); - d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0.000000000001f); - d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0.000000000001f); - } - else - { - #region Documentation of capsule motor LowStop and HighStop parameters - // Intentionally introduce some tilt into the capsule by setting - // the motor stops to small epsilon values. This small tilt prevents - // the capsule from falling into the terrain; a straight-up capsule - // (with -0..0 motor stops) falls into the terrain for reasons yet - // to be comprehended in their entirety. - #endregion - AlignAvatarTiltWithCurrentDirectionOfMovement(Vector3.Zero); - d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, 0.08f); - d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0f); - d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, 0.08f); - d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 0.08f); // must be same as lowstop, else a different, spurious tilt is introduced - d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0f); // same as lowstop - d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0.08f); // same as lowstop - } - - // Fudge factor is 1f by default, we're setting it to 0. We don't want it to Fudge or the - // capped cyllinder will fall over - d.JointSetAMotorParam(Amotor, (int)dParam.FudgeFactor, 0f); - d.JointSetAMotorParam(Amotor, (int)dParam.FMax, tensor); - - //d.Matrix3 bodyrotation = d.BodyGetRotation(Body); - //d.QfromR( - //d.Matrix3 checkrotation = new d.Matrix3(0.7071068,0.5, -0.7071068, - // - //m_log.Info("[PHYSICSAV]: Rotation: " + bodyrotation.M00 + " : " + bodyrotation.M01 + " : " + bodyrotation.M02 + " : " + bodyrotation.M10 + " : " + bodyrotation.M11 + " : " + bodyrotation.M12 + " : " + bodyrotation.M20 + " : " + bodyrotation.M21 + " : " + bodyrotation.M22); - //standupStraight(); - - _parent_scene.geom_name_map[Shell] = Name; - _parent_scene.actor_name_map[Shell] = this; - } - - /// /// Uses the capped cyllinder volume formula to calculate the avatar's mass. /// This may be used in calculations in the scene/scenepresence /// @@ -1126,6 +1009,123 @@ namespace OpenSim.Region.Physics.OdePlugin } /// + /// This creates the Avatar's physical Surrogate in ODE at the position supplied + /// + /// + /// WARNING: This MUST NOT be called outside of ProcessTaints, else we can have unsynchronized access + /// to ODE internals. ProcessTaints is called from within thread-locked Simulate(), so it is the only + /// place that is safe to call this routine AvatarGeomAndBodyCreation. + /// + /// + /// + /// + /// + private void CreateOdeStructures(float npositionX, float npositionY, float npositionZ, float tensor) + { + int dAMotorEuler = 1; +// _parent_scene.waitForSpaceUnlock(_parent_scene.space); + if (CAPSULE_LENGTH <= 0) + { + m_log.Warn("[ODE CHARACTER]: The capsule size you specified in opensim.ini is invalid! Setting it to the smallest possible size!"); + CAPSULE_LENGTH = 0.01f; + } + + if (CAPSULE_RADIUS <= 0) + { + m_log.Warn("[ODE CHARACTER]: The capsule size you specified in opensim.ini is invalid! Setting it to the smallest possible size!"); + CAPSULE_RADIUS = 0.01f; + } + + Shell = d.CreateCapsule(_parent_scene.space, CAPSULE_RADIUS, CAPSULE_LENGTH); + + d.GeomSetCategoryBits(Shell, (int)m_collisionCategories); + d.GeomSetCollideBits(Shell, (int)m_collisionFlags); + + d.MassSetCapsuleTotal(out ShellMass, m_mass, 2, CAPSULE_RADIUS, CAPSULE_LENGTH); + Body = d.BodyCreate(_parent_scene.world); + d.BodySetPosition(Body, npositionX, npositionY, npositionZ); + + _position.X = npositionX; + _position.Y = npositionY; + _position.Z = npositionZ; + + m_taintPosition = _position; + + d.BodySetMass(Body, ref ShellMass); + d.Matrix3 m_caprot; + // 90 Stand up on the cap of the capped cyllinder + if (_parent_scene.IsAvCapsuleTilted) + { + d.RFromAxisAndAngle(out m_caprot, 1, 0, 1, (float)(Math.PI / 2)); + } + else + { + d.RFromAxisAndAngle(out m_caprot, 0, 0, 1, (float)(Math.PI / 2)); + } + + d.GeomSetRotation(Shell, ref m_caprot); + d.BodySetRotation(Body, ref m_caprot); + + d.GeomSetBody(Shell, Body); + + // The purpose of the AMotor here is to keep the avatar's physical + // surrogate from rotating while moving + Amotor = d.JointCreateAMotor(_parent_scene.world, IntPtr.Zero); + d.JointAttach(Amotor, Body, IntPtr.Zero); + d.JointSetAMotorMode(Amotor, dAMotorEuler); + d.JointSetAMotorNumAxes(Amotor, 3); + d.JointSetAMotorAxis(Amotor, 0, 0, 1, 0, 0); + d.JointSetAMotorAxis(Amotor, 1, 0, 0, 1, 0); + d.JointSetAMotorAxis(Amotor, 2, 0, 0, 0, 1); + d.JointSetAMotorAngle(Amotor, 0, 0); + d.JointSetAMotorAngle(Amotor, 1, 0); + d.JointSetAMotorAngle(Amotor, 2, 0); + + // These lowstops and high stops are effectively (no wiggle room) + if (_parent_scene.IsAvCapsuleTilted) + { + d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, -0.000000000001f); + d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0.000000000001f); + d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, -0.000000000001f); + d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 0.000000000001f); + d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0.000000000001f); + d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0.000000000001f); + } + else + { + #region Documentation of capsule motor LowStop and HighStop parameters + // Intentionally introduce some tilt into the capsule by setting + // the motor stops to small epsilon values. This small tilt prevents + // the capsule from falling into the terrain; a straight-up capsule + // (with -0..0 motor stops) falls into the terrain for reasons yet + // to be comprehended in their entirety. + #endregion + AlignAvatarTiltWithCurrentDirectionOfMovement(Vector3.Zero); + d.JointSetAMotorParam(Amotor, (int)dParam.LowStop, 0.08f); + d.JointSetAMotorParam(Amotor, (int)dParam.LoStop3, -0f); + d.JointSetAMotorParam(Amotor, (int)dParam.LoStop2, 0.08f); + d.JointSetAMotorParam(Amotor, (int)dParam.HiStop, 0.08f); // must be same as lowstop, else a different, spurious tilt is introduced + d.JointSetAMotorParam(Amotor, (int)dParam.HiStop3, 0f); // same as lowstop + d.JointSetAMotorParam(Amotor, (int)dParam.HiStop2, 0.08f); // same as lowstop + } + + // Fudge factor is 1f by default, we're setting it to 0. We don't want it to Fudge or the + // capped cyllinder will fall over + d.JointSetAMotorParam(Amotor, (int)dParam.FudgeFactor, 0f); + d.JointSetAMotorParam(Amotor, (int)dParam.FMax, tensor); + + //d.Matrix3 bodyrotation = d.BodyGetRotation(Body); + //d.QfromR( + //d.Matrix3 checkrotation = new d.Matrix3(0.7071068,0.5, -0.7071068, + // + //m_log.Info("[PHYSICSAV]: Rotation: " + bodyrotation.M00 + " : " + bodyrotation.M01 + " : " + bodyrotation.M02 + " : " + bodyrotation.M10 + " : " + bodyrotation.M11 + " : " + bodyrotation.M12 + " : " + bodyrotation.M20 + " : " + bodyrotation.M21 + " : " + bodyrotation.M22); + //standupStraight(); + + _parent_scene.geom_name_map[Shell] = Name; + _parent_scene.actor_name_map[Shell] = this; + } + + /// /// Cleanup the things we use in the scene. /// internal void Destroy() diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index fec4693..94e6185 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -272,7 +272,6 @@ namespace OpenSim.Region.Physics.OdePlugin m_taintadd = true; _parent_scene.AddPhysicsActorTaint(this); - // don't do .add() here; old geoms get recycled with the same hash } public override int PhysicsActorType diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs index e219535..72e9ca0 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs @@ -2160,7 +2160,6 @@ namespace OpenSim.Region.Physics.OdePlugin p.setPrimForRemoval(); AddPhysicsActorTaint(prim); - //RemovePrimThreadLocked(p); } } } @@ -2607,15 +2606,17 @@ namespace OpenSim.Region.Physics.OdePlugin /// /// Called after our prim properties are set Scale, position etc. + /// + /// /// We use this event queue like method to keep changes to the physical scene occuring in the threadlocked mutex /// This assures us that we have no race conditions - /// - /// - public override void AddPhysicsActorTaint(PhysicsActor prim) + /// + /// + public override void AddPhysicsActorTaint(PhysicsActor actor) { - if (prim is OdePrim) + if (actor is OdePrim) { - OdePrim taintedprim = ((OdePrim) prim); + OdePrim taintedprim = ((OdePrim)actor); lock (_taintedPrimLock) { if (!(_taintedPrimH.Contains(taintedprim))) @@ -2627,11 +2628,10 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); _taintedPrimL.Add(taintedprim); // List for ordered readout } } - return; } - else if (prim is OdeCharacter) + else if (actor is OdeCharacter) { - OdeCharacter taintedchar = ((OdeCharacter)prim); + OdeCharacter taintedchar = ((OdeCharacter)actor); lock (_taintedActors) { if (!(_taintedActors.Contains(taintedchar))) @@ -2734,29 +2734,18 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); { try { - // Insert, remove Characters - bool processedtaints = false; - lock (_taintedActors) { if (_taintedActors.Count > 0) { foreach (OdeCharacter character in _taintedActors) - { character.ProcessTaints(); - processedtaints = true; - //character.m_collisionscore = 0; - } - - if (processedtaints) + if (_taintedActors.Count > 0) _taintedActors.Clear(); } } - // Modify other objects in the scene. - processedtaints = false; - lock (_taintedPrimLock) { foreach (OdePrim prim in _taintedPrimL) @@ -2772,7 +2761,6 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); prim.ProcessTaints(); } - processedtaints = true; prim.m_collisionscore = 0; // This loop can block up the Heartbeat for a very long time on large regions. @@ -2785,7 +2773,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); if (SupportsNINJAJoints) SimulatePendingNINJAJoints(); - if (processedtaints) + if (_taintedPrimL.Count > 0) { //Console.WriteLine("Simulate calls Clear of _taintedPrim list"); _taintedPrimH.Clear(); -- cgit v1.1 From b0fe0464af9a11dda184d3613eca734cd8c9f21e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 22 Nov 2011 22:13:57 +0000 Subject: Stop an exception being thrown and a teleport/border cross failing if the desintation sim has no active script engines. This involves getting IScene.RequestModuleInterfaces() to return an empty array (as was stated in the method doc) rather than an array containing one null entry. Callers adjusted to stop checking for the list reference being null (which never happened anyway) --- OpenSim/Framework/IScene.cs | 22 +++++++++++++++--- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 13 +++-------- OpenSim/Region/Framework/Scenes/SceneBase.cs | 2 +- .../Framework/Scenes/SceneObjectPartInventory.cs | 10 ++++----- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 26 +++++++++++----------- 5 files changed, 41 insertions(+), 32 deletions(-) diff --git a/OpenSim/Framework/IScene.cs b/OpenSim/Framework/IScene.cs index f1b4732..76b731f 100644 --- a/OpenSim/Framework/IScene.cs +++ b/OpenSim/Framework/IScene.cs @@ -102,12 +102,28 @@ namespace OpenSim.Framework bool TryGetScenePresence(UUID agentID, out object scenePresence); - T RequestModuleInterface(); - T[] RequestModuleInterfaces(); - + /// + /// Register an interface to a region module. This allows module methods to be called directly as + /// well as via events. If there is already a module registered for this interface, it is not replaced + /// (is this the best behaviour?) + /// + /// void RegisterModuleInterface(M mod); + void StackModuleInterface(M mod); + /// + /// For the given interface, retrieve the region module which implements it. + /// + /// null if there is no registered module implementing that interface + T RequestModuleInterface(); + + /// + /// For the given interface, retrieve an array of region modules that implement it. + /// + /// an empty array if there are no registered modules implementing that interface + T[] RequestModuleInterfaces(); + // void AddCommand(object module, string command, string shorthelp, string longhelp, CommandDelegate callback); ISceneObject DeserializeObject(string representation); diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 663aa22..26eb729 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -82,16 +82,9 @@ namespace OpenSim.Region.Framework.Scenes m_log.Info("[PRIM INVENTORY]: Starting scripts in scene"); IScriptModule[] engines = RequestModuleInterfaces(); - if (engines != null) - { - foreach (IScriptModule engine in engines) - { - if (engine != null) - { - engine.StartProcessing(); - } - } - } + + foreach (IScriptModule engine in engines) + engine.StartProcessing(); } public void AddUploadedInventoryItem(UUID agentID, InventoryItemBase item) diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index dee2ecb..0336fe5 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs @@ -449,7 +449,7 @@ namespace OpenSim.Region.Framework.Scenes } else { - return new T[] { default(T) }; + return new T[] {}; } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 9446741..d80944b 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -232,8 +232,6 @@ namespace OpenSim.Region.Framework.Scenes ArrayList ret = new ArrayList(); IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces(); - if (engines == null) // No engine at all - return ret; foreach (IScriptModule e in engines) { @@ -329,7 +327,7 @@ namespace OpenSim.Region.Framework.Scenes private void RestoreSavedScriptState(UUID oldID, UUID newID) { IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces(); - if (engines == null) // No engine at all + if (engines.Length == 0) // No engine at all return; if (m_part.ParentGroup.m_savedScriptState.ContainsKey(oldID)) @@ -369,6 +367,7 @@ namespace OpenSim.Region.Framework.Scenes m_part.ParentGroup.m_savedScriptState[oldID] = newDoc.OuterXml; } + foreach (IScriptModule e in engines) { if (e != null) @@ -377,6 +376,7 @@ namespace OpenSim.Region.Framework.Scenes break; } } + m_part.ParentGroup.m_savedScriptState.Remove(oldID); } } @@ -1129,7 +1129,7 @@ namespace OpenSim.Region.Framework.Scenes IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces(); - if (engines == null) // No engine at all + if (engines.Length == 0) // No engine at all return ret; List scripts = GetInventoryScripts(); @@ -1157,7 +1157,7 @@ namespace OpenSim.Region.Framework.Scenes public void ResumeScripts() { IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces(); - if (engines == null) + if (engines.Length == 0) return; List scripts = GetInventoryScripts(); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 7d901c9..c2d3501 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3525,23 +3525,23 @@ namespace OpenSim.Region.Framework.Scenes /// The arguments for the event public void SendScriptEventToAttachments(string eventName, Object[] args) { - if (m_scriptEngines != null) + if (m_scriptEngines.Length == 0) + return; + + lock (m_attachments) { - lock (m_attachments) + foreach (SceneObjectGroup grp in m_attachments) { - foreach (SceneObjectGroup grp in m_attachments) + // 16384 is CHANGED_ANIMATION + // + // Send this to all attachment root prims + // + foreach (IScriptModule m in m_scriptEngines) { - // 16384 is CHANGED_ANIMATION - // - // Send this to all attachment root prims - // - foreach (IScriptModule m in m_scriptEngines) - { - if (m == null) // No script engine loaded - continue; + if (m == null) // No script engine loaded + continue; - m.PostObjectEvent(grp.RootPart.UUID, "changed", new Object[] { (int)Changed.ANIMATION }); - } + m.PostObjectEvent(grp.RootPart.UUID, "changed", new Object[] { (int)Changed.ANIMATION }); } } } -- cgit v1.1 From d639f7fdf3ddb4bbb825a08c5c153b5e93b27231 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 22 Nov 2011 22:16:09 +0000 Subject: minor: remove mono compiler warning --- OpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs b/OpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs index 2a44360..23ef757 100755 --- a/OpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs +++ b/OpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs @@ -48,7 +48,7 @@ namespace OpenSim.Region.OptionalModules.PhysicsParameters public class PhysicsParameters : ISharedRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private static string LogHeader = "[PHYSICS PARAMETERS]"; +// private static string LogHeader = "[PHYSICS PARAMETERS]"; private List m_scenes = new List(); private static bool m_commandsLoaded = false; -- cgit v1.1 From fcb066cb5f8d56f13cfbdd4cef9f51a854b95854 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 22 Nov 2011 22:23:52 +0000 Subject: Comment out unimplemented and uncalled RegionCombinerModule.UnCombineRegion() --- .../RegionCombinerModule/RegionCombinerModule.cs | 54 +++++++++++----------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs index 92cbbc6..3f9834c 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs @@ -841,33 +841,33 @@ namespace OpenSim.Region.RegionCombinerModule { } - /// - /// TODO: - /// - /// - public void UnCombineRegion(RegionData rdata) - { - lock (m_regions) - { - if (m_regions.ContainsKey(rdata.RegionId)) - { - // uncombine root region and virtual regions - } - else - { - foreach (RegionConnections r in m_regions.Values) - { - foreach (RegionData rd in r.ConnectedRegions) - { - if (rd.RegionId == rdata.RegionId) - { - // uncombine virtual region - } - } - } - } - } - } +// /// +// /// TODO: +// /// +// /// +// public void UnCombineRegion(RegionData rdata) +// { +// lock (m_regions) +// { +// if (m_regions.ContainsKey(rdata.RegionId)) +// { +// // uncombine root region and virtual regions +// } +// else +// { +// foreach (RegionConnections r in m_regions.Values) +// { +// foreach (RegionData rd in r.ConnectedRegions) +// { +// if (rd.RegionId == rdata.RegionId) +// { +// // uncombine virtual region +// } +// } +// } +// } +// } +// } // Create a set of infinite borders around the whole aabb of the combined island. private void AdjustLargeRegionBounds() -- cgit v1.1 From af90b527314d6cf441dcd593886739ac77b68558 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 22 Nov 2011 22:28:46 +0000 Subject: Comment out uncalled OdeScene.UnCombine() --- OpenSim/Region/Physics/Manager/PhysicsScene.cs | 10 +-- OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 116 ++++++++++++------------- 2 files changed, 60 insertions(+), 66 deletions(-) diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs index eaa1175..7ab295a 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs @@ -221,15 +221,9 @@ namespace OpenSim.Region.Physics.Manager return false; } - public virtual void Combine(PhysicsScene pScene, Vector3 offset, Vector3 extents) - { - return; - } + public virtual void Combine(PhysicsScene pScene, Vector3 offset, Vector3 extents) {} - public virtual void UnCombine(PhysicsScene pScene) - { - - } + public virtual void UnCombine(PhysicsScene pScene) {} /// /// Queue a raycast against the physics scene. diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs index 72e9ca0..b5436bd 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs @@ -3583,64 +3583,64 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); return true; } - public override void UnCombine(PhysicsScene pScene) - { - IntPtr localGround = IntPtr.Zero; -// float[] localHeightfield; - bool proceed = false; - List geomDestroyList = new List(); - - lock (OdeLock) - { - if (RegionTerrain.TryGetValue(Vector3.Zero, out localGround)) - { - foreach (IntPtr geom in TerrainHeightFieldHeights.Keys) - { - if (geom == localGround) - { -// localHeightfield = TerrainHeightFieldHeights[geom]; - proceed = true; - } - else - { - geomDestroyList.Add(geom); - } - } - - if (proceed) - { - m_worldOffset = Vector3.Zero; - WorldExtents = new Vector2((int)Constants.RegionSize, (int)Constants.RegionSize); - m_parentScene = null; - - foreach (IntPtr g in geomDestroyList) - { - // removingHeightField needs to be done or the garbage collector will - // collect the terrain data before we tell ODE to destroy it causing - // memory corruption - if (TerrainHeightFieldHeights.ContainsKey(g)) - { -// float[] removingHeightField = TerrainHeightFieldHeights[g]; - TerrainHeightFieldHeights.Remove(g); - - if (RegionTerrain.ContainsKey(g)) - { - RegionTerrain.Remove(g); - } - - d.GeomDestroy(g); - //removingHeightField = new float[0]; - } - } - - } - else - { - m_log.Warn("[PHYSICS]: Couldn't proceed with UnCombine. Region has inconsistant data."); - } - } - } - } +// public override void UnCombine(PhysicsScene pScene) +// { +// IntPtr localGround = IntPtr.Zero; +//// float[] localHeightfield; +// bool proceed = false; +// List geomDestroyList = new List(); +// +// lock (OdeLock) +// { +// if (RegionTerrain.TryGetValue(Vector3.Zero, out localGround)) +// { +// foreach (IntPtr geom in TerrainHeightFieldHeights.Keys) +// { +// if (geom == localGround) +// { +//// localHeightfield = TerrainHeightFieldHeights[geom]; +// proceed = true; +// } +// else +// { +// geomDestroyList.Add(geom); +// } +// } +// +// if (proceed) +// { +// m_worldOffset = Vector3.Zero; +// WorldExtents = new Vector2((int)Constants.RegionSize, (int)Constants.RegionSize); +// m_parentScene = null; +// +// foreach (IntPtr g in geomDestroyList) +// { +// // removingHeightField needs to be done or the garbage collector will +// // collect the terrain data before we tell ODE to destroy it causing +// // memory corruption +// if (TerrainHeightFieldHeights.ContainsKey(g)) +// { +//// float[] removingHeightField = TerrainHeightFieldHeights[g]; +// TerrainHeightFieldHeights.Remove(g); +// +// if (RegionTerrain.ContainsKey(g)) +// { +// RegionTerrain.Remove(g); +// } +// +// d.GeomDestroy(g); +// //removingHeightField = new float[0]; +// } +// } +// +// } +// else +// { +// m_log.Warn("[PHYSICS]: Couldn't proceed with UnCombine. Region has inconsistant data."); +// } +// } +// } +// } public override void SetWaterLevel(float baseheight) { -- cgit v1.1 From ace4324e753435e317ec388b5b25a8e3ffd84db4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 22 Nov 2011 22:37:06 +0000 Subject: Stop removing actor from the hash maps in OdeScene.RemoveCharacter() since this is now being down in OdeCharacter.DestroyOdeStructures() --- OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs index b5436bd..7b04bcf 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs @@ -1735,12 +1735,7 @@ namespace OpenSim.Region.Physics.OdePlugin internal void RemoveCharacter(OdeCharacter chr) { - if (_characters.Contains(chr)) - { - _characters.Remove(chr); - geom_name_map.Remove(chr.Shell); - actor_name_map.Remove(chr.Shell); - } + _characters.Remove(chr); } private PhysicsActor AddPrim(String name, Vector3 position, Vector3 size, Quaternion rotation, -- cgit v1.1 From b56410285b1af7c5fc2b4a84d8c9c734d2238ff0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 22 Nov 2011 22:46:25 +0000 Subject: Log error if we attempt to add/remove an OdeCharacter from the _characters list inappropriately --- OpenSim/Region/Physics/OdePlugin/OdeScene.cs | 56 ++++++++++++++++------------ 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs index 7b04bcf..0456f56 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs @@ -377,8 +377,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; @@ -769,7 +768,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 @@ -821,17 +820,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; } @@ -1556,7 +1555,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); @@ -1587,13 +1586,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, @@ -2222,7 +2232,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); @@ -2314,7 +2324,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); } } @@ -2330,7 +2340,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); } } @@ -2353,7 +2363,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); } } @@ -2373,7 +2383,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); } } @@ -2389,7 +2399,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); } } @@ -2633,7 +2643,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); } } } @@ -2836,7 +2846,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; @@ -2845,7 +2855,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); } @@ -3405,7 +3415,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]; @@ -3436,7 +3446,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); private void SetTerrain(float[] heightMap, Vector3 pOffset) { int startTime = Util.EnvironmentTickCount(); - m_log.DebugFormat("[PHYSICS]: Setting terrain for {0}", Name); + 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 @@ -3561,7 +3571,7 @@ Console.WriteLine("AddPhysicsActorTaint to " + taintedprim.Name); } m_log.DebugFormat( - "[PHYSICS]: Setting terrain for {0} took {1}ms", Name, Util.EnvironmentTickCountSubtract(startTime)); + "[ODE SCENE]: Setting terrain for {0} took {1}ms", Name, Util.EnvironmentTickCountSubtract(startTime)); } public override void DeleteTerrain() -- cgit v1.1