From caad1edabf755c2ef8e00f94f39a8b4c524012b4 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 17 Jan 2013 14:44:54 -0800 Subject: Add utility function to clamp a vector to a maximum magnitude. --- OpenSim/Framework/Util.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'OpenSim/Framework/Util.cs') diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index f511494..f6c9d15 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -299,6 +299,18 @@ namespace OpenSim.Framework x; } + // Clamp the maximum magnitude of a vector + public static Vector3 ClampV(Vector3 x, float max) + { + Vector3 ret = x; + float lenSq = x.LengthSquared(); + if (lenSq > (max * max)) + { + x = x / x.Length() * max; + } + return x; + } + // Inclusive, within range test (true if equal to the endpoints) public static bool InRange(T x, T min, T max) where T : IComparable -- cgit v1.1 From b77da5039eba6db0f904bfa9ca0852d640436055 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Fri, 4 Jan 2013 08:43:05 +0200 Subject: Assign the SmartThreadPool name in the constructor This is required because some threads are created in the constructor, so assigning the name afterwards would be too late. --- OpenSim/Framework/Util.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'OpenSim/Framework/Util.cs') diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index f6c9d15..9b1e97d 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -1658,8 +1658,13 @@ namespace OpenSim.Framework if (m_ThreadPool != null) throw new InvalidOperationException("SmartThreadPool is already initialized"); - m_ThreadPool = new SmartThreadPool(2000, maxThreads, 2); - m_ThreadPool.Name = "Util"; + STPStartInfo startInfo = new STPStartInfo(); + startInfo.ThreadPoolName = "Util"; + startInfo.IdleTimeout = 2000; + startInfo.MaxWorkerThreads = maxThreads; + startInfo.MinWorkerThreads = 2; + + m_ThreadPool = new SmartThreadPool(startInfo); } public static int FireAndForgetCount() -- cgit v1.1