mirror of
				https://github.com/chev2/botw-toolset.git
				synced 2025-10-30 08:12:17 +00:00 
			
		
		
		
	Use built-in Math.Clamp over MathExt.Clamp, remove MathExt.Clamp
This commit is contained in:
		
							parent
							
								
									3962cdb38c
								
							
						
					
					
						commit
						0052ebc5c5
					
				
					 3 changed files with 4 additions and 21 deletions
				
			
		|  | @ -412,7 +412,7 @@ namespace BOTWToolset.Control | ||||||
|                 if (float.TryParse(textSender.Text, out float overrideValue)) |                 if (float.TryParse(textSender.Text, out float overrideValue)) | ||||||
|                 { |                 { | ||||||
|                     // Clamp value between 0 and 1 |                     // Clamp value between 0 and 1 | ||||||
|                     overrideValue = MathExt.Clamp(overrideValue, 0.0f, 1.0f); |                     overrideValue = Math.Clamp(overrideValue, 0.0f, 1.0f); | ||||||
| 
 | 
 | ||||||
|                     BOTWConsole.Log($"Overriding {textSender.Name} with value {overrideValue}"); |                     BOTWConsole.Log($"Overriding {textSender.Name} with value {overrideValue}"); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -23,10 +23,10 @@ namespace BOTWToolset.IO.TSCB | ||||||
|         public uint FileBaseOffset { get => _fileBaseOffset; set => _fileBaseOffset = value; } |         public uint FileBaseOffset { get => _fileBaseOffset; set => _fileBaseOffset = value; } | ||||||
|         private uint _fileBaseOffset; |         private uint _fileBaseOffset; | ||||||
| 
 | 
 | ||||||
|         public float WorldScale { get => _worldScale; set => _worldScale = value.Clamp(0f, 800.0f); } |         public float WorldScale { get => _worldScale; set => _worldScale = Math.Clamp(value, 0f, 800.0f); } | ||||||
|         private float _worldScale; |         private float _worldScale; | ||||||
| 
 | 
 | ||||||
|         public float TerrainMaxHeight { get => _terrainMaxHeight; set => _terrainMaxHeight = value.Clamp(0f, 800.0f); } |         public float TerrainMaxHeight { get => _terrainMaxHeight; set => _terrainMaxHeight = Math.Clamp(value, 0f, 800.0f); } | ||||||
|         private float _terrainMaxHeight; |         private float _terrainMaxHeight; | ||||||
| 
 | 
 | ||||||
|         public byte[] MaterialInfoOffsets; |         public byte[] MaterialInfoOffsets; | ||||||
|  |  | ||||||
							
								
								
									
										19
									
								
								MathExt.cs
									
										
									
									
									
								
							
							
						
						
									
										19
									
								
								MathExt.cs
									
										
									
									
									
								
							|  | @ -1,27 +1,10 @@ | ||||||
| using System; | namespace BOTWToolset | ||||||
| 
 |  | ||||||
| namespace BOTWToolset |  | ||||||
| { | { | ||||||
|     /// <summary> |     /// <summary> | ||||||
|     /// Extensions for Math. |     /// Extensions for Math. | ||||||
|     /// </summary> |     /// </summary> | ||||||
|     static class MathExt |     static class MathExt | ||||||
|     { |     { | ||||||
|         /// <summary> |  | ||||||
|         /// Clamps a value into a minimum and maximum range. |  | ||||||
|         /// </summary> |  | ||||||
|         /// <typeparam name="T"></typeparam> |  | ||||||
|         /// <param name="val">Value to clamp.</param> |  | ||||||
|         /// <param name="min">The minimum value to use.</param> |  | ||||||
|         /// <param name="max">The maximum value to use.</param> |  | ||||||
|         /// <returns></returns> |  | ||||||
|         public static T Clamp<T>(this T val, T min, T max) where T : IComparable<T> |  | ||||||
|         { |  | ||||||
|             if (val.CompareTo(min) < 0) return min; |  | ||||||
|             else if (val.CompareTo(max) > 0) return max; |  | ||||||
|             else return val; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         /// <summary> |         /// <summary> | ||||||
|         /// Linearly interpolates a value. |         /// Linearly interpolates a value. | ||||||
|         /// </summary> |         /// </summary> | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Chev
						Chev