// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved. using System; namespace FlaxEngine { partial struct GPUSamplerDescription : IEquatable { /// /// Clears description. /// public void Clear() { this = new GPUSamplerDescription(); MaxMipLevel = float.MaxValue; } /// /// Creates a new with default settings. /// /// The filtering method. /// The addressing mode. /// A new instance of class. public static GPUSamplerDescription New(GPUSamplerFilter filter = GPUSamplerFilter.Point, GPUSamplerAddressMode addressMode = GPUSamplerAddressMode.Wrap) { return new GPUSamplerDescription { Filter = filter, AddressU = addressMode, AddressV = addressMode, AddressW = addressMode, MaxMipLevel = float.MaxValue, }; } /// public bool Equals(GPUSamplerDescription other) { return Filter == other.Filter && AddressU == other.AddressU && AddressV == other.AddressV && AddressW == other.AddressW && Mathf.NearEqual(MipBias, other.MipBias) && Mathf.NearEqual(MinMipLevel, other.MinMipLevel) && Mathf.NearEqual(MaxMipLevel, other.MaxMipLevel) && MaxAnisotropy == other.MaxAnisotropy && BorderColor == other.BorderColor && ComparisonFunction == other.ComparisonFunction; } /// public override bool Equals(object obj) { return obj is GPUSamplerDescription other && Equals(other); } /// public override int GetHashCode() { unchecked { var hashCode = (int)Filter; hashCode = (hashCode * 397) ^ (int)AddressU; hashCode = (hashCode * 397) ^ (int)AddressV; hashCode = (hashCode * 397) ^ (int)AddressW; hashCode = (hashCode * 397) ^ (int)MipBias; hashCode = (hashCode * 397) ^ (int)MinMipLevel; hashCode = (hashCode * 397) ^ (int)MaxMipLevel; hashCode = (hashCode * 397) ^ MaxAnisotropy; hashCode = (hashCode * 397) ^ (int)BorderColor; hashCode = (hashCode * 397) ^ (int)ComparisonFunction; return hashCode; } } } }