diff options
author | dahlia | 2015-02-16 23:51:37 -0800 |
---|---|---|
committer | dahlia | 2015-02-16 23:51:37 -0800 |
commit | 8b2af1071f37e45dc330524a4731581867616b21 (patch) | |
tree | c2e9fa657b1324113572bdca1126e2386d4f3a07 | |
parent | Use a boolean flag to signal lookat is running instead of Quaternion.Identity... (diff) | |
download | opensim-SC_OLD-8b2af1071f37e45dc330524a4731581867616b21.zip opensim-SC_OLD-8b2af1071f37e45dc330524a4731581867616b21.tar.gz opensim-SC_OLD-8b2af1071f37e45dc330524a4731581867616b21.tar.bz2 opensim-SC_OLD-8b2af1071f37e45dc330524a4731581867616b21.tar.xz |
Add NaN and Infinity tests for SOP Velocity and Acceleration setters.
-rw-r--r-- | OpenSim/Framework/Util.cs | 16 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 18 |
2 files changed, 29 insertions, 5 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 836fa5f..56a90b1 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -420,6 +420,22 @@ namespace OpenSim.Framework | |||
420 | return x; | 420 | return x; |
421 | } | 421 | } |
422 | 422 | ||
423 | /// <summary> | ||
424 | /// Check if any of the values in a Vector3 are NaN or Infinity | ||
425 | /// </summary> | ||
426 | /// <param name="v">Vector3 to check</param> | ||
427 | /// <returns></returns> | ||
428 | public static bool IsNanOrInfinity(Vector3 v) | ||
429 | { | ||
430 | if (float.IsNaN(v.X) || float.IsNaN(v.Y) || float.IsNaN(v.Z)) | ||
431 | return true; | ||
432 | |||
433 | if (float.IsInfinity(v.X) || float.IsInfinity(v.Y) || float.IsNaN(v.Z)) | ||
434 | return true; | ||
435 | |||
436 | return false; | ||
437 | } | ||
438 | |||
423 | // Inclusive, within range test (true if equal to the endpoints) | 439 | // Inclusive, within range test (true if equal to the endpoints) |
424 | public static bool InRange<T>(T x, T min, T max) | 440 | public static bool InRange<T>(T x, T min, T max) |
425 | where T : IComparable<T> | 441 | where T : IComparable<T> |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 4a8be42..57ec1ae 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -929,14 +929,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
929 | 929 | ||
930 | set | 930 | set |
931 | { | 931 | { |
932 | m_velocity = value; | 932 | if (Util.IsNanOrInfinity(value)) |
933 | m_velocity = Vector3.Zero; | ||
934 | else | ||
935 | m_velocity = value; | ||
933 | 936 | ||
934 | PhysicsActor actor = PhysActor; | 937 | PhysicsActor actor = PhysActor; |
935 | if (actor != null) | 938 | if (actor != null) |
936 | { | 939 | { |
937 | if (actor.IsPhysical) | 940 | if (actor.IsPhysical) |
938 | { | 941 | { |
939 | actor.Velocity = value; | 942 | actor.Velocity = m_velocity; |
940 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); | 943 | ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor); |
941 | } | 944 | } |
942 | } | 945 | } |
@@ -965,8 +968,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
965 | } | 968 | } |
966 | set | 969 | set |
967 | { | 970 | { |
968 | if (float.IsNaN(value.X) || float.IsNaN(value.Y) || float.IsNaN(value.Z) | 971 | if (Util.IsNanOrInfinity(value)) |
969 | || float.IsInfinity(value.X) || float.IsInfinity(value.Y) || float.IsInfinity(value.Z)) | ||
970 | m_angularVelocity = Vector3.Zero; | 972 | m_angularVelocity = Vector3.Zero; |
971 | else | 973 | else |
972 | m_angularVelocity = value; | 974 | m_angularVelocity = value; |
@@ -981,7 +983,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
981 | public Vector3 Acceleration | 983 | public Vector3 Acceleration |
982 | { | 984 | { |
983 | get { return m_acceleration; } | 985 | get { return m_acceleration; } |
984 | set { m_acceleration = value; } | 986 | set |
987 | { | ||
988 | if (Util.IsNanOrInfinity(value)) | ||
989 | m_acceleration = Vector3.Zero; | ||
990 | else | ||
991 | m_acceleration = value; | ||
992 | } | ||
985 | } | 993 | } |
986 | 994 | ||
987 | public string Description { get; set; } | 995 | public string Description { get; set; } |