From 939340325396c80e8798ec43361ffd983ce325c9 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sun, 6 Jan 2013 14:01:15 -0800 Subject: BulletSim: update DLLs and SOs with better debugging output. Add definition of hand crafted avatar mesh. Not used yet. Comments and cleanup. --- OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 4 +- OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs | 145 +++++++++++++++++++-- .../Region/Physics/BulletSPlugin/BulletSimData.cs | 2 + .../Region/Physics/BulletSPlugin/BulletSimTODO.txt | 12 +- 4 files changed, 151 insertions(+), 12 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index 13c2539..a9fbc8b 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs @@ -137,6 +137,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin get { return Type != Vehicle.TYPE_NONE && Prim.IsPhysical; } } + #region Vehicle parameter setting internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue) { VDetailLog("{0},ProcessFloatVehicleParam,param={1},val={2}", Prim.LocalID, pParam, pValue); @@ -546,6 +547,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin m_verticalAttractionMotor.FrictionTimescale = new Vector3(BSMotor.Infinite, BSMotor.Infinite, 0.1f); m_verticalAttractionMotor.PhysicsScene = PhysicsScene; // DEBUG DEBUG DEBUG (enables detail logging) } + #endregion // Vehicle parameter setting // Some of the properties of this prim may have changed. // Do any updating needed for a vehicle @@ -925,7 +927,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin // TODO: Consider taking the rotated size of the object or possibly casting a ray. if (VehiclePosition.Z < GetTerrainHeight(VehiclePosition)) { - // TODO: correct position by applying force rather than forcing position. + // Force position because applying force won't get the vehicle through the terrain Vector3 newPosition = VehiclePosition; newPosition.Z = GetTerrainHeight(VehiclePosition) + 1f; VehiclePosition = newPosition; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs index c75eb9b..cc725e8 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs @@ -27,24 +27,19 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; +using OMV = OpenMetaverse; + namespace OpenSim.Region.Physics.BulletSPlugin { public abstract class BSShape { - public IntPtr ptr { get; set; } - public BSPhysicsShapeType type { get; set; } - public System.UInt64 key { get; set; } public int referenceCount { get; set; } public DateTime lastReferenced { get; set; } public BSShape() { - ptr = IntPtr.Zero; - type = BSPhysicsShapeType.SHAPE_UNKNOWN; - key = 0; referenceCount = 0; lastReferenced = DateTime.Now; } @@ -63,7 +58,7 @@ public abstract class BSShape } // Compound shapes are handled special as they are rebuilt from scratch. - // This isn't too great a hardship since most of the child shapes will already been created. + // This isn't too great a hardship since most of the child shapes will have already been created. if (ret == null && prim.PreferredPhysicalShape == BSPhysicsShapeType.SHAPE_COMPOUND) { // Getting a reference to a compound shape gets you the compound shape with the root prim shape added @@ -71,6 +66,14 @@ public abstract class BSShape physicsScene.DetailLog("{0},BSShapeCollection.CreateGeom,compoundShape,shape={1}", prim.LocalID, ret); } + // Avatars have their own unique shape + if (ret == null && prim.PreferredPhysicalShape == BSPhysicsShapeType.SHAPE_AVATAR) + { + // Getting a reference to a compound shape gets you the compound shape with the root prim shape added + ret = BSShapeAvatar.GetReference(prim); + physicsScene.DetailLog("{0},BSShapeCollection.CreateGeom,avatarShape,shape={1}", prim.LocalID, ret); + } + if (ret == null) ret = GetShapeReferenceNonSpecial(physicsScene, forceRebuild, prim); @@ -228,5 +231,131 @@ public class BSShapeAvatar : BSShape return new BSShapeNull(); } public override void Dereference(BSScene physicsScene) { } + + // From the front: + // A---A + // / \ + // B-------B + // / \ +Z + // C-----------C | + // \ / -Y --+-- +Y + // \ / | + // \ / -Z + // D-----D + // \ / + // E-E + + // From the top A and E are just lines. + // B, C and D are hexagons: + // + // C1--C2 +X + // / \ | + // C0 C3 -Y --+-- +Y + // \ / | + // C5--C4 -X + + // Zero goes directly through the middle so the offsets are from that middle axis + // and up and down from a middle horizon (A and E are the same distance from the zero). + // The height, width and depth is one. All scaling is done by the simulator. + + // Z component -- how far the level is from the middle zero + private const float Aup = 0.5f; + private const float Bup = 0.4f; + private const float Cup = 0.3f; + private const float Dup = -0.4f; + private const float Eup = -0.5f; + + // Y component -- distance from center to x0 and x3 + private const float Awid = 0.25f; + private const float Bwid = 0.3f; + private const float Cwid = 0.5f; + private const float Dwid = 0.3f; + private const float Ewid = 0.2f; + + // Y component -- distance from center to x1, x2, x4 and x5 + private const float Afwid = 0.0f; + private const float Bfwid = 0.2f; + private const float Cfwid = 0.4f; + private const float Dfwid = 0.2f; + private const float Efwid = 0.0f; + + // X component -- distance from zero to the front or back of a level + private const float Adep = 0f; + private const float Bdep = 0.3f; + private const float Cdep = 0.5f; + private const float Ddep = 0.2f; + private const float Edep = 0f; + + private OMV.Vector3[] avatarVertices = { + new OMV.Vector3( 0.0f, -Awid, Aup), // A0 + new OMV.Vector3( 0.0f, +Awid, Aup), // A3 + + new OMV.Vector3( 0.0f, -Bwid, Bup), // B0 + new OMV.Vector3(+Bdep, -Bfwid, Bup), // B1 + new OMV.Vector3(+Bdep, +Bfwid, Bup), // B2 + new OMV.Vector3( 0.0f, +Bwid, Bup), // B3 + new OMV.Vector3(-Bdep, +Bfwid, Bup), // B4 + new OMV.Vector3(-Bdep, -Bfwid, Bup), // B5 + + new OMV.Vector3( 0.0f, -Cwid, Cup), // C0 + new OMV.Vector3(+Cdep, -Cfwid, Cup), // C1 + new OMV.Vector3(+Cdep, +Cfwid, Cup), // C2 + new OMV.Vector3( 0.0f, +Cwid, Cup), // C3 + new OMV.Vector3(-Cdep, +Cfwid, Cup), // C4 + new OMV.Vector3(-Cdep, -Cfwid, Cup), // C5 + + new OMV.Vector3( 0.0f, -Dwid, Dup), // D0 + new OMV.Vector3(+Ddep, -Dfwid, Dup), // D1 + new OMV.Vector3(+Ddep, +Dfwid, Dup), // D2 + new OMV.Vector3( 0.0f, +Dwid, Dup), // D3 + new OMV.Vector3(-Ddep, +Dfwid, Dup), // D4 + new OMV.Vector3(-Ddep, -Dfwid, Dup), // D5 + + new OMV.Vector3( 0.0f, -Ewid, Eup), // E0 + new OMV.Vector3( 0.0f, +Ewid, Eup), // E3 + }; + + // Offsets of the vertices in the vertices array + private enum Ind : int + { + A0, A3, + B0, B1, B2, B3, B4, B5, + C0, C1, C2, C3, C4, C5, + D0, D1, D2, D3, D4, D5, + E0, E3 + } + + // Comments specify trianges and quads in clockwise direction + private Ind[] avatarIndices = { + Ind.A0, Ind.B0, Ind.B1, // A0,B0,B1 + Ind.A0, Ind.B1, Ind.B2, Ind.B2, Ind.A3, Ind.A0, // A0,B1,B2,A3 + Ind.A3, Ind.B2, Ind.B3, // A3,B2,B3 + Ind.A3, Ind.B3, Ind.B4, // A3,B3,B4 + Ind.A3, Ind.B4, Ind.B5, Ind.B5, Ind.A0, Ind.A3, // A3,B4,B5,A0 + Ind.A0, Ind.B5, Ind.B0, // A0,B5,B0 + + Ind.B0, Ind.C0, Ind.C1, Ind.C1, Ind.B1, Ind.B0, // B0,C0,C1,B1 + Ind.B1, Ind.C1, Ind.C2, Ind.C2, Ind.B2, Ind.B1, // B1,C1,C2,B2 + Ind.B2, Ind.C2, Ind.C3, Ind.C3, Ind.B3, Ind.B2, // B2,C2,C3,B3 + Ind.B3, Ind.C3, Ind.C4, Ind.C4, Ind.B4, Ind.B3, // B3,C3,C4,B4 + Ind.B4, Ind.C4, Ind.C5, Ind.C5, Ind.B5, Ind.B4, // B4,C4,C5,B5 + Ind.B5, Ind.C5, Ind.C0, Ind.C0, Ind.B0, Ind.B5, // B5,C5,C0,B0 + + Ind.C0, Ind.D0, Ind.D1, Ind.D1, Ind.C1, Ind.C0, // C0,D0,D1,C1 + Ind.C1, Ind.D1, Ind.D2, Ind.D2, Ind.C2, Ind.C1, // C1,D1,D2,C2 + Ind.C2, Ind.D2, Ind.D3, Ind.D3, Ind.C3, Ind.C2, // C2,D2,D3,C3 + Ind.C3, Ind.D3, Ind.D4, Ind.D4, Ind.C4, Ind.C3, // C3,D3,D4,C4 + Ind.C4, Ind.D4, Ind.D5, Ind.D5, Ind.C5, Ind.C4, // C4,D4,D5,C5 + Ind.C5, Ind.D5, Ind.D0, Ind.D0, Ind.C0, Ind.C5, // C5,D5,D0,C0 + + Ind.E0, Ind.D0, Ind.D1, // E0,D0,D1 + Ind.E0, Ind.D1, Ind.D2, Ind.D2, Ind.E3, Ind.E0, // E0,D1,D2,E3 + Ind.E3, Ind.D2, Ind.D3, // E3,D2,D3 + Ind.E3, Ind.D3, Ind.D4, // E3,D3,D4 + Ind.E3, Ind.D4, Ind.D5, Ind.D5, Ind.E0, Ind.E3, // E3,D4,D5,E0 + Ind.E0, Ind.D5, Ind.D0, // E0,D5,D0 + + }; + } } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs index 662dd68..c7a2f7e 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimData.cs @@ -114,8 +114,10 @@ public class BulletShape public virtual void Clear() { } public virtual bool HasPhysicalShape { get { return false; } } + // Make another reference to this physical object. public virtual BulletShape Clone() { return new BulletShape(); } + // Return 'true' if this and other refer to the same physical object public virtual bool ReferenceSame(BulletShape xx) { return false; } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt index facf720..7b59e60 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt @@ -1,8 +1,6 @@ CURRENT PRIORITIES ================================================= -Redo BulletSimAPI to allow native C# implementation of Bullet option (DONE) -Meshes rendering as bounding boxes -llMoveToTarget +Avatars walking up stairs Vehicle movement on terrain smoothness limitMotorUp calibration (more down?) Preferred orientatino angular correction fix @@ -135,6 +133,9 @@ Eliminate collisions between objects in a linkset. (LinksetConstraint) MORE ====================================================== +Use the HACD convex hull routine in Bullet rather than the C# version. +Do we need to do convex hulls all the time? Can complex meshes be left meshes? + There is some problem with meshes and collisions Test avatar walking up stairs. How does compare with SL. Radius of the capsule affects ability to climb edges. Debounce avatar contact so legs don't keep folding up when standing. @@ -274,3 +275,8 @@ llSetBuoyancy() (DONE) (Resolution: Bullet resets object gravity when added to world. Moved set gravity) Avatar density is WAY off. Compare and calibrate with what's in SL. (DONE) (Resolution: set default density to 3.5 (from 60) which is closer to SL) +Redo BulletSimAPI to allow native C# implementation of Bullet option (DONE) + (Resolution: added BSAPITemplate and then interfaces for C++ Bullet and C# BulletXNA +Meshes rendering as bounding boxes (DONE) + (Resolution: Added test for mesh/sculpties in native shapes so it didn't think it was a box) +llMoveToTarget (Resolution: added simple motor to update the position.) -- cgit v1.1 From 2e5222055ffa1e721221753c26faba342b920712 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Sun, 6 Jan 2013 22:56:16 -0800 Subject: BulletSim: comments and removing small compile errors introduced in last commit. --- OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs | 2 +- OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | 2 -- OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs | 8 ++------ 3 files changed, 3 insertions(+), 9 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs b/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs index befb076..794ee17 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSApiTemplate.cs @@ -6,7 +6,7 @@ * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyrightD + * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * Neither the name of the OpenSimulator Project nor the diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index c215e3a..fe48166 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -58,8 +58,6 @@ public sealed class BSCharacter : BSPhysObject private bool _flying; private bool _setAlwaysRun; private bool _throttleUpdates; - private bool _isColliding; - private bool _collidingObj; private bool _floatOnWater; private OMV.Vector3 _rotationalVelocity; private bool _kinematic; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs index cc725e8..ee18379 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs @@ -95,9 +95,9 @@ public abstract class BSShape // protected abstract static BSShape GetReference(); // Returns a string for debugging that uniquily identifies the memory used by this instance - public string AddrString + public virtual string AddrString { - get { return ptr.ToString("X"); } + get { return "unknown"; } } public override string ToString() @@ -105,10 +105,6 @@ public abstract class BSShape StringBuilder buff = new StringBuilder(); buff.Append(""); -- cgit v1.1 From 599dbc3d9556b7e2693ba61d7e234ef943ebad6d Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 7 Jan 2013 16:04:21 -0800 Subject: BulletSim: fix exception when re-creating the terrain when loading an OAR file --- OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs index 1d55ce3..8244f02 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs @@ -142,6 +142,8 @@ public sealed class BSTerrainMesh : BSTerrainPhys PhysicsScene.PE.RemoveObjectFromWorld(PhysicsScene.World, m_terrainBody); // Frees both the body and the shape. PhysicsScene.PE.DestroyObject(PhysicsScene.World, m_terrainBody); + m_terrainBody.Clear(); + m_terrainShape.Clear(); } } -- cgit v1.1 From 8452c0a8702ccf7ea045740dd829c69a6f509845 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 7 Jan 2013 16:05:02 -0800 Subject: BulletSim: add function to push avatar up when hitting stairs. It looks like BulletSim and ODE rely on penetration correction to cause the avatar to move up and thus allowing walking up stairs. Object penetration was minimized for walking and flying (so one doesn't go through walls) and this stopped stairs from working. This commit introduces avatar movement code to check for collisions at the feet while walking and attempts to raise the avatar for the steps. Not yet perfect but movement is better. --- .../Region/Physics/BulletSPlugin/BSCharacter.cs | 97 ++++++++++++++++------ OpenSim/Region/Physics/BulletSPlugin/BSParam.cs | 18 ++++ .../Region/Physics/BulletSPlugin/BSPhysObject.cs | 27 ++++++ OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 2 +- .../Region/Physics/BulletSPlugin/BulletSimTODO.txt | 2 + 5 files changed, 119 insertions(+), 27 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index fe48166..939d38a 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs @@ -184,10 +184,6 @@ public sealed class BSCharacter : BSPhysObject // standing as well as moving. Destruction of the avatar will destroy the pre-step action. private void SetupMovementMotor() { - - // Someday, use a PID motor for asymmetric speed up and slow down - // _velocityMotor = new BSPIDVMotor("BSCharacter.Velocity", 3f, 5f, BSMotor.InfiniteVector, 1f); - // Infinite decay and timescale values so motor only changes current to target values. _velocityMotor = new BSVMotor("BSCharacter.Velocity", 0.2f, // time scale @@ -214,25 +210,68 @@ public sealed class BSCharacter : BSPhysObject // 'stepVelocity' is now the speed we'd like the avatar to move in. Turn that into an instantanous force. OMV.Vector3 moveForce = (stepVelocity - _velocity) * Mass; - /* - // If moveForce is very small, zero things so we don't keep sending microscopic updates to the user - float moveForceMagnitudeSquared = moveForce.LengthSquared(); - if (moveForceMagnitudeSquared < 0.0001) - { - DetailLog("{0},BSCharacter.MoveMotor,zeroMovement,stepVel={1},vel={2},mass={3},magSq={4},moveForce={5}", - LocalID, stepVelocity, _velocity, Mass, moveForceMagnitudeSquared, moveForce); - ForceVelocity = OMV.Vector3.Zero; - } - else - { - AddForce(moveForce, false, true); - } - */ - // DetailLog("{0},BSCharacter.MoveMotor,move,stepVel={1},vel={2},mass={3},moveForce={4}", LocalID, stepVelocity, _velocity, Mass, moveForce); + // Should we check for move force being small and forcing velocity to zero? + + // Add special movement force to allow avatars to walk up stepped surfaces. + moveForce += WalkUpStairs(); + + DetailLog("{0},BSCharacter.MoveMotor,move,stepVel={1},vel={2},mass={3},moveForce={4}", LocalID, stepVelocity, _velocity, Mass, moveForce); PhysicsScene.PE.ApplyCentralImpulse(PhysBody, moveForce); }); } + // Decide of the character is colliding with a low object and compute a force to pop the + // avatar up so it has a chance of walking up and over the low object. + private OMV.Vector3 WalkUpStairs() + { + OMV.Vector3 ret = OMV.Vector3.Zero; + + // This test is done if moving forward, not flying and is colliding with something. + // DetailLog("{0},BSCharacter.WalkUpStairs,IsColliding={1},flying={2},targSpeed={3},collisions={4}", + // LocalID, IsColliding, Flying, TargetSpeed, CollisionsLastTick.Count); + if (IsColliding && !Flying && TargetSpeed > 0.1f /* && ForwardSpeed < 0.1f */) + { + // The range near the character's feet where we will consider stairs + float nearFeetHeightMin = RawPosition.Z - (Size.Z / 2f) + 0.05f; + float nearFeetHeightMax = nearFeetHeightMin + BSParam.AvatarStepHeight; + + // Look for a collision point that is near the character's feet and is oriented the same as the charactor is + foreach (KeyValuePair kvp in CollisionsLastTick.m_objCollisionList) + { + // Don't care about collisions with the terrain + if (kvp.Key > PhysicsScene.TerrainManager.HighestTerrainID) + { + OMV.Vector3 touchPosition = kvp.Value.Position; + // DetailLog("{0},BSCharacter.WalkUpStairs,min={1},max={2},touch={3}", + // LocalID, nearFeetHeightMin, nearFeetHeightMax, touchPosition); + if (touchPosition.Z >= nearFeetHeightMin && touchPosition.Z <= nearFeetHeightMax) + { + // This contact is within the 'near the feet' range. + // The normal should be our contact point to the object so it is pointing away + // thus the difference between our facing orientation and the normal should be small. + OMV.Vector3 directionFacing = OMV.Vector3.UnitX * RawOrientation; + OMV.Vector3 touchNormal = OMV.Vector3.Normalize(kvp.Value.SurfaceNormal); + float diff = Math.Abs(OMV.Vector3.Distance(directionFacing, touchNormal)); + if (diff < BSParam.AvatarStepApproachFactor) + { + // Found the stairs contact point. Push up a little to raise the character. + float upForce = (touchPosition.Z - nearFeetHeightMin) * Mass * BSParam.AvatarStepForceFactor; + ret = new OMV.Vector3(0f, 0f, upForce); + + // Also move the avatar up for the new height + OMV.Vector3 displacement = new OMV.Vector3(0f, 0f, BSParam.AvatarStepHeight / 2f); + ForcePosition = RawPosition + displacement; + } + DetailLog("{0},BSCharacter.WalkUpStairs,touchPos={1},nearFeetMin={2},faceDir={3},norm={4},diff={5},ret={6}", + LocalID, touchPosition, nearFeetHeightMin, directionFacing, touchNormal, diff, ret); + } + } + } + } + + return ret; + } + public override void RequestPhysicsterseUpdate() { base.RequestPhysicsterseUpdate(); @@ -342,13 +381,11 @@ public sealed class BSCharacter : BSPhysObject } set { _position = value; - PositionSanityCheck(); PhysicsScene.TaintedObject("BSCharacter.setPosition", delegate() { DetailLog("{0},BSCharacter.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); - if (PhysBody.HasPhysicalBody) - PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation); + ForcePosition = _position; }); } } @@ -359,8 +396,11 @@ public sealed class BSCharacter : BSPhysObject } set { _position = value; - PositionSanityCheck(); - PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation); + if (PhysBody.HasPhysicalBody) + { + PositionSanityCheck(); + PhysicsScene.PE.SetTranslation(PhysBody, _position, _orientation); + } } } @@ -373,7 +413,7 @@ public sealed class BSCharacter : BSPhysObject bool ret = false; // TODO: check for out of bounds - if (!PhysicsScene.TerrainManager.IsWithinKnownTerrain(_position)) + if (!PhysicsScene.TerrainManager.IsWithinKnownTerrain(RawPosition)) { // The character is out of the known/simulated area. // Upper levels of code will handle the transition to other areas so, for @@ -382,7 +422,7 @@ public sealed class BSCharacter : BSPhysObject } // If below the ground, move the avatar up - float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(_position); + float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(RawPosition); if (Position.Z < terrainHeight) { DetailLog("{0},BSCharacter.PositionAdjustUnderGround,call,pos={1},terrain={2}", LocalID, _position, terrainHeight); @@ -485,6 +525,11 @@ public sealed class BSCharacter : BSPhysObject }); } } + public override OMV.Vector3 RawVelocity + { + get { return _velocity; } + set { _velocity = value; } + } // Directly setting velocity means this is what the user really wants now. public override OMV.Vector3 Velocity { get { return _velocity; } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs index b9bd0bf..23d573f 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs @@ -75,6 +75,9 @@ public static class BSParam public static float AvatarCapsuleDepth { get; private set; } public static float AvatarCapsuleHeight { get; private set; } public static float AvatarContactProcessingThreshold { get; private set; } + public static float AvatarStepHeight { get; private set; } + public static float AvatarStepApproachFactor { get; private set; } + public static float AvatarStepForceFactor { get; private set; } public static float VehicleAngularDamping { get; private set; } @@ -403,6 +406,21 @@ public static class BSParam (s,cf,p,v) => { AvatarContactProcessingThreshold = cf.GetFloat(p, v); }, (s) => { return AvatarContactProcessingThreshold; }, (s,p,l,v) => { s.UpdateParameterObject((x)=>{AvatarContactProcessingThreshold=x;}, p, l, v); } ), + new ParameterDefn("AvatarStepHeight", "Height of a step obstacle to consider step correction", + 0.3f, + (s,cf,p,v) => { AvatarStepHeight = cf.GetFloat(p, v); }, + (s) => { return AvatarStepHeight; }, + (s,p,l,v) => { AvatarStepHeight = v; } ), + new ParameterDefn("AvatarStepApproachFactor", "Factor to control angle of approach to step (0=straight on)", + 0.6f, + (s,cf,p,v) => { AvatarStepApproachFactor = cf.GetFloat(p, v); }, + (s) => { return AvatarStepApproachFactor; }, + (s,p,l,v) => { AvatarStepApproachFactor = v; } ), + new ParameterDefn("AvatarStepForceFactor", "Controls the amount of force up applied to step up onto a step", + 2.0f, + (s,cf,p,v) => { AvatarStepForceFactor = cf.GetFloat(p, v); }, + (s) => { return AvatarStepForceFactor; }, + (s,p,l,v) => { AvatarStepForceFactor = v; } ), new ParameterDefn("VehicleAngularDamping", "Factor to damp vehicle angular movement per second (0.0 - 1.0)", 0.95f, diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index 534f929..e8575f6 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs @@ -79,6 +79,7 @@ public abstract class BSPhysObject : PhysicsActor Material = MaterialAttributes.Material.Wood; CollisionCollection = new CollisionEventUpdate(); + CollisionsLastTick = CollisionCollection; SubscribedEventsMs = 0; CollidingStep = 0; CollidingGroundStep = 0; @@ -159,6 +160,7 @@ public abstract class BSPhysObject : PhysicsActor public abstract OMV.Quaternion ForceOrientation { get; set; } // The system is telling us the velocity it wants to move at. + // Velocity in world coordinates. // protected OMV.Vector3 m_targetVelocity; // use the definition in PhysicsActor public override OMV.Vector3 TargetVelocity { @@ -169,6 +171,15 @@ public abstract class BSPhysObject : PhysicsActor Velocity = value; } } + public virtual float TargetSpeed + { + get + { + OMV.Vector3 characterOrientedVelocity = TargetVelocity * OMV.Quaternion.Inverse(OMV.Quaternion.Normalize(RawOrientation)); + return characterOrientedVelocity.X; + } + } + public abstract OMV.Vector3 RawVelocity { get; set; } public abstract OMV.Vector3 ForceVelocity { get; set; } public abstract OMV.Vector3 ForceRotationalVelocity { get; set; } @@ -177,6 +188,15 @@ public abstract class BSPhysObject : PhysicsActor public virtual bool ForceBodyShapeRebuild(bool inTaintTime) { return false; } + public virtual float ForwardSpeed + { + get + { + OMV.Vector3 characterOrientedVelocity = RawVelocity * OMV.Quaternion.Inverse(OMV.Quaternion.Normalize(RawOrientation)); + return characterOrientedVelocity.X; + } + } + #region Collisions // Requested number of milliseconds between collision events. Zero means disabled. @@ -223,9 +243,13 @@ public abstract class BSPhysObject : PhysicsActor // The collisions that have been collected this tick protected CollisionEventUpdate CollisionCollection; + // Remember collisions from last tick for fancy collision based actions + // (like a BSCharacter walking up stairs). + protected CollisionEventUpdate CollisionsLastTick; // The simulation step is telling this object about a collision. // Return 'true' if a collision was processed and should be sent up. + // Return 'false' if this object is not enabled/subscribed/appropriate for or has already seen this collision. // Called at taint time from within the Step() function public virtual bool Collide(uint collidingWith, BSPhysObject collidee, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth) @@ -286,6 +310,9 @@ public abstract class BSPhysObject : PhysicsActor // DetailLog("{0},{1}.SendCollisionUpdate,call,numCollisions={2}", LocalID, TypeName, CollisionCollection.Count); base.SendCollisionUpdate(CollisionCollection); + // Remember the collisions from this tick for some collision specific processing. + CollisionsLastTick = CollisionCollection; + // The CollisionCollection instance is passed around in the simulator. // Make sure we don't have a handle to that one and that a new one is used for next time. // This fixes an interesting 'gotcha'. If we call CollisionCollection.Clear() here, diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 94b63e5..400d5d6 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -562,7 +562,7 @@ public sealed class BSPrim : BSPhysObject } return; } - public OMV.Vector3 RawVelocity + public override OMV.Vector3 RawVelocity { get { return _velocity; } set { _velocity = value; } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt index 7b59e60..794a6af 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt @@ -88,6 +88,8 @@ setForce should set a constant force. Different than AddImpulse. Implement raycast. Implement ShapeCollection.Dispose() Implement water as a plain so raycasting and collisions can happen with same. +Add collision penetration return + Add field passed back by BulletSim.dll and fill with info in ManifoldConstact.GetDistance() Add osGetPhysicsEngineName() so scripters can tell whether BulletSim or ODE Also osGetPhysicsEngineVerion() maybe. Linkset.Position and Linkset.Orientation requre rewrite to properly return -- cgit v1.1 From 1603606f1d8bd62574cf98e051877d836cbeb012 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 7 Jan 2013 22:00:50 -0800 Subject: BulletSim: improve vehicle angular banking and deflection computation. Rotate angular correction forces to be world relative rather than vehicle relative. --- OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 37 +++++++++++----------- 1 file changed, 18 insertions(+), 19 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index a9fbc8b..eb695d9 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs @@ -1111,6 +1111,10 @@ namespace OpenSim.Region.Physics.BulletSPlugin + deflectionContribution + bankingContribution; + // Add of the above computation are made relative to vehicle coordinates. + // Convert to world coordinates. + m_lastAngularVelocity *= VehicleOrientation; + // ================================================================== // Apply the correction velocity. // TODO: Should this be applied as an angular force (torque)? @@ -1222,14 +1226,13 @@ namespace OpenSim.Region.Physics.BulletSPlugin public Vector3 ComputeAngularDeflection() { Vector3 ret = Vector3.Zero; - return ret; // DEBUG DEBUG DEBUG - // Disable angular deflection for the moment. + // Since angularMotorUp and angularDeflection are computed independently, they will calculate // approximately the same X or Y correction. When added together (when contributions are combined) // this creates an over-correction and then wabbling as the target is overshot. // TODO: rethink how the different correction computations inter-relate. - if (m_angularDeflectionEfficiency != 0) + if (m_angularDeflectionEfficiency != 0 && VehicleVelocity != Vector3.Zero) { // The direction the vehicle is moving Vector3 movingDirection = VehicleVelocity; @@ -1298,33 +1301,29 @@ namespace OpenSim.Region.Physics.BulletSPlugin if (m_bankingEfficiency != 0 && m_verticalAttractionTimescale < m_verticalAttractionCutoff) { - // This works by rotating a unit vector to the orientation of the vehicle. The - // roll (tilt) will be Y component of a tilting Z vector (zero for no tilt - // up to one for full over). + // Rotate a UnitZ vector (pointing up) to how the vehicle is oriented. + // As the vehicle rolls to the right or left, the Y value will increase from + // zero (straight up) to 1 or -1 (full tilt right or left) Vector3 rollComponents = Vector3.UnitZ * VehicleOrientation; - + // Figure out the yaw value for this much roll. - float turnComponent = rollComponents.Y * rollComponents.Y * m_bankingEfficiency; - // Keep the sign - if (rollComponents.Y < 0f) - turnComponent = -turnComponent; - - // TODO: there must be a better computation of the banking force. - float bankingTurnForce = turnComponent; + // Squared because that seems to give a good value + float yawAngle = (float)Math.Asin(rollComponents.Y * rollComponents.Y) * m_bankingEfficiency; // actual error = static turn error + dynamic turn error - float mixedBankingError = bankingTurnForce * (1f - m_bankingMix) + bankingTurnForce * m_bankingMix * VehicleForwardSpeed; + float mixedYawAngle = yawAngle * (1f - m_bankingMix) + yawAngle * m_bankingMix * VehicleForwardSpeed; + // TODO: the banking effect should not go to infinity but what to limit it to? - mixedBankingError = ClampInRange(-20f, mixedBankingError, 20f); + mixedYawAngle = ClampInRange(-20f, mixedYawAngle, 20f); // Build the force vector to change rotation from what it is to what it should be - ret.Z = -mixedBankingError; + ret.Z = -mixedYawAngle; // Don't do it all at once. ret /= m_bankingTimescale; - VDetailLog("{0}, MoveAngular,Banking,rollComp={1},speed={2},turnComp={3},bankErr={4},mixedBankErr={5},ret={6}", - Prim.LocalID, rollComponents, VehicleForwardSpeed, turnComponent, bankingTurnForce, mixedBankingError, ret); + VDetailLog("{0}, MoveAngular,Banking,rollComp={1},speed={2},rollComp={3},yAng={4},mYAng={5},ret={6}", + Prim.LocalID, rollComponents, VehicleForwardSpeed, rollComponents, yawAngle, mixedYawAngle, ret); } return ret; } -- cgit v1.1 From 2ac96dd1813fa90907ef589b98a9bf68f0ab2e9f Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 8 Jan 2013 22:52:14 +0000 Subject: Add the new UpdateAgentInformation cap to make maturity on more recent viewers work. --- .../Linden/Caps/BunchOfCaps/BunchOfCaps.cs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs index cc69645..a534522 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs @@ -96,8 +96,8 @@ namespace OpenSim.Region.ClientStack.Linden // private static readonly string m_fetchInventoryPath = "0006/"; private static readonly string m_copyFromNotecardPath = "0007/"; // private static readonly string m_remoteParcelRequestPath = "0009/";// This is in the LandManagementModule. - - + private static readonly string m_UpdateAgentInformationPath = "0500/"; + // These are callbacks which will be setup by the scene so that we can update scene data when we // receive capability calls public NewInventoryItem AddNewInventoryItem = null; @@ -204,6 +204,8 @@ namespace OpenSim.Region.ClientStack.Linden m_HostCapsObj.RegisterHandler("UpdateNotecardAgentInventory", req); m_HostCapsObj.RegisterHandler("UpdateScriptAgentInventory", req); m_HostCapsObj.RegisterHandler("UpdateScriptAgent", req); + IRequestHandler UpdateAgentInformationHandler = new RestStreamHandler("POST", capsBase + m_UpdateAgentInformationPath, UpdateAgentInformation); + m_HostCapsObj.RegisterHandler("UpdateAgentInformation", UpdateAgentInformationHandler); m_HostCapsObj.RegisterHandler( "CopyInventoryFromNotecard", @@ -855,6 +857,22 @@ namespace OpenSim.Region.ClientStack.Linden response["int_response_code"] = 200; return LLSDHelpers.SerialiseLLSDReply(response); } + + public string UpdateAgentInformation(string request, string path, + string param, IOSHttpRequest httpRequest, + IOSHttpResponse httpResponse) + { + OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); + OSDMap resp = new OSDMap(); + + OSDMap accessPrefs = new OSDMap(); + accessPrefs["max"] = "A"; + + resp["access_prefs"] = accessPrefs; + + string response = OSDParser.SerializeLLSDXmlString(resp); + return response; + } } public class AssetUploader -- cgit v1.1 From 5561333668f61f043cdfc0733a4eb50a1bcfb14e Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 8 Jan 2013 23:01:09 +0100 Subject: Prevent empty Anim Packs --- OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs index 65ae445..d2fc7f1 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs @@ -164,7 +164,13 @@ namespace OpenSim.Region.Framework.Scenes.Animation { int defaultSize = 0; if (m_defaultAnimation.AnimID != UUID.Zero) + { + defaultSize++; + } + else if (m_animations.Count == 0) + { defaultSize++; + } animIDs = new UUID[m_animations.Count + defaultSize]; sequenceNums = new int[m_animations.Count + defaultSize]; @@ -176,6 +182,12 @@ namespace OpenSim.Region.Framework.Scenes.Animation sequenceNums[0] = m_defaultAnimation.SequenceNum; objectIDs[0] = m_defaultAnimation.ObjectID; } + else if (m_animations.Count == 0) + { + animIDs[0] = m_implicitDefaultAnimation.AnimID; + sequenceNums[0] = m_defaultAnimation.SequenceNum; + objectIDs[0] = m_implicitDefaultAnimation.ObjectID; + } for (int i = 0; i < m_animations.Count; ++i) { -- cgit v1.1 From a775931a0cec9f65748c6e20dd2695edcbe21b7f Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 8 Jan 2013 23:24:34 +0100 Subject: Fix sequence id fr default anim --- OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs index d2fc7f1..64c31f8 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs @@ -185,7 +185,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation else if (m_animations.Count == 0) { animIDs[0] = m_implicitDefaultAnimation.AnimID; - sequenceNums[0] = m_defaultAnimation.SequenceNum; + sequenceNums[0] = m_implicitDefaultAnimation.SequenceNum; objectIDs[0] = m_implicitDefaultAnimation.ObjectID; } -- cgit v1.1 From 5fa4b8b1445829af66a63869672b76624d51a525 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 9 Jan 2013 00:01:48 +0000 Subject: minor: Allow "script *" console commands to take multiple script item ids --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 62 +++++++++++++------------- 1 file changed, 32 insertions(+), 30 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 79cec04..ba63bb6 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -324,40 +324,40 @@ namespace OpenSim.Region.ScriptEngine.XEngine HandleShowStatus); MainConsole.Instance.Commands.AddCommand( - "Scripts", false, "scripts show", "scripts show []", "Show script information", + "Scripts", false, "scripts show", "scripts show [+]", "Show script information", "Show information on all scripts known to the script engine.\n" - + "If a is given then only information on that script will be shown.", + + "If one or more s are given then only information on that script will be shown.", HandleShowScripts); MainConsole.Instance.Commands.AddCommand( - "Scripts", false, "show scripts", "show scripts []", "Show script information", + "Scripts", false, "show scripts", "show scripts [+]", "Show script information", "Synonym for scripts show command", HandleShowScripts); MainConsole.Instance.Commands.AddCommand( - "Scripts", false, "scripts suspend", "scripts suspend []", "Suspends all running scripts", + "Scripts", false, "scripts suspend", "scripts suspend [+]", "Suspends all running scripts", "Suspends all currently running scripts. This only suspends event delivery, it will not suspend a" + " script that is currently processing an event.\n" + "Suspended scripts will continue to accumulate events but won't process them.\n" - + "If a is given then only that script will be suspended. Otherwise, all suitable scripts are suspended.", + + "If one or more s are given then only that script will be suspended. Otherwise, all suitable scripts are suspended.", (module, cmdparams) => HandleScriptsAction(cmdparams, HandleSuspendScript)); MainConsole.Instance.Commands.AddCommand( - "Scripts", false, "scripts resume", "scripts resume []", "Resumes all suspended scripts", + "Scripts", false, "scripts resume", "scripts resume [+]", "Resumes all suspended scripts", "Resumes all currently suspended scripts.\n" + "Resumed scripts will process all events accumulated whilst suspended.\n" - + "If a is given then only that script will be resumed. Otherwise, all suitable scripts are resumed.", + + "If one or more s are given then only that script will be resumed. Otherwise, all suitable scripts are resumed.", (module, cmdparams) => HandleScriptsAction(cmdparams, HandleResumeScript)); MainConsole.Instance.Commands.AddCommand( - "Scripts", false, "scripts stop", "scripts stop []", "Stops all running scripts", + "Scripts", false, "scripts stop", "scripts stop [+]", "Stops all running scripts", "Stops all running scripts.\n" - + "If a is given then only that script will be stopped. Otherwise, all suitable scripts are stopped.", + + "If one or more s are given then only that script will be stopped. Otherwise, all suitable scripts are stopped.", (module, cmdparams) => HandleScriptsAction(cmdparams, HandleStopScript)); MainConsole.Instance.Commands.AddCommand( - "Scripts", false, "scripts start", "scripts start []", "Starts all stopped scripts", + "Scripts", false, "scripts start", "scripts start [+]", "Starts all stopped scripts", "Starts all stopped scripts.\n" - + "If a is given then only that script will be started. Otherwise, all suitable scripts are started.", + + "If one or more s are given then only that script will be started. Otherwise, all suitable scripts are started.", (module, cmdparams) => HandleScriptsAction(cmdparams, HandleStartScript)); MainConsole.Instance.Commands.AddCommand( @@ -478,29 +478,31 @@ namespace OpenSim.Region.ScriptEngine.XEngine return; } - rawItemId = cmdparams[2]; - - if (!UUID.TryParse(rawItemId, out itemId)) + for (int i = 2; i < cmdparams.Length; i++) { - MainConsole.Instance.OutputFormat("ERROR: {0} is not a valid UUID", rawItemId); - return; - } - - if (itemId != UUID.Zero) - { - IScriptInstance instance = GetInstance(itemId); - if (instance == null) + rawItemId = cmdparams[i]; + + if (!UUID.TryParse(rawItemId, out itemId)) { - // Commented out for now since this will cause false reports on simulators with more than - // one scene where the current command line set region is 'root' (which causes commands to - // go to both regions... (sigh) -// MainConsole.Instance.OutputFormat("Error - No item found with id {0}", itemId); - return; + MainConsole.Instance.OutputFormat("ERROR: {0} is not a valid UUID", rawItemId); + continue; } - else + + if (itemId != UUID.Zero) { - action(instance); - return; + IScriptInstance instance = GetInstance(itemId); + if (instance == null) + { + // Commented out for now since this will cause false reports on simulators with more than + // one scene where the current command line set region is 'root' (which causes commands to + // go to both regions... (sigh) + // MainConsole.Instance.OutputFormat("Error - No item found with id {0}", itemId); + continue; + } + else + { + action(instance); + } } } } -- cgit v1.1 From 3d5e3e35b799fe777066ac0cb27cf1bd3e104651 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 9 Jan 2013 00:08:08 +0000 Subject: minor: Fix command match of "debug script" command to "debug scripts" to match other scripts commands (and it's own short help text) --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index ba63bb6..4bbcb7c 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -361,7 +361,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine (module, cmdparams) => HandleScriptsAction(cmdparams, HandleStartScript)); MainConsole.Instance.Commands.AddCommand( - "Scripts", false, "debug script log", "debug scripts log ", "Extra debug logging for a script", + "Scripts", false, "debug scripts log", "debug scripts log ", "Extra debug logging for a script", "Activates or deactivates extra debug logging for the given script.\n" + "Level == 0, deactivate extra debug logging.\n" + "Level >= 1, log state changes.\n" -- cgit v1.1 From c1c540f454b0c9fd189ed768764fb8a51ee773c6 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 9 Jan 2013 00:20:14 +0000 Subject: Revert "Fix sequence id fr default anim" This reverts commit a775931a0cec9f65748c6e20dd2695edcbe21b7f. --- OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs index 64c31f8..d2fc7f1 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs @@ -185,7 +185,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation else if (m_animations.Count == 0) { animIDs[0] = m_implicitDefaultAnimation.AnimID; - sequenceNums[0] = m_implicitDefaultAnimation.SequenceNum; + sequenceNums[0] = m_defaultAnimation.SequenceNum; objectIDs[0] = m_implicitDefaultAnimation.ObjectID; } -- cgit v1.1 From f16c4a254c263a7fd75799fe79da6b3d0a1c80a2 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 9 Jan 2013 00:20:24 +0000 Subject: Revert "Prevent empty Anim Packs" This reverts commit 5561333668f61f043cdfc0733a4eb50a1bcfb14e. --- OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs index d2fc7f1..65ae445 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs @@ -164,13 +164,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation { int defaultSize = 0; if (m_defaultAnimation.AnimID != UUID.Zero) - { - defaultSize++; - } - else if (m_animations.Count == 0) - { defaultSize++; - } animIDs = new UUID[m_animations.Count + defaultSize]; sequenceNums = new int[m_animations.Count + defaultSize]; @@ -182,12 +176,6 @@ namespace OpenSim.Region.Framework.Scenes.Animation sequenceNums[0] = m_defaultAnimation.SequenceNum; objectIDs[0] = m_defaultAnimation.ObjectID; } - else if (m_animations.Count == 0) - { - animIDs[0] = m_implicitDefaultAnimation.AnimID; - sequenceNums[0] = m_defaultAnimation.SequenceNum; - objectIDs[0] = m_implicitDefaultAnimation.ObjectID; - } for (int i = 0; i < m_animations.Count; ++i) { -- cgit v1.1 From df1d7414adbf329e139201cdb7578c7b64bb50c8 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 8 Jan 2013 16:09:15 -0800 Subject: BulletSim: Fix hover height (boats float at the correct level). Fix problem of vehicles going crazy when backing up. --- OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 16 ++++++++++------ OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt | 4 ++-- 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index eb695d9..c34c05a 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs @@ -856,6 +856,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin // The movement computed in the linear motor is relative to the vehicle // coordinates. Rotate the movement to world coordinates. linearMotorContribution *= VehicleOrientation; + // All the contributions after this are world relative (mostly Z modifications) // ================================================================== // Buoyancy: force to overcome gravity. @@ -982,14 +983,11 @@ namespace OpenSim.Region.Physics.BulletSPlugin float verticalCorrectionVelocity = verticalError / m_VhoverTimescale; // TODO: implement m_VhoverEfficiency correctly - if (Math.Abs(verticalError) > m_VhoverEfficiency) - { - ret = new Vector3(0f, 0f, verticalCorrectionVelocity); - } + ret = new Vector3(0f, 0f, verticalCorrectionVelocity); } - VDetailLog("{0}, MoveLinear,hover,pos={1},ret={2},hoverTS={3},height={4},target={5}", - Prim.LocalID, VehiclePosition, ret, m_VhoverTimescale, m_VhoverHeight, m_VhoverTargetHeight); + VDetailLog("{0}, MoveLinear,hover,pos={1},eff={2},hoverTS={3},height={4},target={5},ret={6}", + Prim.LocalID, VehiclePosition, m_VhoverEfficiency, m_VhoverTimescale, m_VhoverHeight, m_VhoverTargetHeight, ret); } return ret; @@ -1238,6 +1236,9 @@ namespace OpenSim.Region.Physics.BulletSPlugin Vector3 movingDirection = VehicleVelocity; movingDirection.Normalize(); + // If the vehicle is going backward, it is still pointing forward + movingDirection *= Math.Sign(VehicleForwardSpeed); + // The direction the vehicle is pointing Vector3 pointingDirection = Vector3.UnitX * VehicleOrientation; pointingDirection.Normalize(); @@ -1246,6 +1247,9 @@ namespace OpenSim.Region.Physics.BulletSPlugin Vector3 deflectionError = movingDirection - pointingDirection; // Don't try to correct very large errors (not our job) + // if (Math.Abs(deflectionError.X) > PIOverFour) deflectionError.X = PIOverTwo * Math.Sign(deflectionError.X); + // if (Math.Abs(deflectionError.Y) > PIOverFour) deflectionError.Y = PIOverTwo * Math.Sign(deflectionError.Y); + // if (Math.Abs(deflectionError.Z) > PIOverFour) deflectionError.Z = PIOverTwo * Math.Sign(deflectionError.Z); if (Math.Abs(deflectionError.X) > PIOverFour) deflectionError.X = 0f; if (Math.Abs(deflectionError.Y) > PIOverFour) deflectionError.Y = 0f; if (Math.Abs(deflectionError.Z) > PIOverFour) deflectionError.Z = 0f; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt index 794a6af..29bd4e4 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt @@ -1,9 +1,9 @@ CURRENT PRIORITIES ================================================= -Avatars walking up stairs +Avatars walking up stairs (HALF DONE) Vehicle movement on terrain smoothness limitMotorUp calibration (more down?) -Preferred orientatino angular correction fix +Preferred orientation angular correction fix Surfboard go wonky when turning Angular motor direction is global coordinates rather than local coordinates? Boats float low in the water -- cgit v1.1 From c28a2f05caae50590e64e61d8b7358ee92a7fca3 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 9 Jan 2013 00:54:28 +0000 Subject: minor: make spacing consistent in console help output --- OpenSim/Framework/Console/CommandConsole.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs index de30414..f9c9307 100644 --- a/OpenSim/Framework/Console/CommandConsole.cs +++ b/OpenSim/Framework/Console/CommandConsole.cs @@ -110,10 +110,11 @@ namespace OpenSim.Framework.Console // Remove initial help keyword helpParts.RemoveAt(0); + help.Add(""); // Will become a newline. + // General help if (helpParts.Count == 0) { - help.Add(""); // Will become a newline. help.Add(GeneralHelpText); help.Add(ItemHelpText); help.AddRange(CollectModulesHelp(tree)); @@ -127,6 +128,8 @@ namespace OpenSim.Framework.Console help.AddRange(CollectHelp(helpParts)); } + help.Add(""); // Will become a newline. + return help; } @@ -200,8 +203,8 @@ namespace OpenSim.Framework.Console help.Add(commandInfo.descriptive_help); - if (descriptiveHelp != string.Empty) - help.Add(string.Empty); +// if (descriptiveHelp != string.Empty) +// help.Add(string.Empty); } else { -- cgit v1.1 From 290dc274ec0860e96f0c19479c8da512779cdab3 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 9 Jan 2013 01:04:43 +0000 Subject: minor: Remove unnecessary commented out code from last commit c28a2f05 and fix up code comment --- OpenSim/Framework/Console/CommandConsole.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Console/CommandConsole.cs b/OpenSim/Framework/Console/CommandConsole.cs index f9c9307..b9f402a 100644 --- a/OpenSim/Framework/Console/CommandConsole.cs +++ b/OpenSim/Framework/Console/CommandConsole.cs @@ -197,14 +197,11 @@ namespace OpenSim.Framework.Console string descriptiveHelp = commandInfo.descriptive_help; - // If we do have some descriptive help then insert a spacing line before and after for readability. + // If we do have some descriptive help then insert a spacing line before for readability. if (descriptiveHelp != string.Empty) help.Add(string.Empty); help.Add(commandInfo.descriptive_help); - -// if (descriptiveHelp != string.Empty) -// help.Add(string.Empty); } else { -- cgit v1.1 From a0000a034f3d193662d56a1c8147771b0d994b23 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 10 Jan 2013 00:32:22 +0000 Subject: Add "show sensors" command to show script sensor information for debug purposes. --- .../Api/Implementation/Plugins/SensorRepeat.cs | 94 ++++++++++++++-------- .../XEngine/ScriptEngineConsoleCommands.cs | 86 ++++++++++++++++++++ OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 5 ++ 3 files changed, 153 insertions(+), 32 deletions(-) create mode 100644 OpenSim/Region/ScriptEngine/XEngine/ScriptEngineConsoleCommands.cs (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index 24cceea..37422d7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs @@ -42,6 +42,41 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins { // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + /// + /// Used by one-off and repeated sensors + /// + public class SensorInfo + { + public uint localID; + public UUID itemID; + public double interval; + public DateTime next; + + public string name; + public UUID keyID; + public int type; + public double range; + public double arc; + public SceneObjectPart host; + + public SensorInfo Clone() + { + SensorInfo s = new SensorInfo(); + s.localID = localID; + s.itemID = itemID; + s.interval = interval; + s.next = next; + s.name = name; + s.keyID = keyID; + s.type = type; + s.range = range; + s.arc = arc; + s.host = host; + + return s; + } + } + public AsyncCommandManager m_CmdManager; /// @@ -79,24 +114,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins private int maximumToReturn = 16; // - // SenseRepeater and Sensors - // - private class SenseRepeatClass - { - public uint localID; - public UUID itemID; - public double interval; - public DateTime next; - - public string name; - public UUID keyID; - public int type; - public double range; - public double arc; - public SceneObjectPart host; - } - - // // Sensed entity // private class SensedEntity : IComparable @@ -128,7 +145,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins /// /// Always lock SenseRepeatListLock when updating this list. /// - private List SenseRepeaters = new List(); + private List SenseRepeaters = new List(); private object SenseRepeatListLock = new object(); public void SetSenseRepeatEvent(uint m_localID, UUID m_itemID, @@ -142,7 +159,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins return; // Add to timer - SenseRepeatClass ts = new SenseRepeatClass(); + SensorInfo ts = new SensorInfo(); ts.localID = m_localID; ts.itemID = m_itemID; ts.interval = sec; @@ -161,11 +178,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins AddSenseRepeater(ts); } - private void AddSenseRepeater(SenseRepeatClass senseRepeater) + private void AddSenseRepeater(SensorInfo senseRepeater) { lock (SenseRepeatListLock) { - List newSenseRepeaters = new List(SenseRepeaters); + List newSenseRepeaters = new List(SenseRepeaters); newSenseRepeaters.Add(senseRepeater); SenseRepeaters = newSenseRepeaters; } @@ -176,8 +193,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins // Remove from timer lock (SenseRepeatListLock) { - List newSenseRepeaters = new List(); - foreach (SenseRepeatClass ts in SenseRepeaters) + List newSenseRepeaters = new List(); + foreach (SensorInfo ts in SenseRepeaters) { if (ts.localID != m_localID || ts.itemID != m_itemID) { @@ -192,7 +209,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins public void CheckSenseRepeaterEvents() { // Go through all timers - foreach (SenseRepeatClass ts in SenseRepeaters) + foreach (SensorInfo ts in SenseRepeaters) { // Time has passed? if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime()) @@ -209,7 +226,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins double range, double arc, SceneObjectPart host) { // Add to timer - SenseRepeatClass ts = new SenseRepeatClass(); + SensorInfo ts = new SensorInfo(); ts.localID = m_localID; ts.itemID = m_itemID; ts.interval = 0; @@ -225,7 +242,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins SensorSweep(ts); } - private void SensorSweep(SenseRepeatClass ts) + private void SensorSweep(SensorInfo ts) { if (ts.host == null) { @@ -301,7 +318,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins } } - private List doObjectSensor(SenseRepeatClass ts) + private List doObjectSensor(SensorInfo ts) { List Entities; List sensedEntities = new List(); @@ -450,7 +467,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins return sensedEntities; } - private List doAgentSensor(SenseRepeatClass ts) + private List doAgentSensor(SensorInfo ts) { List sensedEntities = new List(); @@ -626,7 +643,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins { List data = new List(); - foreach (SenseRepeatClass ts in SenseRepeaters) + foreach (SensorInfo ts in SenseRepeaters) { if (ts.itemID == itemID) { @@ -656,7 +673,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins while (idx < data.Length) { - SenseRepeatClass ts = new SenseRepeatClass(); + SensorInfo ts = new SensorInfo(); ts.localID = localID; ts.itemID = itemID; @@ -677,5 +694,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins idx += 6; } } + + public List GetSensorInfo() + { + List retList = new List(); + + lock (SenseRepeatListLock) + { + foreach (SensorInfo si in SenseRepeaters) + retList.Add(si.Clone()); + } + + return retList; + } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/XEngine/ScriptEngineConsoleCommands.cs b/OpenSim/Region/ScriptEngine/XEngine/ScriptEngineConsoleCommands.cs new file mode 100644 index 0000000..e47917d --- /dev/null +++ b/OpenSim/Region/ScriptEngine/XEngine/ScriptEngineConsoleCommands.cs @@ -0,0 +1,86 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using OpenSim.Framework; +using OpenSim.Framework.Console; +using OpenSim.Region.ScriptEngine.Interfaces; +using OpenSim.Region.ScriptEngine.Shared.Api; +using OpenSim.Region.ScriptEngine.Shared.Api.Plugins; + +namespace OpenSim.Region.ScriptEngine.XEngine +{ + public class ScriptEngineConsoleCommands + { + IScriptEngine m_engine; + + public ScriptEngineConsoleCommands(IScriptEngine engine) + { + m_engine = engine; + } + + public void RegisterCommands() + { + MainConsole.Instance.Commands.AddCommand( + "Scripts", false, "show sensors", "show sensors", "Show script sensors information", + HandleShowSensors); + } + + private void HandleShowSensors(string module, string[] cmdparams) + { + if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_engine.World)) + return; + + SensorRepeat sr = AsyncCommandManager.GetSensorRepeatPlugin(m_engine); + + if (sr == null) + { + MainConsole.Instance.Output("Sensor plugin not yet initialized"); + return; + } + + List sensorInfo = sr.GetSensorInfo(); + + ConsoleDisplayTable cdt = new ConsoleDisplayTable(); + cdt.AddColumn("Part name", 40); + cdt.AddColumn("Script item ID", 36); + cdt.AddColumn("Type", 4); + cdt.AddColumn("Interval", 8); + cdt.AddColumn("Range", 8); + cdt.AddColumn("Arc", 8); + + foreach (SensorRepeat.SensorInfo s in sensorInfo) + { + cdt.AddRow(s.host.Name, s.itemID, s.type, s.interval, s.range, s.arc); + } + + MainConsole.Instance.Output(cdt.ToString()); + MainConsole.Instance.OutputFormat("Total: {0}", sensorInfo.Count); + } + } +} \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 4bbcb7c..8c3bb5b 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -169,6 +169,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine IWorkItemResult m_CurrentCompile = null; private Dictionary m_CompileDict = new Dictionary(); + private ScriptEngineConsoleCommands m_consoleCommands; + public string ScriptEngineName { get { return "XEngine"; } @@ -318,6 +320,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine OnObjectRemoved += m_XmlRpcRouter.ObjectRemoved; } + m_consoleCommands = new ScriptEngineConsoleCommands(this); + m_consoleCommands.RegisterCommands(); + MainConsole.Instance.Commands.AddCommand( "Scripts", false, "xengine status", "xengine status", "Show status information", "Show status information on the script engine.", -- cgit v1.1 From b1b46872500476cf97b5de8c16012b8545fed0c7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 10 Jan 2013 00:57:49 +0000 Subject: Add "show script timers" command to show script timers. For debug purposes. Also, "show sensors" changes to "show script sensors". --- OpenSim/Framework/Monitoring/MemoryWatchdog.cs | 2 +- .../Api/Implementation/Plugins/SensorRepeat.cs | 18 ++------ .../Shared/Api/Implementation/Plugins/Timer.cs | 52 +++++++++++++++------- .../XEngine/ScriptEngineConsoleCommands.cs | 46 +++++++++++++++++-- 4 files changed, 82 insertions(+), 36 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Monitoring/MemoryWatchdog.cs b/OpenSim/Framework/Monitoring/MemoryWatchdog.cs index c6010cd..bc5ed97 100644 --- a/OpenSim/Framework/Monitoring/MemoryWatchdog.cs +++ b/OpenSim/Framework/Monitoring/MemoryWatchdog.cs @@ -72,7 +72,7 @@ namespace OpenSim.Framework.Monitoring /// public static double LastMemoryChurn { - get { if (m_samples.Count > 0) return m_samples.Last(); else return 0; } + get { if (m_samples.Count > 0) return m_samples.First(); else return 0; } } /// diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index 37422d7..dd45406 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs @@ -61,19 +61,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins public SensorInfo Clone() { - SensorInfo s = new SensorInfo(); - s.localID = localID; - s.itemID = itemID; - s.interval = interval; - s.next = next; - s.name = name; - s.keyID = keyID; - s.type = type; - s.range = range; - s.arc = arc; - s.host = host; - - return s; + return (SensorInfo)this.MemberwiseClone(); } } @@ -701,8 +689,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins lock (SenseRepeatListLock) { - foreach (SensorInfo si in SenseRepeaters) - retList.Add(si.Clone()); + foreach (SensorInfo i in SenseRepeaters) + retList.Add(i.Clone()); } return retList; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs index bc63030..0b14565 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/Timer.cs @@ -35,6 +35,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins { public class Timer { + public class TimerInfo + { + public uint localID; + public UUID itemID; + //public double interval; + public long interval; + //public DateTime next; + public long next; + + public TimerInfo Clone() + { + return (TimerInfo)this.MemberwiseClone(); + } + } + public AsyncCommandManager m_CmdManager; public int TimersCount @@ -59,17 +74,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins return localID.ToString() + itemID.ToString(); } - private class TimerClass - { - public uint localID; - public UUID itemID; - //public double interval; - public long interval; - //public DateTime next; - public long next; - } - - private Dictionary Timers = new Dictionary(); + private Dictionary Timers = new Dictionary(); private object TimerListLock = new object(); public void SetTimerEvent(uint m_localID, UUID m_itemID, double sec) @@ -81,7 +86,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins } // Add to timer - TimerClass ts = new TimerClass(); + TimerInfo ts = new TimerInfo(); ts.localID = m_localID; ts.itemID = m_itemID; ts.interval = Convert.ToInt64(sec * 10000000); // How many 100 nanoseconds (ticks) should we wait @@ -121,8 +126,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins lock (TimerListLock) { // Go through all timers - Dictionary.ValueCollection tvals = Timers.Values; - foreach (TimerClass ts in tvals) + Dictionary.ValueCollection tvals = Timers.Values; + foreach (TimerInfo ts in tvals) { // Time has passed? if (ts.next < DateTime.Now.Ticks) @@ -147,8 +152,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins lock (TimerListLock) { - Dictionary.ValueCollection tvals = Timers.Values; - foreach (TimerClass ts in tvals) + Dictionary.ValueCollection tvals = Timers.Values; + foreach (TimerInfo ts in tvals) { if (ts.itemID == itemID) { @@ -167,7 +172,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins while (idx < data.Length) { - TimerClass ts = new TimerClass(); + TimerInfo ts = new TimerInfo(); ts.localID = localID; ts.itemID = itemID; @@ -181,5 +186,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins } } } + + public List GetTimersInfo() + { + List retList = new List(); + + lock (TimerListLock) + { + foreach (TimerInfo i in Timers.Values) + retList.Add(i.Clone()); + } + + return retList; + } } } diff --git a/OpenSim/Region/ScriptEngine/XEngine/ScriptEngineConsoleCommands.cs b/OpenSim/Region/ScriptEngine/XEngine/ScriptEngineConsoleCommands.cs index e47917d..efb854d 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/ScriptEngineConsoleCommands.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/ScriptEngineConsoleCommands.cs @@ -47,20 +47,29 @@ namespace OpenSim.Region.ScriptEngine.XEngine public void RegisterCommands() { MainConsole.Instance.Commands.AddCommand( - "Scripts", false, "show sensors", "show sensors", "Show script sensors information", + "Scripts", false, "show script sensors", "show script sensors", "Show script sensors information", HandleShowSensors); + + MainConsole.Instance.Commands.AddCommand( + "Scripts", false, "show script timers", "show script timers", "Show script sensors information", + HandleShowTimers); + } + + private bool IsSceneSelected() + { + return MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_engine.World; } private void HandleShowSensors(string module, string[] cmdparams) { - if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_engine.World)) + if (!IsSceneSelected()) return; SensorRepeat sr = AsyncCommandManager.GetSensorRepeatPlugin(m_engine); if (sr == null) { - MainConsole.Instance.Output("Sensor plugin not yet initialized"); + MainConsole.Instance.Output("Plugin not yet initialized"); return; } @@ -82,5 +91,36 @@ namespace OpenSim.Region.ScriptEngine.XEngine MainConsole.Instance.Output(cdt.ToString()); MainConsole.Instance.OutputFormat("Total: {0}", sensorInfo.Count); } + + private void HandleShowTimers(string module, string[] cmdparams) + { + if (!IsSceneSelected()) + return; + + Timer timerPlugin = AsyncCommandManager.GetTimerPlugin(m_engine); + + if (timerPlugin == null) + { + MainConsole.Instance.Output("Plugin not yet initialized"); + return; + } + + List timersInfo = timerPlugin.GetTimersInfo(); + + ConsoleDisplayTable cdt = new ConsoleDisplayTable(); + cdt.AddColumn("Part local ID", 13); + cdt.AddColumn("Script item ID", 36); + cdt.AddColumn("Interval", 10); + cdt.AddColumn("Next", 8); + + foreach (Timer.TimerInfo t in timersInfo) + { + // Convert from 100 ns ticks back to seconds + cdt.AddRow(t.localID, t.itemID, (double)t.interval / 10000000, t.next); + } + + MainConsole.Instance.Output(cdt.ToString()); + MainConsole.Instance.OutputFormat("Total: {0}", timersInfo.Count); + } } } \ No newline at end of file -- cgit v1.1 From 84407e322f6469a3001b390f7c516f4eabaad1e6 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 10 Jan 2013 01:30:00 +0000 Subject: revert accidental change to MemoryWatchdog stat calculation in previous b1b4687 --- OpenSim/Framework/Monitoring/MemoryWatchdog.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Monitoring/MemoryWatchdog.cs b/OpenSim/Framework/Monitoring/MemoryWatchdog.cs index bc5ed97..c6010cd 100644 --- a/OpenSim/Framework/Monitoring/MemoryWatchdog.cs +++ b/OpenSim/Framework/Monitoring/MemoryWatchdog.cs @@ -72,7 +72,7 @@ namespace OpenSim.Framework.Monitoring /// public static double LastMemoryChurn { - get { if (m_samples.Count > 0) return m_samples.First(); else return 0; } + get { if (m_samples.Count > 0) return m_samples.Last(); else return 0; } } /// -- cgit v1.1 From 170d37696795d70799fb9b402400133088f389e9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 10 Jan 2013 01:45:56 +0000 Subject: On baked texture save, replace any HG ID with an ordinary asset ID so the HGAssetBroker doesn't try to save back to the avatar's originating region --- OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 0a69979..ce79f07 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -287,6 +287,9 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory if (asset != null) { + // Replace an HG ID with the simple asset ID so that we can persist textures for foreign HG avatars + asset.ID = asset.FullID.ToString(); + asset.Temporary = false; asset.Local = false; m_scene.AssetService.Store(asset); -- cgit v1.1