From 3999822e13d7ae2f6ab1c19a19a01e0cc7c7acd7 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 14 Apr 2012 05:07:52 +0100 Subject: Use chode character actor.SetMomentum() to force full restore Velocity in scenepresence TeleportWithMomentum(), since actor.Velocity was selected by original coders as the input of a desired velocity (even 'forces') that is modified by character conditions, like not changing velocity.Z if it is in free fall. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 4 +++- OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs | 20 +++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 855a341..8ac09e9 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1082,7 +1082,9 @@ namespace OpenSim.Region.Framework.Scenes CheckLandingPoint(ref pos); AbsolutePosition = pos; AddToPhysicalScene(isFlying); - Velocity = vel; + if (PhysicsActor != null) + PhysicsActor.SetMomentum(vel); + SendTerseUpdateToAllClients(); } diff --git a/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs index 2945199..1f1ba95 100644 --- a/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/ChOdePlugin/ODECharacter.cs @@ -140,6 +140,10 @@ namespace OpenSim.Region.Physics.OdePlugin public int m_eventsubscription = 0; private CollisionEventUpdate CollisionEventsThisFrame = new CollisionEventUpdate(); + private Vector3 m_taintMomentum = Vector3.Zero; + private bool m_haveTaintMomentum = false; + + // unique UUID of this character object public UUID m_uuid; public bool bad = false; @@ -800,8 +804,8 @@ namespace OpenSim.Region.Physics.OdePlugin { if (value.IsFinite()) { - m_pidControllerActive = true; _target_velocity = value; + m_pidControllerActive = true; } else { @@ -911,6 +915,12 @@ namespace OpenSim.Region.Physics.OdePlugin public override void SetMomentum(Vector3 momentum) { + if (momentum.IsFinite()) + { + m_taintMomentum = momentum; + m_haveTaintMomentum = true; + _parent_scene.AddPhysicsActorTaint(this); + } } @@ -1424,6 +1434,14 @@ namespace OpenSim.Region.Physics.OdePlugin } } + if (m_haveTaintMomentum) + { + m_haveTaintMomentum = false; + _velocity = m_taintMomentum; + _target_velocity = m_taintMomentum; + m_pidControllerActive = true; + d.BodySetLinearVel(Body, _velocity.X, _velocity.Y, _velocity.Z); + } } } -- cgit v1.1