Add NaN and Infinity tests for SOP Velocity and Acceleration setters.
parent
78814a1533
commit
8b2af1071f
|
@ -420,6 +420,22 @@ namespace OpenSim.Framework
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check if any of the values in a Vector3 are NaN or Infinity
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="v">Vector3 to check</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool IsNanOrInfinity(Vector3 v)
|
||||||
|
{
|
||||||
|
if (float.IsNaN(v.X) || float.IsNaN(v.Y) || float.IsNaN(v.Z))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (float.IsInfinity(v.X) || float.IsInfinity(v.Y) || float.IsNaN(v.Z))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Inclusive, within range test (true if equal to the endpoints)
|
// Inclusive, within range test (true if equal to the endpoints)
|
||||||
public static bool InRange<T>(T x, T min, T max)
|
public static bool InRange<T>(T x, T min, T max)
|
||||||
where T : IComparable<T>
|
where T : IComparable<T>
|
||||||
|
|
|
@ -929,14 +929,17 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
m_velocity = value;
|
if (Util.IsNanOrInfinity(value))
|
||||||
|
m_velocity = Vector3.Zero;
|
||||||
|
else
|
||||||
|
m_velocity = value;
|
||||||
|
|
||||||
PhysicsActor actor = PhysActor;
|
PhysicsActor actor = PhysActor;
|
||||||
if (actor != null)
|
if (actor != null)
|
||||||
{
|
{
|
||||||
if (actor.IsPhysical)
|
if (actor.IsPhysical)
|
||||||
{
|
{
|
||||||
actor.Velocity = value;
|
actor.Velocity = m_velocity;
|
||||||
ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor);
|
ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -965,8 +968,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (float.IsNaN(value.X) || float.IsNaN(value.Y) || float.IsNaN(value.Z)
|
if (Util.IsNanOrInfinity(value))
|
||||||
|| float.IsInfinity(value.X) || float.IsInfinity(value.Y) || float.IsInfinity(value.Z))
|
|
||||||
m_angularVelocity = Vector3.Zero;
|
m_angularVelocity = Vector3.Zero;
|
||||||
else
|
else
|
||||||
m_angularVelocity = value;
|
m_angularVelocity = value;
|
||||||
|
@ -981,7 +983,13 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
public Vector3 Acceleration
|
public Vector3 Acceleration
|
||||||
{
|
{
|
||||||
get { return m_acceleration; }
|
get { return m_acceleration; }
|
||||||
set { m_acceleration = value; }
|
set
|
||||||
|
{
|
||||||
|
if (Util.IsNanOrInfinity(value))
|
||||||
|
m_acceleration = Vector3.Zero;
|
||||||
|
else
|
||||||
|
m_acceleration = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Description { get; set; }
|
public string Description { get; set; }
|
||||||
|
|
Loading…
Reference in New Issue