diff --git a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs index f82e2899d7..a7c4e8d00c 100644 --- a/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs +++ b/OpenSim/Region/PhysicsModules/SharedBase/PhysicsActor.cs @@ -396,6 +396,7 @@ namespace OpenSim.Region.PhysicsModules.SharedBase } public abstract Vector3 Velocity { get; set; } + public virtual Vector3 rootVelocity { get; } public abstract Vector3 Torque { get; set; } public abstract float CollisionScore { get; set;} diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs b/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs index 1b03b3cf76..fc018056f5 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs @@ -607,6 +607,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde set { return; } } + public Vector3 rootVelocity + { + get + { + return _velocity; + } + } + public override Vector3 Velocity { get diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs index 437440c508..21efa9708b 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs @@ -542,13 +542,20 @@ namespace OpenSim.Region.PhysicsModule.ubOde } } + public Vector3 rootVelocity + { + get + { + if(_parent != null) + return ((OdePrim)_parent).Velocity; + return Velocity; + } + } + public override Vector3 Velocity { get { - if (_parent != null) - return ((OdePrim)_parent).Velocity; - if (_zeroFlag) return Vector3.Zero; return _velocity; diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs index e475d8494c..ee80b10ed9 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs @@ -874,7 +874,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde break; case (int)ActorTypes.Prim: - Vector3 relV = p1.Velocity - p2.Velocity; + Vector3 relV = p1.rootVelocity - p2.rootVelocity; float relVlenSQ = relV.LengthSquared(); if (relVlenSQ > 0.0001f) { @@ -899,7 +899,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde 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) + Vector3 v1 = p1.rootVelocity; + if (Math.Abs(v1.X) > 0.1f || Math.Abs(v1.Y) > 0.1f) mu *= frictionMovementMult; p1.CollidingGround = true; @@ -925,8 +926,8 @@ namespace OpenSim.Region.PhysicsModule.ubOde // if (curContact.side1 > 0) // should be 2 ? // IgnoreNegSides = true; - - if (Math.Abs(p2.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y) > 0.1f) + Vector3 v2 = p2.rootVelocity; + if (Math.Abs(v2.X) > 0.1f || Math.Abs(v2.Y) > 0.1f) mu *= frictionMovementMult; if(d.GeomGetClass(g2) == d.GeomClassID.TriMeshClass) @@ -980,7 +981,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde p1.CollidingObj = true; p2.CollidingObj = true; } - else if (p2.Velocity.LengthSquared() > 0.0f) + else if (p2.rootVelocity.LengthSquared() > 0.0f) p2.CollidingObj = true; } else @@ -995,7 +996,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde p1.CollidingObj = true; p2.CollidingObj = true; } - else if (p1.Velocity.LengthSquared() > 0.0f) + else if (p1.rootVelocity.LengthSquared() > 0.0f) p1.CollidingObj = true; } else @@ -1068,10 +1069,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde Vector3 vel = Vector3.Zero; if (p2 != null && p2.IsPhysical) - vel = p2.Velocity; + vel = p2.rootVelocity; if (p1 != null && p1.IsPhysical) - vel -= p1.Velocity; + vel -= p1.rootVelocity; contact.RelativeSpeed = Vector3.Dot(vel, contact.SurfaceNormal);