From 1dca94c72fabf06da4d85d6acad5894dabe79c5a Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 14 Jul 2012 20:10:38 +0100 Subject: [PATCH 01/10] don't subscribe collision events for nonphysical parts only because of collision sounds. Let them be passive --- OpenSim/Region/Framework/Scenes/CollisionSounds.cs | 1 + OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs index 075724eff8..21c9ab9344 100644 --- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs @@ -31,6 +31,7 @@ using System.Reflection; using System.Collections.Generic; using OpenMetaverse; using OpenSim.Framework; +using OpenSim.Region.Physics.Manager; using log4net; namespace OpenSim.Region.Framework.Scenes diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 16a85883d1..735bd32671 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -4917,7 +4917,7 @@ namespace OpenSim.Region.Framework.Scenes pa.OnCollisionUpdate -= PhysicsCollision; - bool hassound = (CollisionSoundType >= 0 && !VolumeDetectActive); + bool hassound = (!VolumeDetectActive && CollisionSoundType >= 0 && ((Flags & PrimFlags.Physics) != 0)); scriptEvents CombinedEvents = AggregateScriptEvents; From a492b6f6934f76dc54740264d49fad958428ff36 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 14 Jul 2012 20:13:40 +0100 Subject: [PATCH 02/10] remove forgotten line... --- OpenSim/Region/Framework/Scenes/CollisionSounds.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs index 21c9ab9344..075724eff8 100644 --- a/OpenSim/Region/Framework/Scenes/CollisionSounds.cs +++ b/OpenSim/Region/Framework/Scenes/CollisionSounds.cs @@ -31,7 +31,6 @@ using System.Reflection; using System.Collections.Generic; using OpenMetaverse; using OpenSim.Framework; -using OpenSim.Region.Physics.Manager; using log4net; namespace OpenSim.Region.Framework.Scenes From 62df82b74d0f3599585f7320aeab8c6a8262f61f Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 15 Jul 2012 00:50:00 +0100 Subject: [PATCH 03/10] messing around... Let terrain and water have nullphysicsactors, let nullphyscisactors have a type water, ground or unknown (default). having this removed geom to name mapping no longer needed. Made some more methods comum to prims and characters acessible via PhysActor allowing for a more uniform access. ... --- .../Region/Physics/Manager/PhysicsActor.cs | 143 +++---- .../Physics/UbitOdePlugin/ODECharacter.cs | 16 +- .../Region/Physics/UbitOdePlugin/ODEPrim.cs | 14 +- .../UbitOdePlugin/ODERayCastRequestManager.cs | 97 +++-- .../Region/Physics/UbitOdePlugin/OdeApi.cs | 6 +- .../Region/Physics/UbitOdePlugin/OdeScene.cs | 378 +++++++----------- 6 files changed, 267 insertions(+), 387 deletions(-) diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index aaeae86f3d..a2c72c30fb 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -43,7 +43,8 @@ namespace OpenSim.Region.Physics.Manager Unknown = 0, Agent = 1, Prim = 2, - Ground = 3 + Ground = 3, + Water = 4 } public enum PIDHoverType @@ -114,7 +115,7 @@ namespace OpenSim.Region.Physics.Manager m_objCollisionList.Add(localID, contact); } else - { + { if (m_objCollisionList[localID].PenetrationDepth < contact.PenetrationDepth) m_objCollisionList[localID] = contact; } @@ -202,7 +203,7 @@ namespace OpenSim.Region.Physics.Manager /// XXX: Bizarrely, this cannot be "Terrain" or "Water" right now unless it really is simulating terrain or /// water. This is not a problem due to the formatting of names given by prims and avatars. /// - public string Name { get; protected set; } + public string Name { get; set; } /// /// This is being used by ODE joint code. @@ -230,11 +231,6 @@ namespace OpenSim.Region.Physics.Manager } } - public virtual byte[] Serialize(bool PhysIsRunning) - { - return new byte[0]; - } - public virtual void RaiseOutOfBounds(Vector3 pos) { // Make a temporary copy of the event to avoid possibility of @@ -258,10 +254,7 @@ namespace OpenSim.Region.Physics.Manager handler(e); } - public virtual void SetMaterial (int material) - { - } - + public virtual void SetMaterial (int material) { } public virtual float Density { get; set; } public virtual float GravModifier { get; set; } public virtual float Friction { get; set; } @@ -373,13 +366,21 @@ namespace OpenSim.Region.Physics.Manager public abstract void SubscribeEvents(int ms); public abstract void UnSubscribeEvents(); public abstract bool SubscribedEvents(); + + public virtual void AddCollisionEvent(uint CollidedWith, ContactPoint contact) { } + + // Warning in a parent part it returns itself, not null + public virtual PhysicsActor ParentActor { get { return this; } } + } public class NullPhysicsActor : PhysicsActor { + private ActorTypes m_actorType = ActorTypes.Unknown; + public override bool Stopped { - get{ return false; } + get{ return true; } } public override Vector3 Position @@ -396,6 +397,7 @@ namespace OpenSim.Region.Physics.Manager public override uint LocalID { + get { return 0; } set { return; } } @@ -455,49 +457,17 @@ namespace OpenSim.Region.Physics.Manager set { return; } } - public override void VehicleFloatParam(int param, float value) - { - } + public override void VehicleFloatParam(int param, float value) {} + public override void VehicleVectorParam(int param, Vector3 value) { } + public override void VehicleRotationParam(int param, Quaternion rotation) { } + public override void VehicleFlags(int param, bool remove) { } + public override void SetVolumeDetect(int param) {} + public override void SetMaterial(int material) {} + public override Vector3 CenterOfMass { get { return Vector3.Zero; }} - public override void VehicleVectorParam(int param, Vector3 value) - { + public override Vector3 GeometricCenter { get { return Vector3.Zero; }} - } - - public override void VehicleRotationParam(int param, Quaternion rotation) - { - - } - - public override void VehicleFlags(int param, bool remove) - { - - } - - public override void SetVolumeDetect(int param) - { - - } - - public override void SetMaterial(int material) - { - - } - - public override Vector3 CenterOfMass - { - get { return Vector3.Zero; } - } - - public override Vector3 GeometricCenter - { - get { return Vector3.Zero; } - } - - public override PrimitiveBaseShape Shape - { - set { return; } - } + public override PrimitiveBaseShape Shape { set { return; }} public override Vector3 Velocity { @@ -517,9 +487,7 @@ namespace OpenSim.Region.Physics.Manager set { } } - public override void CrossingFailure() - { - } + public override void CrossingFailure() {} public override Quaternion Orientation { @@ -559,8 +527,20 @@ namespace OpenSim.Region.Physics.Manager public override int PhysicsActorType { - get { return (int) ActorTypes.Unknown; } - set { return; } + get { return (int)m_actorType; } + set { + ActorTypes type = (ActorTypes)value; + switch (type) + { + case ActorTypes.Ground: + case ActorTypes.Water: + m_actorType = type; + break; + default: + m_actorType = ActorTypes.Unknown; + break; + } + } } public override bool Kinematic @@ -569,26 +549,11 @@ namespace OpenSim.Region.Physics.Manager set { return; } } - public override void link(PhysicsActor obj) - { - } - - public override void delink() - { - } - - public override void LockAngularMotion(Vector3 axis) - { - } - - public override void AddForce(Vector3 force, bool pushforce) - { - } - - public override void AddAngularForce(Vector3 force, bool pushforce) - { - - } + public override void link(PhysicsActor obj) { } + public override void delink() { } + public override void LockAngularMotion(Vector3 axis) { } + public override void AddForce(Vector3 force, bool pushforce) { } + public override void AddAngularForce(Vector3 force, bool pushforce) { } public override Vector3 RotationalVelocity { @@ -610,22 +575,10 @@ namespace OpenSim.Region.Physics.Manager public override float APIDStrength { set { return; } } public override float APIDDamping { set { return; } } - public override void SetMomentum(Vector3 momentum) - { - } - - public override void SubscribeEvents(int ms) - { - - } - public override void UnSubscribeEvents() - { - - } - public override bool SubscribedEvents() - { - return false; - } + public override void SetMomentum(Vector3 momentum) { } + public override void SubscribeEvents(int ms) { } + public override void UnSubscribeEvents() { } + public override bool SubscribedEvents() { return false; } } } diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs index b506b1c370..c363310b16 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODECharacter.cs @@ -106,7 +106,7 @@ namespace OpenSim.Region.Physics.OdePlugin private bool m_freemove = false; // private CollisionLocker ode; - private string m_name = String.Empty; +// private string m_name = String.Empty; // other filter control int m_colliderfilter = 0; int m_colliderGroundfilter = 0; @@ -183,7 +183,7 @@ namespace OpenSim.Region.Physics.OdePlugin m_isPhysical = false; // current status: no ODE information exists - m_name = avName; + Name = avName; AddChange(changes.Add, null); } @@ -218,6 +218,11 @@ namespace OpenSim.Region.Physics.OdePlugin set { m_localID = value; } } + public override PhysicsActor ParentActor + { + get { return (PhysicsActor)this; } + } + public override bool Grabbed { set { return; } @@ -740,7 +745,7 @@ namespace OpenSim.Region.Physics.OdePlugin //kill the Geometry if (Shell != IntPtr.Zero) { - _parent_scene.geom_name_map.Remove(Shell); +// _parent_scene.geom_name_map.Remove(Shell); _parent_scene.actor_name_map.Remove(Shell); _parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace); d.GeomDestroy(Shell); @@ -1115,7 +1120,7 @@ namespace OpenSim.Region.Physics.OdePlugin m_eventsubscription = 0; } - public void AddCollisionEvent(uint CollidedWith, ContactPoint contact) + public override void AddCollisionEvent(uint CollidedWith, ContactPoint contact) { if (CollisionEventsThisFrame == null) CollisionEventsThisFrame = new CollisionEventUpdate(); @@ -1184,7 +1189,7 @@ namespace OpenSim.Region.Physics.OdePlugin } AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z); - _parent_scene.geom_name_map[Shell] = m_name; + _parent_scene.actor_name_map[Shell] = (PhysicsActor)this; _parent_scene.AddCharacter(this); } @@ -1236,7 +1241,6 @@ namespace OpenSim.Region.Physics.OdePlugin Velocity = Vector3.Zero; - _parent_scene.geom_name_map[Shell] = m_name; _parent_scene.actor_name_map[Shell] = (PhysicsActor)this; } else diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs index 6d322e27be..6bf5be1fac 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODEPrim.cs @@ -176,7 +176,7 @@ namespace OpenSim.Region.Physics.OdePlugin private bool m_lastUpdateSent; public IntPtr Body = IntPtr.Zero; - public String Name { get; private set; } +// public String Name { get; private set; } private Vector3 _target_velocity; public Vector3 primOOBsize; // prim real dimensions from mesh @@ -295,14 +295,14 @@ namespace OpenSim.Region.Physics.OdePlugin set { m_localID = value; } } - public OdePrim Parent + public override PhysicsActor ParentActor { get { if (childPrim) - return (OdePrim)_parent; + return _parent; else - return this; + return (PhysicsActor)this; } } @@ -950,7 +950,7 @@ namespace OpenSim.Region.Physics.OdePlugin _parent_scene.RemoveCollisionEventReporting(this); } - public void AddCollisionEvent(uint CollidedWith, ContactPoint contact) + public override void AddCollisionEvent(uint CollidedWith, ContactPoint contact) { if (CollisionEventsThisFrame == null) CollisionEventsThisFrame = new CollisionEventUpdate(); @@ -1431,6 +1431,7 @@ namespace OpenSim.Region.Physics.OdePlugin //Console.WriteLine("SetGeom to " + prim_geom + " for " + Name); if (prim_geom != IntPtr.Zero) { + if (m_NoColide) { d.GeomSetCategoryBits(prim_geom, 0); @@ -1452,7 +1453,6 @@ namespace OpenSim.Region.Physics.OdePlugin CalcPrimBodyData(); - _parent_scene.geom_name_map[prim_geom] = Name; _parent_scene.actor_name_map[prim_geom] = this; } @@ -1526,7 +1526,7 @@ namespace OpenSim.Region.Physics.OdePlugin { if (prim_geom != IntPtr.Zero) { - _parent_scene.geom_name_map.Remove(prim_geom); +// _parent_scene.geom_name_map.Remove(prim_geom); _parent_scene.actor_name_map.Remove(prim_geom); try { diff --git a/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs b/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs index 3d108f8cde..21fe9c08f7 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/ODERayCastRequestManager.cs @@ -470,56 +470,77 @@ namespace OpenSim.Region.Physics.OdePlugin if (p2 == null) { - string name; + /* + string name; - if (!m_scene.geom_name_map.TryGetValue(g2, out name)) - return; + if (!m_scene.geom_name_map.TryGetValue(g2, out name)) + return; - if (name == "Terrain") - { - // land colision - if ((CurrentRayFilter & RayFilterFlags.land) == 0) - return; - } - else if (name == "Water") - { - if ((CurrentRayFilter & RayFilterFlags.water) == 0) - return; - } - else - return; + if (name == "Terrain") + { + // land colision + if ((CurrentRayFilter & RayFilterFlags.land) == 0) + return; + } + else if (name == "Water") + { + if ((CurrentRayFilter & RayFilterFlags.water) == 0) + return; + } + else + return; + */ + return; } else { - if (p2 is OdePrim) + switch (p2.PhysicsActorType) { - RayFilterFlags thisFlags; + case (int)ActorTypes.Prim: - if (p2.IsPhysical) - thisFlags = RayFilterFlags.physical; - else - thisFlags = RayFilterFlags.nonphysical; + RayFilterFlags thisFlags; - if (p2.Phantom) - thisFlags |= RayFilterFlags.phantom; + if (p2.IsPhysical) + thisFlags = RayFilterFlags.physical; + else + thisFlags = RayFilterFlags.nonphysical; - if (p2.IsVolumeDtc) - thisFlags |= RayFilterFlags.volumedtc; + if (p2.Phantom) + thisFlags |= RayFilterFlags.phantom; - if ((thisFlags & CurrentRayFilter) == 0) + if (p2.IsVolumeDtc) + thisFlags |= RayFilterFlags.volumedtc; + + if ((thisFlags & CurrentRayFilter) == 0) + return; + + ID = ((OdePrim)p2).LocalID; + break; + + case (int)ActorTypes.Agent: + + if ((CurrentRayFilter & RayFilterFlags.agent) == 0) + return; + else + ID = ((OdeCharacter)p2).LocalID; + break; + + case (int)ActorTypes.Ground: + + if ((CurrentRayFilter & RayFilterFlags.land) == 0) + return; + break; + + case (int)ActorTypes.Water: + + if ((CurrentRayFilter & RayFilterFlags.water) == 0) + return; + break; + + default: return; - - ID = ((OdePrim)p2).LocalID; + break; } - else if (p2 is OdeCharacter) - { - if ((CurrentRayFilter & RayFilterFlags.agent) == 0) - return; - else - ID = ((OdeCharacter)p2).LocalID; - } - else //?? - return; } d.ContactGeom curcontact = new d.ContactGeom(); diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeApi.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeApi.cs index ee48db54c5..403a4ce85b 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeApi.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeApi.cs @@ -903,7 +903,7 @@ namespace OdeAPI public static extern GeomClassID GeomGetClass(IntPtr geom); [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGeomGetData"), SuppressUnmanagedCodeSecurity] - public static extern IntPtr GeomGetData(IntPtr geom); + public static extern IntPtr GeomGetData(IntPtr geom); [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGeomGetOffsetPosition"), SuppressUnmanagedCodeSecurity] public extern unsafe static Vector3* GeomGetOffsetPositionUnsafe(IntPtr geom); @@ -1096,8 +1096,8 @@ namespace OdeAPI [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGeomSetConvex"), SuppressUnmanagedCodeSecurity] public static extern IntPtr GeomSetConvex(IntPtr geom, dReal[] planes, int planeCount, dReal[] points, int pointCount, int[] polygons); - [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGeomSetData"), SuppressUnmanagedCodeSecurity] - public static extern void GeomSetData(IntPtr geom, IntPtr data); + [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGeomSetData"), SuppressUnmanagedCodeSecurity] + public static extern void GeomSetData(IntPtr geom, IntPtr data); [DllImport("ode", CallingConvention = CallingConvention.Cdecl, EntryPoint = "dGeomSetOffsetPosition"), SuppressUnmanagedCodeSecurity] public static extern void GeomSetOffsetPosition(IntPtr geom, dReal x, dReal y, dReal z); diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs index 659180d8be..1104f45e08 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs @@ -251,7 +251,7 @@ namespace OpenSim.Region.Physics.OdePlugin private List _collisionEventPrimRemove = new List(); private HashSet _badCharacter = new HashSet(); - public Dictionary geom_name_map = new Dictionary(); +// public Dictionary geom_name_map = new Dictionary(); public Dictionary actor_name_map = new Dictionary(); private float contactsurfacelayer = 0.002f; @@ -274,7 +274,7 @@ namespace OpenSim.Region.Physics.OdePlugin private int m_physicsiterations = 10; private const float m_SkipFramesAtms = 0.40f; // Drop frames gracefully at a 400 ms lag - private PhysicsActor PANull = new NullPhysicsActor(); +// private PhysicsActor PANull = new NullPhysicsActor(); private float step_time = 0.0f; public IntPtr world; @@ -713,6 +713,7 @@ namespace OpenSim.Region.Physics.OdePlugin if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact)) return; + if(d.GeomGetCategoryBits(g1) == (uint)CollisionCategories.VolumeDtc || d.GeomGetCategoryBits(g1) == (uint)CollisionCategories.VolumeDtc) { @@ -738,7 +739,7 @@ namespace OpenSim.Region.Physics.OdePlugin return; } - // id contacts done + // contacts done if (count == 0) return; @@ -748,12 +749,14 @@ namespace OpenSim.Region.Physics.OdePlugin if (!actor_name_map.TryGetValue(g1, out p1)) { - p1 = PANull; + m_log.WarnFormat("[PHYSICS]: failed actor mapping for geom 1"); + return; } if (!actor_name_map.TryGetValue(g2, out p2)) { - p2 = PANull; + m_log.WarnFormat("[PHYSICS]: failed actor mapping for geom 2"); + return; } // update actors collision score @@ -765,7 +768,6 @@ namespace OpenSim.Region.Physics.OdePlugin p2.CollisionScore = 0; p2.CollisionScore += count; - // get first contact d.ContactGeom curContact = new d.ContactGeom(); if (!GetCurContactGeom(0, ref curContact)) @@ -798,7 +800,6 @@ namespace OpenSim.Region.Physics.OdePlugin ContactData contactdata1 = new ContactData(0, 0, false); ContactData contactdata2 = new ContactData(0, 0, false); - String name = null; bool dop1foot = false; bool dop2foot = false; bool ignore = false; @@ -830,34 +831,16 @@ namespace OpenSim.Region.Physics.OdePlugin switch (p2.PhysicsActorType) { case (int)ActorTypes.Agent: -/* - p1.getContactData(ref contactdata1); - p2.getContactData(ref contactdata2); - - mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu); - - if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f)) - mu *= frictionMovementMult; -*/ p1.CollidingObj = true; p2.CollidingObj = true; break; + case (int)ActorTypes.Prim: -/* - p1.getContactData(ref contactdata1); - p2.getContactData(ref contactdata2); - - - mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu); - - if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f)) - mu *= frictionMovementMult; - */ if (p2.Velocity.LengthSquared() > 0.0f) p2.CollidingObj = true; - dop1foot = true; break; + default: ignore = true; // avatar to terrain and water ignored break; @@ -869,9 +852,6 @@ namespace OpenSim.Region.Physics.OdePlugin switch (p2.PhysicsActorType) { case (int)ActorTypes.Agent: - // p1.getContactData(ref contactdata1); - // p2.getContactData(ref contactdata2); - AvanormOverride = true; Vector3 tmp = p2.Position - p1.Position; @@ -894,16 +874,12 @@ namespace OpenSim.Region.Physics.OdePlugin bounce = 0; mu = 0; cfm = 0.0001f; - /* - mu = (float)Math.Sqrt(contactdata1.mu * contactdata2.mu); - if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f)) - mu *= frictionMovementMult; - */ dop2foot = true; if (p1.Velocity.LengthSquared() > 0.0f) p1.CollidingObj = true; break; + case (int)ActorTypes.Prim: if ((p1.Velocity - p2.Velocity).LengthSquared() > 0.0f) { @@ -933,95 +909,77 @@ namespace OpenSim.Region.Physics.OdePlugin mu *= frictionMovementMult; break; - default: - if (geom_name_map.TryGetValue(g2, out name)) + + case (int)ActorTypes.Ground: + p1.getContactData(ref contactdata1); + bounce = contactdata1.bounce * TerrainBounce; + mu = (float)Math.Sqrt(contactdata1.mu * TerrainFriction); + if (Math.Abs(p1.Velocity.X) > 0.1f || Math.Abs(p1.Velocity.Y) > 0.1f) + mu *= frictionMovementMult; + p1.CollidingGround = true; + + cfm = p1.Mass; + dscale = 10 / cfm; + dscale = (float)Math.Sqrt(dscale); + if (dscale > 1.0f) + dscale = 1.0f; + erpscale = cfm * 0.01f; + cfm = 0.0001f / cfm; + if (cfm > 0.01f) + cfm = 0.01f; + else if (cfm < 0.00001f) + cfm = 0.00001f; + + if (d.GeomGetClass(g1) == d.GeomClassID.TriMeshClass) { - if (name == "Terrain") - { - p1.getContactData(ref contactdata1); - bounce = contactdata1.bounce * TerrainBounce; - mu = (float)Math.Sqrt(contactdata1.mu * TerrainFriction); - if (Math.Abs(p1.Velocity.X) > 0.1f || Math.Abs(p1.Velocity.Y) > 0.1f) - mu *= frictionMovementMult; - p1.CollidingGround = true; - - cfm = p1.Mass; - dscale = 10 / cfm; - dscale = (float)Math.Sqrt(dscale); - if (dscale > 1.0f) - dscale = 1.0f; - erpscale = cfm * 0.01f; - cfm = 0.0001f / cfm; - if (cfm > 0.01f) - cfm = 0.01f; - else if (cfm < 0.00001f) - cfm = 0.00001f; - - if (d.GeomGetClass(g1) == d.GeomClassID.TriMeshClass) - { - if (curContact.side1 > 0) - IgnoreNegSides = true; - } - - } - else if (name == "Water") - { - ignore = true; - } + if (curContact.side1 > 0) + IgnoreNegSides = true; } - else - ignore = true; + break; + + case (int)ActorTypes.Water: + default: + ignore = true; break; } break; - default: - if (geom_name_map.TryGetValue(g1, out name)) + case (int)ActorTypes.Ground: + if (p2.PhysicsActorType == (int)ActorTypes.Prim) { - if (name == "Terrain") - { - if (p2.PhysicsActorType == (int)ActorTypes.Prim) - { - p2.CollidingGround = true; - p2.getContactData(ref contactdata2); - bounce = contactdata2.bounce * TerrainBounce; - mu = (float)Math.Sqrt(contactdata2.mu * TerrainFriction); + p2.CollidingGround = true; + p2.getContactData(ref contactdata2); + bounce = contactdata2.bounce * TerrainBounce; + mu = (float)Math.Sqrt(contactdata2.mu * TerrainFriction); - cfm = p2.Mass; - dscale = 10 / cfm; - dscale = (float)Math.Sqrt(dscale); + cfm = p2.Mass; + dscale = 10 / cfm; + dscale = (float)Math.Sqrt(dscale); - if (dscale > 1.0f) - dscale = 1.0f; + if (dscale > 1.0f) + dscale = 1.0f; - erpscale = cfm * 0.01f; - cfm = 0.0001f / cfm; - if (cfm > 0.01f) - cfm = 0.01f; - else if (cfm < 0.00001f) - cfm = 0.00001f; + erpscale = cfm * 0.01f; + cfm = 0.0001f / cfm; + if (cfm > 0.01f) + cfm = 0.01f; + else if (cfm < 0.00001f) + cfm = 0.00001f; - if (curContact.side1 > 0) // should be 2 ? - IgnoreNegSides = true; + if (curContact.side1 > 0) // should be 2 ? + IgnoreNegSides = true; - if (Math.Abs(p2.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y) > 0.1f) - mu *= frictionMovementMult; - } - else - ignore = true; - - } - else if (name == "Water" && - (p2.PhysicsActorType == (int)ActorTypes.Prim || p2.PhysicsActorType == (int)ActorTypes.Agent)) - { - ignore = true; - } + if (Math.Abs(p2.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y) > 0.1f) + mu *= frictionMovementMult; } else ignore = true; break; - } + case (int)ActorTypes.Water: + default: + break; + } if (ignore) return; @@ -1162,36 +1120,23 @@ namespace OpenSim.Region.Physics.OdePlugin } */ - } + } private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, ContactPoint contact) - { - - OdeCharacter cc1; - OdePrim cp1; - OdeCharacter cc2; - OdePrim cp2; - OdePrim cp1Parent; - OdePrim cp2Parent; - + { uint obj2LocalID = 0; + bool p1events = p1.SubscribedEvents(); bool p2events = p2.SubscribedEvents(); - + if (p1.IsVolumeDtc) p2events = false; if (p2.IsVolumeDtc) p1events = false; - if (!(p2events || p1events)) + if (!p2events && !p1events) return; - if (p1events) - AddCollisionEventReporting(p1); - - if (p2events) - AddCollisionEventReporting(p2); - Vector3 vel = Vector3.Zero; if (p2 != null && p2.IsPhysical) vel = p2.Velocity; @@ -1200,71 +1145,22 @@ namespace OpenSim.Region.Physics.OdePlugin vel -= p1.Velocity; contact.RelativeSpeed = Vector3.Dot(vel, contact.SurfaceNormal); - + switch ((ActorTypes)p1.PhysicsActorType) - { + { case ActorTypes.Agent: - cc1 = (OdeCharacter)p1; - switch ((ActorTypes)p2.PhysicsActorType) - { - case ActorTypes.Agent: - cc2 = (OdeCharacter)p2; - obj2LocalID = cc2.LocalID; - if (p2events) - cc2.AddCollisionEvent(cc1.LocalID, contact); - break; - - case ActorTypes.Prim: - if (p2 is OdePrim) - { - cp2 = (OdePrim)p2; - if (p2events) - cp2.AddCollisionEvent(cc1.LocalID, contact); - cp2 = cp2.Parent; - obj2LocalID = cp2.LocalID; - } - break; - - case ActorTypes.Ground: - case ActorTypes.Unknown: - default: - obj2LocalID = 0; - break; - } - if (p1events) - { - contact.SurfaceNormal = -contact.SurfaceNormal; - cc1.AddCollisionEvent(obj2LocalID, contact); - } - break; - case ActorTypes.Prim: - - if (p1 is OdePrim) - { - cp1 = (OdePrim)p1; - cp1Parent = cp1.Parent; + { switch ((ActorTypes)p2.PhysicsActorType) - { + { case ActorTypes.Agent: - if (p2 is OdeCharacter) - { - cc2 = (OdeCharacter)p2; - obj2LocalID = cc2.LocalID; - if (p2events) - cc2.AddCollisionEvent(cp1Parent.LocalID, contact); - } - break; case ActorTypes.Prim: - - if (p2 is OdePrim) - { - cp2 = (OdePrim)p2; - if (p2events) - cp2.AddCollisionEvent(cp1Parent.LocalID, contact); - cp2 = cp2.Parent; - obj2LocalID = cp2.LocalID; - } + if (p2events) + { + AddCollisionEventReporting(p2); + p2.AddCollisionEvent(p1.ParentActor.LocalID, contact); + } + obj2LocalID = p2.ParentActor.LocalID; break; case ActorTypes.Ground: @@ -1272,41 +1168,28 @@ namespace OpenSim.Region.Physics.OdePlugin default: obj2LocalID = 0; break; - } - if (p1events) - { - contact.SurfaceNormal = -contact.SurfaceNormal; - cp1.AddCollisionEvent(obj2LocalID, contact); - } } - break; + if (p1events) + { + contact.SurfaceNormal = -contact.SurfaceNormal; + AddCollisionEventReporting(p1); + p1.AddCollisionEvent(obj2LocalID, contact); + } + break; + } case ActorTypes.Ground: case ActorTypes.Unknown: default: - switch ((ActorTypes)p2.PhysicsActorType) + { + if (p2events && !p2.IsVolumeDtc) { - case ActorTypes.Agent: - if (p2 is OdeCharacter) - { - cc2 = (OdeCharacter)p2; - obj2LocalID = cc2.LocalID; - if (p2events) - cc2.AddCollisionEvent(0, contact); - } - break; - case ActorTypes.Prim: - if (p2 is OdePrim) - { - cp2 = (OdePrim)p2; - obj2LocalID = cp2.LocalID; - if (p2events) - cp2.AddCollisionEvent(0, contact); - } - break; + AddCollisionEventReporting(p2); + p2.AddCollisionEvent(0, contact); } break; - } + } } + } /// /// This is our collision testing routine in ODE @@ -2369,6 +2252,7 @@ namespace OpenSim.Region.Physics.OdePlugin RegionTerrain.Remove(pOffset); if (GroundGeom != IntPtr.Zero) { + actor_name_map.Remove(GroundGeom); d.GeomDestroy(GroundGeom); if (TerrainHeightFieldHeights.ContainsKey(GroundGeom)) @@ -2394,27 +2278,32 @@ namespace OpenSim.Region.Physics.OdePlugin d.GeomSetCategoryBits(GroundGeom, (uint)(CollisionCategories.Land)); d.GeomSetCollideBits(GroundGeom, 0); + PhysicsActor pa = new NullPhysicsActor(); + pa.Name = "Terrain"; + pa.PhysicsActorType = (int)ActorTypes.Ground; + actor_name_map[GroundGeom] = pa; + +// geom_name_map[GroundGeom] = "Terrain"; + + d.Matrix3 R = new d.Matrix3(); + + Quaternion q1 = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), 1.5707f); + Quaternion q2 = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), 1.5707f); + + + q1 = q1 * q2; + + Vector3 v3; + float angle; + q1.GetAxisAngle(out v3, out angle); + + d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); + d.GeomSetRotation(GroundGeom, ref R); + d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0); + RegionTerrain.Add(pOffset, GroundGeom); + TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); + TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler); } - geom_name_map[GroundGeom] = "Terrain"; - - d.Matrix3 R = new d.Matrix3(); - - Quaternion q1 = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), 1.5707f); - Quaternion q2 = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), 1.5707f); - - - q1 = q1 * q2; - - Vector3 v3; - float angle; - q1.GetAxisAngle(out v3, out angle); - - d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle); - d.GeomSetRotation(GroundGeom, ref R); - d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0); - RegionTerrain.Add(pOffset, GroundGeom); - TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); - TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler); } } @@ -2478,6 +2367,7 @@ namespace OpenSim.Region.Physics.OdePlugin RegionTerrain.Remove(pOffset); if (GroundGeom != IntPtr.Zero) { + actor_name_map.Remove(GroundGeom); d.GeomDestroy(GroundGeom); if (TerrainHeightFieldHeights.ContainsKey(GroundGeom)) @@ -2509,13 +2399,18 @@ namespace OpenSim.Region.Physics.OdePlugin d.GeomSetCategoryBits(GroundGeom, (uint)(CollisionCategories.Land)); d.GeomSetCollideBits(GroundGeom, 0); - } - geom_name_map[GroundGeom] = "Terrain"; + PhysicsActor pa = new NullPhysicsActor(); + pa.Name = "Terrain"; + pa.PhysicsActorType = (int)ActorTypes.Ground; + actor_name_map[GroundGeom] = pa; - d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0); - RegionTerrain.Add(pOffset, GroundGeom); - TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); - TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler); +// geom_name_map[GroundGeom] = "Terrain"; + + d.GeomSetPosition(GroundGeom, pOffset.X + (float)Constants.RegionSize * 0.5f, pOffset.Y + (float)Constants.RegionSize * 0.5f, 0); + RegionTerrain.Add(pOffset, GroundGeom); + TerrainHeightFieldHeights.Add(GroundGeom, _heightmap); + TerrainHeightFieldHeightsHandlers.Add(GroundGeom, _heightmaphandler); + } } } @@ -2632,6 +2527,7 @@ namespace OpenSim.Region.Physics.OdePlugin { if (WaterGeom != IntPtr.Zero) { + actor_name_map.Remove(WaterGeom); d.GeomDestroy(WaterGeom); d.GeomHeightfieldDataDestroy(WaterHeightmapData); WaterGeom = IntPtr.Zero; @@ -2654,7 +2550,13 @@ namespace OpenSim.Region.Physics.OdePlugin d.GeomSetCategoryBits(WaterGeom, (uint)(CollisionCategories.Water)); d.GeomSetCollideBits(WaterGeom, 0); - geom_name_map[WaterGeom] = "Water"; + + PhysicsActor pa = new NullPhysicsActor(); + pa.Name = "Water"; + pa.PhysicsActorType = (int)ActorTypes.Water; + + actor_name_map[WaterGeom] = pa; +// geom_name_map[WaterGeom] = "Water"; d.Matrix3 R = new d.Matrix3(); From cdd03acffa930ad9d23dc5a6c3af778c0f79567b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 15 Jul 2012 23:37:31 +0100 Subject: [PATCH 04/10] just a kick git --- OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 46337b377f..ddfad82ddb 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -25,6 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + using System; using System.Collections.Generic; using System.Diagnostics; From 3149eca68fce6f9662fa8b84e80f2b880f537414 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 15 Jul 2012 23:45:47 +0100 Subject: [PATCH 05/10] backkick git --- OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index ddfad82ddb..46337b377f 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -25,7 +25,6 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - using System; using System.Collections.Generic; using System.Diagnostics; From cbaf59e086113621c47e1c069344f1f3723f44d4 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 16 Jul 2012 01:47:50 +0100 Subject: [PATCH 06/10] ** TEST ** put back corrected SetPrimParams for avatars, referenced to sitpart and not m_host. --- .../Shared/Api/Implementation/LSL_Api.cs | 82 ++++++++++++------- 1 file changed, 52 insertions(+), 30 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 5bade25e68..5cbcfecef8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -8000,6 +8000,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset. int idx = 0; + SceneObjectPart sitpart = World.GetSceneObjectPart(av.ParentID); // betting this will be used bool positionChanged = false; Vector3 finalPos = Vector3.Zero; @@ -8014,60 +8015,81 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api switch (code) { + // a avatar is a child case (int)ScriptBaseClass.PRIM_POSITION: case (int)ScriptBaseClass.PRIM_POS_LOCAL: { if (remain < 1) return; - LSL_Vector v; v = rules.GetVector3Item(idx++); - SceneObjectPart part = World.GetSceneObjectPart(av.ParentID); - if (part == null) + if (sitpart == null) break; - LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION; - LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR; - if (llGetLinkNumber() > 1) + Vector3 pos = new Vector3((float)v.x, (float)v.y, (float)v.z); // requested absolute position + + if (sitpart != sitpart.ParentGroup.RootPart) { - localRot = llGetLocalRot(); - localPos = llGetLocalPos(); + pos -= sitpart.OffsetPosition; // remove sit part offset + Quaternion rot = sitpart.RotationOffset; + pos *= Quaternion.Conjugate(rot); // removed sit part rotation } + Vector3 sitOffset = (Zrot(av.Rotation)) * (av.Appearance.AvatarHeight * 0.02638f * 2.0f); + pos += sitOffset; - v -= localPos; - v /= localRot; - - LSL_Vector sitOffset = (llRot2Up(new LSL_Rotation(av.Rotation.X, av.Rotation.Y, av.Rotation.Z, av.Rotation.W)) * av.Appearance.AvatarHeight * 0.02638f); - - v = v + 2 * sitOffset; - - av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z); - av.SendAvatarDataToAllAgents(); - + finalPos = pos; + positionChanged = true; } break; - case (int)ScriptBaseClass.PRIM_ROT_LOCAL: case (int)ScriptBaseClass.PRIM_ROTATION: { if (remain < 1) return; - LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION; - LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR; + if (sitpart == null) + break; - if (llGetLinkNumber() > 1) + LSL_Rotation r = rules.GetQuaternionItem(idx++); + Quaternion rot = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); // requested world rotation + + SceneObjectGroup sitgrp = sitpart.ParentGroup; + if (sitgrp != null) { - localRot = llGetLocalRot(); - localPos = llGetLocalPos(); - } + // need to replicate SL bug + rot = sitgrp.RootPart.RotationOffset * rot; + if (sitgrp.RootPart != sitpart) + { + Quaternion srot = sitpart.RotationOffset; + rot = Quaternion.Conjugate(srot) * rot; // removed sit part offset rotation + } - LSL_Rotation r; - r = rules.GetQuaternionItem(idx++); - r = r * llGetRootRotation() / localRot; - av.Rotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); - av.SendAvatarDataToAllAgents(); + av.Rotation = rot; + // av.SendAvatarDataToAllAgents(); + av.SendTerseUpdateToAllClients(); + } + } + break; + + case (int)ScriptBaseClass.PRIM_ROT_LOCAL: + { + if (remain < 1) + return; + + if (sitpart == null) + break; + + LSL_Rotation r = rules.GetQuaternionItem(idx++); + Quaternion rot = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); // requested offset rotation + if (sitpart != sitpart.ParentGroup.RootPart) + { + Quaternion srot = sitpart.RotationOffset; + rot = Quaternion.Conjugate(srot) * rot; // remove sit part offset rotation + } + av.Rotation = rot; +// av.SendAvatarDataToAllAgents(); + av.SendTerseUpdateToAllClients(); } break; From 0d3661fb5f9f8f2cfc29d516d744ce87826ec6be Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 17 Jul 2012 00:27:01 +0100 Subject: [PATCH 07/10] UbitOde: remove useless water collider from active code. --- OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs index 139c4e8004..a554897e53 100644 --- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs @@ -203,9 +203,9 @@ namespace OpenSim.Region.Physics.OdePlugin private float waterlevel = 0f; private int framecount = 0; - private IntPtr WaterGeom = IntPtr.Zero; - private IntPtr WaterHeightmapData = IntPtr.Zero; - private GCHandle WaterMapHandler = new GCHandle(); +// private IntPtr WaterGeom = IntPtr.Zero; +// private IntPtr WaterHeightmapData = IntPtr.Zero; +// private GCHandle WaterMapHandler = new GCHandle(); public float avPIDD = 2200f; // make it visible public float avPIDP = 900f; // make it visible @@ -2491,9 +2491,9 @@ namespace OpenSim.Region.Physics.OdePlugin public override void SetWaterLevel(float baseheight) { waterlevel = baseheight; - randomizeWater(waterlevel); +// randomizeWater(waterlevel); } - +/* public void randomizeWater(float baseheight) { const uint heightmapWidth = Constants.RegionSize + 2; @@ -2574,7 +2574,7 @@ namespace OpenSim.Region.Physics.OdePlugin } } } - +*/ public override void Dispose() { lock (OdeLock) @@ -2624,7 +2624,7 @@ namespace OpenSim.Region.Physics.OdePlugin TerrainHeightFieldHeightsHandlers.Clear(); TerrainHeightFieldHeights.Clear(); - +/* if (WaterGeom != IntPtr.Zero) { d.GeomDestroy(WaterGeom); @@ -2636,7 +2636,7 @@ namespace OpenSim.Region.Physics.OdePlugin if (WaterMapHandler.IsAllocated) WaterMapHandler.Free(); } - +*/ if (ContactgeomsArray != IntPtr.Zero) Marshal.FreeHGlobal(ContactgeomsArray); if (GlobalContactsArray != IntPtr.Zero) From f004db65726fc2e00fe14d9c343ef46136f350f9 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 17 Jul 2012 03:45:16 +0100 Subject: [PATCH 08/10] fix our stats ( old schema ) --- OpenSim/Region/Framework/Scenes/Scene.cs | 53 ++++++++------- .../Framework/Scenes/SimStatsReporter.cs | 67 +++++++++++-------- 2 files changed, 69 insertions(+), 51 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 05af942f6d..f5018283c7 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -225,7 +225,6 @@ namespace OpenSim.Region.Framework.Scenes private int backupMS; private int terrainMS; private int landMS; - private int spareMS; /// /// Tick at which the last frame was processed. @@ -1434,16 +1433,20 @@ namespace OpenSim.Region.Framework.Scenes endFrame = Frame + frames; float physicsFPS = 0f; - int previousFrameTick, tmpMS; - int maintc = Util.EnvironmentTickCount(); + int tmpMS; + int previousFrameTick; + int maintc; + int sleepMS; + int framestart; while (!m_shuttingDown && (endFrame == null || Frame < endFrame)) { + framestart = Util.EnvironmentTickCount(); ++Frame; // m_log.DebugFormat("[SCENE]: Processing frame {0} in {1}", Frame, RegionInfo.RegionName); - agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = spareMS = 0; + agentMS = tempOnRezMS = eventMS = backupMS = terrainMS = landMS = 0; try { @@ -1495,6 +1498,7 @@ namespace OpenSim.Region.Framework.Scenes m_sceneGraph.UpdatePresences(); agentMS += Util.EnvironmentTickCountSubtract(tmpMS); + // Delete temp-on-rez stuff if (Frame % m_update_temp_cleaning == 0 && !m_cleaningTemps) @@ -1573,37 +1577,38 @@ namespace OpenSim.Region.Framework.Scenes Watchdog.UpdateThread(); - previousFrameTick = m_lastFrameTick; - m_lastFrameTick = Util.EnvironmentTickCount(); - tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, maintc); - tmpMS = (int)(MinFrameTime * 1000) - tmpMS; - - m_firstHeartbeat = false; - - if (tmpMS > 0) - { - Thread.Sleep(tmpMS); - spareMS += tmpMS; - } - - frameMS = Util.EnvironmentTickCountSubtract(maintc); - maintc = Util.EnvironmentTickCount(); - otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; - // if (Frame%m_update_avatars == 0) - // UpdateInWorldTime(); StatsReporter.AddPhysicsFPS(physicsFPS); StatsReporter.AddTimeDilation(TimeDilation); StatsReporter.AddFPS(1); - StatsReporter.addFrameMS(frameMS); StatsReporter.addAgentMS(agentMS); StatsReporter.addPhysicsMS(physicsMS + physicsMS2); StatsReporter.addOtherMS(otherMS); - StatsReporter.AddSpareMS(spareMS); StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS()); + previousFrameTick = m_lastFrameTick; + m_lastFrameTick = Util.EnvironmentTickCount(); + tmpMS = Util.EnvironmentTickCountSubtract(m_lastFrameTick, framestart); + tmpMS = (int)(MinFrameTime * 1000) - tmpMS; + + m_firstHeartbeat = false; + + sleepMS = Util.EnvironmentTickCount(); + + if (tmpMS > 0) + Thread.Sleep(tmpMS); + + sleepMS = Util.EnvironmentTickCountSubtract(sleepMS); + frameMS = Util.EnvironmentTickCountSubtract(framestart); + StatsReporter.addSleepMS(sleepMS); + StatsReporter.addFrameMS(frameMS); + + // if (Frame%m_update_avatars == 0) + // UpdateInWorldTime(); + + // Optionally warn if a frame takes double the amount of time that it should. if (DebugUpdates && Util.EnvironmentTickCountSubtract( diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs index 18e6ecec41..d6ff5a2890 100644 --- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs @@ -164,7 +164,7 @@ namespace OpenSim.Region.Framework.Scenes // saved last reported value so there is something available for llGetRegionFPS private float lastReportedSimFPS; - private float[] lastReportedSimStats = new float[22]; + private float[] lastReportedSimStats = new float[23]; private float m_pfps; /// @@ -178,12 +178,13 @@ namespace OpenSim.Region.Framework.Scenes private int m_objectUpdates; private int m_frameMS; - private int m_spareMS; + private int m_netMS; private int m_agentMS; private int m_physicsMS; private int m_imageMS; private int m_otherMS; + private int m_sleeptimeMS; //Ckrinke: (3-21-08) Comment out to remove a compiler warning. Bring back into play when needed. //Ckrinke private int m_scriptMS = 0; @@ -260,7 +261,7 @@ namespace OpenSim.Region.Framework.Scenes private void statsHeartBeat(object sender, EventArgs e) { - SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[22]; + SimStatsPacket.StatBlock[] sb = new SimStatsPacket.StatBlock[23]; SimStatsPacket.RegionBlock rb = new SimStatsPacket.RegionBlock(); // Know what's not thread safe in Mono... modifying timers. @@ -298,6 +299,8 @@ namespace OpenSim.Region.Framework.Scenes physfps = 0; #endregion + float factor = 1 / m_statsUpdateFactor; + if (reportedFPS <= 0) reportedFPS = 1; @@ -308,9 +311,22 @@ namespace OpenSim.Region.Framework.Scenes float targetframetime = 1100.0f / (float)m_nominalReportedFps; float sparetime; + float sleeptime; + if (TotalFrameTime > targetframetime) { sparetime = 0; + sleeptime = 0; + } + else + { + sparetime = m_frameMS - m_physicsMS - m_agentMS; + sparetime *= perframe; + if (sparetime < 0) + sparetime = 0; + else if (sparetime > TotalFrameTime) + sparetime = TotalFrameTime; + sleeptime = m_sleeptimeMS * perframe; } m_rootAgents = m_scene.SceneGraph.GetRootAgentCount(); @@ -327,19 +343,11 @@ namespace OpenSim.Region.Framework.Scenes // m_otherMS = m_frameMS - m_physicsMS - m_imageMS - m_netMS - m_agentMS; // m_imageMS m_netMS are not included in m_frameMS - m_otherMS = m_frameMS - m_physicsMS - m_agentMS; + m_otherMS = m_frameMS - m_physicsMS - m_agentMS - m_sleeptimeMS; if (m_otherMS < 0) m_otherMS = 0; - uint thisFrame = m_scene.Frame; - float framesUpdated = (float)(thisFrame - m_lastUpdateFrame) * m_reportedFpsCorrectionFactor; - m_lastUpdateFrame = thisFrame; - - // Avoid div-by-zero if somehow we've not updated any frames. - if (framesUpdated == 0) - framesUpdated = 1; - - for (int i = 0; i < 22; i++) + for (int i = 0; i < 23; i++) { sb[i] = new SimStatsPacket.StatBlock(); } @@ -369,19 +377,19 @@ namespace OpenSim.Region.Framework.Scenes sb[7].StatValue = m_activePrim; sb[8].StatID = (uint)Stats.FrameMS; - sb[8].StatValue = m_frameMS / framesUpdated; + sb[8].StatValue = TotalFrameTime; sb[9].StatID = (uint)Stats.NetMS; - sb[9].StatValue = m_netMS / framesUpdated; + sb[9].StatValue = m_netMS * perframe; sb[10].StatID = (uint)Stats.PhysicsMS; - sb[10].StatValue = m_physicsMS / framesUpdated; + sb[10].StatValue = m_physicsMS * perframe; sb[11].StatID = (uint)Stats.ImageMS ; - sb[11].StatValue = m_imageMS / framesUpdated; + sb[11].StatValue = m_imageMS * perframe; sb[12].StatID = (uint)Stats.OtherMS; - sb[12].StatValue = m_otherMS / framesUpdated; + sb[12].StatValue = m_otherMS * perframe; sb[13].StatID = (uint)Stats.InPacketsPerSecond; sb[13].StatValue = (m_inPacketsPerSecond / m_statsUpdateFactor); @@ -393,7 +401,7 @@ namespace OpenSim.Region.Framework.Scenes sb[15].StatValue = m_unAckedBytes; sb[16].StatID = (uint)Stats.AgentMS; - sb[16].StatValue = m_agentMS / framesUpdated; + sb[16].StatValue = m_agentMS * perframe; sb[17].StatID = (uint)Stats.PendingDownloads; sb[17].StatValue = m_pendingDownloads; @@ -408,7 +416,10 @@ namespace OpenSim.Region.Framework.Scenes sb[20].StatValue = m_scriptLinesPerSecond / m_statsUpdateFactor; sb[21].StatID = (uint)Stats.SimSpareMs; - sb[21].StatValue = m_spareMS / framesUpdated; + sb[21].StatValue = sparetime; + + sb[22].StatID = (uint)Stats.SimSleepMs; + sb[22].StatValue = sleeptime; for (int i = 0; i < 22; i++) { @@ -441,13 +452,14 @@ namespace OpenSim.Region.Framework.Scenes // Need to change things so that stats source can indicate whether they are per second or // per frame. if (tuple.Key.EndsWith("MS")) - m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / framesUpdated; + m_lastReportedExtraSimStats[tuple.Key] = tuple.Value * perframe; else m_lastReportedExtraSimStats[tuple.Key] = tuple.Value / m_statsUpdateFactor; } } } +// LastReportedObjectUpdates = m_objectUpdates / m_statsUpdateFactor; ResetValues(); } } @@ -470,7 +482,8 @@ namespace OpenSim.Region.Framework.Scenes m_physicsMS = 0; m_imageMS = 0; m_otherMS = 0; - m_spareMS = 0; +// m_spareMS = 0; + m_sleeptimeMS = 0; //Ckrinke This variable is not used, so comment to remove compiler warning until it is used. //Ckrinke m_scriptMS = 0; @@ -549,11 +562,6 @@ namespace OpenSim.Region.Framework.Scenes m_frameMS += ms; } - public void AddSpareMS(int ms) - { - m_spareMS += ms; - } - public void addNetMS(int ms) { m_netMS += ms; @@ -579,6 +587,11 @@ namespace OpenSim.Region.Framework.Scenes m_otherMS += ms; } + public void addSleepMS(int ms) + { + m_sleeptimeMS += ms; + } + public void AddPendingDownloads(int count) { m_pendingDownloads += count; From 1ff498266cd5ecc4ed8f3b1de86758b78a327f61 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 17 Jul 2012 05:25:34 +0100 Subject: [PATCH 09/10] minor changes, removed extra parts physics updates on linking nonroot prims --- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index f1f94a78bf..6ab0027d7e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -3066,7 +3066,7 @@ namespace OpenSim.Region.Framework.Scenes part.LinkNum = linkNum; // Compute the new position of this SOP relative to the group position - part.OffsetPosition = part.GroupPosition - AbsolutePosition; + part.OffsetPosition = newPos - AbsolutePosition; // (radams1 20120711: I don't know why part.OffsetPosition is set multiple times. // It would have the affect of setting the physics engine position multiple @@ -3087,7 +3087,8 @@ namespace OpenSim.Region.Framework.Scenes // Since this SOP's state has changed, push those changes into the physics engine // and the simulator. - part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); + // done on caller +// part.UpdatePrimFlags(UsesPhysics, IsTemporary, IsPhantom, IsVolumeDetect, false); } /// From 5874dfd3422d3ff7e35e8eb7e424f5f003f2d1a2 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 17 Jul 2012 09:47:20 +0100 Subject: [PATCH 10/10] fix PollServiceRequestManager --- .../HttpServer/PollServiceRequestManager.cs | 57 +++++++++++++++---- 1 file changed, 47 insertions(+), 10 deletions(-) diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index 3a14b6fe9b..4fe783d767 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs @@ -290,9 +290,8 @@ namespace OpenSim.Framework.Servers.HttpServer { foreach (PollServiceHttpRequest req in m_retryRequests) { - m_server.DoHTTPGruntWork( - req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id), - new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext)); + DoHTTPGruntWork(m_server,req, + req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id)); } } catch @@ -313,9 +312,8 @@ namespace OpenSim.Framework.Servers.HttpServer try { wreq = m_requests.Dequeue(0); - m_server.DoHTTPGruntWork( - wreq.PollServiceArgs.NoEvents(wreq.RequestID, wreq.PollServiceArgs.Id), - new OSHttpResponse(new HttpResponse(wreq.HttpContext, wreq.Request), wreq.HttpContext)); + DoHTTPGruntWork(m_server,wreq, + wreq.PollServiceArgs.NoEvents(wreq.RequestID, wreq.PollServiceArgs.Id)); } catch { @@ -359,8 +357,7 @@ namespace OpenSim.Framework.Servers.HttpServer try { Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id, str.ReadToEnd()); - m_server.DoHTTPGruntWork(responsedata, - new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext)); + DoHTTPGruntWork(m_server, req, responsedata); } catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream { @@ -375,8 +372,8 @@ namespace OpenSim.Framework.Servers.HttpServer // if ((Environment.TickCount - req.RequestTime) > m_timeout) if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) { - m_server.DoHTTPGruntWork(req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id), - new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext)); + DoHTTPGruntWork(m_server, req, + req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id)); } else { @@ -391,6 +388,46 @@ namespace OpenSim.Framework.Servers.HttpServer } } } + + // DoHTTPGruntWork changed, not sending response + // do the same work around as core + + internal static void DoHTTPGruntWork(BaseHttpServer server, PollServiceHttpRequest req, Hashtable responsedata) + { + OSHttpResponse response + = new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext); + + byte[] buffer = server.DoHTTPGruntWork(responsedata, response); + + response.SendChunked = false; + response.ContentLength64 = buffer.Length; + response.ContentEncoding = Encoding.UTF8; + + try + { + response.OutputStream.Write(buffer, 0, buffer.Length); + } + catch (Exception ex) + { + m_log.Warn(string.Format("[POLL SERVICE WORKER THREAD]: Error ", ex)); + } + finally + { + //response.OutputStream.Close(); + try + { + response.OutputStream.Flush(); + response.Send(); + + //if (!response.KeepAlive && response.ReuseContext) + // response.FreeContext(); + } + catch (Exception e) + { + m_log.Warn(String.Format("[POLL SERVICE WORKER THREAD]: Error ", e)); + } + } + } } }