start removing old hack of using SetMomentum to just set instant velocity, now that TargetVelocity is avaiable

melanie
UbitUmarov 2016-11-07 12:45:20 +00:00
parent d5a428c669
commit d0ae8bb86a
3 changed files with 39 additions and 7 deletions

View File

@ -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 public override Vector3 Torque
{ {
get { return Vector3.Zero; } get { return Vector3.Zero; }
@ -689,7 +708,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
} }
else else
{ {
AddChange(changes.Velocity, force); AddChange(changes.TargetVelocity, force);
} }
} }
else else
@ -1671,16 +1690,14 @@ namespace OpenSim.Region.PhysicsModule.ubOde
{ {
AvatarGeomAndBodyDestroy(); AvatarGeomAndBodyDestroy();
float oldsz = m_size.Z; float oldsz = m_size.Z;
m_size = pSize; m_size = pSize;
AvatarGeomAndBodyCreation(_position.X, _position.Y, AvatarGeomAndBodyCreation(_position.X, _position.Y,
_position.Z + (m_size.Z - oldsz) * 0.5f); _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[collider] = (PhysicsActor)this;
_parent_scene.actor_name_map[capsule] = (PhysicsActor)this; _parent_scene.actor_name_map[capsule] = (PhysicsActor)this;
@ -1738,6 +1755,15 @@ namespace OpenSim.Region.PhysicsModule.ubOde
} }
private void changeVelocity(Vector3 newVel) 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_pidControllerActive = true;
m_freemove = false; m_freemove = false;
@ -1881,6 +1907,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde
changeVelocity((Vector3)arg); changeVelocity((Vector3)arg);
break; break;
case changes.TargetVelocity:
changeTargetVelocity((Vector3)arg);
break;
// case changes.Acceleration: // case changes.Acceleration:
// changeacceleration((Vector3)arg); // changeacceleration((Vector3)arg);
// break; // break;

View File

@ -3805,6 +3805,9 @@ namespace OpenSim.Region.PhysicsModule.ubOde
changevelocity((Vector3)arg); changevelocity((Vector3)arg);
break; break;
case changes.TargetVelocity:
break;
// case changes.Acceleration: // case changes.Acceleration:
// changeacceleration((Vector3)arg); // changeacceleration((Vector3)arg);
// break; // break;
@ -3933,8 +3936,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
donullchange(); donullchange();
break; break;
default: default:
donullchange(); donullchange();
break; break;

View File

@ -112,6 +112,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
OriOffset, // not in use OriOffset, // not in use
// arg Vector3 new position in local coords. Changes prim position in object // arg Vector3 new position in local coords. Changes prim position in object
Velocity, Velocity,
TargetVelocity,
AngVelocity, AngVelocity,
Acceleration, Acceleration,
Force, Force,