From 5181bdae0a3c867ca26900bd3309b7ea56538147 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Fri, 3 Aug 2012 12:21:57 +0100 Subject: attempting to fix a build issue Signed-off-by: BlueWall --- .../Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs index d039111..6b9f537 100644 --- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs @@ -596,9 +596,9 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender } break; case "R": - Font newFont = new Font(myFont, FontStyle.Regular); +// Font newFont = new Font(myFont, FontStyle.Regular); myFont.Dispose(); - myFont = newFont; + myFont = new Font(myFont, FontStyle.Regular); break; } } -- cgit v1.1 From 789e88d8bd2a4e67623faec548db5389cc8fe918 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 3 Aug 2012 21:36:00 +0100 Subject: Move previously unadvertised SendPeriodicAppearanceUpdates setting from [Startup] to [Appearance] config section. Add description and default of false (as before) to OpenSimDefaults.ini If set to true, this config switch will resend avatar appearance information (a small amount of UUID data, not the baked textures themselves) to other avatars in the sim every 60 seconds. For me, this has helped with situations where avatars appear persistently grey - the LL viewer sometimes did not appear to request assets the first time the appearance data was sent. However, this switch will not help with other appearance failure situations (e.g. failure to bake assets). This setting is experimental but will not have any significant impact on the simulator if turned to true. --- OpenSim/Region/Framework/Scenes/Scene.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index c77457c..40cfb72 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -814,8 +814,14 @@ namespace OpenSim.Region.Framework.Scenes m_update_presences = startupConfig.GetInt( "UpdateAgentsEveryNFrames", m_update_presences); m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); + } - SendPeriodicAppearanceUpdates = startupConfig.GetBoolean("SendPeriodicAppearanceUpdates", SendPeriodicAppearanceUpdates); + // FIXME: Ultimately this should be in a module. + IConfig appearanceConfig = m_config.Configs["Appearance"]; + if (appearanceConfig != null) + { + SendPeriodicAppearanceUpdates + = appearanceConfig.GetBoolean("ResendAppearanceUpdates", SendPeriodicAppearanceUpdates); } #endregion Region Config -- cgit v1.1 From faffe2f2f9beda067d2e7bb68918c43bb55ef595 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 3 Aug 2012 22:03:04 +0100 Subject: Fix the recent windows compile error by putting newFont for case "R" in VectorRenderModule inside its own context, rather than disposing of the old font before using it as a prototype for the new. --- .../CoreModules/Scripting/VectorRender/VectorRenderModule.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs index 6b9f537..ca320e1 100644 --- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs @@ -596,9 +596,14 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender } break; case "R": -// Font newFont = new Font(myFont, FontStyle.Regular); - myFont.Dispose(); - myFont = new Font(myFont, FontStyle.Regular); + // We need to place this newFont inside its own context so that the .NET compiler + // doesn't complain about a redefinition of an existing newFont, even though there is none + // The mono compiler doesn't produce this error. + { + Font newFont = new Font(myFont, FontStyle.Regular); + myFont.Dispose(); + myFont = newFont; + } break; } } -- cgit v1.1 From 5914270ff19bdeb745901c0e3fce99c09caeedf3 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 3 Aug 2012 22:15:06 +0100 Subject: Restore SOG constructor chaining removed in recent 513b77b. This is not a functional change. --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 7b284ae..5f90035 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -650,7 +650,7 @@ namespace OpenSim.Region.Framework.Scenes /// its existing localID and UUID. /// /// Root part for this scene object. - public SceneObjectGroup(SceneObjectPart part) + public SceneObjectGroup(SceneObjectPart part) : this() { SetRootPart(part); } -- cgit v1.1 From 205f2326dc17a4926b36ecfd5e67a4da0b755f3b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 3 Aug 2012 23:02:39 +0100 Subject: Consolidate PersistBakedTextures, DelayBeforeAppearanceSend and DelayBeforeAppearanceSave into [Appearance] section from [Startup] config section so that all appearance settings are in the same place and not in the startup bucket. All these settings are in OpenSimDefaults.ini only. If you are using them then please adjust your OpenSim.ini --- OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 7 ++++++- OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index 6c28e78..185f9ce 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -123,9 +123,14 @@ namespace OpenSim.Region.ClientStack.Linden IConfig sconfig = config.Configs["Startup"]; if (sconfig != null) { - m_persistBakedTextures = sconfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures); m_levelUpload = sconfig.GetInt("LevelUpload", 0); } + + IConfig appearanceConfig = config.Configs["Appearance"]; + if (appearanceConfig != null) + { + m_persistBakedTextures = appearanceConfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures); + } } m_assetService = m_Scene.AssetService; diff --git a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs index b3d61a8..6aac591 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs @@ -66,9 +66,9 @@ namespace OpenSim.Region.ClientStack.Linden public void Initialise(IConfigSource source) { - IConfig sconfig = source.Configs["Startup"]; - if (sconfig != null) - m_persistBakedTextures = sconfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures); + IConfig appearanceConfig = source.Configs["Appearance"]; + if (appearanceConfig != null) + m_persistBakedTextures = appearanceConfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures); } public void AddRegion(Scene s) -- cgit v1.1 From 0e3b08fa5bca2200e18dac7a3d1d72d5f4d7bf64 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 3 Aug 2012 23:09:47 +0100 Subject: Update settings loading in AvatarFactoryModule which should have been in last commit 205f2326 --- .../CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 68a4cde..47d5c97 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -66,11 +66,11 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory scene.RegisterModuleInterface(this); scene.EventManager.OnNewClient += SubscribeToClientEvents; - IConfig sconfig = config.Configs["Startup"]; - if (sconfig != null) + IConfig appearanceConfig = appearanceConfig.Configs["Appearance"]; + if (appearanceConfig != null) { - m_savetime = Convert.ToInt32(sconfig.GetString("DelayBeforeAppearanceSave",Convert.ToString(m_savetime))); - m_sendtime = Convert.ToInt32(sconfig.GetString("DelayBeforeAppearanceSend",Convert.ToString(m_sendtime))); + m_savetime = Convert.ToInt32(appearanceConfig.GetString("DelayBeforeAppearanceSave",Convert.ToString(m_savetime))); + m_sendtime = Convert.ToInt32(appearanceConfig.GetString("DelayBeforeAppearanceSend",Convert.ToString(m_sendtime))); // m_log.InfoFormat("[AVFACTORY] configured for {0} save and {1} send",m_savetime,m_sendtime); } -- cgit v1.1 From ea36d4a4cf716442e83cc9cd1b419a43be5adc6e Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 1 Aug 2012 15:04:09 -0700 Subject: BulletSim: Add AddObjectForce to BulletSim API. Add interface 2 enhancements to BSCharacter. Modify AddForce and SetForce to use the new Bullet interface. More DetailLog statements for character. --- .../Region/Physics/BulletSPlugin/BSCharacter.cs | 26 ++++++++++++++++--- OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 29 +++++++++------------- .../Region/Physics/BulletSPlugin/BulletSimAPI.cs | 3 +++ 3 files changed, 38 insertions(+), 20 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 09e1f0c..a5635ff 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -40,6 +40,7 @@ public class BSCharacter : PhysicsActor private static readonly string LogHeader = "[BULLETS CHAR]"; private BSScene _scene; + public BSScene Scene { get { return _scene; } } private String _avName; // private bool _stopped; private Vector3 _size; @@ -73,6 +74,12 @@ public class BSCharacter : PhysicsActor private bool _kinematic; private float _buoyancy; + private BulletBody m_body; + public BulletBody Body { + get { return m_body; } + set { m_body = value; } + } + private int _subscribedEventsMs = 0; private int _nextCollisionOkTime = 0; @@ -116,6 +123,8 @@ public class BSCharacter : PhysicsActor _scene.TaintedObject(delegate() { BulletSimAPI.CreateObject(parent_scene.WorldID, shapeData); + + m_body = new BulletBody(LocalID, BulletSimAPI.GetBodyHandle2(_scene.World.Ptr, LocalID)); }); return; @@ -124,6 +133,7 @@ public class BSCharacter : PhysicsActor // called when this character is being destroyed and the resources should be released public void Destroy() { + // DetailLog("{0},Destroy", LocalID); _scene.TaintedObject(delegate() { BulletSimAPI.DestroyObject(_scene.WorldID, _localID); @@ -174,6 +184,7 @@ public class BSCharacter : PhysicsActor _position = value; _scene.TaintedObject(delegate() { + DetailLog("{0},SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation); }); } @@ -188,9 +199,10 @@ public class BSCharacter : PhysicsActor set { _force = value; // m_log.DebugFormat("{0}: Force = {1}", LogHeader, _force); - _scene.TaintedObject(delegate() + Scene.TaintedObject(delegate() { - BulletSimAPI.SetObjectForce(_scene.WorldID, _localID, _force); + DetailLog("{0},setForce,taint,force={1}", LocalID, _force); + BulletSimAPI.SetObjectForce(Scene.WorldID, LocalID, _force); }); } } @@ -216,6 +228,7 @@ public class BSCharacter : PhysicsActor // m_log.DebugFormat("{0}: set velocity = {1}", LogHeader, _velocity); _scene.TaintedObject(delegate() { + DetailLog("{0},setVelocity,taint,vel={1}", LocalID, _velocity); BulletSimAPI.SetObjectVelocity(_scene.WorldID, _localID, _velocity); }); } @@ -305,6 +318,7 @@ public class BSCharacter : PhysicsActor set { _buoyancy = value; _scene.TaintedObject(delegate() { + DetailLog("{0},setBuoyancy,taint,buoy={1}", LocalID, _buoyancy); BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, LocalID, _buoyancy); }); } @@ -351,7 +365,8 @@ public class BSCharacter : PhysicsActor // m_log.DebugFormat("{0}: AddForce. adding={1}, newForce={2}", LogHeader, force, _force); _scene.TaintedObject(delegate() { - BulletSimAPI.SetObjectForce(_scene.WorldID, _localID, _force); + DetailLog("{0},setAddForce,taint,addedForce={1}", LocalID, _force); + BulletSimAPI.AddObjectForce2(Body.Ptr, _force); }); } else @@ -480,5 +495,10 @@ public class BSCharacter : PhysicsActor // End kludge } + // Invoke the detailed logger and output something if it's enabled. + private void DetailLog(string msg, params Object[] args) + { + Scene.PhysicsLogging.Write(msg, args); + } } } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index ebfd85b..22f5995 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -187,7 +187,7 @@ public sealed class BSPrim : PhysicsActor { _mass = CalculateMass(); // changing size changes the mass BulletSimAPI.SetObjectScaleMass(_scene.WorldID, _localID, _scale, (IsPhysical ? _mass : 0f), IsPhysical); - DetailLog("{0}: setSize: size={1}, mass={2}, physical={3}", LocalID, _size, _mass, IsPhysical); + // DetailLog("{0}: setSize: size={1}, mass={2}, physical={3}", LocalID, _size, _mass, IsPhysical); RecreateGeomAndObject(); }); } @@ -318,7 +318,7 @@ public sealed class BSPrim : PhysicsActor _force = value; _scene.TaintedObject(delegate() { - DetailLog("{0},SetForce,taint,force={1}", LocalID, _force); + DetailLog("{0},setForce,taint,force={1}", LocalID, _force); // BulletSimAPI.SetObjectForce(_scene.WorldID, _localID, _force); BulletSimAPI.SetObjectForce2(Body.Ptr, _force); }); @@ -443,7 +443,7 @@ public sealed class BSPrim : PhysicsActor _scene.TaintedObject(delegate() { // _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID); - DetailLog("{0},SetOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation); + DetailLog("{0},setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation); BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation); }); } @@ -487,10 +487,8 @@ public sealed class BSPrim : PhysicsActor // Maybe a VerifyCorrectPhysicalShape() routine? // RecreateGeomAndObject(); - float mass = _mass; - // Bullet wants static objects have a mass of zero - if (IsStatic) - mass = 0f; + // Bullet wants static objects to have a mass of zero + float mass = IsStatic ? 0f : _mass; DetailLog("{0},SetObjectDynamic,taint,static={1},solid={2},mass={3}", LocalID, IsStatic, IsSolid, mass); BulletSimAPI.SetObjectProperties(_scene.WorldID, LocalID, IsStatic, IsSolid, SubscribedEvents(), mass); @@ -607,6 +605,7 @@ public sealed class BSPrim : PhysicsActor private List m_accumulatedForces = new List(); public override void AddForce(OMV.Vector3 force, bool pushforce) { + // for an object, doesn't matter if force is a pushforce or not if (force.IsFinite()) { // _force += force; @@ -620,21 +619,17 @@ public sealed class BSPrim : PhysicsActor } _scene.TaintedObject(delegate() { + OMV.Vector3 fSum = OMV.Vector3.Zero; lock (m_accumulatedForces) { - if (m_accumulatedForces.Count > 0) + foreach (OMV.Vector3 v in m_accumulatedForces) { - OMV.Vector3 fSum = OMV.Vector3.Zero; - foreach (OMV.Vector3 v in m_accumulatedForces) - { - fSum += v; - } - m_accumulatedForces.Clear(); - - DetailLog("{0},SetObjectForce,taint,force={1}", LocalID, fSum); - BulletSimAPI.SetObjectForce(_scene.WorldID, _localID, fSum); + fSum += v; } + m_accumulatedForces.Clear(); } + DetailLog("{0},AddObjectForce,taint,force={1}", LocalID, _force); + BulletSimAPI.AddObjectForce2(Body.Ptr, fSum); }); } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs index 0ffbc94..1881e41 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs @@ -448,6 +448,9 @@ public static extern bool SetAngularVelocity2(IntPtr obj, Vector3 angularVelocit public static extern bool SetObjectForce2(IntPtr obj, Vector3 force); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] +public static extern bool AddObjectForce2(IntPtr obj, Vector3 force); + +[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern bool SetCcdMotionThreshold2(IntPtr obj, float val); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] -- cgit v1.1 From e7ad6ed3a3fda013cd393df6bb50236871092249 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 3 Aug 2012 14:44:07 -0700 Subject: BulletSim: pass collision subscription information to the C++ code so collisions on objects that don't care are not reported up. --- .../Region/Physics/BulletSPlugin/BSCharacter.cs | 18 ++++++++++++++- OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 16 +++++++++++-- .../Region/Physics/BulletSPlugin/BulletSimAPI.cs | 27 +++++++++++----------- 3 files changed, 45 insertions(+), 16 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index a5635ff..494f5a6 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -125,6 +125,8 @@ public class BSCharacter : PhysicsActor BulletSimAPI.CreateObject(parent_scene.WorldID, shapeData); m_body = new BulletBody(LocalID, BulletSimAPI.GetBodyHandle2(_scene.World.Ptr, LocalID)); + // avatars get all collisions no matter what + BulletSimAPI.AddToCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); }); return; @@ -384,11 +386,25 @@ public class BSCharacter : PhysicsActor // Turn on collision events at a rate no faster than one every the given milliseconds public override void SubscribeEvents(int ms) { _subscribedEventsMs = ms; - _nextCollisionOkTime = Util.EnvironmentTickCount() - _subscribedEventsMs; // make first collision happen + if (ms > 0) + { + // make sure first collision happens + _nextCollisionOkTime = Util.EnvironmentTickCount() - _subscribedEventsMs; + + Scene.TaintedObject(delegate() + { + BulletSimAPI.AddToCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); + }); + } } // Stop collision events public override void UnSubscribeEvents() { _subscribedEventsMs = 0; + // Avatars get all their collision events + // Scene.TaintedObject(delegate() + // { + // BulletSimAPI.RemoveFromCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); + // }); } // Return 'true' if someone has subscribed to events public override bool SubscribedEvents() { diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 22f5995..8e6685b 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -642,11 +642,23 @@ public sealed class BSPrim : PhysicsActor } public override void SubscribeEvents(int ms) { _subscribedEventsMs = ms; - // make sure first collision happens - _nextCollisionOkTime = Util.EnvironmentTickCount() - _subscribedEventsMs; + if (ms > 0) + { + // make sure first collision happens + _nextCollisionOkTime = Util.EnvironmentTickCount() - _subscribedEventsMs; + + Scene.TaintedObject(delegate() + { + BulletSimAPI.AddToCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); + }); + } } public override void UnSubscribeEvents() { _subscribedEventsMs = 0; + Scene.TaintedObject(delegate() + { + BulletSimAPI.RemoveFromCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); + }); } public override bool SubscribedEvents() { return (_subscribedEventsMs > 0); diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs index 1881e41..4e05df6 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs @@ -179,17 +179,18 @@ public struct ConfigurationParameters // Values used by Bullet and BulletSim to control collisions public enum CollisionFlags : uint { - STATIC_OBJECT = 1 << 0, - KINEMATIC_OBJECT = 1 << 1, - NO_CONTACT_RESPONSE = 1 << 2, - CUSTOM_MATERIAL_CALLBACK = 1 << 3, - CHARACTER_OBJECT = 1 << 4, - DISABLE_VISUALIZE_OBJECT = 1 << 5, - DISABLE_SPU_COLLISION_PROCESS = 1 << 6, + CF_STATIC_OBJECT = 1 << 0, + CF_KINEMATIC_OBJECT = 1 << 1, + CF_NO_CONTACT_RESPONSE = 1 << 2, + CF_CUSTOM_MATERIAL_CALLBACK = 1 << 3, + CF_CHARACTER_OBJECT = 1 << 4, + CF_DISABLE_VISUALIZE_OBJECT = 1 << 5, + CF_DISABLE_SPU_COLLISION_PROCESS = 1 << 6, // Following used by BulletSim to control collisions - VOLUME_DETECT_OBJECT = 1 << 10, - PHANTOM_OBJECT = 1 << 11, - PHYSICAL_OBJECT = 1 << 12, + BS_SUBSCRIBE_COLLISION_EVENTS = 1 << 10, + BS_VOLUME_DETECT_OBJECT = 1 << 11, + BS_PHANTOM_OBJECT = 1 << 12, + BS_PHYSICAL_OBJECT = 1 << 13, }; // CFM controls the 'hardness' of the constraint. 0=fixed, 0..1=violatable. Default=0 @@ -481,13 +482,13 @@ public static extern bool SetLinearVelocity2(IntPtr obj, Vector3 val); public static extern bool SetInterpolation2(IntPtr obj, Vector3 lin, Vector3 ang); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] -public static extern IntPtr SetCollisionFlags2(IntPtr obj, uint flags); +public static extern IntPtr SetCollisionFlags2(IntPtr obj, CollisionFlags flags); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] -public static extern IntPtr AddToCollisionFlags2(IntPtr obj, uint flags); +public static extern IntPtr AddToCollisionFlags2(IntPtr obj, CollisionFlags flags); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] -public static extern IntPtr RemoveFromCollisionFlags2(IntPtr obj, uint flags); +public static extern IntPtr RemoveFromCollisionFlags2(IntPtr obj, CollisionFlags flags); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern bool SetMassProps2(IntPtr obj, float mass, Vector3 inertia); -- cgit v1.1 From 2724cf685e5e15c6c7f5c04c1609faa37c5db84e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 3 Aug 2012 23:13:19 +0100 Subject: Fix build break. --- OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 47d5c97..1d6e522 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -66,7 +66,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory scene.RegisterModuleInterface(this); scene.EventManager.OnNewClient += SubscribeToClientEvents; - IConfig appearanceConfig = appearanceConfig.Configs["Appearance"]; + IConfig appearanceConfig = config.Configs["Appearance"]; if (appearanceConfig != null) { m_savetime = Convert.ToInt32(appearanceConfig.GetString("DelayBeforeAppearanceSave",Convert.ToString(m_savetime))); -- cgit v1.1 From fb91ca6f1d3e61444005175d0a0d55025d15ad5b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 3 Aug 2012 23:49:34 +0100 Subject: Fix old regression that stopped saving parcel owner data in OARs. This was working in 0.7.2 but was accidentally removed from 0.7.3. The --publish option for "save oar" will now save oars stripped of parcel owner information as well as scene object info. Please use the --publish option if you want to publish oars that may be later loaded by others to the same grid from which they were saved. --- .../Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs index c179a34..0780d86 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequestExecution.cs @@ -124,7 +124,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver LandData landData = lo.LandData; string landDataPath = String.Format("{0}{1}.xml", ArchiveConstants.LANDDATA_PATH, landData.GlobalID.ToString()); - m_archiveWriter.WriteFile(landDataPath, LandDataSerializer.Serialize(landData)); + m_archiveWriter.WriteFile(landDataPath, LandDataSerializer.Serialize(landData, m_options)); } m_log.InfoFormat("[ARCHIVER]: Adding terrain information to archive."); -- cgit v1.1 From 374ebab5742fda56b148b874d2ead5fb7d13aef9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 3 Aug 2012 23:54:17 +0100 Subject: Strip experimental tag from --publish option of "save oar" region console command --- OpenSim/Region/Application/OpenSim.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 07a9756..6bbab35 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -294,14 +294,13 @@ namespace OpenSim "save oar [-h|--home=] [--noassets] [--publish] [--perm=] []", "Save a region's data to an OAR archive.", // "-v|--version= generates scene objects as per older versions of the serialization (e.g. -v=0)" + Environment.NewLine - "-h|--home= adds the url of the profile service to the saved user information." + Environment.NewLine - + "--noassets stops assets being saved to the OAR." + Environment.NewLine - + "--publish saves an OAR stripped of owner and last owner information." + Environment.NewLine - + " on reload, the estate owner will be the owner of all objects" + Environment.NewLine - + " this is useful if you're making oars generally available that might be reloaded to the same grid from which you published" + Environment.NewLine - + " this option is EXPERIMENTAL" + Environment.NewLine - + "--perm= stops objects with insufficient permissions from being saved to the OAR." + Environment.NewLine - + " can contain one or more of these characters: \"C\" = Copy, \"T\" = Transfer" + Environment.NewLine + "-h|--home= adds the url of the profile service to the saved user information.\n" + + "--noassets stops assets being saved to the OAR.\n" + + "--publish saves an OAR stripped of owner and last owner information.\n" + + " on reload, the estate owner will be the owner of all objects\n" + + " this is useful if you're making oars generally available that might be reloaded to the same grid from which you published\n" + + "--perm= stops objects with insufficient permissions from being saved to the OAR.\n" + + " can contain one or more of these characters: \"C\" = Copy, \"T\" = Transfer\n" + "The OAR path must be a filesystem path." + " If this is not given then the oar is saved to region.oar in the current directory.", SaveOar); -- cgit v1.1 From 4adb3471ac6e7710395a47d77aa8c1b3715a6c99 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 6 Aug 2012 12:55:52 -0700 Subject: BulletSim: update SOs and DLLs to run on more Linux versions. Correct multiple buoyancy settings when character flying. Remove chatty log message on prim destruction. --- OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | 9 ++++++--- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 494f5a6..ee485b4 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -274,9 +274,12 @@ public class BSCharacter : PhysicsActor public override bool Flying { get { return _flying; } set { - _flying = value; - // simulate flying by changing the effect of gravity - this.Buoyancy = ComputeBuoyancyFromFlying(_flying); + if (_flying != value) + { + _flying = value; + // simulate flying by changing the effect of gravity + this.Buoyancy = ComputeBuoyancyFromFlying(_flying); + } } } private float ComputeBuoyancyFromFlying(bool ifFlying) { diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 011033c..7151908 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -352,7 +352,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters BSPrim bsprim = prim as BSPrim; if (bsprim != null) { - m_log.DebugFormat("{0}: RemovePrim. id={1}/{2}", LogHeader, bsprim.Name, bsprim.LocalID); + // m_log.DebugFormat("{0}: RemovePrim. id={1}/{2}", LogHeader, bsprim.Name, bsprim.LocalID); try { lock (m_prims) m_prims.Remove(bsprim.LocalID); -- cgit v1.1 From 926c0b90a17716ae3f83feaa1703703326bc6434 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 7 Aug 2012 20:48:22 +0100 Subject: Release http-in URLs when llResetScript is called --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index c3b1f3d..3591d14 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -183,6 +183,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llResetScript() { m_host.AddScriptLPS(1); + + // We need to tell the URL module, if we hav one, to release + // the allocated URLs + if (m_UrlModule != null) + m_UrlModule.ScriptRemoved(m_item.ItemID); + m_ScriptEngine.ApiResetScript(m_item.ItemID); } -- cgit v1.1 From 1c51ae662c3cff284104ca643479654c8f61d2ff Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 7 Aug 2012 20:48:22 +0100 Subject: Release http-in URLs when llResetScript is called --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index ce1c364..7237d1d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -226,6 +226,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llResetScript() { m_host.AddScriptLPS(1); + + // We need to tell the URL module, if we hav one, to release + // the allocated URLs + if (m_UrlModule != null) + m_UrlModule.ScriptRemoved(m_item.ItemID); + m_ScriptEngine.ApiResetScript(m_item.ItemID); } -- cgit v1.1 From 19417fca41e59e931193ee99d3e4a12092488f1f Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 7 Aug 2012 17:15:06 -0700 Subject: BulletSim: Added avatar capsule scaling for size of avatar. This also fixes computation of avatar mass. Added parameter MaxPersistantManifoldPoolSize. Fixed a parameter setting bug which caused crashes of there were more than 400 or so physical objects. I tested up to 5000. Updated BulletSim DLLs and SOs. --- .../Region/Physics/BulletSPlugin/BSCharacter.cs | 41 ++++++++++++++++++---- OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 8 ++--- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 11 ++++-- .../Region/Physics/BulletSPlugin/BulletSimAPI.cs | 1 + 4 files changed, 47 insertions(+), 14 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index ee485b4..d4f5c63 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -102,7 +102,9 @@ public class BSCharacter : PhysicsActor _orientation = Quaternion.Identity; _velocity = Vector3.Zero; _buoyancy = ComputeBuoyancyFromFlying(isFlying); - _scale = new Vector3(1f, 1f, 1f); + // The dimensions of the avatar capsule are kept in the scale. + // Physics creates a unit capsule which is scaled by the physics engine. + _scale = new Vector3(_scene.Params.avatarCapsuleRadius, _scene.Params.avatarCapsuleRadius, size.Z); _density = _scene.Params.avatarDensity; ComputeAvatarVolumeAndMass(); // set _avatarVolume and _mass based on capsule size, _density and _scale @@ -150,9 +152,28 @@ public class BSCharacter : PhysicsActor public override bool Stopped { get { return false; } } - public override Vector3 Size { - get { return _size; } - set { _size = value; + public override Vector3 Size { + get + { + // Avatar capsule size is kept in the scale parameter. + return new Vector3(_scale.X * 2, _scale.Y * 2, _scale.Z); + } + + set { + // When an avatar's size is set, only the height is changed + // and that really only depends on the radius. + _size = value; + _scale.Z = (_size.Z * 1.15f) - (_scale.X + _scale.Y); + + // TODO: something has to be done with the avatar's vertical position + + ComputeAvatarVolumeAndMass(); + + _scene.TaintedObject(delegate() + { + BulletSimAPI.SetObjectScaleMass(_scene.WorldID, LocalID, _scale, _mass, true); + }); + } } public override PrimitiveBaseShape Shape { @@ -419,9 +440,15 @@ public class BSCharacter : PhysicsActor { _avatarVolume = (float)( Math.PI - * _scene.Params.avatarCapsuleRadius * _scale.X - * _scene.Params.avatarCapsuleRadius * _scale.Y - * _scene.Params.avatarCapsuleHeight * _scale.Z); + * _scale.X + * _scale.Y // the area of capsule cylinder + * _scale.Z // times height of capsule cylinder + + 1.33333333f + * Math.PI + * _scale.X + * Math.Min(_scale.X, _scale.Y) + * _scale.Y // plus the volume of the capsule end caps + ); _mass = _density * _avatarVolume; } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 8e6685b..11868bc 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -977,8 +977,8 @@ public sealed class BSPrim : PhysicsActor { if (_pbs.ProfileShape == ProfileShape.HalfCircle && _pbs.PathCurve == (byte)Extrusion.Curve1) { - if (_size.X == _size.Y && _size.Y == _size.Z && _size.X == _size.Z) - { + // if (_size.X == _size.Y && _size.Y == _size.Z && _size.X == _size.Z) + // { // m_log.DebugFormat("{0}: CreateGeom: Defaulting to sphere of size {1}", LogHeader, _size); if (forceRebuild || (_shapeType != ShapeData.PhysicsShapeType.SHAPE_SPHERE)) { @@ -989,7 +989,7 @@ public sealed class BSPrim : PhysicsActor // TODO: do we need to check for and destroy a mesh or hull that might have been left from before? ret = true; } - } + // } } else { @@ -1039,7 +1039,7 @@ public sealed class BSPrim : PhysicsActor // if this new shape is the same as last time, don't recreate the mesh if (_meshKey == newMeshKey) return; - DetailLog("{0},CreateGeomMesh,create,key={1}", LocalID, _meshKey); + DetailLog("{0},CreateGeomMesh,create,key={1}", LocalID, newMeshKey); // Since we're recreating new, get rid of any previously generated shape if (_meshKey != 0) { diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 7151908..0e257b6 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -1027,14 +1027,19 @@ public class BSScene : PhysicsScene, IPhysicsParameters (s,p,l,v) => { s.UpdateParameterAvatars(ref s.m_params[0].avatarContactProcessingThreshold, p, l, v); } ), - new ParameterDefn("MaxPersistantManifoldPoolSize", "Number of manifolds pooled (0 means default)", + new ParameterDefn("MaxPersistantManifoldPoolSize", "Number of manifolds pooled (0 means default of 4096)", 0f, // zero to disable (s,cf,p,v) => { s.m_params[0].maxPersistantManifoldPoolSize = cf.GetFloat(p, v); }, (s) => { return s.m_params[0].maxPersistantManifoldPoolSize; }, (s,p,l,v) => { s.m_params[0].maxPersistantManifoldPoolSize = v; } ), + new ParameterDefn("MaxCollisionAlgorithmPoolSize", "Number of collisions pooled (0 means default of 4096)", + 0f, // zero to disable + (s,cf,p,v) => { s.m_params[0].maxCollisionAlgorithmPoolSize = cf.GetFloat(p, v); }, + (s) => { return s.m_params[0].maxCollisionAlgorithmPoolSize; }, + (s,p,l,v) => { s.m_params[0].maxCollisionAlgorithmPoolSize = v; } ), new ParameterDefn("ShouldDisableContactPoolDynamicAllocation", "Enable to allow large changes in object count", - ConfigurationParameters.numericTrue, - (s,cf,p,v) => { s.m_params[0].maxPersistantManifoldPoolSize = s.NumericBool(cf.GetBoolean(p, s.BoolNumeric(v))); }, + ConfigurationParameters.numericFalse, + (s,cf,p,v) => { s.m_params[0].shouldDisableContactPoolDynamicAllocation = s.NumericBool(cf.GetBoolean(p, s.BoolNumeric(v))); }, (s) => { return s.m_params[0].shouldDisableContactPoolDynamicAllocation; }, (s,p,l,v) => { s.m_params[0].shouldDisableContactPoolDynamicAllocation = v; } ), new ParameterDefn("ShouldForceUpdateAllAabbs", "Enable to recomputer AABBs every simulator step", diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs index 4e05df6..86fc9d2 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs @@ -158,6 +158,7 @@ public struct ConfigurationParameters public float avatarContactProcessingThreshold; public float maxPersistantManifoldPoolSize; + public float maxCollisionAlgorithmPoolSize; public float shouldDisableContactPoolDynamicAllocation; public float shouldForceUpdateAllAabbs; public float shouldRandomizeSolverOrder; -- cgit v1.1 From 5ab151c2d69277b8c528b8ebe94d2b0d2312a2fc Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 8 Aug 2012 13:48:49 -0700 Subject: BulletSim: add avatar code to keep avatars from ending up trapped under the terrain --- .../Region/Physics/BulletSPlugin/BSCharacter.cs | 56 ++++++++++------------ OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs | 13 ++--- OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 4 +- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 26 +++++----- 4 files changed, 46 insertions(+), 53 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index d4f5c63..8149a53 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -205,6 +205,8 @@ public class BSCharacter : PhysicsActor } set { _position = value; + PositionSanityCheck(); + _scene.TaintedObject(delegate() { DetailLog("{0},SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); @@ -212,6 +214,28 @@ public class BSCharacter : PhysicsActor }); } } + + // Check that the current position is sane and, if not, modify the position to make it so. + // Check for being below terrain and being out of bounds. + // Returns 'true' of the position was made sane by some action. + private bool PositionSanityCheck() + { + bool ret = false; + + // If below the ground, move the avatar up + float terrainHeight = Scene.GetTerrainHeightAtXYZ(_position); + if (_position.Z < terrainHeight) + { + DetailLog("{0},PositionAdjustUnderGround,call,pos={1},orient={2}", LocalID, _position, _orientation); + _position.Z = terrainHeight + 2.0f; + ret = true; + } + + // TODO: check for out of bounds + + return ret; + } + public override float Mass { get { return _mass; @@ -456,42 +480,12 @@ public class BSCharacter : PhysicsActor // the world that things have changed. public void UpdateProperties(EntityProperties entprop) { - /* - bool changed = false; - // we assign to the local variables so the normal set action does not happen - if (_position != entprop.Position) { - _position = entprop.Position; - changed = true; - } - if (_orientation != entprop.Rotation) { - _orientation = entprop.Rotation; - changed = true; - } - if (_velocity != entprop.Velocity) { - _velocity = entprop.Velocity; - changed = true; - } - if (_acceleration != entprop.Acceleration) { - _acceleration = entprop.Acceleration; - changed = true; - } - if (_rotationalVelocity != entprop.RotationalVelocity) { - _rotationalVelocity = entprop.RotationalVelocity; - changed = true; - } - if (changed) { - // m_log.DebugFormat("{0}: UpdateProperties: id={1}, c={2}, pos={3}, rot={4}", LogHeader, LocalID, changed, _position, _orientation); - // Avatar movement is not done by generating this event. There is code in the heartbeat - // loop that updates avatars. - // base.RequestPhysicsterseUpdate(); - } - */ _position = entprop.Position; _orientation = entprop.Rotation; _velocity = entprop.Velocity; _acceleration = entprop.Acceleration; _rotationalVelocity = entprop.RotationalVelocity; - // Avatars don't report theirr changes the usual way. Changes are checked for in the heartbeat loop. + // Avatars don't report their changes the usual way. Changes are checked for in the heartbeat loop. // base.RequestPhysicsterseUpdate(); } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs index 6f8430c..d19c4b8 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs @@ -296,13 +296,13 @@ public class BSLinkset DetailLog("{0},LinkAChildToMe,taint,root={1},child={2}", m_linksetRoot.LocalID, m_linksetRoot.LocalID, childPrim.LocalID); BSConstraint constrain = m_scene.Constraints.CreateConstraint( m_scene.World, m_linksetRoot.Body, childPrim.Body, - // childRelativePosition, - // childRelativeRotation, + childRelativePosition, + childRelativeRotation, OMV.Vector3.Zero, - OMV.Quaternion.Identity, - OMV.Vector3.Zero, - OMV.Quaternion.Identity + -childRelativeRotation ); + + // zero linear and angular limits makes the objects unable to move in relation to each other constrain.SetLinearLimits(OMV.Vector3.Zero, OMV.Vector3.Zero); constrain.SetAngularLimits(OMV.Vector3.Zero, OMV.Vector3.Zero); @@ -339,7 +339,8 @@ public class BSLinkset // Invoke the detailed logger and output something if it's enabled. private void DebugLog(string msg, params Object[] args) { - m_scene.Logger.DebugFormat(msg, args); + if (m_scene.ShouldDebugLog) + m_scene.Logger.DebugFormat(msg, args); } // Invoke the detailed logger and output something if it's enabled. diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 11868bc..98b69b1 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -42,7 +42,7 @@ public sealed class BSPrim : PhysicsActor private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly string LogHeader = "[BULLETS PRIM]"; - private void DebugLog(string mm, params Object[] xx) { if (_scene.shouldDebugLog) m_log.DebugFormat(mm, xx); } + private void DebugLog(string mm, params Object[] xx) { if (_scene.ShouldDebugLog) m_log.DebugFormat(mm, xx); } private IMesh _mesh; private PrimitiveBaseShape _pbs; @@ -1338,7 +1338,6 @@ public sealed class BSPrim : PhysicsActor base.RequestPhysicsterseUpdate(); } - /* else { // For debugging, we also report the movement of children @@ -1346,7 +1345,6 @@ public sealed class BSPrim : PhysicsActor LocalID, entprop.Position, entprop.Rotation, entprop.Velocity, entprop.Acceleration, entprop.RotationalVelocity); } - */ } // I've collided with something diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 0e257b6..117086a 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -73,7 +73,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); private static readonly string LogHeader = "[BULLETS SCENE]"; - public void DebugLog(string mm, params Object[] xx) { if (shouldDebugLog) m_log.DebugFormat(mm, xx); } + public void DebugLog(string mm, params Object[] xx) { if (ShouldDebugLog) m_log.DebugFormat(mm, xx); } public string BulletSimVersion = "?"; @@ -169,7 +169,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters ConfigurationParameters[] m_params; GCHandle m_paramsHandle; - public bool shouldDebugLog { get; private set; } + public bool ShouldDebugLog { get; private set; } private BulletSimAPI.DebugLogCallback m_DebugLogCallbackHandle; @@ -812,12 +812,12 @@ public class BSScene : PhysicsScene, IPhysicsParameters private struct ParameterDefn { - public string name; - public string desc; - public float defaultValue; - public ParamUser userParam; - public ParamGet getter; - public ParamSet setter; + public string name; // string name of the parameter + public string desc; // a short description of what the parameter means + public float defaultValue; // default value if not specified anywhere else + public ParamUser userParam; // get the value from the configuration file + public ParamGet getter; // return the current value stored for this parameter + public ParamSet setter; // set the current value for this parameter public ParameterDefn(string n, string d, float v, ParamUser u, ParamGet g, ParamSet s) { name = n; @@ -834,7 +834,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters // To add a new externally referencable/settable parameter, add the paramter storage // location somewhere in the program and make an entry in this table with the // getters and setters. - // To add a new variable, it is easiest to find an existing definition and copy it. + // It is easiest to find an existing definition and copy it. // Parameter values are floats. Booleans are converted to a floating value. // // A ParameterDefn() takes the following parameters: @@ -870,7 +870,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters (s) => { return (float)s.m_meshLOD; }, (s,p,l,v) => { s.m_meshLOD = (int)v; } ), new ParameterDefn("SculptLOD", "Level of detail to render sculpties (32, 16, 8 or 4. 32=most detailed)", - 32, + 32f, (s,cf,p,v) => { s.m_sculptLOD = cf.GetInt(p, (int)v); }, (s) => { return (float)s.m_sculptLOD; }, (s,p,l,v) => { s.m_sculptLOD = (int)v; } ), @@ -1106,9 +1106,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters (s,p,l,v) => { s.m_detailedStatsStep = (int)v; } ), new ParameterDefn("ShouldDebugLog", "Enables detailed DEBUG log statements", ConfigurationParameters.numericFalse, - (s,cf,p,v) => { s.shouldDebugLog = cf.GetBoolean(p, s.BoolNumeric(v)); }, - (s) => { return s.NumericBool(s.shouldDebugLog); }, - (s,p,l,v) => { s.shouldDebugLog = s.BoolNumeric(v); } ), + (s,cf,p,v) => { s.ShouldDebugLog = cf.GetBoolean(p, s.BoolNumeric(v)); }, + (s) => { return s.NumericBool(s.ShouldDebugLog); }, + (s,p,l,v) => { s.ShouldDebugLog = s.BoolNumeric(v); } ), }; -- cgit v1.1 From 38e79b80a87d213748d55d66e8b72021999d3945 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 9 Aug 2012 15:01:05 -0700 Subject: BulletSim: separate out the constraints by type. The linksets use 6dof constraint but eventually others will be exposed so future features can use all the Bullet capabilities. Force children to generate a position update when unlinked. --- .../Physics/BulletSPlugin/BS6DofConstraint.cs | 80 ++++++++++++++++++++++ .../Region/Physics/BulletSPlugin/BSConstraint.cs | 60 +++------------- .../BulletSPlugin/BSConstraintCollection.cs | 10 --- OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs | 38 +++++++--- OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 15 ++-- .../Region/Physics/BulletSPlugin/BulletSimAPI.cs | 37 +++++----- 6 files changed, 146 insertions(+), 94 deletions(-) create mode 100755 OpenSim/Region/Physics/BulletSPlugin/BS6DofConstraint.cs (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BS6DofConstraint.cs b/OpenSim/Region/Physics/BulletSPlugin/BS6DofConstraint.cs new file mode 100755 index 0000000..72df6b9 --- /dev/null +++ b/OpenSim/Region/Physics/BulletSPlugin/BS6DofConstraint.cs @@ -0,0 +1,80 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyrightD + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; + +namespace OpenSim.Region.Physics.BulletSPlugin +{ + +public class BS6DofConstraint : BSConstraint +{ + // Create a btGeneric6DofConstraint + public BS6DofConstraint(BulletSim world, BulletBody obj1, BulletBody obj2, + Vector3 frame1, Quaternion frame1rot, + Vector3 frame2, Quaternion frame2rot ) + { + m_world = world; + m_body1 = obj1; + m_body2 = obj2; + m_constraint = new BulletConstraint( + BulletSimAPI.Create6DofConstraint2(m_world.Ptr, m_body1.Ptr, m_body2.Ptr, + frame1, frame1rot, + frame2, frame2rot, + true /*useLinearReferenceFrameA*/, true /*disableCollisionsBetweenLinkedBodies*/)); + m_enabled = true; + } + + public bool SetCFMAndERP(float cfm, float erp) + { + bool ret = true; + BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_STOP_CFM, cfm, ConstraintParamAxis.AXIS_ALL); + BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_STOP_ERP, erp, ConstraintParamAxis.AXIS_ALL); + BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_CFM, cfm, ConstraintParamAxis.AXIS_ALL); + return ret; + } + + public bool UseFrameOffset(bool useOffset) + { + bool ret = false; + float onOff = useOffset ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse; + if (m_enabled) + ret = BulletSimAPI.UseFrameOffset2(m_constraint.Ptr, onOff); + return ret; + } + + public bool TranslationalLimitMotor(bool enable, float targetVelocity, float maxMotorForce) + { + bool ret = false; + float onOff = enable ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse; + if (m_enabled) + ret = BulletSimAPI.TranslationalLimitMotor2(m_constraint.Ptr, onOff, targetVelocity, maxMotorForce); + return ret; + } +} +} diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs index ea3093a..a17efea 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs @@ -32,30 +32,19 @@ using OpenMetaverse; namespace OpenSim.Region.Physics.BulletSPlugin { -public class BSConstraint : IDisposable +public abstract class BSConstraint : IDisposable { - private BulletSim m_world; - private BulletBody m_body1; - private BulletBody m_body2; - private BulletConstraint m_constraint; - private bool m_enabled = false; + protected BulletSim m_world; + protected BulletBody m_body1; + protected BulletBody m_body2; + protected BulletConstraint m_constraint; + protected bool m_enabled = false; - public BSConstraint(BulletSim world, BulletBody obj1, BulletBody obj2, - Vector3 frame1, Quaternion frame1rot, - Vector3 frame2, Quaternion frame2rot - ) + public BSConstraint() { - m_world = world; - m_body1 = obj1; - m_body2 = obj2; - m_constraint = new BulletConstraint(BulletSimAPI.CreateConstraint2(m_world.Ptr, m_body1.Ptr, m_body2.Ptr, - frame1, frame1rot, - frame2, frame2rot, - true /*useLinearReferenceFrameA*/, true /*disableCollisionsBetweenLinkedBodies*/)); - m_enabled = true; } - public void Dispose() + public virtual void Dispose() { if (m_enabled) { @@ -68,7 +57,7 @@ public class BSConstraint : IDisposable public BulletBody Body1 { get { return m_body1; } } public BulletBody Body2 { get { return m_body2; } } - public bool SetLinearLimits(Vector3 low, Vector3 high) + public virtual bool SetLinearLimits(Vector3 low, Vector3 high) { bool ret = false; if (m_enabled) @@ -76,7 +65,7 @@ public class BSConstraint : IDisposable return ret; } - public bool SetAngularLimits(Vector3 low, Vector3 high) + public virtual bool SetAngularLimits(Vector3 low, Vector3 high) { bool ret = false; if (m_enabled) @@ -84,34 +73,7 @@ public class BSConstraint : IDisposable return ret; } - public bool SetCFMAndERP(float cfm, float erp) - { - bool ret = true; - BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_STOP_CFM, cfm, ConstraintParamAxis.AXIS_ALL); - BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_STOP_ERP, erp, ConstraintParamAxis.AXIS_ALL); - BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_CFM, cfm, ConstraintParamAxis.AXIS_ALL); - return ret; - } - - public bool UseFrameOffset(bool useOffset) - { - bool ret = false; - float onOff = useOffset ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse; - if (m_enabled) - ret = BulletSimAPI.UseFrameOffset2(m_constraint.Ptr, onOff); - return ret; - } - - public bool TranslationalLimitMotor(bool enable, float targetVelocity, float maxMotorForce) - { - bool ret = false; - float onOff = enable ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse; - if (m_enabled) - ret = BulletSimAPI.TranslationalLimitMotor2(m_constraint.Ptr, onOff, targetVelocity, maxMotorForce); - return ret; - } - - public bool CalculateTransforms() + public virtual bool CalculateTransforms() { bool ret = false; if (m_enabled) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs index c88e645..397045a 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs @@ -63,16 +63,6 @@ public class BSConstraintCollection : IDisposable m_constraints.Clear(); } - public BSConstraint CreateConstraint(BulletSim world, BulletBody obj1, BulletBody obj2, - Vector3 frame1, Quaternion frame1rot, - Vector3 frame2, Quaternion frame2rot) - { - BSConstraint constrain = new BSConstraint(world, obj1, obj2, frame1, frame1rot, frame2, frame2rot); - - this.AddConstraint(constrain); - return constrain; - } - public bool AddConstraint(BSConstraint cons) { // There is only one constraint between any bodies. Remove any old just to make sure. diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs index d19c4b8..e265d6d 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs @@ -101,7 +101,7 @@ public class BSLinkset { // Note that we don't do a foreach because the remove routine // takes it out of the list. - RemoveChildFromLinkset(m_children[0]); + RemoveChildFromOtherLinkset(m_children[0]); } m_children.Clear(); // just to make sure } @@ -124,6 +124,7 @@ public class BSLinkset lock (m_linksetActivityLock) { + // The body pointer is refetched in case anything has moved. System.IntPtr aPtr = BulletSimAPI.GetBodyHandle2(m_scene.World.Ptr, m_linksetRoot.LocalID); if (aPtr == System.IntPtr.Zero) { @@ -155,7 +156,7 @@ public class BSLinkset } foreach (BSPrim bsp in toRemove) { - RemoveChildFromLinkset(bsp); + RemoveChildFromOtherLinkset(bsp); } } } @@ -208,7 +209,8 @@ public class BSLinkset com += bp.Position * bp.MassRaw; totalMass += bp.MassRaw; } - com /= totalMass; + if (totalMass != 0f) + com /= totalMass; return com; } @@ -221,7 +223,7 @@ public class BSLinkset { com += bp.Position * bp.MassRaw; } - com /= m_children.Count + 1; + com /= (m_children.Count + 1); return com; } @@ -237,13 +239,24 @@ public class BSLinkset m_scene.TaintedObject(delegate() { DebugLog("{0}: AddChildToLinkset: adding child {1} to {2}", LogHeader, child.LocalID, m_linksetRoot.LocalID); - DetailLog("{0},AddChildToLinkset,child={1}", m_linksetRoot.LocalID, pchild.LocalID); + DetailLog("{0},AddChildToLinkset,taint,child={1}", m_linksetRoot.LocalID, pchild.LocalID); PhysicallyLinkAChildToRoot(pchild); // build the physical binding between me and the child }); } return; } + // Forcefully removing a child from a linkset. + // This is not being called by the child so we have to make sure the child doesn't think + // it's still connected to the linkset. + // Normal OpenSimulator operation will never do this because other SceneObjectPart information + // has to be updated also (like pointer to prim's parent). + public void RemoveChildFromOtherLinkset(BSPrim pchild) + { + pchild.Linkset = new BSLinkset(m_scene, pchild); + RemoveChildFromLinkset(pchild); + } + // I am the root of a linkset and one of my children is being removed. // Safe to call even if the child is not really in my linkset. public void RemoveChildFromLinkset(BSPrim pchild) @@ -255,7 +268,7 @@ public class BSLinkset m_scene.TaintedObject(delegate() { DebugLog("{0}: RemoveChildFromLinkset: Removing constraint to {1}", LogHeader, child.LocalID); - DetailLog("{0},RemoveChildFromLinkset,child={1}", m_linksetRoot.LocalID, pchild.LocalID); + DetailLog("{0},RemoveChildFromLinkset,taint,child={1}", m_linksetRoot.LocalID, pchild.LocalID); if (m_children.Count == 0) { @@ -294,13 +307,14 @@ public class BSLinkset // http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4818 // DebugLog("{0}: CreateLinkset: Adding a constraint between root prim {1} and child prim {2}", LogHeader, LocalID, childPrim.LocalID); DetailLog("{0},LinkAChildToMe,taint,root={1},child={2}", m_linksetRoot.LocalID, m_linksetRoot.LocalID, childPrim.LocalID); - BSConstraint constrain = m_scene.Constraints.CreateConstraint( + BS6DofConstraint constrain = new BS6DofConstraint( m_scene.World, m_linksetRoot.Body, childPrim.Body, childRelativePosition, childRelativeRotation, OMV.Vector3.Zero, -childRelativeRotation ); + m_scene.Constraints.AddConstraint(constrain); // zero linear and angular limits makes the objects unable to move in relation to each other constrain.SetLinearLimits(OMV.Vector3.Zero, OMV.Vector3.Zero); @@ -319,11 +333,13 @@ public class BSLinkset // Called at taint time! private void PhysicallyUnlinkAChildFromRoot(BSPrim childPrim) { - DebugLog("{0}: PhysicallyUnlinkAChildFromRoot: RemoveConstraint between root prim {1} and child prim {2}", - LogHeader, m_linksetRoot.LocalID, childPrim.LocalID); + // DebugLog("{0}: PhysicallyUnlinkAChildFromRoot: RemoveConstraint between root prim {1} and child prim {2}", + // LogHeader, m_linksetRoot.LocalID, childPrim.LocalID); DetailLog("{0},PhysicallyUnlinkAChildFromRoot,taint,root={1},child={2}", m_linksetRoot.LocalID, m_linksetRoot.LocalID, childPrim.LocalID); - // BulletSimAPI.RemoveConstraint(_scene.WorldID, LocalID, childPrim.LocalID); + m_scene.Constraints.RemoveAndDestroyConstraint(m_linksetRoot.Body, childPrim.Body); + // Make the child refresh its location + BulletSimAPI.PushUpdate2(childPrim.Body.Ptr); } // Remove linkage between myself and any possible children I might have @@ -332,8 +348,8 @@ public class BSLinkset { // DebugLog("{0}: PhysicallyUnlinkAllChildren:", LogHeader); DetailLog("{0},PhysicallyUnlinkAllChildren,taint", m_linksetRoot.LocalID); + m_scene.Constraints.RemoveAndDestroyConstraint(m_linksetRoot.Body); - // BulletSimAPI.RemoveConstraintByID(_scene.WorldID, LocalID); } // Invoke the detailed logger and output something if it's enabled. diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 98b69b1..e0f6ed2 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -224,10 +224,12 @@ public sealed class BSPrim : PhysicsActor // link me to the specified parent public override void link(PhysicsActor obj) { BSPrim parent = obj as BSPrim; - DebugLog("{0}: link {1}/{2} to {3}", LogHeader, _avName, _localID, obj.LocalID); - DetailLog("{0},link,parent={1}", LocalID, obj.LocalID); - - _linkset = _linkset.AddMeToLinkset(this, parent); + if (parent != null) + { + DebugLog("{0}: link {1}/{2} to {3}", LogHeader, _avName, _localID, parent.LocalID); + DetailLog("{0},link,parent={1}", LocalID, parent.LocalID); + _linkset = _linkset.AddMeToLinkset(this, parent); + } return; } @@ -478,7 +480,6 @@ public sealed class BSPrim : PhysicsActor // Make gravity work if the object is physical and not selected // No locking here because only called when it is safe - // Only called at taint time so it is save to call into Bullet. private void SetObjectDynamic() { // RA: remove this for the moment. @@ -982,7 +983,7 @@ public sealed class BSPrim : PhysicsActor // m_log.DebugFormat("{0}: CreateGeom: Defaulting to sphere of size {1}", LogHeader, _size); if (forceRebuild || (_shapeType != ShapeData.PhysicsShapeType.SHAPE_SPHERE)) { - DetailLog("{0},CreateGeom,sphere", LocalID); + DetailLog("{0},CreateGeom,sphere (force={1}", LocalID, forceRebuild); _shapeType = ShapeData.PhysicsShapeType.SHAPE_SPHERE; // Bullet native objects are scaled by the Bullet engine so pass the size in _scale = _size; @@ -996,7 +997,7 @@ public sealed class BSPrim : PhysicsActor // m_log.DebugFormat("{0}: CreateGeom: Defaulting to box. lid={1}, type={2}, size={3}", LogHeader, LocalID, _shapeType, _size); if (forceRebuild || (_shapeType != ShapeData.PhysicsShapeType.SHAPE_BOX)) { - DetailLog("{0},CreateGeom,box", LocalID); + DetailLog("{0},CreateGeom,box (force={1})", LocalID, forceRebuild); _shapeType = ShapeData.PhysicsShapeType.SHAPE_BOX; _scale = _size; // TODO: do we need to check for and destroy a mesh or hull that might have been left from before? diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs index 86fc9d2..c016402 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs @@ -363,7 +363,7 @@ public static extern IntPtr GetSimHandle2(uint worldID); public static extern IntPtr GetBodyHandleWorldID2(uint worldID, uint id); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] -public static extern IntPtr GetBodyHandle2(IntPtr sim, uint id); +public static extern IntPtr GetBodyHandle2(IntPtr world, uint id); // =============================================================================== [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] @@ -372,40 +372,43 @@ public static extern IntPtr Initialize2(Vector3 maxPosition, IntPtr parms, int maxUpdates, IntPtr updateArray); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] -public static extern bool UpdateParameter2(IntPtr sim, uint localID, String parm, float value); +public static extern bool UpdateParameter2(IntPtr world, uint localID, String parm, float value); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] -public static extern void SetHeightmap2(IntPtr sim, float[] heightmap); +public static extern void SetHeightmap2(IntPtr world, float[] heightmap); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern void Shutdown2(IntPtr sim); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] -public static extern int PhysicsStep2(IntPtr sim, float timeStep, int maxSubSteps, float fixedTimeStep, +public static extern int PhysicsStep2(IntPtr world, float timeStep, int maxSubSteps, float fixedTimeStep, out int updatedEntityCount, out IntPtr updatedEntitiesPtr, out int collidersCount, out IntPtr collidersPtr); +[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] +public static extern bool PushUpdate2(IntPtr obj); + /* [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] -public static extern IntPtr CreateMesh2(IntPtr sim, int indicesCount, int* indices, int verticesCount, float* vertices ); +public static extern IntPtr CreateMesh2(IntPtr world, int indicesCount, int* indices, int verticesCount, float* vertices ); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] -public static extern bool BuildHull2(IntPtr sim, IntPtr mesh); +public static extern bool BuildHull2(IntPtr world, IntPtr mesh); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] -public static extern bool ReleaseHull2(IntPtr sim, IntPtr mesh); +public static extern bool ReleaseHull2(IntPtr world, IntPtr mesh); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] -public static extern bool DestroyMesh2(IntPtr sim, IntPtr mesh); +public static extern bool DestroyMesh2(IntPtr world, IntPtr mesh); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] -public static extern IntPtr CreateObject2(IntPtr sim, ShapeData shapeData); +public static extern IntPtr CreateObject2(IntPtr world, ShapeData shapeData); */ [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] -public static extern IntPtr CreateConstraint2(IntPtr sim, IntPtr obj1, IntPtr obj2, +public static extern IntPtr Create6DofConstraint2(IntPtr world, IntPtr obj1, IntPtr obj2, Vector3 frame1loc, Quaternion frame1rot, Vector3 frame2loc, Quaternion frame2rot, bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies); @@ -429,7 +432,13 @@ public static extern bool CalculateTransforms2(IntPtr constrain); public static extern bool SetConstraintParam2(IntPtr constrain, ConstraintParams paramIndex, float value, ConstraintParamAxis axis); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] -public static extern bool DestroyConstraint2(IntPtr sim, IntPtr constrain); +public static extern bool DestroyConstraint2(IntPtr world, IntPtr constrain); + +[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] +public static extern Vector3 AddObjectToWorld2(IntPtr world, IntPtr obj); + +[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] +public static extern Vector3 RemoveObjectFromWorld2(IntPtr world, IntPtr obj); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern Vector3 GetPosition2(IntPtr obj); @@ -510,12 +519,6 @@ public static extern bool SetMargin2(IntPtr obj, float val); public static extern bool UpdateSingleAabb2(IntPtr world, IntPtr obj); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] -public static extern bool AddObjectToWorld2(IntPtr world, IntPtr obj); - -[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] -public static extern bool RemoveObjectFromWorld2(IntPtr world, IntPtr obj); - -[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern bool DestroyObject2(IntPtr world, uint id); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] -- cgit v1.1 From 320982cae388814b8e7e9e9fe62724caa9621d90 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 9 Aug 2012 15:17:19 -0700 Subject: BulletSim: add an identifier to the TaintObject call so exceptions that happen when the taint is invoked can be debugged --- .../Region/Physics/BulletSPlugin/BSCharacter.cs | 22 +++++----- OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs | 4 +- OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 49 ++++++++++------------ OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 34 +++++++++------ 4 files changed, 57 insertions(+), 52 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 8149a53..d49a578 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -122,7 +122,7 @@ public class BSCharacter : PhysicsActor shapeData.Restitution = _scene.Params.avatarRestitution; // do actual create at taint time - _scene.TaintedObject(delegate() + _scene.TaintedObject("BSCharacter.create", delegate() { BulletSimAPI.CreateObject(parent_scene.WorldID, shapeData); @@ -138,7 +138,7 @@ public class BSCharacter : PhysicsActor public void Destroy() { // DetailLog("{0},Destroy", LocalID); - _scene.TaintedObject(delegate() + _scene.TaintedObject("BSCharacter.destroy", delegate() { BulletSimAPI.DestroyObject(_scene.WorldID, _localID); }); @@ -169,7 +169,7 @@ public class BSCharacter : PhysicsActor ComputeAvatarVolumeAndMass(); - _scene.TaintedObject(delegate() + _scene.TaintedObject("BSCharacter.setSize", delegate() { BulletSimAPI.SetObjectScaleMass(_scene.WorldID, LocalID, _scale, _mass, true); }); @@ -207,7 +207,7 @@ public class BSCharacter : PhysicsActor _position = value; PositionSanityCheck(); - _scene.TaintedObject(delegate() + _scene.TaintedObject("BSCharacter.setPosition", delegate() { DetailLog("{0},SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation); @@ -246,7 +246,7 @@ public class BSCharacter : PhysicsActor set { _force = value; // m_log.DebugFormat("{0}: Force = {1}", LogHeader, _force); - Scene.TaintedObject(delegate() + Scene.TaintedObject("BSCharacter.SetForce", delegate() { DetailLog("{0},setForce,taint,force={1}", LocalID, _force); BulletSimAPI.SetObjectForce(Scene.WorldID, LocalID, _force); @@ -273,7 +273,7 @@ public class BSCharacter : PhysicsActor set { _velocity = value; // m_log.DebugFormat("{0}: set velocity = {1}", LogHeader, _velocity); - _scene.TaintedObject(delegate() + _scene.TaintedObject("BSCharacter.setVelocity", delegate() { DetailLog("{0},setVelocity,taint,vel={1}", LocalID, _velocity); BulletSimAPI.SetObjectVelocity(_scene.WorldID, _localID, _velocity); @@ -299,7 +299,7 @@ public class BSCharacter : PhysicsActor set { _orientation = value; // m_log.DebugFormat("{0}: set orientation to {1}", LogHeader, _orientation); - _scene.TaintedObject(delegate() + _scene.TaintedObject("BSCharacter.setOrientation", delegate() { // _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID); BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation); @@ -366,7 +366,7 @@ public class BSCharacter : PhysicsActor public override float Buoyancy { get { return _buoyancy; } set { _buoyancy = value; - _scene.TaintedObject(delegate() + _scene.TaintedObject("BSCharacter.setBuoyancy", delegate() { DetailLog("{0},setBuoyancy,taint,buoy={1}", LocalID, _buoyancy); BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, LocalID, _buoyancy); @@ -413,7 +413,7 @@ public class BSCharacter : PhysicsActor _force.Y += force.Y; _force.Z += force.Z; // m_log.DebugFormat("{0}: AddForce. adding={1}, newForce={2}", LogHeader, force, _force); - _scene.TaintedObject(delegate() + _scene.TaintedObject("BSCharacter.AddForce", delegate() { DetailLog("{0},setAddForce,taint,addedForce={1}", LocalID, _force); BulletSimAPI.AddObjectForce2(Body.Ptr, _force); @@ -439,7 +439,7 @@ public class BSCharacter : PhysicsActor // make sure first collision happens _nextCollisionOkTime = Util.EnvironmentTickCount() - _subscribedEventsMs; - Scene.TaintedObject(delegate() + Scene.TaintedObject("BSCharacter.SubscribeEvents", delegate() { BulletSimAPI.AddToCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); }); @@ -449,7 +449,7 @@ public class BSCharacter : PhysicsActor public override void UnSubscribeEvents() { _subscribedEventsMs = 0; // Avatars get all their collision events - // Scene.TaintedObject(delegate() + // Scene.TaintedObject("BSCharacter.UnSubscribeEvents", delegate() // { // BulletSimAPI.RemoveFromCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); // }); diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs index e265d6d..bf262c5 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs @@ -236,7 +236,7 @@ public class BSLinkset { m_children.Add(child); - m_scene.TaintedObject(delegate() + m_scene.TaintedObject("AddChildToLinkset", delegate() { DebugLog("{0}: AddChildToLinkset: adding child {1} to {2}", LogHeader, child.LocalID, m_linksetRoot.LocalID); DetailLog("{0},AddChildToLinkset,taint,child={1}", m_linksetRoot.LocalID, pchild.LocalID); @@ -265,7 +265,7 @@ public class BSLinkset if (m_children.Remove(child)) { - m_scene.TaintedObject(delegate() + m_scene.TaintedObject("RemoveChildFromLinkset", delegate() { DebugLog("{0}: RemoveChildFromLinkset: Removing constraint to {1}", LogHeader, child.LocalID); DetailLog("{0},RemoveChildFromLinkset,taint,child={1}", m_linksetRoot.LocalID, pchild.LocalID); diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index e0f6ed2..988e03b 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -145,7 +145,7 @@ public sealed class BSPrim : PhysicsActor _vehicle = new BSDynamics(this); // add vehicleness _mass = CalculateMass(); // do the actual object creation at taint time - _scene.TaintedObject(delegate() + _scene.TaintedObject("BSPrim.create", delegate() { RecreateGeomAndObject(); @@ -166,7 +166,7 @@ public sealed class BSPrim : PhysicsActor _vehicle.ProcessTypeChange(Vehicle.TYPE_NONE); _scene.RemoveVehiclePrim(this); // just to make sure - _scene.TaintedObject(delegate() + _scene.TaintedObject("BSPrim.destroy", delegate() { // Undo any links between me and any other object _linkset = _linkset.RemoveMeFromLinkset(this); @@ -183,7 +183,7 @@ public sealed class BSPrim : PhysicsActor get { return _size; } set { _size = value; - _scene.TaintedObject(delegate() + _scene.TaintedObject("BSPrim.setSize", delegate() { _mass = CalculateMass(); // changing size changes the mass BulletSimAPI.SetObjectScaleMass(_scene.WorldID, _localID, _scale, (IsPhysical ? _mass : 0f), IsPhysical); @@ -195,7 +195,7 @@ public sealed class BSPrim : PhysicsActor public override PrimitiveBaseShape Shape { set { _pbs = value; - _scene.TaintedObject(delegate() + _scene.TaintedObject("BSPrim.setShape", delegate() { _mass = CalculateMass(); // changing the shape changes the mass RecreateGeomAndObject(); @@ -213,7 +213,7 @@ public sealed class BSPrim : PhysicsActor public override bool Selected { set { _isSelected = value; - _scene.TaintedObject(delegate() + _scene.TaintedObject("BSPrim.setSelected", delegate() { SetObjectDynamic(); }); @@ -281,7 +281,7 @@ public sealed class BSPrim : PhysicsActor set { _position = value; // TODO: what does it mean to set the position of a child prim?? Rebuild the constraint? - _scene.TaintedObject(delegate() + _scene.TaintedObject("BSPrim.setPosition", delegate() { DetailLog("{0},SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation); @@ -318,7 +318,7 @@ public sealed class BSPrim : PhysicsActor get { return _force; } set { _force = value; - _scene.TaintedObject(delegate() + _scene.TaintedObject("BSPrim.setForce", delegate() { DetailLog("{0},setForce,taint,force={1}", LocalID, _force); // BulletSimAPI.SetObjectForce(_scene.WorldID, _localID, _force); @@ -333,7 +333,7 @@ public sealed class BSPrim : PhysicsActor } set { Vehicle type = (Vehicle)value; - _scene.TaintedObject(delegate() + _scene.TaintedObject("BSPrim.setVehicleType", delegate() { DetailLog("{0},SetVehicleType,taint,type={1}", LocalID, type); _vehicle.ProcessTypeChange(type); @@ -343,12 +343,7 @@ public sealed class BSPrim : PhysicsActor } else { - _scene.TaintedObject(delegate() - { - // Tell the physics engine to clear state - BulletSimAPI.ClearForces2(this.Body.Ptr); - }); - + BulletSimAPI.ClearForces2(this.Body.Ptr); // make it so the scene will call us each tick to do vehicle things _scene.AddVehiclePrim(this); } @@ -358,28 +353,28 @@ public sealed class BSPrim : PhysicsActor } public override void VehicleFloatParam(int param, float value) { - _scene.TaintedObject(delegate() + _scene.TaintedObject("BSPrim.VehicleFloatParam", delegate() { _vehicle.ProcessFloatVehicleParam((Vehicle)param, value, _scene.LastSimulatedTimestep); }); } public override void VehicleVectorParam(int param, OMV.Vector3 value) { - _scene.TaintedObject(delegate() + _scene.TaintedObject("BSPrim.VehicleVectorParam", delegate() { _vehicle.ProcessVectorVehicleParam((Vehicle)param, value, _scene.LastSimulatedTimestep); }); } public override void VehicleRotationParam(int param, OMV.Quaternion rotation) { - _scene.TaintedObject(delegate() + _scene.TaintedObject("BSPrim.VehicleRotationParam", delegate() { _vehicle.ProcessRotationVehicleParam((Vehicle)param, rotation); }); } public override void VehicleFlags(int param, bool remove) { - _scene.TaintedObject(delegate() + _scene.TaintedObject("BSPrim.VehicleFlags", delegate() { _vehicle.ProcessVehicleFlags(param, remove); }); @@ -397,7 +392,7 @@ public sealed class BSPrim : PhysicsActor public override void SetVolumeDetect(int param) { bool newValue = (param != 0); _isVolumeDetect = newValue; - _scene.TaintedObject(delegate() + _scene.TaintedObject("BSPrim.SetVolumeDetect", delegate() { SetObjectDynamic(); }); @@ -408,7 +403,7 @@ public sealed class BSPrim : PhysicsActor get { return _velocity; } set { _velocity = value; - _scene.TaintedObject(delegate() + _scene.TaintedObject("BSPrim.setVelocity", delegate() { DetailLog("{0},SetVelocity,taint,vel={1}", LocalID, _velocity); BulletSimAPI.SetObjectVelocity(_scene.WorldID, LocalID, _velocity); @@ -442,7 +437,7 @@ public sealed class BSPrim : PhysicsActor set { _orientation = value; // TODO: what does it mean if a child in a linkset changes its orientation? Rebuild the constraint? - _scene.TaintedObject(delegate() + _scene.TaintedObject("BSPrim.setOrientation", delegate() { // _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID); DetailLog("{0},setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation); @@ -459,7 +454,7 @@ public sealed class BSPrim : PhysicsActor get { return _isPhysical; } set { _isPhysical = value; - _scene.TaintedObject(delegate() + _scene.TaintedObject("BSPrim.setIsPhysical", delegate() { SetObjectDynamic(); }); @@ -547,7 +542,7 @@ public sealed class BSPrim : PhysicsActor set { _rotationalVelocity = value; // m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity); - _scene.TaintedObject(delegate() + _scene.TaintedObject("BSPrim.setRotationalVelocity", delegate() { DetailLog("{0},SetRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity); BulletSimAPI.SetObjectAngularVelocity(_scene.WorldID, LocalID, _rotationalVelocity); @@ -564,7 +559,7 @@ public sealed class BSPrim : PhysicsActor get { return _buoyancy; } set { _buoyancy = value; - _scene.TaintedObject(delegate() + _scene.TaintedObject("BSPrim.setBuoyancy", delegate() { DetailLog("{0},SetBuoyancy,taint,buoy={1}", LocalID, _buoyancy); BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, _localID, _buoyancy); @@ -618,7 +613,7 @@ public sealed class BSPrim : PhysicsActor m_log.WarnFormat("{0}: Got a NaN force applied to a Character", LogHeader); return; } - _scene.TaintedObject(delegate() + _scene.TaintedObject("BSPrim.AddForce", delegate() { OMV.Vector3 fSum = OMV.Vector3.Zero; lock (m_accumulatedForces) @@ -648,7 +643,7 @@ public sealed class BSPrim : PhysicsActor // make sure first collision happens _nextCollisionOkTime = Util.EnvironmentTickCount() - _subscribedEventsMs; - Scene.TaintedObject(delegate() + Scene.TaintedObject("BSPrim.SubscribeEvents", delegate() { BulletSimAPI.AddToCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); }); @@ -656,7 +651,7 @@ public sealed class BSPrim : PhysicsActor } public override void UnSubscribeEvents() { _subscribedEventsMs = 0; - Scene.TaintedObject(delegate() + Scene.TaintedObject("BSPrim.UnSubscribeEvents", delegate() { BulletSimAPI.RemoveFromCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); }); diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 117086a..65a8014 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -162,7 +162,17 @@ public class BSScene : PhysicsScene, IPhysicsParameters } public delegate void TaintCallback(); - private List _taintedObjects; + private struct TaintCallbackEntry + { + public String ident; + public TaintCallback callback; + public TaintCallbackEntry(string i, TaintCallback c) + { + ident = i; + callback = c; + } + } + private List _taintedObjects; private Object _taintLock = new Object(); // A pointer to an instance if this structure is passed to the C++ code @@ -232,7 +242,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters BulletSimAPI.SetDebugLogCallback(m_DebugLogCallbackHandle); } - _taintedObjects = new List(); + _taintedObjects = new List(); mesher = meshmerizer; // The bounding box for the simulated world @@ -535,7 +545,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters public override void SetTerrain(float[] heightMap) { m_heightMap = heightMap; - this.TaintedObject(delegate() + this.TaintedObject("BSScene.SetTerrain", delegate() { BulletSimAPI.SetHeightmap(m_worldID, m_heightMap); }); @@ -727,12 +737,12 @@ public class BSScene : PhysicsScene, IPhysicsParameters // Calls to the PhysicsActors can't directly call into the physics engine // because it might be busy. We delay changes to a known time. // We rely on C#'s closure to save and restore the context for the delegate. - public void TaintedObject(TaintCallback callback) + public void TaintedObject(String ident, TaintCallback callback) { if (!m_initialized) return; lock (_taintLock) - _taintedObjects.Add(callback); + _taintedObjects.Add(new TaintCallbackEntry(ident, callback)); return; } @@ -744,22 +754,22 @@ public class BSScene : PhysicsScene, IPhysicsParameters if (_taintedObjects.Count > 0) // save allocating new list if there is nothing to process { // swizzle a new list into the list location so we can process what's there - List oldList; + List oldList; lock (_taintLock) { oldList = _taintedObjects; - _taintedObjects = new List(); + _taintedObjects = new List(); } - foreach (TaintCallback callback in oldList) + foreach (TaintCallbackEntry tcbe in oldList) { try { - callback(); + tcbe.callback(); } catch (Exception e) { - m_log.ErrorFormat("{0}: ProcessTaints: Exception: {1}", LogHeader, e); + m_log.ErrorFormat("{0}: ProcessTaints: {1}: Exception: {2}", LogHeader, tcbe.ident, e); } } oldList.Clear(); @@ -1248,7 +1258,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters List objectIDs = lIDs; string xparm = parm.ToLower(); float xval = val; - TaintedObject(delegate() { + TaintedObject("BSScene.UpdateParameterSet", delegate() { foreach (uint lID in objectIDs) { BulletSimAPI.UpdateParameter(m_worldID, lID, xparm, xval); @@ -1268,7 +1278,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters uint xlocalID = localID; string xparm = parm.ToLower(); float xval = val; - TaintedObject(delegate() { + TaintedObject("BSScene.TaintedUpdateParameter", delegate() { BulletSimAPI.UpdateParameter(m_worldID, xlocalID, xparm, xval); }); } -- cgit v1.1 From 3ca770cd2c7705d53efe11bb2a2315392b1f492a Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 10 Aug 2012 08:33:09 -0700 Subject: BulletSim: Add module names to DetailLog output. Fix some problems with linksets that were caused by checking data structures that are changed regularly from taint time code -- resulted in linksets not being unlinked properly. --- .../Region/Physics/BulletSPlugin/BSCharacter.cs | 8 ++- OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs | 57 +++++++++--------- OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 69 ++++++++++++---------- 3 files changed, 71 insertions(+), 63 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index d49a578..4f48cfb 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -248,7 +248,7 @@ public class BSCharacter : PhysicsActor // m_log.DebugFormat("{0}: Force = {1}", LogHeader, _force); Scene.TaintedObject("BSCharacter.SetForce", delegate() { - DetailLog("{0},setForce,taint,force={1}", LocalID, _force); + DetailLog("{0},BSCharacter.setForce,taint,force={1}", LocalID, _force); BulletSimAPI.SetObjectForce(Scene.WorldID, LocalID, _force); }); } @@ -275,7 +275,7 @@ public class BSCharacter : PhysicsActor // m_log.DebugFormat("{0}: set velocity = {1}", LogHeader, _velocity); _scene.TaintedObject("BSCharacter.setVelocity", delegate() { - DetailLog("{0},setVelocity,taint,vel={1}", LocalID, _velocity); + DetailLog("{0},BSCharacter.setVelocity,taint,vel={1}", LocalID, _velocity); BulletSimAPI.SetObjectVelocity(_scene.WorldID, _localID, _velocity); }); } @@ -487,6 +487,10 @@ public class BSCharacter : PhysicsActor _rotationalVelocity = entprop.RotationalVelocity; // Avatars don't report their changes the usual way. Changes are checked for in the heartbeat loop. // base.RequestPhysicsterseUpdate(); + + DetailLog("{0},BSCharacter.UpdateProperties,child,pos={1},orient={2},vel={3},accel={4},rotVel={5}", + LocalID, entprop.Position, entprop.Rotation, entprop.Velocity, + entprop.Acceleration, entprop.RotationalVelocity); } // Called by the scene when a collision with this object is reported diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs index bf262c5..f68e06e 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs @@ -40,9 +40,12 @@ public class BSLinkset public BSPrim Root { get { return m_linksetRoot; } } private BSScene m_scene; + public BSScene Scene { get { return m_scene; } } private List m_children; + public int NumberOfChildren { get { return m_children.Count; } } + // We lock the diddling of linkset classes to prevent any badness. // This locks the modification of the instances of this class. Changes // to the physical representation is done via the tainting mechenism. @@ -113,9 +116,10 @@ public class BSLinkset } // The child is down to a linkset of just itself - return new BSLinkset(m_scene, child); + return new BSLinkset(Scene, child); } + /* DEPRECATED: this is really bad in that it trys to unlink other prims. // An existing linkset had one of its members rebuilt or something. // Go through the linkset and rebuild the pointers to the bodies of the linkset members. public BSLinkset RefreshLinkset(BSPrim requestor) @@ -163,6 +167,7 @@ public class BSLinkset return ret; } + */ // Return 'true' if the passed object is the root object of this linkset @@ -229,18 +234,19 @@ public class BSLinkset } // I am the root of a linkset and a new child is being added - public void AddChildToLinkset(BSPrim pchild) + // Called while LinkActivity is locked. + public void AddChildToLinkset(BSPrim child) { - BSPrim child = pchild; if (!HasChild(child)) { m_children.Add(child); + BSPrim root = Root; // capture the root as of now m_scene.TaintedObject("AddChildToLinkset", delegate() { DebugLog("{0}: AddChildToLinkset: adding child {1} to {2}", LogHeader, child.LocalID, m_linksetRoot.LocalID); - DetailLog("{0},AddChildToLinkset,taint,child={1}", m_linksetRoot.LocalID, pchild.LocalID); - PhysicallyLinkAChildToRoot(pchild); // build the physical binding between me and the child + DetailLog("{0},AddChildToLinkset,taint,child={1}", m_linksetRoot.LocalID, child.LocalID); + PhysicallyLinkAChildToRoot(root, child); // build the physical binding between me and the child }); } return; @@ -259,26 +265,17 @@ public class BSLinkset // I am the root of a linkset and one of my children is being removed. // Safe to call even if the child is not really in my linkset. - public void RemoveChildFromLinkset(BSPrim pchild) + public void RemoveChildFromLinkset(BSPrim child) { - BSPrim child = pchild; - if (m_children.Remove(child)) { + BSPrim root = Root; // capture the root as of now m_scene.TaintedObject("RemoveChildFromLinkset", delegate() { DebugLog("{0}: RemoveChildFromLinkset: Removing constraint to {1}", LogHeader, child.LocalID); - DetailLog("{0},RemoveChildFromLinkset,taint,child={1}", m_linksetRoot.LocalID, pchild.LocalID); + DetailLog("{0},RemoveChildFromLinkset,taint,child={1}", m_linksetRoot.LocalID, child.LocalID); - if (m_children.Count == 0) - { - // if the linkset is empty, make sure all linkages have been removed - PhysicallyUnlinkAllChildrenFromRoot(); - } - else - { - PhysicallyUnlinkAChildFromRoot(pchild); - } + PhysicallyUnlinkAChildFromRoot(root, child); }); } else @@ -291,14 +288,14 @@ public class BSLinkset // Create a constraint between me (root of linkset) and the passed prim (the child). // Called at taint time! - private void PhysicallyLinkAChildToRoot(BSPrim childPrim) + private void PhysicallyLinkAChildToRoot(BSPrim rootPrim, BSPrim childPrim) { // Zero motion for children so they don't interpolate childPrim.ZeroMotion(); // relative position normalized to the root prim - OMV.Quaternion invThisOrientation = OMV.Quaternion.Inverse(m_linksetRoot.Orientation); - OMV.Vector3 childRelativePosition = (childPrim.Position - m_linksetRoot.Position) * invThisOrientation; + OMV.Quaternion invThisOrientation = OMV.Quaternion.Inverse(rootPrim.Orientation); + OMV.Vector3 childRelativePosition = (childPrim.Position - rootPrim.Position) * invThisOrientation; // relative rotation of the child to the parent OMV.Quaternion childRelativeRotation = invThisOrientation * childPrim.Orientation; @@ -306,9 +303,9 @@ public class BSLinkset // create a constraint that allows no freedom of movement between the two objects // http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4818 // DebugLog("{0}: CreateLinkset: Adding a constraint between root prim {1} and child prim {2}", LogHeader, LocalID, childPrim.LocalID); - DetailLog("{0},LinkAChildToMe,taint,root={1},child={2}", m_linksetRoot.LocalID, m_linksetRoot.LocalID, childPrim.LocalID); + DetailLog("{0},LinkAChildToMe,taint,root={1},child={2}", rootPrim.LocalID, rootPrim.LocalID, childPrim.LocalID); BS6DofConstraint constrain = new BS6DofConstraint( - m_scene.World, m_linksetRoot.Body, childPrim.Body, + m_scene.World, rootPrim.Body, childPrim.Body, childRelativePosition, childRelativeRotation, OMV.Vector3.Zero, @@ -331,25 +328,25 @@ public class BSLinkset // Remove linkage between myself and a particular child // Called at taint time! - private void PhysicallyUnlinkAChildFromRoot(BSPrim childPrim) + private void PhysicallyUnlinkAChildFromRoot(BSPrim rootPrim, BSPrim childPrim) { // DebugLog("{0}: PhysicallyUnlinkAChildFromRoot: RemoveConstraint between root prim {1} and child prim {2}", - // LogHeader, m_linksetRoot.LocalID, childPrim.LocalID); - DetailLog("{0},PhysicallyUnlinkAChildFromRoot,taint,root={1},child={2}", m_linksetRoot.LocalID, m_linksetRoot.LocalID, childPrim.LocalID); + // LogHeader, rootPrim.LocalID, childPrim.LocalID); + DetailLog("{0},PhysicallyUnlinkAChildFromRoot,taint,root={1},child={2}", rootPrim.LocalID, rootPrim.LocalID, childPrim.LocalID); - m_scene.Constraints.RemoveAndDestroyConstraint(m_linksetRoot.Body, childPrim.Body); + m_scene.Constraints.RemoveAndDestroyConstraint(rootPrim.Body, childPrim.Body); // Make the child refresh its location BulletSimAPI.PushUpdate2(childPrim.Body.Ptr); } // Remove linkage between myself and any possible children I might have // Called at taint time! - private void PhysicallyUnlinkAllChildrenFromRoot() + private void PhysicallyUnlinkAllChildrenFromRoot(BSPrim rootPrim) { // DebugLog("{0}: PhysicallyUnlinkAllChildren:", LogHeader); - DetailLog("{0},PhysicallyUnlinkAllChildren,taint", m_linksetRoot.LocalID); + DetailLog("{0},PhysicallyUnlinkAllChildren,taint", rootPrim.LocalID); - m_scene.Constraints.RemoveAndDestroyConstraint(m_linksetRoot.Body); + m_scene.Constraints.RemoveAndDestroyConstraint(rootPrim.Body); } // Invoke the detailed logger and output something if it's enabled. diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 988e03b..4193d22 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -160,16 +160,18 @@ public sealed class BSPrim : PhysicsActor public void Destroy() { // m_log.DebugFormat("{0}: Destroy, id={1}", LogHeader, LocalID); - // DetailLog("{0},Destroy", LocalID); + // DetailLog("{0},BSPrim.Destroy", LocalID); // Undo any vehicle properties _vehicle.ProcessTypeChange(Vehicle.TYPE_NONE); _scene.RemoveVehiclePrim(this); // just to make sure + // Undo any links between me and any other object + _linkset = _linkset.RemoveMeFromLinkset(this); + _scene.TaintedObject("BSPrim.destroy", delegate() { - // Undo any links between me and any other object - _linkset = _linkset.RemoveMeFromLinkset(this); + DetailLog("{0},BSPrim.Destroy,taint,", LocalID); // everything in the C# world will get garbage collected. Tell the C++ world to free stuff. BulletSimAPI.DestroyObject(_scene.WorldID, LocalID); @@ -187,7 +189,7 @@ public sealed class BSPrim : PhysicsActor { _mass = CalculateMass(); // changing size changes the mass BulletSimAPI.SetObjectScaleMass(_scene.WorldID, _localID, _scale, (IsPhysical ? _mass : 0f), IsPhysical); - // DetailLog("{0}: setSize: size={1}, mass={2}, physical={3}", LocalID, _size, _mass, IsPhysical); + // DetailLog("{0}: BSPrim.setSize: size={1}, mass={2}, physical={3}", LocalID, _size, _mass, IsPhysical); RecreateGeomAndObject(); }); } @@ -227,7 +229,7 @@ public sealed class BSPrim : PhysicsActor if (parent != null) { DebugLog("{0}: link {1}/{2} to {3}", LogHeader, _avName, _localID, parent.LocalID); - DetailLog("{0},link,parent={1}", LocalID, parent.LocalID); + DetailLog("{0},BSPrim.link,parent={1}", LocalID, parent.LocalID); _linkset = _linkset.AddMeToLinkset(this, parent); } return; @@ -239,9 +241,14 @@ public sealed class BSPrim : PhysicsActor // Race condition here: if link() and delink() in same simulation tick, the delink will not happen DebugLog("{0}: delink {1}/{2}. Parent={3}", LogHeader, _avName, _localID, _linkset.Root._avName+"/"+_linkset.Root.LocalID.ToString()); - DetailLog("{0},delink,parent={1}", LocalID, _linkset.Root.LocalID.ToString()); - _linkset.RemoveMeFromLinkset(this); + BSPrim parentBefore = _linkset.Root; + int childrenBefore = _linkset.NumberOfChildren; + + _linkset = _linkset.RemoveMeFromLinkset(this); + + DetailLog("{0},BSPrim.delink,parentBefore={1},childrenBefore={2},parentAfter={3},childrenAfter={4}, ", + LocalID, parentBefore.LocalID, childrenBefore, _linkset.Root.LocalID, _linkset.NumberOfChildren); return; } @@ -264,7 +271,7 @@ public sealed class BSPrim : PhysicsActor public override void LockAngularMotion(OMV.Vector3 axis) { - DetailLog("{0},LockAngularMotion,call,axis={1}", LocalID, axis); + DetailLog("{0},BSPrim.LockAngularMotion,call,axis={1}", LocalID, axis); return; } @@ -283,7 +290,7 @@ public sealed class BSPrim : PhysicsActor // TODO: what does it mean to set the position of a child prim?? Rebuild the constraint? _scene.TaintedObject("BSPrim.setPosition", delegate() { - DetailLog("{0},SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); + DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation); }); } @@ -320,7 +327,7 @@ public sealed class BSPrim : PhysicsActor _force = value; _scene.TaintedObject("BSPrim.setForce", delegate() { - DetailLog("{0},setForce,taint,force={1}", LocalID, _force); + DetailLog("{0},BSPrim.setForce,taint,force={1}", LocalID, _force); // BulletSimAPI.SetObjectForce(_scene.WorldID, _localID, _force); BulletSimAPI.SetObjectForce2(Body.Ptr, _force); }); @@ -335,7 +342,7 @@ public sealed class BSPrim : PhysicsActor Vehicle type = (Vehicle)value; _scene.TaintedObject("BSPrim.setVehicleType", delegate() { - DetailLog("{0},SetVehicleType,taint,type={1}", LocalID, type); + DetailLog("{0},BSPrim.SetVehicleType,taint,type={1}", LocalID, type); _vehicle.ProcessTypeChange(type); if (type == Vehicle.TYPE_NONE) { @@ -405,7 +412,7 @@ public sealed class BSPrim : PhysicsActor _velocity = value; _scene.TaintedObject("BSPrim.setVelocity", delegate() { - DetailLog("{0},SetVelocity,taint,vel={1}", LocalID, _velocity); + DetailLog("{0},BSPrim.SetVelocity,taint,vel={1}", LocalID, _velocity); BulletSimAPI.SetObjectVelocity(_scene.WorldID, LocalID, _velocity); }); } @@ -413,7 +420,7 @@ public sealed class BSPrim : PhysicsActor public override OMV.Vector3 Torque { get { return _torque; } set { _torque = value; - DetailLog("{0},SetTorque,call,torque={1}", LocalID, _torque); + DetailLog("{0},BSPrim.SetTorque,call,torque={1}", LocalID, _torque); } } public override float CollisionScore { @@ -440,7 +447,7 @@ public sealed class BSPrim : PhysicsActor _scene.TaintedObject("BSPrim.setOrientation", delegate() { // _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID); - DetailLog("{0},setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation); + DetailLog("{0},BSPrim.setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation); BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation); }); } @@ -486,7 +493,7 @@ public sealed class BSPrim : PhysicsActor // Bullet wants static objects to have a mass of zero float mass = IsStatic ? 0f : _mass; - DetailLog("{0},SetObjectDynamic,taint,static={1},solid={2},mass={3}", LocalID, IsStatic, IsSolid, mass); + DetailLog("{0},BSPrim.SetObjectDynamic,taint,static={1},solid={2},mass={3}", LocalID, IsStatic, IsSolid, mass); BulletSimAPI.SetObjectProperties(_scene.WorldID, LocalID, IsStatic, IsSolid, SubscribedEvents(), mass); } @@ -544,7 +551,7 @@ public sealed class BSPrim : PhysicsActor // m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity); _scene.TaintedObject("BSPrim.setRotationalVelocity", delegate() { - DetailLog("{0},SetRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity); + DetailLog("{0},BSPrim.SetRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity); BulletSimAPI.SetObjectAngularVelocity(_scene.WorldID, LocalID, _rotationalVelocity); }); } @@ -561,7 +568,7 @@ public sealed class BSPrim : PhysicsActor _buoyancy = value; _scene.TaintedObject("BSPrim.setBuoyancy", delegate() { - DetailLog("{0},SetBuoyancy,taint,buoy={1}", LocalID, _buoyancy); + DetailLog("{0},BSPrim.SetBuoyancy,taint,buoy={1}", LocalID, _buoyancy); BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, _localID, _buoyancy); }); } @@ -624,17 +631,17 @@ public sealed class BSPrim : PhysicsActor } m_accumulatedForces.Clear(); } - DetailLog("{0},AddObjectForce,taint,force={1}", LocalID, _force); + DetailLog("{0},BSPrim.AddObjectForce,taint,force={1}", LocalID, _force); BulletSimAPI.AddObjectForce2(Body.Ptr, fSum); }); } public override void AddAngularForce(OMV.Vector3 force, bool pushforce) { - DetailLog("{0},AddAngularForce,call,angForce={1},push={2}", LocalID, force, pushforce); + DetailLog("{0},BSPrim.AddAngularForce,call,angForce={1},push={2}", LocalID, force, pushforce); // m_log.DebugFormat("{0}: AddAngularForce. f={1}, push={2}", LogHeader, force, pushforce); } public override void SetMomentum(OMV.Vector3 momentum) { - DetailLog("{0},SetMomentum,call,mom={1}", LocalID, momentum); + DetailLog("{0},BSPrim.SetMomentum,call,mom={1}", LocalID, momentum); } public override void SubscribeEvents(int ms) { _subscribedEventsMs = ms; @@ -978,7 +985,7 @@ public sealed class BSPrim : PhysicsActor // m_log.DebugFormat("{0}: CreateGeom: Defaulting to sphere of size {1}", LogHeader, _size); if (forceRebuild || (_shapeType != ShapeData.PhysicsShapeType.SHAPE_SPHERE)) { - DetailLog("{0},CreateGeom,sphere (force={1}", LocalID, forceRebuild); + DetailLog("{0},BSPrim.CreateGeom,sphere (force={1}", LocalID, forceRebuild); _shapeType = ShapeData.PhysicsShapeType.SHAPE_SPHERE; // Bullet native objects are scaled by the Bullet engine so pass the size in _scale = _size; @@ -992,7 +999,7 @@ public sealed class BSPrim : PhysicsActor // m_log.DebugFormat("{0}: CreateGeom: Defaulting to box. lid={1}, type={2}, size={3}", LogHeader, LocalID, _shapeType, _size); if (forceRebuild || (_shapeType != ShapeData.PhysicsShapeType.SHAPE_BOX)) { - DetailLog("{0},CreateGeom,box (force={1})", LocalID, forceRebuild); + DetailLog("{0},BSPrim.CreateGeom,box (force={1})", LocalID, forceRebuild); _shapeType = ShapeData.PhysicsShapeType.SHAPE_BOX; _scale = _size; // TODO: do we need to check for and destroy a mesh or hull that might have been left from before? @@ -1035,12 +1042,12 @@ public sealed class BSPrim : PhysicsActor // if this new shape is the same as last time, don't recreate the mesh if (_meshKey == newMeshKey) return; - DetailLog("{0},CreateGeomMesh,create,key={1}", LocalID, newMeshKey); + DetailLog("{0},BSPrim.CreateGeomMesh,create,key={1}", LocalID, newMeshKey); // Since we're recreating new, get rid of any previously generated shape if (_meshKey != 0) { // m_log.DebugFormat("{0}: CreateGeom: deleting old mesh. lID={1}, Key={2}", LogHeader, _localID, _meshKey); - DetailLog("{0},CreateGeomMesh,deleteOld,key={1}", LocalID, _meshKey); + DetailLog("{0},BSPrim.CreateGeomMesh,deleteOld,key={1}", LocalID, _meshKey); BulletSimAPI.DestroyMesh(_scene.WorldID, _meshKey); _mesh = null; _meshKey = 0; @@ -1070,7 +1077,7 @@ public sealed class BSPrim : PhysicsActor _shapeType = ShapeData.PhysicsShapeType.SHAPE_MESH; // meshes are already scaled by the meshmerizer _scale = new OMV.Vector3(1f, 1f, 1f); - DetailLog("{0},CreateGeomMesh,done", LocalID); + DetailLog("{0},BSPrim.CreateGeomMesh,done", LocalID); return; } @@ -1084,17 +1091,17 @@ public sealed class BSPrim : PhysicsActor // if the hull hasn't changed, don't rebuild it if (newHullKey == _hullKey) return; - DetailLog("{0},CreateGeomHull,create,key={1}", LocalID, _meshKey); + DetailLog("{0},BSPrim.CreateGeomHull,create,key={1}", LocalID, _meshKey); // Since we're recreating new, get rid of any previously generated shape if (_hullKey != 0) { // m_log.DebugFormat("{0}: CreateGeom: deleting old hull. Key={1}", LogHeader, _hullKey); - DetailLog("{0},CreateGeomHull,deleteOldHull,key={1}", LocalID, _meshKey); + DetailLog("{0},BSPrim.CreateGeomHull,deleteOldHull,key={1}", LocalID, _meshKey); BulletSimAPI.DestroyHull(_scene.WorldID, _hullKey); _hullKey = 0; _hulls.Clear(); - DetailLog("{0},CreateGeomHull,deleteOldMesh,key={1}", LocalID, _meshKey); + DetailLog("{0},BSPrim.CreateGeomHull,deleteOldMesh,key={1}", LocalID, _meshKey); BulletSimAPI.DestroyMesh(_scene.WorldID, _meshKey); _mesh = null; // the mesh cannot match either _meshKey = 0; @@ -1191,7 +1198,7 @@ public sealed class BSPrim : PhysicsActor _shapeType = ShapeData.PhysicsShapeType.SHAPE_HULL; // meshes are already scaled by the meshmerizer _scale = new OMV.Vector3(1f, 1f, 1f); - DetailLog("{0},CreateGeomHull,done", LocalID); + DetailLog("{0},BSPrim.CreateGeomHull,done", LocalID); return; } @@ -1329,7 +1336,7 @@ public sealed class BSPrim : PhysicsActor // m_log.DebugFormat("{0}: RequestTerseUpdate. id={1}, ch={2}, pos={3}, rot={4}, vel={5}, acc={6}, rvel={7}", // LogHeader, LocalID, changed, _position, _orientation, _velocity, _acceleration, _rotationalVelocity); - DetailLog("{0},UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}", + DetailLog("{0},BSPrim.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}", LocalID, _position, _orientation, _velocity, _acceleration, _rotationalVelocity); base.RequestPhysicsterseUpdate(); @@ -1337,7 +1344,7 @@ public sealed class BSPrim : PhysicsActor else { // For debugging, we also report the movement of children - DetailLog("{0},UpdateProperties,child,pos={1},orient={2},vel={3},accel={4},rotVel={5}", + DetailLog("{0},BSPrim.BSPrim.UpdateProperties,child,pos={1},orient={2},vel={3},accel={4},rotVel={5}", LocalID, entprop.Position, entprop.Rotation, entprop.Velocity, entprop.Acceleration, entprop.RotationalVelocity); } -- cgit v1.1 From 0c7ce4fc98d4be185d5a5d83d4cc1c596b5cb1d3 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 10 Aug 2012 16:22:44 -0700 Subject: BulletSim: many, many detailed logging messages for physical linkset debugging. Linkset bugs fixed where accounting of children would get lost. Moved scene based vehicle tracking logic from prim to the scene. Added GetCollisionFlags2 method to BulletSimAPI. Updated DLLs and SOs. --- .../Region/Physics/BulletSPlugin/BSCharacter.cs | 2 +- .../Region/Physics/BulletSPlugin/BSConstraint.cs | 4 +- .../BulletSPlugin/BSConstraintCollection.cs | 8 ++- OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs | 14 +++--- OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 58 ++++++++++++---------- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 27 ++++++++-- .../Region/Physics/BulletSPlugin/BulletSimAPI.cs | 9 +++- 7 files changed, 78 insertions(+), 44 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 4f48cfb..f164afe 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -488,7 +488,7 @@ public class BSCharacter : PhysicsActor // Avatars don't report their changes the usual way. Changes are checked for in the heartbeat loop. // base.RequestPhysicsterseUpdate(); - DetailLog("{0},BSCharacter.UpdateProperties,child,pos={1},orient={2},vel={3},accel={4},rotVel={5}", + DetailLog("{0},BSCharacter.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}", LocalID, entprop.Position, entprop.Rotation, entprop.Velocity, entprop.Acceleration, entprop.RotationalVelocity); } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs index a17efea..da26b72 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs @@ -49,7 +49,9 @@ public abstract class BSConstraint : IDisposable if (m_enabled) { // BulletSimAPI.RemoveConstraint(m_world.ID, m_body1.ID, m_body2.ID); - BulletSimAPI.DestroyConstraint2(m_world.Ptr, m_constraint.Ptr); + bool success = BulletSimAPI.DestroyConstraint2(m_world.Ptr, m_constraint.Ptr); + m_world.scene.DetailLog("{0},BSConstraint.Dispose,taint,body1={1},body2={2},success={3}", BSScene.DetailLogZero, m_body1.ID, m_body2.ID, success); + m_constraint.Ptr = System.IntPtr.Zero; m_enabled = false; } } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs index 397045a..3df2ddc 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs @@ -68,6 +68,8 @@ public class BSConstraintCollection : IDisposable // There is only one constraint between any bodies. Remove any old just to make sure. RemoveAndDestroyConstraint(cons.Body1, cons.Body2); + m_world.scene.DetailLog("{0},BSConstraintCollection.AddConstraint,call,body1={1},body2={2}", BSScene.DetailLogZero, cons.Body1.ID, cons.Body2.ID); + m_constraints.Add(cons); return true; @@ -108,6 +110,7 @@ public class BSConstraintCollection : IDisposable if (this.TryGetConstraint(body1, body2, out constrain)) { + m_world.scene.DetailLog("{0},BSConstraintCollection.RemoveAndDestroyConstraint,taint,body1={1},body2={2}", BSScene.DetailLogZero, body1.ID, body2.ID); // remove the constraint from our collection m_constraints.Remove(constrain); // tell the engine that all its structures need to be freed @@ -148,10 +151,11 @@ public class BSConstraintCollection : IDisposable public bool RecalculateAllConstraints() { - foreach (BSConstraint constrain in m_constraints) + ForEachConstraint(delegate(BSConstraint constrain) { constrain.CalculateTransforms(); - } + return false; + }); return true; } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs index f68e06e..4a71612 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs @@ -44,8 +44,6 @@ public class BSLinkset private List m_children; - public int NumberOfChildren { get { return m_children.Count; } } - // We lock the diddling of linkset classes to prevent any badness. // This locks the modification of the instances of this class. Changes // to the physical representation is done via the tainting mechenism. @@ -83,14 +81,14 @@ public class BSLinkset // Link to a linkset where the child knows the parent. // Parent changing should not happen so do some sanity checking. - // We return the parent's linkset so the child can track it's membership. - public BSLinkset AddMeToLinkset(BSPrim child, BSPrim parent) + // We return the parent's linkset so the child can track its membership. + public BSLinkset AddMeToLinkset(BSPrim child) { lock (m_linksetActivityLock) { - parent.Linkset.AddChildToLinkset(child); + AddChildToLinkset(child); } - return parent.Linkset; + return this; } public BSLinkset RemoveMeFromLinkset(BSPrim child) @@ -176,6 +174,8 @@ public class BSLinkset return (requestor.LocalID == m_linksetRoot.LocalID); } + public int NumberOfChildren { get { return m_children.Count; } } + // Return 'true' if this linkset has any children (more than the root member) public bool HasAnyChildren { get { return (m_children.Count > 0); } } @@ -303,7 +303,7 @@ public class BSLinkset // create a constraint that allows no freedom of movement between the two objects // http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4818 // DebugLog("{0}: CreateLinkset: Adding a constraint between root prim {1} and child prim {2}", LogHeader, LocalID, childPrim.LocalID); - DetailLog("{0},LinkAChildToMe,taint,root={1},child={2}", rootPrim.LocalID, rootPrim.LocalID, childPrim.LocalID); + DetailLog("{0},PhysicallyLinkAChildToRoot,taint,root={1},child={2}", rootPrim.LocalID, rootPrim.LocalID, childPrim.LocalID); BS6DofConstraint constrain = new BS6DofConstraint( m_scene.World, rootPrim.Body, childPrim.Body, childRelativePosition, diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 4193d22..05cc822 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -138,13 +138,14 @@ public sealed class BSPrim : PhysicsActor _isPhysical = pisPhysical; _isVolumeDetect = false; _subscribedEventsMs = 0; - _friction = _scene.Params.defaultFriction; // TODO: compute based on object material - _density = _scene.Params.defaultDensity; // TODO: compute based on object material + _friction = _scene.Params.defaultFriction; // TODO: compute based on object material + _density = _scene.Params.defaultDensity; // TODO: compute based on object material _restitution = _scene.Params.defaultRestitution; _linkset = new BSLinkset(_scene, this); // a linkset of one - _vehicle = new BSDynamics(this); // add vehicleness + _vehicle = new BSDynamics(this); // add vehicleness _mass = CalculateMass(); // do the actual object creation at taint time + DetailLog("{0},BSPrim.constructor,call", LocalID); _scene.TaintedObject("BSPrim.create", delegate() { RecreateGeomAndObject(); @@ -160,19 +161,22 @@ public sealed class BSPrim : PhysicsActor public void Destroy() { // m_log.DebugFormat("{0}: Destroy, id={1}", LogHeader, LocalID); - // DetailLog("{0},BSPrim.Destroy", LocalID); - - // Undo any vehicle properties - _vehicle.ProcessTypeChange(Vehicle.TYPE_NONE); - _scene.RemoveVehiclePrim(this); // just to make sure // Undo any links between me and any other object + BSPrim parentBefore = _linkset.Root; + int childrenBefore = _linkset.NumberOfChildren; + _linkset = _linkset.RemoveMeFromLinkset(this); + DetailLog("{0},BSPrim.Destroy,call,parentBefore={1},childrenBefore={2},parentAfter={3},childrenAfter={4}", + LocalID, parentBefore.LocalID, childrenBefore, _linkset.Root.LocalID, _linkset.NumberOfChildren); + + // Undo any vehicle properties + this.VehicleType = (int)Vehicle.TYPE_NONE; + _scene.TaintedObject("BSPrim.destroy", delegate() { DetailLog("{0},BSPrim.Destroy,taint,", LocalID); - // everything in the C# world will get garbage collected. Tell the C++ world to free stuff. BulletSimAPI.DestroyObject(_scene.WorldID, LocalID); }); @@ -229,8 +233,13 @@ public sealed class BSPrim : PhysicsActor if (parent != null) { DebugLog("{0}: link {1}/{2} to {3}", LogHeader, _avName, _localID, parent.LocalID); - DetailLog("{0},BSPrim.link,parent={1}", LocalID, parent.LocalID); - _linkset = _linkset.AddMeToLinkset(this, parent); + BSPrim parentBefore = _linkset.Root; + int childrenBefore = _linkset.NumberOfChildren; + + _linkset = parent.Linkset.AddMeToLinkset(this); + + DetailLog("{0},BSPrim.link,call,parentBefore={1}, childrenBefore=={2}, parentAfter={3}, childrenAfter={4}", + LocalID, parentBefore.LocalID, childrenBefore, _linkset.Root.LocalID, _linkset.NumberOfChildren); } return; } @@ -340,21 +349,14 @@ public sealed class BSPrim : PhysicsActor } set { Vehicle type = (Vehicle)value; - _scene.TaintedObject("BSPrim.setVehicleType", delegate() + BSPrim vehiclePrim = this; + _scene.TaintedObject("setVehicleType", delegate() { - DetailLog("{0},BSPrim.SetVehicleType,taint,type={1}", LocalID, type); + // Done at taint time so we're sure the physics engine is not using the variables + // Vehicle code changes the parameters for this vehicle type. _vehicle.ProcessTypeChange(type); - if (type == Vehicle.TYPE_NONE) - { - _scene.RemoveVehiclePrim(this); - } - else - { - BulletSimAPI.ClearForces2(this.Body.Ptr); - // make it so the scene will call us each tick to do vehicle things - _scene.AddVehiclePrim(this); - } - return; + // Tell the scene about the vehicle so it will get processing each frame. + _scene.VehicleInSceneTypeChanged(this, type); }); } } @@ -493,8 +495,10 @@ public sealed class BSPrim : PhysicsActor // Bullet wants static objects to have a mass of zero float mass = IsStatic ? 0f : _mass; - DetailLog("{0},BSPrim.SetObjectDynamic,taint,static={1},solid={2},mass={3}", LocalID, IsStatic, IsSolid, mass); BulletSimAPI.SetObjectProperties(_scene.WorldID, LocalID, IsStatic, IsSolid, SubscribedEvents(), mass); + + CollisionFlags cf = BulletSimAPI.GetCollisionFlags2(Body.Ptr); + DetailLog("{0},BSPrim.SetObjectDynamic,taint,static={1},solid={2},mass={3}, cf={4}", LocalID, IsStatic, IsSolid, mass, cf); } // prims don't fly @@ -1224,7 +1228,7 @@ public sealed class BSPrim : PhysicsActor bool ret = BulletSimAPI.CreateObject(_scene.WorldID, shape); // the CreateObject() may have recreated the rigid body. Make sure we have the latest. - m_body.Ptr = BulletSimAPI.GetBodyHandle2(_scene.World.Ptr, LocalID); + Body = new BulletBody(LocalID, BulletSimAPI.GetBodyHandle2(_scene.World.Ptr, LocalID)); return ret; } @@ -1344,7 +1348,7 @@ public sealed class BSPrim : PhysicsActor else { // For debugging, we also report the movement of children - DetailLog("{0},BSPrim.BSPrim.UpdateProperties,child,pos={1},orient={2},vel={3},accel={4},rotVel={5}", + DetailLog("{0},BSPrim.UpdateProperties,child,pos={1},orient={2},vel={3},accel={4},rotVel={5}", LocalID, entprop.Position, entprop.Rotation, entprop.Velocity, entprop.Acceleration, entprop.RotationalVelocity); } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 65a8014..beaea1f 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -255,7 +255,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters // Initialization to support the transition to a new API which puts most of the logic // into the C# code so it is easier to modify and add to. - m_worldSim = new BulletSim(m_worldID, BulletSimAPI.GetSimHandle2(m_worldID)); + m_worldSim = new BulletSim(m_worldID, this, BulletSimAPI.GetSimHandle2(m_worldID)); m_constraintCollection = new BSConstraintCollection(World); m_initialized = true; @@ -362,6 +362,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters BSPrim bsprim = prim as BSPrim; if (bsprim != null) { + DetailLog("{0},RemovePrim,call", bsprim.LocalID); // m_log.DebugFormat("{0}: RemovePrim. id={1}/{2}", LogHeader, bsprim.Name, bsprim.LocalID); try { @@ -387,6 +388,8 @@ public class BSScene : PhysicsScene, IPhysicsParameters if (!m_initialized) return null; + DetailLog("{0},AddPrimShape,call", localID); + BSPrim prim = new BSPrim(localID, primName, this, position, size, rotation, pbs, isPhysical); lock (m_prims) m_prims.Add(localID, prim); return prim; @@ -426,12 +429,12 @@ public class BSScene : PhysicsScene, IPhysicsParameters { numSubSteps = BulletSimAPI.PhysicsStep(m_worldID, timeStep, m_maxSubSteps, m_fixedTimeStep, out updatedEntityCount, out updatedEntitiesPtr, out collidersCount, out collidersPtr); - DetailLog("{0},Simulate,call, substeps={1}, updates={2}, colliders={3}", "0000000000", numSubSteps, updatedEntityCount, collidersCount); + DetailLog("{0},Simulate,call, substeps={1}, updates={2}, colliders={3}", DetailLogZero, numSubSteps, updatedEntityCount, collidersCount); } catch (Exception e) { m_log.WarnFormat("{0},PhysicsStep Exception: substeps={1}, updates={2}, colliders={3}, e={4}", LogHeader, numSubSteps, updatedEntityCount, collidersCount, e); - DetailLog("{0},PhysicsStepException,call, substeps={1}, updates={2}, colliders={3}", "0000000000", numSubSteps, updatedEntityCount, collidersCount); + DetailLog("{0},PhysicsStepException,call, substeps={1}, updates={2}, colliders={3}", DetailLogZero, numSubSteps, updatedEntityCount, collidersCount); // updatedEntityCount = 0; collidersCount = 0; } @@ -777,6 +780,20 @@ public class BSScene : PhysicsScene, IPhysicsParameters } #region Vehicles + + public void VehicleInSceneTypeChanged(BSPrim vehic, Vehicle newType) + { + if (newType == Vehicle.TYPE_NONE) + { + RemoveVehiclePrim(vehic); + } + else + { + // make it so the scene will call us each tick to do vehicle things + AddVehiclePrim(vehic); + } + } + // Make so the scene will call this prim for vehicle actions each tick. // Safe to call if prim is already in the vehicle list. public void AddVehiclePrim(BSPrim vehicle) @@ -1304,10 +1321,12 @@ public class BSScene : PhysicsScene, IPhysicsParameters #endregion Runtime settable parameters // Invoke the detailed logger and output something if it's enabled. - private void DetailLog(string msg, params Object[] args) + public void DetailLog(string msg, params Object[] args) { PhysicsLogging.Write(msg, args); } + // used to fill in the LocalID when there isn't one + public const string DetailLogZero = "0000000000"; } } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs index c016402..6800b96 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs @@ -35,9 +35,11 @@ namespace OpenSim.Region.Physics.BulletSPlugin { // Classes to allow some type checking for the API public struct BulletSim { - public BulletSim(uint id, IntPtr xx) { ID = id; Ptr = xx; } - public IntPtr Ptr; + public BulletSim(uint id, BSScene bss, IntPtr xx) { ID = id; scene = bss; Ptr = xx; } public uint ID; + // The scene is only in here so very low level routines have a handle to print debug/error messages + public BSScene scene; + public IntPtr Ptr; } public struct BulletBody @@ -492,6 +494,9 @@ public static extern bool SetLinearVelocity2(IntPtr obj, Vector3 val); public static extern bool SetInterpolation2(IntPtr obj, Vector3 lin, Vector3 ang); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] +public static extern CollisionFlags GetCollisionFlags2(IntPtr obj); + +[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern IntPtr SetCollisionFlags2(IntPtr obj, CollisionFlags flags); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] -- cgit v1.1 From 58c630c18e3540fc1c33fda5f12bbcba540f44cb Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Mon, 13 Aug 2012 12:20:19 +0100 Subject: attempt at replicating behaviour of llList2thing functions in SL Committed with changes. Please don't sign comments with your name. Please don't use your own coding style, use the OpenSim project style. Please don't modify unrelated whitespace. Signed-off-by: Melanie --- .../Shared/Api/Implementation/LSL_Api.cs | 76 ++++++++++++++++++++-- 1 file changed, 69 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 3591d14..e87ec1c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -4957,12 +4957,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { return 0; } + + // Vectors & Rotations always return zero in SL, but + // keys don't always return zero, it seems to be a bit complex. + else if (src.Data[index] is LSL_Vector || + src.Data[index] is LSL_Rotation) + { + return 0; + } try { + if (src.Data[index] is LSL_Integer) - return (LSL_Integer) src.Data[index]; + return (LSL_Integer)src.Data[index]; else if (src.Data[index] is LSL_Float) - return Convert.ToInt32(((LSL_Float) src.Data[index]).value); + return Convert.ToInt32(((LSL_Float)src.Data[index]).value); return new LSL_Integer(src.Data[index].ToString()); } catch (FormatException) @@ -4982,14 +4991,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { return 0.0; } + + // Vectors & Rotations always return zero in SL + else if (src.Data[index] is LSL_Vector || + src.Data[index] is LSL_Rotation) + { + return 0; + } + // valid keys seem to get parsed as integers then converted to floats + else + { + UUID uuidt; + if (src.Data[index] is LSL_Key && UUID.TryParse(src.Data[index].ToString(), out uuidt)) + { + return Convert.ToDouble(new LSL_Integer(src.Data[index].ToString()).value); + } + } try { if (src.Data[index] is LSL_Integer) - return Convert.ToDouble(((LSL_Integer) src.Data[index]).value); + return Convert.ToDouble(((LSL_Integer)src.Data[index]).value); else if (src.Data[index] is LSL_Float) - return Convert.ToDouble(((LSL_Float) src.Data[index]).value); + return Convert.ToDouble(((LSL_Float)src.Data[index]).value); else if (src.Data[index] is LSL_String) - return Convert.ToDouble(((LSL_String) src.Data[index]).m_string); + return Convert.ToDouble(((LSL_String)src.Data[index]).m_string); return Convert.ToDouble(src.Data[index]); } catch (FormatException) @@ -5012,17 +5037,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return src.Data[index].ToString(); } - public LSL_String llList2Key(LSL_List src, int index) + public LSL_Key llList2Key(LSL_List src, int index) { m_host.AddScriptLPS(1); if (index < 0) { index = src.Length + index; } + if (index >= src.Length || index < 0) { return ""; } + + // SL spits out an empty string for types other than key & string + // At the time of patching, LSL_Key is currently LSL_String, + // so the OR check may be a little redundant, but it's being done + // for completion and should LSL_Key ever be implemented + // as it's own struct + else if (!(src.Data[index] is LSL_String || + src.Data[index] is LSL_Key)) + { + return ""; + } + return src.Data[index].ToString(); } @@ -5041,6 +5079,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { return (LSL_Vector)src.Data[index]; } + + // SL spits always out ZERO_VECTOR for anything other than + // strings or vectors. Although keys always return ZERO_VECTOR, + // it is currently difficult to make the distinction between + // a string, a key as string and a string that by coincidence + // is a string, so we're going to leave that up to the + // LSL_Vector constructor. + else if (!(src.Data[index] is LSL_String || + src.Data[index] is LSL_Vector)) + { + return new LSL_Vector(0, 0, 0); + } else { return new LSL_Vector(src.Data[index].ToString()); @@ -5058,7 +5108,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { return new LSL_Rotation(0, 0, 0, 1); } - if (src.Data[index].GetType() == typeof(LSL_Rotation)) + + // SL spits always out ZERO_ROTATION for anything other than + // strings or vectors. Although keys always return ZERO_ROTATION, + // it is currently difficult to make the distinction between + // a string, a key as string and a string that by coincidence + // is a string, so we're going to leave that up to the + // LSL_Rotation constructor. + else if (!(src.Data[index] is LSL_String || + src.Data[index] is LSL_Rotation)) + { + return new LSL_Rotation(0, 0, 0, 1); + } + else if (src.Data[index].GetType() == typeof(LSL_Rotation)) { return (LSL_Rotation)src.Data[index]; } -- cgit v1.1 From fe4c3a37c0a4d41c410ef99003c7ab437bdbc5f0 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 14 Aug 2012 00:12:15 +0100 Subject: Lay some groundwork for temp attachments. Decouple attachments from inventory. --- .../Avatar/Attachments/AttachmentsModule.cs | 41 ++++++++++++++-------- .../Attachments/Tests/AttachmentsModuleTests.cs | 6 ++-- .../Framework/Interfaces/IAttachmentsModule.cs | 2 +- OpenSim/Region/Framework/Scenes/Scene.cs | 2 +- .../Shared/Api/Implementation/LSL_Api.cs | 2 +- 5 files changed, 33 insertions(+), 20 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 464dfd3..77dd0f0 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -239,7 +239,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments sp.ClearAttachments(); } - public bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent) + public bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool temp) { lock (sp.AttachmentsSyncLock) { @@ -298,7 +298,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments group.AbsolutePosition = attachPos; if (sp.PresenceType != PresenceType.Npc) - UpdateUserInventoryWithAttachment(sp, group, attachmentPt); + UpdateUserInventoryWithAttachment(sp, group, attachmentPt, temp); AttachToAgent(sp, group, attachmentPt, attachPos, silent); } @@ -306,7 +306,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments return true; } - private void UpdateUserInventoryWithAttachment(IScenePresence sp, SceneObjectGroup group, uint attachmentPt) + private void UpdateUserInventoryWithAttachment(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool temp) { // Remove any previous attachments List attachments = sp.GetAttachments(attachmentPt); @@ -316,18 +316,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments { if (attachments[0].FromItemID != UUID.Zero) DetachSingleAttachmentToInvInternal(sp, attachments[0]); - else - m_log.WarnFormat( - "[ATTACHMENTS MODULE]: When detaching existing attachment {0} {1} at point {2} to make way for {3} {4} for {5}, couldn't find the associated item ID to adjust inventory attachment record!", - attachments[0].Name, attachments[0].LocalId, attachmentPt, group.Name, group.LocalId, sp.Name); + // Error logging commented because UUID.Zero now means temp attachment +// else +// m_log.WarnFormat( +// "[ATTACHMENTS MODULE]: When detaching existing attachment {0} {1} at point {2} to make way for {3} {4} for {5}, couldn't find the associated item ID to adjust inventory attachment record!", +// attachments[0].Name, attachments[0].LocalId, attachmentPt, group.Name, group.LocalId, sp.Name); } // Add the new attachment to inventory if we don't already have it. - UUID newAttachmentItemID = group.FromItemID; - if (newAttachmentItemID == UUID.Zero) - newAttachmentItemID = AddSceneObjectAsNewAttachmentInInv(sp, group).ID; + if (!temp) + { + UUID newAttachmentItemID = group.FromItemID; + if (newAttachmentItemID == UUID.Zero) + newAttachmentItemID = AddSceneObjectAsNewAttachmentInInv(sp, group).ID; - ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group); + ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group); + } } public SceneObjectGroup RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt) @@ -416,7 +420,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments so.PrimCount, sp.UUID, sp.AbsolutePosition)) return; - bool changed = sp.Appearance.DetachAttachment(inventoryID); + bool changed = false; + if (inventoryID != UUID.Zero) + changed = sp.Appearance.DetachAttachment(inventoryID); if (changed && m_scene.AvatarFactory != null) m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID); @@ -521,6 +527,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments /// private void UpdateKnownItem(IScenePresence sp, SceneObjectGroup grp, string scriptedState) { + if (grp.FromItemID == UUID.Zero) + { + // We can't save temp attachments + grp.HasGroupChanged = false; + return; + } + // Saving attachments for NPCs messes them up for the real owner! INPCModule module = m_scene.RequestModuleInterface(); if (module != null) @@ -777,7 +790,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments // This will throw if the attachment fails try { - AttachObject(sp, objatt, attachmentPt, false); + AttachObject(sp, objatt, attachmentPt, false, false); } catch (Exception e) { @@ -931,7 +944,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments AttachmentPt &= 0x7f; // Calls attach with a Zero position - if (AttachObject(sp, part.ParentGroup, AttachmentPt, false)) + if (AttachObject(sp, part.ParentGroup, AttachmentPt, false, false)) { // m_log.Debug( // "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 6e7a414..1d13f75 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -189,7 +189,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID); - scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false); + scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false); // Check status on scene presence Assert.That(sp.HasAttachments(), Is.True); @@ -243,7 +243,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests sp2.AbsolutePosition = new Vector3(0, 0, 0); sp2.HandleAgentRequestSit(sp2.ControllingClient, sp2.UUID, so.UUID, Vector3.Zero); - scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false); + scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false); Assert.That(sp.HasAttachments(), Is.False); Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); @@ -641,4 +641,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests // Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); // } } -} \ No newline at end of file +} diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs index d5200b7..8155eab 100644 --- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs @@ -83,7 +83,7 @@ namespace OpenSim.Region.Framework.Interfaces /// /// /// true if the object was successfully attached, false otherwise - bool AttachObject(IScenePresence sp, SceneObjectGroup grp, uint AttachmentPt, bool silent); + bool AttachObject(IScenePresence sp, SceneObjectGroup grp, uint AttachmentPt, bool silent, bool temp); /// /// Rez an attachment from user inventory and change inventory status to match. diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 40cfb72..0967c34 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -2628,7 +2628,7 @@ namespace OpenSim.Region.Framework.Scenes RootPrim.RemFlag(PrimFlags.TemporaryOnRez); if (AttachmentsModule != null) - AttachmentsModule.AttachObject(sp, grp, 0, false); + AttachmentsModule.AttachObject(sp, grp, 0, false, false); } else { diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index e87ec1c..1287709 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3043,7 +3043,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; if (attachmentsModule != null) - return attachmentsModule.AttachObject(presence, grp, (uint)attachmentPoint, false); + return attachmentsModule.AttachObject(presence, grp, (uint)attachmentPoint, false, false); else return false; } -- cgit v1.1 From 62acfabec4638284e0d9c88ccbd50d2d0f4b65a6 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 14 Aug 2012 00:54:12 +0100 Subject: Add the skeleton for the temp attachments module --- .../Avatar/Attachments/TempAttachmentsModule.cs | 82 ++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs b/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs new file mode 100644 index 0000000..c1efd7c --- /dev/null +++ b/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs @@ -0,0 +1,82 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using log4net; +using Mono.Addins; +using Nini.Config; +using OpenMetaverse; +using OpenSim.Framework; +using OpenSim.Framework.Console; +using OpenSim.Framework.Monitoring; +using OpenSim.Region.ClientStack.LindenUDP; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; + +namespace OpenSim.Region.OptionalModules.Avatar.Attachments +{ + /// + /// A module that just holds commands for inspecting avatar appearance. + /// + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "TempAttachmentsModule")] + public class TempAttachmentsModule : INonSharedRegionModule + { + public void Initialise(IConfigSource configSource) + { + } + + public void AddRegion(Scene scene) + { + } + + public void RemoveRegion(Scene scene) + { + } + + public void RegionLoaded(Scene scene) + { + } + + public void Close() + { + } + + public Type ReplaceableInterface + { + get { return null; } + } + + public string Name + { + get { return "TempAttachmentsModule"; } + } + } +} -- cgit v1.1 From 9bd2c1b88add5d6cc529a6882a7067200cb78ecb Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 14 Aug 2012 01:12:27 +0100 Subject: As per lindn spec, disable detach and drop for temp attachments --- .../Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 77dd0f0..f107be1 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -410,6 +410,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments UUID inventoryID = so.FromItemID; + // As per Linden spec, drop is disabled for temp attachs + if (inventoryID == UUID.Zero) + return; + // m_log.DebugFormat( // "[ATTACHMENTS MODULE]: In DetachSingleAttachmentToGround(), object is {0} {1}, associated item is {2}", // so.Name, so.LocalId, inventoryID); @@ -454,6 +458,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments public void DetachSingleAttachmentToInv(IScenePresence sp, SceneObjectGroup so) { + // As per Linden spec, detach (take) is disabled for temp attachs + if (so.FromItemID == UUID.Zero) + return; + lock (sp.AttachmentsSyncLock) { // Save avatar attachment information -- cgit v1.1 From 12a329eb8542f46a71c457eb506f37d7e56b1305 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 14 Aug 2012 02:28:23 +0200 Subject: Comment spammy debug --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index b37aba3..3f19370 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -179,9 +179,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC ScenePresence sp; scene.TryGetScenePresence(agentID, out sp); - m_log.DebugFormat( - "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", - sp.Name, pos, scene.RegionInfo.RegionName, noFly, landAtTarget); +// m_log.DebugFormat( +// "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", +// sp.Name, pos, scene.RegionInfo.RegionName, noFly, landAtTarget); sp.MoveToTarget(pos, noFly, landAtTarget); sp.SetAlwaysRun = running; -- cgit v1.1 From 4bbdcfb5ee81f459df9ff9a2ac477f6419cfc279 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 14 Aug 2012 01:45:02 +0100 Subject: Implement the temp attachments. UNTESTED --- .../Avatar/Attachments/TempAttachmentsModule.cs | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs b/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs index c1efd7c..e659ec0 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs @@ -49,12 +49,28 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "TempAttachmentsModule")] public class TempAttachmentsModule : INonSharedRegionModule { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private Scene m_scene; + public void Initialise(IConfigSource configSource) { } public void AddRegion(Scene scene) { + m_scene = scene; + + IScriptModuleComms comms = scene.RequestModuleInterface(); + if (comms != null) + { + comms.RegisterScriptInvocation( this, "llAttachToAvatarTemp"); + m_log.DebugFormat("[TEMP ATTACHS]: Registered script functions"); + } + else + { + m_log.ErrorFormat("[TEMP ATTACHS]: Failed to register script functions"); + } } public void RemoveRegion(Scene scene) @@ -78,5 +94,33 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments { get { return "TempAttachmentsModule"; } } + + private void llAttachToAvatarTemp(UUID host, UUID script, int attachmentPoint) + { + SceneObjectPart hostPart = m_scene.GetSceneObjectPart(host); + + if (hostPart == null) + return; + + if (hostPart.ParentGroup.IsAttachment) + return; + + IAttachmentsModule attachmentsModule = m_scene.RequestModuleInterface(); + if (attachmentsModule == null) + return; + + TaskInventoryItem item = hostPart.Inventory.GetInventoryItem(script); + if (item == null) + return; + + if ((item.PermsMask & 32) == 0) // PERMISSION_ATTACH + return; + + ScenePresence target; + if (!m_scene.TryGetScenePresence(item.PermsGranter, out target)) + return; + + attachmentsModule.AttachObject(target, hostPart.ParentGroup, (uint)attachmentPoint, false, true); + } } } -- cgit v1.1 From 20b66cf654a74bef0d514bbf30b72496ba0edd37 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 14 Aug 2012 03:02:43 +0200 Subject: Removed more spammy NPC crap --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 3f19370..72853ea 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -352,7 +352,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC scene.RemoveClient(agentID, false); m_avatars.Remove(agentID); - m_log.DebugFormat("[NPC MODULE]: Removed NPC {0} {1}", agentID, av.Name); +// m_log.DebugFormat("[NPC MODULE]: Removed NPC {0} {1}", agentID, av.Name); return true; } } -- cgit v1.1 From 1be072f19ee72f8b983aeceb036b1e6c6e041991 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 14 Aug 2012 09:55:44 +0100 Subject: Move inititalization to RegionLoaded to avoid a module loading order issue --- .../Avatar/Attachments/TempAttachmentsModule.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs b/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs index e659ec0..7011f38 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs @@ -59,6 +59,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments public void AddRegion(Scene scene) { + } + + public void RemoveRegion(Scene scene) + { + } + + public void RegionLoaded(Scene scene) + { m_scene = scene; IScriptModuleComms comms = scene.RequestModuleInterface(); @@ -73,14 +81,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments } } - public void RemoveRegion(Scene scene) - { - } - - public void RegionLoaded(Scene scene) - { - } - public void Close() { } -- cgit v1.1 From a5b6492223ae0dfeb12d768c12e6347e93225d14 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 14 Aug 2012 13:40:13 +0100 Subject: Perform ownership transfer and permission propagation as well as needed updates on the new temp attachment. --- .../Avatar/Attachments/TempAttachmentsModule.cs | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs b/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs index 7011f38..27ba5c9 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs @@ -120,6 +120,34 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments if (!m_scene.TryGetScenePresence(item.PermsGranter, out target)) return; + if (target.UUID != hostPart.ParentGroup.OwnerID) + { + uint effectivePerms = hostPart.ParentGroup.GetEffectivePermissions(); + + if ((effectivePerms & (uint)PermissionMask.Transfer) == 0) + return; + + hostPart.ParentGroup.SetOwnerId(target.UUID); + hostPart.ParentGroup.SetRootPartOwner(hostPart.ParentGroup.RootPart, target.UUID, target.ControllingClient.ActiveGroupId); + + if (m_scene.Permissions.PropagatePermissions()) + { + foreach (SceneObjectPart child in hostPart.ParentGroup.Parts) + { + child.Inventory.ChangeInventoryOwner(target.UUID); + child.TriggerScriptChangedEvent(Changed.OWNER); + child.ApplyNextOwnerPermissions(); + } + } + + hostPart.ParentGroup.RootPart.ObjectSaleType = 0; + hostPart.ParentGroup.RootPart.SalePrice = 10; + + hostPart.ParentGroup.HasGroupChanged = true; + hostPart.ParentGroup.RootPart.SendPropertiesToClient(target.ControllingClient); + hostPart.ParentGroup.RootPart.ScheduleFullUpdate(); + } + attachmentsModule.AttachObject(target, hostPart.ParentGroup, (uint)attachmentPoint, false, true); } } -- cgit v1.1 From 195b69d1ea90a123ce1a61536dffa33276c1e76a Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 14 Aug 2012 21:54:47 +0200 Subject: Allow the use of the region debug console found in recent viewers. This console will be available to estate owners and managers. If the user using the console had god privs, they can use "set console on" and "set console off" to switch on the actual region console. This allows console access from within the viewer. The region debug console can coexist with any other main console. --- .../Region/Framework/Interfaces/IRegionConsole.cs | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 OpenSim/Region/Framework/Interfaces/IRegionConsole.cs (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Interfaces/IRegionConsole.cs b/OpenSim/Region/Framework/Interfaces/IRegionConsole.cs new file mode 100644 index 0000000..4d261d6 --- /dev/null +++ b/OpenSim/Region/Framework/Interfaces/IRegionConsole.cs @@ -0,0 +1,39 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using OpenMetaverse; +using OpenSim.Framework; + +namespace OpenSim.Region.Framework.Interfaces +{ + public interface IRegionConsole + { + bool RunCommand(string command, UUID invokerID); + void SendConsoleOutput(UUID agentID, string message); + void AddCommand(string module, bool shared, string command, string help, string longhelp, CommandDelegate fn); + } +} -- cgit v1.1 From f21fdff4f98a3916aa63ae84f335bfb763345c54 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 14 Aug 2012 21:58:07 +0200 Subject: Actually add the module --- .../ClientStack/Linden/Caps/RegionConsoleModule.cs | 234 +++++++++++++++++++++ 1 file changed, 234 insertions(+) create mode 100644 OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs new file mode 100644 index 0000000..36af55f --- /dev/null +++ b/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs @@ -0,0 +1,234 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Drawing; +using System.Drawing.Imaging; +using System.Reflection; +using System.IO; +using System.Web; +using log4net; +using Nini.Config; +using Mono.Addins; +using OpenMetaverse; +using OpenMetaverse.StructuredData; +using OpenMetaverse.Imaging; +using OpenSim.Framework; +using OpenSim.Framework.Console; +using OpenSim.Framework.Servers; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; +using Caps = OpenSim.Framework.Capabilities.Caps; +using OpenSim.Capabilities.Handlers; + +namespace OpenSim.Region.ClientStack.Linden +{ + + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RegionConsoleModule")] + public class RegionConsoleModule : INonSharedRegionModule, IRegionConsole + { + private static readonly ILog m_log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private Scene m_scene; + private IEventQueue m_eventQueue; + private Commands m_commands = new Commands(); + public ICommands Commands { get { return m_commands; } } + + public void Initialise(IConfigSource source) + { + m_commands.AddCommand( "Help", false, "help", "help []", "Display help on a particular command or on a list of commands in a category", Help); + } + + public void AddRegion(Scene s) + { + m_scene = s; + m_scene.RegisterModuleInterface(this); + } + + public void RemoveRegion(Scene s) + { + m_scene.EventManager.OnRegisterCaps -= RegisterCaps; + m_scene = null; + } + + public void RegionLoaded(Scene s) + { + m_scene.EventManager.OnRegisterCaps += RegisterCaps; + m_eventQueue = m_scene.RequestModuleInterface(); + } + + public void PostInitialise() + { + } + + public void Close() { } + + public string Name { get { return "RegionConsoleModule"; } } + + public Type ReplaceableInterface + { + get { return null; } + } + + public void RegisterCaps(UUID agentID, Caps caps) + { + if (!m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(agentID)) + return; + + UUID capID = UUID.Random(); + + m_log.DebugFormat("[REGION CONSOLE]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName); + caps.RegisterHandler( + "SimConsoleAsync", + new ConsoleHandler("/CAPS/" + capID + "/", "SimConsoleAsync", agentID, this, m_scene)); + } + + public void SendConsoleOutput(UUID agentID, string message) + { + OSD osd = OSD.FromString(message); + + m_eventQueue.Enqueue(EventQueueHelper.BuildEvent("SimConsoleResponse", osd), agentID); + } + + public bool RunCommand(string command, UUID invokerID) + { + string[] parts = Parser.Parse(command); + Array.Resize(ref parts, parts.Length + 1); + parts[parts.Length - 1] = invokerID.ToString(); + + if (m_commands.Resolve(parts).Length == 0) + return false; + + return true; + } + + private void Help(string module, string[] cmd) + { + UUID agentID = new UUID(cmd[cmd.Length - 1]); + Array.Resize(ref cmd, cmd.Length - 1); + + List help = Commands.GetHelp(cmd); + + string reply = String.Empty; + + foreach (string s in help) + { + reply += s + "\n"; + } + + SendConsoleOutput(agentID, reply); + } + + public void AddCommand(string module, bool shared, string command, string help, string longhelp, CommandDelegate fn) + { + m_commands.AddCommand(module, shared, command, help, longhelp, fn); + } + } + + public class ConsoleHandler : BaseStreamHandler + { + private static readonly ILog m_log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private RegionConsoleModule m_consoleModule; + private UUID m_agentID; + private bool m_isGod; + private Scene m_scene; + private bool m_consoleIsOn = false; + + public ConsoleHandler(string path, string name, UUID agentID, RegionConsoleModule module, Scene scene) + :base("POST", path, name, agentID.ToString()) + { + m_agentID = agentID; + m_consoleModule = module; + m_scene = scene; + + m_isGod = m_scene.Permissions.IsGod(agentID); + } + + public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) + { + StreamReader reader = new StreamReader(request); + string message = reader.ReadToEnd(); + + OSD osd = OSDParser.DeserializeLLSDXml(message); + + string cmd = osd.AsString(); + if (cmd == "set console on") + { + if (m_isGod) + { + MainConsole.Instance.OnOutput += ConsoleSender; + m_consoleIsOn = true; + m_consoleModule.SendConsoleOutput(m_agentID, "Console is now on"); + } + return new byte[0]; + } + else if (cmd == "set console off") + { + MainConsole.Instance.OnOutput -= ConsoleSender; + m_consoleIsOn = false; + m_consoleModule.SendConsoleOutput(m_agentID, "Console is now off"); + return new byte[0]; + } + + if (m_consoleIsOn == false && m_consoleModule.RunCommand(osd.AsString().Trim(), m_agentID)) + return new byte[0]; + + if (m_isGod && m_consoleIsOn) + { + MainConsole.Instance.RunCommand(osd.AsString().Trim()); + } + else + { + m_consoleModule.SendConsoleOutput(m_agentID, "Unknown command"); + } + + return new byte[0]; + } + + private void ConsoleSender(string text) + { + m_consoleModule.SendConsoleOutput(m_agentID, text); + } + + private void OnMakeChildAgent(ScenePresence presence) + { + if (presence.UUID == m_agentID) + { + MainConsole.Instance.OnOutput -= ConsoleSender; + m_consoleIsOn = false; + } + } + } +} -- cgit v1.1 From 4a969b45bd3032c8f744ef816347711f67809a37 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 14 Aug 2012 22:02:40 +0200 Subject: Remove NPC debug spam --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index cfedca9..f16927c 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -124,9 +124,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, owner, senseAsAgent, scene); npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue); - m_log.DebugFormat( - "[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}", - firstname, lastname, npcAvatar.AgentId, owner, senseAsAgent, position, scene.RegionInfo.RegionName); +// m_log.DebugFormat( +// "[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}", +// firstname, lastname, npcAvatar.AgentId, owner, senseAsAgent, position, scene.RegionInfo.RegionName); AgentCircuitData acd = new AgentCircuitData(); acd.AgentID = npcAvatar.AgentId; @@ -157,7 +157,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC { sp.CompleteMovement(npcAvatar, false); m_avatars.Add(npcAvatar.AgentId, npcAvatar); - m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", npcAvatar.AgentId, sp.Name); +// m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", npcAvatar.AgentId, sp.Name); } } ev.Set(); @@ -179,9 +179,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC ScenePresence sp; if (scene.TryGetScenePresence(agentID, out sp)) { - m_log.DebugFormat( - "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", - sp.Name, pos, scene.RegionInfo.RegionName, noFly, landAtTarget); +// m_log.DebugFormat( +// "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", +// sp.Name, pos, scene.RegionInfo.RegionName, noFly, landAtTarget); sp.MoveToTarget(pos, noFly, landAtTarget); sp.SetAlwaysRun = running; -- cgit v1.1 From c42fe6c159d49535888937c3f219e028eb755efa Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 14 Aug 2012 21:44:06 +0100 Subject: Prevent race conditions when one thread removes an NPC SP before another thread has retreived it after checking whether the NPC exists. --- .../Region/OptionalModules/World/NPC/NPCModule.cs | 64 ++++++++++------------ .../Shared/Api/Implementation/OSSL_Api.cs | 25 +++++++-- 2 files changed, 50 insertions(+), 39 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 1e85fb4..3f25bcf 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -176,16 +176,17 @@ namespace OpenSim.Region.OptionalModules.World.NPC if (m_avatars.ContainsKey(agentID)) { ScenePresence sp; - scene.TryGetScenePresence(agentID, out sp); - - m_log.DebugFormat( - "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", - sp.Name, pos, scene.RegionInfo.RegionName, noFly, landAtTarget); - - sp.MoveToTarget(pos, noFly, landAtTarget); - sp.SetAlwaysRun = running; - - return true; + if (scene.TryGetScenePresence(agentID, out sp)) + { + m_log.DebugFormat( + "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", + sp.Name, pos, scene.RegionInfo.RegionName, noFly, landAtTarget); + + sp.MoveToTarget(pos, noFly, landAtTarget); + sp.SetAlwaysRun = running; + + return true; + } } } @@ -199,12 +200,13 @@ namespace OpenSim.Region.OptionalModules.World.NPC if (m_avatars.ContainsKey(agentID)) { ScenePresence sp; - scene.TryGetScenePresence(agentID, out sp); - - sp.Velocity = Vector3.Zero; - sp.ResetMoveToTarget(); + if (scene.TryGetScenePresence(agentID, out sp)) + { + sp.Velocity = Vector3.Zero; + sp.ResetMoveToTarget(); - return true; + return true; + } } } @@ -222,9 +224,6 @@ namespace OpenSim.Region.OptionalModules.World.NPC { if (m_avatars.ContainsKey(agentID)) { - ScenePresence sp; - scene.TryGetScenePresence(agentID, out sp); - m_avatars[agentID].Say(channel, text); return true; @@ -240,9 +239,6 @@ namespace OpenSim.Region.OptionalModules.World.NPC { if (m_avatars.ContainsKey(agentID)) { - ScenePresence sp; - scene.TryGetScenePresence(agentID, out sp); - m_avatars[agentID].Shout(channel, text); return true; @@ -259,11 +255,13 @@ namespace OpenSim.Region.OptionalModules.World.NPC if (m_avatars.ContainsKey(agentID)) { ScenePresence sp; - scene.TryGetScenePresence(agentID, out sp); - sp.HandleAgentRequestSit(m_avatars[agentID], agentID, partID, Vector3.Zero); -// sp.HandleAgentSit(m_avatars[agentID], agentID); - - return true; + if (scene.TryGetScenePresence(agentID, out sp)) + { + sp.HandleAgentRequestSit(m_avatars[agentID], agentID, partID, Vector3.Zero); + // sp.HandleAgentSit(m_avatars[agentID], agentID); + + return true; + } } } @@ -276,9 +274,6 @@ namespace OpenSim.Region.OptionalModules.World.NPC { if (m_avatars.ContainsKey(agentID)) { - ScenePresence sp; - scene.TryGetScenePresence(agentID, out sp); - m_avatars[agentID].Whisper(channel, text); return true; @@ -295,10 +290,12 @@ namespace OpenSim.Region.OptionalModules.World.NPC if (m_avatars.ContainsKey(agentID)) { ScenePresence sp; - scene.TryGetScenePresence(agentID, out sp); - sp.StandUp(); + if (scene.TryGetScenePresence(agentID, out sp)) + { + sp.StandUp(); - return true; + return true; + } } } @@ -311,6 +308,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC { if (m_avatars.ContainsKey(agentID)) return m_avatars[agentID].Touch(objectID); + return false; } } @@ -321,9 +319,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC { NPCAvatar av; if (m_avatars.TryGetValue(agentID, out av)) - { return av.OwnerID; - } } return UUID.Zero; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index bcd1a6f..859ee93 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs @@ -2434,8 +2434,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (!npcModule.CheckPermissions(npcId, m_host.OwnerID)) return new LSL_Vector(0, 0, 0); - Vector3 pos = World.GetScenePresence(npcId).AbsolutePosition; - return new LSL_Vector(pos.X, pos.Y, pos.Z); + ScenePresence sp = World.GetScenePresence(npcId); + + if (sp != null) + { + Vector3 pos = sp.AbsolutePosition; + return new LSL_Vector(pos.X, pos.Y, pos.Z); + } } return new LSL_Vector(0, 0, 0); @@ -2503,9 +2508,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W); ScenePresence sp = World.GetScenePresence(npcId); - Quaternion rot = sp.Rotation; - return new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W); + if (sp != null) + { + Quaternion rot = sp.Rotation; + return new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W); + } } return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W); @@ -2527,7 +2535,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; ScenePresence sp = World.GetScenePresence(npcId); - sp.Rotation = LSL_Api.Rot2Quaternion(rotation); + + if (sp != null) + sp.Rotation = LSL_Api.Rot2Quaternion(rotation); } } @@ -2689,6 +2699,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.High, "osNpcTouch"); m_host.AddScriptLPS(1); + INPCModule module = World.RequestModuleInterface(); int linkNum = link_num.value; if (module != null || (linkNum < 0 && linkNum != ScriptBaseClass.LINK_THIS)) @@ -2696,12 +2707,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api UUID npcId; if (!UUID.TryParse(npcLSL_Key, out npcId) || !module.CheckPermissions(npcId, m_host.OwnerID)) return; + SceneObjectPart part = null; UUID objectId; if (UUID.TryParse(LSL_String.ToString(object_key), out objectId)) part = World.GetSceneObjectPart(objectId); + if (part == null) return; + if (linkNum != ScriptBaseClass.LINK_THIS) { if (linkNum == 0 || linkNum == ScriptBaseClass.LINK_ROOT) @@ -2716,6 +2730,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return; } } + module.Touch(npcId, part.UUID); } } -- cgit v1.1 From faa710aee13347c4c55690f516ffda9179a92f3c Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 14 Aug 2012 21:54:47 +0200 Subject: Allow the use of the region debug console found in recent viewers. This console will be available to estate owners and managers. If the user using the console had god privs, they can use "set console on" and "set console off" to switch on the actual region console. This allows console access from within the viewer. The region debug console can coexist with any other main console. --- .../Region/Framework/Interfaces/IRegionConsole.cs | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 OpenSim/Region/Framework/Interfaces/IRegionConsole.cs (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Interfaces/IRegionConsole.cs b/OpenSim/Region/Framework/Interfaces/IRegionConsole.cs new file mode 100644 index 0000000..4d261d6 --- /dev/null +++ b/OpenSim/Region/Framework/Interfaces/IRegionConsole.cs @@ -0,0 +1,39 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using OpenMetaverse; +using OpenSim.Framework; + +namespace OpenSim.Region.Framework.Interfaces +{ + public interface IRegionConsole + { + bool RunCommand(string command, UUID invokerID); + void SendConsoleOutput(UUID agentID, string message); + void AddCommand(string module, bool shared, string command, string help, string longhelp, CommandDelegate fn); + } +} -- cgit v1.1 From f6562e226915dc09d78df43111c9c481b95bdcc8 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 14 Aug 2012 21:58:07 +0200 Subject: Actually add the module --- .../ClientStack/Linden/Caps/RegionConsoleModule.cs | 234 +++++++++++++++++++++ 1 file changed, 234 insertions(+) create mode 100644 OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs new file mode 100644 index 0000000..36af55f --- /dev/null +++ b/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs @@ -0,0 +1,234 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.Drawing; +using System.Drawing.Imaging; +using System.Reflection; +using System.IO; +using System.Web; +using log4net; +using Nini.Config; +using Mono.Addins; +using OpenMetaverse; +using OpenMetaverse.StructuredData; +using OpenMetaverse.Imaging; +using OpenSim.Framework; +using OpenSim.Framework.Console; +using OpenSim.Framework.Servers; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; +using Caps = OpenSim.Framework.Capabilities.Caps; +using OpenSim.Capabilities.Handlers; + +namespace OpenSim.Region.ClientStack.Linden +{ + + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RegionConsoleModule")] + public class RegionConsoleModule : INonSharedRegionModule, IRegionConsole + { + private static readonly ILog m_log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private Scene m_scene; + private IEventQueue m_eventQueue; + private Commands m_commands = new Commands(); + public ICommands Commands { get { return m_commands; } } + + public void Initialise(IConfigSource source) + { + m_commands.AddCommand( "Help", false, "help", "help []", "Display help on a particular command or on a list of commands in a category", Help); + } + + public void AddRegion(Scene s) + { + m_scene = s; + m_scene.RegisterModuleInterface(this); + } + + public void RemoveRegion(Scene s) + { + m_scene.EventManager.OnRegisterCaps -= RegisterCaps; + m_scene = null; + } + + public void RegionLoaded(Scene s) + { + m_scene.EventManager.OnRegisterCaps += RegisterCaps; + m_eventQueue = m_scene.RequestModuleInterface(); + } + + public void PostInitialise() + { + } + + public void Close() { } + + public string Name { get { return "RegionConsoleModule"; } } + + public Type ReplaceableInterface + { + get { return null; } + } + + public void RegisterCaps(UUID agentID, Caps caps) + { + if (!m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(agentID)) + return; + + UUID capID = UUID.Random(); + + m_log.DebugFormat("[REGION CONSOLE]: /CAPS/{0} in region {1}", capID, m_scene.RegionInfo.RegionName); + caps.RegisterHandler( + "SimConsoleAsync", + new ConsoleHandler("/CAPS/" + capID + "/", "SimConsoleAsync", agentID, this, m_scene)); + } + + public void SendConsoleOutput(UUID agentID, string message) + { + OSD osd = OSD.FromString(message); + + m_eventQueue.Enqueue(EventQueueHelper.BuildEvent("SimConsoleResponse", osd), agentID); + } + + public bool RunCommand(string command, UUID invokerID) + { + string[] parts = Parser.Parse(command); + Array.Resize(ref parts, parts.Length + 1); + parts[parts.Length - 1] = invokerID.ToString(); + + if (m_commands.Resolve(parts).Length == 0) + return false; + + return true; + } + + private void Help(string module, string[] cmd) + { + UUID agentID = new UUID(cmd[cmd.Length - 1]); + Array.Resize(ref cmd, cmd.Length - 1); + + List help = Commands.GetHelp(cmd); + + string reply = String.Empty; + + foreach (string s in help) + { + reply += s + "\n"; + } + + SendConsoleOutput(agentID, reply); + } + + public void AddCommand(string module, bool shared, string command, string help, string longhelp, CommandDelegate fn) + { + m_commands.AddCommand(module, shared, command, help, longhelp, fn); + } + } + + public class ConsoleHandler : BaseStreamHandler + { + private static readonly ILog m_log = + LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + private RegionConsoleModule m_consoleModule; + private UUID m_agentID; + private bool m_isGod; + private Scene m_scene; + private bool m_consoleIsOn = false; + + public ConsoleHandler(string path, string name, UUID agentID, RegionConsoleModule module, Scene scene) + :base("POST", path, name, agentID.ToString()) + { + m_agentID = agentID; + m_consoleModule = module; + m_scene = scene; + + m_isGod = m_scene.Permissions.IsGod(agentID); + } + + public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) + { + StreamReader reader = new StreamReader(request); + string message = reader.ReadToEnd(); + + OSD osd = OSDParser.DeserializeLLSDXml(message); + + string cmd = osd.AsString(); + if (cmd == "set console on") + { + if (m_isGod) + { + MainConsole.Instance.OnOutput += ConsoleSender; + m_consoleIsOn = true; + m_consoleModule.SendConsoleOutput(m_agentID, "Console is now on"); + } + return new byte[0]; + } + else if (cmd == "set console off") + { + MainConsole.Instance.OnOutput -= ConsoleSender; + m_consoleIsOn = false; + m_consoleModule.SendConsoleOutput(m_agentID, "Console is now off"); + return new byte[0]; + } + + if (m_consoleIsOn == false && m_consoleModule.RunCommand(osd.AsString().Trim(), m_agentID)) + return new byte[0]; + + if (m_isGod && m_consoleIsOn) + { + MainConsole.Instance.RunCommand(osd.AsString().Trim()); + } + else + { + m_consoleModule.SendConsoleOutput(m_agentID, "Unknown command"); + } + + return new byte[0]; + } + + private void ConsoleSender(string text) + { + m_consoleModule.SendConsoleOutput(m_agentID, text); + } + + private void OnMakeChildAgent(ScenePresence presence) + { + if (presence.UUID == m_agentID) + { + MainConsole.Instance.OnOutput -= ConsoleSender; + m_consoleIsOn = false; + } + } + } +} -- cgit v1.1 From 7d1bec00d5cda6d7024a3d64b5913b5c08c15a3f Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 15 Aug 2012 01:08:30 +0200 Subject: Add a skeleton for a name value storage associated with regions --- OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs | 6 ++++++ OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs | 6 ++++++ OpenSim/Region/Framework/Scenes/Scene.cs | 4 ++++ 3 files changed, 16 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs b/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs index ccb583d..3e97a7a 100644 --- a/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs +++ b/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs @@ -117,5 +117,11 @@ namespace OpenSim.Region.Framework.Interfaces void RemoveRegionEnvironmentSettings(UUID regionUUID); UUID[] GetObjectIDs(UUID regionID); + + void SaveExtra(UUID regionID, string name, string value); + + void RemoveExtra(UUID regionID, string name); + + Dictionary GetExtra(UUID regionID); } } diff --git a/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs b/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs index d7c80f7..17bd48b 100644 --- a/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs +++ b/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs @@ -128,6 +128,12 @@ namespace OpenSim.Region.Framework.Interfaces /// the region UUID void RemoveRegionEnvironmentSettings(UUID regionUUID); + void SaveExtra(UUID regionID, string name, string val); + + void RemoveExtra(UUID regionID, string name); + + Dictionary GetExtra(UUID regionID); + void Shutdown(); } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 1fc4c52..79ebc6e 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -177,6 +177,8 @@ namespace OpenSim.Region.Framework.Scenes protected ICapabilitiesModule m_capsModule; protected IGroupsModule m_groupsModule; + private Dictionary m_extraSettings; + /// /// Current scene frame number /// @@ -658,6 +660,8 @@ namespace OpenSim.Region.Framework.Scenes // FIXME: It shouldn't be up to the database plugins to create this data - we should do it when a new // region is set up and avoid these gyrations. RegionSettings rs = simDataService.LoadRegionSettings(RegionInfo.RegionID); + m_extraSettings = simDataService.GetExtra(RegionInfo.RegionID); + bool updatedTerrainTextures = false; if (rs.TerrainTexture1 == UUID.Zero) { -- cgit v1.1 From dc82ad0f7abe5f09675dfc3768da2a0134503916 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 15 Aug 2012 02:06:22 +0100 Subject: Add a skeleton for a name value storage associated with regions --- OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs | 5 +++++ OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs | 6 ++++++ OpenSim/Region/Framework/Scenes/Scene.cs | 4 ++++ 3 files changed, 15 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs b/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs index 0fcafcc..085b5ca 100644 --- a/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs +++ b/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs @@ -116,5 +116,10 @@ namespace OpenSim.Region.Framework.Interfaces /// the region UUID void RemoveRegionEnvironmentSettings(UUID regionUUID); + void SaveExtra(UUID regionID, string name, string value); + + void RemoveExtra(UUID regionID, string name); + + Dictionary GetExtra(UUID regionID); } } diff --git a/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs b/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs index e424976..3787ca0 100644 --- a/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs +++ b/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs @@ -127,6 +127,12 @@ namespace OpenSim.Region.Framework.Interfaces /// the region UUID void RemoveRegionEnvironmentSettings(UUID regionUUID); + void SaveExtra(UUID regionID, string name, string val); + + void RemoveExtra(UUID regionID, string name); + + Dictionary GetExtra(UUID regionID); + void Shutdown(); } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 0967c34..59f49ea 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -174,6 +174,8 @@ namespace OpenSim.Region.Framework.Scenes protected ICapabilitiesModule m_capsModule; protected IGroupsModule m_groupsModule; + private Dictionary m_extraSettings; + /// /// Current scene frame number /// @@ -635,6 +637,8 @@ namespace OpenSim.Region.Framework.Scenes // FIXME: It shouldn't be up to the database plugins to create this data - we should do it when a new // region is set up and avoid these gyrations. RegionSettings rs = simDataService.LoadRegionSettings(RegionInfo.RegionID); + m_extraSettings = simDataService.GetExtra(RegionInfo.RegionID); + bool updatedTerrainTextures = false; if (rs.TerrainTexture1 == UUID.Zero) { -- cgit v1.1 From da0f6b926fdc40cf729bfc3ace4367758adf8f93 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 15 Aug 2012 18:22:16 +0200 Subject: Add support for the extra params to scene and the event manager --- OpenSim/Region/Framework/Scenes/EventManager.cs | 23 +++++++++++++++ OpenSim/Region/Framework/Scenes/Scene.cs | 39 +++++++++++++++++++++++++ 2 files changed, 62 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 7cb3811..eee5960 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -217,6 +217,9 @@ namespace OpenSim.Region.Framework.Scenes /// public event NewScript OnNewScript; + public delegate void ExtraSettingChangedDelegate(Scene scene, string name, string value); + public event ExtraSettingChangedDelegate OnExtraSettingChanged; + public virtual void TriggerNewScript(UUID clientID, SceneObjectPart part, UUID itemID) { NewScript handlerNewScript = OnNewScript; @@ -2616,5 +2619,25 @@ namespace OpenSim.Region.Framework.Scenes } } + public void TriggerExtraSettingChanged(Scene scene, string name, string val) + { + ExtraSettingChangedDelegate handler = OnExtraSettingChanged; + + if (handler != null) + { + foreach (ExtraSettingChangedDelegate d in handler.GetInvocationList()) + { + try + { + d(scene, name, val); + } + catch (Exception e) + { + m_log.ErrorFormat("[EVENT MANAGER]: Delegate for ExtraSettingChanged failed - continuing {0} - {1}", + e.Message, e.StackTrace); + } + } + } + } } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 79ebc6e..a5f0bff 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -5854,5 +5854,44 @@ Environment.Exit(1); callback(asset); } + + public string GetExtraSetting(string name) + { + string val; + + if (!m_extraSettings.TryGetValue(name, out val)) + return String.Empty; + + return val; + } + + public void StoreExtraSetting(string name, string val) + { + string oldVal; + + if (m_extraSettings.TryGetValue(name, out oldVal)) + { + if (oldVal == val) + return; + } + + m_extraSettings[name] = val; + + m_SimulationDataService.SaveExtra(RegionInfo.RegionID, name, val); + + m_eventManager.TriggerExtraSettingChanged(this, name, val); + } + + public void RemoveExtraSetting(string name) + { + if (!m_extraSettings.ContainsKey(name)) + return; + + m_extraSettings.Remove(name); + + m_SimulationDataService.RemoveExtra(RegionInfo.RegionID, name); + + m_eventManager.TriggerExtraSettingChanged(this, name, String.Empty); + } } } -- cgit v1.1 From 44dc138d8b7a957f9db39fd1a017c0267dfd0829 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 15 Aug 2012 18:22:52 +0200 Subject: Let the temp attachment module add a command to allow attaching without permissions and add support for this (incomplete!) to LSL --- .../Avatar/Attachments/TempAttachmentsModule.cs | 41 +++++++++++++++-- .../Shared/Api/Implementation/LSL_Api.cs | 51 ++++++++++------------ 2 files changed, 60 insertions(+), 32 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs b/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs index 68a484a..417b620 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs @@ -43,15 +43,13 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.OptionalModules.Avatar.Attachments { - /// - /// A module that just holds commands for inspecting avatar appearance. - /// [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "TempAttachmentsModule")] public class TempAttachmentsModule : INonSharedRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private Scene m_scene; + private IRegionConsole m_console; public void Initialise(IConfigSource configSource) { @@ -74,6 +72,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments { comms.RegisterScriptInvocation( this, "llAttachToAvatarTemp"); m_log.DebugFormat("[TEMP ATTACHS]: Registered script functions"); + m_console = scene.RequestModuleInterface(); + + if (m_console != null) + { + m_console.AddCommand("TempATtachModule", false, "set auto_grant_attach_perms", "set auto_grant_attach_perms true|false", "Allow objects owned by the region owner os estate managers to obtain attach permissions without asking the user", SetAutoGrantAttachPerms); + } } else { @@ -95,6 +99,37 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments get { return "TempAttachmentsModule"; } } + private void SendConsoleOutput(UUID agentID, string text) + { + if (m_console == null) + return; + + m_console.SendConsoleOutput(agentID, text); + } + + private void SetAutoGrantAttachPerms(string module, string[] parms) + { + UUID agentID = new UUID(parms[parms.Length - 1]); + Array.Resize(ref parms, parms.Length - 1); + + if (parms.Length != 3) + { + SendConsoleOutput(agentID, "Command parameter error"); + return; + } + + string val = parms[2]; + if (val != "true" && val != "false") + { + SendConsoleOutput(agentID, "Command parameter error"); + return; + } + + m_scene.StoreExtraSetting("auto_grant_attach_perms", val); + + SendConsoleOutput(agentID, String.Format("auto_grant_attach_perms set to {0}", val)); + } + private void llAttachToAvatarTemp(UUID host, UUID script, int attachmentPoint) { SceneObjectPart hostPart = m_scene.GetSceneObjectPart(host); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 54cb214..1115542 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3753,29 +3753,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); + int implicitPerms = 0; + if (m_host.ParentGroup.IsAttachment && (UUID)agent == m_host.ParentGroup.AttachedAvatar) { // When attached, certain permissions are implicit if requested from owner - int implicitPerms = ScriptBaseClass.PERMISSION_TAKE_CONTROLS | + implicitPerms = ScriptBaseClass.PERMISSION_TAKE_CONTROLS | ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION | ScriptBaseClass.PERMISSION_CONTROL_CAMERA | ScriptBaseClass.PERMISSION_TRACK_CAMERA | ScriptBaseClass.PERMISSION_ATTACH; - if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms - { - m_host.TaskInventory.LockItemsForWrite(true); - m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; - m_host.TaskInventory[m_item.ItemID].PermsMask = perm; - m_host.TaskInventory.LockItemsForWrite(false); - - m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( - "run_time_permissions", new Object[] { - new LSL_Integer(perm) }, - new DetectParams[0])); - - return; - } } else { @@ -3796,26 +3784,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (sitting) { // When agent is sitting, certain permissions are implicit if requested from sitting agent - int implicitPerms = ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION | + implicitPerms = ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION | ScriptBaseClass.PERMISSION_CONTROL_CAMERA | ScriptBaseClass.PERMISSION_TRACK_CAMERA | ScriptBaseClass.PERMISSION_TAKE_CONTROLS; + } + else + { + if (World.GetExtraSetting("auto_grant_attach_perms") == "true") + implicitPerms = ScriptBaseClass.PERMISSION_ATTACH; + } + } - if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms - { - m_host.TaskInventory.LockItemsForWrite(true); - m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; - m_host.TaskInventory[m_item.ItemID].PermsMask = perm; - m_host.TaskInventory.LockItemsForWrite(false); + if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms + { + m_host.TaskInventory.LockItemsForWrite(true); + m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; + m_host.TaskInventory[m_item.ItemID].PermsMask = perm; + m_host.TaskInventory.LockItemsForWrite(false); - m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( - "run_time_permissions", new Object[] { - new LSL_Integer(perm) }, - new DetectParams[0])); + m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( + "run_time_permissions", new Object[] { + new LSL_Integer(perm) }, + new DetectParams[0])); - return; - } - } + return; } ScenePresence presence = World.GetScenePresence(agentID); -- cgit v1.1 From c27ff70d5c9c7f91ff63b197359de84f7508ec60 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 15 Aug 2012 18:22:16 +0200 Subject: Add support for the extra params to scene and the event manager --- OpenSim/Region/Framework/Scenes/EventManager.cs | 23 +++++++++++++++ OpenSim/Region/Framework/Scenes/Scene.cs | 39 +++++++++++++++++++++++++ 2 files changed, 62 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 6dea2f0..4d65be9 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -213,6 +213,9 @@ namespace OpenSim.Region.Framework.Scenes /// public event NewScript OnNewScript; + public delegate void ExtraSettingChangedDelegate(Scene scene, string name, string value); + public event ExtraSettingChangedDelegate OnExtraSettingChanged; + public virtual void TriggerNewScript(UUID clientID, SceneObjectPart part, UUID itemID) { NewScript handlerNewScript = OnNewScript; @@ -2591,5 +2594,25 @@ namespace OpenSim.Region.Framework.Scenes } } + public void TriggerExtraSettingChanged(Scene scene, string name, string val) + { + ExtraSettingChangedDelegate handler = OnExtraSettingChanged; + + if (handler != null) + { + foreach (ExtraSettingChangedDelegate d in handler.GetInvocationList()) + { + try + { + d(scene, name, val); + } + catch (Exception e) + { + m_log.ErrorFormat("[EVENT MANAGER]: Delegate for ExtraSettingChanged failed - continuing {0} - {1}", + e.Message, e.StackTrace); + } + } + } + } } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 59f49ea..0e5ddfd 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -5447,5 +5447,44 @@ namespace OpenSim.Region.Framework.Scenes callback(asset); } + + public string GetExtraSetting(string name) + { + string val; + + if (!m_extraSettings.TryGetValue(name, out val)) + return String.Empty; + + return val; + } + + public void StoreExtraSetting(string name, string val) + { + string oldVal; + + if (m_extraSettings.TryGetValue(name, out oldVal)) + { + if (oldVal == val) + return; + } + + m_extraSettings[name] = val; + + m_SimulationDataService.SaveExtra(RegionInfo.RegionID, name, val); + + m_eventManager.TriggerExtraSettingChanged(this, name, val); + } + + public void RemoveExtraSetting(string name) + { + if (!m_extraSettings.ContainsKey(name)) + return; + + m_extraSettings.Remove(name); + + m_SimulationDataService.RemoveExtra(RegionInfo.RegionID, name); + + m_eventManager.TriggerExtraSettingChanged(this, name, String.Empty); + } } } -- cgit v1.1 From ebbf349c6a883ea641ee02b0517313f6391f60ef Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 15 Aug 2012 18:22:52 +0200 Subject: Let the temp attachment module add a command to allow attaching without permissions and add support for this (incomplete!) to LSL --- .../Avatar/Attachments/TempAttachmentsModule.cs | 41 ++++++++++++- .../Shared/Api/Implementation/LSL_Api.cs | 70 ++++++++++++---------- 2 files changed, 77 insertions(+), 34 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs b/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs index 27ba5c9..cb89cd1 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs @@ -43,15 +43,13 @@ using OpenSim.Region.Framework.Scenes; namespace OpenSim.Region.OptionalModules.Avatar.Attachments { - /// - /// A module that just holds commands for inspecting avatar appearance. - /// [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "TempAttachmentsModule")] public class TempAttachmentsModule : INonSharedRegionModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private Scene m_scene; + private IRegionConsole m_console; public void Initialise(IConfigSource configSource) { @@ -74,6 +72,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments { comms.RegisterScriptInvocation( this, "llAttachToAvatarTemp"); m_log.DebugFormat("[TEMP ATTACHS]: Registered script functions"); + m_console = scene.RequestModuleInterface(); + + if (m_console != null) + { + m_console.AddCommand("TempATtachModule", false, "set auto_grant_attach_perms", "set auto_grant_attach_perms true|false", "Allow objects owned by the region owner os estate managers to obtain attach permissions without asking the user", SetAutoGrantAttachPerms); + } } else { @@ -95,6 +99,37 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments get { return "TempAttachmentsModule"; } } + private void SendConsoleOutput(UUID agentID, string text) + { + if (m_console == null) + return; + + m_console.SendConsoleOutput(agentID, text); + } + + private void SetAutoGrantAttachPerms(string module, string[] parms) + { + UUID agentID = new UUID(parms[parms.Length - 1]); + Array.Resize(ref parms, parms.Length - 1); + + if (parms.Length != 3) + { + SendConsoleOutput(agentID, "Command parameter error"); + return; + } + + string val = parms[2]; + if (val != "true" && val != "false") + { + SendConsoleOutput(agentID, "Command parameter error"); + return; + } + + m_scene.StoreExtraSetting("auto_grant_attach_perms", val); + + SendConsoleOutput(agentID, String.Format("auto_grant_attach_perms set to {0}", val)); + } + private void llAttachToAvatarTemp(UUID host, UUID script, int attachmentPoint) { SceneObjectPart hostPart = m_scene.GetSceneObjectPart(host); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 1287709..8b53edc 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3424,53 +3424,61 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); + int implicitPerms = 0; + if (m_host.ParentGroup.IsAttachment && (UUID)agent == m_host.ParentGroup.AttachedAvatar) { // When attached, certain permissions are implicit if requested from owner - int implicitPerms = ScriptBaseClass.PERMISSION_TAKE_CONTROLS | + implicitPerms = ScriptBaseClass.PERMISSION_TAKE_CONTROLS | ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION | ScriptBaseClass.PERMISSION_CONTROL_CAMERA | ScriptBaseClass.PERMISSION_ATTACH; - - if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms + } + else + { + bool sitting = false; + if (m_host.SitTargetAvatar == agentID) { - lock (m_host.TaskInventory) + sitting = true; + } + else + { + foreach (SceneObjectPart p in m_host.ParentGroup.Parts) { - m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; - m_host.TaskInventory[m_item.ItemID].PermsMask = perm; + if (p.SitTargetAvatar == agentID) + sitting = true; } + } - m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( - "run_time_permissions", new Object[] { - new LSL_Integer(perm) }, - new DetectParams[0])); - - return; + if (sitting) + { + // When agent is sitting, certain permissions are implicit if requested from sitting agent + implicitPerms = ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION | + ScriptBaseClass.PERMISSION_CONTROL_CAMERA | + ScriptBaseClass.PERMISSION_TRACK_CAMERA | + ScriptBaseClass.PERMISSION_TAKE_CONTROLS; + } + else + { + if (World.GetExtraSetting("auto_grant_attach_perms") == "true") + implicitPerms = ScriptBaseClass.PERMISSION_ATTACH; } } - else if (m_host.SitTargetAvatar == agentID) // Sitting avatar - { - // When agent is sitting, certain permissions are implicit if requested from sitting agent - int implicitPerms = ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION | - ScriptBaseClass.PERMISSION_CONTROL_CAMERA | - ScriptBaseClass.PERMISSION_TRACK_CAMERA | - ScriptBaseClass.PERMISSION_TAKE_CONTROLS; - if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms + if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms + { + lock (m_host.TaskInventory) { - lock (m_host.TaskInventory) - { - m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; - m_host.TaskInventory[m_item.ItemID].PermsMask = perm; - } + m_host.TaskInventory[m_item.ItemID].PermsGranter = agentID; + m_host.TaskInventory[m_item.ItemID].PermsMask = perm; + } - m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( - "run_time_permissions", new Object[] { - new LSL_Integer(perm) }, - new DetectParams[0])); + m_ScriptEngine.PostScriptEvent(m_item.ItemID, new EventParams( + "run_time_permissions", new Object[] { + new LSL_Integer(perm) }, + new DetectParams[0])); - return; - } + return; } ScenePresence presence = World.GetScenePresence(agentID); -- cgit v1.1 From 11a4b9ec1d4f93cfd0600d090efbf257c9ea9a1b Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 14 Aug 2012 16:20:07 -0700 Subject: BulletSim: rework physics FPS calculation to make a more realistic number. --- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index beaea1f..f63ad95 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -413,7 +413,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters // prevent simulation until we've been initialized if (!m_initialized) return 10.0f; - long simulateStartTime = Util.EnvironmentTickCount(); + int simulateStartTime = Util.EnvironmentTickCount(); // update the prim states while we know the physics engine is not busy ProcessTaints(); @@ -511,8 +511,13 @@ public class BSScene : PhysicsScene, IPhysicsParameters // long simulateTotalTime = Util.EnvironmentTickCountSubtract(simulateStartTime); // return (timeStep * (float)simulateTotalTime); - // TODO: FIX THIS: fps calculation wrong. This calculation always returns about 1 in normal operation. - return timeStep / (numSubSteps * m_fixedTimeStep) * 1000f; + // TODO: FIX THIS: fps calculation possibly wrong. + // This calculation says 1/timeStep is the ideal frame rate. Any time added to + // that by the physics simulation gives a slower frame rate. + long totalSimulationTime = Util.EnvironmentTickCountSubtract(simulateStartTime); + if (totalSimulationTime >= timeStep) + return 0; + return 1f / (timeStep + totalSimulationTime); } // Something has collided -- cgit v1.1 From 6f1f299619d0ca60e06dc03d499259efcd4eeb80 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 14 Aug 2012 16:22:21 -0700 Subject: BulletSim: Add the class BSCharacter to the DetailLog output --- OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index f164afe..d288ab7 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -137,7 +137,7 @@ public class BSCharacter : PhysicsActor // called when this character is being destroyed and the resources should be released public void Destroy() { - // DetailLog("{0},Destroy", LocalID); + // DetailLog("{0},BSCharacter.Destroy", LocalID); _scene.TaintedObject("BSCharacter.destroy", delegate() { BulletSimAPI.DestroyObject(_scene.WorldID, _localID); @@ -209,7 +209,7 @@ public class BSCharacter : PhysicsActor _scene.TaintedObject("BSCharacter.setPosition", delegate() { - DetailLog("{0},SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); + DetailLog("{0},BSCharacter.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation); }); } @@ -226,7 +226,7 @@ public class BSCharacter : PhysicsActor float terrainHeight = Scene.GetTerrainHeightAtXYZ(_position); if (_position.Z < terrainHeight) { - DetailLog("{0},PositionAdjustUnderGround,call,pos={1},orient={2}", LocalID, _position, _orientation); + DetailLog("{0},BSCharacter.PositionAdjustUnderGround,call,pos={1},orient={2}", LocalID, _position, _orientation); _position.Z = terrainHeight + 2.0f; ret = true; } @@ -368,7 +368,7 @@ public class BSCharacter : PhysicsActor set { _buoyancy = value; _scene.TaintedObject("BSCharacter.setBuoyancy", delegate() { - DetailLog("{0},setBuoyancy,taint,buoy={1}", LocalID, _buoyancy); + DetailLog("{0},BSCharacter.setBuoyancy,taint,buoy={1}", LocalID, _buoyancy); BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, LocalID, _buoyancy); }); } @@ -415,7 +415,7 @@ public class BSCharacter : PhysicsActor // m_log.DebugFormat("{0}: AddForce. adding={1}, newForce={2}", LogHeader, force, _force); _scene.TaintedObject("BSCharacter.AddForce", delegate() { - DetailLog("{0},setAddForce,taint,addedForce={1}", LocalID, _force); + DetailLog("{0},BSCharacter.setAddForce,taint,addedForce={1}", LocalID, _force); BulletSimAPI.AddObjectForce2(Body.Ptr, _force); }); } @@ -507,6 +507,7 @@ public class BSCharacter : PhysicsActor { _collidingGroundStep = _scene.SimulationStep; } + // DetailLog("{0},BSCharacter.Collison,call,with={1}", LocalID, collidingWith); // throttle collisions to the rate specified in the subscription if (_subscribedEventsMs != 0) { @@ -535,7 +536,10 @@ public class BSCharacter : PhysicsActor if (collisionCollection == null) collisionCollection = new CollisionEventUpdate(); base.SendCollisionUpdate(collisionCollection); - collisionCollection.Clear(); + // If there were any collisions in the collection, make sure we don't use the + // same instance next time. + if (collisionCollection.Count > 0) + collisionCollection = null; // End kludge } -- cgit v1.1 From c1c1d48af15b4ac0ed5951816f6225a74ffa6eba Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 14 Aug 2012 16:24:34 -0700 Subject: BulletSim: add BSConstraint.RecomputConstraintVariables for the recomputation after linksets changed, etc --- OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs index da26b72..cf8dbc5 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs @@ -80,10 +80,27 @@ public abstract class BSConstraint : IDisposable bool ret = false; if (m_enabled) { + // Recompute the internal transforms BulletSimAPI.CalculateTransforms2(m_constraint.Ptr); ret = true; } return ret; } + + // Reset this constraint making sure it has all its internal structures + // recomputed and is enabled and ready to go. + public virtual bool RecomputeConstraintVariables(float mass) + { + bool ret = false; + if (m_enabled) + { + ret = CalculateTransforms(); + if (ret) + { + BulletSimAPI.SetConstraintEnable2(m_constraint.Ptr, m_world.scene.NumericBool(true)); + } + } + return ret; + } } } -- cgit v1.1 From 77a7758cf50e14b3ed7309d0d36612d9987b987b Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 14 Aug 2012 16:25:59 -0700 Subject: BulletSim: Refactor BSConstraintCollection to add a new RemoveAndDestroyConstraint(BSConstraint xx) --- .../Physics/BulletSPlugin/BSConstraintCollection.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs index 3df2ddc..862b744 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs @@ -112,16 +112,24 @@ public class BSConstraintCollection : IDisposable { m_world.scene.DetailLog("{0},BSConstraintCollection.RemoveAndDestroyConstraint,taint,body1={1},body2={2}", BSScene.DetailLogZero, body1.ID, body2.ID); // remove the constraint from our collection - m_constraints.Remove(constrain); - // tell the engine that all its structures need to be freed - constrain.Dispose(); - // we destroyed something + RemoveAndDestroyConstraint(constrain); ret = true; } return ret; } + // The constraint MUST exist in the collection + public bool RemoveAndDestroyConstraint(BSConstraint constrain) + { + // remove the constraint from our collection + m_constraints.Remove(constrain); + // tell the engine that all its structures need to be freed + constrain.Dispose(); + // we destroyed something + return true; + } + // Remove all constraints that reference the passed body. // Return 'true' if any constraints were destroyed. public bool RemoveAndDestroyConstraint(BulletBody body1) -- cgit v1.1 From 257446889b5fecf9a5e085f8e3b963dca3613e3f Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 14 Aug 2012 16:38:11 -0700 Subject: BulletSim: fix problem of a null reference exception on shutdown if there were linksets in the region. --- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index f63ad95..cacab01 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -511,12 +511,12 @@ public class BSScene : PhysicsScene, IPhysicsParameters // long simulateTotalTime = Util.EnvironmentTickCountSubtract(simulateStartTime); // return (timeStep * (float)simulateTotalTime); - // TODO: FIX THIS: fps calculation possibly wrong. - // This calculation says 1/timeStep is the ideal frame rate. Any time added to - // that by the physics simulation gives a slower frame rate. - long totalSimulationTime = Util.EnvironmentTickCountSubtract(simulateStartTime); - if (totalSimulationTime >= timeStep) - return 0; + // TODO: FIX THIS: fps calculation possibly wrong. + // This calculation says 1/timeStep is the ideal frame rate. Any time added to + // that by the physics simulation gives a slower frame rate. + long totalSimulationTime = Util.EnvironmentTickCountSubtract(simulateStartTime); + if (totalSimulationTime >= timeStep) + return 0; return 1f / (timeStep + totalSimulationTime); } @@ -595,12 +595,6 @@ public class BSScene : PhysicsScene, IPhysicsParameters // make sure no stepping happens while we're deleting stuff m_initialized = false; - if (m_constraintCollection != null) - { - m_constraintCollection.Dispose(); - m_constraintCollection = null; - } - foreach (KeyValuePair kvp in m_avatars) { kvp.Value.Destroy(); @@ -613,6 +607,13 @@ public class BSScene : PhysicsScene, IPhysicsParameters } m_prims.Clear(); + // Now that the prims are all cleaned up, there should be no constraints left + if (m_constraintCollection != null) + { + m_constraintCollection.Dispose(); + m_constraintCollection = null; + } + // Anything left in the unmanaged code should be cleaned out BulletSimAPI.Shutdown(WorldID); -- cgit v1.1 From b05a2fc4edb632f80b16034feb4c680dbda9c006 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 14 Aug 2012 16:41:36 -0700 Subject: BulletSim: don't recreate mesh unless it needs it when rebuilding the hull. Make sure the collisionCollection is reallocated each tick to fix race condition of it being cleared while still in use. --- OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 30 +++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 05cc822..38a9e46 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -497,6 +497,9 @@ public sealed class BSPrim : PhysicsActor BulletSimAPI.SetObjectProperties(_scene.WorldID, LocalID, IsStatic, IsSolid, SubscribedEvents(), mass); + // recompute any linkset parameters + _linkset.Refresh(this); + CollisionFlags cf = BulletSimAPI.GetCollisionFlags2(Body.Ptr); DetailLog("{0},BSPrim.SetObjectDynamic,taint,static={1},solid={2},mass={3}, cf={4}", LocalID, IsStatic, IsSolid, mass, cf); } @@ -1095,28 +1098,21 @@ public sealed class BSPrim : PhysicsActor // if the hull hasn't changed, don't rebuild it if (newHullKey == _hullKey) return; - DetailLog("{0},BSPrim.CreateGeomHull,create,key={1}", LocalID, _meshKey); + DetailLog("{0},BSPrim.CreateGeomHull,create,oldKey={1},newKey={2}", LocalID, _hullKey, newHullKey); // Since we're recreating new, get rid of any previously generated shape if (_hullKey != 0) { // m_log.DebugFormat("{0}: CreateGeom: deleting old hull. Key={1}", LogHeader, _hullKey); - DetailLog("{0},BSPrim.CreateGeomHull,deleteOldHull,key={1}", LocalID, _meshKey); + DetailLog("{0},BSPrim.CreateGeomHull,deleteOldHull,key={1}", LocalID, _hullKey); BulletSimAPI.DestroyHull(_scene.WorldID, _hullKey); _hullKey = 0; - _hulls.Clear(); - DetailLog("{0},BSPrim.CreateGeomHull,deleteOldMesh,key={1}", LocalID, _meshKey); - BulletSimAPI.DestroyMesh(_scene.WorldID, _meshKey); - _mesh = null; // the mesh cannot match either - _meshKey = 0; } _hullKey = newHullKey; - if (_meshKey != _hullKey) - { - // if the underlying mesh has changed, rebuild it - CreateGeomMesh(); - } + + // Make sure the underlying mesh exists and is correct + CreateGeomMesh(); int[] indices = _mesh.getIndexListAsInt(); List vertices = _mesh.getVertexList(); @@ -1142,7 +1138,7 @@ public sealed class BSPrim : PhysicsActor // create the hull into the _hulls variable convexBuilder.process(dcomp); - // Convert the vertices and indices for passing to unmanaged + // Convert the vertices and indices for passing to unmanaged. // The hull information is passed as a large floating point array. // The format is: // convHulls[0] = number of hulls @@ -1355,7 +1351,7 @@ public sealed class BSPrim : PhysicsActor } // I've collided with something - CollisionEventUpdate collisionCollection = null; + CollisionEventUpdate collisionCollection; public void Collide(uint collidingWith, ActorTypes type, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth) { // m_log.DebugFormat("{0}: Collide: ms={1}, id={2}, with={3}", LogHeader, _subscribedEventsMs, LocalID, collidingWith); @@ -1367,6 +1363,8 @@ public sealed class BSPrim : PhysicsActor _collidingGroundStep = _scene.SimulationStep; } + // DetailLog("{0},BSPrim.Collison,call,with={1}", LocalID, collidingWith); + // if someone is subscribed to collision events.... if (_subscribedEventsMs != 0) { // throttle the collisions to the number of milliseconds specified in the subscription @@ -1387,7 +1385,9 @@ public sealed class BSPrim : PhysicsActor if (collisionCollection != null && collisionCollection.Count > 0) { base.SendCollisionUpdate(collisionCollection); - collisionCollection.Clear(); + // The collisionCollection structure is passed around in the simulator. + // Make sure we don't have a handle to that one and that a new one is used next time. + collisionCollection = null; } } -- cgit v1.1 From 68f112888bd02b33e3b2f58f5b2adb90ce23e84b Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 15 Aug 2012 11:33:38 -0700 Subject: BulletSim: clean up detail logging by adding many more debug log statements and then commenting out most of the additions. --- .../Region/Physics/BulletSPlugin/BSCharacter.cs | 2 + .../Region/Physics/BulletSPlugin/BSConstraint.cs | 6 +++ OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 2 +- OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 60 +++++++++++----------- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 8 +-- 5 files changed, 44 insertions(+), 34 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index d288ab7..e2f7af9 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -488,9 +488,11 @@ public class BSCharacter : PhysicsActor // Avatars don't report their changes the usual way. Changes are checked for in the heartbeat loop. // base.RequestPhysicsterseUpdate(); + /* DetailLog("{0},BSCharacter.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}", LocalID, entprop.Position, entprop.Rotation, entprop.Velocity, entprop.Acceleration, entprop.RotationalVelocity); + */ } // Called by the scene when a collision with this object is reported diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs index cf8dbc5..25084d8 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs @@ -97,8 +97,14 @@ public abstract class BSConstraint : IDisposable ret = CalculateTransforms(); if (ret) { + // m_world.scene.PhysicsLogging.Write("{0},BSConstraint.RecomputeConstraintVariables,taint,enabling,A={1},B={2}", + // BSScene.DetailLogZero, Body1.ID, Body2.ID); BulletSimAPI.SetConstraintEnable2(m_constraint.Ptr, m_world.scene.NumericBool(true)); } + else + { + m_world.scene.Logger.ErrorFormat("[BULLETSIM CONSTRAINT] CalculateTransforms failed. A={0}, B={1}", Body1.ID, Body2.ID); + } } return ret; } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index c197e61..5a9f135 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs @@ -613,7 +613,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin MoveAngular(pTimestep); LimitRotation(pTimestep); - DetailLog("{0},Dynamics,done,pos={1},force={2},velocity={3},angvel={4}", + DetailLog("{0},BSDynamics.Step,done,pos={1},force={2},velocity={3},angvel={4}", m_prim.LocalID, m_prim.Position, m_prim.Force, m_prim.Velocity, m_prim.RotationalVelocity); }// end Step diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 38a9e46..9c20004 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -163,13 +163,13 @@ public sealed class BSPrim : PhysicsActor // m_log.DebugFormat("{0}: Destroy, id={1}", LogHeader, LocalID); // Undo any links between me and any other object - BSPrim parentBefore = _linkset.Root; + BSPrim parentBefore = _linkset.LinksetRoot; int childrenBefore = _linkset.NumberOfChildren; _linkset = _linkset.RemoveMeFromLinkset(this); DetailLog("{0},BSPrim.Destroy,call,parentBefore={1},childrenBefore={2},parentAfter={3},childrenAfter={4}", - LocalID, parentBefore.LocalID, childrenBefore, _linkset.Root.LocalID, _linkset.NumberOfChildren); + LocalID, parentBefore.LocalID, childrenBefore, _linkset.LinksetRoot.LocalID, _linkset.NumberOfChildren); // Undo any vehicle properties this.VehicleType = (int)Vehicle.TYPE_NONE; @@ -233,13 +233,13 @@ public sealed class BSPrim : PhysicsActor if (parent != null) { DebugLog("{0}: link {1}/{2} to {3}", LogHeader, _avName, _localID, parent.LocalID); - BSPrim parentBefore = _linkset.Root; + BSPrim parentBefore = _linkset.LinksetRoot; int childrenBefore = _linkset.NumberOfChildren; _linkset = parent.Linkset.AddMeToLinkset(this); DetailLog("{0},BSPrim.link,call,parentBefore={1}, childrenBefore=={2}, parentAfter={3}, childrenAfter={4}", - LocalID, parentBefore.LocalID, childrenBefore, _linkset.Root.LocalID, _linkset.NumberOfChildren); + LocalID, parentBefore.LocalID, childrenBefore, _linkset.LinksetRoot.LocalID, _linkset.NumberOfChildren); } return; } @@ -249,15 +249,15 @@ public sealed class BSPrim : PhysicsActor // TODO: decide if this parent checking needs to happen at taint time // Race condition here: if link() and delink() in same simulation tick, the delink will not happen DebugLog("{0}: delink {1}/{2}. Parent={3}", LogHeader, _avName, _localID, - _linkset.Root._avName+"/"+_linkset.Root.LocalID.ToString()); + _linkset.LinksetRoot._avName+"/"+_linkset.LinksetRoot.LocalID.ToString()); - BSPrim parentBefore = _linkset.Root; + BSPrim parentBefore = _linkset.LinksetRoot; int childrenBefore = _linkset.NumberOfChildren; _linkset = _linkset.RemoveMeFromLinkset(this); DetailLog("{0},BSPrim.delink,parentBefore={1},childrenBefore={2},parentAfter={3},childrenAfter={4}, ", - LocalID, parentBefore.LocalID, childrenBefore, _linkset.Root.LocalID, _linkset.NumberOfChildren); + LocalID, parentBefore.LocalID, childrenBefore, _linkset.LinksetRoot.LocalID, _linkset.NumberOfChildren); return; } @@ -280,7 +280,7 @@ public sealed class BSPrim : PhysicsActor public override void LockAngularMotion(OMV.Vector3 axis) { - DetailLog("{0},BSPrim.LockAngularMotion,call,axis={1}", LocalID, axis); + // DetailLog("{0},BSPrim.LockAngularMotion,call,axis={1}", LocalID, axis); return; } @@ -299,7 +299,7 @@ public sealed class BSPrim : PhysicsActor // TODO: what does it mean to set the position of a child prim?? Rebuild the constraint? _scene.TaintedObject("BSPrim.setPosition", delegate() { - DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); + // DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation); }); } @@ -336,7 +336,7 @@ public sealed class BSPrim : PhysicsActor _force = value; _scene.TaintedObject("BSPrim.setForce", delegate() { - DetailLog("{0},BSPrim.setForce,taint,force={1}", LocalID, _force); + // DetailLog("{0},BSPrim.setForce,taint,force={1}", LocalID, _force); // BulletSimAPI.SetObjectForce(_scene.WorldID, _localID, _force); BulletSimAPI.SetObjectForce2(Body.Ptr, _force); }); @@ -414,7 +414,7 @@ public sealed class BSPrim : PhysicsActor _velocity = value; _scene.TaintedObject("BSPrim.setVelocity", delegate() { - DetailLog("{0},BSPrim.SetVelocity,taint,vel={1}", LocalID, _velocity); + // DetailLog("{0},BSPrim.SetVelocity,taint,vel={1}", LocalID, _velocity); BulletSimAPI.SetObjectVelocity(_scene.WorldID, LocalID, _velocity); }); } @@ -422,7 +422,7 @@ public sealed class BSPrim : PhysicsActor public override OMV.Vector3 Torque { get { return _torque; } set { _torque = value; - DetailLog("{0},BSPrim.SetTorque,call,torque={1}", LocalID, _torque); + // DetailLog("{0},BSPrim.SetTorque,call,torque={1}", LocalID, _torque); } } public override float CollisionScore { @@ -449,7 +449,7 @@ public sealed class BSPrim : PhysicsActor _scene.TaintedObject("BSPrim.setOrientation", delegate() { // _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID); - DetailLog("{0},BSPrim.setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation); + // DetailLog("{0},BSPrim.setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation); BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation); }); } @@ -501,7 +501,7 @@ public sealed class BSPrim : PhysicsActor _linkset.Refresh(this); CollisionFlags cf = BulletSimAPI.GetCollisionFlags2(Body.Ptr); - DetailLog("{0},BSPrim.SetObjectDynamic,taint,static={1},solid={2},mass={3}, cf={4}", LocalID, IsStatic, IsSolid, mass, cf); + // DetailLog("{0},BSPrim.SetObjectDynamic,taint,static={1},solid={2},mass={3}, cf={4}", LocalID, IsStatic, IsSolid, mass, cf); } // prims don't fly @@ -558,7 +558,7 @@ public sealed class BSPrim : PhysicsActor // m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity); _scene.TaintedObject("BSPrim.setRotationalVelocity", delegate() { - DetailLog("{0},BSPrim.SetRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity); + // DetailLog("{0},BSPrim.SetRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity); BulletSimAPI.SetObjectAngularVelocity(_scene.WorldID, LocalID, _rotationalVelocity); }); } @@ -575,7 +575,7 @@ public sealed class BSPrim : PhysicsActor _buoyancy = value; _scene.TaintedObject("BSPrim.setBuoyancy", delegate() { - DetailLog("{0},BSPrim.SetBuoyancy,taint,buoy={1}", LocalID, _buoyancy); + // DetailLog("{0},BSPrim.SetBuoyancy,taint,buoy={1}", LocalID, _buoyancy); BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, _localID, _buoyancy); }); } @@ -638,17 +638,17 @@ public sealed class BSPrim : PhysicsActor } m_accumulatedForces.Clear(); } - DetailLog("{0},BSPrim.AddObjectForce,taint,force={1}", LocalID, _force); + // DetailLog("{0},BSPrim.AddObjectForce,taint,force={1}", LocalID, _force); BulletSimAPI.AddObjectForce2(Body.Ptr, fSum); }); } public override void AddAngularForce(OMV.Vector3 force, bool pushforce) { - DetailLog("{0},BSPrim.AddAngularForce,call,angForce={1},push={2}", LocalID, force, pushforce); + // DetailLog("{0},BSPrim.AddAngularForce,call,angForce={1},push={2}", LocalID, force, pushforce); // m_log.DebugFormat("{0}: AddAngularForce. f={1}, push={2}", LogHeader, force, pushforce); } public override void SetMomentum(OMV.Vector3 momentum) { - DetailLog("{0},BSPrim.SetMomentum,call,mom={1}", LocalID, momentum); + // DetailLog("{0},BSPrim.SetMomentum,call,mom={1}", LocalID, momentum); } public override void SubscribeEvents(int ms) { _subscribedEventsMs = ms; @@ -992,7 +992,7 @@ public sealed class BSPrim : PhysicsActor // m_log.DebugFormat("{0}: CreateGeom: Defaulting to sphere of size {1}", LogHeader, _size); if (forceRebuild || (_shapeType != ShapeData.PhysicsShapeType.SHAPE_SPHERE)) { - DetailLog("{0},BSPrim.CreateGeom,sphere (force={1}", LocalID, forceRebuild); + // DetailLog("{0},BSPrim.CreateGeom,sphere (force={1}", LocalID, forceRebuild); _shapeType = ShapeData.PhysicsShapeType.SHAPE_SPHERE; // Bullet native objects are scaled by the Bullet engine so pass the size in _scale = _size; @@ -1006,7 +1006,7 @@ public sealed class BSPrim : PhysicsActor // m_log.DebugFormat("{0}: CreateGeom: Defaulting to box. lid={1}, type={2}, size={3}", LogHeader, LocalID, _shapeType, _size); if (forceRebuild || (_shapeType != ShapeData.PhysicsShapeType.SHAPE_BOX)) { - DetailLog("{0},BSPrim.CreateGeom,box (force={1})", LocalID, forceRebuild); + // DetailLog("{0},BSPrim.CreateGeom,box (force={1})", LocalID, forceRebuild); _shapeType = ShapeData.PhysicsShapeType.SHAPE_BOX; _scale = _size; // TODO: do we need to check for and destroy a mesh or hull that might have been left from before? @@ -1049,12 +1049,12 @@ public sealed class BSPrim : PhysicsActor // if this new shape is the same as last time, don't recreate the mesh if (_meshKey == newMeshKey) return; - DetailLog("{0},BSPrim.CreateGeomMesh,create,key={1}", LocalID, newMeshKey); + // DetailLog("{0},BSPrim.CreateGeomMesh,create,key={1}", LocalID, newMeshKey); // Since we're recreating new, get rid of any previously generated shape if (_meshKey != 0) { // m_log.DebugFormat("{0}: CreateGeom: deleting old mesh. lID={1}, Key={2}", LogHeader, _localID, _meshKey); - DetailLog("{0},BSPrim.CreateGeomMesh,deleteOld,key={1}", LocalID, _meshKey); + // DetailLog("{0},BSPrim.CreateGeomMesh,deleteOld,key={1}", LocalID, _meshKey); BulletSimAPI.DestroyMesh(_scene.WorldID, _meshKey); _mesh = null; _meshKey = 0; @@ -1084,7 +1084,7 @@ public sealed class BSPrim : PhysicsActor _shapeType = ShapeData.PhysicsShapeType.SHAPE_MESH; // meshes are already scaled by the meshmerizer _scale = new OMV.Vector3(1f, 1f, 1f); - DetailLog("{0},BSPrim.CreateGeomMesh,done", LocalID); + // DetailLog("{0},BSPrim.CreateGeomMesh,done", LocalID); return; } @@ -1098,13 +1098,13 @@ public sealed class BSPrim : PhysicsActor // if the hull hasn't changed, don't rebuild it if (newHullKey == _hullKey) return; - DetailLog("{0},BSPrim.CreateGeomHull,create,oldKey={1},newKey={2}", LocalID, _hullKey, newHullKey); + // DetailLog("{0},BSPrim.CreateGeomHull,create,oldKey={1},newKey={2}", LocalID, _hullKey, newHullKey); // Since we're recreating new, get rid of any previously generated shape if (_hullKey != 0) { // m_log.DebugFormat("{0}: CreateGeom: deleting old hull. Key={1}", LogHeader, _hullKey); - DetailLog("{0},BSPrim.CreateGeomHull,deleteOldHull,key={1}", LocalID, _hullKey); + // DetailLog("{0},BSPrim.CreateGeomHull,deleteOldHull,key={1}", LocalID, _hullKey); BulletSimAPI.DestroyHull(_scene.WorldID, _hullKey); _hullKey = 0; } @@ -1198,7 +1198,7 @@ public sealed class BSPrim : PhysicsActor _shapeType = ShapeData.PhysicsShapeType.SHAPE_HULL; // meshes are already scaled by the meshmerizer _scale = new OMV.Vector3(1f, 1f, 1f); - DetailLog("{0},BSPrim.CreateGeomHull,done", LocalID); + // DetailLog("{0},BSPrim.CreateGeomHull,done", LocalID); return; } @@ -1336,11 +1336,12 @@ public sealed class BSPrim : PhysicsActor // m_log.DebugFormat("{0}: RequestTerseUpdate. id={1}, ch={2}, pos={3}, rot={4}, vel={5}, acc={6}, rvel={7}", // LogHeader, LocalID, changed, _position, _orientation, _velocity, _acceleration, _rotationalVelocity); - DetailLog("{0},BSPrim.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}", - LocalID, _position, _orientation, _velocity, _acceleration, _rotationalVelocity); + // DetailLog("{0},BSPrim.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}", + // LocalID, _position, _orientation, _velocity, _acceleration, _rotationalVelocity); base.RequestPhysicsterseUpdate(); } + /* else { // For debugging, we also report the movement of children @@ -1348,6 +1349,7 @@ public sealed class BSPrim : PhysicsActor LocalID, entprop.Position, entprop.Rotation, entprop.Velocity, entprop.Acceleration, entprop.RotationalVelocity); } + */ } // I've collided with something diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index cacab01..a31c578 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -362,7 +362,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters BSPrim bsprim = prim as BSPrim; if (bsprim != null) { - DetailLog("{0},RemovePrim,call", bsprim.LocalID); + // DetailLog("{0},RemovePrim,call", bsprim.LocalID); // m_log.DebugFormat("{0}: RemovePrim. id={1}/{2}", LogHeader, bsprim.Name, bsprim.LocalID); try { @@ -388,7 +388,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters if (!m_initialized) return null; - DetailLog("{0},AddPrimShape,call", localID); + // DetailLog("{0},AddPrimShape,call", localID); BSPrim prim = new BSPrim(localID, primName, this, position, size, rotation, pbs, isPhysical); lock (m_prims) m_prims.Add(localID, prim); @@ -429,12 +429,12 @@ public class BSScene : PhysicsScene, IPhysicsParameters { numSubSteps = BulletSimAPI.PhysicsStep(m_worldID, timeStep, m_maxSubSteps, m_fixedTimeStep, out updatedEntityCount, out updatedEntitiesPtr, out collidersCount, out collidersPtr); - DetailLog("{0},Simulate,call, substeps={1}, updates={2}, colliders={3}", DetailLogZero, numSubSteps, updatedEntityCount, collidersCount); + // DetailLog("{0},Simulate,call, substeps={1}, updates={2}, colliders={3}", DetailLogZero, numSubSteps, updatedEntityCount, collidersCount); } catch (Exception e) { m_log.WarnFormat("{0},PhysicsStep Exception: substeps={1}, updates={2}, colliders={3}, e={4}", LogHeader, numSubSteps, updatedEntityCount, collidersCount, e); - DetailLog("{0},PhysicsStepException,call, substeps={1}, updates={2}, colliders={3}", DetailLogZero, numSubSteps, updatedEntityCount, collidersCount); + // DetailLog("{0},PhysicsStepException,call, substeps={1}, updates={2}, colliders={3}", DetailLogZero, numSubSteps, updatedEntityCount, collidersCount); // updatedEntityCount = 0; collidersCount = 0; } -- cgit v1.1 From 9efe7bf7ba741b0d61ef71c09b5848c424e3c258 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 15 Aug 2012 11:36:21 -0700 Subject: BulletSim: add locking to constraintCollection and rename some of the public method variables to reduce confusion between a physics scene and the real scene. --- .../BulletSPlugin/BSConstraintCollection.cs | 94 ++++---- OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs | 250 +++++++++++++-------- 2 files changed, 197 insertions(+), 147 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs index 862b744..22ea367 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs @@ -56,21 +56,25 @@ public class BSConstraintCollection : IDisposable public void Clear() { - foreach (BSConstraint cons in m_constraints) + lock (m_constraints) { - cons.Dispose(); + foreach (BSConstraint cons in m_constraints) + { + cons.Dispose(); + } + m_constraints.Clear(); } - m_constraints.Clear(); } public bool AddConstraint(BSConstraint cons) { - // There is only one constraint between any bodies. Remove any old just to make sure. - RemoveAndDestroyConstraint(cons.Body1, cons.Body2); - - m_world.scene.DetailLog("{0},BSConstraintCollection.AddConstraint,call,body1={1},body2={2}", BSScene.DetailLogZero, cons.Body1.ID, cons.Body2.ID); + lock (m_constraints) + { + // There is only one constraint between any bodies. Remove any old just to make sure. + RemoveAndDestroyConstraint(cons.Body1, cons.Body2); - m_constraints.Add(cons); + m_constraints.Add(cons); + } return true; } @@ -84,16 +88,19 @@ public class BSConstraintCollection : IDisposable uint lookingID1 = body1.ID; uint lookingID2 = body2.ID; - ForEachConstraint(delegate(BSConstraint constrain) + lock (m_constraints) { - if ((constrain.Body1.ID == lookingID1 && constrain.Body2.ID == lookingID2) - || (constrain.Body1.ID == lookingID2 && constrain.Body2.ID == lookingID1)) + foreach (BSConstraint constrain in m_constraints) { - foundConstraint = constrain; - found = true; + if ((constrain.Body1.ID == lookingID1 && constrain.Body2.ID == lookingID2) + || (constrain.Body1.ID == lookingID2 && constrain.Body2.ID == lookingID1)) + { + foundConstraint = constrain; + found = true; + break; + } } - return found; - }); + } returnConstraint = foundConstraint; return found; } @@ -103,17 +110,16 @@ public class BSConstraintCollection : IDisposable // Return 'true' if a constraint was found and destroyed. public bool RemoveAndDestroyConstraint(BulletBody body1, BulletBody body2) { - // return BulletSimAPI.RemoveConstraint(m_world.ID, obj1.ID, obj2.ID); - bool ret = false; - BSConstraint constrain; - - if (this.TryGetConstraint(body1, body2, out constrain)) + lock (m_constraints) { - m_world.scene.DetailLog("{0},BSConstraintCollection.RemoveAndDestroyConstraint,taint,body1={1},body2={2}", BSScene.DetailLogZero, body1.ID, body2.ID); - // remove the constraint from our collection - RemoveAndDestroyConstraint(constrain); - ret = true; + BSConstraint constrain; + if (this.TryGetConstraint(body1, body2, out constrain)) + { + // remove the constraint from our collection + RemoveAndDestroyConstraint(constrain); + ret = true; + } } return ret; @@ -122,8 +128,11 @@ public class BSConstraintCollection : IDisposable // The constraint MUST exist in the collection public bool RemoveAndDestroyConstraint(BSConstraint constrain) { - // remove the constraint from our collection - m_constraints.Remove(constrain); + lock (m_constraints) + { + // remove the constraint from our collection + m_constraints.Remove(constrain); + } // tell the engine that all its structures need to be freed constrain.Dispose(); // we destroyed something @@ -138,16 +147,15 @@ public class BSConstraintCollection : IDisposable List toRemove = new List(); uint lookingID = body1.ID; - ForEachConstraint(delegate(BSConstraint constrain) + lock (m_constraints) { - if (constrain.Body1.ID == lookingID || constrain.Body2.ID == lookingID) + foreach (BSConstraint constrain in m_constraints) { - toRemove.Add(constrain); + if (constrain.Body1.ID == lookingID || constrain.Body2.ID == lookingID) + { + toRemove.Add(constrain); + } } - return false; - }); - lock (m_constraints) - { foreach (BSConstraint constrain in toRemove) { m_constraints.Remove(constrain); @@ -159,28 +167,16 @@ public class BSConstraintCollection : IDisposable public bool RecalculateAllConstraints() { - ForEachConstraint(delegate(BSConstraint constrain) - { - constrain.CalculateTransforms(); - return false; - }); - return true; - } - - // Lock the constraint list and loop through it. - // The constraint action returns 'true' if it wants the loop aborted. - private void ForEachConstraint(ConstraintAction action) - { + bool ret = false; lock (m_constraints) { foreach (BSConstraint constrain in m_constraints) { - if (action(constrain)) - break; + constrain.CalculateTransforms(); + ret = true; } } + return ret; } - - } } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs index 4a71612..087b9bb 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs @@ -37,11 +37,12 @@ public class BSLinkset private static string LogHeader = "[BULLETSIM LINKSET]"; private BSPrim m_linksetRoot; - public BSPrim Root { get { return m_linksetRoot; } } + public BSPrim LinksetRoot { get { return m_linksetRoot; } } - private BSScene m_scene; - public BSScene Scene { get { return m_scene; } } + private BSScene m_physicsScene; + public BSScene PhysicsScene { get { return m_physicsScene; } } + // The children under the root in this linkset private List m_children; // We lock the diddling of linkset classes to prevent any badness. @@ -73,7 +74,7 @@ public class BSLinkset public BSLinkset(BSScene scene, BSPrim parent) { // A simple linkset of one (no children) - m_scene = scene; + m_physicsScene = scene; m_linksetRoot = parent; m_children = new List(); m_mass = parent.MassRaw; @@ -91,6 +92,9 @@ public class BSLinkset return this; } + // Remove a child from a linkset. + // Returns a new linkset for the child which is a linkset of one (just the + // orphened child). public BSLinkset RemoveMeFromLinkset(BSPrim child) { lock (m_linksetActivityLock) @@ -114,60 +118,9 @@ public class BSLinkset } // The child is down to a linkset of just itself - return new BSLinkset(Scene, child); + return new BSLinkset(PhysicsScene, child); } - /* DEPRECATED: this is really bad in that it trys to unlink other prims. - // An existing linkset had one of its members rebuilt or something. - // Go through the linkset and rebuild the pointers to the bodies of the linkset members. - public BSLinkset RefreshLinkset(BSPrim requestor) - { - BSLinkset ret = requestor.Linkset; - - lock (m_linksetActivityLock) - { - // The body pointer is refetched in case anything has moved. - System.IntPtr aPtr = BulletSimAPI.GetBodyHandle2(m_scene.World.Ptr, m_linksetRoot.LocalID); - if (aPtr == System.IntPtr.Zero) - { - // That's odd. We can't find the root of the linkset. - // The linkset is somehow dead. The requestor is now a member of a linkset of one. - DetailLog("{0},RefreshLinkset.RemoveRoot,child={1}", m_linksetRoot.LocalID, m_linksetRoot.LocalID); - ret = RemoveMeFromLinkset(m_linksetRoot); - } - else - { - // Reconstruct the pointer to the body of the linkset root. - DetailLog("{0},RefreshLinkset.RebuildRoot,rootID={1},ptr={2}", m_linksetRoot.LocalID, m_linksetRoot.LocalID, aPtr); - m_linksetRoot.Body = new BulletBody(m_linksetRoot.LocalID, aPtr); - - List toRemove = new List(); - foreach (BSPrim bsp in m_children) - { - aPtr = BulletSimAPI.GetBodyHandle2(m_scene.World.Ptr, bsp.LocalID); - if (aPtr == System.IntPtr.Zero) - { - toRemove.Add(bsp); - } - else - { - // Reconstruct the pointer to the body of the linkset root. - DetailLog("{0},RefreshLinkset.RebuildChild,rootID={1},ptr={2}", bsp.LocalID, m_linksetRoot.LocalID, aPtr); - bsp.Body = new BulletBody(bsp.LocalID, aPtr); - } - } - foreach (BSPrim bsp in toRemove) - { - RemoveChildFromOtherLinkset(bsp); - } - } - } - - return ret; - } - */ - - // Return 'true' if the passed object is the root object of this linkset public bool IsRoot(BSPrim requestor) { @@ -183,12 +136,15 @@ public class BSLinkset public bool HasChild(BSPrim child) { bool ret = false; - foreach (BSPrim bp in m_children) + lock (m_linksetActivityLock) { - if (child.LocalID == bp.LocalID) + foreach (BSPrim bp in m_children) { - ret = true; - break; + if (child.LocalID == bp.LocalID) + { + ret = true; + break; + } } } return ret; @@ -209,13 +165,16 @@ public class BSLinkset OMV.Vector3 com = m_linksetRoot.Position * m_linksetRoot.MassRaw; float totalMass = m_linksetRoot.MassRaw; - foreach (BSPrim bp in m_children) + lock (m_linksetActivityLock) { - com += bp.Position * bp.MassRaw; - totalMass += bp.MassRaw; + foreach (BSPrim bp in m_children) + { + com += bp.Position * bp.MassRaw; + totalMass += bp.MassRaw; + } + if (totalMass != 0f) + com /= totalMass; } - if (totalMass != 0f) - com /= totalMass; return com; } @@ -224,29 +183,84 @@ public class BSLinkset { OMV.Vector3 com = m_linksetRoot.Position; - foreach (BSPrim bp in m_children) + lock (m_linksetActivityLock) { - com += bp.Position * bp.MassRaw; + foreach (BSPrim bp in m_children) + { + com += bp.Position * bp.MassRaw; + } + com /= (m_children.Count + 1); } - com /= (m_children.Count + 1); return com; } + // When physical properties are changed the linkset needs to recalculate + // its internal properties. + public void Refresh(BSPrim requestor) + { + // If there are no children, there aren't any constraints to recompute + if (!HasAnyChildren) + return; + + // Only the root does the recomputation + if (IsRoot(requestor)) + { + PhysicsScene.TaintedObject("BSLinkSet.Refresh", delegate() + { + RecomputeLinksetConstraintVariables(); + }); + } + } + + // Call each of the constraints that make up this linkset and recompute the + // various transforms and variables. Used when objects are added or removed + // from a linkset to make sure the constraints know about the new mass and + // geometry. + // Must only be called at taint time!! + private bool RecomputeLinksetConstraintVariables() + { + float linksetMass = LinksetMass; + lock (m_linksetActivityLock) + { + foreach (BSPrim child in m_children) + { + BSConstraint constrain; + if (m_physicsScene.Constraints.TryGetConstraint(LinksetRoot.Body, child.Body, out constrain)) + { + // DetailLog("{0},BSLinkset.RecomputeLinksetConstraintVariables,taint,child={1},mass={2},A={3},B={4}", + // LinksetRoot.LocalID, child.LocalID, linksetMass, constrain.Body1.ID, constrain.Body2.ID); + constrain.RecomputeConstraintVariables(linksetMass); + } + else + { + // Non-fatal error that can happen when children are being added to the linkset but + // their constraints have not been created yet. + // Caused by the fact that m_children is built at run time but building constraints + // happens at taint time. + // m_physicsScene.Logger.ErrorFormat("[BULLETSIM LINKSET] RecomputeLinksetConstraintVariables: constraint not found for root={0}, child={1}", + // m_linksetRoot.Body.ID, child.Body.ID); + } + } + } + return false; + } + // I am the root of a linkset and a new child is being added // Called while LinkActivity is locked. - public void AddChildToLinkset(BSPrim child) + private void AddChildToLinkset(BSPrim child) { if (!HasChild(child)) { m_children.Add(child); - BSPrim root = Root; // capture the root as of now - m_scene.TaintedObject("AddChildToLinkset", delegate() + BSPrim rootx = LinksetRoot; // capture the root as of now + BSPrim childx = child; + m_physicsScene.TaintedObject("AddChildToLinkset", delegate() { - DebugLog("{0}: AddChildToLinkset: adding child {1} to {2}", LogHeader, child.LocalID, m_linksetRoot.LocalID); - DetailLog("{0},AddChildToLinkset,taint,child={1}", m_linksetRoot.LocalID, child.LocalID); - PhysicallyLinkAChildToRoot(root, child); // build the physical binding between me and the child + // DebugLog("{0}: AddChildToLinkset: adding child {1} to {2}", LogHeader, child.LocalID, m_linksetRoot.LocalID); + // DetailLog("{0},AddChildToLinkset,taint,child={1}", m_linksetRoot.LocalID, child.LocalID); + PhysicallyLinkAChildToRoot(rootx, childx); // build the physical binding between me and the child }); } return; @@ -257,31 +271,34 @@ public class BSLinkset // it's still connected to the linkset. // Normal OpenSimulator operation will never do this because other SceneObjectPart information // has to be updated also (like pointer to prim's parent). - public void RemoveChildFromOtherLinkset(BSPrim pchild) + private void RemoveChildFromOtherLinkset(BSPrim pchild) { - pchild.Linkset = new BSLinkset(m_scene, pchild); + pchild.Linkset = new BSLinkset(m_physicsScene, pchild); RemoveChildFromLinkset(pchild); } // I am the root of a linkset and one of my children is being removed. // Safe to call even if the child is not really in my linkset. - public void RemoveChildFromLinkset(BSPrim child) + private void RemoveChildFromLinkset(BSPrim child) { if (m_children.Remove(child)) { - BSPrim root = Root; // capture the root as of now - m_scene.TaintedObject("RemoveChildFromLinkset", delegate() + BSPrim rootx = LinksetRoot; // capture the root as of now + BSPrim childx = child; + m_physicsScene.TaintedObject("RemoveChildFromLinkset", delegate() { - DebugLog("{0}: RemoveChildFromLinkset: Removing constraint to {1}", LogHeader, child.LocalID); - DetailLog("{0},RemoveChildFromLinkset,taint,child={1}", m_linksetRoot.LocalID, child.LocalID); + // DebugLog("{0}: RemoveChildFromLinkset: Removing constraint to {1}", LogHeader, child.LocalID); + // DetailLog("{0},RemoveChildFromLinkset,taint,child={1}", m_linksetRoot.LocalID, child.LocalID); - PhysicallyUnlinkAChildFromRoot(root, child); + PhysicallyUnlinkAChildFromRoot(rootx, childx); }); + + RecomputeLinksetConstraintVariables(); } else { // This will happen if we remove the root of the linkset first. Non-fatal occurance. - // m_scene.Logger.ErrorFormat("{0}: Asked to remove child from linkset that was not in linkset", LogHeader); + // PhysicsScene.Logger.ErrorFormat("{0}: Asked to remove child from linkset that was not in linkset", LogHeader); } return; } @@ -293,37 +310,72 @@ public class BSLinkset // Zero motion for children so they don't interpolate childPrim.ZeroMotion(); + // Relative position normalized to the root prim + // Essentually a vector pointing from center of rootPrim to center of childPrim + OMV.Vector3 childRelativePosition = childPrim.Position - rootPrim.Position; + + // real world coordinate of midpoint between the two objects + OMV.Vector3 midPoint = rootPrim.Position + (childRelativePosition / 2); + + // create a constraint that allows no freedom of movement between the two objects + // http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4818 + // DebugLog("{0}: CreateLinkset: Adding a constraint between root prim {1} and child prim {2}", LogHeader, LocalID, childPrim.LocalID); + DetailLog("{0},PhysicallyLinkAChildToRoot,taint,root={1},child={2},rLoc={3},cLoc={4},midLoc={5}", + rootPrim.LocalID, rootPrim.LocalID, childPrim.LocalID, rootPrim.Position, childPrim.Position, midPoint); + BS6DofConstraint constrain = new BS6DofConstraint( + m_physicsScene.World, rootPrim.Body, childPrim.Body, + midPoint, + true, + true + ); + /* NOTE: attempt to build constraint with full frame computation, etc. + * Using the midpoint is easier since it lets the Bullet code use the transforms + * of the objects. + * Code left here as an example. + // ================================================================================== // relative position normalized to the root prim OMV.Quaternion invThisOrientation = OMV.Quaternion.Inverse(rootPrim.Orientation); OMV.Vector3 childRelativePosition = (childPrim.Position - rootPrim.Position) * invThisOrientation; // relative rotation of the child to the parent OMV.Quaternion childRelativeRotation = invThisOrientation * childPrim.Orientation; + OMV.Quaternion inverseChildRelativeRotation = OMV.Quaternion.Inverse(childRelativeRotation); // create a constraint that allows no freedom of movement between the two objects // http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4818 // DebugLog("{0}: CreateLinkset: Adding a constraint between root prim {1} and child prim {2}", LogHeader, LocalID, childPrim.LocalID); DetailLog("{0},PhysicallyLinkAChildToRoot,taint,root={1},child={2}", rootPrim.LocalID, rootPrim.LocalID, childPrim.LocalID); BS6DofConstraint constrain = new BS6DofConstraint( - m_scene.World, rootPrim.Body, childPrim.Body, - childRelativePosition, - childRelativeRotation, + PhysicsScene.World, rootPrim.Body, childPrim.Body, OMV.Vector3.Zero, - -childRelativeRotation + OMV.Quaternion.Inverse(rootPrim.Orientation), + OMV.Vector3.Zero, + OMV.Quaternion.Inverse(childPrim.Orientation), + // A point half way between the parent and child + // childRelativePosition/2, + // childRelativeRotation, + // childRelativePosition/2, + // inverseChildRelativeRotation, + true, + true ); - m_scene.Constraints.AddConstraint(constrain); + // ================================================================================== + */ + + m_physicsScene.Constraints.AddConstraint(constrain); // zero linear and angular limits makes the objects unable to move in relation to each other constrain.SetLinearLimits(OMV.Vector3.Zero, OMV.Vector3.Zero); constrain.SetAngularLimits(OMV.Vector3.Zero, OMV.Vector3.Zero); // tweek the constraint to increase stability - constrain.UseFrameOffset(m_scene.BoolNumeric(m_scene.Params.linkConstraintUseFrameOffset)); - constrain.TranslationalLimitMotor(m_scene.BoolNumeric(m_scene.Params.linkConstraintEnableTransMotor), - m_scene.Params.linkConstraintTransMotorMaxVel, - m_scene.Params.linkConstraintTransMotorMaxForce); - constrain.SetCFMAndERP(m_scene.Params.linkConstraintCFM, m_scene.Params.linkConstraintERP); + constrain.UseFrameOffset(PhysicsScene.BoolNumeric(PhysicsScene.Params.linkConstraintUseFrameOffset)); + constrain.TranslationalLimitMotor(PhysicsScene.BoolNumeric(PhysicsScene.Params.linkConstraintEnableTransMotor), + PhysicsScene.Params.linkConstraintTransMotorMaxVel, + PhysicsScene.Params.linkConstraintTransMotorMaxForce); + constrain.SetCFMAndERP(PhysicsScene.Params.linkConstraintCFM, PhysicsScene.Params.linkConstraintERP); + RecomputeLinksetConstraintVariables(); } // Remove linkage between myself and a particular child @@ -334,7 +386,9 @@ public class BSLinkset // LogHeader, rootPrim.LocalID, childPrim.LocalID); DetailLog("{0},PhysicallyUnlinkAChildFromRoot,taint,root={1},child={2}", rootPrim.LocalID, rootPrim.LocalID, childPrim.LocalID); - m_scene.Constraints.RemoveAndDestroyConstraint(rootPrim.Body, childPrim.Body); + // Find the constraint for this link and get rid of it from the overall collection and from my list + m_physicsScene.Constraints.RemoveAndDestroyConstraint(rootPrim.Body, childPrim.Body); + // Make the child refresh its location BulletSimAPI.PushUpdate2(childPrim.Body.Ptr); } @@ -346,20 +400,20 @@ public class BSLinkset // DebugLog("{0}: PhysicallyUnlinkAllChildren:", LogHeader); DetailLog("{0},PhysicallyUnlinkAllChildren,taint", rootPrim.LocalID); - m_scene.Constraints.RemoveAndDestroyConstraint(rootPrim.Body); + m_physicsScene.Constraints.RemoveAndDestroyConstraint(rootPrim.Body); } // Invoke the detailed logger and output something if it's enabled. private void DebugLog(string msg, params Object[] args) { - if (m_scene.ShouldDebugLog) - m_scene.Logger.DebugFormat(msg, args); + if (m_physicsScene.ShouldDebugLog) + m_physicsScene.Logger.DebugFormat(msg, args); } // Invoke the detailed logger and output something if it's enabled. private void DetailLog(string msg, params Object[] args) { - m_scene.PhysicsLogging.Write(msg, args); + m_physicsScene.PhysicsLogging.Write(msg, args); } } -- cgit v1.1 From dd10cf01e70f757f70f18d442974688a45a2d433 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 15 Aug 2012 11:36:50 -0700 Subject: BulletSim: add hinge constraint. Update BulletSimAPI with new constraint related function calls. Reorganize locking in BS6DofConstraint. Update BS6DofConstraint to do constraint reset correctly. Add new 'midpoint' construction of 6Dof constraint. --- .../Physics/BulletSPlugin/BS6DofConstraint.cs | 50 +++++++++++++++++--- .../Physics/BulletSPlugin/BSHingeConstraint.cs | 55 ++++++++++++++++++++++ .../Region/Physics/BulletSPlugin/BulletSimAPI.cs | 27 +++++++++++ 3 files changed, 126 insertions(+), 6 deletions(-) create mode 100755 OpenSim/Region/Physics/BulletSPlugin/BSHingeConstraint.cs (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BS6DofConstraint.cs b/OpenSim/Region/Physics/BulletSPlugin/BS6DofConstraint.cs index 72df6b9..683bc51 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BS6DofConstraint.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BS6DofConstraint.cs @@ -37,7 +37,8 @@ public class BS6DofConstraint : BSConstraint // Create a btGeneric6DofConstraint public BS6DofConstraint(BulletSim world, BulletBody obj1, BulletBody obj2, Vector3 frame1, Quaternion frame1rot, - Vector3 frame2, Quaternion frame2rot ) + Vector3 frame2, Quaternion frame2rot, + bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) { m_world = world; m_body1 = obj1; @@ -46,16 +47,45 @@ public class BS6DofConstraint : BSConstraint BulletSimAPI.Create6DofConstraint2(m_world.Ptr, m_body1.Ptr, m_body2.Ptr, frame1, frame1rot, frame2, frame2rot, - true /*useLinearReferenceFrameA*/, true /*disableCollisionsBetweenLinkedBodies*/)); + useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies)); m_enabled = true; } + public BS6DofConstraint(BulletSim world, BulletBody obj1, BulletBody obj2, + Vector3 joinPoint, + bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) + { + m_world = world; + m_body1 = obj1; + m_body2 = obj2; + m_constraint = new BulletConstraint( + BulletSimAPI.Create6DofConstraintToPoint2(m_world.Ptr, m_body1.Ptr, m_body2.Ptr, + joinPoint, + useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies)); + m_enabled = true; + } + + public bool SetFrames(Vector3 frameA, Quaternion frameArot, Vector3 frameB, Quaternion frameBrot) + { + bool ret = false; + if (m_enabled) + { + BulletSimAPI.SetFrames2(m_constraint.Ptr, frameA, frameArot, frameB, frameBrot); + ret = true; + } + return ret; + } + public bool SetCFMAndERP(float cfm, float erp) { - bool ret = true; - BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_STOP_CFM, cfm, ConstraintParamAxis.AXIS_ALL); - BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_STOP_ERP, erp, ConstraintParamAxis.AXIS_ALL); - BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_CFM, cfm, ConstraintParamAxis.AXIS_ALL); + bool ret = false; + if (m_enabled) + { + BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_STOP_CFM, cfm, ConstraintParamAxis.AXIS_ALL); + BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_STOP_ERP, erp, ConstraintParamAxis.AXIS_ALL); + BulletSimAPI.SetConstraintParam2(m_constraint.Ptr, ConstraintParams.BT_CONSTRAINT_CFM, cfm, ConstraintParamAxis.AXIS_ALL); + ret = true; + } return ret; } @@ -76,5 +106,13 @@ public class BS6DofConstraint : BSConstraint ret = BulletSimAPI.TranslationalLimitMotor2(m_constraint.Ptr, onOff, targetVelocity, maxMotorForce); return ret; } + + public bool SetBreakingImpulseThreshold(float threshold) + { + bool ret = false; + if (m_enabled) + ret = BulletSimAPI.SetBreakingImpulseThreshold2(m_constraint.Ptr, threshold); + return ret; + } } } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSHingeConstraint.cs b/OpenSim/Region/Physics/BulletSPlugin/BSHingeConstraint.cs new file mode 100755 index 0000000..d68048b --- /dev/null +++ b/OpenSim/Region/Physics/BulletSPlugin/BSHingeConstraint.cs @@ -0,0 +1,55 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyrightD + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; + +namespace OpenSim.Region.Physics.BulletSPlugin +{ + +class BSHingeConstraint : BSConstraint +{ + public BSHingeConstraint(BulletSim world, BulletBody obj1, BulletBody obj2, + Vector3 pivotInA, Vector3 pivotInB, + Vector3 axisInA, Vector3 axisInB, + bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) + { + m_world = world; + m_body1 = obj1; + m_body2 = obj2; + m_constraint = new BulletConstraint( + BulletSimAPI.CreateHingeConstraint2(m_world.Ptr, m_body1.Ptr, m_body2.Ptr, + pivotInA, pivotInB, + axisInA, axisInB, + useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies)); + m_enabled = true; + } + +} + +} diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs index 6800b96..504bd3c 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs @@ -416,6 +416,27 @@ public static extern IntPtr Create6DofConstraint2(IntPtr world, IntPtr obj1, Int bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] +public static extern IntPtr Create6DofConstraintToPoint2(IntPtr world, IntPtr obj1, IntPtr obj2, + Vector3 joinPoint, + bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies); + +[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] +public static extern IntPtr CreateHingeConstraint2(IntPtr world, IntPtr obj1, IntPtr obj2, + Vector3 pivotinA, Vector3 pivotinB, + Vector3 axisInA, Vector3 axisInB, + bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies); + +[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] +public static extern void SetConstraintEnable2(IntPtr constrain, float numericTrueFalse); + +[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] +public static extern void SetConstraintNumSolverIterations2(IntPtr constrain, float iterations); + +[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] +public static extern bool SetFrames2(IntPtr constrain, + Vector3 frameA, Quaternion frameArot, Vector3 frameB, Quaternion frameBrot); + +[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern bool SetLinearLimits2(IntPtr constrain, Vector3 low, Vector3 hi); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] @@ -428,6 +449,9 @@ public static extern bool UseFrameOffset2(IntPtr constrain, float enable); public static extern bool TranslationalLimitMotor2(IntPtr constrain, float enable, float targetVel, float maxMotorForce); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] +public static extern bool SetBreakingImpulseThreshold2(IntPtr constrain, float threshold); + +[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern bool CalculateTransforms2(IntPtr constrain); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] @@ -518,6 +542,9 @@ public static extern bool SetGravity2(IntPtr obj, Vector3 val); public static extern IntPtr ClearForces2(IntPtr obj); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] +public static extern IntPtr ClearAllForces2(IntPtr obj); + +[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern bool SetMargin2(IntPtr obj, float val); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] -- cgit v1.1 From 7679384829a8bc8c7761bed19914f05b6b50de9b Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Tue, 14 Aug 2012 11:36:51 +0100 Subject: adding ATTACH_*_PEC constants --- OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index c3eada0..e1c054d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs @@ -226,6 +226,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase public const int ATTACH_BELLY = 28; public const int ATTACH_RPEC = 29; public const int ATTACH_LPEC = 30; + public const int ATTACH_LEFT_PEC = 29; // Same value as ATTACH_RPEC, see https://jira.secondlife.com/browse/SVC-580 + public const int ATTACH_RIGHT_PEC = 30; // Same value as ATTACH_LPEC, see https://jira.secondlife.com/browse/SVC-580 public const int ATTACH_HUD_CENTER_2 = 31; public const int ATTACH_HUD_TOP_RIGHT = 32; public const int ATTACH_HUD_TOP_CENTER = 33; -- cgit v1.1 From 8cd4042f9e87a483de396dba5fa842f17028cb95 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Wed, 15 Aug 2012 21:14:39 +0100 Subject: Implementing PRIM_LINK_TARGET in a non-recursive fashion --- .../Shared/Api/Implementation/LSL_Api.cs | 222 ++++++++++----------- 1 file changed, 106 insertions(+), 116 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 1115542..42f77c6 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -338,34 +338,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public List GetLinkParts(int linkType) { + return GetLinkParts(m_host, linkType); + } + + private List GetLinkParts(SceneObjectPart part, int linkType) + { List ret = new List(); - if (m_host == null || m_host.ParentGroup == null || m_host.ParentGroup.IsDeleted) + if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) return ret; - ret.Add(m_host); + ret.Add(part); switch (linkType) { case ScriptBaseClass.LINK_SET: - return new List(m_host.ParentGroup.Parts); + return new List(part.ParentGroup.Parts); case ScriptBaseClass.LINK_ROOT: ret = new List(); - ret.Add(m_host.ParentGroup.RootPart); + ret.Add(part.ParentGroup.RootPart); return ret; case ScriptBaseClass.LINK_ALL_OTHERS: - ret = new List(m_host.ParentGroup.Parts); + ret = new List(part.ParentGroup.Parts); - if (ret.Contains(m_host)) - ret.Remove(m_host); + if (ret.Contains(part)) + ret.Remove(part); return ret; case ScriptBaseClass.LINK_ALL_CHILDREN: - ret = new List(m_host.ParentGroup.Parts); + ret = new List(part.ParentGroup.Parts); - if (ret.Contains(m_host.ParentGroup.RootPart)) - ret.Remove(m_host.ParentGroup.RootPart); + if (ret.Contains(part.ParentGroup.RootPart)) + ret.Remove(part.ParentGroup.RootPart); return ret; case ScriptBaseClass.LINK_THIS: @@ -375,7 +380,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (linkType < 0) return new List(); - SceneObjectPart target = m_host.ParentGroup.GetLinkNumPart(linkType); + SceneObjectPart target = part.ParentGroup.GetLinkNumPart(linkType); if (target == null) return new List(); ret = new List(); @@ -7750,7 +7755,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetPrimitiveParams(LSL_List rules) { m_host.AddScriptLPS(1); - SetPrimParams(m_host, rules); + + setLinkPrimParams(ScriptBaseClass.LINK_THIS, rules); ScriptSleep(200); } @@ -7764,26 +7770,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api private void setLinkPrimParams(int linknumber, LSL_List rules) { - List parts = GetLinkParts(linknumber); + List parts = new List(); + List prims = GetLinkParts(linknumber); List avatars = GetLinkAvatars(linknumber); - if (parts.Count>0) + foreach (SceneObjectPart p in prims) + parts.Add(p); + foreach (ScenePresence p in avatars) + parts.Add(p); + + LSL_List remaining = null; + + if (parts.Count > 0) { - try + foreach (SceneObjectPart part in parts) + remaining = SetPrimParams(part, rules); + + while(remaining != null && remaining.Length > 2) { - parts[0].ParentGroup.areUpdatesSuspended = true; + linknumber = remaining.GetLSLIntegerItem(0); + rules = remaining.GetSublist(1,-1); + parts.Clear(); + prims = GetLinkParts(linknumber); + avatars = GetLinkAvatars(linknumber); + foreach (SceneObjectPart p in prims) + parts.Add(p); + foreach (ScenePresence p in avatars) + parts.Add(p); + foreach (SceneObjectPart part in parts) - SetPrimParams(part, rules); - } - finally - { - parts[0].ParentGroup.areUpdatesSuspended = false; + remaining = SetPrimParams(part, rules); } } - if (avatars.Count > 0) - { - foreach (ScenePresence avatar in avatars) - SetPrimParams(avatar, rules); - } } private void SetPhysicsMaterial(SceneObjectPart part, int material_bits, @@ -7845,7 +7862,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return new Vector3((float)x, (float)y, (float)z); } - protected void SetPrimParams(ScenePresence av, LSL_List rules) + protected LSL_List SetPrimParams(ScenePresence av, LSL_List rules) { //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset. @@ -7868,7 +7885,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_POS_LOCAL: { if (remain < 1) - return; + return null; LSL_Vector v; v = rules.GetVector3Item(idx++); @@ -7902,7 +7919,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_ROTATION: { if (remain < 1) - return; + return null; LSL_Rotation r; r = rules.GetQuaternionItem(idx++); @@ -7933,7 +7950,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_NAME: case (int)ScriptBaseClass.PRIM_DESC: if (remain < 1) - return; + return null; idx++; break; @@ -7941,13 +7958,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_FULLBRIGHT: case (int)ScriptBaseClass.PRIM_TEXGEN: if (remain < 2) - return; + return null; idx += 2; break; case (int)ScriptBaseClass.PRIM_TYPE: if (remain < 3) - return; + return null; code = (int)rules.GetLSLIntegerItem(idx++); remain = rules.Length - idx; switch (code) @@ -7956,13 +7973,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER: case (int)ScriptBaseClass.PRIM_TYPE_PRISM: if (remain < 6) - return; + return null; idx += 6; break; case (int)ScriptBaseClass.PRIM_TYPE_SPHERE: if (remain < 5) - return; + return null; idx += 5; break; @@ -7970,13 +7987,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TYPE_TUBE: case (int)ScriptBaseClass.PRIM_TYPE_RING: if (remain < 11) - return; + return null; idx += 11; break; case (int)ScriptBaseClass.PRIM_TYPE_SCULPT: if (remain < 2) - return; + return null; idx += 2; break; } @@ -7987,7 +8004,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_BUMP_SHINY: case (int)ScriptBaseClass.PRIM_OMEGA: if (remain < 3) - return; + return null; idx += 3; break; @@ -7995,33 +8012,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_POINT_LIGHT: case (int)ScriptBaseClass.PRIM_PHYSICS_MATERIAL: if (remain < 5) - return; + return null; idx += 5; break; case (int)ScriptBaseClass.PRIM_FLEXIBLE: if (remain < 7) - return; + return null; idx += 7; break; case (int)ScriptBaseClass.PRIM_LINK_TARGET: if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. - return; - - if (positionChanged) - { - positionChanged = false; - av.OffsetPosition = finalPos; -// av.SendAvatarDataToAllAgents(); - av.SendTerseUpdateToAllClients(); - } + return null; - LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++); - LSL_List new_rules = rules.GetSublist(idx, -1); - setLinkPrimParams((int)new_linknumber, new_rules); - return; + return rules.GetSublist(idx, -1); } } } @@ -8036,12 +8042,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api positionChanged = false; } } + return null; } - protected void SetPrimParams(SceneObjectPart part, LSL_List rules) + protected LSL_List SetPrimParams(SceneObjectPart part, LSL_List rules) { if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) - return; + return null; int idx = 0; @@ -8066,7 +8073,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_POSITION: case (int)ScriptBaseClass.PRIM_POS_LOCAL: if (remain < 1) - return; + return null; v=rules.GetVector3Item(idx++); currentPosition = GetSetPosTarget(part, v, currentPosition); @@ -8075,7 +8082,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; case (int)ScriptBaseClass.PRIM_SIZE: if (remain < 1) - return; + return null; v=rules.GetVector3Item(idx++); SetScale(part, v); @@ -8083,7 +8090,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; case (int)ScriptBaseClass.PRIM_ROTATION: if (remain < 1) - return; + return null; LSL_Rotation q = rules.GetQuaternionItem(idx++); SceneObjectPart rootPart = parentgrp.RootPart; @@ -8104,7 +8111,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TYPE: if (remain < 3) - return; + return null; code = (int)rules.GetLSLIntegerItem(idx++); @@ -8123,7 +8130,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { case (int)ScriptBaseClass.PRIM_TYPE_BOX: if (remain < 6) - return; + return null; face = (int)rules.GetLSLIntegerItem(idx++); v = rules.GetVector3Item(idx++); // cut @@ -8138,7 +8145,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER: if (remain < 6) - return; + return null; face = (int)rules.GetLSLIntegerItem(idx++); // holeshape v = rules.GetVector3Item(idx++); // cut @@ -8152,7 +8159,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TYPE_PRISM: if (remain < 6) - return; + return null; face = (int)rules.GetLSLIntegerItem(idx++); // holeshape v = rules.GetVector3Item(idx++); //cut @@ -8166,7 +8173,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TYPE_SPHERE: if (remain < 5) - return; + return null; face = (int)rules.GetLSLIntegerItem(idx++); // holeshape v = rules.GetVector3Item(idx++); // cut @@ -8179,7 +8186,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TYPE_TORUS: if (remain < 11) - return; + return null; face = (int)rules.GetLSLIntegerItem(idx++); // holeshape v = rules.GetVector3Item(idx++); //cut @@ -8198,7 +8205,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TYPE_TUBE: if (remain < 11) - return; + return null; face = (int)rules.GetLSLIntegerItem(idx++); // holeshape v = rules.GetVector3Item(idx++); //cut @@ -8217,7 +8224,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TYPE_RING: if (remain < 11) - return; + return null; face = (int)rules.GetLSLIntegerItem(idx++); // holeshape v = rules.GetVector3Item(idx++); //cut @@ -8236,7 +8243,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TYPE_SCULPT: if (remain < 2) - return; + return null; string map = rules.Data[idx++].ToString(); face = (int)rules.GetLSLIntegerItem(idx++); // type @@ -8248,7 +8255,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TEXTURE: if (remain < 5) - return; + return null; face=(int)rules.GetLSLIntegerItem(idx++); string tex=rules.Data[idx++].ToString(); @@ -8265,7 +8272,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_COLOR: if (remain < 3) - return; + return null; face=(int)rules.GetLSLIntegerItem(idx++); LSL_Vector color=rules.GetVector3Item(idx++); @@ -8278,7 +8285,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_FLEXIBLE: if (remain < 7) - return; + return null; bool flexi = rules.GetLSLIntegerItem(idx++); int softness = rules.GetLSLIntegerItem(idx++); @@ -8294,7 +8301,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_POINT_LIGHT: if (remain < 5) - return; + return null; bool light = rules.GetLSLIntegerItem(idx++); LSL_Vector lightcolor = rules.GetVector3Item(idx++); float intensity = (float)rules.GetLSLFloatItem(idx++); @@ -8307,7 +8314,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_GLOW: if (remain < 2) - return; + return null; face = rules.GetLSLIntegerItem(idx++); float glow = (float)rules.GetLSLFloatItem(idx++); @@ -8317,7 +8324,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_BUMP_SHINY: if (remain < 3) - return; + return null; face = (int)rules.GetLSLIntegerItem(idx++); int shiny = (int)rules.GetLSLIntegerItem(idx++); Bumpiness bump = (Bumpiness)(int)rules.GetLSLIntegerItem(idx++); @@ -8328,7 +8335,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_FULLBRIGHT: if (remain < 2) - return; + return null; face = rules.GetLSLIntegerItem(idx++); bool st = rules.GetLSLIntegerItem(idx++); SetFullBright(part, face , st); @@ -8336,17 +8343,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_MATERIAL: if (remain < 1) - return; + return null; int mat = rules.GetLSLIntegerItem(idx++); if (mat < 0 || mat > 7) - return; + return null; part.Material = Convert.ToByte(mat); break; case (int)ScriptBaseClass.PRIM_PHANTOM: if (remain < 1) - return; + return null; string ph = rules.Data[idx++].ToString(); parentgrp.ScriptSetPhantomStatus(ph.Equals("1")); @@ -8355,7 +8362,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_PHYSICS: if (remain < 1) - return; + return null; string phy = rules.Data[idx++].ToString(); bool physics; @@ -8369,7 +8376,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_PHYSICS_SHAPE_TYPE: if (remain < 1) - return; + return null; int shape_type = rules.GetLSLIntegerItem(idx++); @@ -8385,7 +8392,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_PHYSICS_MATERIAL: if (remain < 5) - return; + return null; int material_bits = rules.GetLSLIntegerItem(idx++); float material_density = (float)rules.GetLSLFloatItem(idx++); @@ -8399,7 +8406,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: if (remain < 1) - return; + return null; string temp = rules.Data[idx++].ToString(); parentgrp.ScriptSetTemporaryStatus(temp.Equals("1")); @@ -8408,7 +8415,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TEXGEN: if (remain < 2) - return; + return null; //face,type face = rules.GetLSLIntegerItem(idx++); int style = rules.GetLSLIntegerItem(idx++); @@ -8416,7 +8423,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; case (int)ScriptBaseClass.PRIM_TEXT: if (remain < 3) - return; + return null; string primText = rules.GetLSLStringItem(idx++); LSL_Vector primTextColor = rules.GetVector3Item(idx++); LSL_Float primTextAlpha = rules.GetLSLFloatItem(idx++); @@ -8428,26 +8435,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; case (int)ScriptBaseClass.PRIM_NAME: if (remain < 1) - return; + return null; string primName = rules.GetLSLStringItem(idx++); part.Name = primName; break; case (int)ScriptBaseClass.PRIM_DESC: if (remain < 1) - return; + return null; string primDesc = rules.GetLSLStringItem(idx++); part.Description = primDesc; break; case (int)ScriptBaseClass.PRIM_ROT_LOCAL: if (remain < 1) - return; - + return null; LSL_Rotation lr = rules.GetQuaternionItem(idx++); SetRot(part, Rot2Quaternion(lr)); break; case (int)ScriptBaseClass.PRIM_OMEGA: if (remain < 3) - return; + return null; LSL_Vector axis = rules.GetVector3Item(idx++); LSL_Float spinrate = rules.GetLSLFloatItem(idx++); LSL_Float gain = rules.GetLSLFloatItem(idx++); @@ -8456,35 +8462,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_LINK_TARGET: if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. - return; - - // do a pending position change before jumping to other part/avatar - if (positionChanged) - { - positionChanged = false; - if (parentgrp == null) - return; - - if (parentgrp.RootPart == part) - { - - Util.FireAndForget(delegate(object x) - { - parentgrp.UpdateGroupPosition(new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z)); - }); - } - else - { - part.OffsetPosition = new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z); - parentgrp.HasGroupChanged = true; - parentgrp.ScheduleGroupForTerseUpdate(); - } - } + return null; - LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++); - LSL_List new_rules = rules.GetSublist(idx, -1); - setLinkPrimParams((int)new_linknumber, new_rules); - return; + return rules.GetSublist(idx, -1); } } } @@ -8508,6 +8488,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } } + return null; } public LSL_String llStringToBase64(string str) @@ -12143,7 +12124,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (obj.OwnerID != m_host.OwnerID) return; - SetPrimParams(obj, rules); + LSL_List remaining = SetPrimParams(obj, rules); + + while (remaining != null && remaining.Length > 2) + { + LSL_Integer newLink = remaining.GetLSLIntegerItem(0); + LSL_List newrules = remaining.GetSublist(1, -1); + foreach(SceneObjectPart part in GetLinkParts(obj, newLink)){ + remaining = SetPrimParams(part, newrules); + } + } } public LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules) -- cgit v1.1 From c313de630f2fec6793da2bc1f51dd54be82cb3e8 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 15 Aug 2012 23:31:38 +0200 Subject: Add a real_id field to the login response if impersonation is used. The wrapper script needs this for proper logging. --- .../Authentication/LocalAuthenticationServiceConnector.cs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs index 9484a5a..25ee4c6 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs @@ -137,6 +137,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication #region IAuthenticationService + public string Authenticate(UUID principalID, string password, int lifetime, out UUID realID) + { + // Not implemented at the regions + return string.Empty; + } + public string Authenticate(UUID principalID, string password, int lifetime) { // Not implemented at the regions -- cgit v1.1 From 5a1b6fdf0638e100f8246f4131dab9bb037d78cf Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 15 Aug 2012 22:43:32 +0100 Subject: Don't enable the thread watchdog until all regions are ready. This is to avoid false positives when the machine is under heavy load whilst starting up. --- OpenSim/Region/Application/OpenSimBase.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 37cfe1d..f784398 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -305,8 +305,13 @@ namespace OpenSim m_httpServerPort = m_networkServersInfo.HttpListenerPort; SceneManager.OnRestartSim += handleRestartRegion; - // Only start the memory watchdog once all regions are ready - SceneManager.OnRegionsReadyStatusChange += sm => MemoryWatchdog.Enabled = sm.AllRegionsReady; + // Only enable the watchdogs when all regions are ready. Otherwise we get false positives when cpu is + // heavily used during initial startup. + // + // FIXME: It's also possible that region ready status should be flipped during an OAR load since this + // also makes heavy use of the CPU. + SceneManager.OnRegionsReadyStatusChange + += sm => { MemoryWatchdog.Enabled = sm.AllRegionsReady; Watchdog.Enabled = sm.AllRegionsReady; }; } /// -- cgit v1.1 From 0aa1f1cc3f9f6556e470329cfb7982a774077444 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Wed, 15 Aug 2012 21:14:39 +0100 Subject: Implementing PRIM_LINK_TARGET in a non-recursive fashion --- .../Shared/Api/Implementation/LSL_Api.cs | 123 +++++++++++++-------- 1 file changed, 74 insertions(+), 49 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 8b53edc..55567d1 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -244,32 +244,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public List GetLinkParts(int linkType) { + return GetLinkParts(m_host, linkType); + } + + private List GetLinkParts(SceneObjectPart part, int linkType) + { List ret = new List(); - ret.Add(m_host); + ret.Add(part); switch (linkType) { case ScriptBaseClass.LINK_SET: - return new List(m_host.ParentGroup.Parts); + return new List(part.ParentGroup.Parts); case ScriptBaseClass.LINK_ROOT: ret = new List(); - ret.Add(m_host.ParentGroup.RootPart); + ret.Add(part.ParentGroup.RootPart); return ret; case ScriptBaseClass.LINK_ALL_OTHERS: - ret = new List(m_host.ParentGroup.Parts); + ret = new List(part.ParentGroup.Parts); - if (ret.Contains(m_host)) - ret.Remove(m_host); + if (ret.Contains(part)) + ret.Remove(part); return ret; case ScriptBaseClass.LINK_ALL_CHILDREN: - ret = new List(m_host.ParentGroup.Parts); + ret = new List(part.ParentGroup.Parts); - if (ret.Contains(m_host.ParentGroup.RootPart)) - ret.Remove(m_host.ParentGroup.RootPart); + if (ret.Contains(part.ParentGroup.RootPart)) + ret.Remove(part.ParentGroup.RootPart); return ret; case ScriptBaseClass.LINK_THIS: @@ -279,7 +284,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (linkType < 0) return new List(); - SceneObjectPart target = m_host.ParentGroup.GetLinkNumPart(linkType); + SceneObjectPart target = part.ParentGroup.GetLinkNumPart(linkType); if (target == null) return new List(); ret = new List(); @@ -7254,7 +7259,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llSetPrimitiveParams(LSL_List rules) { m_host.AddScriptLPS(1); - SetPrimParams(m_host, rules); + + setLinkPrimParams(ScriptBaseClass.LINK_THIS, rules); ScriptSleep(200); } @@ -7279,11 +7285,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { List parts = GetLinkParts(linknumber); + LSL_List remaining = null; + foreach (SceneObjectPart part in parts) - SetPrimParams(part, rules); + remaining = SetPrimParams(part, rules); + + while(remaining != null && remaining.Length > 2) + { + linknumber = remaining.GetLSLIntegerItem(0); + rules = remaining.GetSublist(1,-1); + parts = GetLinkParts(linknumber); + + foreach (SceneObjectPart part in parts) + remaining = SetPrimParams(part, rules); + } } - protected void SetPrimParams(SceneObjectPart part, LSL_List rules) + protected LSL_List SetPrimParams(SceneObjectPart part, LSL_List rules) { int idx = 0; @@ -7306,7 +7324,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_POSITION: case (int)ScriptBaseClass.PRIM_POS_LOCAL: if (remain < 1) - return; + return null; v=rules.GetVector3Item(idx++); positionChanged = true; @@ -7315,7 +7333,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; case (int)ScriptBaseClass.PRIM_SIZE: if (remain < 1) - return; + return null; v=rules.GetVector3Item(idx++); SetScale(part, v); @@ -7323,7 +7341,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; case (int)ScriptBaseClass.PRIM_ROTATION: if (remain < 1) - return; + return null; LSL_Rotation q = rules.GetQuaternionItem(idx++); // try to let this work as in SL... @@ -7343,7 +7361,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TYPE: if (remain < 3) - return; + return null; code = (int)rules.GetLSLIntegerItem(idx++); @@ -7362,7 +7380,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { case (int)ScriptBaseClass.PRIM_TYPE_BOX: if (remain < 6) - return; + return null; face = (int)rules.GetLSLIntegerItem(idx++); v = rules.GetVector3Item(idx++); // cut @@ -7377,7 +7395,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER: if (remain < 6) - return; + return null; face = (int)rules.GetLSLIntegerItem(idx++); // holeshape v = rules.GetVector3Item(idx++); // cut @@ -7391,7 +7409,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TYPE_PRISM: if (remain < 6) - return; + return null; face = (int)rules.GetLSLIntegerItem(idx++); // holeshape v = rules.GetVector3Item(idx++); //cut @@ -7405,7 +7423,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TYPE_SPHERE: if (remain < 5) - return; + return null; face = (int)rules.GetLSLIntegerItem(idx++); // holeshape v = rules.GetVector3Item(idx++); // cut @@ -7418,7 +7436,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TYPE_TORUS: if (remain < 11) - return; + return null; face = (int)rules.GetLSLIntegerItem(idx++); // holeshape v = rules.GetVector3Item(idx++); //cut @@ -7437,7 +7455,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TYPE_TUBE: if (remain < 11) - return; + return null; face = (int)rules.GetLSLIntegerItem(idx++); // holeshape v = rules.GetVector3Item(idx++); //cut @@ -7456,7 +7474,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TYPE_RING: if (remain < 11) - return; + return null; face = (int)rules.GetLSLIntegerItem(idx++); // holeshape v = rules.GetVector3Item(idx++); //cut @@ -7475,7 +7493,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TYPE_SCULPT: if (remain < 2) - return; + return null; string map = rules.Data[idx++].ToString(); face = (int)rules.GetLSLIntegerItem(idx++); // type @@ -7487,7 +7505,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TEXTURE: if (remain < 5) - return; + return null; face=(int)rules.GetLSLIntegerItem(idx++); string tex=rules.Data[idx++].ToString(); @@ -7504,7 +7522,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_COLOR: if (remain < 3) - return; + return null; face=(int)rules.GetLSLIntegerItem(idx++); LSL_Vector color=rules.GetVector3Item(idx++); @@ -7517,7 +7535,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_FLEXIBLE: if (remain < 7) - return; + return null; bool flexi = rules.GetLSLIntegerItem(idx++); int softness = rules.GetLSLIntegerItem(idx++); @@ -7533,7 +7551,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_POINT_LIGHT: if (remain < 5) - return; + return null; bool light = rules.GetLSLIntegerItem(idx++); LSL_Vector lightcolor = rules.GetVector3Item(idx++); float intensity = (float)rules.GetLSLFloatItem(idx++); @@ -7546,7 +7564,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_GLOW: if (remain < 2) - return; + return null; face = rules.GetLSLIntegerItem(idx++); float glow = (float)rules.GetLSLFloatItem(idx++); @@ -7556,7 +7574,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_BUMP_SHINY: if (remain < 3) - return; + return null; face = (int)rules.GetLSLIntegerItem(idx++); int shiny = (int)rules.GetLSLIntegerItem(idx++); Bumpiness bump = (Bumpiness)(int)rules.GetLSLIntegerItem(idx++); @@ -7567,7 +7585,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_FULLBRIGHT: if (remain < 2) - return; + return null; face = rules.GetLSLIntegerItem(idx++); bool st = rules.GetLSLIntegerItem(idx++); SetFullBright(part, face , st); @@ -7575,17 +7593,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_MATERIAL: if (remain < 1) - return; + return null; int mat = rules.GetLSLIntegerItem(idx++); if (mat < 0 || mat > 7) - return; + return null; part.Material = Convert.ToByte(mat); break; case (int)ScriptBaseClass.PRIM_PHANTOM: if (remain < 1) - return; + return null; string ph = rules.Data[idx++].ToString(); m_host.ParentGroup.ScriptSetPhantomStatus(ph.Equals("1")); @@ -7594,7 +7612,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_PHYSICS: if (remain < 1) - return; + return null; string phy = rules.Data[idx++].ToString(); bool physics; @@ -7608,7 +7626,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: if (remain < 1) - return; + return null; string temp = rules.Data[idx++].ToString(); m_host.ParentGroup.ScriptSetTemporaryStatus(temp.Equals("1")); @@ -7617,7 +7635,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_TEXGEN: if (remain < 2) - return; + return null; //face,type face = rules.GetLSLIntegerItem(idx++); int style = rules.GetLSLIntegerItem(idx++); @@ -7625,7 +7643,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; case (int)ScriptBaseClass.PRIM_TEXT: if (remain < 3) - return; + return null; string primText = rules.GetLSLStringItem(idx++); LSL_Vector primTextColor = rules.GetVector3Item(idx++); LSL_Float primTextAlpha = rules.GetLSLFloatItem(idx++); @@ -7637,25 +7655,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; case (int)ScriptBaseClass.PRIM_NAME: if (remain < 1) - return; + return null; string primName = rules.GetLSLStringItem(idx++); part.Name = primName; break; case (int)ScriptBaseClass.PRIM_DESC: if (remain < 1) - return; + return null; string primDesc = rules.GetLSLStringItem(idx++); part.Description = primDesc; break; case (int)ScriptBaseClass.PRIM_ROT_LOCAL: if (remain < 1) - return; + return null; LSL_Rotation lr = rules.GetQuaternionItem(idx++); SetRot(part, Rot2Quaternion(lr)); break; case (int)ScriptBaseClass.PRIM_OMEGA: if (remain < 3) - return; + return null; LSL_Vector axis = rules.GetVector3Item(idx++); LSL_Float spinrate = rules.GetLSLFloatItem(idx++); LSL_Float gain = rules.GetLSLFloatItem(idx++); @@ -7663,12 +7681,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api break; case (int)ScriptBaseClass.PRIM_LINK_TARGET: if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. - return; - LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++); - LSL_List new_rules = rules.GetSublist(idx, -1); - setLinkPrimParams((int)new_linknumber, new_rules); + return null; - return; + return rules.GetSublist(idx, -1); } } } @@ -7690,6 +7705,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } } } + return null; } public LSL_String llStringToBase64(string str) @@ -10762,7 +10778,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (obj.OwnerID != m_host.OwnerID) return; - SetPrimParams(obj, rules); + LSL_List remaining = SetPrimParams(obj, rules); + + while (remaining != null && remaining.Length > 2) + { + LSL_Integer newLink = remaining.GetLSLIntegerItem(0); + LSL_List newrules = remaining.GetSublist(1, -1); + foreach(SceneObjectPart part in GetLinkParts(obj, newLink)){ + remaining = SetPrimParams(part, newrules); + } + } } public LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules) -- cgit v1.1 From 684f8208d9ce882f29ded6350a7eb359055749dc Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 15 Aug 2012 23:58:39 +0200 Subject: Do a proper null check to avoid the overloaded operator == trap --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 42f77c6..c4109dd 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7785,7 +7785,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api foreach (SceneObjectPart part in parts) remaining = SetPrimParams(part, rules); - while(remaining != null && remaining.Length > 2) + while((object)remaining != null && remaining.Length > 2) { linknumber = remaining.GetLSLIntegerItem(0); rules = remaining.GetSublist(1,-1); -- cgit v1.1 From 5ac77316e062056466bc70e3afd91e5ba6fef367 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 16 Aug 2012 00:59:58 +0200 Subject: Remove XML debug spam from vivox voice --- .../Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index 396d4c5..a30a38d 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs @@ -469,8 +469,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice avatarName = avatar.Name; m_log.DebugFormat("[VivoxVoice][PROVISIONVOICE]: scene = {0}, agentID = {1}", scene, agentID); - m_log.DebugFormat("[VivoxVoice][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}", - request, path, param); +// m_log.DebugFormat("[VivoxVoice][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}", +// request, path, param); XmlElement resp; bool retry = false; @@ -577,7 +577,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse); - m_log.DebugFormat("[VivoxVoice][PROVISIONVOICE]: avatar \"{0}\": {1}", avatarName, r); +// m_log.DebugFormat("[VivoxVoice][PROVISIONVOICE]: avatar \"{0}\": {1}", avatarName, r); return r; } @@ -625,8 +625,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice // voice channel LandData land = scene.GetLandData(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); - m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": request: {4}, path: {5}, param: {6}", - scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, request, path, param); +// m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": request: {4}, path: {5}, param: {6}", +// scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, request, path, param); // m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: avatar \"{0}\": location: {1} {2} {3}", // avatarName, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z); @@ -656,8 +656,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice parcelVoiceInfo = new LLSDParcelVoiceInfoResponse(scene.RegionInfo.RegionName, land.LocalID, creds); string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo); - m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": {4}", - scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, r); +// m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": {4}", +// scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, r); return r; } catch (Exception e) @@ -684,11 +684,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice public string ChatSessionRequest(Scene scene, string request, string path, string param, UUID agentID, Caps caps) { - ScenePresence avatar = scene.GetScenePresence(agentID); - string avatarName = avatar.Name; +// ScenePresence avatar = scene.GetScenePresence(agentID); +// string avatarName = avatar.Name; - m_log.DebugFormat("[VivoxVoice][CHATSESSION]: avatar \"{0}\": request: {1}, path: {2}, param: {3}", - avatarName, request, path, param); +// m_log.DebugFormat("[VivoxVoice][CHATSESSION]: avatar \"{0}\": request: {1}, path: {2}, param: {3}", +// avatarName, request, path, param); return "true"; } @@ -1119,7 +1119,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice try { // Otherwise prepare the request - m_log.DebugFormat("[VivoxVoice] Sending request <{0}>", requrl); +// m_log.DebugFormat("[VivoxVoice] Sending request <{0}>", requrl); HttpWebRequest req = (HttpWebRequest)WebRequest.Create(requrl); HttpWebResponse rsp = null; -- cgit v1.1 From 4e5c19595c663d29e881a08ac5b0325301473b93 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 16 Aug 2012 01:01:03 +0200 Subject: Fix casts and calls for link primitive param setting for avatars --- .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index c4109dd..5264613 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7782,8 +7782,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (parts.Count > 0) { - foreach (SceneObjectPart part in parts) - remaining = SetPrimParams(part, rules); + foreach (object part in parts) + { + if (part is SceneObjectPart) + remaining = SetPrimParams((SceneObjectPart)part, rules); + else + remaining = SetPrimParams((ScenePresence)part, rules); + } while((object)remaining != null && remaining.Length > 2) { @@ -7797,8 +7802,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api foreach (ScenePresence p in avatars) parts.Add(p); - foreach (SceneObjectPart part in parts) - remaining = SetPrimParams(part, rules); + foreach (object part in parts) + { + if (part is SceneObjectPart) + remaining = SetPrimParams((SceneObjectPart)part, rules); + else + remaining = SetPrimParams((ScenePresence)part, rules); + } } } } -- cgit v1.1 From b97053269b33c4fc733372cf44f0f16d244d87b8 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 16 Aug 2012 01:02:20 +0200 Subject: Change case of areUpdatesSuspended to upper case as is proper for a property --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 14 ++++++------- .../Region/Framework/Scenes/SceneObjectGroup.cs | 2 +- .../Shared/Api/Implementation/LSL_Api.cs | 24 +++++++++++----------- 3 files changed, 20 insertions(+), 20 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index e0260e2..a1da5ee 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1793,7 +1793,7 @@ namespace OpenSim.Region.Framework.Scenes try { - parentGroup.areUpdatesSuspended = true; + parentGroup.AreUpdatesSuspended = true; List childGroups = new List(); @@ -1850,7 +1850,7 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectGroupsByLocalPartID[part.LocalId] = parentGroup; } - parentGroup.areUpdatesSuspended = false; + parentGroup.AreUpdatesSuspended = false; parentGroup.HasGroupChanged = true; parentGroup.ProcessBackup(m_parentScene.SimulationDataService, true); parentGroup.ScheduleGroupForFullUpdate(); @@ -1896,7 +1896,7 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectGroup group = part.ParentGroup; if (!affectedGroups.Contains(group)) { - group.areUpdatesSuspended = true; + group.AreUpdatesSuspended = true; affectedGroups.Add(group); } } @@ -1922,7 +1922,7 @@ namespace OpenSim.Region.Framework.Scenes // However, editing linked parts and unlinking may be different // SceneObjectGroup group = root.ParentGroup; - group.areUpdatesSuspended = true; + group.AreUpdatesSuspended = true; List newSet = new List(group.Parts); int numChildren = newSet.Count; @@ -1945,7 +1945,7 @@ namespace OpenSim.Region.Framework.Scenes group.DelinkFromGroup(p, sendEventsToRemainder); if (numChildren > 2) { - p.ParentGroup.areUpdatesSuspended = true; + p.ParentGroup.AreUpdatesSuspended = true; } else { @@ -1980,7 +1980,7 @@ namespace OpenSim.Region.Framework.Scenes foreach (SceneObjectPart newChild in newSet) newChild.ClearUpdateSchedule(); - newRoot.ParentGroup.areUpdatesSuspended = true; + newRoot.ParentGroup.AreUpdatesSuspended = true; LinkObjects(newRoot, newSet); if (!affectedGroups.Contains(newRoot.ParentGroup)) affectedGroups.Add(newRoot.ParentGroup); @@ -1998,7 +1998,7 @@ namespace OpenSim.Region.Framework.Scenes m_parentScene.SimulationDataService.RemoveObject(g.UUID, m_parentScene.RegionInfo.RegionID); g.TriggerScriptChangedEvent(Changed.LINK); g.HasGroupChanged = true; // Persist - g.areUpdatesSuspended = false; + g.AreUpdatesSuspended = false; g.ScheduleGroupForFullUpdate(); } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index d837adb..4d610f4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -116,7 +116,7 @@ namespace OpenSim.Region.Framework.Scenes private bool m_suspendUpdates; private List m_linkedAvatars = new List(); - public bool areUpdatesSuspended + public bool AreUpdatesSuspended { get { diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 5264613..0148394 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -1775,13 +1775,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { try { - parts[0].ParentGroup.areUpdatesSuspended = true; + parts[0].ParentGroup.AreUpdatesSuspended = true; foreach (SceneObjectPart part in parts) SetAlpha(part, alpha, face); } finally { - parts[0].ParentGroup.areUpdatesSuspended = false; + parts[0].ParentGroup.AreUpdatesSuspended = false; } } } @@ -1962,13 +1962,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { try { - parts[0].ParentGroup.areUpdatesSuspended = true; + parts[0].ParentGroup.AreUpdatesSuspended = true; foreach (SceneObjectPart part in parts) SetTexture(part, texture, face); } finally { - parts[0].ParentGroup.areUpdatesSuspended = false; + parts[0].ParentGroup.AreUpdatesSuspended = false; } } ScriptSleep(200); @@ -3931,13 +3931,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { try { - parts[0].ParentGroup.areUpdatesSuspended = true; + parts[0].ParentGroup.AreUpdatesSuspended = true; foreach (SceneObjectPart part in parts) part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); } finally { - parts[0].ParentGroup.areUpdatesSuspended = false; + parts[0].ParentGroup.AreUpdatesSuspended = false; } } } @@ -4055,7 +4055,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { try { - parts[0].ParentGroup.areUpdatesSuspended = true; + parts[0].ParentGroup.AreUpdatesSuspended = true; foreach (SceneObjectPart part in parts) { parentPrim.DelinkFromGroup(part.LocalId, true); @@ -4063,7 +4063,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } finally { - parts[0].ParentGroup.areUpdatesSuspended = false; + parts[0].ParentGroup.AreUpdatesSuspended = false; } } @@ -4078,7 +4078,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api try { - parts[0].ParentGroup.areUpdatesSuspended = true; + parts[0].ParentGroup.AreUpdatesSuspended = true; foreach (SceneObjectPart part in parts) { part.ClearUpdateSchedule(); @@ -4087,7 +4087,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } finally { - parts[0].ParentGroup.areUpdatesSuspended = false; + parts[0].ParentGroup.AreUpdatesSuspended = false; } @@ -6302,7 +6302,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { try { - parts[0].ParentGroup.areUpdatesSuspended = true; + parts[0].ParentGroup.AreUpdatesSuspended = true; foreach (var part in parts) { SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); @@ -6310,7 +6310,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } finally { - parts[0].ParentGroup.areUpdatesSuspended = false; + parts[0].ParentGroup.AreUpdatesSuspended = false; } } } -- cgit v1.1 From bbac8f76faff387756bfa55dea83fa3bd589ef79 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 16 Aug 2012 01:18:32 +0200 Subject: Remove AreUpdatesSuspended flag because it does nothing --- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 7 ------- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 17 ----------------- .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 12 ------------ 3 files changed, 36 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index a1da5ee..e29b2c1 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -1793,7 +1793,6 @@ namespace OpenSim.Region.Framework.Scenes try { - parentGroup.AreUpdatesSuspended = true; List childGroups = new List(); @@ -1850,7 +1849,6 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectGroupsByLocalPartID[part.LocalId] = parentGroup; } - parentGroup.AreUpdatesSuspended = false; parentGroup.HasGroupChanged = true; parentGroup.ProcessBackup(m_parentScene.SimulationDataService, true); parentGroup.ScheduleGroupForFullUpdate(); @@ -1896,7 +1894,6 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectGroup group = part.ParentGroup; if (!affectedGroups.Contains(group)) { - group.AreUpdatesSuspended = true; affectedGroups.Add(group); } } @@ -1922,7 +1919,6 @@ namespace OpenSim.Region.Framework.Scenes // However, editing linked parts and unlinking may be different // SceneObjectGroup group = root.ParentGroup; - group.AreUpdatesSuspended = true; List newSet = new List(group.Parts); int numChildren = newSet.Count; @@ -1945,7 +1941,6 @@ namespace OpenSim.Region.Framework.Scenes group.DelinkFromGroup(p, sendEventsToRemainder); if (numChildren > 2) { - p.ParentGroup.AreUpdatesSuspended = true; } else { @@ -1980,7 +1975,6 @@ namespace OpenSim.Region.Framework.Scenes foreach (SceneObjectPart newChild in newSet) newChild.ClearUpdateSchedule(); - newRoot.ParentGroup.AreUpdatesSuspended = true; LinkObjects(newRoot, newSet); if (!affectedGroups.Contains(newRoot.ParentGroup)) affectedGroups.Add(newRoot.ParentGroup); @@ -1998,7 +1992,6 @@ namespace OpenSim.Region.Framework.Scenes m_parentScene.SimulationDataService.RemoveObject(g.UUID, m_parentScene.RegionInfo.RegionID); g.TriggerScriptChangedEvent(Changed.LINK); g.HasGroupChanged = true; // Persist - g.AreUpdatesSuspended = false; g.ScheduleGroupForFullUpdate(); } } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 4d610f4..6104c66 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -113,25 +113,8 @@ namespace OpenSim.Region.Framework.Scenes private long m_maxPersistTime = 0; private long m_minPersistTime = 0; private Random m_rand; - private bool m_suspendUpdates; private List m_linkedAvatars = new List(); - public bool AreUpdatesSuspended - { - get - { - return m_suspendUpdates; - } - set - { - m_suspendUpdates = value; - if (!value) - { - QueueForUpdateCheck(); - } - } - } - /// /// This indicates whether the object has changed such that it needs to be repersisted to permenant storage /// (the database). diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 0148394..5f7b95f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -1775,13 +1775,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { try { - parts[0].ParentGroup.AreUpdatesSuspended = true; foreach (SceneObjectPart part in parts) SetAlpha(part, alpha, face); } finally { - parts[0].ParentGroup.AreUpdatesSuspended = false; } } } @@ -1962,13 +1960,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { try { - parts[0].ParentGroup.AreUpdatesSuspended = true; foreach (SceneObjectPart part in parts) SetTexture(part, texture, face); } finally { - parts[0].ParentGroup.AreUpdatesSuspended = false; } } ScriptSleep(200); @@ -3931,13 +3927,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { try { - parts[0].ParentGroup.AreUpdatesSuspended = true; foreach (SceneObjectPart part in parts) part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); } finally { - parts[0].ParentGroup.AreUpdatesSuspended = false; } } } @@ -4055,7 +4049,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { try { - parts[0].ParentGroup.AreUpdatesSuspended = true; foreach (SceneObjectPart part in parts) { parentPrim.DelinkFromGroup(part.LocalId, true); @@ -4063,7 +4056,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } finally { - parts[0].ParentGroup.AreUpdatesSuspended = false; } } @@ -4078,7 +4070,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api try { - parts[0].ParentGroup.AreUpdatesSuspended = true; foreach (SceneObjectPart part in parts) { part.ClearUpdateSchedule(); @@ -4087,7 +4078,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } finally { - parts[0].ParentGroup.AreUpdatesSuspended = false; } @@ -6302,7 +6292,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { try { - parts[0].ParentGroup.AreUpdatesSuspended = true; foreach (var part in parts) { SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); @@ -6310,7 +6299,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } finally { - parts[0].ParentGroup.AreUpdatesSuspended = false; } } } -- cgit v1.1 From 9995421df118e1270f289ea82451e0c7b6dd5b40 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 15 Aug 2012 23:58:39 +0200 Subject: Do a proper null check to avoid the overloaded operator == trap --- OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 55567d1..7e48659 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -10780,7 +10780,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api LSL_List remaining = SetPrimParams(obj, rules); - while (remaining != null && remaining.Length > 2) + while ((object)remaining != null && remaining.Length > 2) { LSL_Integer newLink = remaining.GetLSLIntegerItem(0); LSL_List newrules = remaining.GetSublist(1, -1); -- cgit v1.1