From eafc3d6c47b736ca6e4d777c8bcaf059d116ed4c Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 16 Mar 2012 08:59:41 -0700 Subject: BulletSim: Update list of TODO tasks --- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index e9a849c..b1e551c 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -52,6 +52,19 @@ using OpenSim.Region.Framework; // Implement LockAngularMotion // Decide if clearing forces is the right thing to do when setting position (BulletSim::SetObjectTranslation) // Does NeedsMeshing() really need to exclude all the different shapes? +// Remove mesh and Hull stuff. Use mesh passed to bullet and use convexdecom from bullet. +// Add PID movement operations +// Debug linkset +// Ccd threshold to defaults (0.0) +// Command line get and set is broken +// Check terrain size. 128 or 127? +// Test with multiple regions in one simulator +// Multiple contact points on collision? +// See code in ode::near... calls to collision_accounting_events() +// Use collision masks for collision with terrain and phantom objects +// Check out llVolumeDetect. Must do something for that. +// Physical phantom objects and related typing (collision options ) +// Raycast // namespace OpenSim.Region.Physics.BulletSPlugin { -- cgit v1.1 From 3e7e1661243447986edb8658379f6604f4ee92de Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 16 Mar 2012 14:05:01 -0700 Subject: BulletSim: update BulletSim.dll to Bullet 2.80 and add libBulletSim.so to the new lib32 and lib64 binary directories --- bin/lib32/BulletSim.dll | Bin 562176 -> 566784 bytes bin/lib32/libBulletSim.so | Bin 0 -> 618542 bytes bin/lib64/BulletSim.dll | Bin 768000 -> 773632 bytes bin/lib64/libBulletSim.so | Bin 0 -> 684103 bytes 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100755 bin/lib32/libBulletSim.so create mode 100755 bin/lib64/libBulletSim.so diff --git a/bin/lib32/BulletSim.dll b/bin/lib32/BulletSim.dll index d1571cf..82d9737 100755 Binary files a/bin/lib32/BulletSim.dll and b/bin/lib32/BulletSim.dll differ diff --git a/bin/lib32/libBulletSim.so b/bin/lib32/libBulletSim.so new file mode 100755 index 0000000..f93f7d7 Binary files /dev/null and b/bin/lib32/libBulletSim.so differ diff --git a/bin/lib64/BulletSim.dll b/bin/lib64/BulletSim.dll index ec21dfe..f922ccc 100755 Binary files a/bin/lib64/BulletSim.dll and b/bin/lib64/BulletSim.dll differ diff --git a/bin/lib64/libBulletSim.so b/bin/lib64/libBulletSim.so new file mode 100755 index 0000000..c0c859f Binary files /dev/null and b/bin/lib64/libBulletSim.so differ -- cgit v1.1 From 898a16802bceab9cc43ad15be6f4354335b471fb Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 16 Mar 2012 16:37:21 -0700 Subject: BulletSim: add some new runtime setable parameters to match the dll. --- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 13 ++++++++++--- OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs | 10 ++++++---- bin/OpenSimDefaults.ini | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index b1e551c..977dcbe 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -177,6 +177,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters if (m_log.IsDebugEnabled) { m_log.DebugFormat("{0}: Initialize: Setting debug callback for unmanaged code", LogHeader); + // the handle is saved to it doesn't get freed after this call m_DebugLogCallbackHandle = new BulletSimAPI.DebugLogCallback(BulletLogger); BulletSimAPI.SetDebugLogCallback(m_DebugLogCallbackHandle); } @@ -185,7 +186,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters mesher = meshmerizer; // The bounding box for the simulated world - Vector3 worldExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, 4096f); + Vector3 worldExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, 8192f); // m_log.DebugFormat("{0}: Initialize: Calling BulletSimAPI.Initialize.", LogHeader); m_worldID = BulletSimAPI.Initialize(worldExtent, m_paramsHandle.AddrOfPinnedObject(), @@ -233,7 +234,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters parms.terrainFriction = 0.5f; parms.terrainHitFraction = 0.8f; parms.terrainRestitution = 0f; - parms.avatarFriction = 0.0f; + parms.avatarFriction = 0.5f; parms.avatarDensity = 60f; parms.avatarCapsuleRadius = 0.37f; parms.avatarCapsuleHeight = 1.5f; // 2.140599f @@ -716,6 +717,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters // new PhysParameterEntry("CcdSweptSphereRadius", "" ), new PhysParameterEntry("ContactProcessingThreshold", "Distance between contacts before doing collision check" ), + new PhysParameterEntry("Friction", "Set friction parameter for a specific object" ), + new PhysParameterEntry("Restitution", "Set restitution parameter for a specific object" ), + new PhysParameterEntry("TerrainFriction", "Factor to reduce movement against terrain surface" ), new PhysParameterEntry("TerrainHitFraction", "Distance to measure hit collisions" ), new PhysParameterEntry("TerrainRestitution", "Bouncyness" ), @@ -756,7 +760,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters case "defaultdensity": m_params[0].defaultDensity = val; break; case "defaultrestitution": m_params[0].defaultRestitution = val; break; case "collisionmargin": m_params[0].collisionMargin = val; break; - case "gravity": m_params[0].gravity = val; TaintedUpdateParameter(lparm, PhysParameterEntry.APPLY_TO_NONE, val); break; + case "gravity": m_params[0].gravity = val; TaintedUpdateParameter(lparm, localID, val); break; case "lineardamping": UpdateParameterPrims(ref m_params[0].linearDamping, lparm, localID, val); break; case "angulardamping": UpdateParameterPrims(ref m_params[0].angularDamping, lparm, localID, val); break; @@ -767,6 +771,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters case "ccdsweptsphereradius": UpdateParameterPrims(ref m_params[0].ccdSweptSphereRadius, lparm, localID, val); break; case "contactprocessingthreshold": UpdateParameterPrims(ref m_params[0].contactProcessingThreshold, lparm, localID, val); break; + case "friction": TaintedUpdateParameter(lparm, localID, val); break; + case "restitution": TaintedUpdateParameter(lparm, localID, val); break; + // set a terrain physical feature and cause terrain to be recalculated case "terrainfriction": m_params[0].terrainFriction = val; TaintedUpdateParameter("terrain", 0, val); break; case "terrainhitfraction": m_params[0].terrainHitFraction = val; TaintedUpdateParameter("terrain", 0, val); break; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs index d12bd7d..aab0994 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs @@ -149,16 +149,16 @@ public static extern uint Initialize(Vector3 maxPosition, IntPtr parms, int maxUpdates, IntPtr updateArray); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] -public static extern bool UpdateParameter(uint worldID, uint localID, - [MarshalAs(UnmanagedType.LPStr)]string paramCode, float value); - -[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern void SetHeightmap(uint worldID, [MarshalAs(UnmanagedType.LPArray)] float[] heightMap); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern void Shutdown(uint worldID); +[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] +public static extern bool UpdateParameter(uint worldID, uint localID, + [MarshalAs(UnmanagedType.LPStr)]string paramCode, float value); +// =============================================================================== [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern int PhysicsStep(uint worldID, float timeStep, int maxSubSteps, float fixedTimeStep, out int updatedEntityCount, @@ -240,6 +240,7 @@ public static extern bool HasObject(uint worldID, uint id); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern bool DestroyObject(uint worldID, uint id); +// =============================================================================== [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern SweepHit ConvexSweepTest(uint worldID, uint id, Vector3 to, float extraMargin); @@ -249,6 +250,7 @@ public static extern RaycastHit RayTest(uint worldID, uint id, Vector3 from, Vec [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern Vector3 RecoverFromPenetration(uint worldID, uint id); +// =============================================================================== [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern void DumpBulletStatistics(); diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index fd31131..d291cfb 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini @@ -833,7 +833,7 @@ TerrainFriction = 0.50 TerrainHitFriction = 0.8 TerrainRestitution = 0 - AvatarFriction = 0 + AvatarFriction = 0.5 AvatarDensity = 60.0 AvatarCapsuleRadius = 0.37 AvatarCapsuleHeight = 1.5 -- cgit v1.1 From 6c55fd93a300cd077bd04c1b8c3bedc7a03074e7 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 16 Mar 2012 17:13:06 -0700 Subject: BulletSim: set buoyancy in only one place --- OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 0cab5d1..e816b61 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -260,11 +260,8 @@ public class BSCharacter : PhysicsActor get { return _flying; } set { _flying = value; - _scene.TaintedObject(delegate() - { - // simulate flying by changing the effect of gravity - BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, LocalID, _flying ? 1f : 0f); - }); + // simulate flying by changing the effect of gravity + this.Buoyancy(_flying ? 1f : 0f); } } public override bool @@ -299,6 +296,7 @@ public class BSCharacter : PhysicsActor get { return _kinematic; } set { _kinematic = value; } } + // neg=fall quickly, 0=1g, 1=0g, pos=float up public override float Buoyancy { get { return _buoyancy; } set { _buoyancy = value; -- cgit v1.1 From cb2727cf6e7b40473d10cfbea61155f5bcf6646f Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sun, 18 Mar 2012 11:53:53 -0700 Subject: BulletSim: Add AvatarRestitution parameter. Centralize computation of buoyancy for flying. Tweek avatar default friction and resititution --- OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | 9 ++++++--- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 3 +++ bin/OpenSimDefaults.ini | 3 ++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index e816b61..1a61431 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -94,7 +94,7 @@ public class BSCharacter : PhysicsActor _flying = isFlying; _orientation = Quaternion.Identity; _velocity = Vector3.Zero; - _buoyancy = isFlying ? 1f : 0f; + _buoyancy = ComputeBuoyancyFromFlying(isFlying); _scale = new Vector3(1f, 1f, 1f); _density = _scene.Params.avatarDensity; ComputeAvatarVolumeAndMass(); // set _avatarVolume and _mass based on capsule size, _density and _scale @@ -110,7 +110,7 @@ public class BSCharacter : PhysicsActor shapeData.Buoyancy = _buoyancy; shapeData.Static = ShapeData.numericFalse; shapeData.Friction = _scene.Params.avatarFriction; - shapeData.Restitution = _scene.Params.defaultRestitution; + shapeData.Restitution = _scene.Params.avatarRestitution; // do actual create at taint time _scene.TaintedObject(delegate() @@ -261,9 +261,12 @@ public class BSCharacter : PhysicsActor set { _flying = value; // simulate flying by changing the effect of gravity - this.Buoyancy(_flying ? 1f : 0f); + this.Buoyancy(ComputeBuoyancyFromFlying(_flying)); } } + private float ComputeBuoyancyFromFlying(bool ifFlying) { + return ifFlying ? 1f : 0f; + } public override bool SetAlwaysRun { get { return _setAlwaysRun; } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 977dcbe..9b12b4f 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -235,6 +235,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters parms.terrainHitFraction = 0.8f; parms.terrainRestitution = 0f; parms.avatarFriction = 0.5f; + parms.avatarRestitution = 0.0f; parms.avatarDensity = 60f; parms.avatarCapsuleRadius = 0.37f; parms.avatarCapsuleHeight = 1.5f; // 2.140599f @@ -279,7 +280,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters parms.terrainHitFraction = pConfig.GetFloat("TerrainHitFraction", parms.terrainHitFraction); parms.terrainRestitution = pConfig.GetFloat("TerrainRestitution", parms.terrainRestitution); parms.avatarFriction = pConfig.GetFloat("AvatarFriction", parms.avatarFriction); + parms.avatarRestitution = pConfig.GetFloat("AvatarRestitution", parms.avatarRestitution); parms.avatarDensity = pConfig.GetFloat("AvatarDensity", parms.avatarDensity); + parms.avatarRestitution = pConfig.GetFloat("AvatarRestitution", parms.avatarRestitution); parms.avatarCapsuleRadius = pConfig.GetFloat("AvatarCapsuleRadius", parms.avatarCapsuleRadius); parms.avatarCapsuleHeight = pConfig.GetFloat("AvatarCapsuleHeight", parms.avatarCapsuleHeight); } diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index d291cfb..2f4a549 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini @@ -833,7 +833,8 @@ TerrainFriction = 0.50 TerrainHitFriction = 0.8 TerrainRestitution = 0 - AvatarFriction = 0.5 + AvatarFriction = 0.2 + AvatarRestitution = 0.0 AvatarDensity = 60.0 AvatarCapsuleRadius = 0.37 AvatarCapsuleHeight = 1.5 -- cgit v1.1 From 7783c93802f61d4ed9994c3f9e924066be0469be Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 21 Mar 2012 07:07:44 -0700 Subject: BulletSim: update TODO list. Rearrange code for readability. Add per object friction and restitution runtime settable parameters. --- .../Region/Physics/BulletSPlugin/BSCharacter.cs | 4 +-- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 30 +++++++++++----------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 1a61431..20708d9 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -261,7 +261,7 @@ public class BSCharacter : PhysicsActor set { _flying = value; // simulate flying by changing the effect of gravity - this.Buoyancy(ComputeBuoyancyFromFlying(_flying)); + this.Buoyancy = ComputeBuoyancyFromFlying(_flying); } } private float ComputeBuoyancyFromFlying(bool ifFlying) { @@ -356,7 +356,7 @@ public class BSCharacter : PhysicsActor } else { - m_log.WarnFormat("{0}: Got a NaN force applied to a Character", LogHeader); + m_log.ErrorFormat("{0}: Got a NaN force applied to a Character", LogHeader); } //m_lastUpdateSent = false; } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 9b12b4f..142103b 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -37,14 +37,18 @@ using OpenMetaverse; using OpenSim.Region.Framework; // TODOs for BulletSim (for BSScene, BSPrim, BSCharacter and BulletSim) +// Debug linkset +// Test with multiple regions in one simulator // Adjust character capsule size when height is adjusted (ScenePresence.SetHeight) // Test sculpties // Compute physics FPS reasonably // Based on material, set density and friction -// More efficient memory usage in passing hull information from BSPrim to BulletSim +// More efficient memory usage when passing hull information from BSPrim to BulletSim // Four states of prim: Physical, regular, phantom and selected. Are we modeling these correctly? // In SL one can set both physical and phantom (gravity, does not effect others, makes collisions with ground) // At the moment, physical and phantom causes object to drop through the terrain +// Physical phantom objects and related typing (collision options ) +// Check out llVolumeDetect. Must do something for that. // Should prim.link() and prim.delink() membership checking happen at taint time? // Mesh sharing. Use meshHash to tell if we already have a hull of that shape and only create once // Do attachments need to be handled separately? Need collision events. Do not collide with VolumeDetect @@ -53,17 +57,14 @@ using OpenSim.Region.Framework; // Decide if clearing forces is the right thing to do when setting position (BulletSim::SetObjectTranslation) // Does NeedsMeshing() really need to exclude all the different shapes? // Remove mesh and Hull stuff. Use mesh passed to bullet and use convexdecom from bullet. -// Add PID movement operations -// Debug linkset -// Ccd threshold to defaults (0.0) -// Command line get and set is broken +// Add PID movement operations. What does ScenePresence.MoveToTarget do? // Check terrain size. 128 or 127? -// Test with multiple regions in one simulator // Multiple contact points on collision? // See code in ode::near... calls to collision_accounting_events() +// (This might not be a problem. ODE collects all the collisions with one object in one tick.) // Use collision masks for collision with terrain and phantom objects -// Check out llVolumeDetect. Must do something for that. -// Physical phantom objects and related typing (collision options ) +// Figure out how to not allocate a new Dictionary and List for every collision +// in BSPrim.Collide() and BSCharacter.Collide(). Can the same ones be reused? // Raycast // namespace OpenSim.Region.Physics.BulletSPlugin @@ -282,7 +283,6 @@ public class BSScene : PhysicsScene, IPhysicsParameters parms.avatarFriction = pConfig.GetFloat("AvatarFriction", parms.avatarFriction); parms.avatarRestitution = pConfig.GetFloat("AvatarRestitution", parms.avatarRestitution); parms.avatarDensity = pConfig.GetFloat("AvatarDensity", parms.avatarDensity); - parms.avatarRestitution = pConfig.GetFloat("AvatarRestitution", parms.avatarRestitution); parms.avatarCapsuleRadius = pConfig.GetFloat("AvatarCapsuleRadius", parms.avatarCapsuleRadius); parms.avatarCapsuleHeight = pConfig.GetFloat("AvatarCapsuleHeight", parms.avatarCapsuleHeight); } @@ -408,16 +408,16 @@ public class BSScene : PhysicsScene, IPhysicsParameters { EntityProperties entprop = m_updateArray[ii]; // m_log.DebugFormat("{0}: entprop[{1}]: id={2}, pos={3}", LogHeader, ii, entprop.ID, entprop.Position); - BSCharacter actor; - if (m_avatars.TryGetValue(entprop.ID, out actor)) - { - actor.UpdateProperties(entprop); - continue; - } BSPrim prim; if (m_prims.TryGetValue(entprop.ID, out prim)) { prim.UpdateProperties(entprop); + continue; + } + BSCharacter actor; + if (m_avatars.TryGetValue(entprop.ID, out actor)) + { + actor.UpdateProperties(entprop); } } } -- cgit v1.1 From 4bfd9e28caa8273ed27804e1bae938e0f8daf5c3 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 21 Mar 2012 17:24:17 -0700 Subject: BulletSim: add updated (but not working) BulletSim dlls --- bin/lib32/BulletSim.dll | Bin 566784 -> 532480 bytes bin/lib32/libBulletSim.so | Bin 618542 -> 618538 bytes bin/lib64/BulletSim.dll | Bin 773632 -> 684544 bytes bin/lib64/libBulletSim.so | Bin 684103 -> 684103 bytes 4 files changed, 0 insertions(+), 0 deletions(-) diff --git a/bin/lib32/BulletSim.dll b/bin/lib32/BulletSim.dll index 82d9737..7811c46 100755 Binary files a/bin/lib32/BulletSim.dll and b/bin/lib32/BulletSim.dll differ diff --git a/bin/lib32/libBulletSim.so b/bin/lib32/libBulletSim.so index f93f7d7..dd2c5ee 100755 Binary files a/bin/lib32/libBulletSim.so and b/bin/lib32/libBulletSim.so differ diff --git a/bin/lib64/BulletSim.dll b/bin/lib64/BulletSim.dll index f922ccc..b8a4ed0 100755 Binary files a/bin/lib64/BulletSim.dll and b/bin/lib64/BulletSim.dll differ diff --git a/bin/lib64/libBulletSim.so b/bin/lib64/libBulletSim.so index c0c859f..3ee7cbf 100755 Binary files a/bin/lib64/libBulletSim.so and b/bin/lib64/libBulletSim.so differ -- cgit v1.1 From efe61b2481ce10f16b156542c122971d35c227e1 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 22 Mar 2012 17:04:06 -0700 Subject: BulletSim: remove confusion between angularVelocity and rotationalVelocity (there is still confusion in the rest of OpenSim). Enhance some debug statements to include the object ID. --- OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 4 ++-- OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 17 ++++++----------- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 5 +++-- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index 046726d..eb20eb3 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs @@ -821,7 +821,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin */ // Get what the body is doing, this includes 'external' influences - Vector3 angularVelocity = m_prim.AngularVelocity; + Vector3 angularVelocity = m_prim.RotationalVelocity; // Vector3 angularVelocity = Vector3.Zero; if (m_angularMotorApply > 0) @@ -910,7 +910,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin m_lastAngularVelocity -= m_lastAngularVelocity * decayamount; // Apply to the body - m_prim.AngularVelocity = m_lastAngularVelocity; + m_prim.RotationalVelocity = m_lastAngularVelocity; } //end MoveAngular internal void LimitRotation(float timestep) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 898436b..f122df9 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -85,7 +85,6 @@ public sealed class BSPrim : PhysicsActor private OMV.Vector3 _rotationalVelocity; private bool _kinematic; private float _buoyancy; - private OMV.Vector3 _angularVelocity; private List _childrenPrims; private BSPrim _parentPrim; @@ -119,7 +118,6 @@ public sealed class BSPrim : PhysicsActor _buoyancy = 1f; _velocity = OMV.Vector3.Zero; _rotationalVelocity = OMV.Vector3.Zero; - _angularVelocity = OMV.Vector3.Zero; _hullKey = 0; _meshKey = 0; _pbs = pbs; @@ -146,7 +144,7 @@ public sealed class BSPrim : PhysicsActor // called when this prim is being destroyed and we should free all the resources public void Destroy() { - // m_log.DebugFormat("{0}: Destroy", LogHeader); + // m_log.DebugFormat("{0}: Destroy, id={1}", LogHeader, LocalID); // Undo any vehicle properties _vehicle.ProcessTypeChange(Vehicle.TYPE_NONE); _scene.RemoveVehiclePrim(this); // just to make sure @@ -203,7 +201,7 @@ public sealed class BSPrim : PhysicsActor // link me to the specified parent public override void link(PhysicsActor obj) { - BSPrim parent = (BSPrim)obj; + BSPrim parent = obj as BSPrim; // m_log.DebugFormat("{0}: link {1}/{2} to {3}", LogHeader, _avName, _localID, obj.LocalID); // TODO: decide if this parent checking needs to happen at taint time if (_parentPrim == null) @@ -527,10 +525,6 @@ public sealed class BSPrim : PhysicsActor }); } } - public OMV.Vector3 AngularVelocity { - get { return _angularVelocity; } - set { _angularVelocity = value; } - } public override bool Kinematic { get { return _kinematic; } set { _kinematic = value; @@ -993,7 +987,7 @@ public sealed class BSPrim : PhysicsActor } // m_log.DebugFormat("{0}: CreateGeomMesh: calling CreateMesh. lid={1}, key={2}, indices={3}, vertices={4}", - // LogHeader, _localID, _meshKey, indices.Length, vertices.Count); + // LogHeader, _localID, _meshKey, indices.Length, vertices.Count); BulletSimAPI.CreateMesh(_scene.WorldID, _meshKey, indices.GetLength(0), indices, vertices.Count, verticesAsFloats); @@ -1127,7 +1121,7 @@ public sealed class BSPrim : PhysicsActor return; } - // Create an object in Bullet + // Create an object in Bullet if it has not already been created // No locking here because this is done when the physics engine is not simulating private void CreateObject() { @@ -1324,7 +1318,8 @@ public sealed class BSPrim : PhysicsActor _velocity = entprop.Velocity; _acceleration = entprop.Acceleration; _rotationalVelocity = entprop.RotationalVelocity; - // m_log.DebugFormat("{0}: RequestTerseUpdate. id={1}, ch={2}, pos={3}, rot={4}", LogHeader, LocalID, changed, _position, _orientation); + // 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); base.RequestPhysicsterseUpdate(); } } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 142103b..13d5e03 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -487,12 +487,12 @@ public class BSScene : PhysicsScene, IPhysicsParameters public override void DeleteTerrain() { - m_log.DebugFormat("{0}: DeleteTerrain()", LogHeader); + // m_log.DebugFormat("{0}: DeleteTerrain()", LogHeader); } public override void Dispose() { - m_log.DebugFormat("{0}: Dispose()", LogHeader); + // m_log.DebugFormat("{0}: Dispose()", LogHeader); } public override Dictionary GetTopColliders() @@ -753,6 +753,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters switch (lparm) { case "detailedstats": m_detailedStatsStep = (int)val; break; + case "meshlod": m_meshLOD = (int)val; break; case "sculptlod": m_sculptLOD = (int)val; break; case "maxsubstep": m_maxSubSteps = (int)val; break; -- cgit v1.1 From 975184b3f94e169a720ee1dd9044f09a7dbb77cd Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 16 Mar 2012 08:59:41 -0700 Subject: BulletSim: Update list of TODO tasks --- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index e9a849c..b1e551c 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -52,6 +52,19 @@ using OpenSim.Region.Framework; // Implement LockAngularMotion // Decide if clearing forces is the right thing to do when setting position (BulletSim::SetObjectTranslation) // Does NeedsMeshing() really need to exclude all the different shapes? +// Remove mesh and Hull stuff. Use mesh passed to bullet and use convexdecom from bullet. +// Add PID movement operations +// Debug linkset +// Ccd threshold to defaults (0.0) +// Command line get and set is broken +// Check terrain size. 128 or 127? +// Test with multiple regions in one simulator +// Multiple contact points on collision? +// See code in ode::near... calls to collision_accounting_events() +// Use collision masks for collision with terrain and phantom objects +// Check out llVolumeDetect. Must do something for that. +// Physical phantom objects and related typing (collision options ) +// Raycast // namespace OpenSim.Region.Physics.BulletSPlugin { -- cgit v1.1 From 6c504426252668a7d366705e49ca1ba642367412 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 16 Mar 2012 14:05:01 -0700 Subject: BulletSim: update BulletSim.dll to Bullet 2.80 and add libBulletSim.so to the new lib32 and lib64 binary directories --- bin/lib32/BulletSim.dll | Bin 562176 -> 566784 bytes bin/lib32/libBulletSim.so | Bin 0 -> 618542 bytes bin/lib64/BulletSim.dll | Bin 768000 -> 773632 bytes bin/lib64/libBulletSim.so | Bin 0 -> 684103 bytes 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100755 bin/lib32/libBulletSim.so create mode 100755 bin/lib64/libBulletSim.so diff --git a/bin/lib32/BulletSim.dll b/bin/lib32/BulletSim.dll index d1571cf..82d9737 100755 Binary files a/bin/lib32/BulletSim.dll and b/bin/lib32/BulletSim.dll differ diff --git a/bin/lib32/libBulletSim.so b/bin/lib32/libBulletSim.so new file mode 100755 index 0000000..f93f7d7 Binary files /dev/null and b/bin/lib32/libBulletSim.so differ diff --git a/bin/lib64/BulletSim.dll b/bin/lib64/BulletSim.dll index ec21dfe..f922ccc 100755 Binary files a/bin/lib64/BulletSim.dll and b/bin/lib64/BulletSim.dll differ diff --git a/bin/lib64/libBulletSim.so b/bin/lib64/libBulletSim.so new file mode 100755 index 0000000..c0c859f Binary files /dev/null and b/bin/lib64/libBulletSim.so differ -- cgit v1.1 From b22d0401693dad44790d4cbf58d85c0fe3870460 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 16 Mar 2012 16:37:21 -0700 Subject: BulletSim: add some new runtime setable parameters to match the dll. --- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 13 ++++++++++--- OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs | 10 ++++++---- bin/OpenSimDefaults.ini | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index b1e551c..977dcbe 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -177,6 +177,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters if (m_log.IsDebugEnabled) { m_log.DebugFormat("{0}: Initialize: Setting debug callback for unmanaged code", LogHeader); + // the handle is saved to it doesn't get freed after this call m_DebugLogCallbackHandle = new BulletSimAPI.DebugLogCallback(BulletLogger); BulletSimAPI.SetDebugLogCallback(m_DebugLogCallbackHandle); } @@ -185,7 +186,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters mesher = meshmerizer; // The bounding box for the simulated world - Vector3 worldExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, 4096f); + Vector3 worldExtent = new Vector3(Constants.RegionSize, Constants.RegionSize, 8192f); // m_log.DebugFormat("{0}: Initialize: Calling BulletSimAPI.Initialize.", LogHeader); m_worldID = BulletSimAPI.Initialize(worldExtent, m_paramsHandle.AddrOfPinnedObject(), @@ -233,7 +234,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters parms.terrainFriction = 0.5f; parms.terrainHitFraction = 0.8f; parms.terrainRestitution = 0f; - parms.avatarFriction = 0.0f; + parms.avatarFriction = 0.5f; parms.avatarDensity = 60f; parms.avatarCapsuleRadius = 0.37f; parms.avatarCapsuleHeight = 1.5f; // 2.140599f @@ -716,6 +717,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters // new PhysParameterEntry("CcdSweptSphereRadius", "" ), new PhysParameterEntry("ContactProcessingThreshold", "Distance between contacts before doing collision check" ), + new PhysParameterEntry("Friction", "Set friction parameter for a specific object" ), + new PhysParameterEntry("Restitution", "Set restitution parameter for a specific object" ), + new PhysParameterEntry("TerrainFriction", "Factor to reduce movement against terrain surface" ), new PhysParameterEntry("TerrainHitFraction", "Distance to measure hit collisions" ), new PhysParameterEntry("TerrainRestitution", "Bouncyness" ), @@ -756,7 +760,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters case "defaultdensity": m_params[0].defaultDensity = val; break; case "defaultrestitution": m_params[0].defaultRestitution = val; break; case "collisionmargin": m_params[0].collisionMargin = val; break; - case "gravity": m_params[0].gravity = val; TaintedUpdateParameter(lparm, PhysParameterEntry.APPLY_TO_NONE, val); break; + case "gravity": m_params[0].gravity = val; TaintedUpdateParameter(lparm, localID, val); break; case "lineardamping": UpdateParameterPrims(ref m_params[0].linearDamping, lparm, localID, val); break; case "angulardamping": UpdateParameterPrims(ref m_params[0].angularDamping, lparm, localID, val); break; @@ -767,6 +771,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters case "ccdsweptsphereradius": UpdateParameterPrims(ref m_params[0].ccdSweptSphereRadius, lparm, localID, val); break; case "contactprocessingthreshold": UpdateParameterPrims(ref m_params[0].contactProcessingThreshold, lparm, localID, val); break; + case "friction": TaintedUpdateParameter(lparm, localID, val); break; + case "restitution": TaintedUpdateParameter(lparm, localID, val); break; + // set a terrain physical feature and cause terrain to be recalculated case "terrainfriction": m_params[0].terrainFriction = val; TaintedUpdateParameter("terrain", 0, val); break; case "terrainhitfraction": m_params[0].terrainHitFraction = val; TaintedUpdateParameter("terrain", 0, val); break; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs index d12bd7d..aab0994 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs @@ -149,16 +149,16 @@ public static extern uint Initialize(Vector3 maxPosition, IntPtr parms, int maxUpdates, IntPtr updateArray); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] -public static extern bool UpdateParameter(uint worldID, uint localID, - [MarshalAs(UnmanagedType.LPStr)]string paramCode, float value); - -[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern void SetHeightmap(uint worldID, [MarshalAs(UnmanagedType.LPArray)] float[] heightMap); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern void Shutdown(uint worldID); +[DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] +public static extern bool UpdateParameter(uint worldID, uint localID, + [MarshalAs(UnmanagedType.LPStr)]string paramCode, float value); +// =============================================================================== [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern int PhysicsStep(uint worldID, float timeStep, int maxSubSteps, float fixedTimeStep, out int updatedEntityCount, @@ -240,6 +240,7 @@ public static extern bool HasObject(uint worldID, uint id); [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern bool DestroyObject(uint worldID, uint id); +// =============================================================================== [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern SweepHit ConvexSweepTest(uint worldID, uint id, Vector3 to, float extraMargin); @@ -249,6 +250,7 @@ public static extern RaycastHit RayTest(uint worldID, uint id, Vector3 from, Vec [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern Vector3 RecoverFromPenetration(uint worldID, uint id); +// =============================================================================== [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] public static extern void DumpBulletStatistics(); diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index 6986046..1216bce 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini @@ -846,7 +846,7 @@ TerrainFriction = 0.50 TerrainHitFriction = 0.8 TerrainRestitution = 0 - AvatarFriction = 0 + AvatarFriction = 0.5 AvatarDensity = 60.0 AvatarCapsuleRadius = 0.37 AvatarCapsuleHeight = 1.5 -- cgit v1.1 From 6ecdadb32999aed776df29e53541326958daf836 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 16 Mar 2012 17:13:06 -0700 Subject: BulletSim: set buoyancy in only one place --- OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 0cab5d1..e816b61 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -260,11 +260,8 @@ public class BSCharacter : PhysicsActor get { return _flying; } set { _flying = value; - _scene.TaintedObject(delegate() - { - // simulate flying by changing the effect of gravity - BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, LocalID, _flying ? 1f : 0f); - }); + // simulate flying by changing the effect of gravity + this.Buoyancy(_flying ? 1f : 0f); } } public override bool @@ -299,6 +296,7 @@ public class BSCharacter : PhysicsActor get { return _kinematic; } set { _kinematic = value; } } + // neg=fall quickly, 0=1g, 1=0g, pos=float up public override float Buoyancy { get { return _buoyancy; } set { _buoyancy = value; -- cgit v1.1 From de24feb275ddd1c7e7c0b04900718a9000b8d49b Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sun, 18 Mar 2012 11:53:53 -0700 Subject: BulletSim: Add AvatarRestitution parameter. Centralize computation of buoyancy for flying. Tweek avatar default friction and resititution --- OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | 9 ++++++--- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 3 +++ bin/OpenSimDefaults.ini | 3 ++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index e816b61..1a61431 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -94,7 +94,7 @@ public class BSCharacter : PhysicsActor _flying = isFlying; _orientation = Quaternion.Identity; _velocity = Vector3.Zero; - _buoyancy = isFlying ? 1f : 0f; + _buoyancy = ComputeBuoyancyFromFlying(isFlying); _scale = new Vector3(1f, 1f, 1f); _density = _scene.Params.avatarDensity; ComputeAvatarVolumeAndMass(); // set _avatarVolume and _mass based on capsule size, _density and _scale @@ -110,7 +110,7 @@ public class BSCharacter : PhysicsActor shapeData.Buoyancy = _buoyancy; shapeData.Static = ShapeData.numericFalse; shapeData.Friction = _scene.Params.avatarFriction; - shapeData.Restitution = _scene.Params.defaultRestitution; + shapeData.Restitution = _scene.Params.avatarRestitution; // do actual create at taint time _scene.TaintedObject(delegate() @@ -261,9 +261,12 @@ public class BSCharacter : PhysicsActor set { _flying = value; // simulate flying by changing the effect of gravity - this.Buoyancy(_flying ? 1f : 0f); + this.Buoyancy(ComputeBuoyancyFromFlying(_flying)); } } + private float ComputeBuoyancyFromFlying(bool ifFlying) { + return ifFlying ? 1f : 0f; + } public override bool SetAlwaysRun { get { return _setAlwaysRun; } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 977dcbe..9b12b4f 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -235,6 +235,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters parms.terrainHitFraction = 0.8f; parms.terrainRestitution = 0f; parms.avatarFriction = 0.5f; + parms.avatarRestitution = 0.0f; parms.avatarDensity = 60f; parms.avatarCapsuleRadius = 0.37f; parms.avatarCapsuleHeight = 1.5f; // 2.140599f @@ -279,7 +280,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters parms.terrainHitFraction = pConfig.GetFloat("TerrainHitFraction", parms.terrainHitFraction); parms.terrainRestitution = pConfig.GetFloat("TerrainRestitution", parms.terrainRestitution); parms.avatarFriction = pConfig.GetFloat("AvatarFriction", parms.avatarFriction); + parms.avatarRestitution = pConfig.GetFloat("AvatarRestitution", parms.avatarRestitution); parms.avatarDensity = pConfig.GetFloat("AvatarDensity", parms.avatarDensity); + parms.avatarRestitution = pConfig.GetFloat("AvatarRestitution", parms.avatarRestitution); parms.avatarCapsuleRadius = pConfig.GetFloat("AvatarCapsuleRadius", parms.avatarCapsuleRadius); parms.avatarCapsuleHeight = pConfig.GetFloat("AvatarCapsuleHeight", parms.avatarCapsuleHeight); } diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index 1216bce..a31e6f4 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini @@ -846,7 +846,8 @@ TerrainFriction = 0.50 TerrainHitFriction = 0.8 TerrainRestitution = 0 - AvatarFriction = 0.5 + AvatarFriction = 0.2 + AvatarRestitution = 0.0 AvatarDensity = 60.0 AvatarCapsuleRadius = 0.37 AvatarCapsuleHeight = 1.5 -- cgit v1.1 From 1a738caecab74c5b9f6b6bac69a3ea9ccdc80b24 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 21 Mar 2012 07:07:44 -0700 Subject: BulletSim: update TODO list. Rearrange code for readability. Add per object friction and restitution runtime settable parameters. --- .../Region/Physics/BulletSPlugin/BSCharacter.cs | 4 +-- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 30 +++++++++++----------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 1a61431..20708d9 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -261,7 +261,7 @@ public class BSCharacter : PhysicsActor set { _flying = value; // simulate flying by changing the effect of gravity - this.Buoyancy(ComputeBuoyancyFromFlying(_flying)); + this.Buoyancy = ComputeBuoyancyFromFlying(_flying); } } private float ComputeBuoyancyFromFlying(bool ifFlying) { @@ -356,7 +356,7 @@ public class BSCharacter : PhysicsActor } else { - m_log.WarnFormat("{0}: Got a NaN force applied to a Character", LogHeader); + m_log.ErrorFormat("{0}: Got a NaN force applied to a Character", LogHeader); } //m_lastUpdateSent = false; } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 9b12b4f..142103b 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -37,14 +37,18 @@ using OpenMetaverse; using OpenSim.Region.Framework; // TODOs for BulletSim (for BSScene, BSPrim, BSCharacter and BulletSim) +// Debug linkset +// Test with multiple regions in one simulator // Adjust character capsule size when height is adjusted (ScenePresence.SetHeight) // Test sculpties // Compute physics FPS reasonably // Based on material, set density and friction -// More efficient memory usage in passing hull information from BSPrim to BulletSim +// More efficient memory usage when passing hull information from BSPrim to BulletSim // Four states of prim: Physical, regular, phantom and selected. Are we modeling these correctly? // In SL one can set both physical and phantom (gravity, does not effect others, makes collisions with ground) // At the moment, physical and phantom causes object to drop through the terrain +// Physical phantom objects and related typing (collision options ) +// Check out llVolumeDetect. Must do something for that. // Should prim.link() and prim.delink() membership checking happen at taint time? // Mesh sharing. Use meshHash to tell if we already have a hull of that shape and only create once // Do attachments need to be handled separately? Need collision events. Do not collide with VolumeDetect @@ -53,17 +57,14 @@ using OpenSim.Region.Framework; // Decide if clearing forces is the right thing to do when setting position (BulletSim::SetObjectTranslation) // Does NeedsMeshing() really need to exclude all the different shapes? // Remove mesh and Hull stuff. Use mesh passed to bullet and use convexdecom from bullet. -// Add PID movement operations -// Debug linkset -// Ccd threshold to defaults (0.0) -// Command line get and set is broken +// Add PID movement operations. What does ScenePresence.MoveToTarget do? // Check terrain size. 128 or 127? -// Test with multiple regions in one simulator // Multiple contact points on collision? // See code in ode::near... calls to collision_accounting_events() +// (This might not be a problem. ODE collects all the collisions with one object in one tick.) // Use collision masks for collision with terrain and phantom objects -// Check out llVolumeDetect. Must do something for that. -// Physical phantom objects and related typing (collision options ) +// Figure out how to not allocate a new Dictionary and List for every collision +// in BSPrim.Collide() and BSCharacter.Collide(). Can the same ones be reused? // Raycast // namespace OpenSim.Region.Physics.BulletSPlugin @@ -282,7 +283,6 @@ public class BSScene : PhysicsScene, IPhysicsParameters parms.avatarFriction = pConfig.GetFloat("AvatarFriction", parms.avatarFriction); parms.avatarRestitution = pConfig.GetFloat("AvatarRestitution", parms.avatarRestitution); parms.avatarDensity = pConfig.GetFloat("AvatarDensity", parms.avatarDensity); - parms.avatarRestitution = pConfig.GetFloat("AvatarRestitution", parms.avatarRestitution); parms.avatarCapsuleRadius = pConfig.GetFloat("AvatarCapsuleRadius", parms.avatarCapsuleRadius); parms.avatarCapsuleHeight = pConfig.GetFloat("AvatarCapsuleHeight", parms.avatarCapsuleHeight); } @@ -408,16 +408,16 @@ public class BSScene : PhysicsScene, IPhysicsParameters { EntityProperties entprop = m_updateArray[ii]; // m_log.DebugFormat("{0}: entprop[{1}]: id={2}, pos={3}", LogHeader, ii, entprop.ID, entprop.Position); - BSCharacter actor; - if (m_avatars.TryGetValue(entprop.ID, out actor)) - { - actor.UpdateProperties(entprop); - continue; - } BSPrim prim; if (m_prims.TryGetValue(entprop.ID, out prim)) { prim.UpdateProperties(entprop); + continue; + } + BSCharacter actor; + if (m_avatars.TryGetValue(entprop.ID, out actor)) + { + actor.UpdateProperties(entprop); } } } -- cgit v1.1 From 2f6e8564fe01a4a6421fdda5acdf41aef99cce8a Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 21 Mar 2012 17:24:17 -0700 Subject: BulletSim: add updated (but not working) BulletSim dlls --- bin/lib32/BulletSim.dll | Bin 566784 -> 532480 bytes bin/lib32/libBulletSim.so | Bin 618542 -> 618538 bytes bin/lib64/BulletSim.dll | Bin 773632 -> 684544 bytes bin/lib64/libBulletSim.so | Bin 684103 -> 684103 bytes 4 files changed, 0 insertions(+), 0 deletions(-) diff --git a/bin/lib32/BulletSim.dll b/bin/lib32/BulletSim.dll index 82d9737..7811c46 100755 Binary files a/bin/lib32/BulletSim.dll and b/bin/lib32/BulletSim.dll differ diff --git a/bin/lib32/libBulletSim.so b/bin/lib32/libBulletSim.so index f93f7d7..dd2c5ee 100755 Binary files a/bin/lib32/libBulletSim.so and b/bin/lib32/libBulletSim.so differ diff --git a/bin/lib64/BulletSim.dll b/bin/lib64/BulletSim.dll index f922ccc..b8a4ed0 100755 Binary files a/bin/lib64/BulletSim.dll and b/bin/lib64/BulletSim.dll differ diff --git a/bin/lib64/libBulletSim.so b/bin/lib64/libBulletSim.so index c0c859f..3ee7cbf 100755 Binary files a/bin/lib64/libBulletSim.so and b/bin/lib64/libBulletSim.so differ -- cgit v1.1 From 1273f259e46154f861104610e8f6029b3c19623d Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 22 Mar 2012 17:04:06 -0700 Subject: BulletSim: remove confusion between angularVelocity and rotationalVelocity (there is still confusion in the rest of OpenSim). Enhance some debug statements to include the object ID. --- OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 4 ++-- OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 17 ++++++----------- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 5 +++-- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index 046726d..eb20eb3 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs @@ -821,7 +821,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin */ // Get what the body is doing, this includes 'external' influences - Vector3 angularVelocity = m_prim.AngularVelocity; + Vector3 angularVelocity = m_prim.RotationalVelocity; // Vector3 angularVelocity = Vector3.Zero; if (m_angularMotorApply > 0) @@ -910,7 +910,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin m_lastAngularVelocity -= m_lastAngularVelocity * decayamount; // Apply to the body - m_prim.AngularVelocity = m_lastAngularVelocity; + m_prim.RotationalVelocity = m_lastAngularVelocity; } //end MoveAngular internal void LimitRotation(float timestep) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 898436b..f122df9 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -85,7 +85,6 @@ public sealed class BSPrim : PhysicsActor private OMV.Vector3 _rotationalVelocity; private bool _kinematic; private float _buoyancy; - private OMV.Vector3 _angularVelocity; private List _childrenPrims; private BSPrim _parentPrim; @@ -119,7 +118,6 @@ public sealed class BSPrim : PhysicsActor _buoyancy = 1f; _velocity = OMV.Vector3.Zero; _rotationalVelocity = OMV.Vector3.Zero; - _angularVelocity = OMV.Vector3.Zero; _hullKey = 0; _meshKey = 0; _pbs = pbs; @@ -146,7 +144,7 @@ public sealed class BSPrim : PhysicsActor // called when this prim is being destroyed and we should free all the resources public void Destroy() { - // m_log.DebugFormat("{0}: Destroy", LogHeader); + // m_log.DebugFormat("{0}: Destroy, id={1}", LogHeader, LocalID); // Undo any vehicle properties _vehicle.ProcessTypeChange(Vehicle.TYPE_NONE); _scene.RemoveVehiclePrim(this); // just to make sure @@ -203,7 +201,7 @@ public sealed class BSPrim : PhysicsActor // link me to the specified parent public override void link(PhysicsActor obj) { - BSPrim parent = (BSPrim)obj; + BSPrim parent = obj as BSPrim; // m_log.DebugFormat("{0}: link {1}/{2} to {3}", LogHeader, _avName, _localID, obj.LocalID); // TODO: decide if this parent checking needs to happen at taint time if (_parentPrim == null) @@ -527,10 +525,6 @@ public sealed class BSPrim : PhysicsActor }); } } - public OMV.Vector3 AngularVelocity { - get { return _angularVelocity; } - set { _angularVelocity = value; } - } public override bool Kinematic { get { return _kinematic; } set { _kinematic = value; @@ -993,7 +987,7 @@ public sealed class BSPrim : PhysicsActor } // m_log.DebugFormat("{0}: CreateGeomMesh: calling CreateMesh. lid={1}, key={2}, indices={3}, vertices={4}", - // LogHeader, _localID, _meshKey, indices.Length, vertices.Count); + // LogHeader, _localID, _meshKey, indices.Length, vertices.Count); BulletSimAPI.CreateMesh(_scene.WorldID, _meshKey, indices.GetLength(0), indices, vertices.Count, verticesAsFloats); @@ -1127,7 +1121,7 @@ public sealed class BSPrim : PhysicsActor return; } - // Create an object in Bullet + // Create an object in Bullet if it has not already been created // No locking here because this is done when the physics engine is not simulating private void CreateObject() { @@ -1324,7 +1318,8 @@ public sealed class BSPrim : PhysicsActor _velocity = entprop.Velocity; _acceleration = entprop.Acceleration; _rotationalVelocity = entprop.RotationalVelocity; - // m_log.DebugFormat("{0}: RequestTerseUpdate. id={1}, ch={2}, pos={3}, rot={4}", LogHeader, LocalID, changed, _position, _orientation); + // 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); base.RequestPhysicsterseUpdate(); } } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 142103b..13d5e03 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -487,12 +487,12 @@ public class BSScene : PhysicsScene, IPhysicsParameters public override void DeleteTerrain() { - m_log.DebugFormat("{0}: DeleteTerrain()", LogHeader); + // m_log.DebugFormat("{0}: DeleteTerrain()", LogHeader); } public override void Dispose() { - m_log.DebugFormat("{0}: Dispose()", LogHeader); + // m_log.DebugFormat("{0}: Dispose()", LogHeader); } public override Dictionary GetTopColliders() @@ -753,6 +753,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters switch (lparm) { case "detailedstats": m_detailedStatsStep = (int)val; break; + case "meshlod": m_meshLOD = (int)val; break; case "sculptlod": m_sculptLOD = (int)val; break; case "maxsubstep": m_maxSubSteps = (int)val; break; -- cgit v1.1 From 142de1d02f086c80888eb216cfd31b84ec27a79b Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 23 Mar 2012 10:59:40 -0700 Subject: BulletSim: add a bunch of internal Bullet configuration parameters to OpenSimDefaults.ini and the code. --- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 34 ++++++++++++++++++++++ .../Region/Physics/BulletSPlugin/BulletSimAPI.cs | 9 ++++++ bin/OpenSimDefaults.ini | 9 ++++++ 3 files changed, 52 insertions(+) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 13d5e03..8d0f9a6 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -240,6 +240,15 @@ public class BSScene : PhysicsScene, IPhysicsParameters parms.avatarDensity = 60f; parms.avatarCapsuleRadius = 0.37f; parms.avatarCapsuleHeight = 1.5f; // 2.140599f + parms.avatarContactProcessingThreshold = 0.1f; + + parms.maxPersistantManifoldPoolSize = 0f; + parms.shouldDisableContactPoolDynamicAllocation = ConfigurationParameters.numericFalse; + parms.shouldForceUpdateAllAabbs = ConfigurationParameters.numericFalse; + parms.shouldRandomizeSolverOrder = ConfigurationParameters.numericFalse; + parms.shouldSplitSimulationIslands = ConfigurationParameters.numericFalse; + parms.shouldEnableFrictionCaching = ConfigurationParameters.numericFalse; + parms.numberOfSolverIterations = 0f; // means use default if (config != null) { @@ -285,11 +294,36 @@ public class BSScene : PhysicsScene, IPhysicsParameters parms.avatarDensity = pConfig.GetFloat("AvatarDensity", parms.avatarDensity); parms.avatarCapsuleRadius = pConfig.GetFloat("AvatarCapsuleRadius", parms.avatarCapsuleRadius); parms.avatarCapsuleHeight = pConfig.GetFloat("AvatarCapsuleHeight", parms.avatarCapsuleHeight); + parms.avatarContactProcessingThreshold = pConfig.GetFloat("AvatarContactProcessingThreshold", parms.avatarContactProcessingThreshold); + + parms.maxPersistantManifoldPoolSize = pConfig.GetFloat("MaxPersistantManifoldPoolSize", parms.maxPersistantManifoldPoolSize); + parms.shouldDisableContactPoolDynamicAllocation = ParamBoolean(pConfig, "ShouldDisableContactPoolDynamicAllocation", parms.shouldDisableContactPoolDynamicAllocation); + parms.shouldForceUpdateAllAabbs = ParamBoolean(pConfig, "ShouldForceUpdateAllAabbs", parms.shouldForceUpdateAllAabbs); + parms.shouldRandomizeSolverOrder = ParamBoolean(pConfig, "ShouldRandomizeSolverOrder", parms.shouldRandomizeSolverOrder); + parms.shouldSplitSimulationIslands = ParamBoolean(pConfig, "ShouldSplitSimulationIslands", parms.shouldSplitSimulationIslands); + parms.shouldEnableFrictionCaching = ParamBoolean(pConfig, "ShouldEnableFrictionCaching", parms.shouldEnableFrictionCaching); + parms.numberOfSolverIterations = pConfig.GetFloat("NumberOfSolverIterations", parms.numberOfSolverIterations); } } m_params[0] = parms; } + // A helper function that handles a true/false parameter and returns the proper float number encoding + float ParamBoolean(IConfig config, string parmName, float deflt) + { + float ret = deflt; + if (config.Contains(parmName)) + { + ret = ConfigurationParameters.numericFalse; + if (config.GetBoolean(parmName, false)) + { + ret = ConfigurationParameters.numericTrue; + } + } + return ret; + } + + // Called directly from unmanaged code so don't do much private void BulletLogger(string msg) { diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs index aab0994..086f0dc 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs @@ -132,6 +132,15 @@ public struct ConfigurationParameters public float avatarRestitution; public float avatarCapsuleRadius; public float avatarCapsuleHeight; + public float avatarContactProcessingThreshold; + + public float maxPersistantManifoldPoolSize; + public float shouldDisableContactPoolDynamicAllocation; + public float shouldForceUpdateAllAabbs; + public float shouldRandomizeSolverOrder; + public float shouldSplitSimulationIslands; + public float shouldEnableFrictionCaching; + public float numberOfSolverIterations; public const float numericTrue = 1f; public const float numericFalse = 0f; diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index a31e6f4..34f70a2 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini @@ -851,6 +851,7 @@ AvatarDensity = 60.0 AvatarCapsuleRadius = 0.37 AvatarCapsuleHeight = 1.5 + AvatarContactProcessingThreshold = 0.1; MaxObjectMass = 10000.01 @@ -863,6 +864,14 @@ CcdMotionThreshold = 0.0 CcdSweptSphereRadius = 0.0 ContactProcessingThreshold = 0.1 + MaxPersistantManifoldPoolSize = 0; + ShouldDisableContactPoolDynamicAllocation = False; + ShouldForceUpdateAllAabbs = False; + ShouldRandomizeSolverOrder = False; + ShouldSplitSimulationIslands = False; + ShouldEnableFrictionCaching = False; + NumberOfSolverIterations = 0; + ; Whether to mesh sculpties MeshSculptedPrim = true -- cgit v1.1 From 3f53b7bc919b8270327911c3bc8ea71640c68c81 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 23 Mar 2012 12:12:06 -0700 Subject: BulletSim: Add new configuration parameters to get and set console commands --- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 36 ++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 8d0f9a6..8d2e25f 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -750,9 +750,17 @@ public class BSScene : PhysicsScene, IPhysicsParameters new PhysParameterEntry("DeactivationTime", "Seconds before considering an object potentially static" ), new PhysParameterEntry("LinearSleepingThreshold", "Seconds to measure linear movement before considering static" ), new PhysParameterEntry("AngularSleepingThreshold", "Seconds to measure angular movement before considering static" ), - // new PhysParameterEntry("CcdMotionThreshold", "" ), - // new PhysParameterEntry("CcdSweptSphereRadius", "" ), + new PhysParameterEntry("CcdMotionThreshold", "Continuious collision detection threshold (0 means no CCD)" ), + new PhysParameterEntry("CcdSweptSphereRadius", "Continuious collision detection test radius" ), new PhysParameterEntry("ContactProcessingThreshold", "Distance between contacts before doing collision check" ), + // Can only change the following at initialization time. Change the INI file and reboot. + new PhysParameterEntry("MaxPersistantManifoldPoolSize", "Number of manifolds pooled (0 means default)"), + new PhysParameterEntry("ShouldDisableContactPoolDynamicAllocation", "Enable to allow large changes in object count"), + new PhysParameterEntry("ShouldForceUpdateAllAabbs", "Enable to recomputer AABBs every simulator step"), + new PhysParameterEntry("ShouldRandomizeSolverOrder", "Enable for slightly better stacking interaction"), + new PhysParameterEntry("ShouldSplitSimulationIslands", "Enable splitting active object scanning islands"), + new PhysParameterEntry("ShouldEnableFrictionCaching", "Enable friction computation caching"), + new PhysParameterEntry("NumberOfSolverIterations", "Number of internal iterations (0 means default)"), new PhysParameterEntry("Friction", "Set friction parameter for a specific object" ), new PhysParameterEntry("Restitution", "Set restitution parameter for a specific object" ), @@ -764,7 +772,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters new PhysParameterEntry("AvatarDensity", "Density of an avatar. Changed on avatar recreation." ), new PhysParameterEntry("AvatarRestitution", "Bouncyness. Changed on avatar recreation." ), new PhysParameterEntry("AvatarCapsuleRadius", "Radius of space around an avatar" ), - new PhysParameterEntry("AvatarCapsuleHeight", "Default height of space around avatar" ) + new PhysParameterEntry("AvatarCapsuleHeight", "Default height of space around avatar" ), + new PhysParameterEntry("AvatarContactProcessingThreshold", "Distance from capsule to check for collisions") + }; #region IPhysicsParameters @@ -798,6 +808,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters case "defaultdensity": m_params[0].defaultDensity = val; break; case "defaultrestitution": m_params[0].defaultRestitution = val; break; case "collisionmargin": m_params[0].collisionMargin = val; break; + case "gravity": m_params[0].gravity = val; TaintedUpdateParameter(lparm, localID, val); break; case "lineardamping": UpdateParameterPrims(ref m_params[0].linearDamping, lparm, localID, val); break; @@ -808,6 +819,14 @@ public class BSScene : PhysicsScene, IPhysicsParameters case "ccdmotionthreshold": UpdateParameterPrims(ref m_params[0].ccdMotionThreshold, lparm, localID, val); break; case "ccdsweptsphereradius": UpdateParameterPrims(ref m_params[0].ccdSweptSphereRadius, lparm, localID, val); break; case "contactprocessingthreshold": UpdateParameterPrims(ref m_params[0].contactProcessingThreshold, lparm, localID, val); break; + // the following are used only at initialization time so setting them makes no sense + // case "maxPersistantmanifoldpoolSize": m_params[0].maxPersistantManifoldPoolSize = val; break; + // case "shoulddisablecontactpooldynamicallocation": m_params[0].shouldDisableContactPoolDynamicAllocation = val; break; + // case "shouldforceupdateallaabbs": m_params[0].shouldForceUpdateAllAabbs = val; break; + // case "shouldrandomizesolverorder": m_params[0].shouldRandomizeSolverOrder = val; break; + // case "shouldsplitsimulationislands": m_params[0].shouldSplitSimulationIslands = val; break; + // case "shouldenablefrictioncaching": m_params[0].shouldEnableFrictionCaching = val; break; + // case "numberofsolveriterations": m_params[0].numberOfSolverIterations = val; break; case "friction": TaintedUpdateParameter(lparm, localID, val); break; case "restitution": TaintedUpdateParameter(lparm, localID, val); break; @@ -821,7 +840,8 @@ public class BSScene : PhysicsScene, IPhysicsParameters case "avatardensity": UpdateParameterAvatars(ref m_params[0].avatarDensity, "avatar", localID, val); break; case "avatarrestitution": UpdateParameterAvatars(ref m_params[0].avatarRestitution, "avatar", localID, val); break; case "avatarcapsuleradius": UpdateParameterAvatars(ref m_params[0].avatarCapsuleRadius, "avatar", localID, val); break; - case "avatarcapsuleheight": UpdateParameterAvatars(ref m_params[0].avatarCapsuleHeight, "avatar", localID, val); break; + case "avatarcapsuleheight": UpdateParameterAvatars(ref m_params[0].avatarCapsuleHeight, "avatar", localID, val); break; + case "avatarcontactprocessingthreshold": UpdateParameterAvatars(ref m_params[0].avatarContactProcessingThreshold, "avatar", localID, val); break; default: ret = false; break; } @@ -914,6 +934,13 @@ public class BSScene : PhysicsScene, IPhysicsParameters case "ccdmotionthreshold": val = m_params[0].ccdMotionThreshold; break; case "ccdsweptsphereradius": val = m_params[0].ccdSweptSphereRadius; break; case "contactprocessingthreshold": val = m_params[0].contactProcessingThreshold; break; + case "maxPersistantmanifoldpoolSize": val = m_params[0].maxPersistantManifoldPoolSize; break; + case "shoulddisablecontactpooldynamicallocation": val = m_params[0].shouldDisableContactPoolDynamicAllocation; break; + case "shouldforceupdateallaabbs": val = m_params[0].shouldForceUpdateAllAabbs; break; + case "shouldrandomizesolverorder": val = m_params[0].shouldRandomizeSolverOrder; break; + case "shouldsplitsimulationislands": val = m_params[0].shouldSplitSimulationIslands; break; + case "shouldenablefrictioncaching": val = m_params[0].shouldEnableFrictionCaching; break; + case "numberofsolveriterations": val = m_params[0].numberOfSolverIterations; break; case "terrainfriction": val = m_params[0].terrainFriction; break; case "terrainhitfraction": val = m_params[0].terrainHitFraction; break; @@ -924,6 +951,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters case "avatarrestitution": val = m_params[0].avatarRestitution; break; case "avatarcapsuleradius": val = m_params[0].avatarCapsuleRadius; break; case "avatarcapsuleheight": val = m_params[0].avatarCapsuleHeight; break; + case "avatarcontactprocessingthreshold": val = m_params[0].avatarContactProcessingThreshold; break; default: ret = false; break; } -- cgit v1.1 From ff54b3c3661a6bf9d5f0d9a24f8aeed5b42ce0ce Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Fri, 23 Mar 2012 15:50:32 -0700 Subject: BulletSim: change default of shouldDisableContactPoolDynamicAllocation from False to True. It seems that collisions don't happen well when it is False (things fall through terrain). --- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 4 ++-- bin/OpenSimDefaults.ini | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 8d2e25f..36dead0 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -243,7 +243,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters parms.avatarContactProcessingThreshold = 0.1f; parms.maxPersistantManifoldPoolSize = 0f; - parms.shouldDisableContactPoolDynamicAllocation = ConfigurationParameters.numericFalse; + parms.shouldDisableContactPoolDynamicAllocation = ConfigurationParameters.numericTrue; parms.shouldForceUpdateAllAabbs = ConfigurationParameters.numericFalse; parms.shouldRandomizeSolverOrder = ConfigurationParameters.numericFalse; parms.shouldSplitSimulationIslands = ConfigurationParameters.numericFalse; @@ -840,7 +840,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters case "avatardensity": UpdateParameterAvatars(ref m_params[0].avatarDensity, "avatar", localID, val); break; case "avatarrestitution": UpdateParameterAvatars(ref m_params[0].avatarRestitution, "avatar", localID, val); break; case "avatarcapsuleradius": UpdateParameterAvatars(ref m_params[0].avatarCapsuleRadius, "avatar", localID, val); break; - case "avatarcapsuleheight": UpdateParameterAvatars(ref m_params[0].avatarCapsuleHeight, "avatar", localID, val); break; + case "avatarcapsuleheight": UpdateParameterAvatars(ref m_params[0].avatarCapsuleHeight, "avatar", localID, val); break; case "avatarcontactprocessingthreshold": UpdateParameterAvatars(ref m_params[0].avatarContactProcessingThreshold, "avatar", localID, val); break; default: ret = false; break; diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index 34f70a2..41be415 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini @@ -865,7 +865,7 @@ CcdSweptSphereRadius = 0.0 ContactProcessingThreshold = 0.1 MaxPersistantManifoldPoolSize = 0; - ShouldDisableContactPoolDynamicAllocation = False; + ShouldDisableContactPoolDynamicAllocation = True; ShouldForceUpdateAllAabbs = False; ShouldRandomizeSolverOrder = False; ShouldSplitSimulationIslands = False; -- cgit v1.1 From a14437ad5abf4d4dc95897216224548515a599e7 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Sat, 24 Mar 2012 22:43:42 -0700 Subject: Add support for key, vector, rotation and list types for both arguments and return values to the modInvoke family of functions. See http://opensimulator.org/wiki/OSSL_Script_Library/ModInvoke --- .../ScriptModuleComms/ScriptModuleCommsModule.cs | 8 + .../Shared/Api/Implementation/MOD_Api.cs | 245 ++++++++++++++++----- .../ScriptEngine/Shared/Api/Interface/IMOD_Api.cs | 24 +- .../ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs | 34 ++- 4 files changed, 237 insertions(+), 74 deletions(-) diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs index a90362e..0661c65 100644 --- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs @@ -147,6 +147,14 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms return "modInvokeI"; else if (sid.ReturnType == typeof(float)) return "modInvokeF"; + else if (sid.ReturnType == typeof(UUID)) + return "modInvokeK"; + else if (sid.ReturnType == typeof(OpenMetaverse.Vector3)) + return "modInvokeV"; + else if (sid.ReturnType == typeof(OpenMetaverse.Quaternion)) + return "modInvokeR"; + else if (sid.ReturnType == typeof(object[])) + return "modInvokeL"; } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs index 2942104..1bcbcd3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs @@ -120,33 +120,101 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// /// /// The name of the function to invoke - /// List of parameters + /// List of parameters /// string result of the invocation - public string modInvokeS(string fname, params object[] parms) + public LSL_String modInvokeS(string fname, params object[] parms) { Type returntype = m_comms.LookupReturnType(fname); if (returntype != typeof(string)) MODError(String.Format("return type mismatch for {0}",fname)); - return (string)modInvoke(fname,parms); + string result = (string)modInvoke(fname,parms); + return new LSL_String(result); } - public int modInvokeI(string fname, params object[] parms) + public LSL_Integer modInvokeI(string fname, params object[] parms) { Type returntype = m_comms.LookupReturnType(fname); if (returntype != typeof(int)) MODError(String.Format("return type mismatch for {0}",fname)); - return (int)modInvoke(fname,parms); + int result = (int)modInvoke(fname,parms); + return new LSL_Integer(result); } - public float modInvokeF(string fname, params object[] parms) + public LSL_Float modInvokeF(string fname, params object[] parms) { Type returntype = m_comms.LookupReturnType(fname); if (returntype != typeof(float)) MODError(String.Format("return type mismatch for {0}",fname)); - return (float)modInvoke(fname,parms); + float result = (float)modInvoke(fname,parms); + return new LSL_Float(result); + } + + public LSL_Key modInvokeK(string fname, params object[] parms) + { + Type returntype = m_comms.LookupReturnType(fname); + if (returntype != typeof(UUID)) + MODError(String.Format("return type mismatch for {0}",fname)); + + UUID result = (UUID)modInvoke(fname,parms); + return new LSL_Key(result.ToString()); + } + + public LSL_Vector modInvokeV(string fname, params object[] parms) + { + Type returntype = m_comms.LookupReturnType(fname); + if (returntype != typeof(OpenMetaverse.Vector3)) + MODError(String.Format("return type mismatch for {0}",fname)); + + OpenMetaverse.Vector3 result = (OpenMetaverse.Vector3)modInvoke(fname,parms); + return new LSL_Vector(result.X,result.Y,result.Z); + } + + public LSL_Rotation modInvokeR(string fname, params object[] parms) + { + Type returntype = m_comms.LookupReturnType(fname); + if (returntype != typeof(OpenMetaverse.Quaternion)) + MODError(String.Format("return type mismatch for {0}",fname)); + + OpenMetaverse.Quaternion result = (OpenMetaverse.Quaternion)modInvoke(fname,parms); + return new LSL_Rotation(result.X,result.Y,result.Z,result.W); + } + + public LSL_List modInvokeL(string fname, params object[] parms) + { + Type returntype = m_comms.LookupReturnType(fname); + if (returntype != typeof(object[])) + MODError(String.Format("return type mismatch for {0}",fname)); + + object[] result = (object[])modInvoke(fname,parms); + object[] llist = new object[result.Length]; + for (int i = 0; i < result.Length; i++) + { + if (result[i] is string) + llist[i] = new LSL_String((string)result[i]); + else if (result[i] is int) + llist[i] = new LSL_Integer((int)result[i]); + else if (result[i] is float) + llist[i] = new LSL_Float((float)result[i]); + else if (result[i] is OpenMetaverse.Vector3) + { + OpenMetaverse.Vector3 vresult = (OpenMetaverse.Vector3)result[i]; + llist[i] = new LSL_Vector(vresult.X,vresult.Y,vresult.Z); + } + else if (result[i] is OpenMetaverse.Quaternion) + { + OpenMetaverse.Quaternion qresult = (OpenMetaverse.Quaternion)result[i]; + llist[i] = new LSL_Rotation(qresult.X,qresult.Y,qresult.Z,qresult.W); + } + else + { + MODError(String.Format("unknown list element returned by {0}",fname)); + } + } + + return new LSL_List(llist); } /// @@ -168,63 +236,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api MODError(String.Format("wrong number of parameters to function {0}",fname)); object[] convertedParms = new object[parms.Length]; - for (int i = 0; i < parms.Length; i++) - { - if (parms[i] is LSL_String) - { - if (signature[i] != typeof(string)) - MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name)); - - convertedParms[i] = (string)(LSL_String)parms[i]; - } - else if (parms[i] is LSL_Integer) - { - if (signature[i] != typeof(int)) - MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name)); - - convertedParms[i] = (int)(LSL_Integer)parms[i]; - } - else if (parms[i] is LSL_Float) - { - if (signature[i] != typeof(float)) - MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name)); - - convertedParms[i] = (float)(LSL_Float)parms[i]; - } - else if (parms[i] is LSL_Key) - { - if (signature[i] != typeof(string)) - MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name)); - - convertedParms[i] = (string)(LSL_Key)parms[i]; - } - else if (parms[i] is LSL_Rotation) - { - if (signature[i] != typeof(string)) - MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name)); - - convertedParms[i] = (string)(LSL_Rotation)parms[i]; - } - else if (parms[i] is LSL_Vector) - { - if (signature[i] != typeof(string)) - MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name)); + convertedParms[i] = ConvertFromLSL(parms[i],signature[i]); - convertedParms[i] = (string)(LSL_Vector)parms[i]; - } - else - { - if (signature[i] != parms[i].GetType()) - MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name)); + // now call the function, the contract with the function is that it will always return + // non-null but don't trust it completely + try + { + object result = m_comms.InvokeOperation(m_itemID,fname,convertedParms); + if (result != null) + return result; - convertedParms[i] = parms[i]; - } + MODError(String.Format("Invocation of {0} failed; null return value",fname)); + } + catch (Exception e) + { + MODError(String.Format("Invocation of {0} failed; {1}",fname,e.Message)); } - return m_comms.InvokeOperation(m_itemID,fname,convertedParms); + return null; } + /// + /// Send a command to functions registered on an event + /// public string modSendCommand(string module, string command, string k) { if (!m_MODFunctionsEnabled) @@ -239,5 +274,101 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return req.ToString(); } + + /// + /// + protected object ConvertFromLSL(object lslparm, Type type) + { + // ---------- String ---------- + if (lslparm is LSL_String) + { + if (type == typeof(string)) + return (string)(LSL_String)lslparm; + + // Need to check for UUID since keys are often treated as strings + if (type == typeof(UUID)) + return new UUID((string)(LSL_String)lslparm); + } + + // ---------- Integer ---------- + else if (lslparm is LSL_Integer) + { + if (type == typeof(int)) + return (int)(LSL_Integer)lslparm; + } + + // ---------- Float ---------- + else if (lslparm is LSL_Float) + { + if (type == typeof(float)) + return (float)(LSL_Float)lslparm; + } + + // ---------- Key ---------- + else if (lslparm is LSL_Key) + { + if (type == typeof(UUID)) + return new UUID((LSL_Key)lslparm); + } + + // ---------- Rotation ---------- + else if (lslparm is LSL_Rotation) + { + if (type == typeof(OpenMetaverse.Quaternion)) + { + LSL_Rotation rot = (LSL_Rotation)lslparm; + return new OpenMetaverse.Quaternion((float)rot.x,(float)rot.y,(float)rot.z,(float)rot.s); + } + } + + // ---------- Vector ---------- + else if (lslparm is LSL_Vector) + { + if (type == typeof(OpenMetaverse.Vector3)) + { + LSL_Vector vect = (LSL_Vector)lslparm; + return new OpenMetaverse.Vector3((float)vect.x,(float)vect.y,(float)vect.z); + } + } + + // ---------- List ---------- + else if (lslparm is LSL_List) + { + if (type == typeof(object[])) + { + object[] plist = (lslparm as LSL_List).Data; + object[] result = new object[plist.Length]; + for (int i = 0; i < plist.Length; i++) + { + if (plist[i] is LSL_String) + result[i] = (string)(LSL_String)plist[i]; + else if (plist[i] is LSL_Integer) + result[i] = (int)(LSL_Integer)plist[i]; + else if (plist[i] is LSL_Float) + result[i] = (float)(LSL_Float)plist[i]; + else if (plist[i] is LSL_Key) + result[i] = new UUID((LSL_Key)plist[i]); + else if (plist[i] is LSL_Rotation) + { + LSL_Rotation rot = (LSL_Rotation)plist[i]; + result[i] = new OpenMetaverse.Quaternion((float)rot.x,(float)rot.y,(float)rot.z,(float)rot.s); + } + else if (plist[i] is LSL_Vector) + { + LSL_Vector vect = (LSL_Vector)plist[i]; + result[i] = new OpenMetaverse.Vector3((float)vect.x,(float)vect.y,(float)vect.z); + } + else + MODError("unknown LSL list element type"); + } + + return result; + } + } + + MODError(String.Format("parameter type mismatch; expecting {0}",type.Name)); + return null; + } + } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs index 756a59f..d258f76 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs @@ -28,26 +28,26 @@ using System.Collections; using OpenSim.Region.ScriptEngine.Interfaces; -using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; -using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; -using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; +using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; +using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; +using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; +using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; -using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; -using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; +using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces { public interface IMOD_Api { // Invocation functions - string modInvokeS(string fname, params object[] parms); - int modInvokeI(string fname, params object[] parms); - float modInvokeF(string fname, params object[] parms); - // vector modInvokeV(string fname, params object[] parms); - // rotation modInvokeV(string fname, params object[] parms); - // key modInvokeK(string fname, params object[] parms); - // list modInvokeL(string fname, params object[] parms); + LSL_String modInvokeS(string fname, params object[] parms); + LSL_Integer modInvokeI(string fname, params object[] parms); + LSL_Float modInvokeF(string fname, params object[] parms); + LSL_Key modInvokeK(string fname, params object[] parms); + LSL_Vector modInvokeV(string fname, params object[] parms); + LSL_Rotation modInvokeR(string fname, params object[] parms); + LSL_List modInvokeL(string fname, params object[] parms); //Module functions string modSendCommand(string modules, string command, string k); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs index 04b7f14..e7a4b2b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs @@ -39,10 +39,14 @@ using integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; using vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; using rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; using key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; -using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; -using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; + using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; +using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; +using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; +using LSL_Rotation = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion; +using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; +using LSL_Vector = OpenSim.Region.ScriptEngine.Shared.LSL_Types.Vector3; namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase { @@ -58,21 +62,41 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_MOD_Functions = (IMOD_Api)api; } - public string modInvokeS(string fname, params object[] parms) + public LSL_String modInvokeS(string fname, params object[] parms) { return m_MOD_Functions.modInvokeS(fname, parms); } - public int modInvokeI(string fname, params object[] parms) + public LSL_Integer modInvokeI(string fname, params object[] parms) { return m_MOD_Functions.modInvokeI(fname, parms); } - public float modInvokeF(string fname, params object[] parms) + public LSL_Float modInvokeF(string fname, params object[] parms) { return m_MOD_Functions.modInvokeF(fname, parms); } + public LSL_Key modInvokeK(string fname, params object[] parms) + { + return m_MOD_Functions.modInvokeK(fname, parms); + } + + public LSL_Vector modInvokeV(string fname, params object[] parms) + { + return m_MOD_Functions.modInvokeV(fname, parms); + } + + public LSL_Rotation modInvokeR(string fname, params object[] parms) + { + return m_MOD_Functions.modInvokeR(fname, parms); + } + + public LSL_List modInvokeL(string fname, params object[] parms) + { + return m_MOD_Functions.modInvokeL(fname, parms); + } + public string modSendCommand(string module, string command, string k) { return m_MOD_Functions.modSendCommand(module, command, k); -- cgit v1.1 From cb44808504e48125d630823880ee8e710afcd9ea Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 25 Mar 2012 19:52:38 +0100 Subject: Simplify the module invocation registration. The types and method name can be pulled fromt he delegate so we don't need to pass them explicitly --- .../Framework/Interfaces/IScriptModuleComms.cs | 3 ++- .../ScriptModuleComms/ScriptModuleCommsModule.cs | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs index bb4c788..8bfbbf8 100644 --- a/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs @@ -46,7 +46,8 @@ namespace OpenSim.Region.Framework.Interfaces /// event ScriptCommand OnScriptCommand; - void RegisterScriptInvocation(string name, ScriptInvocation fn, Type[] csig, Type rsig); + void RegisterScriptInvocation(ScriptInvocation fn); + ScriptInvocation[] GetScriptInvocationList(); ScriptInvocation LookupScriptInvocation(string fname); string LookupModInvocation(string fname); diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs index 0661c65..8e8a0b6 100644 --- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs @@ -126,14 +126,30 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms m_scriptModule.PostScriptEvent(script, "link_message", args); } - public void RegisterScriptInvocation(string fname, ScriptInvocation fcall, Type[] csig, Type rsig) + public void RegisterScriptInvocation(ScriptInvocation fcall) { lock (m_scriptInvocation) { - m_scriptInvocation[fname] = new ScriptInvocationData(fname,fcall,csig,rsig); + ParameterInfo[] parameters = fcall.Method.GetParameters (); + Type[] parmTypes = new Type[parameters.Length]; + for (int i = 0 ; i < parameters.Length ; i++) + parmTypes[i] = parameters[i].ParameterType; + m_scriptInvocation[fcall.Method.Name] = new ScriptInvocationData(fcall.Method.Name, fcall, parmTypes, fcall.Method.ReturnType); } } + public ScriptInvocation[] GetScriptInvocationList() + { + List ret = new List(); + + lock (m_scriptInvocation) + { + foreach (ScriptInvocationData d in m_scriptInvocation.Values) + ret.Add(d.ScriptInvocationFn); + } + return ret.ToArray(); + } + public string LookupModInvocation(string fname) { lock (m_scriptInvocation) -- cgit v1.1 From d7cc194e83ade3453649ab897a4f40b0fa856d0d Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 26 Mar 2012 00:30:52 +0100 Subject: Correct the design error I introduced into ScriptComms. Untested but about to be. --- .../Framework/Interfaces/IScriptModuleComms.cs | 7 ++--- .../ScriptModuleComms/ScriptModuleCommsModule.cs | 36 +++++++++++++--------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs index 8bfbbf8..8a08fbe 100644 --- a/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs @@ -31,7 +31,6 @@ using OpenMetaverse; namespace OpenSim.Region.Framework.Interfaces { public delegate void ScriptCommand(UUID script, string id, string module, string command, string k); - public delegate object ScriptInvocation(UUID script, object[] parms); /// /// Interface for communication between OpenSim modules and in-world scripts @@ -46,10 +45,10 @@ namespace OpenSim.Region.Framework.Interfaces /// event ScriptCommand OnScriptCommand; - void RegisterScriptInvocation(ScriptInvocation fn); - ScriptInvocation[] GetScriptInvocationList(); + void RegisterScriptInvocation(Delegate fn); + Delegate[] GetScriptInvocationList(); - ScriptInvocation LookupScriptInvocation(string fname); + Delegate LookupScriptInvocation(string fname); string LookupModInvocation(string fname); Type[] LookupTypeSignature(string fname); Type LookupReturnType(string fname); diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs index 8e8a0b6..e37e42e 100644 --- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs @@ -47,15 +47,15 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms #region ScriptInvocation protected class ScriptInvocationData { - public ScriptInvocation ScriptInvocationFn { get; private set; } + public Delegate ScriptInvocationDelegate { get; private set; } public string FunctionName { get; private set; } public Type[] TypeSignature { get; private set; } public Type ReturnType { get; private set; } - public ScriptInvocationData(string fname, ScriptInvocation fn, Type[] callsig, Type returnsig) + public ScriptInvocationData(string fname, Delegate fn, Type[] callsig, Type returnsig) { FunctionName = fname; - ScriptInvocationFn = fn; + ScriptInvocationDelegate = fn; TypeSignature = callsig; ReturnType = returnsig; } @@ -126,26 +126,30 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms m_scriptModule.PostScriptEvent(script, "link_message", args); } - public void RegisterScriptInvocation(ScriptInvocation fcall) + public void RegisterScriptInvocation(Delegate fcall) { lock (m_scriptInvocation) { ParameterInfo[] parameters = fcall.Method.GetParameters (); - Type[] parmTypes = new Type[parameters.Length]; - for (int i = 0 ; i < parameters.Length ; i++) - parmTypes[i] = parameters[i].ParameterType; + if (parameters.Length == 0) // Must have one UUID param + return; + + // Hide the first parameter + Type[] parmTypes = new Type[parameters.Length - 1]; + for (int i = 1 ; i < parameters.Length ; i++) + parmTypes[i - 1] = parameters[i].ParameterType; m_scriptInvocation[fcall.Method.Name] = new ScriptInvocationData(fcall.Method.Name, fcall, parmTypes, fcall.Method.ReturnType); } } - public ScriptInvocation[] GetScriptInvocationList() + public Delegate[] GetScriptInvocationList() { - List ret = new List(); + List ret = new List(); lock (m_scriptInvocation) { foreach (ScriptInvocationData d in m_scriptInvocation.Values) - ret.Add(d.ScriptInvocationFn); + ret.Add(d.ScriptInvocationDelegate); } return ret.ToArray(); } @@ -177,13 +181,13 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms return null; } - public ScriptInvocation LookupScriptInvocation(string fname) + public Delegate LookupScriptInvocation(string fname) { lock (m_scriptInvocation) { ScriptInvocationData sid; if (m_scriptInvocation.TryGetValue(fname,out sid)) - return sid.ScriptInvocationFn; + return sid.ScriptInvocationDelegate; } return null; @@ -215,8 +219,12 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms public object InvokeOperation(UUID scriptid, string fname, params object[] parms) { - ScriptInvocation fn = LookupScriptInvocation(fname); - return fn(scriptid,parms); + List olist = new List(); + olist.Add(scriptid); + foreach (object o in parms) + olist.Add(o); + Delegate fn = LookupScriptInvocation(fname); + return fn.DynamicInvoke(olist.ToArray()); } #endregion -- cgit v1.1 From ac0f1ff0a66e361e7ca24ce4660bf58c5662283c Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 26 Mar 2012 01:21:44 +0100 Subject: Dynamically create the delegate type to reduce complexity in the caller --- .../Framework/Interfaces/IScriptModuleComms.cs | 3 ++- .../ScriptModuleComms/ScriptModuleCommsModule.cs | 22 +++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs index 8a08fbe..34586f5 100644 --- a/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs @@ -26,6 +26,7 @@ */ using System; +using System.Reflection; using OpenMetaverse; namespace OpenSim.Region.Framework.Interfaces @@ -45,7 +46,7 @@ namespace OpenSim.Region.Framework.Interfaces /// event ScriptCommand OnScriptCommand; - void RegisterScriptInvocation(Delegate fn); + void RegisterScriptInvocation(object target, MethodInfo mi); Delegate[] GetScriptInvocationList(); Delegate LookupScriptInvocation(string fname); diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs index e37e42e..e0683a0 100644 --- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs @@ -35,6 +35,8 @@ using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using Mono.Addins; using OpenMetaverse; +using System.Linq; +using System.Linq.Expressions; namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms { @@ -126,8 +128,26 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms m_scriptModule.PostScriptEvent(script, "link_message", args); } - public void RegisterScriptInvocation(Delegate fcall) + public void RegisterScriptInvocation(object target, MethodInfo mi) { + Type delegateType; + + var typeArgs = mi.GetParameters() + .Select(p => p.ParameterType) + .ToList(); + + if (mi.ReturnType == typeof(void)) + { + delegateType = Expression.GetActionType(typeArgs.ToArray()); + } + else + { + typeArgs.Add(mi.ReturnType); + delegateType = Expression.GetFuncType(typeArgs.ToArray()); + } + + Delegate fcall = Delegate.CreateDelegate(delegateType, target, mi); + lock (m_scriptInvocation) { ParameterInfo[] parameters = fcall.Method.GetParameters (); -- cgit v1.1 From c9c01d52265dde85aa8b8813fb00af8375240ebd Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 26 Mar 2012 03:20:40 +0100 Subject: Further simplify ScriptComms --- .../Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs index e0683a0..7fc8759 100644 --- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs @@ -128,8 +128,10 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms m_scriptModule.PostScriptEvent(script, "link_message", args); } - public void RegisterScriptInvocation(object target, MethodInfo mi) + public void RegisterScriptInvocation(object target, string meth) { + MethodInfo mi = target.GetType()..GetMethod(meth, + BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); Type delegateType; var typeArgs = mi.GetParameters() -- cgit v1.1 From 98a6c789430bdaba73b5008c1630b37793ee2c5b Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 26 Mar 2012 03:32:30 +0100 Subject: Fix the omission on the interface declaration --- OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs index 34586f5..2183c1c 100644 --- a/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs @@ -46,7 +46,7 @@ namespace OpenSim.Region.Framework.Interfaces /// event ScriptCommand OnScriptCommand; - void RegisterScriptInvocation(object target, MethodInfo mi); + void RegisterScriptInvocation(object target, string method); Delegate[] GetScriptInvocationList(); Delegate LookupScriptInvocation(string fname); -- cgit v1.1 From 055269805d88c5f3d347d3ba7d03db2182a78277 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Sun, 25 Mar 2012 22:59:06 -0700 Subject: Fix compile error in ScriptModuelComms and add some debugging into the modInvoke routines to simplify finding method registration issues. --- .../Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs index 7fc8759..c2ec5b4 100644 --- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs @@ -130,10 +130,18 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms public void RegisterScriptInvocation(object target, string meth) { - MethodInfo mi = target.GetType()..GetMethod(meth, + m_log.DebugFormat("[MODULE COMMANDS] Register method {0} from type {1}",meth,target.GetType().Name); + + + MethodInfo mi = target.GetType().GetMethod(meth, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); + if (mi == null) + { + m_log.WarnFormat("[MODULE COMMANDS] Failed to register method {0}",meth); + return; + } + Type delegateType; - var typeArgs = mi.GetParameters() .Select(p => p.ParameterType) .ToList(); @@ -197,6 +205,8 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms return "modInvokeR"; else if (sid.ReturnType == typeof(object[])) return "modInvokeL"; + + m_log.WarnFormat("[MODULE COMMANDS] failed to find match for {0} with return type {1}",fname,sid.ReturnType.Name); } } -- cgit v1.1 From 7e0936e4b6ec0596390266a8435dea9c3f19f09c Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 26 Mar 2012 14:19:55 +0100 Subject: Add a hust UUID to the script invocations --- OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs | 2 +- .../ScriptModuleComms/ScriptModuleCommsModule.cs | 15 ++++++++------- .../ScriptEngine/Shared/Api/Implementation/MOD_Api.cs | 11 ++++++++++- .../Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs | 1 + .../Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs | 5 +++++ 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs index 2183c1c..34a4bfc 100644 --- a/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs @@ -54,7 +54,7 @@ namespace OpenSim.Region.Framework.Interfaces Type[] LookupTypeSignature(string fname); Type LookupReturnType(string fname); - object InvokeOperation(UUID scriptId, string fname, params object[] parms); + object InvokeOperation(UUID hostId, UUID scriptId, string fname, params object[] parms); /// /// Send a link_message event to an in-world script diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs index 7fc8759..1e755ba 100644 --- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs @@ -130,7 +130,7 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms public void RegisterScriptInvocation(object target, string meth) { - MethodInfo mi = target.GetType()..GetMethod(meth, + MethodInfo mi = target.GetType().GetMethod(meth, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); Type delegateType; @@ -153,13 +153,13 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms lock (m_scriptInvocation) { ParameterInfo[] parameters = fcall.Method.GetParameters (); - if (parameters.Length == 0) // Must have one UUID param + if (parameters.Length < 2) // Must have two UUID params return; - // Hide the first parameter - Type[] parmTypes = new Type[parameters.Length - 1]; - for (int i = 1 ; i < parameters.Length ; i++) - parmTypes[i - 1] = parameters[i].ParameterType; + // Hide the first two parameters + Type[] parmTypes = new Type[parameters.Length - 2]; + for (int i = 2 ; i < parameters.Length ; i++) + parmTypes[i - 2] = parameters[i].ParameterType; m_scriptInvocation[fcall.Method.Name] = new ScriptInvocationData(fcall.Method.Name, fcall, parmTypes, fcall.Method.ReturnType); } } @@ -239,9 +239,10 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms return null; } - public object InvokeOperation(UUID scriptid, string fname, params object[] parms) + public object InvokeOperation(UUID hostid, UUID scriptid, string fname, params object[] parms) { List olist = new List(); + olist.Add(hostid); olist.Add(scriptid); foreach (object o in parms) olist.Add(o); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs index 1bcbcd3..7c07e15 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs @@ -122,6 +122,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api /// The name of the function to invoke /// List of parameters /// string result of the invocation + public void modInvokeN(string fname, params object[] parms) + { + Type returntype = m_comms.LookupReturnType(fname); + if (returntype != typeof(string)) + MODError(String.Format("return type mismatch for {0}",fname)); + + modInvoke(fname,parms); + } + public LSL_String modInvokeS(string fname, params object[] parms) { Type returntype = m_comms.LookupReturnType(fname); @@ -243,7 +252,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // non-null but don't trust it completely try { - object result = m_comms.InvokeOperation(m_itemID,fname,convertedParms); + object result = m_comms.InvokeOperation(m_host.UUID, m_itemID, fname, convertedParms); if (result != null) return result; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs index d258f76..aa78aaa 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IMOD_Api.cs @@ -41,6 +41,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces public interface IMOD_Api { // Invocation functions + void modInvokeN(string fname, params object[] parms); LSL_String modInvokeS(string fname, params object[] parms); LSL_Integer modInvokeI(string fname, params object[] parms); LSL_Float modInvokeF(string fname, params object[] parms); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs index e7a4b2b..1c47138 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/MOD_Stub.cs @@ -62,6 +62,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_MOD_Functions = (IMOD_Api)api; } + public void modInvokeN(string fname, params object[] parms) + { + m_MOD_Functions.modInvokeN(fname, parms); + } + public LSL_String modInvokeS(string fname, params object[] parms) { return m_MOD_Functions.modInvokeS(fname, parms); -- cgit v1.1 From 3691e39178ccc569ee96fdeeefe16324c779f127 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 26 Mar 2012 08:48:51 -0700 Subject: BulletSim: update BulletSim.dll and libBulletSim.so with latest versions --- bin/lib32/BulletSim.dll | Bin 532480 -> 533504 bytes bin/lib32/libBulletSim.so | Bin 618538 -> 619149 bytes bin/lib64/BulletSim.dll | Bin 684544 -> 685056 bytes bin/lib64/libBulletSim.so | Bin 684103 -> 688874 bytes 4 files changed, 0 insertions(+), 0 deletions(-) diff --git a/bin/lib32/BulletSim.dll b/bin/lib32/BulletSim.dll index 7811c46..357f26e 100755 Binary files a/bin/lib32/BulletSim.dll and b/bin/lib32/BulletSim.dll differ diff --git a/bin/lib32/libBulletSim.so b/bin/lib32/libBulletSim.so index dd2c5ee..948d8e3 100755 Binary files a/bin/lib32/libBulletSim.so and b/bin/lib32/libBulletSim.so differ diff --git a/bin/lib64/BulletSim.dll b/bin/lib64/BulletSim.dll index b8a4ed0..db8530c 100755 Binary files a/bin/lib64/BulletSim.dll and b/bin/lib64/BulletSim.dll differ diff --git a/bin/lib64/libBulletSim.so b/bin/lib64/libBulletSim.so index 3ee7cbf..b2fd9d2 100755 Binary files a/bin/lib64/libBulletSim.so and b/bin/lib64/libBulletSim.so differ -- cgit v1.1 From 2fcdecf0900a5b458227ede4b34faec427f3cf28 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 26 Mar 2012 08:57:40 -0700 Subject: BulletSim: fix typo introducted by previous checkins (git merge sometimes makes mistakes) --- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 6963af5..581d540 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -833,9 +833,6 @@ public class BSScene : PhysicsScene, IPhysicsParameters case "friction": TaintedUpdateParameter(lparm, localID, val); break; case "restitution": TaintedUpdateParameter(lparm, localID, val); break; - case "friction": TaintedUpdateParameter(lparm, localID, val); break; - case "restitution": TaintedUpdateParameter(lparm, localID, val); break; - // set a terrain physical feature and cause terrain to be recalculated case "terrainfriction": m_params[0].terrainFriction = val; TaintedUpdateParameter("terrain", 0, val); break; case "terrainhitfraction": m_params[0].terrainHitFraction = val; TaintedUpdateParameter("terrain", 0, val); break; -- cgit v1.1 From ad865ab4fc6703610d15336fa22fa2a62f628979 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 26 Mar 2012 16:46:07 +0100 Subject: Add some more overloads to allow registering overloaded methods and lists of methods. --- .../Region/Framework/Interfaces/IScriptModuleComms.cs | 2 ++ .../ScriptModuleComms/ScriptModuleCommsModule.cs | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs index 34a4bfc..bfe1e8d 100644 --- a/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs @@ -47,6 +47,8 @@ namespace OpenSim.Region.Framework.Interfaces event ScriptCommand OnScriptCommand; void RegisterScriptInvocation(object target, string method); + void RegisterScriptInvocation(object target, MethodInfo method); + void RegisterScriptInvocation(object target, string[] methods); Delegate[] GetScriptInvocationList(); Delegate LookupScriptInvocation(string fname); diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs index 0605590..cab30de 100644 --- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs @@ -130,9 +130,6 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms public void RegisterScriptInvocation(object target, string meth) { - m_log.DebugFormat("[MODULE COMMANDS] Register method {0} from type {1}",meth,target.GetType().Name); - - MethodInfo mi = target.GetType().GetMethod(meth, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); if (mi == null) @@ -140,7 +137,20 @@ namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms m_log.WarnFormat("[MODULE COMMANDS] Failed to register method {0}",meth); return; } - + + RegisterScriptInvocation(target, mi); + } + + public void RegisterScriptInvocation(object target, string[] meth) + { + foreach (string m in meth) + RegisterScriptInvocation(target, m); + } + + public void RegisterScriptInvocation(object target, MethodInfo mi) + { + m_log.DebugFormat("[MODULE COMMANDS] Register method {0} from type {1}", mi.Name, target.GetType().Name); + Type delegateType; var typeArgs = mi.GetParameters() .Select(p => p.ParameterType) -- cgit v1.1 From 84c9bd52d3c2e01f1b385a6dd0fc4822a652867b Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 26 Mar 2012 13:48:15 -0700 Subject: BulletSim: update BulletSim binaries and configuration fixing a crash which happens when there are more than a few hundred physical objects. --- bin/OpenSimDefaults.ini | 3 ++- bin/lib32/BulletSim.dll | Bin 533504 -> 533504 bytes bin/lib32/libBulletSim.so | Bin 619149 -> 619145 bytes bin/lib64/BulletSim.dll | Bin 685056 -> 686080 bytes bin/lib64/libBulletSim.so | Bin 688874 -> 688866 bytes 5 files changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index 41be415..28c5587 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini @@ -864,8 +864,9 @@ CcdMotionThreshold = 0.0 CcdSweptSphereRadius = 0.0 ContactProcessingThreshold = 0.1 + ; If setting a pool size, also disable dynamic allocation (default pool size is 4096 with dynamic alloc) MaxPersistantManifoldPoolSize = 0; - ShouldDisableContactPoolDynamicAllocation = True; + ShouldDisableContactPoolDynamicAllocation = False; ShouldForceUpdateAllAabbs = False; ShouldRandomizeSolverOrder = False; ShouldSplitSimulationIslands = False; diff --git a/bin/lib32/BulletSim.dll b/bin/lib32/BulletSim.dll index 357f26e..5bef6e9 100755 Binary files a/bin/lib32/BulletSim.dll and b/bin/lib32/BulletSim.dll differ diff --git a/bin/lib32/libBulletSim.so b/bin/lib32/libBulletSim.so index 948d8e3..9882f5b 100755 Binary files a/bin/lib32/libBulletSim.so and b/bin/lib32/libBulletSim.so differ diff --git a/bin/lib64/BulletSim.dll b/bin/lib64/BulletSim.dll index db8530c..9f09ef8 100755 Binary files a/bin/lib64/BulletSim.dll and b/bin/lib64/BulletSim.dll differ diff --git a/bin/lib64/libBulletSim.so b/bin/lib64/libBulletSim.so index b2fd9d2..fa47bf1 100755 Binary files a/bin/lib64/libBulletSim.so and b/bin/lib64/libBulletSim.so differ -- cgit v1.1 From 872d513daaa68b94b78f71bd2a2d9a0f117ff727 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 26 Mar 2012 17:36:33 -0700 Subject: BulletSim: make avatar animations update properly. It seems that ODE calls the avatar collision handling routine even if there are no collisions. This causes the animation to be updated. So, for instance, going from HOVER to FLY is caused by the physics engine calling the collision routine each frame with 0 collisions. --- .../Region/Physics/BulletSPlugin/BSCharacter.cs | 24 ++++++++++++++++++---- OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 18 +++++++++++----- OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | 15 ++++++++++++++ 3 files changed, 48 insertions(+), 9 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 20708d9..b08d5db 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -426,6 +426,8 @@ public class BSCharacter : PhysicsActor } } + // Called by the scene when a collision with this object is reported + CollisionEventUpdate collisionCollection = null; public void Collide(uint collidingWith, ActorTypes type, Vector3 contactPoint, Vector3 contactNormal, float pentrationDepth) { // m_log.DebugFormat("{0}: Collide: ms={1}, id={2}, with={3}", LogHeader, _subscribedEventsMs, LocalID, collidingWith); @@ -443,10 +445,24 @@ public class BSCharacter : PhysicsActor if (nowTime < (_lastCollisionTime + _subscribedEventsMs)) return; _lastCollisionTime = nowTime; - Dictionary contactPoints = new Dictionary(); - contactPoints.Add(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); - CollisionEventUpdate args = new CollisionEventUpdate(contactPoints); - base.SendCollisionUpdate(args); + if (collisionCollection == null) + collisionCollection = new CollisionEventUpdate(); + collisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); + } + + public void SendCollisions() + { + // if (collisionCollection != null) + // { + // base.SendCollisionUpdate(collisionCollection); + // collisionCollection = null; + // } + // Kludge to make a collision call even if there are no collisions. + // This causes the avatar animation to get updated. + if (collisionCollection == null) + collisionCollection = new CollisionEventUpdate(); + base.SendCollisionUpdate(collisionCollection); + collisionCollection = null; } } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index f122df9..248d1f2 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -1326,6 +1326,7 @@ public sealed class BSPrim : PhysicsActor } // I've collided with something + CollisionEventUpdate collisionCollection = null; 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); @@ -1343,11 +1344,18 @@ public sealed class BSPrim : PhysicsActor if (nowTime < (_lastCollisionTime + _subscribedEventsMs)) return; _lastCollisionTime = nowTime; - // create the event for the collision - Dictionary contactPoints = new Dictionary(); - contactPoints.Add(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); - CollisionEventUpdate args = new CollisionEventUpdate(contactPoints); - base.SendCollisionUpdate(args); + if (collisionCollection == null) + collisionCollection = new CollisionEventUpdate(); + collisionCollection.AddCollider(collidingWith, new ContactPoint(contactPoint, contactNormal, pentrationDepth)); + } + + public void SendCollisions() + { + if (collisionCollection != null) + { + base.SendCollisionUpdate(collisionCollection); + collisionCollection = null; + } } } } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 581d540..94a0ccf 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs @@ -78,6 +78,8 @@ public class BSScene : PhysicsScene, IPhysicsParameters private Dictionary m_avatars = new Dictionary(); private Dictionary m_prims = new Dictionary(); + private HashSet m_avatarsWithCollisions = new HashSet(); + private HashSet m_primsWithCollisions = new HashSet(); private List m_vehicles = new List(); private float[] m_heightMap; private float m_waterLevel; @@ -435,6 +437,17 @@ public class BSScene : PhysicsScene, IPhysicsParameters } } + // The SendCollision's batch up the collisions on the objects. Now push the collisions into the simulator. + foreach (BSPrim bsp in m_primsWithCollisions) + bsp.SendCollisions(); + m_primsWithCollisions.Clear(); + // foreach (BSCharacter bsc in m_avatarsWithCollisions) + // bsc.SendCollisions(); + // This is a kludge to get avatar movement updated. ODE sends collisions even if there isn't any + foreach (KeyValuePair kvp in m_avatars) + kvp.Value.SendCollisions(); + m_avatarsWithCollisions.Clear(); + // If any of the objects had updated properties, tell the object it has been changed by the physics engine if (updatedEntityCount > 0) { @@ -485,11 +498,13 @@ public class BSScene : PhysicsScene, IPhysicsParameters BSPrim prim; if (m_prims.TryGetValue(localID, out prim)) { prim.Collide(collidingWith, type, collidePoint, collideNormal, penitration); + m_primsWithCollisions.Add(prim); return; } BSCharacter actor; if (m_avatars.TryGetValue(localID, out actor)) { actor.Collide(collidingWith, type, collidePoint, collideNormal, penitration); + m_avatarsWithCollisions.Add(actor); return; } return; -- cgit v1.1