mirror of
https://github.com/opensim/opensim.git
synced 2026-08-13 13:15:44 +08:00
replace Util.Clamp<T>()
This commit is contained in:
@@ -762,8 +762,8 @@ namespace OpenSim.Framework
|
||||
// There is a practical limit to region size.
|
||||
if (RegionSizeX > Constants.MaximumRegionSize || RegionSizeY > Constants.MaximumRegionSize)
|
||||
{
|
||||
RegionSizeX = Util.Clamp<uint>(RegionSizeX, Constants.RegionSize, Constants.MaximumRegionSize);
|
||||
RegionSizeY = Util.Clamp<uint>(RegionSizeY, Constants.RegionSize, Constants.MaximumRegionSize);
|
||||
RegionSizeX = Math.Clamp(RegionSizeX, Constants.RegionSize, Constants.MaximumRegionSize);
|
||||
RegionSizeY = Math.Clamp(RegionSizeY, Constants.RegionSize, Constants.MaximumRegionSize);
|
||||
m_log.ErrorFormat("{0} Region dimensions must be less than {1}. Clamping {2}'s size to <{3},{4}>",
|
||||
LogHeader, Constants.MaximumRegionSize, m_regionName, RegionSizeX, RegionSizeY);
|
||||
}
|
||||
|
||||
@@ -659,6 +659,7 @@ namespace OpenSim.Framework
|
||||
return true;
|
||||
}
|
||||
|
||||
//obsolete use Math.Clamp
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T Clamp<T>(T x, T min, T max)
|
||||
where T : IComparable<T>
|
||||
|
||||
@@ -349,7 +349,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||
get { return m_dripRate; }
|
||||
set
|
||||
{
|
||||
m_dripRate = OpenSim.Framework.Util.Clamp<float>(value, m_minimumFlow, MaxDripRate);
|
||||
m_dripRate = Math.Clamp(value, m_minimumFlow, MaxDripRate);
|
||||
|
||||
if (m_parent != null)
|
||||
m_parent.RegisterRequest(this, m_dripRate);
|
||||
|
||||
@@ -152,7 +152,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
||||
return;
|
||||
}
|
||||
//pass this in as degrees now, convert to radians later during actual work phase
|
||||
rotation = Util.Clamp<float>(rotation, -359f, 359f);
|
||||
rotation = Math.Clamp(rotation, -359f, 359f);
|
||||
});
|
||||
options.Add("rotation-center=", delegate(string v)
|
||||
{
|
||||
|
||||
@@ -232,9 +232,9 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap
|
||||
detailTexture[t].UnlockBits(bmdata);
|
||||
detailTexture[t].Dispose();
|
||||
|
||||
mapColorsRed[t] = (byte)Util.Clamp(cR / npixeis, 0 , 255);
|
||||
mapColorsGreen[t] = (byte)Util.Clamp(cG / npixeis, 0 , 255);
|
||||
mapColorsBlue[t] = (byte)Util.Clamp(cB / npixeis, 0 , 255);
|
||||
mapColorsRed[t] = (byte)Math.Clamp(cR / npixeis, 0 , 255);
|
||||
mapColorsGreen[t] = (byte)Math.Clamp(cG / npixeis, 0 , 255);
|
||||
mapColorsBlue[t] = (byte)Math.Clamp(cB / npixeis, 0 , 255);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1875,7 +1875,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
nowMS = Util.GetTimeStampMS();
|
||||
sleepMS = (float)(nowMS - lastMS);
|
||||
sleepError = sleepMS - frameMS;
|
||||
Util.Clamp(sleepError, 0.0f, 20f);
|
||||
sleepError = Math.Clamp(sleepError, 0.0f, 20f);
|
||||
frameMS = (float)(nowMS - framestart);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -408,7 +408,7 @@ namespace OpenSim.Region.PhysicsModule.BulletS
|
||||
get { return base.Efficiency; }
|
||||
set
|
||||
{
|
||||
base.Efficiency = Util.Clamp(value, 0f, 1f);
|
||||
base.Efficiency = Math.Clamp(value, 0f, 1f);
|
||||
|
||||
// Compute factors based on efficiency.
|
||||
// If efficiency is high (1f), use a factor value that moves the error value to zero with little overshoot.
|
||||
|
||||
@@ -1606,7 +1606,7 @@ namespace OpenSim.Region.PhysicsModule.BulletS
|
||||
|
||||
returnMass = Density * BSParam.DensityScaleFactor * volume;
|
||||
|
||||
returnMass = Util.Clamp(returnMass, BSParam.MinimumObjectMass, BSParam.MaximumObjectMass);
|
||||
returnMass = Math.Clamp(returnMass, BSParam.MinimumObjectMass, BSParam.MaximumObjectMass);
|
||||
// DetailLog("{0},BSPrim.CalculateMass,den={1},vol={2},mass={3}", LocalID, Density, volume, returnMass);
|
||||
DetailLog("{0},BSPrim.CalculateMass,den={1},vol={2},mass={3},pathB={4},pathE={5},profB={6},profE={7},siz={8}",
|
||||
LocalID, Density, volume, returnMass, pathBegin, pathEnd, profileBegin, profileEnd, _size);
|
||||
|
||||
@@ -363,8 +363,8 @@ namespace OpenSim.Region.PhysicsModule.BulletS
|
||||
// First, base addresses are never negative so correct for that possible problem.
|
||||
if (ret.X < 0f || ret.Y < 0f)
|
||||
{
|
||||
ret.X = Util.Clamp<float>(ret.X, 0f, 1000000f);
|
||||
ret.Y = Util.Clamp<float>(ret.Y, 0f, 1000000f);
|
||||
ret.X = Math.Clamp(ret.X, 0f, 1000000f);
|
||||
ret.Y = Math.Clamp(ret.Y, 0f, 1000000f);
|
||||
DetailLog("{0},BSTerrainManager.ClampPositionToKnownTerrain,zeroingNegXorY,oldPos={1},newPos={2}",
|
||||
BSScene.DetailLogZero, pPos, ret);
|
||||
}
|
||||
@@ -510,8 +510,8 @@ namespace OpenSim.Region.PhysicsModule.BulletS
|
||||
return ret;
|
||||
|
||||
// Just some sanity
|
||||
ret.X = Util.Clamp<float>(ret.X, 0f, 1000000f);
|
||||
ret.Y = Util.Clamp<float>(ret.Y, 0f, 1000000f);
|
||||
ret.X = Math.Clamp(ret.X, 0f, 1000000f);
|
||||
ret.Y = Math.Clamp(ret.Y, 0f, 1000000f);
|
||||
ret.Z = 0f;
|
||||
|
||||
lock (m_terrains)
|
||||
|
||||
@@ -6237,8 +6237,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
float rsy = World.RegionInfo.RegionSizeY;
|
||||
|
||||
// can understand what sl does if position is not in region, so do something :)
|
||||
float px = (float)Util.Clamp(pos.x, 0.5, rsx - 0.5);
|
||||
float py = (float)Util.Clamp(pos.y, 0.5, rsy - 0.5);
|
||||
float px = Math.Clamp((float)pos.x, 0.5f, rsx - 0.5f);
|
||||
float py = Math.Clamp((float)pos.y, 0.5f, rsy - 0.5f);
|
||||
|
||||
float ex, ey;
|
||||
|
||||
@@ -10247,10 +10247,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
return new LSL_List();
|
||||
}
|
||||
|
||||
float repeatX = (float)Util.Clamp(mnrepeat.x,-100.0, 100.0);
|
||||
float repeatY = (float)Util.Clamp(mnrepeat.y,-100.0, 100.0);
|
||||
float offsetX = (float)Util.Clamp(mnoffset.x, 0, 1.0);
|
||||
float offsetY = (float)Util.Clamp(mnoffset.y, 0, 1.0);
|
||||
float repeatX = Math.Clamp((float)mnrepeat.x,-100.0f, 100.0f);
|
||||
float repeatY = Math.Clamp((float)mnrepeat.y,-100.0f, 100.0f);
|
||||
float offsetX = Math.Clamp((float)mnoffset.x, 0f, 1.0f);
|
||||
float offsetY = Math.Clamp((float)mnoffset.y, 0f, 1.0f);
|
||||
|
||||
materialChanged |= SetMaterialNormalMap(part, face, mapID, repeatX, repeatY, offsetX, offsetY, mnrot);
|
||||
break;
|
||||
@@ -10349,15 +10349,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
return new LSL_List();
|
||||
}
|
||||
|
||||
float srepeatX = (float)Util.Clamp(msrepeat.x, -100.0, 100.0);
|
||||
float srepeatY = (float)Util.Clamp(msrepeat.y, -100.0, 100.0);
|
||||
float soffsetX = (float)Util.Clamp(msoffset.x, -1.0, 1.0);
|
||||
float soffsetY = (float)Util.Clamp(msoffset.y, -1.0, 1.0);
|
||||
byte colorR = (byte)(255.0 * Util.Clamp(mscolor.x, 0, 1.0) + 0.5);
|
||||
byte colorG = (byte)(255.0 * Util.Clamp(mscolor.y, 0, 1.0) + 0.5);
|
||||
byte colorB = (byte)(255.0 * Util.Clamp(mscolor.z, 0, 1.0) + 0.5);
|
||||
byte gloss = (byte)Util.Clamp((int)msgloss, 0, 255);
|
||||
byte env = (byte)Util.Clamp((int)msenv, 0, 255);
|
||||
float srepeatX = Math.Clamp((float)msrepeat.x, -100.0f, 100.0f);
|
||||
float srepeatY = Math.Clamp((float)msrepeat.y, -100.0f, 100.0f);
|
||||
float soffsetX = Math.Clamp((float)msoffset.x, -1.0f, 1.0f);
|
||||
float soffsetY = Math.Clamp((float)msoffset.y, -1.0f, 1.0f);
|
||||
byte colorR = (byte)(255.0f * Math.Clamp((float)mscolor.x, 0f, 1.0f) + 0.5f);
|
||||
byte colorG = (byte)(255.0f * Math.Clamp((float)mscolor.y, 0f, 1.0f) + 0.5f);
|
||||
byte colorB = (byte)(255.0f * Math.Clamp((float)mscolor.z, 0f, 1.0f) + 0.5f);
|
||||
byte gloss = (byte)Math.Clamp((int)msgloss, 0, 255);
|
||||
byte env = (byte)Math.Clamp((int)msenv, 0, 255);
|
||||
|
||||
materialChanged |= SetMaterialSpecMap(part, face, smapID, srepeatX, srepeatY, soffsetX, soffsetY,
|
||||
msrot, colorR, colorG, colorB, gloss, env);
|
||||
@@ -10426,9 +10426,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
{
|
||||
part.Shape.ProjectionEntry = true;
|
||||
part.Shape.ProjectionTextureUUID = stexID;
|
||||
part.Shape.ProjectionFOV = Util.Clamp(fov, 0, 3.0f);
|
||||
part.Shape.ProjectionFocus = Util.Clamp(focus, -20.0f, 20.0f);
|
||||
part.Shape.ProjectionAmbiance = Util.Clamp(amb, 0, 1.0f);
|
||||
part.Shape.ProjectionFOV = Math.Clamp(fov, 0, 3.0f);
|
||||
part.Shape.ProjectionFocus = Math.Clamp(focus, -20.0f, 20.0f);
|
||||
part.Shape.ProjectionAmbiance = Math.Clamp(amb, 0, 1.0f);
|
||||
|
||||
part.ParentGroup.HasGroupChanged = true;
|
||||
part.ScheduleFullUpdate();
|
||||
@@ -16586,32 +16586,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
int yInt = (int)yPos;
|
||||
|
||||
// Corner 1 of 1x1 rectangle
|
||||
int x = Util.Clamp<int>(xInt+1, 0, World.Heightmap.Width - 1);
|
||||
int y = Util.Clamp<int>(yInt+1, 0, World.Heightmap.Height - 1);
|
||||
int x = Math.Clamp(xInt+1, 0, World.Heightmap.Width - 1);
|
||||
int y = Math.Clamp(yInt+1, 0, World.Heightmap.Height - 1);
|
||||
Vector3 pos1 = new(x, y, (float)World.Heightmap[x, y]);
|
||||
// Adjust bounding box
|
||||
zLower = Math.Min(zLower, pos1.Z);
|
||||
zUpper = Math.Max(zUpper, pos1.Z);
|
||||
|
||||
// Corner 2 of 1x1 rectangle
|
||||
x = Util.Clamp<int>(xInt, 0, World.Heightmap.Width - 1);
|
||||
y = Util.Clamp<int>(yInt+1, 0, World.Heightmap.Height - 1);
|
||||
x = Math.Clamp(xInt, 0, World.Heightmap.Width - 1);
|
||||
y = Math.Clamp(yInt+1, 0, World.Heightmap.Height - 1);
|
||||
Vector3 pos2 = new(x, y, (float)World.Heightmap[x, y]);
|
||||
// Adjust bounding box
|
||||
zLower = Math.Min(zLower, pos2.Z);
|
||||
zUpper = Math.Max(zUpper, pos2.Z);
|
||||
|
||||
// Corner 3 of 1x1 rectangle
|
||||
x = Util.Clamp<int>(xInt, 0, World.Heightmap.Width - 1);
|
||||
y = Util.Clamp<int>(yInt, 0, World.Heightmap.Height - 1);
|
||||
x = Math.Clamp(xInt, 0, World.Heightmap.Width - 1);
|
||||
y = Math.Clamp(yInt, 0, World.Heightmap.Height - 1);
|
||||
Vector3 pos3 = new(x, y, (float)World.Heightmap[x, y]);
|
||||
// Adjust bounding box
|
||||
zLower = Math.Min(zLower, pos3.Z);
|
||||
zUpper = Math.Max(zUpper, pos3.Z);
|
||||
|
||||
// Corner 4 of 1x1 rectangle
|
||||
x = Util.Clamp<int>(xInt+1, 0, World.Heightmap.Width - 1);
|
||||
y = Util.Clamp<int>(yInt, 0, World.Heightmap.Height - 1);
|
||||
x = Math.Clamp(xInt+1, 0, World.Heightmap.Width - 1);
|
||||
y = Math.Clamp(yInt, 0, World.Heightmap.Height - 1);
|
||||
Vector3 pos4 = new(x, y, (float)World.Heightmap[x, y]);
|
||||
// Adjust bounding box
|
||||
zLower = Math.Min(zLower, pos4.Z);
|
||||
|
||||
@@ -3968,9 +3968,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
obj.Shape.ProjectionEntry = true;
|
||||
obj.Shape.ProjectionTextureUUID = texID;
|
||||
obj.Shape.ProjectionFOV = Util.Clamp((float)fov, 0, 3.0f);
|
||||
obj.Shape.ProjectionFocus = Util.Clamp((float)focus, -20.0f, 20.0f);
|
||||
obj.Shape.ProjectionAmbiance = Util.Clamp((float)amb, 0, 1.0f);
|
||||
obj.Shape.ProjectionFOV = Math.Clamp((float)fov, 0, 3.0f);
|
||||
obj.Shape.ProjectionFocus = Math.Clamp((float)focus, -20.0f, 20.0f);
|
||||
obj.Shape.ProjectionAmbiance = Math.Clamp((float)amb, 0, 1.0f);
|
||||
|
||||
obj.ParentGroup.HasGroupChanged = true;
|
||||
obj.ScheduleFullUpdate();
|
||||
|
||||
Reference in New Issue
Block a user