From 418c0cb01d72a48bb1cd708d25a3e9159e711661 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 12 Dec 2012 22:06:09 +0000 Subject: Add asset id to "show script" and "show scripts" command output to make it easier to extract and inspect the script's asset via "dump asset" --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 965101a..986f658 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -542,6 +542,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine sb.AppendFormat("Queued events : {0}\n", instance.EventsQueued); sb.AppendFormat("Processed events : {0}\n", instance.EventsProcessed); sb.AppendFormat("Item UUID : {0}\n", instance.ItemID); + sb.AppendFormat("Asset UUID : {0}\n", instance.AssetID); sb.AppendFormat("Containing part name: {0}\n", instance.PrimName); sb.AppendFormat("Containing part UUID: {0}\n", instance.ObjectID); sb.AppendFormat("Position : {0}\n", sop.AbsolutePosition); -- cgit v1.1 From 047270bdc83d029486215a418fada27b225dbab0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 12 Dec 2012 23:13:34 +0000 Subject: Add "debug script log" command to allow setting a numeric debug level on individual IScriptInstances for debugging purposes. Current, state changes and event fires can be logged for individual scripts. See command help for more details. --- OpenSim/Framework/Console/ConsoleUtil.cs | 28 ++++++++++-- .../ScriptEngine/Interfaces/IScriptInstance.cs | 12 +++++ .../ScriptEngine/Shared/Instance/ScriptInstance.cs | 37 +++++++++++---- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 53 ++++++++++++++++++++-- 4 files changed, 113 insertions(+), 17 deletions(-) diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs index 16a63e0..dff956a 100644 --- a/OpenSim/Framework/Console/ConsoleUtil.cs +++ b/OpenSim/Framework/Console/ConsoleUtil.cs @@ -97,7 +97,7 @@ namespace OpenSim.Framework.Console if (!UUID.TryParse(rawUuid, out uuid)) { if (console != null) - console.OutputFormat("{0} is not a valid uuid", rawUuid); + console.OutputFormat("ERROR: {0} is not a valid uuid", rawUuid); return false; } @@ -110,7 +110,7 @@ namespace OpenSim.Framework.Console if (!uint.TryParse(rawLocalId, out localId)) { if (console != null) - console.OutputFormat("{0} is not a valid local id", localId); + console.OutputFormat("ERROR: {0} is not a valid local id", localId); return false; } @@ -118,7 +118,7 @@ namespace OpenSim.Framework.Console if (localId == 0) { if (console != null) - console.OutputFormat("{0} is not a valid local id - it must be greater than 0", localId); + console.OutputFormat("ERROR: {0} is not a valid local id - it must be greater than 0", localId); return false; } @@ -150,10 +150,30 @@ namespace OpenSim.Framework.Console } if (console != null) - console.OutputFormat("{0} is not a valid UUID or local id", rawId); + console.OutputFormat("ERROR: {0} is not a valid UUID or local id", rawId); return false; } + + /// + /// Convert a minimum vector input from the console to an OpenMetaverse.Vector3 + /// + /// Can be null if no console is available. + /// /param> + /// + /// + public static bool TryParseConsoleInt(ICommandConsole console, string rawConsoleInt, out int i) + { + if (!int.TryParse(rawConsoleInt, out i)) + { + if (console != null) + console.OutputFormat("ERROR: {0} is not a valid integer", rawConsoleInt); + + return false; + } + + return true; + } /// /// Convert a minimum vector input from the console to an OpenMetaverse.Vector3 diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs index 0cef550..00a99c3 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs @@ -59,6 +59,18 @@ namespace OpenSim.Region.ScriptEngine.Interfaces public interface IScriptInstance { /// + /// Debug level for this script instance. + /// + /// + /// Level == 0, no extra data is logged. + /// Level >= 1, state changes are logged. + /// Level >= 2, event firing is logged. + /// + /// The debug level. + /// + int DebugLevel { get; set; } + + /// /// Is the script currently running? /// bool Running { get; set; } diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 5ad6eeb..435e9dc 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -93,6 +93,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance private UUID m_CurrentStateHash; private UUID m_RegionID; + public int DebugLevel { get; set; } + public Dictionary, KeyValuePair> LineMap { get; set; } private Dictionary m_Apis = new Dictionary(); @@ -703,21 +705,42 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance if (data.EventName == "collision") m_CollisionInQueue = false; } - -// m_log.DebugFormat("[XEngine]: Processing event {0} for {1}", data.EventName, this); + + SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); + + if (DebugLevel >= 2) + m_log.DebugFormat( + "[SCRIPT INSTANCE]: Processing event {0} for {1}/{2}({3})/{4}({5}) @ {6}/{7}", + data.EventName, + ScriptName, + part.Name, + part.LocalId, + part.ParentGroup.Name, + part.ParentGroup.UUID, + part.AbsolutePosition, + part.ParentGroup.Scene.Name); m_DetectParams = data.DetectParams; if (data.EventName == "state") // Hardcoded state change { - // m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}", - // PrimName, ScriptName, data.Params[0].ToString()); State = data.Params[0].ToString(); + + if (DebugLevel >= 1) + m_log.DebugFormat( + "[SCRIPT INSTANCE]: Changing state to {0} for {1}/{2}({3})/{4}({5}) @ {6}/{7}", + State, + ScriptName, + part.Name, + part.LocalId, + part.ParentGroup.Name, + part.ParentGroup.UUID, + part.AbsolutePosition, + part.ParentGroup.Scene.Name); + AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID); - SceneObjectPart part = Engine.World.GetSceneObjectPart( - LocalID); if (part != null) { part.SetScriptEvents(ItemID, @@ -729,8 +752,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance if (Engine.World.PipeEventsForScript(LocalID) || data.EventName == "control") // Don't freeze avies! { - SceneObjectPart part = Engine.World.GetSceneObjectPart( - LocalID); // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}", // PrimName, ScriptName, data.EventName, State); diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 986f658..828f2fb 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -304,7 +304,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine MainConsole.Instance.Commands.AddCommand( "Scripts", false, "scripts show", "scripts show []", "Show script information", - "Show information on all scripts known to the script engine." + "Show information on all scripts known to the script engine.\n" + "If a is given then only information on that script will be shown.", HandleShowScripts); @@ -323,22 +323,30 @@ namespace OpenSim.Region.ScriptEngine.XEngine MainConsole.Instance.Commands.AddCommand( "Scripts", false, "scripts resume", "scripts resume []", "Resumes all suspended scripts", "Resumes all currently suspended scripts.\n" - + "Resumed scripts will process all events accumulated whilst suspended." + + "Resumed scripts will process all events accumulated whilst suspended.\n" + "If a is given then only that script will be resumed. Otherwise, all suitable scripts are resumed.", (module, cmdparams) => HandleScriptsAction(cmdparams, HandleResumeScript)); MainConsole.Instance.Commands.AddCommand( "Scripts", false, "scripts stop", "scripts stop []", "Stops all running scripts", - "Stops all running scripts." + "Stops all running scripts.\n" + "If a is given then only that script will be stopped. Otherwise, all suitable scripts are stopped.", (module, cmdparams) => HandleScriptsAction(cmdparams, HandleStopScript)); MainConsole.Instance.Commands.AddCommand( "Scripts", false, "scripts start", "scripts start []", "Starts all stopped scripts", - "Starts all stopped scripts." + "Starts all stopped scripts.\n" + "If a is given then only that script will be started. Otherwise, all suitable scripts are started.", (module, cmdparams) => HandleScriptsAction(cmdparams, HandleStartScript)); + MainConsole.Instance.Commands.AddCommand( + "Scripts", false, "debug script log", "debug scripts log ", "Extra debug logging for a script", + "Activates or deactivates extra debug logging for the given script.\n" + + "Level == 0, deactivate extra debug logging.\n" + + "Level >= 1, log state changes.\n" + + "Level >= 2, log event invocations.\n", + HandleDebugScriptLogCommand); + // MainConsole.Instance.Commands.AddCommand( // "Debug", false, "debug xengine", "debug xengine []", // "Turn on detailed xengine debugging.", @@ -347,6 +355,41 @@ namespace OpenSim.Region.ScriptEngine.XEngine // HandleDebugLevelCommand); } + private void HandleDebugScriptLogCommand(string module, string[] args) + { + if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene)) + return; + + if (args.Length != 5) + { + MainConsole.Instance.Output("Usage: debug script log "); + return; + } + + UUID itemId; + + if (!ConsoleUtil.TryParseConsoleUuid(MainConsole.Instance, args[3], out itemId)) + return; + + int newLevel; + + if (!ConsoleUtil.TryParseConsoleInt(MainConsole.Instance, args[4], out newLevel)) + return; + + IScriptInstance si; + + lock (m_Scripts) + { + // XXX: We can't give the user feedback on a bad item id because this may apply to a different script + // engine + if (!m_Scripts.TryGetValue(itemId, out si)) + return; + } + + si.DebugLevel = newLevel; + MainConsole.Instance.OutputFormat("Set debug level of {0} {1} to {2}", si.ScriptName, si.ItemID, newLevel); + } + /// /// Change debug level /// @@ -418,7 +461,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine if (!UUID.TryParse(rawItemId, out itemId)) { - MainConsole.Instance.OutputFormat("Error - {0} is not a valid UUID", rawItemId); + MainConsole.Instance.OutputFormat("ERROR: {0} is not a valid UUID", rawItemId); return; } -- cgit v1.1 From 512e4c931379877a1fd8c35f41111431f0a85ff5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 12 Dec 2012 23:30:26 +0000 Subject: Log situations where workitem event threads are aborted on stop request because they failed to complete event processing within the given timeout. This is for bug hunting purposes where thread aborts may be causing dangling lock issues and subsequent vm crashes on mono (with ReaderWriterLockSlim, etc.) --- OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 435e9dc..dfe8386 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -550,9 +550,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance // forcibly abort the work item (this aborts the underlying thread). if (!m_InSelfDelete) { -// m_log.ErrorFormat( -// "[SCRIPT INSTANCE]: Aborting script {0} {1} in prim {2} {3} {4} {5}", -// ScriptName, ItemID, PrimName, ObjectID, m_InSelfDelete, DateTime.Now.Ticks); + m_log.DebugFormat( + "[SCRIPT INSTANCE]: Aborting unstopped script {0} {1} in prim {2}, localID {3}, timeout was {4} ms", + ScriptName, ItemID, PrimName, LocalID, timeout); workItem.Abort(); } -- cgit v1.1 From 7bb5613dc665a788e1b151278c20d415f708242a Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 11 Dec 2012 16:46:43 -0800 Subject: BulletSim: updates and rearrangement of the TODO list. --- .../Region/Physics/BulletSPlugin/BulletSimTODO.txt | 47 +++++++++++++++------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt index 1c7b577..11c1387 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt @@ -20,6 +20,10 @@ Neb car jiggling left and right Happens on terrain and any other mesh object. Flat cubes are much smoother. This has been reduced but not eliminated. For limitMotorUp, use raycast down to find if vehicle is in the air. +Angular motion around Z moves the vehicle in world Z and not vehicle Z in ODE. + Verify that angular motion specified around Z moves in the vehicle coordinates. +Verify llGetVel() is returning a smooth and good value for vehicle movement. +llGetVel() should return the root's velocity if requested in a child prim. Implement function efficiency for lineaar and angular motion. Should vehicle angular/linear movement friction happen after all the components or does it only apply to the basic movement? @@ -32,19 +36,14 @@ Border crossing with linked vehicle causes crash BULLETSIM TODO LIST: ================================================= -Avatar height off after unsitting (float off ground) +Avatar height off after unsitting (floats off ground) Editting appearance then moving restores. Must not be initializing height when recreating capsule after unsit. Duplicating a physical prim causes old prim to jump away Dup a phys prim and the original become unselected and thus interacts w/ selected prim. -Disable activity of passive linkset children. - Since the linkset is a compound object, the old prims are left lying - around and need to be phantomized so they don't collide, ... Scenes with hundred of thousands of static objects take a lot of physics CPU time. BSPrim.Force should set a continious force on the prim. The force should be applied each tick. Some limits? -Linksets should allow collisions to individual children - Add LocalID to children shapes in LinksetCompound and create events for individuals Gun sending shooter flying. Collision margin (gap between physical objects lying on each other) Boundry checking (crashes related to crossing boundry) @@ -57,14 +56,34 @@ Small physical objects do not interact correctly The chain will fall apart and pairs will dance around on ground Chains of 1x1x.2 will stay connected but will dance. Chains above 2x2x.4 are move stable and get stablier as torui get larger. -Add material type linkage and input all the material property definitions. - Skeleton classes and table are in the sources but are not filled or used. Add PID motor for avatar movement (slow to stop, ...) setForce should set a constant force. Different than AddImpulse. Implement raycast. Implement ShapeCollection.Dispose() Implement water as a plain so raycasting and collisions can happen with same. +Add osGetPhysicsEngineName() so scripters can tell whether BulletSim or ODE + Also osGetPhysicsEngineVerion() maybe. + +LINKSETS +====================================================== +Linksets should allow collisions to individual children + Add LocalID to children shapes in LinksetCompound and create events for individuals +Verify/think through scripts in children of linksets. What do they reference + and return when getting position, velocity, ... +Confirm constraint linksets still work after making all the changes for compound linksets. +Add 'changed' flag or similar to reduce the number of times a linkset is rebuilt. + For compound linksets, add ability to remove or reposition individual child shapes. +Disable activity of passive linkset children. + Since the linkset is a compound object, the old prims are left lying + around and need to be phantomized so they don't collide, ... +Speed up creation of large physical linksets + For instance, sitting in Neb's car (130 prims) takes several seconds to become physical +Eliminate collisions between objects in a linkset. (LinksetConstraint) + Have UserPointer point to struct with localID and linksetID? + Objects in original linkset still collide with each other? +MORE +====================================================== Find/remove avatar collision with ID=0. Test avatar walking up stairs. How does compare with SL. Radius of the capsule affects ability to climb edges. @@ -73,8 +92,6 @@ Debounce avatar contact so legs don't keep folding up when standing. Implement LSL physics controls. Like STATUS_ROTATE_X. Add border extensions to terrain to help region crossings and objects leaving region. -Speed up creation of large physical linksets - For instance, sitting in Neb's car (130 prims) takes several seconds to become physical Performance test with lots of avatars. Can BulletSim support a thousand? Optimize collisions in C++: only send up to the object subscribed to collisions. Use collision subscription and remove the collsion(A,B) and collision(B,A) @@ -85,10 +102,6 @@ Avatar jump Performance measurement and changes to make quicker. Implement detailed physics stats (GetStats()). -Eliminate collisions between objects in a linkset. (LinksetConstraint) - Have UserPointer point to struct with localID and linksetID? - Objects in original linkset still collide with each other? - Measure performance improvement from hulls Test not using ghost objects for volume detect implementation. Performance of closures and delegates for taint processing @@ -101,6 +114,9 @@ Physics Arena central pyramid: why is one side permiable? INTERNAL IMPROVEMENT/CLEANUP ================================================= +Consider moving prim/character body and shape destruction in destroy() + to postTimeTime rather than protecting all the potential sets that + might have been queued up. Remove unused fields from ShapeData (not used in API2) Breakout code for mesh/hull/compound/native into separate BSShape* classes Standardize access to building and reference code. @@ -154,3 +170,6 @@ Package Bullet source mods for Bullet internal stats output (Resolution: move code into WorldData.h rather than relying on patches) Single prim vehicles don't seem to properly vehiclize. (Resolution: mass was not getting set properly for single prim linksets) +Add material type linkage and input all the material property definitions. + Skeleton classes and table are in the sources but are not filled or used. + (Resolution: -- cgit v1.1 From 6f1f7f02065520d061745afff9b1ed1bd672d87b Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 12 Dec 2012 15:07:17 -0800 Subject: BulletSim: non-functional commenting and reorganization of material attribute specifications. --- .../Region/Physics/BulletSPlugin/BSMaterials.cs | 81 +++++++++++++--------- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 1 + 2 files changed, 49 insertions(+), 33 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSMaterials.cs b/OpenSim/Region/Physics/BulletSPlugin/BSMaterials.cs index 390c2f9..c113a43 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSMaterials.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSMaterials.cs @@ -50,10 +50,11 @@ public struct MaterialAttributes Avatar, NumberOfTypes // the count of types in the enum. } + // Names must be in the order of the above enum. - public static string[] MaterialNames = { "Stone", "Metal", "Glass", "Wood", - "Flesh", "Plastic", "Rubber", "Light", "Avatar" }; - public static string[] MaterialAttribs = { "Density", "Friction", "Restitution"}; + // These names must coorespond to the lower case field names in the MaterialAttributes + // structure as reflection is used to select the field to put the value in. + public static readonly string[] MaterialAttribs = { "Density", "Friction", "Restitution"}; public MaterialAttributes(string t, float d, float f, float r) { @@ -70,60 +71,74 @@ public struct MaterialAttributes public static class BSMaterials { - public static MaterialAttributes[] Attributes; + // Attributes for each material type + private static readonly MaterialAttributes[] Attributes; + + // Map of material name to material type code + public static readonly Dictionary MaterialMap; static BSMaterials() { // Attribute sets for both the non-physical and physical instances of materials. Attributes = new MaterialAttributes[(int)MaterialAttributes.Material.NumberOfTypes * 2]; + + // Map of name to type code. + MaterialMap = new Dictionary(); + MaterialMap.Add("Stone", MaterialAttributes.Material.Stone); + MaterialMap.Add("Metal", MaterialAttributes.Material.Metal); + MaterialMap.Add("Glass", MaterialAttributes.Material.Glass); + MaterialMap.Add("Wood", MaterialAttributes.Material.Wood); + MaterialMap.Add("Flesh", MaterialAttributes.Material.Flesh); + MaterialMap.Add("Plastic", MaterialAttributes.Material.Plastic); + MaterialMap.Add("Rubber", MaterialAttributes.Material.Rubber); + MaterialMap.Add("Light", MaterialAttributes.Material.Light); + MaterialMap.Add("Avatar", MaterialAttributes.Material.Avatar); } // This is where all the default material attributes are defined. public static void InitializeFromDefaults(ConfigurationParameters parms) { // Values from http://wiki.secondlife.com/wiki/PRIM_MATERIAL - // public static string[] MaterialNames = { "Stone", "Metal", "Glass", "Wood", - // "Flesh", "Plastic", "Rubber", "Light", "Avatar" }; + float dDensity = parms.defaultDensity; float dFriction = parms.defaultFriction; float dRestitution = parms.defaultRestitution; - float dDensity = parms.defaultDensity; Attributes[(int)MaterialAttributes.Material.Stone] = - new MaterialAttributes("stone",dDensity, 0.8f, 0.4f); + new MaterialAttributes("stone",dDensity, 0.8f, 0.4f); Attributes[(int)MaterialAttributes.Material.Metal] = - new MaterialAttributes("metal",dDensity, 0.3f, 0.4f); + new MaterialAttributes("metal",dDensity, 0.3f, 0.4f); Attributes[(int)MaterialAttributes.Material.Glass] = - new MaterialAttributes("glass",dDensity, 0.2f, 0.7f); + new MaterialAttributes("glass",dDensity, 0.2f, 0.7f); Attributes[(int)MaterialAttributes.Material.Wood] = - new MaterialAttributes("wood",dDensity, 0.6f, 0.5f); + new MaterialAttributes("wood",dDensity, 0.6f, 0.5f); Attributes[(int)MaterialAttributes.Material.Flesh] = - new MaterialAttributes("flesh",dDensity, 0.9f, 0.3f); + new MaterialAttributes("flesh",dDensity, 0.9f, 0.3f); Attributes[(int)MaterialAttributes.Material.Plastic] = - new MaterialAttributes("plastic",dDensity, 0.4f, 0.7f); + new MaterialAttributes("plastic",dDensity, 0.4f, 0.7f); Attributes[(int)MaterialAttributes.Material.Rubber] = - new MaterialAttributes("rubber",dDensity, 0.9f, 0.9f); + new MaterialAttributes("rubber",dDensity, 0.9f, 0.9f); Attributes[(int)MaterialAttributes.Material.Light] = - new MaterialAttributes("light",dDensity, dFriction, dRestitution); + new MaterialAttributes("light",dDensity, dFriction, dRestitution); Attributes[(int)MaterialAttributes.Material.Avatar] = - new MaterialAttributes("avatar",60f, 0.2f, 0f); + new MaterialAttributes("avatar",60f, 0.2f, 0f); Attributes[(int)MaterialAttributes.Material.Stone + (int)MaterialAttributes.Material.NumberOfTypes] = - new MaterialAttributes("stonePhysical",dDensity, 0.8f, 0.4f); + new MaterialAttributes("stonePhysical",dDensity, 0.8f, 0.4f); Attributes[(int)MaterialAttributes.Material.Metal + (int)MaterialAttributes.Material.NumberOfTypes] = - new MaterialAttributes("metalPhysical",dDensity, 0.8f, 0.4f); + new MaterialAttributes("metalPhysical",dDensity, 0.8f, 0.4f); Attributes[(int)MaterialAttributes.Material.Glass + (int)MaterialAttributes.Material.NumberOfTypes] = - new MaterialAttributes("glassPhysical",dDensity, 0.8f, 0.7f); + new MaterialAttributes("glassPhysical",dDensity, 0.8f, 0.7f); Attributes[(int)MaterialAttributes.Material.Wood + (int)MaterialAttributes.Material.NumberOfTypes] = - new MaterialAttributes("woodPhysical",dDensity, 0.8f, 0.5f); + new MaterialAttributes("woodPhysical",dDensity, 0.8f, 0.5f); Attributes[(int)MaterialAttributes.Material.Flesh + (int)MaterialAttributes.Material.NumberOfTypes] = - new MaterialAttributes("fleshPhysical",dDensity, 0.8f, 0.3f); + new MaterialAttributes("fleshPhysical",dDensity, 0.8f, 0.3f); Attributes[(int)MaterialAttributes.Material.Plastic + (int)MaterialAttributes.Material.NumberOfTypes] = - new MaterialAttributes("plasticPhysical",dDensity, 0.8f, 0.7f); + new MaterialAttributes("plasticPhysical",dDensity, 0.8f, 0.7f); Attributes[(int)MaterialAttributes.Material.Rubber + (int)MaterialAttributes.Material.NumberOfTypes] = - new MaterialAttributes("rubberPhysical",dDensity, 0.8f, 0.9f); + new MaterialAttributes("rubberPhysical",dDensity, 0.8f, 0.9f); Attributes[(int)MaterialAttributes.Material.Light + (int)MaterialAttributes.Material.NumberOfTypes] = - new MaterialAttributes("lightPhysical",dDensity, dFriction, dRestitution); + new MaterialAttributes("lightPhysical",dDensity, dFriction, dRestitution); Attributes[(int)MaterialAttributes.Material.Avatar + (int)MaterialAttributes.Material.NumberOfTypes] = - new MaterialAttributes("avatarPhysical",60f, 0.2f, 0f); + new MaterialAttributes("avatarPhysical",60f, 0.2f, 0f); } // Under the [BulletSim] section, one can change the individual material @@ -139,34 +154,34 @@ public static class BSMaterials // the physical value. public static void InitializefromParameters(IConfig pConfig) { - int matType = 0; - foreach (string matName in MaterialAttributes.MaterialNames) + foreach (KeyValuePair kvp in MaterialMap) { + string matName = kvp.Key; foreach (string attribName in MaterialAttributes.MaterialAttribs) { string paramName = matName + attribName; if (pConfig.Contains(paramName)) { float paramValue = pConfig.GetFloat(paramName); - SetAttributeValue(matType, attribName, paramValue); + SetAttributeValue((int)kvp.Value, attribName, paramValue); // set the physical value also - SetAttributeValue(matType + (int)MaterialAttributes.Material.NumberOfTypes, attribName, paramValue); + SetAttributeValue((int)kvp.Value + (int)MaterialAttributes.Material.NumberOfTypes, attribName, paramValue); } paramName += "Physical"; if (pConfig.Contains(paramName)) { float paramValue = pConfig.GetFloat(paramName); - SetAttributeValue(matType + (int)MaterialAttributes.Material.NumberOfTypes, attribName, paramValue); + SetAttributeValue((int)kvp.Value + (int)MaterialAttributes.Material.NumberOfTypes, attribName, paramValue); } } - matType++; } } + // Use reflection to set the value in the attribute structure. private static void SetAttributeValue(int matType, string attribName, float val) { MaterialAttributes thisAttrib = Attributes[matType]; - FieldInfo fieldInfo = thisAttrib.GetType().GetField(attribName); + FieldInfo fieldInfo = thisAttrib.GetType().GetField(attribName.ToLower()); if (fieldInfo != null) { fieldInfo.SetValue(thisAttrib, val); @@ -174,12 +189,12 @@ public static class BSMaterials } } + // Given a material type, return a structure of attributes. public static MaterialAttributes GetAttributes(MaterialAttributes.Material type, bool isPhysical) { int ind = (int)type; if (isPhysical) ind += (int)MaterialAttributes.Material.NumberOfTypes; return Attributes[ind]; } - } } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index f4f2801..cf5bb57 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -309,6 +309,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters BSMaterials.InitializeFromDefaults(Params); if (pConfig != null) { + // Let the user add new and interesting material property values. BSMaterials.InitializefromParameters(pConfig); } } -- cgit v1.1 From e1814aa827c2d0af21d087bd34e3c7f4f7cf25bd Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 12 Dec 2012 16:29:03 -0800 Subject: BulletSim: fix problem of avatar's floating off the ground after unsitting. Reworked size/scale logic so physical scale is kept in Bullet and physObject scale is the preferred size -- usually same as size but avatars are computed differently. --- .../Region/Physics/BulletSPlugin/BSCharacter.cs | 18 +++++++++-------- .../Region/Physics/BulletSPlugin/BSPhysObject.cs | 2 +- OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 8 ++------ .../Physics/BulletSPlugin/BSShapeCollection.cs | 23 +++++++++++++--------- 4 files changed, 27 insertions(+), 24 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 83c78f6..c8aad8d 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -105,12 +105,12 @@ public sealed class BSCharacter : BSPhysObject DetailLog("{0},BSCharacter.create,call,size={1},scale={2},density={3},volume={4},mass={5}", LocalID, _size, Scale, _avatarDensity, _avatarVolume, RawMass); - // do actual create at taint time + // do actual creation in taint time PhysicsScene.TaintedObject("BSCharacter.create", delegate() { DetailLog("{0},BSCharacter.create,taint", LocalID); // New body and shape into PhysBody and PhysShape - PhysicsScene.Shapes.GetBodyAndShape(true, PhysicsScene.World, this, null, null); + PhysicsScene.Shapes.GetBodyAndShape(true, PhysicsScene.World, this); SetPhysicalProperties(); }); @@ -189,6 +189,11 @@ public sealed class BSCharacter : BSPhysObject set { // When an avatar's size is set, only the height is changed. _size = value; + // Old versions of ScenePresence passed only the height. If width and/or depth are zero, + // replace with the default values. + if (_size.X == 0f) _size.X = PhysicsScene.Params.avatarCapsuleDepth; + if (_size.Y == 0f) _size.Y = PhysicsScene.Params.avatarCapsuleWidth; + ComputeAvatarScale(_size); ComputeAvatarVolumeAndMass(); DetailLog("{0},BSCharacter.setSize,call,size={1},scale={2},density={3},volume={4},mass={5}", @@ -196,18 +201,18 @@ public sealed class BSCharacter : BSPhysObject PhysicsScene.TaintedObject("BSCharacter.setSize", delegate() { - if (PhysShape.HasPhysicalShape) + if (PhysBody.HasPhysicalBody && PhysShape.HasPhysicalShape) { BulletSimAPI.SetLocalScaling2(PhysShape.ptr, Scale); UpdatePhysicalMassProperties(RawMass); + // Make sure this change appears as a property update event + BulletSimAPI.PushUpdate2(PhysBody.ptr); } }); } } - public override OMV.Vector3 Scale { get; set; } - public override PrimitiveBaseShape Shape { set { BaseShape = value; } @@ -638,9 +643,6 @@ public sealed class BSCharacter : BSPhysObject private void ComputeAvatarScale(OMV.Vector3 size) { - // The 'size' given by the simulator is the mid-point of the avatar - // and X and Y are unspecified. - OMV.Vector3 newScale = size; // newScale.X = PhysicsScene.Params.avatarCapsuleWidth; // newScale.Y = PhysicsScene.Params.avatarCapsuleDepth; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index f3b6993..6539b43 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs @@ -109,7 +109,7 @@ public abstract class BSPhysObject : PhysicsActor public EntityProperties CurrentEntityProperties { get; set; } public EntityProperties LastEntityProperties { get; set; } - public abstract OMV.Vector3 Scale { get; set; } + public virtual OMV.Vector3 Scale { get; set; } public abstract bool IsSolid { get; } public abstract bool IsStatic { get; } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 35d22c0..19c29cc 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -45,7 +45,6 @@ public sealed class BSPrim : BSPhysObject private static readonly string LogHeader = "[BULLETS PRIM]"; // _size is what the user passed. Scale is what we pass to the physics engine with the mesh. - // Often Scale is unity because the meshmerizer will apply _size when creating the mesh. private OMV.Vector3 _size; // the multiplier for each mesh dimension as passed by the user private bool _grabbed; @@ -93,7 +92,7 @@ public sealed class BSPrim : BSPhysObject _physicsActorType = (int)ActorTypes.Prim; _position = pos; _size = size; - Scale = size; // the scale will be set by CreateGeom depending on object type + Scale = size; // prims are the size the user wants them to be (different for BSCharactes). _orientation = rotation; _buoyancy = 1f; _velocity = OMV.Vector3.Zero; @@ -159,12 +158,10 @@ public sealed class BSPrim : BSPhysObject // We presume the scale and size are the same. If scale must be changed for // the physical shape, that is done when the geometry is built. _size = value; + Scale = _size; ForceBodyShapeRebuild(false); } } - // Scale is what we set in the physics engine. It is different than 'size' in that - // 'size' can be encorporated into the mesh. In that case, the scale is <1,1,1>. - public override OMV.Vector3 Scale { get; set; } public override PrimitiveBaseShape Shape { set { @@ -1369,7 +1366,6 @@ public sealed class BSPrim : BSPhysObject // Create the correct physical representation for this type of object. // Updates PhysBody and PhysShape with the new information. // Ignore 'forceRebuild'. This routine makes the right choices and changes of necessary. - // Returns 'true' if either the body or the shape was changed. PhysicsScene.Shapes.GetBodyAndShape(false, PhysicsScene.World, this, null, delegate(BulletBody dBody) { // Called if the current prim body is about to be destroyed. diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs index 4ab9a99..ea996ae 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs @@ -126,6 +126,11 @@ public sealed class BSShapeCollection : IDisposable return ret; } + public bool GetBodyAndShape(bool forceRebuild, BulletSim sim, BSPhysObject prim) + { + return GetBodyAndShape(forceRebuild, sim, prim, null, null); + } + // Track another user of a body. // We presume the caller has allocated the body. // Bodies only have one user so the body is just put into the world if not already there. @@ -460,6 +465,11 @@ public sealed class BSShapeCollection : IDisposable && pbs.PathScaleX == 100 && pbs.PathScaleY == 100 && pbs.PathShearX == 0 && pbs.PathShearY == 0) ) ) { + // Get the scale of any existing shape so we can see if the new shape is same native type and same size. + OMV.Vector3 scaleOfExistingShape = OMV.Vector3.Zero; + if (prim.PhysShape.HasPhysicalShape) + scaleOfExistingShape = BulletSimAPI.GetLocalScaling2(prim.PhysShape.ptr); + if (DDetail) DetailLog("{0},BSShapeCollection.CreateGeom,maybeNative,force={1},primScale={2},primSize={3},primShape={4}", prim.LocalID, forceRebuild, prim.Scale, prim.Size, prim.PhysShape.type); @@ -469,7 +479,7 @@ public sealed class BSShapeCollection : IDisposable { haveShape = true; if (forceRebuild - || prim.Scale != prim.Size + || prim.Scale != scaleOfExistingShape || prim.PhysShape.type != BSPhysicsShapeType.SHAPE_SPHERE ) { @@ -483,7 +493,7 @@ public sealed class BSShapeCollection : IDisposable { haveShape = true; if (forceRebuild - || prim.Scale != prim.Size + || prim.Scale != scaleOfExistingShape || prim.PhysShape.type != BSPhysicsShapeType.SHAPE_BOX ) { @@ -542,7 +552,6 @@ public sealed class BSShapeCollection : IDisposable prim.LocalID, newShape, prim.Scale); // native shapes are scaled by Bullet - prim.Scale = prim.Size; prim.PhysShape = newShape; return true; } @@ -555,8 +564,8 @@ public sealed class BSShapeCollection : IDisposable ShapeData nativeShapeData = new ShapeData(); nativeShapeData.Type = shapeType; nativeShapeData.ID = prim.LocalID; - nativeShapeData.Scale = prim.Size; - nativeShapeData.Size = prim.Size; // unneeded, I think. + nativeShapeData.Scale = prim.Scale; + nativeShapeData.Size = prim.Scale; // unneeded, I think. nativeShapeData.MeshKey = (ulong)shapeKey; nativeShapeData.HullKey = (ulong)shapeKey; @@ -611,8 +620,6 @@ public sealed class BSShapeCollection : IDisposable ReferenceShape(newShape); - // meshes are already scaled by the meshmerizer - prim.Scale = new OMV.Vector3(1f, 1f, 1f); prim.PhysShape = newShape; return true; // 'true' means a new shape has been added to this prim @@ -683,8 +690,6 @@ public sealed class BSShapeCollection : IDisposable ReferenceShape(newShape); - // hulls are already scaled by the meshmerizer - prim.Scale = new OMV.Vector3(1f, 1f, 1f); prim.PhysShape = newShape; return true; // 'true' means a new shape has been added to this prim } -- cgit v1.1 From 6fca93f0b1343bad8582d10634a4ae4dc161e401 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 13 Dec 2012 01:03:35 +0000 Subject: Fix sounds so that they play from inventory after teleport rather than only on initial login region. Regression from commit ed162a10 (Fri Oct 5 13:50:12 2012) We had started listening for the client login event for attaching the sound trigger event rather than OnNewClient Addresses http://opensimulator.org/mantis/view.php?id=6453 Many thanks to danbanner for identifying the exact commit where this went wrong, which made identifying the fix easy. --- OpenSim/Region/CoreModules/World/Sound/SoundModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs index 089fcda..883045a 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs @@ -76,7 +76,7 @@ namespace OpenSim.Region.CoreModules.World.Sound public void RemoveRegion(Scene scene) { - m_scene.EventManager.OnClientLogin -= OnNewClient; + m_scene.EventManager.OnNewClient -= OnNewClient; } public void RegionLoaded(Scene scene) @@ -85,7 +85,7 @@ namespace OpenSim.Region.CoreModules.World.Sound return; m_scene = scene; - m_scene.EventManager.OnClientLogin += OnNewClient; + m_scene.EventManager.OnNewClient += OnNewClient; m_scene.RegisterModuleInterface(this); } -- cgit v1.1