From 19e0ada93af347cff93a3950f66abe245399f8b2 Mon Sep 17 00:00:00 2001 From: Teravus Ovares Date: Sun, 17 Feb 2008 10:41:08 +0000 Subject: * Located and destroyed the weird velocity and rotation transfers. It turned out to be that the Static PhysicsVector.Zero was transferring velocities between all non fixed objects. Not so static after all :(. Finding it was cruel and unusual punishment from the CLR. * Therefore, when you run through a pile of prim you won't see things rotate when they're not supposed to anymore. * Avatars don't float off either. --- OpenSim/Region/Environment/Scenes/ScenePresence.cs | 20 ++++++++++++++++---- .../Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs | 6 ++++++ .../Region/Physics/BulletXPlugin/BulletXPlugin.cs | 5 +++++ OpenSim/Region/Physics/Manager/CollisionLocker.cs | 2 +- OpenSim/Region/Physics/Manager/PhysicsActor.cs | 7 +++++++ OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | 10 ++++++++-- OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 20 +++++++++++++------- OpenSim/Region/Physics/POSPlugin/POSPlugin.cs | 10 ++++++++++ OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs | 10 ++++++++++ 9 files changed, 76 insertions(+), 14 deletions(-) diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 2b02ab9..67b07f6 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -77,8 +77,11 @@ namespace OpenSim.Region.Environment.Scenes private bool m_newForce = false; private bool m_newCoarseLocations = true; private bool m_gotAllObjectsInScene = false; - + private bool m_lastPhysicsStoppedStatus = false; + + private LLVector3 m_lastVelocity = LLVector3.Zero; + // Default AV Height private float m_avHeight = 127.0f; @@ -1263,11 +1266,17 @@ namespace OpenSim.Region.Environment.Scenes m_updateCount = 0; } } - else if (Util.GetDistanceTo(lastPhysPos, AbsolutePosition) > 0.02) // physics-related movement + else if ((Util.GetDistanceTo(lastPhysPos, AbsolutePosition) > 0.02) || (Util.GetDistanceTo(m_lastVelocity, m_velocity) > 0.02)) // physics-related movement { + + + // Send Terse Update to all clients updates lastPhysPos and m_lastVelocity + // doing the above assures us that we know what we sent the clients last SendTerseUpdateToAllClients(); m_updateCount = 0; - lastPhysPos = AbsolutePosition; + + + } // followed suggestion from mic bowman. reversed the two lines below. @@ -1308,6 +1317,9 @@ namespace OpenSim.Region.Environment.Scenes m_scene.Broadcast(SendTerseUpdateToClient); + m_lastVelocity = m_velocity; + lastPhysPos = AbsolutePosition; + m_scene.AddAgentTime(System.Environment.TickCount - m_perfMonMS); } @@ -1729,7 +1741,7 @@ namespace OpenSim.Region.Environment.Scenes AbsolutePosition.Z); m_physicsActor = scene.AddAvatar(Firstname + "." + Lastname, pVec); - m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; + //m_physicsActor.OnRequestTerseUpdate += SendTerseUpdateToAllClients; m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; } diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs index d767eab..3fb30fb 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/BasicPhysicsPlugin.cs @@ -274,6 +274,12 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin set { return; } } + public override bool Stopped + { + get { return false; } + } + + public override PhysicsVector Position { get { return _position; } diff --git a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs index 314708f..f5f222b 100644 --- a/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs +++ b/OpenSim/Region/Physics/BulletXPlugin/BulletXPlugin.cs @@ -730,6 +730,11 @@ namespace OpenSim.Region.Physics.BulletXPlugin _name = name; } + public override bool Stopped + { + get { return false; } + } + public override PhysicsVector Position { get { return _position; } diff --git a/OpenSim/Region/Physics/Manager/CollisionLocker.cs b/OpenSim/Region/Physics/Manager/CollisionLocker.cs index 8c2e702..98e9736 100644 --- a/OpenSim/Region/Physics/Manager/CollisionLocker.cs +++ b/OpenSim/Region/Physics/Manager/CollisionLocker.cs @@ -35,7 +35,7 @@ namespace OpenSim.Region.Physics.Manager public class CollisionLocker { - private bool locked = false; + private List worldlock = new List(); public CollisionLocker() { diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index 97eccba..b96ce27 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -118,6 +118,8 @@ namespace OpenSim.Region.Physics.Manager get { return new NullPhysicsActor(); } } + public abstract bool Stopped { get; } + public abstract PhysicsVector Size { get; set; } public abstract PrimitiveBaseShape Shape { set; } @@ -204,6 +206,11 @@ namespace OpenSim.Region.Physics.Manager public class NullPhysicsActor : PhysicsActor { + public override bool Stopped + { + get{ return false; } + } + public override PhysicsVector Position { get { return PhysicsVector.Zero; } diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index 6b8d0e2..0f1446c 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs @@ -317,6 +317,11 @@ namespace OpenSim.Region.Physics.OdePlugin m_pidControllerActive = status; } + public override bool Stopped + { + get { return _zeroFlag; } + } + /// /// This 'puts' an avatar somewhere in the physics space. /// Not really a good choice unless you 'know' it's a good @@ -509,8 +514,9 @@ namespace OpenSim.Region.Physics.OdePlugin public override PhysicsVector Velocity { get { + // There's a problem with PhysicsVector.Zero! Don't Use it Here! if (_zeroFlag) - return PhysicsVector.Zero; + return new PhysicsVector(0f, 0f, 0f); m_lastUpdateSent = false; return _velocity; } @@ -756,7 +762,7 @@ namespace OpenSim.Region.Physics.OdePlugin if (!m_lastUpdateSent) { m_lastUpdateSent = true; - base.RequestPhysicsterseUpdate(); + //base.RequestPhysicsterseUpdate(); } } diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index fae5316..b41153b 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -1129,6 +1129,11 @@ namespace OpenSim.Region.Physics.OdePlugin set { m_throttleUpdates = value; } } + public override bool Stopped + { + get { return _zeroFlag; } + } + public override PhysicsVector Position { get { return _position; } @@ -1233,12 +1238,13 @@ namespace OpenSim.Region.Physics.OdePlugin public override PhysicsVector RotationalVelocity { get { + PhysicsVector pv = new PhysicsVector(0, 0, 0); if (_zeroFlag) - return PhysicsVector.Zero; + return pv; m_lastUpdateSent = false; - if (m_rotationalVelocity.IsIdentical(PhysicsVector.Zero, 0.2f)) - return PhysicsVector.Zero; + if (m_rotationalVelocity.IsIdentical(pv, 0.2f)) + return pv; return m_rotationalVelocity; } @@ -1261,7 +1267,7 @@ namespace OpenSim.Region.Physics.OdePlugin public void UpdatePositionAndVelocity() { // no lock; called from Simulate() -- if you call this from elsewhere, gotta lock or do Monitor.Enter/Exit! - + PhysicsVector pv = new PhysicsVector(0, 0, 0); if (Body != (IntPtr) 0) { d.Vector3 vec = d.BodyGetPosition(Body); @@ -1348,7 +1354,7 @@ namespace OpenSim.Region.Physics.OdePlugin { m_throttleUpdates = false; throttleCounter = 0; - m_rotationalVelocity = PhysicsVector.Zero; + m_rotationalVelocity = pv; base.RequestPhysicsterseUpdate(); m_lastUpdateSent = true; } @@ -1362,9 +1368,9 @@ namespace OpenSim.Region.Physics.OdePlugin _velocity.X = vel.X; _velocity.Y = vel.Y; _velocity.Z = vel.Z; - if (_velocity.IsIdentical(PhysicsVector.Zero, 0.5f)) + if (_velocity.IsIdentical(pv, 0.5f)) { - m_rotationalVelocity = PhysicsVector.Zero; + m_rotationalVelocity = pv; } else { diff --git a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs index 3bd25f6..bac61f4 100644 --- a/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs +++ b/OpenSim/Region/Physics/POSPlugin/POSPlugin.cs @@ -403,6 +403,11 @@ namespace OpenSim.Region.Physics.POSPlugin set { return; } } + public override bool Stopped + { + get { return false; } + } + public override PhysicsVector Position { get { return _position; } @@ -545,6 +550,11 @@ namespace OpenSim.Region.Physics.POSPlugin set { return; } } + public override bool Stopped + { + get { return false; } + } + public override PhysicsVector Position { get { return _position; } diff --git a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs index 4a0467c..ffa0838 100644 --- a/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs +++ b/OpenSim/Region/Physics/PhysXPlugin/PhysXPlugin.cs @@ -279,6 +279,11 @@ namespace OpenSim.Region.Physics.PhysXPlugin set { m_rotationalVelocity = value; } } + public override bool Stopped + { + get { return false; } + } + public override PhysicsVector Position { get { return _position; } @@ -479,6 +484,11 @@ namespace OpenSim.Region.Physics.PhysXPlugin set { return; } } + public override bool Stopped + { + get { return false; } + } + public override PhysicsVector Position { get -- cgit v1.1