From d0ae8bb86aa64632cf2e3d4e879d7a5f5fb96bb3 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Mon, 7 Nov 2016 12:45:20 +0000 Subject: [PATCH] start removing old hack of using SetMomentum to just set instant velocity, now that TargetVelocity is avaiable --- .../PhysicsModules/ubOde/ODECharacter.cs | 40 ++++++++++++++++--- .../Region/PhysicsModules/ubOde/ODEPrim.cs | 5 ++- .../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 9640e911af..f7e1044622 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; @@ -1738,6 +1755,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; @@ -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 4adf87ef30..3403f4baac 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 e6aa7ef360..6267051aac 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,