From f254af29ac88c2aa073d604c89709b4abca9a2f1 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 24 Nov 2012 03:39:37 +0000 Subject: [PATCH 01/33] avoid potencial NullReferenceException --- .../Shared/Api/Implementation/AsyncCommandManager.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs index 94fd940dc1..6879ebbe97 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs @@ -317,8 +317,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api comms.DeleteListener(itemID); IXMLRPC xmlrpc = engine.World.RequestModuleInterface(); - xmlrpc.DeleteChannels(itemID); - xmlrpc.CancelSRDRequests(itemID); + if (xmlrpc != null) + { + xmlrpc.DeleteChannels(itemID); + xmlrpc.CancelSRDRequests(itemID); + } // Remove Sensors m_SensorRepeat[engine].UnSetSenseRepeaterEvents(localID, itemID); From 62244b5ea5d9fcbe24e35906517fb02022cdcc7c Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 24 Nov 2012 22:46:24 +0000 Subject: [PATCH 02/33] don't zero constant force and torque in selection --- OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs index dc247a9fa2..7dddab6175 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs @@ -84,7 +84,7 @@ namespace OpenSim.Region.Physics.OdePlugin private Vector3 _position; private Vector3 _velocity; - private Vector3 _torque; + private Vector3 m_torque; private Vector3 m_lastVelocity; private Vector3 m_lastposition; private Vector3 m_rotationalVelocity; @@ -597,7 +597,7 @@ namespace OpenSim.Region.Physics.OdePlugin if (!IsPhysical || Body == IntPtr.Zero) return Vector3.Zero; - return _torque; + return m_torque; } set @@ -2425,10 +2425,10 @@ namespace OpenSim.Region.Physics.OdePlugin { if (!childPrim) { - m_force = Vector3.Zero; +// m_force = Vector3.Zero; m_forceacc = Vector3.Zero; m_angularForceacc = Vector3.Zero; - _torque = Vector3.Zero; +// m_torque = Vector3.Zero; _velocity = Vector3.Zero; _acceleration = Vector3.Zero; m_rotationalVelocity = Vector3.Zero; @@ -2968,7 +2968,7 @@ namespace OpenSim.Region.Physics.OdePlugin d.BodyEnable(Body); } - _torque = newtorque; + m_torque = newtorque; } } @@ -3364,7 +3364,7 @@ namespace OpenSim.Region.Physics.OdePlugin Vector3 trq; - trq = _torque; + trq = m_torque; trq += m_angularForceacc; m_angularForceacc = Vector3.Zero; if (trq.X != 0 || trq.Y != 0 || trq.Z != 0) From fc1be7e41fc7dd23c5396665f7b464de45590368 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 4 Dec 2012 01:54:37 +0000 Subject: [PATCH 03/33] raise standing avatar a bit to reduce knees bending on some collisions. reduce head size a bit --- OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs index 3d5be3e590..f33fdb4887 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs @@ -96,7 +96,7 @@ namespace OpenSim.Region.Physics.OdePlugin private float feetSZ = 0.5f; const float feetScale = 0.9f; const float invFeetScale = 1.0f / 0.9f; - const float sizeZAdjust = 0.15f; + const float sizeZAdjust = 0.18f; private float boneOff = 0; @@ -676,12 +676,12 @@ namespace OpenSim.Region.Physics.OdePlugin m_invElipSizeX = 1.0f / m_size.X; m_invElipSizeY = 1.0f / m_size.Y; - float topsx = m_size.X; + float topsx = m_size.X * 0.9f; float midsx = m_size.X; float feetsx = m_size.X * feetScale; float bonesx = feetsx * 0.2f; - float topsy = m_size.Y * 0.5f; + float topsy = m_size.Y * 0.4f; float midsy = m_size.Y; float feetsy = m_size.Y * feetScale; float bonesy = feetsy * 0.2f; @@ -1057,7 +1057,7 @@ namespace OpenSim.Region.Physics.OdePlugin // colide with land d.AABB aabb; d.GeomGetAABB(feetbox, out aabb); - float chrminZ = aabb.MinZ - 0.04f; // move up a bit + float chrminZ = aabb.MinZ - 0.02f; // move up a bit Vector3 posch = localpos; float ftmp; From b6d29aa124cf1ec1c1dbe6874720e6cc39faf06f Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 4 Dec 2012 02:46:40 +0000 Subject: [PATCH 04/33] move characters (avatars) to own collision space, also fixing a problem with previus code that was still assuming the avatar is g2 --- .../Physics/UbitOdePlugin/ODECharacter.cs | 18 ++++----- .../UbitOdePlugin/ODERayCastRequestManager.cs | 3 ++ .../Region/Physics/UbitOdePlugin/OdeScene.cs | 40 ++++++++++++++++--- 3 files changed, 47 insertions(+), 14 deletions(-) diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs index f33fdb4887..925900f0b5 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs @@ -708,21 +708,21 @@ namespace OpenSim.Region.Physics.OdePlugin bot += midsz; float topz = bot + topsz * 0.5f; - _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace); + _parent_scene.waitForSpaceUnlock(_parent_scene.CharsSpace); - feetbox = d.CreateBox(_parent_scene.ActiveSpace, feetsx, feetsy, feetsz); + feetbox = d.CreateBox(_parent_scene.CharsSpace, feetsx, feetsy, feetsz); d.GeomSetCategoryBits(feetbox, (uint)m_collisionCategories); d.GeomSetCollideBits(feetbox, (uint)m_collisionFlags); - midbox = d.CreateBox(_parent_scene.ActiveSpace, midsx, midsy, midsz); + midbox = d.CreateBox(_parent_scene.CharsSpace, midsx, midsy, midsz); d.GeomSetCategoryBits(midbox, (uint)m_collisionCategories); d.GeomSetCollideBits(midbox, (uint)m_collisionFlags); - topbox = d.CreateBox(_parent_scene.ActiveSpace, topsx, topsy, topsz); + topbox = d.CreateBox(_parent_scene.CharsSpace, topsx, topsy, topsz); d.GeomSetCategoryBits(topbox, (uint)m_collisionCategories); d.GeomSetCollideBits(topbox, (uint)m_collisionFlags); - bonebox = d.CreateBox(_parent_scene.ActiveSpace, bonesx, bonesy, bonesz); + bonebox = d.CreateBox(_parent_scene.CharsSpace, bonesx, bonesy, bonesz); d.GeomSetCategoryBits(bonebox, (uint)m_collisionCategories); d.GeomSetCollideBits(bonebox, (uint)m_collisionFlags); @@ -828,21 +828,21 @@ namespace OpenSim.Region.Physics.OdePlugin if (topbox != IntPtr.Zero) { _parent_scene.actor_name_map.Remove(topbox); - _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace); + _parent_scene.waitForSpaceUnlock(_parent_scene.CharsSpace); d.GeomDestroy(topbox); topbox = IntPtr.Zero; } if (midbox != IntPtr.Zero) { _parent_scene.actor_name_map.Remove(midbox); - _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace); + _parent_scene.waitForSpaceUnlock(_parent_scene.CharsSpace); d.GeomDestroy(midbox); midbox = IntPtr.Zero; } if (feetbox != IntPtr.Zero) { _parent_scene.actor_name_map.Remove(feetbox); - _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace); + _parent_scene.waitForSpaceUnlock(_parent_scene.CharsSpace); d.GeomDestroy(feetbox); feetbox = IntPtr.Zero; } @@ -850,7 +850,7 @@ namespace OpenSim.Region.Physics.OdePlugin if (bonebox != IntPtr.Zero) { _parent_scene.actor_name_map.Remove(bonebox); - _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace); + _parent_scene.waitForSpaceUnlock(_parent_scene.CharsSpace); d.GeomDestroy(bonebox); bonebox = IntPtr.Zero; } diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs index 799a324f4b..f449099233 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs @@ -324,7 +324,10 @@ namespace OpenSim.Region.Physics.OdePlugin { // Collide tests if ((CurrentRayFilter & FilterActiveSpace) != 0) + { d.SpaceCollide2(ray, m_scene.ActiveSpace, IntPtr.Zero, nearCallback); + d.SpaceCollide2(ray, m_scene.CharsSpace, IntPtr.Zero, nearCallback); + } if ((CurrentRayFilter & FilterStaticSpace) != 0 && (m_contactResults.Count < CurrentMaxCount)) d.SpaceCollide2(ray, m_scene.StaticSpace, IntPtr.Zero, nearCallback); if ((CurrentRayFilter & RayFilterFlags.land) != 0 && (m_contactResults.Count < CurrentMaxCount)) diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs index 003a91c942..07987d1f54 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs @@ -299,6 +299,7 @@ namespace OpenSim.Region.Physics.OdePlugin public IntPtr TopSpace; // the global space public IntPtr ActiveSpace; // space for active prims + public IntPtr CharsSpace; // space for active prims public IntPtr StaticSpace; // space for the static things around public IntPtr GroundSpace; // space for ground @@ -372,21 +373,25 @@ namespace OpenSim.Region.Physics.OdePlugin // now the major subspaces ActiveSpace = d.HashSpaceCreate(TopSpace); + CharsSpace = d.HashSpaceCreate(TopSpace); StaticSpace = d.HashSpaceCreate(TopSpace); GroundSpace = d.HashSpaceCreate(TopSpace); } catch { // i must RtC#FM + // i did! } d.HashSpaceSetLevels(TopSpace, -2, 8); d.HashSpaceSetLevels(ActiveSpace, -2, 8); + d.HashSpaceSetLevels(CharsSpace, -4, 3); d.HashSpaceSetLevels(StaticSpace, -2, 8); d.HashSpaceSetLevels(GroundSpace, 0, 8); // demote to second level d.SpaceSetSublevel(ActiveSpace, 1); + d.SpaceSetSublevel(CharsSpace, 1); d.SpaceSetSublevel(StaticSpace, 1); d.SpaceSetSublevel(GroundSpace, 1); @@ -396,11 +401,24 @@ namespace OpenSim.Region.Physics.OdePlugin CollisionCategories.Phantom | CollisionCategories.VolumeDtc )); - d.GeomSetCollideBits(ActiveSpace, 0); + d.GeomSetCollideBits(ActiveSpace, (uint)(CollisionCategories.Space | + CollisionCategories.Geom | + CollisionCategories.Character | + CollisionCategories.Phantom | + CollisionCategories.VolumeDtc + )); + d.GeomSetCategoryBits(CharsSpace, (uint)(CollisionCategories.Space | + CollisionCategories.Geom | + CollisionCategories.Character | + CollisionCategories.Phantom | + CollisionCategories.VolumeDtc + )); + d.GeomSetCollideBits(CharsSpace, 0); + d.GeomSetCategoryBits(StaticSpace, (uint)(CollisionCategories.Space | CollisionCategories.Geom | - CollisionCategories.Land | - CollisionCategories.Water | +// CollisionCategories.Land | +// CollisionCategories.Water | CollisionCategories.Phantom | CollisionCategories.VolumeDtc )); @@ -1271,6 +1289,9 @@ namespace OpenSim.Region.Physics.OdePlugin d.SpaceCollide2(StaticSpace, chr.midbox, IntPtr.Zero, nearCallback); d.SpaceCollide2(StaticSpace, chr.feetbox, IntPtr.Zero, nearCallback); d.SpaceCollide2(StaticSpace, chr.bonebox, IntPtr.Zero, nearCallback); + + // chars with chars + d.SpaceCollide(CharsSpace, IntPtr.Zero, nearCallback); // no coll with gnd } } @@ -1312,16 +1333,25 @@ namespace OpenSim.Region.Physics.OdePlugin m_log.Warn("[PHYSICS]: Unable to collide Active prim to static space"); } } - // finally colide active things amoung them + // colide active amoung them try { d.SpaceCollide(ActiveSpace, IntPtr.Zero, nearCallback); } catch (AccessViolationException) + { + m_log.Warn("[PHYSICS]: Unable to collide Active with Characters space"); + } + // and with chars + try + { + d.SpaceCollide2(ActiveSpace, CharsSpace,IntPtr.Zero, nearCallback); + } + catch (AccessViolationException) { m_log.Warn("[PHYSICS]: Unable to collide in Active space"); } -// _perloopContact.Clear(); + // _perloopContact.Clear(); } #endregion From de3180a63ecb89971321b7dce60dd86703f87e6d Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 5 Dec 2012 23:19:18 +0000 Subject: [PATCH 05/33] avatar collision plane send to viewer is only relative to feet. change avatar collider, just rounding the boxes, etc --- .../Region/Framework/Scenes/ScenePresence.cs | 15 +- .../Region/Physics/Manager/PhysicsActor.cs | 2 + .../Physics/UbitOdePlugin/ODECharacter.cs | 155 +++++++----------- .../Region/Physics/UbitOdePlugin/OdeScene.cs | 18 +- 4 files changed, 85 insertions(+), 105 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index bacc9c90a3..f5d609df7f 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3465,6 +3465,7 @@ namespace OpenSim.Region.Framework.Scenes ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true); } + /// /// Event called by the physics plugin to tell the avatar about a collision. /// @@ -3494,7 +3495,6 @@ namespace OpenSim.Region.Framework.Scenes CollisionEventUpdate collisionData = (CollisionEventUpdate)e; Dictionary coldata = collisionData.m_objCollisionList; - CollisionPlane = Vector4.UnitW; // // No collisions at all means we may be flying. Update always // // to make falling work @@ -3504,6 +3504,8 @@ namespace OpenSim.Region.Framework.Scenes // m_lastColCount = coldata.Count; // } + CollisionPlane = Vector4.UnitW; + if (coldata.Count != 0) { switch (Animator.CurrentMovementAnimation) @@ -3517,17 +3519,22 @@ namespace OpenSim.Region.Framework.Scenes ContactPoint lowest; lowest.SurfaceNormal = Vector3.Zero; lowest.Position = Vector3.Zero; - lowest.Position.Z = Single.NaN; + lowest.Position.Z = float.MaxValue; foreach (ContactPoint contact in coldata.Values) { - if (Single.IsNaN(lowest.Position.Z) || contact.Position.Z < lowest.Position.Z) + + if (contact.CharacterFeet && contact.Position.Z < lowest.Position.Z) { lowest = contact; } } - CollisionPlane = new Vector4(-lowest.SurfaceNormal, -Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); + if (lowest.Position.Z != float.MaxValue) + { + lowest.SurfaceNormal = -lowest.SurfaceNormal; + CollisionPlane = new Vector4(lowest.SurfaceNormal, Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); + } } break; } diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index 5af6373f0e..e1168bdd81 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -61,6 +61,7 @@ namespace OpenSim.Region.Physics.Manager public Vector3 SurfaceNormal; public float PenetrationDepth; public float RelativeSpeed; + public bool CharacterFeet; public ContactPoint(Vector3 position, Vector3 surfaceNormal, float penetrationDepth) { @@ -68,6 +69,7 @@ namespace OpenSim.Region.Physics.Manager SurfaceNormal = surfaceNormal; PenetrationDepth = penetrationDepth; RelativeSpeed = 0f; // for now let this one be set explicity + CharacterFeet = true; // keep other plugins work as before } } diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs index 925900f0b5..fd6b8aae4d 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs @@ -84,18 +84,15 @@ namespace OpenSim.Region.Physics.OdePlugin private float m_mass = 80f; public float m_density = 60f; private bool m_pidControllerActive = true; - public float PID_D = 800.0f; - public float PID_P = 900.0f; - //private static float POSTURE_SERVO = 10000.0f; - - private float m_invElipSizeX; - private float m_invElipSizeY; + const float basePID_D = 0.55f; // scaled for unit mass unit time (2200 /(50*80)) + const float basePID_P = 0.225f; // scaled for unit mass unit time (900 /(50*80)) + public float PID_D; + public float PID_P; private float feetOff = 0; private float feetSZ = 0.5f; - const float feetScale = 0.9f; - const float invFeetScale = 1.0f / 0.9f; + const float feetScale = 0.8f; const float sizeZAdjust = 0.18f; private float boneOff = 0; @@ -160,7 +157,7 @@ namespace OpenSim.Region.Physics.OdePlugin - public OdeCharacter(String avName, OdeScene parent_scene, Vector3 pos, Vector3 pSize, float pid_d, float pid_p, float density, float walk_divisor, float rundivisor) + public OdeCharacter(String avName, OdeScene parent_scene, Vector3 pos, Vector3 pSize, float density, float walk_divisor, float rundivisor) { m_uuid = UUID.Random(); @@ -184,8 +181,6 @@ namespace OpenSim.Region.Physics.OdePlugin _parent_scene = parent_scene; - PID_D = pid_d; - PID_P = pid_p; m_size.X = pSize.X; m_size.Y = pSize.Y; @@ -204,6 +199,8 @@ namespace OpenSim.Region.Physics.OdePlugin // force lower density for testing m_density = 3.0f; + m_density *= 1.4f; // scale to have mass similar to capsule + mu = parent_scene.AvatarFriction; walkDivisor = walk_divisor; @@ -211,6 +208,9 @@ namespace OpenSim.Region.Physics.OdePlugin m_mass = m_density * m_size.X * m_size.Y * m_size.Z; ; // sure we have a default + PID_D = basePID_D * m_mass / parent_scene.ODE_STEPSIZE; + PID_P = basePID_P * m_mass / parent_scene.ODE_STEPSIZE; + m_isPhysical = false; // current status: no ODE information exists Name = avName; @@ -491,7 +491,7 @@ namespace OpenSim.Region.Physics.OdePlugin { get { - return m_density * m_size.X * m_size.Y * m_size.Z; + return m_mass; } } public override void link(PhysicsActor obj) @@ -671,23 +671,22 @@ namespace OpenSim.Region.Physics.OdePlugin private void AvatarGeomAndBodyCreation(float npositionX, float npositionY, float npositionZ) { // sizes one day should came from visual parameters + float sx = m_size.X; + float sy = m_size.Y; float sz = m_size.Z + sizeZAdjust; - m_invElipSizeX = 1.0f / m_size.X; - m_invElipSizeY = 1.0f / m_size.Y; + float topsx = sx * 0.9f; + float midsx = sx; + float feetsx = sx * feetScale; + float bonesx = sx * 0.2f; - float topsx = m_size.X * 0.9f; - float midsx = m_size.X; - float feetsx = m_size.X * feetScale; - float bonesx = feetsx * 0.2f; - - float topsy = m_size.Y * 0.4f; - float midsy = m_size.Y; - float feetsy = m_size.Y * feetScale; + float topsy = sy * 0.4f; + float midsy = sy; + float feetsy = sy * feetScale * 0.8f; float bonesy = feetsy * 0.2f; float topsz = sz * 0.15f; - float feetsz = sz * 0.3f; + float feetsz = sz * 0.45f; if (feetsz > 0.6f) feetsz = 0.6f; @@ -726,22 +725,12 @@ namespace OpenSim.Region.Physics.OdePlugin d.GeomSetCategoryBits(bonebox, (uint)m_collisionCategories); d.GeomSetCollideBits(bonebox, (uint)m_collisionFlags); - d.MassSetBox(out ShellMass, m_density, m_size.X , m_size.Y, m_size.Z); + m_mass = m_density * m_size.X * m_size.Y * m_size.Z; // update mass - m_mass = ShellMass.mass; // update mass + d.MassSetBoxTotal(out ShellMass, m_mass, m_size.X, m_size.Y, m_size.Z); - // rescale PID parameters - PID_D = _parent_scene.avPIDD; - PID_P = _parent_scene.avPIDP; - - // rescale PID parameters so that this aren't affected by mass - // and so don't get unstable for some masses - // also scale by ode time step so you don't need to refix them - - PID_D /= 50 * 80; //scale to original mass of around 80 and 50 ODE fps - PID_D *= m_mass / _parent_scene.ODE_STEPSIZE; - PID_P /= 50 * 80; - PID_P *= m_mass / _parent_scene.ODE_STEPSIZE; + PID_D = basePID_D * m_mass / _parent_scene.ODE_STEPSIZE; + PID_P = basePID_P * m_mass / _parent_scene.ODE_STEPSIZE; Body = d.BodyCreate(_parent_scene.world); @@ -857,8 +846,9 @@ namespace OpenSim.Region.Physics.OdePlugin } - public bool Collide(IntPtr me, bool reverse, ref d.ContactGeom contact) + public bool Collide(IntPtr me, bool reverse, ref d.ContactGeom contact, ref bool feetcollision) { + feetcollision = false; if (me == bonebox) // inner bone { @@ -870,44 +860,13 @@ namespace OpenSim.Region.Physics.OdePlugin if (me == topbox) // keep a box head return true; - // rotate elipsoide assuming only rotation around Z - float ca = m_orientation.W * m_orientation.W - m_orientation.Z * m_orientation.Z; - float sa = 2 * m_orientation.W * m_orientation.Z; - - float isx; - float isy; - - if (me == feetbox) // feet have narrow bounds - { - - isx = m_invElipSizeX * invFeetScale; - isy = m_invElipSizeY * invFeetScale; - } - else - { - isx = m_invElipSizeX; - isy = m_invElipSizeY; - } - - float a = isx * ca - isy * sa; - float b = isx * sa + isy * ca; - + float t; float offx = contact.pos.X - _position.X; - float er = offx * a; - er *= er; - float offy = contact.pos.Y - _position.Y; - float ty = offy * b; - er += ty * ty; if (me == midbox) { - if (er > 4.0f) // no collision - return false; - if (er < 0.2f) - return true; - - float t = offx * offx + offy * offy; + t = offx * offx + offy * offy; t = (float)Math.Sqrt(t); t = 1 / t; offx *= t; @@ -930,40 +889,51 @@ namespace OpenSim.Region.Physics.OdePlugin else if (me == feetbox) { - float c = feetSZ * 2; float h = contact.pos.Z - _position.Z; + + if (Math.Abs(contact.normal.Z) > 0.95f) + { + feetcollision = true; + if (h < boneOff) + IsColliding = true; + return true; + } + float offz = h - feetOff; // distance from top of feetbox - float tz = offz / c; - er += tz * tz; - - if (er > 4.0f) // no collision + if (offz > 0) return false; - if (er > 0.2f) + if (offz > -0.01) { - float t = offx * offx + offy * offy + offz * offz; + offx = 0; + offy = 0; + offz = -1.0f; + } + else + { + t = offx * offx + offy * offy + offz * offz; t = (float)Math.Sqrt(t); t = 1 / t; offx *= t; offy *= t; offz *= t; - - if (reverse) - { - contact.normal.X = offx; - contact.normal.Y = offy; - contact.normal.Z = offz; - } - else - { - contact.normal.X = -offx; - contact.normal.Y = -offy; - contact.normal.Z = -offz; - } } - if(h < boneOff) + if (reverse) + { + contact.normal.X = offx; + contact.normal.Y = offy; + contact.normal.Z = offz; + } + else + { + contact.normal.X = -offx; + contact.normal.Y = -offy; + contact.normal.Z = -offz; + } + feetcollision = true; + if (h < boneOff) IsColliding = true; } else @@ -1105,6 +1075,7 @@ namespace OpenSim.Region.Physics.OdePlugin contact.SurfaceNormal.Y = 0f; contact.SurfaceNormal.Z = -1f; contact.RelativeSpeed = -vel.Z; + contact.CharacterFeet = true; AddCollisionEvent(0, contact); vec.Z *= 0.5f; diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs index 07987d1f54..2b4d368f61 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs @@ -224,9 +224,6 @@ namespace OpenSim.Region.Physics.OdePlugin // private IntPtr WaterHeightmapData = IntPtr.Zero; // private GCHandle WaterMapHandler = new GCHandle(); - public float avPIDD = 2200f; // make it visible - public float avPIDP = 900f; // make it visible - private float avCapRadius = 0.37f; private float avDensity = 3f; private float avMovementDivisorWalk = 1.3f; private float avMovementDivisorRun = 0.8f; @@ -486,7 +483,6 @@ namespace OpenSim.Region.Physics.OdePlugin avDensity = physicsconfig.GetFloat("av_density", avDensity); avMovementDivisorWalk = physicsconfig.GetFloat("av_movement_divisor_walk", avMovementDivisorWalk); avMovementDivisorRun = physicsconfig.GetFloat("av_movement_divisor_run", avMovementDivisorRun); - avCapRadius = physicsconfig.GetFloat("av_capsule_radius", avCapRadius); contactsPerCollision = physicsconfig.GetInt("contacts_per_collision", contactsPerCollision); @@ -1040,6 +1036,8 @@ namespace OpenSim.Region.Physics.OdePlugin IntPtr Joint; + bool FeetCollision = false; + int i = 0; int ncontacts = 0; while(true) @@ -1058,7 +1056,7 @@ namespace OpenSim.Region.Physics.OdePlugin { if(dop1foot) { - if (!(((OdeCharacter)p1).Collide(g1,false, ref curContact))) + if (!(((OdeCharacter)p1).Collide(g1, false, ref curContact, ref FeetCollision))) { if (++i >= count) break; @@ -1068,7 +1066,7 @@ namespace OpenSim.Region.Physics.OdePlugin } else if(dop2foot) { - if(!(((OdeCharacter) p2).Collide(g2,true,ref curContact))) + if (!(((OdeCharacter)p2).Collide(g2, true, ref curContact, ref FeetCollision))) { if (++i >= count) break; @@ -1177,9 +1175,11 @@ namespace OpenSim.Region.Physics.OdePlugin } } - if(ncontacts > 0) + if (ncontacts > 0) + { + maxDepthContact.CharacterFeet = FeetCollision; collision_accounting_events(p1, p2, maxDepthContact); - + } /* if (notskipedcount > geomContactPointsStartthrottle) { @@ -1393,7 +1393,7 @@ namespace OpenSim.Region.Physics.OdePlugin pos.X = position.X; pos.Y = position.Y; pos.Z = position.Z; - OdeCharacter newAv = new OdeCharacter(avName, this, pos, size, avPIDD, avPIDP, avDensity, avMovementDivisorWalk, avMovementDivisorRun); + OdeCharacter newAv = new OdeCharacter(avName, this, pos, size, avDensity, avMovementDivisorWalk, avMovementDivisorRun); newAv.Flying = isFlying; newAv.MinimumGroundFlightOffset = minimumGroundFlightOffset; From 135e0ea853203cbad5790ac9f0b21d67f8828af8 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 7 Dec 2012 13:47:58 +0000 Subject: [PATCH 06/33] *TEST* add some avatar skeleton information and use it to calculate avatar height and bounding box. Change LSL acording. --- OpenSim/Framework/AvatarAppearance.cs | 30 ++ OpenSim/Framework/AvatarSkeleton.cs | 281 ++++++++++++++++++ .../Shared/Api/Implementation/LSL_Api.cs | 29 +- 3 files changed, 336 insertions(+), 4 deletions(-) create mode 100644 OpenSim/Framework/AvatarSkeleton.cs diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index 16385417e6..ad783c8d86 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs @@ -55,6 +55,13 @@ namespace OpenSim.Framework protected AvatarWearable[] m_wearables; protected Dictionary> m_attachments; protected float m_avatarHeight = 0; + protected Vector3 m_avatarSize = new Vector3(0.45f, 0.6f, 1.9f); + protected Vector3 m_avatarBoxSize = new Vector3(0.45f, 0.6f, 1.9f); + protected float m_avatarFeetOffset = 0; + protected float m_avatarAnimOffset = 0; + + + private AvatarSkeleton skeleton = new AvatarSkeleton(); public virtual int Serial { @@ -68,6 +75,21 @@ namespace OpenSim.Framework set { m_visualparams = value; } } + public virtual Vector3 AvatarSize + { + get { return m_avatarSize; } + } + + public virtual Vector3 AvatarBoxSize + { + get { return m_avatarBoxSize; } + } + + public virtual float AvatarFeetOffset + { + get { return m_avatarFeetOffset + m_avatarAnimOffset; } + } + public virtual Primitive.TextureEntry Texture { get { return m_texture; } @@ -363,6 +385,7 @@ namespace OpenSim.Framework /// public virtual void SetHeight() { +/* // Start with shortest possible female avatar height m_avatarHeight = 1.14597f; // Add offset for male avatars @@ -375,6 +398,13 @@ namespace OpenSim.Framework + 0.07f * (float)m_visualparams[(int)VPElement.SHOES_PLATFORM_HEIGHT] / 255.0f + 0.08f * (float)m_visualparams[(int)VPElement.SHOES_HEEL_HEIGHT] / 255.0f + 0.076f * (float)m_visualparams[(int)VPElement.SHAPE_NECK_LENGTH] / 255.0f; +*/ + + skeleton.ApplyVisualParameters(m_visualparams); + m_avatarSize = skeleton.StandSize; + m_avatarBoxSize = skeleton.StandBoxSize; + m_avatarFeetOffset = skeleton.FeetOffset; + m_avatarHeight = m_avatarSize.Z; } public virtual void SetWearable(int wearableId, AvatarWearable wearable) diff --git a/OpenSim/Framework/AvatarSkeleton.cs b/OpenSim/Framework/AvatarSkeleton.cs new file mode 100644 index 0000000000..269099b216 --- /dev/null +++ b/OpenSim/Framework/AvatarSkeleton.cs @@ -0,0 +1,281 @@ +/* + * 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. + */ +// Ubit 2012 +using System; +using System.Collections; +using System.Collections.Generic; +using OpenMetaverse; +using OpenMetaverse.StructuredData; +using log4net; +using VPElement = OpenSim.Framework.AvatarAppearance.VPElement; + + + +namespace OpenSim.Framework +{ + /// + /// Contains the Avatar's Skeleton + /// + public class AvatarSkeleton + { + const int NBONES = 26; + const float BOXAJUST = 0.2f; + + public enum Bones : int + { + EyeLeft, + Eyeright, + Skull, + Head, + Neck, + CollarRight, + CollarLeft, + Shoulderright, + ShoulderLeft, + ElbowRight, + ElbowLeft, + WristRight, + WristLeft, + Chest, + Torso, + Pelvis, + Hipright, + HipLeft, + KneeRight, + KneeLeft, + AnkleRight, + AnkleLeft, + FootRight, + FootLeft, + ToeRight, + ToeLeft + } + + public struct bone + { + public Vector3 Offset; + public Vector3 Scale; + public bone(float x, float y, float z) + { + Offset = new Vector3(x, y, z); + Scale = new Vector3(1f, 1f, 1f); + } + + public void addScale(float x, float y, float z, float factor) + { + Scale.X += x * factor; + Scale.Y += y * factor; + Scale.Y += z * factor; + } + + public void addOffset(float x, float y, float z, float factor) + { + Offset.X += x * factor; + Offset.Y += y * factor; + Offset.Y += z * factor; + } + } + + private bone[] DefaultBones = new bone[] + { + new bone(0.098f, 0.036f, 0.079f), // EyeLeft + new bone(0.098f, -0.036f, 0.079f), // Eyeright + new bone(0.0f, 0.0f, 0.079f), // Skull + new bone(0.0f, 0.0f, 0.076f), // Head + new bone(-0.1f, 0.0f, 0.251f), // Neck + new bone(-0.021f, -0.085f, 0.165f), // CollarRight + new bone(-0.021f, 0.085f, 0.165f), // CollarLeft + new bone(0.0f, -0.79f, 0.0f), // Shoulderright + new bone(0.0f, 0.79f, 0.0f), // ShoulderLeft + new bone(0.0f, -0.248f, 0.0f), // ElbowRight + new bone(0.0f, 0.248f, 0.0f), // ElbowLeft + new bone(0.0f, -0.205f, 0.0f), // WristRight + new bone(0.0f, 0.205f, 0.0f), // WristLeft + new bone(-0.015f, 0.000f, 0.205f), // Chest + new bone(0.0f, 0.0f, 0.084f), // Torso + new bone(0.0f, 0.0f, 1.067f), // Pelvis + new bone(0.034f, -0.129f, -0.041f), // Hipright + new bone(0.034f, 0.127f, -0.041f), // HipLeft + new bone(-0.001f, 0.049f, -0.491f), // KneeRight + new bone(-0.001f, -0.046f, -0.491f), // KneeLeft + new bone(-0.029f, 0.0f, -0.468f), // AnkleRight + new bone(-0.029f, 0.001f, -0.468f), // AnkleLeft + new bone(0.112f, 0.0f, -0.061f), // FootRight + new bone(0.112f, 0.0f, -0.061f), // FootLeft + new bone(0.109f, 0.0f, 0.0f), // ToeRight + new bone(0.109f, 0.0f, 0.0f) // ToeLeft + }; + + private bone[] m_bones = null; + private byte[] m_visualParams = null; + + const float bytescale = 1.0f / 255.0f; + + private float convertVP(AvatarAppearance.VPElement vp) + { + return (float)m_visualParams[(int)vp] * bytescale; + } + + private Vector3 m_standSize; + private float m_feetOffset = 0f; + + public Vector3 StandSize + { + get + { + if (m_bones == null || m_visualParams == null) + return new Vector3(0.45f, 0.6f, 1.9f); + else + return m_standSize; + } + } + + public Vector3 StandBoxSize + { + get + { + if (m_bones == null || m_visualParams == null) + return new Vector3(0.45f, 0.6f, 1.9f + BOXAJUST); + else + { + Vector3 r = m_standSize; + r.Z += BOXAJUST; + return r; + } + } + } + + public float FeetOffset + { + get + { + if (m_bones == null || m_visualParams == null) + return 0.0f; + else + { + return m_feetOffset; + } + } + } + + /// + /// Set avatar height by a calculation based on their visual parameters. + /// + + public void ApplyVisualParameters(byte[] vPs) + { + m_visualParams = vPs; + + if (m_bones == null) + { + m_bones = new bone[NBONES]; + for (int i = 0; i < NBONES; i++) + m_bones[i] = DefaultBones[i]; + } + + float bone_skull = m_bones[(int)Bones.Skull].Offset.Z; + float bone_head = m_bones[(int)Bones.Head].Offset.Z; + float bone_neck = m_bones[(int)Bones.Neck].Offset.Z; + float bone_chest = m_bones[(int)Bones.Chest].Offset.Z; + float bone_torso = m_bones[(int)Bones.Torso].Offset.Z; + float bone_hip = m_bones[(int)Bones.Hipright].Offset.Z; + float bone_knee = m_bones[(int)Bones.KneeRight].Offset.Z; + float bone_ank = m_bones[(int)Bones.AnkleRight].Offset.Z; + float bone_foot = m_bones[(int)Bones.FootRight].Offset.Z; + + float sbone_skull = m_bones[(int)Bones.Skull].Scale.Z; + float sbone_head = m_bones[(int)Bones.Head].Scale.Z; + float sbone_neck = m_bones[(int)Bones.Neck].Scale.Z; + float sbone_chest = m_bones[(int)Bones.Chest].Scale.Z; + float sbone_torso = m_bones[(int)Bones.Torso].Scale.Z; + float sbone_pelvis = m_bones[(int)Bones.Pelvis].Scale.Z; + float sbone_hip = m_bones[(int)Bones.Hipright].Scale.Z; + float sbone_knee = m_bones[(int)Bones.KneeRight].Scale.Z; + float sbone_ank = m_bones[(int)Bones.AnkleRight].Scale.Z; + float sbone_foot = m_bones[(int)Bones.FootRight].Scale.Z; + + float v_male = (m_visualParams[(int)VPElement.SHAPE_MALE] == 0) ? 0.0f : 1.0f; + sbone_neck += v_male * 0.2f; + sbone_chest += v_male * 0.05f; + sbone_torso += v_male * 0.05f; + sbone_knee += v_male * 0.1f; + + float v_height = convertVP(VPElement.SHAPE_HEIGHT) * 4.3f - 2.3f; + sbone_neck += v_height * 0.02f; + sbone_chest += v_height * 0.05f; + sbone_torso += v_height * 0.05f; + sbone_hip += v_height * 0.1f; + sbone_knee += v_height * 0.1f; + + float v_hip_len = convertVP(VPElement.SHAPE_HIP_LENGTH) * 2f - 1f; + sbone_pelvis += v_hip_len * 0.3f; + + float v_torso_len = convertVP(VPElement.SHAPE_TORSO_LENGTH) * 2f - 1f; + sbone_torso += v_torso_len * 0.3f; + sbone_pelvis += v_torso_len * 0.1f; + sbone_hip += v_torso_len * -0.1f; + sbone_knee += v_torso_len * -0.05f; + + float v_head_size = convertVP(VPElement.SHAPE_HEAD_SIZE) * 0.35f - 0.25f; + bone_skull += v_head_size * 0.1f; + sbone_skull += v_head_size; + sbone_head += v_head_size; + + float v_shoes_heel = convertVP(VPElement.SHOES_HEEL_HEIGHT); + bone_foot += v_shoes_heel * -0.08f; + + float v_shoes_plat = convertVP(VPElement.SHOES_PLATFORM_HEIGHT); + bone_foot += v_shoes_plat * -0.07f; + + float v_leg_lenght = convertVP(VPElement.SHAPE_LEG_LENGTH) * 2f - 1f; + sbone_hip += v_leg_lenght * 0.2f; + sbone_knee += v_leg_lenght * 0.2f; + + float v_neck_len = convertVP(VPElement.SHAPE_NECK_LENGTH) * 2f - 1f; + sbone_neck += v_neck_len * 0.5f; + + float hipmess = bone_hip * sbone_pelvis; + + float pelvisToFoot = hipmess - + bone_knee * sbone_hip - + bone_ank * sbone_knee - + bone_foot * sbone_ank; + + + float size = 1.4142f * bone_skull * sbone_head + + bone_head * sbone_neck + + bone_neck * sbone_chest + + bone_chest * sbone_torso + + bone_torso * sbone_pelvis; + + size += pelvisToFoot; + + m_standSize = new Vector3(0.45f, 0.6f, size); + m_feetOffset = 0.5f * size - pelvisToFoot; + } + } +} diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 6b63d9401d..759339595b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3013,7 +3013,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } bool result = money.ObjectGiveMoney( - m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount, UUID.Zero); + m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount); if (result) return 1; @@ -6384,7 +6384,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } else { - agentSize = new LSL_Vector(0.45, 0.6, avatar.Appearance.AvatarHeight); +// agentSize = new LSL_Vector(0.45f, 0.6f, avatar.Appearance.AvatarHeight); + Vector3 s = avatar.Appearance.AvatarSize; + agentSize = new LSL_Vector(s.X, s.Y, s.Z); } return agentSize; } @@ -8591,8 +8593,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // and standing avatar since server 1.36 LSL_Vector lower; LSL_Vector upper; + + Vector3 box = presence.Appearance.AvatarBoxSize * 0.5f; + if (presence.Animator.Animations.ImplicitDefaultAnimation.AnimID == DefaultAvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) +/* { // This is for ground sitting avatars float height = presence.Appearance.AvatarHeight / 2.66666667f; @@ -8610,6 +8616,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Adjust to the documented error offsets (see LSL Wiki) lower += new LSL_Vector(0.05f, 0.05f, 0.05f); upper -= new LSL_Vector(0.05f, 0.05f, 0.05f); +*/ + { + // This is for ground sitting avatars TODO! + lower = new LSL_Vector(-box.X - 0.1125, -box.Y, box.Z * -1.0f); + upper = new LSL_Vector(box.X + 0.1125, box.Y, box.Z * -1.0f); + } + else + { + // This is for standing/flying avatars + lower = new LSL_Vector(-box.X, -box.Y, -box.Z); + upper = new LSL_Vector(box.X, box.Y, box.Z); + } if (lower.x > upper.x) lower.x = upper.x; @@ -12529,7 +12547,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } bool result = money.ObjectGiveMoney( - m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount, txn); + m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount); if (result) { @@ -12931,7 +12949,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api case (int)ScriptBaseClass.PRIM_SIZE: // as in llGetAgentSize above - res.Add(new LSL_Vector(0.45f, 0.6f, avatar.Appearance.AvatarHeight)); +// res.Add(new LSL_Vector(0.45f, 0.6f, avatar.Appearance.AvatarHeight)); + Vector3 s = avatar.Appearance.AvatarSize; + res.Add(new LSL_Vector(s.X, s.Y, s.Z)); + break; case (int)ScriptBaseClass.PRIM_ROTATION: From 1eddc4a9dad1cbe0a93b65331edd046ac1c9acf8 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 7 Dec 2012 14:01:22 +0000 Subject: [PATCH 07/33] fix regression --- .../Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 759339595b..7ff30ca844 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3013,7 +3013,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } bool result = money.ObjectGiveMoney( - m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount); + m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount,UUID.Zero); if (result) return 1; @@ -12547,7 +12547,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } bool result = money.ObjectGiveMoney( - m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount); + m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID, toID, amount,UUID.Zero); if (result) { From d2499c4c314b290c42f454913305d97c6eec92d6 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 7 Dec 2012 15:54:46 +0000 Subject: [PATCH 08/33] *TEST* Use new avatar size in ubitODE. --- OpenSim/Framework/AvatarSkeleton.cs | 3 +- .../AvatarFactory/AvatarFactoryModule.cs | 11 ++++- .../Region/Framework/Scenes/ScenePresence.cs | 6 +++ .../Region/Physics/Manager/PhysicsActor.cs | 5 ++ .../Physics/UbitOdePlugin/ODECharacter.cs | 48 +++++++++++++++++-- .../Region/Physics/UbitOdePlugin/OdeScene.cs | 1 + 6 files changed, 68 insertions(+), 6 deletions(-) diff --git a/OpenSim/Framework/AvatarSkeleton.cs b/OpenSim/Framework/AvatarSkeleton.cs index 269099b216..7a49f22e21 100644 --- a/OpenSim/Framework/AvatarSkeleton.cs +++ b/OpenSim/Framework/AvatarSkeleton.cs @@ -275,7 +275,8 @@ namespace OpenSim.Framework size += pelvisToFoot; m_standSize = new Vector3(0.45f, 0.6f, size); - m_feetOffset = 0.5f * size - pelvisToFoot; + // m_feetOffset = 0.5f * size - pelvisToFoot; + m_feetOffset = 0.0f; } } } diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 849600520c..d557a28647 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -174,12 +174,21 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory // m_log.DebugFormat( // "[AVFACTORY]: Setting visual params for {0} to {1}", // client.Name, string.Join(", ", visualParamsStrings)); - +/* float oldHeight = sp.Appearance.AvatarHeight; changed = sp.Appearance.SetVisualParams(visualParams); if (sp.Appearance.AvatarHeight != oldHeight && sp.Appearance.AvatarHeight > 0) ((ScenePresence)sp).SetHeight(sp.Appearance.AvatarHeight); + */ + float oldoff = sp.Appearance.AvatarFeetOffset; + Vector3 oldbox = sp.Appearance.AvatarBoxSize; + changed = sp.Appearance.SetVisualParams(visualParams); + float off = sp.Appearance.AvatarFeetOffset; + Vector3 box = sp.Appearance.AvatarBoxSize; + if(oldoff != off || oldbox != box) + ((ScenePresence)sp).SetSize(box,off); + } // Process the baked texture array diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index f5d609df7f..b6eae8efed 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1260,6 +1260,12 @@ namespace OpenSim.Region.Framework.Scenes PhysicsActor.Size = new Vector3(0.45f, 0.6f, height); } + public void SetSize(Vector3 size, float feetoffset) + { + if (PhysicsActor != null && !IsChildAgent) + PhysicsActor.setAvatarSize(size, feetoffset); + } + /// /// Complete Avatar's movement into the region. /// diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index e1168bdd81..0405dadd72 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -175,6 +175,11 @@ namespace OpenSim.Region.Physics.Manager public abstract Vector3 Size { get; set; } + public virtual void setAvatarSize(Vector3 size, float feetOffset) + { + Size = size; + } + public virtual bool Phantom { get; set; } public virtual bool IsVolumeDtc diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs index fd6b8aae4d..9c245e6e00 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs @@ -90,13 +90,12 @@ namespace OpenSim.Region.Physics.OdePlugin public float PID_D; public float PID_P; + private float m_feetOffset = 0; private float feetOff = 0; private float feetSZ = 0.5f; const float feetScale = 0.8f; - const float sizeZAdjust = 0.18f; private float boneOff = 0; - public float walkDivisor = 1.3f; public float runDivisor = 0.8f; private bool flying = false; @@ -475,6 +474,28 @@ namespace OpenSim.Region.Physics.OdePlugin } } + public override void setAvatarSize(Vector3 size, float feetOffset) + { + if (size.IsFinite()) + { + if (size.X < 0.01f) + size.X = 0.01f; + if (size.Y < 0.01f) + size.Y = 0.01f; + if (size.Z < 0.01f) + size.Z = 0.01f; + + strAvatarSize st = new strAvatarSize(); + st.size = size; + st.offset = feetOffset; + AddChange(changes.AvatarSize, st); + } + else + { + m_log.Warn("[PHYSICS]: Got a NaN AvatarSize from Scene on a Character"); + } + + } /// /// This creates the Avatar's physical Surrogate at the position supplied /// @@ -673,7 +694,8 @@ namespace OpenSim.Region.Physics.OdePlugin // sizes one day should came from visual parameters float sx = m_size.X; float sy = m_size.Y; - float sz = m_size.Z + sizeZAdjust; + float sz = m_size.Z; + float topsx = sx * 0.9f; float midsx = sx; @@ -693,7 +715,7 @@ namespace OpenSim.Region.Physics.OdePlugin float midsz = sz - topsz - feetsz; float bonesz = sz; - float bot = -sz * 0.5f; + float bot = -sz * 0.5f + m_feetOffset; boneOff = bot + 0.3f; @@ -754,6 +776,7 @@ namespace OpenSim.Region.Physics.OdePlugin d.GeomSetOffsetPosition(feetbox, 0, 0, feetz); d.GeomSetOffsetPosition(midbox, 0, 0, midz); d.GeomSetOffsetPosition(topbox, 0, 0, topz); + d.GeomSetOffsetPosition(bonebox, 0, 0, m_feetOffset); // The purpose of the AMotor here is to keep the avatar's physical // surrogate from rotating while moving @@ -1402,6 +1425,12 @@ namespace OpenSim.Region.Physics.OdePlugin { } + private void changeAvatarSize(strAvatarSize st) + { + m_feetOffset = st.offset; + changeSize(st.size); + } + private void changeSize(Vector3 pSize) { if (pSize.IsFinite()) @@ -1609,6 +1638,10 @@ namespace OpenSim.Region.Physics.OdePlugin changeSize((Vector3)arg); break; + case changes.AvatarSize: + changeAvatarSize((strAvatarSize)arg); + break; + case changes.Momentum: changeMomentum((Vector3)arg); break; @@ -1656,5 +1689,12 @@ namespace OpenSim.Region.Physics.OdePlugin { _parent_scene.AddChange((PhysicsActor)this, what, arg); } + + private struct strAvatarSize + { + public Vector3 size; + public float offset; + } + } } diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs index 2b4d368f61..7d1d2fe997 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs @@ -147,6 +147,7 @@ namespace OpenSim.Region.Physics.OdePlugin PIDHoverActive, Size, + AvatarSize, Shape, PhysRepData, AddPhysRep, From b2f3516b68d6333d70e8758e93d37197863f9a05 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 7 Dec 2012 17:28:07 +0000 Subject: [PATCH 09/33] calculate avatar size on tps --- OpenSim/Framework/AvatarAppearance.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index ad783c8d86..9e912def79 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs @@ -678,8 +678,8 @@ namespace OpenSim.Framework { if ((data != null) && (data["serial"] != null)) m_serial = data["serial"].AsInteger(); - if ((data != null) && (data["height"] != null)) - m_avatarHeight = (float)data["height"].AsReal(); +// if ((data != null) && (data["height"] != null)) +// m_avatarHeight = (float)data["height"].AsReal(); try { @@ -741,6 +741,7 @@ namespace OpenSim.Framework // att.ItemID, att.AssetID, att.AttachPoint); } } + SetHeight(); } catch (Exception e) { From 2ea0dc55d7ea6da6e91ab614856cdeece7eae5d2 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 7 Dec 2012 20:06:35 +0000 Subject: [PATCH 10/33] create a new ode character also with the new information --- .../Region/Framework/Scenes/ScenePresence.cs | 6 ++++++ OpenSim/Region/Physics/Manager/PhysicsScene.cs | 18 ++++++++++++++++-- .../Physics/UbitOdePlugin/ODECharacter.cs | 3 ++- .../Region/Physics/UbitOdePlugin/OdeScene.cs | 4 ++-- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index b6eae8efed..7602d6bf83 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3450,9 +3450,15 @@ namespace OpenSim.Region.Framework.Scenes Vector3 pVec = AbsolutePosition; +/* PhysicsActor = scene.AddAvatar( LocalId, Firstname + "." + Lastname, pVec, new Vector3(0.45f, 0.6f, Appearance.AvatarHeight), isFlying); +*/ + + PhysicsActor = scene.AddAvatar( + LocalId, Firstname + "." + Lastname, pVec, + Appearance.AvatarBoxSize,Appearance.AvatarFeetOffset, isFlying); //PhysicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; PhysicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs index ce269fabc1..c07213e0b8 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs @@ -127,8 +127,10 @@ namespace OpenSim.Region.Physics.Manager /// /// /// - public abstract PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying); - + public virtual PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying) + { + return null; + } /// /// Add an avatar /// @@ -145,6 +147,18 @@ namespace OpenSim.Region.Physics.Manager return ret; } + public virtual PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size,float feetOffset, bool isFlying) + { + return null; + } + + public virtual PhysicsActor AddAvatar(uint localID,string avName, Vector3 position, Vector3 size, float feetOffset, bool isFlying) + { + PhysicsActor ret = AddAvatar(avName, position, size,feetOffset, isFlying); + if (ret != null) ret.LocalID = localID; + return ret; + } + /// /// Remove an avatar. /// diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs index 9c245e6e00..15bdc5705f 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs @@ -156,7 +156,7 @@ namespace OpenSim.Region.Physics.OdePlugin - public OdeCharacter(String avName, OdeScene parent_scene, Vector3 pos, Vector3 pSize, float density, float walk_divisor, float rundivisor) + public OdeCharacter(String avName, OdeScene parent_scene, Vector3 pos, Vector3 pSize, float pfeetOffset, float density, float walk_divisor, float rundivisor) { m_uuid = UUID.Random(); @@ -192,6 +192,7 @@ namespace OpenSim.Region.Physics.OdePlugin if(m_size.Z <0.01f) m_size.Z = 0.01f; + m_feetOffset = pfeetOffset; m_orientation = Quaternion.Identity; m_density = density; diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs index 7d1d2fe997..2ba59407f2 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs @@ -1388,13 +1388,13 @@ namespace OpenSim.Region.Physics.OdePlugin #region Add/Remove Entities - public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, bool isFlying) + public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, float feetOffset, bool isFlying) { Vector3 pos; pos.X = position.X; pos.Y = position.Y; pos.Z = position.Z; - OdeCharacter newAv = new OdeCharacter(avName, this, pos, size, avDensity, avMovementDivisorWalk, avMovementDivisorRun); + OdeCharacter newAv = new OdeCharacter(avName, this, pos, size, feetOffset, avDensity, avMovementDivisorWalk, avMovementDivisorRun); newAv.Flying = isFlying; newAv.MinimumGroundFlightOffset = minimumGroundFlightOffset; From 93bede4e6aa0838e14f39f5e641b028267d2683c Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 7 Dec 2012 21:26:58 +0000 Subject: [PATCH 11/33] revert the use of avatar skeleton and use avatar size provided by viewers, since at least for now seems good enought --- OpenSim/Framework/AvatarAppearance.cs | 47 +-- OpenSim/Framework/AvatarSkeleton.cs | 282 ------------------ OpenSim/Framework/IClientAPI.cs | 2 +- .../ClientStack/Linden/UDP/LLClientView.cs | 3 +- .../AvatarFactory/AvatarFactoryModule.cs | 31 +- .../Region/Framework/Scenes/ScenePresence.cs | 4 +- .../Server/IRCClientView.cs | 2 +- OpenSim/Services/Interfaces/IAvatarService.cs | 4 +- 8 files changed, 62 insertions(+), 313 deletions(-) delete mode 100644 OpenSim/Framework/AvatarSkeleton.cs diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index 9e912def79..b01b8da5fb 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs @@ -40,6 +40,11 @@ namespace OpenSim.Framework /// public class AvatarAppearance { + const float AVBOXAJUST = 0.2f; + const float AVBOXMINX = 0.2f; + const float AVBOXMINY = 0.3f; + const float AVBOXMINZ = 0.5f; + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); // this is viewer capabilities and weared things dependent @@ -60,9 +65,6 @@ namespace OpenSim.Framework protected float m_avatarFeetOffset = 0; protected float m_avatarAnimOffset = 0; - - private AvatarSkeleton skeleton = new AvatarSkeleton(); - public virtual int Serial { get { return m_serial; } @@ -120,7 +122,8 @@ namespace OpenSim.Framework SetDefaultWearables(); SetDefaultTexture(); SetDefaultParams(); - SetHeight(); +// SetHeight(); + SetSize(new Vector3(0.45f,0.6f,1.9f)); m_attachments = new Dictionary>(); } @@ -129,7 +132,7 @@ namespace OpenSim.Framework // m_log.WarnFormat("[AVATAR APPEARANCE]: create appearance from OSDMap"); Unpack(map); - SetHeight(); +// SetHeight(); done in Unpack } public AvatarAppearance(AvatarWearable[] wearables, Primitive.TextureEntry textureEntry, byte[] visualParams) @@ -153,7 +156,7 @@ namespace OpenSim.Framework else SetDefaultParams(); - SetHeight(); +// SetHeight(); m_attachments = new Dictionary>(); } @@ -172,7 +175,8 @@ namespace OpenSim.Framework SetDefaultWearables(); SetDefaultTexture(); SetDefaultParams(); - SetHeight(); +// SetHeight(); + SetSize(new Vector3(0.45f, 0.6f, 1.9f)); m_attachments = new Dictionary>(); return; @@ -201,7 +205,8 @@ namespace OpenSim.Framework if (appearance.VisualParams != null) m_visualparams = (byte[])appearance.VisualParams.Clone(); - m_avatarHeight = appearance.m_avatarHeight; +// m_avatarHeight = appearance.m_avatarHeight; + SetSize(appearance.AvatarSize); // Copy the attachment, force append mode since that ensures consistency m_attachments = new Dictionary>(); @@ -368,8 +373,8 @@ namespace OpenSim.Framework } } // Reset the height if the visual parameters actually changed - if (changed) - SetHeight(); +// if (changed) +// SetHeight(); return changed; } @@ -399,11 +404,19 @@ namespace OpenSim.Framework + 0.08f * (float)m_visualparams[(int)VPElement.SHOES_HEEL_HEIGHT] / 255.0f + 0.076f * (float)m_visualparams[(int)VPElement.SHAPE_NECK_LENGTH] / 255.0f; */ - - skeleton.ApplyVisualParameters(m_visualparams); - m_avatarSize = skeleton.StandSize; - m_avatarBoxSize = skeleton.StandBoxSize; - m_avatarFeetOffset = skeleton.FeetOffset; + } + + public void SetSize(Vector3 avSize) + { + m_avatarSize = avSize; + m_avatarBoxSize = avSize; + m_avatarBoxSize.Z += AVBOXAJUST; + if (m_avatarBoxSize.X < AVBOXMINX) + m_avatarBoxSize.X = AVBOXMINX; + if (m_avatarBoxSize.Y < AVBOXMINY) + m_avatarBoxSize.Y = AVBOXMINY; + if (m_avatarBoxSize.Z < AVBOXMINZ) + m_avatarBoxSize.Z = AVBOXMINZ; m_avatarHeight = m_avatarSize.Z; } @@ -678,8 +691,9 @@ namespace OpenSim.Framework { if ((data != null) && (data["serial"] != null)) m_serial = data["serial"].AsInteger(); -// if ((data != null) && (data["height"] != null)) + if ((data != null) && (data["height"] != null)) // m_avatarHeight = (float)data["height"].AsReal(); + SetSize(new Vector3(0.45f,0.6f, (float)data["height"].AsReal())); try { @@ -741,7 +755,6 @@ namespace OpenSim.Framework // att.ItemID, att.AssetID, att.AttachPoint); } } - SetHeight(); } catch (Exception e) { diff --git a/OpenSim/Framework/AvatarSkeleton.cs b/OpenSim/Framework/AvatarSkeleton.cs deleted file mode 100644 index 7a49f22e21..0000000000 --- a/OpenSim/Framework/AvatarSkeleton.cs +++ /dev/null @@ -1,282 +0,0 @@ -/* - * 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. - */ -// Ubit 2012 -using System; -using System.Collections; -using System.Collections.Generic; -using OpenMetaverse; -using OpenMetaverse.StructuredData; -using log4net; -using VPElement = OpenSim.Framework.AvatarAppearance.VPElement; - - - -namespace OpenSim.Framework -{ - /// - /// Contains the Avatar's Skeleton - /// - public class AvatarSkeleton - { - const int NBONES = 26; - const float BOXAJUST = 0.2f; - - public enum Bones : int - { - EyeLeft, - Eyeright, - Skull, - Head, - Neck, - CollarRight, - CollarLeft, - Shoulderright, - ShoulderLeft, - ElbowRight, - ElbowLeft, - WristRight, - WristLeft, - Chest, - Torso, - Pelvis, - Hipright, - HipLeft, - KneeRight, - KneeLeft, - AnkleRight, - AnkleLeft, - FootRight, - FootLeft, - ToeRight, - ToeLeft - } - - public struct bone - { - public Vector3 Offset; - public Vector3 Scale; - public bone(float x, float y, float z) - { - Offset = new Vector3(x, y, z); - Scale = new Vector3(1f, 1f, 1f); - } - - public void addScale(float x, float y, float z, float factor) - { - Scale.X += x * factor; - Scale.Y += y * factor; - Scale.Y += z * factor; - } - - public void addOffset(float x, float y, float z, float factor) - { - Offset.X += x * factor; - Offset.Y += y * factor; - Offset.Y += z * factor; - } - } - - private bone[] DefaultBones = new bone[] - { - new bone(0.098f, 0.036f, 0.079f), // EyeLeft - new bone(0.098f, -0.036f, 0.079f), // Eyeright - new bone(0.0f, 0.0f, 0.079f), // Skull - new bone(0.0f, 0.0f, 0.076f), // Head - new bone(-0.1f, 0.0f, 0.251f), // Neck - new bone(-0.021f, -0.085f, 0.165f), // CollarRight - new bone(-0.021f, 0.085f, 0.165f), // CollarLeft - new bone(0.0f, -0.79f, 0.0f), // Shoulderright - new bone(0.0f, 0.79f, 0.0f), // ShoulderLeft - new bone(0.0f, -0.248f, 0.0f), // ElbowRight - new bone(0.0f, 0.248f, 0.0f), // ElbowLeft - new bone(0.0f, -0.205f, 0.0f), // WristRight - new bone(0.0f, 0.205f, 0.0f), // WristLeft - new bone(-0.015f, 0.000f, 0.205f), // Chest - new bone(0.0f, 0.0f, 0.084f), // Torso - new bone(0.0f, 0.0f, 1.067f), // Pelvis - new bone(0.034f, -0.129f, -0.041f), // Hipright - new bone(0.034f, 0.127f, -0.041f), // HipLeft - new bone(-0.001f, 0.049f, -0.491f), // KneeRight - new bone(-0.001f, -0.046f, -0.491f), // KneeLeft - new bone(-0.029f, 0.0f, -0.468f), // AnkleRight - new bone(-0.029f, 0.001f, -0.468f), // AnkleLeft - new bone(0.112f, 0.0f, -0.061f), // FootRight - new bone(0.112f, 0.0f, -0.061f), // FootLeft - new bone(0.109f, 0.0f, 0.0f), // ToeRight - new bone(0.109f, 0.0f, 0.0f) // ToeLeft - }; - - private bone[] m_bones = null; - private byte[] m_visualParams = null; - - const float bytescale = 1.0f / 255.0f; - - private float convertVP(AvatarAppearance.VPElement vp) - { - return (float)m_visualParams[(int)vp] * bytescale; - } - - private Vector3 m_standSize; - private float m_feetOffset = 0f; - - public Vector3 StandSize - { - get - { - if (m_bones == null || m_visualParams == null) - return new Vector3(0.45f, 0.6f, 1.9f); - else - return m_standSize; - } - } - - public Vector3 StandBoxSize - { - get - { - if (m_bones == null || m_visualParams == null) - return new Vector3(0.45f, 0.6f, 1.9f + BOXAJUST); - else - { - Vector3 r = m_standSize; - r.Z += BOXAJUST; - return r; - } - } - } - - public float FeetOffset - { - get - { - if (m_bones == null || m_visualParams == null) - return 0.0f; - else - { - return m_feetOffset; - } - } - } - - /// - /// Set avatar height by a calculation based on their visual parameters. - /// - - public void ApplyVisualParameters(byte[] vPs) - { - m_visualParams = vPs; - - if (m_bones == null) - { - m_bones = new bone[NBONES]; - for (int i = 0; i < NBONES; i++) - m_bones[i] = DefaultBones[i]; - } - - float bone_skull = m_bones[(int)Bones.Skull].Offset.Z; - float bone_head = m_bones[(int)Bones.Head].Offset.Z; - float bone_neck = m_bones[(int)Bones.Neck].Offset.Z; - float bone_chest = m_bones[(int)Bones.Chest].Offset.Z; - float bone_torso = m_bones[(int)Bones.Torso].Offset.Z; - float bone_hip = m_bones[(int)Bones.Hipright].Offset.Z; - float bone_knee = m_bones[(int)Bones.KneeRight].Offset.Z; - float bone_ank = m_bones[(int)Bones.AnkleRight].Offset.Z; - float bone_foot = m_bones[(int)Bones.FootRight].Offset.Z; - - float sbone_skull = m_bones[(int)Bones.Skull].Scale.Z; - float sbone_head = m_bones[(int)Bones.Head].Scale.Z; - float sbone_neck = m_bones[(int)Bones.Neck].Scale.Z; - float sbone_chest = m_bones[(int)Bones.Chest].Scale.Z; - float sbone_torso = m_bones[(int)Bones.Torso].Scale.Z; - float sbone_pelvis = m_bones[(int)Bones.Pelvis].Scale.Z; - float sbone_hip = m_bones[(int)Bones.Hipright].Scale.Z; - float sbone_knee = m_bones[(int)Bones.KneeRight].Scale.Z; - float sbone_ank = m_bones[(int)Bones.AnkleRight].Scale.Z; - float sbone_foot = m_bones[(int)Bones.FootRight].Scale.Z; - - float v_male = (m_visualParams[(int)VPElement.SHAPE_MALE] == 0) ? 0.0f : 1.0f; - sbone_neck += v_male * 0.2f; - sbone_chest += v_male * 0.05f; - sbone_torso += v_male * 0.05f; - sbone_knee += v_male * 0.1f; - - float v_height = convertVP(VPElement.SHAPE_HEIGHT) * 4.3f - 2.3f; - sbone_neck += v_height * 0.02f; - sbone_chest += v_height * 0.05f; - sbone_torso += v_height * 0.05f; - sbone_hip += v_height * 0.1f; - sbone_knee += v_height * 0.1f; - - float v_hip_len = convertVP(VPElement.SHAPE_HIP_LENGTH) * 2f - 1f; - sbone_pelvis += v_hip_len * 0.3f; - - float v_torso_len = convertVP(VPElement.SHAPE_TORSO_LENGTH) * 2f - 1f; - sbone_torso += v_torso_len * 0.3f; - sbone_pelvis += v_torso_len * 0.1f; - sbone_hip += v_torso_len * -0.1f; - sbone_knee += v_torso_len * -0.05f; - - float v_head_size = convertVP(VPElement.SHAPE_HEAD_SIZE) * 0.35f - 0.25f; - bone_skull += v_head_size * 0.1f; - sbone_skull += v_head_size; - sbone_head += v_head_size; - - float v_shoes_heel = convertVP(VPElement.SHOES_HEEL_HEIGHT); - bone_foot += v_shoes_heel * -0.08f; - - float v_shoes_plat = convertVP(VPElement.SHOES_PLATFORM_HEIGHT); - bone_foot += v_shoes_plat * -0.07f; - - float v_leg_lenght = convertVP(VPElement.SHAPE_LEG_LENGTH) * 2f - 1f; - sbone_hip += v_leg_lenght * 0.2f; - sbone_knee += v_leg_lenght * 0.2f; - - float v_neck_len = convertVP(VPElement.SHAPE_NECK_LENGTH) * 2f - 1f; - sbone_neck += v_neck_len * 0.5f; - - float hipmess = bone_hip * sbone_pelvis; - - float pelvisToFoot = hipmess - - bone_knee * sbone_hip - - bone_ank * sbone_knee - - bone_foot * sbone_ank; - - - float size = 1.4142f * bone_skull * sbone_head + - bone_head * sbone_neck + - bone_neck * sbone_chest + - bone_chest * sbone_torso + - bone_torso * sbone_pelvis; - - size += pelvisToFoot; - - m_standSize = new Vector3(0.45f, 0.6f, size); - // m_feetOffset = 0.5f * size - pelvisToFoot; - m_feetOffset = 0.0f; - } - } -} diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index f686c6035d..c9b67defdf 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -64,7 +64,7 @@ namespace OpenSim.Framework public delegate void NetworkStats(int inPackets, int outPackets, int unAckedBytes); - public delegate void SetAppearance(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams); + public delegate void SetAppearance(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 AvSize); public delegate void StartAnim(IClientAPI remoteClient, UUID animID); diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 8e0b72fe50..2efaa79947 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -6248,6 +6248,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP // Temporarily protect ourselves from the mantis #951 failure. // However, we could do this for several other handlers where a failure isn't terminal // for the client session anyway, in order to protect ourselves against bad code in plugins + Vector3 avSize = appear.AgentData.Size; try { byte[] visualparams = new byte[appear.VisualParam.Length]; @@ -6258,7 +6259,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (appear.ObjectData.TextureEntry.Length > 1) te = new Primitive.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length); - handlerSetAppearance(sender, te, visualparams); + handlerSetAppearance(sender, te, visualparams,avSize); } catch (Exception e) { diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index d557a28647..4c42397cc5 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -145,6 +145,21 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory SetAppearance(sp, appearance.Texture, appearance.VisualParams); } + + public void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize) + { + float oldoff = sp.Appearance.AvatarFeetOffset; + Vector3 oldbox = sp.Appearance.AvatarBoxSize; + + SetAppearance(sp, textureEntry, visualParams); + sp.Appearance.SetSize(avSize); + + float off = sp.Appearance.AvatarFeetOffset; + Vector3 box = sp.Appearance.AvatarBoxSize; + if (oldoff != off || oldbox != box) + ((ScenePresence)sp).SetSize(box, off); + } + /// /// Set appearance data (texture asset IDs and slider settings) /// @@ -181,13 +196,13 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory if (sp.Appearance.AvatarHeight != oldHeight && sp.Appearance.AvatarHeight > 0) ((ScenePresence)sp).SetHeight(sp.Appearance.AvatarHeight); */ - float oldoff = sp.Appearance.AvatarFeetOffset; - Vector3 oldbox = sp.Appearance.AvatarBoxSize; +// float oldoff = sp.Appearance.AvatarFeetOffset; +// Vector3 oldbox = sp.Appearance.AvatarBoxSize; changed = sp.Appearance.SetVisualParams(visualParams); - float off = sp.Appearance.AvatarFeetOffset; - Vector3 box = sp.Appearance.AvatarBoxSize; - if(oldoff != off || oldbox != box) - ((ScenePresence)sp).SetSize(box,off); +// float off = sp.Appearance.AvatarFeetOffset; +// Vector3 box = sp.Appearance.AvatarBoxSize; +// if(oldoff != off || oldbox != box) +// ((ScenePresence)sp).SetSize(box,off); } @@ -620,12 +635,12 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory /// /// /// - private void Client_OnSetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams) + private void Client_OnSetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize) { // m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance called for {0} ({1})", client.Name, client.AgentId); ScenePresence sp = m_scene.GetScenePresence(client.AgentId); if (sp != null) - SetAppearance(sp, textureEntry, visualParams); + SetAppearance(sp, textureEntry, visualParams,avSize); else m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance unable to find presence for {0}", client.AgentId); } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 7602d6bf83..9dfccca445 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3443,8 +3443,8 @@ namespace OpenSim.Region.Framework.Scenes Name, Scene.RegionInfo.RegionName); } - if (Appearance.AvatarHeight == 0) - Appearance.SetHeight(); +// if (Appearance.AvatarHeight == 0) +// Appearance.SetHeight(); PhysicsScene scene = m_scene.PhysicsScene; diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index a31ccacdb1..1b4ed1e76e 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -911,7 +911,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server // Mimicking LLClientView which gets always set appearance from client. AvatarAppearance appearance; m_scene.GetAvatarAppearance(this, out appearance); - OnSetAppearance(this, appearance.Texture, (byte[])appearance.VisualParams.Clone()); + OnSetAppearance(this, appearance.Texture, (byte[])appearance.VisualParams.Clone(),appearance.AvatarSize); } public void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args) diff --git a/OpenSim/Services/Interfaces/IAvatarService.cs b/OpenSim/Services/Interfaces/IAvatarService.cs index 0caa5211c8..260e1c64ca 100644 --- a/OpenSim/Services/Interfaces/IAvatarService.cs +++ b/OpenSim/Services/Interfaces/IAvatarService.cs @@ -201,7 +201,8 @@ namespace OpenSim.Services.Interfaces appearance.Serial = Int32.Parse(Data["Serial"]); if (Data.ContainsKey("AvatarHeight")) - appearance.AvatarHeight = float.Parse(Data["AvatarHeight"]); + appearance.SetSize(new Vector3(0.45f, 0.6f, float.Parse(Data["AvatarHeight"]))); +// appearance.AvatarHeight = float.Parse(Data["AvatarHeight"]); // Legacy Wearables if (Data.ContainsKey("BodyItem")) @@ -339,6 +340,7 @@ namespace OpenSim.Services.Interfaces appearance.Wearables[AvatarWearable.EYES].Wear( AvatarWearable.DefaultWearables[ AvatarWearable.EYES][0]); + } catch { From c73c2fb0707ee4dc78a354d932293f3e7e83ac50 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 7 Dec 2012 21:53:33 +0000 Subject: [PATCH 12/33] add some default size setting and checks --- OpenSim/Framework/AvatarAppearance.cs | 22 +++++++++++++++++-- .../Region/Framework/Scenes/ScenePresence.cs | 3 ++- OpenSim/Services/Interfaces/IAvatarService.cs | 7 +++++- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index b01b8da5fb..2183fb6c8a 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs @@ -40,10 +40,12 @@ namespace OpenSim.Framework /// public class AvatarAppearance { + // SL box diferent to size const float AVBOXAJUST = 0.2f; + // constrains for ubitode physics const float AVBOXMINX = 0.2f; const float AVBOXMINY = 0.3f; - const float AVBOXMINZ = 0.5f; + const float AVBOXMINZ = 1.2f; private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -60,7 +62,7 @@ namespace OpenSim.Framework protected AvatarWearable[] m_wearables; protected Dictionary> m_attachments; protected float m_avatarHeight = 0; - protected Vector3 m_avatarSize = new Vector3(0.45f, 0.6f, 1.9f); + protected Vector3 m_avatarSize = new Vector3(0.45f, 0.6f, 1.9f); // sl Z cloud value protected Vector3 m_avatarBoxSize = new Vector3(0.45f, 0.6f, 1.9f); protected float m_avatarFeetOffset = 0; protected float m_avatarAnimOffset = 0; @@ -157,6 +159,8 @@ namespace OpenSim.Framework SetDefaultParams(); // SetHeight(); + if(m_avatarHeight == 0) + SetSize(new Vector3(0.45f,0.6f,1.9f)); m_attachments = new Dictionary>(); } @@ -408,6 +412,20 @@ namespace OpenSim.Framework public void SetSize(Vector3 avSize) { + if (avSize.X > 32f) + avSize.X = 32f; + else if (avSize.X < 0.1f) + avSize.X = 0.1f; + + if (avSize.Y > 32f) + avSize.Y = 32f; + else if (avSize.Y < 0.1f) + avSize.Y = 0.1f; + if (avSize.Z > 32f) + avSize.Z = 32f; + else if (avSize.Z < 0.1f) + avSize.Z = 0.1f; + m_avatarSize = avSize; m_avatarBoxSize = avSize; m_avatarBoxSize.Z += AVBOXAJUST; diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 9dfccca445..9ada5bb24e 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3443,8 +3443,9 @@ namespace OpenSim.Region.Framework.Scenes Name, Scene.RegionInfo.RegionName); } -// if (Appearance.AvatarHeight == 0) + if (Appearance.AvatarHeight == 0) // Appearance.SetHeight(); + Appearance.SetSize(new Vector3(0.45f,0.6f,1.9f)); PhysicsScene scene = m_scene.PhysicsScene; diff --git a/OpenSim/Services/Interfaces/IAvatarService.cs b/OpenSim/Services/Interfaces/IAvatarService.cs index 260e1c64ca..c0130f139b 100644 --- a/OpenSim/Services/Interfaces/IAvatarService.cs +++ b/OpenSim/Services/Interfaces/IAvatarService.cs @@ -201,8 +201,13 @@ namespace OpenSim.Services.Interfaces appearance.Serial = Int32.Parse(Data["Serial"]); if (Data.ContainsKey("AvatarHeight")) - appearance.SetSize(new Vector3(0.45f, 0.6f, float.Parse(Data["AvatarHeight"]))); + { + float h = float.Parse(Data["AvatarHeight"]); + if( h == 0f) + h = 1.9f; + appearance.SetSize(new Vector3(0.45f, 0.6f, h )); // appearance.AvatarHeight = float.Parse(Data["AvatarHeight"]); + } // Legacy Wearables if (Data.ContainsKey("BodyItem")) From ecdd0e225f088ad1311a26f5934cd9e08aa697bd Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 9 Dec 2012 00:55:09 +0000 Subject: [PATCH 13/33] add velocityinterpolator packets handling but actually do nothing, since they don't do what i was looking for. --- .../ClientStack/Linden/UDP/LLClientView.cs | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 2efaa79947..4ed9a0a366 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -331,6 +331,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP private Prioritizer m_prioritizer; private bool m_disableFacelights = false; + private bool m_VelocityInterpolate = false; private const uint MaxTransferBytesPerPacket = 600; @@ -5309,8 +5310,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP // If AgentUpdate is ever handled asynchronously, then we will also need to construct a new AgentUpdateArgs // for each AgentUpdate packet. AddLocalPacketHandler(PacketType.AgentUpdate, HandleAgentUpdate, false); - + AddLocalPacketHandler(PacketType.ViewerEffect, HandleViewerEffect, false); + AddLocalPacketHandler(PacketType.VelocityInterpolateOff, HandleVelocityInterpolateOff, false); + AddLocalPacketHandler(PacketType.VelocityInterpolateOn, HandleVelocityInterpolateOn, false); AddLocalPacketHandler(PacketType.AgentCachedTexture, HandleAgentTextureCached, false); AddLocalPacketHandler(PacketType.MultipleObjectUpdate, HandleMultipleObjUpdate, false); AddLocalPacketHandler(PacketType.MoneyTransferRequest, HandleMoneyTransferRequest, false); @@ -5828,6 +5831,29 @@ namespace OpenSim.Region.ClientStack.LindenUDP return true; } + private bool HandleVelocityInterpolateOff(IClientAPI sender, Packet Pack) + { + VelocityInterpolateOffPacket p = (VelocityInterpolateOffPacket)Pack; + if (p.AgentData.SessionID != SessionId || + p.AgentData.AgentID != AgentId) + return true; + + m_VelocityInterpolate = false; + return true; + } + + private bool HandleVelocityInterpolateOn(IClientAPI sender, Packet Pack) + { + VelocityInterpolateOffPacket p = (VelocityInterpolateOffPacket)Pack; + if (p.AgentData.SessionID != SessionId || + p.AgentData.AgentID != AgentId) + return true; + + m_VelocityInterpolate = true; + return true; + } + + private bool HandleAvatarPropertiesRequest(IClientAPI sender, Packet Pack) { AvatarPropertiesRequestPacket avatarProperties = (AvatarPropertiesRequestPacket)Pack; From 8e6bc554702c4e5083dc1bda98ba77d57a995fb1 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 9 Dec 2012 23:25:07 +0100 Subject: [PATCH 14/33] Check database for root prim IDs only to try and get a handle on prim loss once and for all. --- OpenSim/Data/MySQL/MySQLSimulationData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 12c979aa50..01b9299035 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs @@ -2028,7 +2028,7 @@ namespace OpenSim.Data.MySQL using (MySqlCommand cmd = dbcon.CreateCommand()) { - cmd.CommandText = "select UUID from prims where RegionUUID = ?RegionUUID"; + cmd.CommandText = "select UUID from prims where RegionUUID = ?RegionUUID and SceneGroupID = UUID"; cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString()); using (IDataReader reader = ExecuteReader(cmd)) From c6430b14dbc9d39b9c9b79ead1c1ebaaff833745 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 10 Dec 2012 11:25:30 +0000 Subject: [PATCH 15/33] typo fix --- OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 4ed9a0a366..ea3c6a4f81 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -3992,6 +3992,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP const float TIME_DILATION = 1.0f; ushort timeDilation = Utils.FloatToUInt16(avgTimeDilation, 0.0f, 1.0f); + if (terseAgentUpdateBlocks.IsValueCreated) { @@ -4972,7 +4973,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP // in that direction, even though we don't model this on the server. Implementing this in the future // may improve movement smoothness. // acceleration = new Vector3(1, 0, 0); - + angularVelocity = Vector3.Zero; if (sendTexture) @@ -5844,7 +5845,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP private bool HandleVelocityInterpolateOn(IClientAPI sender, Packet Pack) { - VelocityInterpolateOffPacket p = (VelocityInterpolateOffPacket)Pack; + VelocityInterpolateOnPacket p = (VelocityInterpolateOnPacket)Pack; if (p.AgentData.SessionID != SessionId || p.AgentData.AgentID != AgentId) return true; From 80639ace95089414423b16f90c8994f50e010373 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 11 Dec 2012 04:36:27 +0000 Subject: [PATCH 16/33] a few more changes on avatar collider --- .../Physics/UbitOdePlugin/ODECharacter.cs | 345 ++++++++++++++---- .../Region/Physics/UbitOdePlugin/OdeScene.cs | 345 ++++++------------ 2 files changed, 377 insertions(+), 313 deletions(-) diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs index 15bdc5705f..1b25faf16f 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs @@ -74,7 +74,6 @@ namespace OpenSim.Region.Physics.OdePlugin private Vector3 _position; private Vector3 _zeroPosition; - private bool _zeroFlag = false; private Vector3 _velocity; private Vector3 _target_velocity; private Vector3 _acceleration; @@ -90,11 +89,15 @@ namespace OpenSim.Region.Physics.OdePlugin public float PID_D; public float PID_P; + private float timeStep; + private float invtimeStep; + private float m_feetOffset = 0; private float feetOff = 0; private float feetSZ = 0.5f; const float feetScale = 0.8f; private float boneOff = 0; + private float m_lastVelocitySqr = 0; public float walkDivisor = 1.3f; public float runDivisor = 0.8f; @@ -103,6 +106,9 @@ namespace OpenSim.Region.Physics.OdePlugin private bool m_iscollidingGround = false; private bool m_iscollidingObj = false; private bool m_alwaysRun = false; + + private bool _zeroFlag = false; + private int m_requestedUpdateFrequency = 0; private uint m_localID = 0; public bool m_returnCollisions = false; @@ -120,6 +126,7 @@ namespace OpenSim.Region.Physics.OdePlugin int m_colliderfilter = 0; int m_colliderGroundfilter = 0; int m_colliderObjectfilter = 0; + bool m_collisionException = false; // Default we're a Character private CollisionCategories m_collisionCategories = (CollisionCategories.Character); @@ -132,10 +139,11 @@ namespace OpenSim.Region.Physics.OdePlugin // we do land collisions not ode | CollisionCategories.Land); public IntPtr Body = IntPtr.Zero; private OdeScene _parent_scene; - public IntPtr topbox = IntPtr.Zero; - public IntPtr midbox = IntPtr.Zero; - public IntPtr feetbox = IntPtr.Zero; - public IntPtr bonebox = IntPtr.Zero; + private IntPtr topbox = IntPtr.Zero; + private IntPtr midbox = IntPtr.Zero; + private IntPtr feetbox = IntPtr.Zero; + private IntPtr bbox = IntPtr.Zero; + public IntPtr collider = IntPtr.Zero; public IntPtr Amotor = IntPtr.Zero; @@ -143,6 +151,7 @@ namespace OpenSim.Region.Physics.OdePlugin + public int m_eventsubscription = 0; private int m_cureventsubscription = 0; private CollisionEventUpdate CollisionEventsThisFrame = null; @@ -160,6 +169,9 @@ namespace OpenSim.Region.Physics.OdePlugin { m_uuid = UUID.Random(); + timeStep = parent_scene.ODE_STEPSIZE; + invtimeStep = 1 / timeStep; + if (pos.IsFinite()) { if (pos.Z > 99999f) @@ -208,8 +220,8 @@ namespace OpenSim.Region.Physics.OdePlugin m_mass = m_density * m_size.X * m_size.Y * m_size.Z; ; // sure we have a default - PID_D = basePID_D * m_mass / parent_scene.ODE_STEPSIZE; - PID_P = basePID_P * m_mass / parent_scene.ODE_STEPSIZE; + PID_D = basePID_D * m_mass * invtimeStep; + PID_P = basePID_P * m_mass * invtimeStep; m_isPhysical = false; // current status: no ODE information exists @@ -292,7 +304,7 @@ namespace OpenSim.Region.Physics.OdePlugin set { flying = value; - // m_log.DebugFormat("[PHYSICS]: Set OdeCharacter Flying to {0}", flying); +// m_log.DebugFormat("[PHYSICS]: Set OdeCharacter Flying to {0}", flying); } } @@ -336,25 +348,25 @@ namespace OpenSim.Region.Physics.OdePlugin get { return m_iscollidingGround; } set { - /* we now control this - if (value) - { - m_colliderGroundfilter += 2; - if (m_colliderGroundfilter > 2) - m_colliderGroundfilter = 2; - } - else - { - m_colliderGroundfilter--; - if (m_colliderGroundfilter < 0) - m_colliderGroundfilter = 0; - } +/* we now control this + if (value) + { + m_colliderGroundfilter += 2; + if (m_colliderGroundfilter > 2) + m_colliderGroundfilter = 2; + } + else + { + m_colliderGroundfilter--; + if (m_colliderGroundfilter < 0) + m_colliderGroundfilter = 0; + } - if (m_colliderGroundfilter == 0) - m_iscollidingGround = false; - else - m_iscollidingGround = true; - */ + if (m_colliderGroundfilter == 0) + m_iscollidingGround = false; + else + m_iscollidingGround = true; + */ } } @@ -386,7 +398,7 @@ namespace OpenSim.Region.Physics.OdePlugin else m_iscollidingObj = true; - // m_iscollidingObj = value; +// m_iscollidingObj = value; if (m_iscollidingObj) m_pidControllerActive = false; @@ -634,8 +646,8 @@ namespace OpenSim.Region.Physics.OdePlugin get { return m_orientation; } set { - // fakeori = value; - // givefakeori++; +// fakeori = value; +// givefakeori++; value.Normalize(); AddChange(changes.Orientation, value); @@ -690,6 +702,46 @@ namespace OpenSim.Region.Physics.OdePlugin AddChange(changes.Momentum, momentum); } + private void ajustCollider() + { + float vq = _velocity.LengthSquared(); + if (m_lastVelocitySqr != vq) + { + m_lastVelocitySqr = vq; + if (vq > 100.0f) + { + Vector3 off = _velocity; + float t = 0.5f * timeStep; + off = off * t; + d.GeomSetOffsetPosition(bbox, off.X, off.Y, off.Z); + off.X = 2.0f * (m_size.X + Math.Abs(off.X)); + off.Y = 2.0f * (m_size.Y + Math.Abs(off.Y)); + off.Z = m_size.Z + 2.0f * Math.Abs(off.Z); + d.GeomBoxSetLengths(bbox, off.X, off.Y, off.Z); + + d.GeomSetCategoryBits(bbox, (uint)m_collisionCategories); + d.GeomSetCollideBits(bbox, (uint)m_collisionFlags); + d.GeomSetCategoryBits(topbox, 0); + d.GeomSetCollideBits(topbox, 0); + d.GeomSetCategoryBits(midbox, 0); + d.GeomSetCollideBits(midbox, 0); + d.GeomSetCategoryBits(feetbox, 0); + d.GeomSetCollideBits(feetbox, 0); + } + else + { + d.GeomSetCategoryBits(bbox, 0); + d.GeomSetCollideBits(bbox, 0); + d.GeomSetCategoryBits(topbox, (uint)m_collisionCategories); + d.GeomSetCollideBits(topbox, (uint)m_collisionFlags); + d.GeomSetCategoryBits(midbox, (uint)m_collisionCategories); + d.GeomSetCollideBits(midbox, (uint)m_collisionFlags); + d.GeomSetCategoryBits(feetbox, (uint)m_collisionCategories); + d.GeomSetCollideBits(feetbox, (uint)m_collisionFlags); + } + } + } + private void AvatarGeomAndBodyCreation(float npositionX, float npositionY, float npositionZ) { // sizes one day should came from visual parameters @@ -697,7 +749,6 @@ namespace OpenSim.Region.Physics.OdePlugin float sy = m_size.Y; float sz = m_size.Z; - float topsx = sx * 0.9f; float midsx = sx; float feetsx = sx * feetScale; @@ -732,21 +783,17 @@ namespace OpenSim.Region.Physics.OdePlugin _parent_scene.waitForSpaceUnlock(_parent_scene.CharsSpace); - feetbox = d.CreateBox(_parent_scene.CharsSpace, feetsx, feetsy, feetsz); - d.GeomSetCategoryBits(feetbox, (uint)m_collisionCategories); - d.GeomSetCollideBits(feetbox, (uint)m_collisionFlags); + collider = d.HashSpaceCreate(_parent_scene.CharsSpace); + d.HashSpaceSetLevels(collider, -4, 3); + d.SpaceSetSublevel(collider, 3); + d.SpaceSetCleanup(collider, false); + d.GeomSetCategoryBits(collider, (uint)m_collisionCategories); + d.GeomSetCollideBits(collider, (uint)m_collisionFlags); - midbox = d.CreateBox(_parent_scene.CharsSpace, midsx, midsy, midsz); - d.GeomSetCategoryBits(midbox, (uint)m_collisionCategories); - d.GeomSetCollideBits(midbox, (uint)m_collisionFlags); - - topbox = d.CreateBox(_parent_scene.CharsSpace, topsx, topsy, topsz); - d.GeomSetCategoryBits(topbox, (uint)m_collisionCategories); - d.GeomSetCollideBits(topbox, (uint)m_collisionFlags); - - bonebox = d.CreateBox(_parent_scene.CharsSpace, bonesx, bonesy, bonesz); - d.GeomSetCategoryBits(bonebox, (uint)m_collisionCategories); - d.GeomSetCollideBits(bonebox, (uint)m_collisionFlags); + feetbox = d.CreateBox(collider, feetsx, feetsy, feetsz); + midbox = d.CreateBox(collider, midsx, midsy, midsz); + topbox = d.CreateBox(collider, topsx, topsy, topsz); + bbox = d.CreateBox(collider, m_size.X, m_size.Y, m_size.Z); m_mass = m_density * m_size.X * m_size.Y * m_size.Z; // update mass @@ -758,9 +805,13 @@ namespace OpenSim.Region.Physics.OdePlugin Body = d.BodyCreate(_parent_scene.world); _zeroFlag = false; + m_collisionException = false; m_pidControllerActive = true; m_freemove = false; + _velocity = Vector3.Zero; + m_lastVelocitySqr = 0; + d.BodySetAutoDisableFlag(Body, false); d.BodySetPosition(Body, npositionX, npositionY, npositionZ); @@ -772,12 +823,14 @@ namespace OpenSim.Region.Physics.OdePlugin d.GeomSetBody(feetbox, Body); d.GeomSetBody(midbox, Body); d.GeomSetBody(topbox, Body); - d.GeomSetBody(bonebox, Body); + d.GeomSetBody(bbox, Body); d.GeomSetOffsetPosition(feetbox, 0, 0, feetz); d.GeomSetOffsetPosition(midbox, 0, 0, midz); d.GeomSetOffsetPosition(topbox, 0, 0, topz); - d.GeomSetOffsetPosition(bonebox, 0, 0, m_feetOffset); + + ajustCollider(); + // The purpose of the AMotor here is to keep the avatar's physical // surrogate from rotating while moving @@ -841,44 +894,109 @@ namespace OpenSim.Region.Physics.OdePlugin if (topbox != IntPtr.Zero) { _parent_scene.actor_name_map.Remove(topbox); - _parent_scene.waitForSpaceUnlock(_parent_scene.CharsSpace); + _parent_scene.waitForSpaceUnlock(collider); d.GeomDestroy(topbox); topbox = IntPtr.Zero; } if (midbox != IntPtr.Zero) { _parent_scene.actor_name_map.Remove(midbox); - _parent_scene.waitForSpaceUnlock(_parent_scene.CharsSpace); + _parent_scene.waitForSpaceUnlock(collider); d.GeomDestroy(midbox); midbox = IntPtr.Zero; } if (feetbox != IntPtr.Zero) { _parent_scene.actor_name_map.Remove(feetbox); - _parent_scene.waitForSpaceUnlock(_parent_scene.CharsSpace); + _parent_scene.waitForSpaceUnlock(collider); d.GeomDestroy(feetbox); feetbox = IntPtr.Zero; } - if (bonebox != IntPtr.Zero) + if (bbox != IntPtr.Zero) { - _parent_scene.actor_name_map.Remove(bonebox); - _parent_scene.waitForSpaceUnlock(_parent_scene.CharsSpace); - d.GeomDestroy(bonebox); - bonebox = IntPtr.Zero; + _parent_scene.actor_name_map.Remove(bbox); + _parent_scene.waitForSpaceUnlock(collider); + d.GeomDestroy(bbox); + bbox = IntPtr.Zero; + } + + if (collider != IntPtr.Zero) + { + d.SpaceDestroy(collider); + collider = IntPtr.Zero; } } + //in place 2D rotation around Z assuming rot is normalised and is a rotation around Z + public void RotateXYonZ(ref float x, ref float y, ref Quaternion rot) + { + float sin = 2.0f * rot.Z * rot.W; + float cos = rot.W * rot.W - rot.Z * rot.Z; + float tx = x; + + x = tx * cos - y * sin; + y = tx * sin + y * cos; + } + public void RotateXYonZ(ref float x, ref float y, ref float sin, ref float cos) + { + float tx = x; + x = tx * cos - y * sin; + y = tx * sin + y * cos; + } + public void invRotateXYonZ(ref float x, ref float y, ref float sin, ref float cos) + { + float tx = x; + x = tx * cos + y * sin; + y = -tx * sin + y * cos; + } + + public void invRotateXYonZ(ref float x, ref float y, ref Quaternion rot) + { + float sin = - 2.0f * rot.Z * rot.W; + float cos = rot.W * rot.W - rot.Z * rot.Z; + float tx = x; + + x = tx * cos - y * sin; + y = tx * sin + y * cos; + } + + public bool Collide(IntPtr me, bool reverse, ref d.ContactGeom contact, ref bool feetcollision) { feetcollision = false; + if (m_collisionException) + return false; - if (me == bonebox) // inner bone + if (me == bbox) // if moving fast { - if (contact.pos.Z - _position.Z < boneOff) - IsColliding = true; - return true; + // force a full inelastic collision + m_collisionException = true; + + Vector3 off = m_size * 0.5f; + off.X += contact.depth; + off.Y += contact.depth; + off.Z += contact.depth; + if (reverse) + { + off.X *= -contact.normal.X; + off.Y *= -contact.normal.Y; + off.Z *= -contact.normal.Z; + } + else + { + off.X *= contact.normal.X; + off.Y *= contact.normal.Y; + off.Z *= contact.normal.Z; + } + + off.X += contact.pos.X; + off.Y += contact.pos.Y; + off.Z += contact.pos.Z; + + _position = off; + return false; } if (me == topbox) // keep a box head @@ -890,6 +1008,21 @@ namespace OpenSim.Region.Physics.OdePlugin if (me == midbox) { + if (Math.Abs(contact.normal.Z) > 0.95f) + { + float nz = contact.normal.Z; + if (!reverse) + nz = -nz; + + if (nz > 0) + return true; // missed head TODO + + // missed feet collision? + + + return true; + } + t = offx * offx + offy * offy; t = (float)Math.Sqrt(t); t = 1 / t; @@ -917,12 +1050,19 @@ namespace OpenSim.Region.Physics.OdePlugin if (Math.Abs(contact.normal.Z) > 0.95f) { + if (contact.normal.Z > 0) + contact.normal.Z = 1.0f; + else + contact.normal.Z = -1.0f; + contact.normal.X = 0.0f; + contact.normal.Y = 0.0f; feetcollision = true; if (h < boneOff) IsColliding = true; return true; } + float offz = h - feetOff; // distance from top of feetbox if (offz > 0) @@ -971,11 +1111,28 @@ namespace OpenSim.Region.Physics.OdePlugin /// This is the avatar's movement control + PID Controller /// /// - public void Move(float timeStep, List defects) + public void Move(List defects) { if (Body == IntPtr.Zero) return; + if (m_collisionException) + { + d.BodySetPosition(Body,_position.X, _position.Y, _position.Z); + d.BodySetLinearVel(Body, 0, 0, 0); + + float v = _velocity.Length(); + if (v != 0) + { + v = 6.0f / v; + _velocity = _velocity * v; + d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z); + } + ajustCollider(); + m_collisionException = false; + return; + } + d.Vector3 dtmp = d.BodyGetPosition(Body); Vector3 localpos = new Vector3(dtmp.X, dtmp.Y, dtmp.Z); @@ -1049,6 +1206,7 @@ namespace OpenSim.Region.Physics.OdePlugin //****************************************** // colide with land + d.AABB aabb; d.GeomGetAABB(feetbox, out aabb); float chrminZ = aabb.MinZ - 0.02f; // move up a bit @@ -1095,8 +1253,8 @@ namespace OpenSim.Region.Physics.OdePlugin contact.Position.X = localpos.X; contact.Position.Y = localpos.Y; contact.Position.Z = chrminZ; - contact.SurfaceNormal.X = 0f; - contact.SurfaceNormal.Y = 0f; + contact.SurfaceNormal.X = 0.0f; + contact.SurfaceNormal.Y = 0.0f; contact.SurfaceNormal.Z = -1f; contact.RelativeSpeed = -vel.Z; contact.CharacterFeet = true; @@ -1118,6 +1276,7 @@ namespace OpenSim.Region.Physics.OdePlugin m_iscollidingGround = false; } + //****************************************** bool tviszero = (_target_velocity.X == 0.0f && _target_velocity.Y == 0.0f && _target_velocity.Z == 0.0f); @@ -1253,21 +1412,58 @@ namespace OpenSim.Region.Physics.OdePlugin } // update our local ideia of position velocity and aceleration + // _position = localpos; _position = localpos; + if (_zeroFlag) { _velocity = Vector3.Zero; _acceleration = Vector3.Zero; + m_rotationalVelocity = Vector3.Zero; } else { - _acceleration = _velocity; // previus velocity - _velocity = vel; - _acceleration = (vel - _acceleration) / timeStep; + Vector3 a =_velocity; // previus velocity + SetSmooth(ref _velocity, ref vel, 2); + a = (_velocity - a) * invtimeStep; + SetSmooth(ref _acceleration, ref a, 2); + + dtmp = d.BodyGetAngularVel(Body); + m_rotationalVelocity.X = 0f; + m_rotationalVelocity.Y = 0f; + m_rotationalVelocity.Z = dtmp.Z; + Math.Round(m_rotationalVelocity.Z,3); } - + ajustCollider(); } + public void round(ref Vector3 v, int digits) + { + v.X = (float)Math.Round(v.X, digits); + v.Y = (float)Math.Round(v.Y, digits); + v.Z = (float)Math.Round(v.Z, digits); + } + + public void SetSmooth(ref Vector3 dst, ref Vector3 value) + { + dst.X = 0.1f * dst.X + 0.9f * value.X; + dst.Y = 0.1f * dst.Y + 0.9f * value.Y; + dst.Z = 0.1f * dst.Z + 0.9f * value.Z; + } + + public void SetSmooth(ref Vector3 dst, ref Vector3 value, int rounddigits) + { + dst.X = 0.4f * dst.X + 0.6f * value.X; + dst.X = (float)Math.Round(dst.X, rounddigits); + + dst.Y = 0.4f * dst.Y + 0.6f * value.Y; + dst.Y = (float)Math.Round(dst.Y, rounddigits); + + dst.Z = 0.4f * dst.Z + 0.6f * value.Z; + dst.Z = (float)Math.Round(dst.Z, rounddigits); + } + + /// /// Updates the reported position and velocity. /// Used to copy variables from unmanaged space at heartbeat rate and also trigger scene updates acording @@ -1394,10 +1590,11 @@ namespace OpenSim.Region.Physics.OdePlugin AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z); - _parent_scene.actor_name_map[topbox] = (PhysicsActor)this; - _parent_scene.actor_name_map[midbox] = (PhysicsActor)this; + _parent_scene.actor_name_map[collider] = (PhysicsActor)this; _parent_scene.actor_name_map[feetbox] = (PhysicsActor)this; - _parent_scene.actor_name_map[bonebox] = (PhysicsActor)this; + _parent_scene.actor_name_map[midbox] = (PhysicsActor)this; + _parent_scene.actor_name_map[topbox] = (PhysicsActor)this; + _parent_scene.actor_name_map[bbox] = (PhysicsActor)this; _parent_scene.AddCharacter(this); } else @@ -1450,13 +1647,16 @@ namespace OpenSim.Region.Physics.OdePlugin _position.Z + (m_size.Z - oldsz) * 0.5f); Velocity = Vector3.Zero; + - _parent_scene.actor_name_map[topbox] = (PhysicsActor)this; - _parent_scene.actor_name_map[midbox] = (PhysicsActor)this; + _parent_scene.actor_name_map[collider] = (PhysicsActor)this; _parent_scene.actor_name_map[feetbox] = (PhysicsActor)this; - _parent_scene.actor_name_map[bonebox] = (PhysicsActor)this; + _parent_scene.actor_name_map[midbox] = (PhysicsActor)this; + _parent_scene.actor_name_map[topbox] = (PhysicsActor)this; + _parent_scene.actor_name_map[bbox] = (PhysicsActor)this; } m_freemove = false; + m_collisionException = false; m_pidControllerActive = true; } else @@ -1565,6 +1765,7 @@ namespace OpenSim.Region.Physics.OdePlugin if (Body != IntPtr.Zero) d.BodySetLinearVel(Body, newmomentum.X, newmomentum.Y, newmomentum.Z); + ajustCollider(); } private void donullchange() @@ -1573,7 +1774,7 @@ namespace OpenSim.Region.Physics.OdePlugin public bool DoAChange(changes what, object arg) { - if (topbox == IntPtr.Zero && what != changes.Add && what != changes.Remove) + if (collider == IntPtr.Zero && what != changes.Add && what != changes.Remove) { return false; } diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs index 2ba59407f2..f8d7195443 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs @@ -178,7 +178,9 @@ namespace OpenSim.Region.Physics.OdePlugin public changes what; public Object arg; } - + + + public class OdeScene : PhysicsScene { private readonly ILog m_log; @@ -301,6 +303,8 @@ namespace OpenSim.Region.Physics.OdePlugin public IntPtr StaticSpace; // space for the static things around public IntPtr GroundSpace; // space for ground + public IntPtr SharedRay; + // some speedup variables private int spaceGridMaxX; private int spaceGridMaxY; @@ -428,6 +432,8 @@ namespace OpenSim.Region.Physics.OdePlugin contactgroup = d.JointGroupCreate(0); //contactgroup + SharedRay = d.CreateRay(TopSpace, 1.0f); + d.WorldSetAutoDisableFlag(world, false); } } @@ -733,35 +739,35 @@ namespace OpenSim.Region.Physics.OdePlugin if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact)) return; -/* -// debug - PhysicsActor dp2; - if (d.GeomGetClass(g1) == d.GeomClassID.HeightfieldClass) - { - d.AABB aabb; - d.GeomGetAABB(g2, out aabb); - float x = aabb.MaxX - aabb.MinX; - float y = aabb.MaxY - aabb.MinY; - float z = aabb.MaxZ - aabb.MinZ; - if (x > 60.0f || y > 60.0f || z > 60.0f) - { - if (!actor_name_map.TryGetValue(g2, out dp2)) - m_log.WarnFormat("[PHYSICS]: failed actor mapping for geom 2"); - else - m_log.WarnFormat("[PHYSICS]: land versus large prim geo {0},size {1}, AABBsize <{2},{3},{4}>, at {5} ori {6},({7})", - dp2.Name, dp2.Size, x, y, z, - dp2.Position.ToString(), - dp2.Orientation.ToString(), - dp2.Orientation.Length()); - return; - } - } -// -*/ + /* + // debug + PhysicsActor dp2; + if (d.GeomGetClass(g1) == d.GeomClassID.HeightfieldClass) + { + d.AABB aabb; + d.GeomGetAABB(g2, out aabb); + float x = aabb.MaxX - aabb.MinX; + float y = aabb.MaxY - aabb.MinY; + float z = aabb.MaxZ - aabb.MinZ; + if (x > 60.0f || y > 60.0f || z > 60.0f) + { + if (!actor_name_map.TryGetValue(g2, out dp2)) + m_log.WarnFormat("[PHYSICS]: failed actor mapping for geom 2"); + else + m_log.WarnFormat("[PHYSICS]: land versus large prim geo {0},size {1}, AABBsize <{2},{3},{4}>, at {5} ori {6},({7})", + dp2.Name, dp2.Size, x, y, z, + dp2.Position.ToString(), + dp2.Orientation.ToString(), + dp2.Orientation.Length()); + return; + } + } + // + */ - if(d.GeomGetCategoryBits(g1) == (uint)CollisionCategories.VolumeDtc || - d.GeomGetCategoryBits(g1) == (uint)CollisionCategories.VolumeDtc) + if (d.GeomGetCategoryBits(g1) == (uint)CollisionCategories.VolumeDtc || + d.GeomGetCategoryBits(g2) == (uint)CollisionCategories.VolumeDtc) { int cflags; unchecked @@ -776,7 +782,7 @@ namespace OpenSim.Region.Physics.OdePlugin catch (SEHException) { m_log.Error("[PHYSICS]: The Operating system shut down ODE because of corrupt memory. This could be a result of really irregular terrain. If this repeats continuously, restart using Basic Physics and terrain fill your terrain. Restarting the sim."); -// ode.drelease(world); + // ode.drelease(world); base.TriggerPhysicsBasedRestart(); } catch (Exception e) @@ -816,26 +822,25 @@ namespace OpenSim.Region.Physics.OdePlugin // get first contact d.ContactGeom curContact = new d.ContactGeom(); + if (!GetCurContactGeom(0, ref curContact)) return; - // for now it's the one with max depth - ContactPoint maxDepthContact = new ContactPoint( - new Vector3(curContact.pos.X, curContact.pos.Y, curContact.pos.Z), - new Vector3(curContact.normal.X, curContact.normal.Y, curContact.normal.Z), - curContact.depth - ); + // do volume detection case - if ( - (p1.IsVolumeDtc || p2.IsVolumeDtc)) + if ((p1.IsVolumeDtc || p2.IsVolumeDtc)) { + ContactPoint maxDepthContact = new ContactPoint( + new Vector3(curContact.pos.X, curContact.pos.Y, curContact.pos.Z), + new Vector3(curContact.normal.X, curContact.normal.Y, curContact.normal.Z), + curContact.depth, false + ); + collision_accounting_events(p1, p2, maxDepthContact); return; } // big messy collision analises - Vector3 normoverride = Vector3.Zero; //damm c# - float mu = 0; float bounce = 0; float cfm = 0.0001f; @@ -846,36 +851,15 @@ namespace OpenSim.Region.Physics.OdePlugin ContactData contactdata1 = new ContactData(0, 0, false); ContactData contactdata2 = new ContactData(0, 0, false); - bool dop1foot = false; - bool dop2foot = false; + bool dop1ava = false; + bool dop2ava = false; bool ignore = false; - bool AvanormOverride = false; switch (p1.PhysicsActorType) { case (int)ActorTypes.Agent: { - dop1foot = true; - - AvanormOverride = true; - Vector3 tmp = p2.Position - p1.Position; - normoverride = p2.Velocity - p1.Velocity; - mu = normoverride.LengthSquared(); - - if (mu > 1e-6) - { - mu = 1.0f / (float)Math.Sqrt(mu); - normoverride *= mu; - mu = Vector3.Dot(tmp, normoverride); - if (mu > 0) - normoverride *= -1; - } - else - { - tmp.Normalize(); - normoverride = -tmp; - } - + dop1ava = true; switch (p2.PhysicsActorType) { case (int)ActorTypes.Agent: @@ -886,7 +870,6 @@ namespace OpenSim.Region.Physics.OdePlugin case (int)ActorTypes.Prim: if (p2.Velocity.LengthSquared() > 0.0f) p2.CollidingObj = true; - dop1foot = true; break; default: @@ -901,33 +884,8 @@ namespace OpenSim.Region.Physics.OdePlugin { case (int)ActorTypes.Agent: + dop2ava = true; - dop2foot = true; - - AvanormOverride = true; - - Vector3 tmp = p2.Position - p1.Position; - normoverride = p2.Velocity - p1.Velocity; - mu = normoverride.LengthSquared(); - if (mu > 1e-6) - { - mu = 1.0f / (float)Math.Sqrt(mu); - normoverride *= mu; - mu = Vector3.Dot(tmp, normoverride); - if (mu > 0) - normoverride *= -1; - } - else - { - tmp.Normalize(); - normoverride = -tmp; - } - - bounce = 0; - mu = 0; - cfm = 0.0001f; - - dop2foot = true; if (p1.Velocity.LengthSquared() > 0.0f) p1.CollidingObj = true; break; @@ -1032,170 +990,78 @@ namespace OpenSim.Region.Physics.OdePlugin default: break; } + if (ignore) return; + + d.ContactGeom maxContact = curContact; +// if (IgnoreNegSides && curContact.side1 < 0) +// maxContact.depth = float.MinValue; + + d.ContactGeom minContact = curContact; +// if (IgnoreNegSides && curContact.side1 < 0) +// minContact.depth = float.MaxValue; + IntPtr Joint; - bool FeetCollision = false; - - int i = 0; int ncontacts = 0; - while(true) - { - if (IgnoreNegSides && curContact.side1 < 0) + + int i = 0; + + while (true) { + if (m_global_contactcount >= maxContactsbeforedeath) + break; + +// if (!(IgnoreNegSides && curContact.side1 < 0)) + { + bool noskip = true; + if (dop1ava) + { + if (!(((OdeCharacter)p1).Collide(g1,false, ref curContact, ref FeetCollision))) + + noskip = false; + } + else if (dop2ava) + { + if (!(((OdeCharacter)p2).Collide(g2,true, ref curContact, ref FeetCollision))) + noskip = false; + } + + if (noskip) + { + m_global_contactcount++; + ncontacts++; + + Joint = CreateContacJoint(ref curContact, mu, bounce, cfm, erpscale, dscale); + d.JointAttach(Joint, b1, b2); + + if (curContact.depth > maxContact.depth) + maxContact = curContact; + + if (curContact.depth < minContact.depth) + minContact = curContact; + } + } + if (++i >= count) break; if (!GetCurContactGeom(i, ref curContact)) break; } - else - - { - if(dop1foot) - { - if (!(((OdeCharacter)p1).Collide(g1, false, ref curContact, ref FeetCollision))) - { - if (++i >= count) - break; - else - continue; - } - } - else if(dop2foot) - { - if (!(((OdeCharacter)p2).Collide(g2, true, ref curContact, ref FeetCollision))) - { - if (++i >= count) - break; - else - continue; - } - } - -/* - if (AvanormOverride) - { - if (curContact.depth > 0.3f) - { - if (dop1foot && (p1.Position.Z - curContact.pos.Z) > (p1.Size.Z - avCapRadius) * 0.5f) - p1.IsColliding = true; - if (dop2foot && (p2.Position.Z - curContact.pos.Z) > (p2.Size.Z - avCapRadius) * 0.5f) - p2.IsColliding = true; - curContact.normal.X = normoverride.X; - curContact.normal.Y = normoverride.Y; - curContact.normal.Z = normoverride.Z; - } - - else - { - if (dop1foot) - { - float sz = p1.Size.Z; - Vector3 vtmp = p1.Position; - float ppos = curContact.pos.Z - vtmp.Z + (sz - avCapRadius) * 0.5f; - if (ppos > 0f) - { - if (!p1.Flying) - { - d.AABB aabb; - d.GeomGetAABB(g2, out aabb); - float tmp = vtmp.Z - sz * .18f; - - if (aabb.MaxZ < tmp) - { - vtmp.X = curContact.pos.X - vtmp.X; - vtmp.Y = curContact.pos.Y - vtmp.Y; - vtmp.Z = -0.2f; - vtmp.Normalize(); - curContact.normal.X = vtmp.X; - curContact.normal.Y = vtmp.Y; - curContact.normal.Z = vtmp.Z; - } - } - } - else - p1.IsColliding = true; - - } - - if (dop2foot) - { - float sz = p2.Size.Z; - Vector3 vtmp = p2.Position; - vtmp.Z -= sz * 0.5f; - vtmp.Z += 0.5f; - float ppos = vtmp.Z - curContact.pos.Z; - if (ppos > 0f) - { - if (!p2.Flying) - { - float tmp = vtmp.Z - sz * .18f; - vtmp.X = curContact.pos.X - vtmp.X; - vtmp.Y = curContact.pos.Y - vtmp.Y; - vtmp.Z = curContact.pos.Z - vtmp.Z; - vtmp.Normalize(); - curContact.normal.X = vtmp.X; - curContact.normal.Y = vtmp.Y; - curContact.normal.Z = vtmp.Z; - } - } -// else - p2.IsColliding = true; - - } - } - } -*/ - ncontacts++; - Joint = CreateContacJoint(ref curContact, mu, bounce, cfm, erpscale, dscale); - d.JointAttach(Joint, b1, b2); - - if (++m_global_contactcount >= maxContactsbeforedeath) - break; - - if (++i >= count) - break; - - if (!GetCurContactGeom(i, ref curContact)) - break; - - if (curContact.depth > maxDepthContact.PenetrationDepth) - { - maxDepthContact.Position.X = curContact.pos.X; - maxDepthContact.Position.Y = curContact.pos.Y; - maxDepthContact.Position.Z = curContact.pos.Z; - maxDepthContact.SurfaceNormal.X = curContact.normal.X; - maxDepthContact.SurfaceNormal.Y = curContact.normal.Y; - maxDepthContact.SurfaceNormal.Z = curContact.normal.Z; - maxDepthContact.PenetrationDepth = curContact.depth; - } - } - } if (ncontacts > 0) { - maxDepthContact.CharacterFeet = FeetCollision; + ContactPoint maxDepthContact = new ContactPoint( + new Vector3(maxContact.pos.X, maxContact.pos.Y, maxContact.pos.Z), + new Vector3(minContact.normal.X, minContact.normal.Y, minContact.normal.Z), + maxContact.depth, FeetCollision + ); collision_accounting_events(p1, p2, maxDepthContact); } -/* - if (notskipedcount > geomContactPointsStartthrottle) - { - // If there are more then 3 contact points, it's likely - // that we've got a pile of objects, so ... - // We don't want to send out hundreds of terse updates over and over again - // so lets throttle them and send them again after it's somewhat sorted out. - this needs checking so out for now - if (b1 != IntPtr.Zero) - p1.ThrottleUpdates = true; - if (b2 != IntPtr.Zero) - p2.ThrottleUpdates = true; - - } - */ } private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, ContactPoint contact) @@ -1286,10 +1152,7 @@ namespace OpenSim.Region.Physics.OdePlugin // chr.CollidingGround = false; not done here chr.CollidingObj = false; // do colisions with static space - d.SpaceCollide2(StaticSpace, chr.topbox, IntPtr.Zero, nearCallback); - d.SpaceCollide2(StaticSpace, chr.midbox, IntPtr.Zero, nearCallback); - d.SpaceCollide2(StaticSpace, chr.feetbox, IntPtr.Zero, nearCallback); - d.SpaceCollide2(StaticSpace, chr.bonebox, IntPtr.Zero, nearCallback); + d.SpaceCollide2(chr.collider, StaticSpace, IntPtr.Zero, nearCallback); // chars with chars d.SpaceCollide(CharsSpace, IntPtr.Zero, nearCallback); @@ -1346,7 +1209,7 @@ namespace OpenSim.Region.Physics.OdePlugin // and with chars try { - d.SpaceCollide2(ActiveSpace, CharsSpace,IntPtr.Zero, nearCallback); + d.SpaceCollide2(CharsSpace,ActiveSpace, IntPtr.Zero, nearCallback); } catch (AccessViolationException) { @@ -1837,7 +1700,7 @@ namespace OpenSim.Region.Physics.OdePlugin foreach (OdeCharacter actor in _characters) { if (actor != null) - actor.Move(ODE_STEPSIZE, defects); + actor.Move(defects); } if (defects.Count != 0) { From 420015b7d0dafe956d7ab1980d8e4f499395df76 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 11 Dec 2012 04:47:40 +0000 Subject: [PATCH 17/33] missing file --- OpenSim/Region/Physics/Manager/PhysicsActor.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index 0405dadd72..e39cee7d0d 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -71,6 +71,15 @@ namespace OpenSim.Region.Physics.Manager RelativeSpeed = 0f; // for now let this one be set explicity CharacterFeet = true; // keep other plugins work as before } + + public ContactPoint(Vector3 position, Vector3 surfaceNormal, float penetrationDepth, bool feet) + { + Position = position; + SurfaceNormal = surfaceNormal; + PenetrationDepth = penetrationDepth; + RelativeSpeed = 0f; // for now let this one be set explicity + CharacterFeet = feet; // keep other plugins work as before + } } public struct ContactData From 9a253c7c04281b9f9a13dda1c098251b1d81a70a Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 11 Dec 2012 04:49:14 +0000 Subject: [PATCH 18/33] missing files remove some warnings... --- OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs | 4 ++-- .../Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs | 1 - OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs index 7dddab6175..faa948809f 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs @@ -2521,7 +2521,7 @@ namespace OpenSim.Region.Physics.OdePlugin prm.m_collisionCategories = m_collisionCategories; prm.m_collisionFlags = m_collisionFlags; - if (prm.prim_geom != null) + if (prm.prim_geom != IntPtr.Zero) { if (prm.m_NoColide) @@ -2542,7 +2542,7 @@ namespace OpenSim.Region.Physics.OdePlugin // ((OdePrim)_parent).ChildSelectedChange(true); - if (prim_geom != null) + if (prim_geom != IntPtr.Zero) { if (m_NoColide) { diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs index f449099233..561ab1c0aa 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs @@ -555,7 +555,6 @@ namespace OpenSim.Region.Physics.OdePlugin break; default: - return; break; } } diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs index f8d7195443..88788201de 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs @@ -515,7 +515,7 @@ namespace OpenSim.Region.Physics.OdePlugin odetimestepMS = (int)(1000.0f * ODE_STEPSIZE +0.5f); ContactgeomsArray = Marshal.AllocHGlobal(contactsPerCollision * d.ContactGeom.unmanagedSizeOf); - GlobalContactsArray = GlobalContactsArray = Marshal.AllocHGlobal(maxContactsbeforedeath * d.Contact.unmanagedSizeOf); + GlobalContactsArray = Marshal.AllocHGlobal(maxContactsbeforedeath * d.Contact.unmanagedSizeOf); m_materialContactsData[(int)Material.Stone].mu = 0.8f; m_materialContactsData[(int)Material.Stone].bounce = 0.4f; From 28ea08c3e234f8ca3c6590af4045349af7fed844 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 11 Dec 2012 17:14:32 +0000 Subject: [PATCH 19/33] fix let other phys plugins work.. broken when added feetOffset --- OpenSim/Region/Physics/Manager/PhysicsScene.cs | 10 ++-------- OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs | 7 ++++--- OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | 4 ++-- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs index c07213e0b8..cdffa6b3c6 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs @@ -147,15 +147,9 @@ namespace OpenSim.Region.Physics.Manager return ret; } - public virtual PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size,float feetOffset, bool isFlying) + public virtual PhysicsActor AddAvatar(uint localID, string avName, Vector3 position, Vector3 size, float feetOffset, bool isFlying) { - return null; - } - - public virtual PhysicsActor AddAvatar(uint localID,string avName, Vector3 position, Vector3 size, float feetOffset, bool isFlying) - { - PhysicsActor ret = AddAvatar(avName, position, size,feetOffset, isFlying); - if (ret != null) ret.LocalID = localID; + PhysicsActor ret = AddAvatar(localID, avName, position, size, isFlying); return ret; } diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs index 1b25faf16f..b769c8895e 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs @@ -165,9 +165,10 @@ namespace OpenSim.Region.Physics.OdePlugin - public OdeCharacter(String avName, OdeScene parent_scene, Vector3 pos, Vector3 pSize, float pfeetOffset, float density, float walk_divisor, float rundivisor) + public OdeCharacter(uint localID, String avName, OdeScene parent_scene, Vector3 pos, Vector3 pSize, float pfeetOffset, float density, float walk_divisor, float rundivisor) { m_uuid = UUID.Random(); + m_localID = localID; timeStep = parent_scene.ODE_STEPSIZE; invtimeStep = 1 / timeStep; @@ -1209,7 +1210,7 @@ namespace OpenSim.Region.Physics.OdePlugin d.AABB aabb; d.GeomGetAABB(feetbox, out aabb); - float chrminZ = aabb.MinZ - 0.02f; // move up a bit + float chrminZ = aabb.MinZ; ; // move up a bit Vector3 posch = localpos; float ftmp; @@ -1252,7 +1253,7 @@ namespace OpenSim.Region.Physics.OdePlugin contact.PenetrationDepth = depth; contact.Position.X = localpos.X; contact.Position.Y = localpos.Y; - contact.Position.Z = chrminZ; + contact.Position.Z = terrainheight; contact.SurfaceNormal.X = 0.0f; contact.SurfaceNormal.Y = 0.0f; contact.SurfaceNormal.Z = -1f; diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs index 88788201de..15eb01fa21 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs @@ -1251,13 +1251,13 @@ namespace OpenSim.Region.Physics.OdePlugin #region Add/Remove Entities - public override PhysicsActor AddAvatar(string avName, Vector3 position, Vector3 size, float feetOffset, bool isFlying) + public override PhysicsActor AddAvatar(uint localID, string avName, Vector3 position, Vector3 size, float feetOffset, bool isFlying) { Vector3 pos; pos.X = position.X; pos.Y = position.Y; pos.Z = position.Z; - OdeCharacter newAv = new OdeCharacter(avName, this, pos, size, feetOffset, avDensity, avMovementDivisorWalk, avMovementDivisorRun); + OdeCharacter newAv = new OdeCharacter(localID,avName, this, pos, size, feetOffset, avDensity, avMovementDivisorWalk, avMovementDivisorRun); newAv.Flying = isFlying; newAv.MinimumGroundFlightOffset = minimumGroundFlightOffset; From f35e3c6fe04327ad4bc9b9864663910ea2b5d717 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 11 Dec 2012 19:38:44 +0000 Subject: [PATCH 20/33] changes on the fast speed avatars collider, collisions from above, etc --- .../Physics/UbitOdePlugin/ODECharacter.cs | 126 +++++++++--------- 1 file changed, 64 insertions(+), 62 deletions(-) diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs index b769c8895e..27a9f1cc3c 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs @@ -970,78 +970,86 @@ namespace OpenSim.Region.Physics.OdePlugin if (m_collisionException) return false; + Vector3 offset; + if (me == bbox) // if moving fast { // force a full inelastic collision m_collisionException = true; - Vector3 off = m_size * 0.5f; - off.X += contact.depth; - off.Y += contact.depth; - off.Z += contact.depth; + offset = m_size * m_orientation; + + offset.X = (float)Math.Abs(offset.X) * 0.5f + contact.depth; + offset.Y = (float)Math.Abs(offset.Y) * 0.5f + contact.depth; + offset.Z = (float)Math.Abs(offset.Z) * 0.5f + contact.depth; + if (reverse) { - off.X *= -contact.normal.X; - off.Y *= -contact.normal.Y; - off.Z *= -contact.normal.Z; + offset.X *= -contact.normal.X; + offset.Y *= -contact.normal.Y; + offset.Z *= -contact.normal.Z; } else { - off.X *= contact.normal.X; - off.Y *= contact.normal.Y; - off.Z *= contact.normal.Z; + offset.X *= contact.normal.X; + offset.Y *= contact.normal.Y; + offset.Z *= contact.normal.Z; } - off.X += contact.pos.X; - off.Y += contact.pos.Y; - off.Z += contact.pos.Z; + offset.X += contact.pos.X; + offset.Y += contact.pos.Y; + offset.Z += contact.pos.Z; - _position = off; + _position = offset; return false; } - if (me == topbox) // keep a box head - return true; + offset.X = contact.pos.X - _position.X; + offset.Y = contact.pos.Y - _position.Y; - float t; - float offx = contact.pos.X - _position.X; - float offy = contact.pos.Y - _position.Y; + if (me == topbox) + { + offset.Z = contact.pos.Z - _position.Z; + + offset.Normalize(); + + if (reverse) + { + contact.normal.X = offset.X; + contact.normal.Y = offset.Y; + contact.normal.Z = offset.Z; + } + else + { + contact.normal.X = -offset.X; + contact.normal.Y = -offset.Y; + contact.normal.Z = -offset.Z; + } + return true; + } if (me == midbox) { if (Math.Abs(contact.normal.Z) > 0.95f) - { - float nz = contact.normal.Z; - if (!reverse) - nz = -nz; + offset.Z = contact.pos.Z - _position.Z; + else + offset.Z = contact.normal.Z; - if (nz > 0) - return true; // missed head TODO - - // missed feet collision? - - - return true; - } - - t = offx * offx + offy * offy; - t = (float)Math.Sqrt(t); - t = 1 / t; - offx *= t; - offy *= t; + offset.Normalize(); if (reverse) { - contact.normal.X = offx; - contact.normal.Y = offy; + contact.normal.X = offset.X; + contact.normal.Y = offset.Y; + contact.normal.Z = offset.Z; } else { - contact.normal.X = -offx; - contact.normal.Y = -offy; + contact.normal.X = -offset.X; + contact.normal.Y = -offset.Y; + contact.normal.Z = -offset.Z; } - contact.normal.Z = 0; return true; } @@ -1063,39 +1071,33 @@ namespace OpenSim.Region.Physics.OdePlugin return true; } + offset.Z = h - feetOff; // distance from top of feetbox - float offz = h - feetOff; // distance from top of feetbox - - if (offz > 0) + if (offset.Z > 0) return false; - if (offz > -0.01) + if (offset.Z > -0.01) { - offx = 0; - offy = 0; - offz = -1.0f; + offset.X = 0; + offset.Y = 0; + offset.Z = -1.0f; } else { - t = offx * offx + offy * offy + offz * offz; - t = (float)Math.Sqrt(t); - t = 1 / t; - offx *= t; - offy *= t; - offz *= t; + offset.Normalize(); } if (reverse) { - contact.normal.X = offx; - contact.normal.Y = offy; - contact.normal.Z = offz; + contact.normal.X = offset.X; + contact.normal.Y = offset.Y; + contact.normal.Z = offset.Z; } else { - contact.normal.X = -offx; - contact.normal.Y = -offy; - contact.normal.Z = -offz; + contact.normal.X = -offset.X; + contact.normal.Y = -offset.Y; + contact.normal.Z = -offset.Z; } feetcollision = true; if (h < boneOff) @@ -1125,7 +1127,7 @@ namespace OpenSim.Region.Physics.OdePlugin float v = _velocity.Length(); if (v != 0) { - v = 6.0f / v; + v = 5.0f / v; _velocity = _velocity * v; d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z); } From 71fc9f29f92edf2956ecb25dcbcdb97d262c8a14 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 11 Dec 2012 22:53:24 +0000 Subject: [PATCH 21/33] make ubitODE ignore X and Y rotation components on avatar rotations --- .../Physics/UbitOdePlugin/ODECharacter.cs | 51 ++++++++++++++----- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs index 27a9f1cc3c..bb04ea73be 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs @@ -80,6 +80,7 @@ namespace OpenSim.Region.Physics.OdePlugin private Vector3 m_rotationalVelocity; private Vector3 m_size; private Quaternion m_orientation; + private Quaternion m_orientation2D; private float m_mass = 80f; public float m_density = 60f; private bool m_pidControllerActive = true; @@ -207,6 +208,7 @@ namespace OpenSim.Region.Physics.OdePlugin m_feetOffset = pfeetOffset; m_orientation = Quaternion.Identity; + m_orientation2D = Quaternion.Identity; m_density = density; // force lower density for testing @@ -649,7 +651,6 @@ namespace OpenSim.Region.Physics.OdePlugin { // fakeori = value; // givefakeori++; - value.Normalize(); AddChange(changes.Orientation, value); } @@ -977,7 +978,7 @@ namespace OpenSim.Region.Physics.OdePlugin // force a full inelastic collision m_collisionException = true; - offset = m_size * m_orientation; + offset = m_size * m_orientation2D; offset.X = (float)Math.Abs(offset.X) * 0.5f + contact.depth; offset.Y = (float)Math.Abs(offset.Y) * 0.5f + contact.depth; @@ -1143,10 +1144,10 @@ namespace OpenSim.Region.Physics.OdePlugin // so force it back to identity d.Quaternion qtmp; - qtmp.W = m_orientation.W; - qtmp.X = m_orientation.X; - qtmp.Y = m_orientation.Y; - qtmp.Z = m_orientation.Z; + qtmp.W = m_orientation2D.W; + qtmp.X = m_orientation2D.X; + qtmp.Y = m_orientation2D.Y; + qtmp.Z = m_orientation2D.Z; d.BodySetQuaternion(Body, ref qtmp); if (m_pidControllerActive == false) @@ -1679,14 +1680,36 @@ namespace OpenSim.Region.Physics.OdePlugin private void changeOrientation(Quaternion newOri) { - d.Quaternion myrot = new d.Quaternion(); - myrot.X = newOri.X; - myrot.Y = newOri.Y; - myrot.Z = newOri.Z; - myrot.W = newOri.W; - float t = d.JointGetAMotorAngle(Amotor, 2); - d.BodySetQuaternion(Body,ref myrot); - m_orientation = newOri; + if (m_orientation != newOri) + { + m_orientation = newOri; // keep a copy for core use + // but only use rotations around Z + + m_orientation2D.W = newOri.W; + m_orientation2D.Z = newOri.Z; + + float t = m_orientation2D.W * m_orientation2D.W + m_orientation2D.Z * m_orientation2D.Z; + if (t > 0) + { + t = 1.0f / (float)Math.Sqrt(t); + m_orientation2D.W *= t; + m_orientation2D.Z *= t; + } + else + { + m_orientation2D.W = 1.0f; + m_orientation2D.Z = 0f; + } + m_orientation2D.Y = 0f; + m_orientation2D.X = 0f; + + d.Quaternion myrot = new d.Quaternion(); + myrot.X = m_orientation2D.X; + myrot.Y = m_orientation2D.Y; + myrot.Z = m_orientation2D.Z; + myrot.W = m_orientation2D.W; + d.BodySetQuaternion(Body, ref myrot); + } } private void changeVelocity(Vector3 newVel) From 20773dcfccc04d8af14e27f87746711bfaba07b1 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 13 Dec 2012 02:55:36 +0000 Subject: [PATCH 22/33] add a Check method to flotsamAssetCache, so to check if a asset is in cache without actually loading it. Make use limited use of it in avatarfactory textures check. Also on llclientview HandleAgentTextureCached that now should work. Other asset cache modules for now will return false, so are broken. baked textures logic still unchanged. *UNTESTED* --- OpenSim/Framework/IImprovedAssetCache.cs | 1 + .../ClientStack/Linden/UDP/LLClientView.cs | 29 +++++-- .../CoreModules/Asset/CenomeAssetCache.cs | 6 ++ .../CoreModules/Asset/CoreAssetCache.cs | 4 + .../CoreModules/Asset/FlotsamAssetCache.cs | 75 +++++++++++++++++++ .../Asset/GlynnTuckerAssetCache.cs | 5 ++ .../AvatarFactory/AvatarFactoryModule.cs | 51 +++++++++---- 7 files changed, 151 insertions(+), 20 deletions(-) diff --git a/OpenSim/Framework/IImprovedAssetCache.cs b/OpenSim/Framework/IImprovedAssetCache.cs index 251215a559..a0b8b55aaa 100644 --- a/OpenSim/Framework/IImprovedAssetCache.cs +++ b/OpenSim/Framework/IImprovedAssetCache.cs @@ -33,6 +33,7 @@ namespace OpenSim.Framework { void Cache(AssetBase asset); AssetBase Get(string id); + bool Check(string id); void Expire(string id); void Clear(); } diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index ea3c6a4f81..edb1a9dabc 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -3992,7 +3992,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP const float TIME_DILATION = 1.0f; ushort timeDilation = Utils.FloatToUInt16(avgTimeDilation, 0.0f, 1.0f); - if (terseAgentUpdateBlocks.IsValueCreated) { @@ -11695,14 +11694,30 @@ namespace OpenSim.Region.ClientStack.LindenUDP cachedresp.WearableData = new AgentCachedTextureResponsePacket.WearableDataBlock[cachedtex.WearableData.Length]; - for (int i = 0; i < cachedtex.WearableData.Length; i++) + IImprovedAssetCache cache = m_scene.RequestModuleInterface(); + if (cache == null) { - cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); - cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex; - cachedresp.WearableData[i].TextureID = UUID.Zero; - cachedresp.WearableData[i].HostName = new byte[0]; + for (int i = 0; i < cachedtex.WearableData.Length; i++) + { + cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); + cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex; + cachedresp.WearableData[i].TextureID = UUID.Zero; + cachedresp.WearableData[i].HostName = new byte[0]; + } + } + else + { + for (int i = 0; i < cachedtex.WearableData.Length; i++) + { + cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); + cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex; + if(cache.Check(cachedtex.WearableData[i].ID.ToString())) + cachedresp.WearableData[i].TextureID = UUID.Zero; + else + cachedresp.WearableData[i].TextureID = UUID.Zero; + cachedresp.WearableData[i].HostName = new byte[0]; + } } - cachedresp.Header.Zerocoded = true; OutPacket(cachedresp, ThrottleOutPacketType.Task); diff --git a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs index e40caeca4d..f43305ff40 100644 --- a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs @@ -194,6 +194,12 @@ namespace OpenSim.Region.CoreModules.Asset #region IImprovedAssetCache Members + + public bool Check(string id) + { + return false; + } + /// /// Cache asset. /// diff --git a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs index 9742a5caa4..58ce61ac4e 100644 --- a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs @@ -112,6 +112,10 @@ namespace OpenSim.Region.CoreModules.Asset //////////////////////////////////////////////////////////// // IImprovedAssetCache // + public bool Check(string id) + { + return false; + } public void Cache(AssetBase asset) { diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index b1bb56bb0b..a0f1e8c560 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs @@ -348,6 +348,17 @@ namespace OpenSim.Region.CoreModules.Asset return asset; } + private bool CheckFromMemoryCache(string id) + { + AssetBase asset = null; + + if (m_MemoryCache.TryGetValue(id, out asset)) + return true; + + return false; + } + + /// /// Try to get an asset from the file cache. /// @@ -420,6 +431,50 @@ namespace OpenSim.Region.CoreModules.Asset return asset; } + private bool CheckFromFileCache(string id) + { + bool found = false; + + string filename = GetFileName(id); + if (File.Exists(filename)) + { + // actually check if we can open it, and so update expire + FileStream stream = null; + try + { + stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read); + if (stream != null) + { + found = true; + stream.Close(); + } + + } + catch (System.Runtime.Serialization.SerializationException e) + { + found = false; + m_log.ErrorFormat( + "[FLOTSAM ASSET CACHE]: Failed to check file {0} for asset {1}. Exception {2} {3}", + filename, id, e.Message, e.StackTrace); + + // If there was a problem deserializing the asset, the asset may + // either be corrupted OR was serialized under an old format + // {different version of AssetBase} -- we should attempt to + // delete it and re-cache + File.Delete(filename); + } + catch (Exception e) + { + found = false; + m_log.ErrorFormat( + "[FLOTSAM ASSET CACHE]: Failed to check file {0} for asset {1}. Exception {2} {3}", + filename, id, e.Message, e.StackTrace); + } + } + + return found; + } + public AssetBase Get(string id) { m_Requests++; @@ -456,11 +511,26 @@ namespace OpenSim.Region.CoreModules.Asset return asset; } + public bool Check(string id) + { + if (m_MemoryCacheEnabled && CheckFromMemoryCache(id)) + return true; + + if (m_FileCacheEnabled && CheckFromFileCache(id)) + return true; + return false; + } + public AssetBase GetCached(string id) { return Get(id); } + public AssetBase CheckCached(string id) + { + return Get(id); + } + public void Expire(string id) { if (m_LogLevel >= 2) @@ -941,6 +1011,11 @@ namespace OpenSim.Region.CoreModules.Asset return asset.Data; } + public bool CheckData(string id) + { + return Check(id); ; + } + public bool Get(string id, object sender, AssetRetrieved handler) { AssetBase asset = Get(id); diff --git a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs index 9592ca0019..ce9b5467f6 100644 --- a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs @@ -115,6 +115,11 @@ namespace OpenSim.Region.CoreModules.Asset // IImprovedAssetCache // + public bool Check(string id) + { + return false; + } + public void Cache(AssetBase asset) { if (asset != null) diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 4c42397cc5..3532b1dfe2 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs @@ -361,6 +361,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory public bool ValidateBakedTextureCache(IScenePresence sp) { bool defonly = true; // are we only using default textures + IImprovedAssetCache cache = m_scene.RequestModuleInterface(); // Process the texture entry for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) @@ -385,8 +386,16 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory defonly = false; // found a non-default texture reference - if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) - return false; + if (cache != null) + { + if (!cache.Check(face.TextureID.ToString())) + return false; + } + else + { + if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) + return false; + } } // m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1}", sp.Name, sp.UUID); @@ -398,6 +407,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory public int RequestRebake(IScenePresence sp, bool missingTexturesOnly) { int texturesRebaked = 0; + IImprovedAssetCache cache = m_scene.RequestModuleInterface(); for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) { @@ -421,21 +431,36 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory if (missingTexturesOnly) { - if (m_scene.AssetService.Get(face.TextureID.ToString()) != null) + if (cache != null) { - continue; + if (cache.Check(face.TextureID.ToString())) + continue; + else + { + m_log.DebugFormat( + "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.", + face.TextureID, idx, sp.Name); + } } else { - // On inter-simulator teleports, this occurs if baked textures are not being stored by the - // grid asset service (which means that they are not available to the new region and so have - // to be re-requested from the client). - // - // The only available core OpenSimulator behaviour right now - // is not to store these textures, temporarily or otherwise. - m_log.DebugFormat( - "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.", - face.TextureID, idx, sp.Name); + if (m_scene.AssetService.Get(face.TextureID.ToString()) != null) + { + continue; + } + + else + { + // On inter-simulator teleports, this occurs if baked textures are not being stored by the + // grid asset service (which means that they are not available to the new region and so have + // to be re-requested from the client). + // + // The only available core OpenSimulator behaviour right now + // is not to store these textures, temporarily or otherwise. + m_log.DebugFormat( + "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.", + face.TextureID, idx, sp.Name); + } } } else From b3a77c16bd2ad83076ddf19275b2f104210bba07 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 13 Dec 2012 07:34:27 +0000 Subject: [PATCH 23/33] FIX small avatars movement on terrain. (avatar appearance getting even more messy) --- .../ClientStack/Linden/UDP/LLClientView.cs | 4 +- .../Region/Framework/Scenes/ScenePresence.cs | 40 +++++++++++++++++-- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index edb1a9dabc..4860da051a 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -5122,7 +5122,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP update.PCode = (byte)PCode.Avatar; update.ProfileCurve = 1; update.PSBlock = Utils.EmptyBytes; - update.Scale = new Vector3(0.45f, 0.6f, 1.9f); + update.Scale = data.Appearance.AvatarSize; +// update.Scale.Z -= 0.2f; + update.Text = Utils.EmptyBytes; update.TextColor = new byte[4]; diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 9ada5bb24e..6299a8e3e9 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -140,6 +140,8 @@ namespace OpenSim.Region.Framework.Scenes private Vector3 m_lastPosition; private Quaternion m_lastRotation; private Vector3 m_lastVelocity; + private Vector3 m_lastSize = new Vector3(0.45f,0.6f,1.9f); + private Vector3? m_forceToApply; private int m_userFlags; @@ -563,6 +565,23 @@ namespace OpenSim.Region.Framework.Scenes } } + public override Vector3 AngularVelocity + { + get + { + if (PhysicsActor != null) + { + m_rotationalvelocity = PhysicsActor.RotationalVelocity; + + // m_log.DebugFormat( + // "[SCENE PRESENCE]: Set velocity {0} for {1} in {2} via getting Velocity!", + // m_velocity, Name, Scene.RegionInfo.RegionName); + } + + return m_rotationalvelocity; + } + } + private Quaternion m_bodyRot = Quaternion.Identity; public Quaternion Rotation @@ -1264,6 +1283,7 @@ namespace OpenSim.Region.Framework.Scenes { if (PhysicsActor != null && !IsChildAgent) PhysicsActor.setAvatarSize(size, feetoffset); + } /// @@ -2572,9 +2592,13 @@ namespace OpenSim.Region.Framework.Scenes // NOTE: Velocity is not the same as m_velocity. Velocity will attempt to // grab the latest PhysicsActor velocity, whereas m_velocity is often // storing a requested force instead of an actual traveling velocity + if (Appearance.AvatarSize != m_lastSize) + { + m_lastSize = Appearance.AvatarSize; + SendAvatarDataToAllAgents(); + } - // Throw away duplicate or insignificant updates - if (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || + else if (!Rotation.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) || !Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) || !m_pos.ApproxEquals(m_lastPosition, POSITION_TOLERANCE)) { @@ -2872,6 +2896,8 @@ namespace OpenSim.Region.Framework.Scenes avatar.ControllingClient.SendAppearance( UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); + + } #endregion @@ -3517,10 +3543,9 @@ namespace OpenSim.Region.Framework.Scenes // m_lastColCount = coldata.Count; // } - CollisionPlane = Vector4.UnitW; - if (coldata.Count != 0) { +/* switch (Animator.CurrentMovementAnimation) { case "STAND": @@ -3529,6 +3554,7 @@ namespace OpenSim.Region.Framework.Scenes case "CROUCH": case "CROUCHWALK": { + */ ContactPoint lowest; lowest.SurfaceNormal = Vector3.Zero; lowest.Position = Vector3.Zero; @@ -3548,10 +3574,16 @@ namespace OpenSim.Region.Framework.Scenes lowest.SurfaceNormal = -lowest.SurfaceNormal; CollisionPlane = new Vector4(lowest.SurfaceNormal, Vector3.Dot(lowest.Position, lowest.SurfaceNormal)); } + else + CollisionPlane = Vector4.UnitW; +/* } break; } +*/ } + else + CollisionPlane = Vector4.UnitW; RaiseCollisionScriptEvents(coldata); From c0368f4143ae13b847bc6b10198de7f09414caee Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 13 Dec 2012 07:39:10 +0000 Subject: [PATCH 24/33] fix coment out code not in use --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 6299a8e3e9..92a474815e 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -564,7 +564,7 @@ namespace OpenSim.Region.Framework.Scenes // Scene.RegionInfo.RegionName, Name, m_velocity); } } - +// public override Vector3 AngularVelocity { get @@ -581,7 +581,7 @@ namespace OpenSim.Region.Framework.Scenes return m_rotationalvelocity; } } - +// private Quaternion m_bodyRot = Quaternion.Identity; public Quaternion Rotation From 94a659a9e08cb5e6cb4d5b3aa7d46b11217098a0 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 13 Dec 2012 07:46:33 +0000 Subject: [PATCH 25/33] fix the 'fix' --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 92a474815e..45cae51080 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -564,7 +564,7 @@ namespace OpenSim.Region.Framework.Scenes // Scene.RegionInfo.RegionName, Name, m_velocity); } } -// +/* public override Vector3 AngularVelocity { get @@ -581,7 +581,7 @@ namespace OpenSim.Region.Framework.Scenes return m_rotationalvelocity; } } -// +/* private Quaternion m_bodyRot = Quaternion.Identity; public Quaternion Rotation From 5ad424a79278e0079d1f2540d470541f276ce71c Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 13 Dec 2012 07:48:29 +0000 Subject: [PATCH 26/33] right fix this time ?? --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 45cae51080..e026ffd549 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -581,7 +581,7 @@ namespace OpenSim.Region.Framework.Scenes return m_rotationalvelocity; } } -/* +*/ private Quaternion m_bodyRot = Quaternion.Identity; public Quaternion Rotation From 7a093df24b470a6c80d67b1f8572f37a2a350521 Mon Sep 17 00:00:00 2001 From: Melanie Date: Fri, 14 Dec 2012 03:35:55 +0100 Subject: [PATCH 27/33] Prevent a failed user relogi from throwing exceptions in poll services --- OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs | 2 +- OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs index 6b33561476..908f628274 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs @@ -377,7 +377,7 @@ namespace OpenSim.Region.ClientStack.Linden protocol = "https"; } caps.RegisterHandler("GetMesh", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl)); - m_pollservices.Add(agentID, args); + m_pollservices[agentID] = args; m_capsDict[agentID] = capUrl; diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index dd87671cc0..d4dbfb97fc 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs @@ -333,7 +333,7 @@ namespace OpenSim.Region.ClientStack.Linden protocol = "https"; } caps.RegisterHandler("GetTexture", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl)); - m_pollservices.Add(agentID, args); + m_pollservices[agentID] = args; m_capsDict[agentID] = capUrl; } From d2695cb3f7356a5c4047bbef2ac8f83fc8350976 Mon Sep 17 00:00:00 2001 From: teravus Date: Sat, 15 Dec 2012 16:26:03 -0500 Subject: [PATCH 28/33] * Fix for Prim Locking. Prior to the merge, it was just a clone of the root part to each of the child parts. --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index b9f9c86cd1..0b82093003 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3439,17 +3439,17 @@ namespace OpenSim.Region.Framework.Scenes public void AdjustChildPrimPermissions() { - uint newOwnerMask = (uint)PermissionMask.All & 0xfffffff8; // Mask folded bits - uint foldedPerms = RootPart.OwnerMask & 3; + //uint newOwnerMask = (uint)PermissionMask.All & 0xfffffff8; // Mask folded bits + //uint foldedPerms = RootPart.OwnerMask & 3; ForEachPart(part => { - newOwnerMask &= part.BaseMask; + //newOwnerMask &= part.BaseMask; if (part != RootPart) part.ClonePermissions(RootPart); }); - RootPart.OwnerMask = newOwnerMask | foldedPerms; + //RootPart.OwnerMask = newOwnerMask | foldedPerms; RootPart.ScheduleFullUpdate(); } From 7d8c2b342c77cd4c5b26ee9500b5d9383b8bae77 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 16 Dec 2012 02:05:01 +0100 Subject: [PATCH 29/33] Fix locking objects --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index b9f9c86cd1..4ad8b11098 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3449,7 +3449,9 @@ namespace OpenSim.Region.Framework.Scenes part.ClonePermissions(RootPart); }); - RootPart.OwnerMask = newOwnerMask | foldedPerms; + uint lockMask = ~(uint)PermissionMask.Move; + uint lockBit = RootPart.OwnerMask & (uint)PermissionMask.Move; + RootPart.OwnerMask = (RootPart.OwnerMask & lockBit) | ((newOwnerMask | foldedPerms) & lockMask); RootPart.ScheduleFullUpdate(); } From d003aa2e7b690d21f7d6094431c16ad0de5776d4 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 17 Dec 2012 01:40:48 +0000 Subject: [PATCH 30/33] * TEST * unscripted sit --- .../Region/Framework/Scenes/ScenePresence.cs | 236 ++++-------------- .../Physics/UbitOdePlugin/ODESitAvatar.cs | 183 ++++++++++++++ .../Region/Physics/UbitOdePlugin/OdeScene.cs | 15 +- 3 files changed, 251 insertions(+), 183 deletions(-) create mode 100644 OpenSim/Region/Physics/UbitOdePlugin/ODESitAvatar.cs diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index e026ffd549..7ff163b4da 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2103,12 +2103,29 @@ namespace OpenSim.Region.Framework.Scenes } else { - if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) - { +// if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) +// { // m_log.DebugFormat( // "[SCENE PRESENCE]: Sitting {0} on {1} {2} because sit target is unset and within 10m", // Name, part.Name, part.LocalId); + if (m_scene.PhysicsScene != null && + part.PhysActor != null && + Util.GetDistanceTo(AbsolutePosition, pos) <= 30) + { + + Vector3 camdif = CameraPosition - part.AbsolutePosition; + camdif.Normalize(); + +// m_log.InfoFormat("sit {0} {1}", offset.ToString(), camdif.ToString()); + + if (m_scene.PhysicsScene.SitAvatar(part.PhysActor, AbsolutePosition, CameraPosition, offset, new Vector3(0.35f, 0, 0.65f), PhysicsSitResponse) != 0) + return; + } + + if (Util.GetDistanceTo(AbsolutePosition, pos) <= 10) + { + AbsolutePosition = pos + new Vector3(0.0f, 0.0f, m_sitAvatarHeight); canSit = true; } @@ -2196,197 +2213,54 @@ namespace OpenSim.Region.Framework.Scenes SendSitResponse(targetID, offset, Quaternion.Identity); } - /* - public void SitRayCastAvatarPosition(SceneObjectPart part) + public void PhysicsSitResponse(int status, uint partID, Vector3 offset, Quaternion Orientation) { - Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; - Vector3 StartRayCastPosition = AbsolutePosition; - Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); - float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); - m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionResponse); - } - public void SitRayCastAvatarPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) - { - SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); - if (part != null) - { - if (hitYN) - { - if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) - { - SitRaycastFindEdge(collisionPoint, normal); - m_log.DebugFormat("[SIT]: Raycast Avatar Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); - } - else - { - SitRayCastAvatarPositionCameraZ(part); - } - } - else - { - SitRayCastAvatarPositionCameraZ(part); - } - } - else + if (status < 0) { ControllingClient.SendAlertMessage("Sit position no longer exists"); - m_requestedSitTargetUUID = UUID.Zero; - m_requestedSitTargetID = 0; - m_requestedSitOffset = Vector3.Zero; + return; } - } + if (status == 0) + return; - public void SitRayCastAvatarPositionCameraZ(SceneObjectPart part) - { - // Next, try to raycast from the camera Z position - Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; - Vector3 StartRayCastPosition = AbsolutePosition; StartRayCastPosition.Z = CameraPosition.Z; - Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); - float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); - m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastAvatarPositionCameraZResponse); - } - - public void SitRayCastAvatarPositionCameraZResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) - { - SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); - if (part != null) + SceneObjectPart part = m_scene.GetSceneObjectPart(partID); + if (part == null || part.ParentGroup.IsAttachment) { - if (hitYN) - { - if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) - { - SitRaycastFindEdge(collisionPoint, normal); - m_log.DebugFormat("[SIT]: Raycast Avatar Position + CameraZ succeeded at point: {0}, normal:{1}", collisionPoint, normal); - } - else - { - SitRayCastCameraPosition(part); - } - } - else - { - SitRayCastCameraPosition(part); - } - } - else - { - ControllingClient.SendAlertMessage("Sit position no longer exists"); - m_requestedSitTargetUUID = UUID.Zero; - m_requestedSitTargetID = 0; - m_requestedSitOffset = Vector3.Zero; + return; } +// m_log.InfoFormat("physsit {0} {1}", offset.ToString(),Orientation.ToString()); + + part.AddSittingAvatar(UUID); + + Vector3 cameraAtOffset = part.GetCameraAtOffset(); + Vector3 cameraEyeOffset = part.GetCameraEyeOffset(); + bool forceMouselook = part.GetForceMouselook(); + + ControllingClient.SendSitResponse( + part.UUID, offset, Orientation, false, cameraAtOffset, cameraEyeOffset, forceMouselook); + + part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); + + // assuming no autopilot in use + Velocity = Vector3.Zero; + RemoveFromPhysicalScene(); + + Rotation = Orientation; + m_pos = offset; + + m_requestedSitTargetID = 0; // invalidate the viewer sit comand for now + part.ParentGroup.AddAvatar(UUID); + + ParentPart = part; + ParentID = part.LocalId; + + Animator.TrySetMovementAnimation("SIT"); + SendAvatarDataToAllAgents(); } - public void SitRayCastCameraPosition(SceneObjectPart part) - { - // Next, try to raycast from the camera position - Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; - Vector3 StartRayCastPosition = CameraPosition; - Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); - float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); - m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastCameraPositionResponse); - } - - public void SitRayCastCameraPositionResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) - { - SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); - if (part != null) - { - if (hitYN) - { - if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) - { - SitRaycastFindEdge(collisionPoint, normal); - m_log.DebugFormat("[SIT]: Raycast Camera Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); - } - else - { - SitRayHorizontal(part); - } - } - else - { - SitRayHorizontal(part); - } - } - else - { - ControllingClient.SendAlertMessage("Sit position no longer exists"); - m_requestedSitTargetUUID = UUID.Zero; - m_requestedSitTargetID = 0; - m_requestedSitOffset = Vector3.Zero; - } - - } - - public void SitRayHorizontal(SceneObjectPart part) - { - // Next, try to raycast from the avatar position to fwd - Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; - Vector3 StartRayCastPosition = CameraPosition; - Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); - float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); - m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastHorizontalResponse); - } - - public void SitRayCastHorizontalResponse(bool hitYN, Vector3 collisionPoint, uint localid, float pdistance, Vector3 normal) - { - SceneObjectPart part = FindNextAvailableSitTarget(m_requestedSitTargetUUID); - if (part != null) - { - if (hitYN) - { - if (collisionPoint.ApproxEquals(m_requestedSitOffset + part.AbsolutePosition, 0.2f)) - { - SitRaycastFindEdge(collisionPoint, normal); - m_log.DebugFormat("[SIT]: Raycast Horizontal Position succeeded at point: {0}, normal:{1}", collisionPoint, normal); - // Next, try to raycast from the camera position - Vector3 EndRayCastPosition = part.AbsolutePosition + m_requestedSitOffset; - Vector3 StartRayCastPosition = CameraPosition; - Vector3 direction = Vector3.Normalize(EndRayCastPosition - StartRayCastPosition); - float distance = Vector3.Distance(EndRayCastPosition, StartRayCastPosition); - //m_scene.PhysicsScene.RaycastWorld(StartRayCastPosition, direction, distance, SitRayCastResponseAvatarPosition); - } - else - { - ControllingClient.SendAlertMessage("Sit position not accessable."); - m_requestedSitTargetUUID = UUID.Zero; - m_requestedSitTargetID = 0; - m_requestedSitOffset = Vector3.Zero; - } - } - else - { - ControllingClient.SendAlertMessage("Sit position not accessable."); - m_requestedSitTargetUUID = UUID.Zero; - m_requestedSitTargetID = 0; - m_requestedSitOffset = Vector3.Zero; - } - } - else - { - ControllingClient.SendAlertMessage("Sit position no longer exists"); - m_requestedSitTargetUUID = UUID.Zero; - m_requestedSitTargetID = 0; - m_requestedSitOffset = Vector3.Zero; - } - - } - - private void SitRaycastFindEdge(Vector3 collisionPoint, Vector3 collisionNormal) - { - int i = 0; - //throw new NotImplementedException(); - //m_requestedSitTargetUUID = UUID.Zero; - //m_requestedSitTargetID = 0; - //m_requestedSitOffset = Vector3.Zero; - - SendSitResponse(ControllingClient, m_requestedSitTargetUUID, collisionPoint - m_requestedSitOffset, Quaternion.Identity); - } - */ public void HandleAgentSit(IClientAPI remoteClient, UUID agentID) { diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODESitAvatar.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODESitAvatar.cs new file mode 100644 index 0000000000..225bff8e65 --- /dev/null +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODESitAvatar.cs @@ -0,0 +1,183 @@ +/* + * 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. + */ +// Ubit 2012 +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Text; +using OpenSim.Framework; +using OpenSim.Region.Physics.Manager; +using OdeAPI; +using log4net; +using OpenMetaverse; + +namespace OpenSim.Region.Physics.OdePlugin +{ + /// + /// + public class ODESitAvatar + { + private OdeScene m_scene; + private ODERayCastRequestManager m_raymanager; + + public ODESitAvatar(OdeScene pScene, ODERayCastRequestManager raymanager) + { + m_scene = pScene; + m_raymanager = raymanager; + } + + private static Vector3 SitAjust = new Vector3(0, 0, 0.4f); + + public void Sit(PhysicsActor actor, Vector3 avPos, Vector3 avCameraPosition, Vector3 offset, Vector3 avOffset, SitAvatarCallback PhysicsSitResponse) + { + if (!m_scene.haveActor(actor) || !(actor is OdePrim) || ((OdePrim)actor).prim_geom == IntPtr.Zero) + { + PhysicsSitResponse(-1, actor.LocalID, offset, Quaternion.Identity); + return; + } + + IntPtr geom = ((OdePrim)actor).prim_geom; + + d.Vector3 dtmp = d.GeomGetPosition(geom); + Vector3 geopos; + geopos.X = dtmp.X; + geopos.Y = dtmp.Y; + geopos.Z = dtmp.Z; + + + d.AABB aabb; + Quaternion ori; + d.Quaternion qtmp; + d.GeomCopyQuaternion(geom, out qtmp); + Quaternion geomOri; + geomOri.X = qtmp.X; + geomOri.Y = qtmp.Y; + geomOri.Z = qtmp.Z; + geomOri.W = qtmp.W; + Quaternion geomInvOri; + geomInvOri.X = -qtmp.X; + geomInvOri.Y = -qtmp.Y; + geomInvOri.Z = -qtmp.Z; + geomInvOri.W = qtmp.W; + + Vector3 target = geopos + offset; + Vector3 rayDir = target - avCameraPosition; + float raylen = rayDir.Length(); + float t = 1 / raylen; + rayDir.X *= t; + rayDir.Y *= t; + rayDir.Z *= t; + + raylen += 0.5f; + List rayResults; + + rayResults = m_scene.RaycastActor(actor, avCameraPosition, rayDir , raylen, 1); + if (rayResults.Count == 0 || rayResults[0].ConsumerID != actor.LocalID) + { + d.GeomGetAABB(geom,out aabb); + offset = new Vector3(avOffset.X, 0, aabb.MaxZ + avOffset.Z - geopos.Z); + ori = geomInvOri; + offset *= geomInvOri; + + PhysicsSitResponse(1, actor.LocalID, offset, ori); + return; + } + + offset = rayResults[0].Pos - geopos; + double ang; + float s; + float c; + + d.GeomClassID geoclass = d.GeomGetClass(geom); + + if (geoclass == d.GeomClassID.SphereClass) + { + float r = d.GeomSphereGetRadius(geom); + + offset.Normalize(); + offset *= r; + + ang = Math.Atan2(offset.Y, offset.X); + ang *= 0.5d; + s = (float)Math.Sin(ang); + c = (float)Math.Cos(ang); + + ori = new Quaternion(0, 0, s, c); + + if (r < 0.4f) + { + offset = new Vector3(0, 0, r); + } + else if (offset.Z < 0.4f) + { + t = offset.Z; + float rsq = r * r; + + t = 1.0f / (rsq - t * t); + offset.X *= t; + offset.Y *= t; + offset.Z = 0.4f; + t = rsq - 0.16f; + offset.X *= t; + offset.Y *= t; + } + + offset += avOffset * ori; + + ori = geomInvOri * ori; + offset *= geomInvOri; + + PhysicsSitResponse(1, actor.LocalID, offset, ori); + return; + } + + Vector3 norm = rayResults[0].Normal; + + if (norm.Z < 0) + { + PhysicsSitResponse(0, actor.LocalID, offset, Quaternion.Identity); + return; + } + + ang = Math.Atan2(-rayDir.Y, -rayDir.X); + ang *= 0.5d; + s = (float)Math.Sin(ang); + c = (float)Math.Cos(ang); + + ori = new Quaternion(0, 0, s, c); + + offset += avOffset * ori; + + ori = geomInvOri * ori; + offset *= geomInvOri; + + PhysicsSitResponse(1, actor.LocalID, offset, ori); + return; + } + } +} \ No newline at end of file diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs index 15eb01fa21..fbf2f0dabd 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs @@ -362,8 +362,7 @@ namespace OpenSim.Region.Physics.OdePlugin nearCallback = near; - m_rayCastManager = new ODERayCastRequestManager(this); - + m_rayCastManager = new ODERayCastRequestManager(this); lock (OdeLock) { @@ -2711,5 +2710,17 @@ namespace OpenSim.Region.Physics.OdePlugin } return new List(); } + + public override int SitAvatar(PhysicsActor actor, Vector3 AbsolutePosition, Vector3 CameraPosition, Vector3 offset, Vector3 AvatarSize, SitAvatarCallback PhysicsSitResponse) + { + Util.FireAndForget( delegate + { + ODESitAvatar sitAvatar = new ODESitAvatar(this, m_rayCastManager); + if(sitAvatar != null) + sitAvatar.Sit(actor, AbsolutePosition, CameraPosition, offset, AvatarSize, PhysicsSitResponse); + }); + return 1; + } + } } From 9d1a6558d9e65ab70703cea15b3752c33c4ee244 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 17 Dec 2012 01:43:16 +0000 Subject: [PATCH 31/33] *TESTP unscripted sit: missing files --- OpenSim/Region/Physics/Manager/PhysicsActor.cs | 1 + OpenSim/Region/Physics/Manager/PhysicsScene.cs | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index e39cee7d0d..9338130400 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -411,6 +411,7 @@ namespace OpenSim.Region.Physics.Manager // Warning in a parent part it returns itself, not null public virtual PhysicsActor ParentActor { get { return this; } } + } public class NullPhysicsActor : PhysicsActor diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs index cdffa6b3c6..a442cf0970 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs @@ -38,6 +38,7 @@ namespace OpenSim.Region.Physics.Manager public delegate void RaycastCallback(bool hitYN, Vector3 collisionPoint, uint localid, float distance, Vector3 normal); public delegate void RayCallback(List list); + public delegate void SitAvatarCallback(int status, uint partID, Vector3 offset, Quaternion Orientation); public delegate void JointMoved(PhysicsJoint joint); public delegate void JointDeactivated(PhysicsJoint joint); @@ -357,5 +358,9 @@ namespace OpenSim.Region.Physics.Manager return new List(); } + public virtual int SitAvatar(PhysicsActor actor, Vector3 AbsolutePosition, Vector3 CameraPosition, Vector3 offset, Vector3 AvatarSize, SitAvatarCallback PhysicsSitResponse) + { + return 0; + } } } From 861477d85e794d067f372587ccf56d8887e5ec63 Mon Sep 17 00:00:00 2001 From: Melanie Date: Tue, 18 Dec 2012 09:32:05 +0100 Subject: [PATCH 32/33] Fix locking for good --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 0b974c69b1..4ad8b11098 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3439,12 +3439,12 @@ namespace OpenSim.Region.Framework.Scenes public void AdjustChildPrimPermissions() { - //uint newOwnerMask = (uint)PermissionMask.All & 0xfffffff8; // Mask folded bits - //uint foldedPerms = RootPart.OwnerMask & 3; + uint newOwnerMask = (uint)PermissionMask.All & 0xfffffff8; // Mask folded bits + uint foldedPerms = RootPart.OwnerMask & 3; ForEachPart(part => { - //newOwnerMask &= part.BaseMask; + newOwnerMask &= part.BaseMask; if (part != RootPart) part.ClonePermissions(RootPart); }); From d1dd5a8ba9f707e63597d42cbe199a3f7ec15fe7 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 19 Dec 2012 13:04:41 +0100 Subject: [PATCH 33/33] Add the interfaces for the new Avination baked texture cache service --- .../Interfaces/IBakedTextureModule.cs | 19 +++++++++++++++++++ .../Interfaces/IBakedTextureService.cs | 17 +++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 OpenSim/Region/Framework/Interfaces/IBakedTextureModule.cs create mode 100644 OpenSim/Services/Interfaces/IBakedTextureService.cs diff --git a/OpenSim/Region/Framework/Interfaces/IBakedTextureModule.cs b/OpenSim/Region/Framework/Interfaces/IBakedTextureModule.cs new file mode 100644 index 0000000000..d63898acd8 --- /dev/null +++ b/OpenSim/Region/Framework/Interfaces/IBakedTextureModule.cs @@ -0,0 +1,19 @@ +//////////////////////////////////////////////////////////////// +// +// (c) 2009, 2010 Careminster Limited and Melanie Thielker +// +// All rights reserved +// +using System; +using Nini.Config; +using OpenSim.Framework; +using OpenMetaverse; + +namespace OpenSim.Services.Interfaces +{ + public interface IBakedTextureModule + { + AssetBase[] Get(UUID id); + void Store(UUID id, AssetBase[] data); + } +} diff --git a/OpenSim/Services/Interfaces/IBakedTextureService.cs b/OpenSim/Services/Interfaces/IBakedTextureService.cs new file mode 100644 index 0000000000..8206ecd4ab --- /dev/null +++ b/OpenSim/Services/Interfaces/IBakedTextureService.cs @@ -0,0 +1,17 @@ +//////////////////////////////////////////////////////////////// +// +// (c) 2009, 2010 Careminster Limited and Melanie Thielker +// +// All rights reserved +// +using System; +using Nini.Config; + +namespace OpenSim.Services.Interfaces +{ + public interface IBakedTextureService + { + string Get(string id); + void Store(string id, string data); + } +}