From d0ae8bb86aa64632cf2e3d4e879d7a5f5fb96bb3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 7 Nov 2016 12:45:20 +0000 Subject: start removing old hack of using SetMomentum to just set instant velocity, now that TargetVelocity is avaiable --- .../Region/PhysicsModules/ubOde/ODECharacter.cs | 40 +++++++++++++++++++--- OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs | 5 +-- OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs | 1 + 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs b/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs index 9640e91..f7e1044 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODECharacter.cs @@ -632,6 +632,25 @@ namespace OpenSim.Region.PhysicsModule.ubOde } } + public override Vector3 TargetVelocity + { + get + { + return m_targetVelocity; + } + set + { + if (value.IsFinite()) + { + AddChange(changes.TargetVelocity, value); + } + else + { + m_log.Warn("[PHYSICS]: Got a NaN velocity from Scene in a Character"); + } + } + } + public override Vector3 Torque { get { return Vector3.Zero; } @@ -689,7 +708,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde } else { - AddChange(changes.Velocity, force); + AddChange(changes.TargetVelocity, force); } } else @@ -1671,16 +1690,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde { AvatarGeomAndBodyDestroy(); - float oldsz = m_size.Z; m_size = pSize; - AvatarGeomAndBodyCreation(_position.X, _position.Y, _position.Z + (m_size.Z - oldsz) * 0.5f); - Velocity = Vector3.Zero; - +// Velocity = Vector3.Zero; + m_targetVelocity = Vector3.Zero; _parent_scene.actor_name_map[collider] = (PhysicsActor)this; _parent_scene.actor_name_map[capsule] = (PhysicsActor)this; @@ -1739,6 +1756,15 @@ namespace OpenSim.Region.PhysicsModule.ubOde private void changeVelocity(Vector3 newVel) { + _velocity = newVel; + setFreeMove(); + + if (Body != IntPtr.Zero) + d.BodySetLinearVel(Body, newVel.X, newVel.Y, newVel.Z); + } + + private void changeTargetVelocity(Vector3 newVel) + { m_pidControllerActive = true; m_freemove = false; _target_velocity = newVel; @@ -1881,6 +1907,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde changeVelocity((Vector3)arg); break; + case changes.TargetVelocity: + changeTargetVelocity((Vector3)arg); + break; + // case changes.Acceleration: // changeacceleration((Vector3)arg); // break; diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs index 4adf87e..3403f4b 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEPrim.cs @@ -3805,6 +3805,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde changevelocity((Vector3)arg); break; + case changes.TargetVelocity: + break; + // case changes.Acceleration: // changeacceleration((Vector3)arg); // break; @@ -3933,8 +3936,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde donullchange(); break; - - default: donullchange(); break; diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs index e6aa7ef..6267051 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEScene.cs @@ -112,6 +112,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde OriOffset, // not in use // arg Vector3 new position in local coords. Changes prim position in object Velocity, + TargetVelocity, AngVelocity, Acceleration, Force, -- cgit v1.1