// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. namespace FlaxEngine { partial struct MaterialInfo { /// /// Creates the default . /// /// The result. public static MaterialInfo CreateDefault() { return new MaterialInfo { Domain = MaterialDomain.Surface, BlendMode = MaterialBlendMode.Opaque, ShadingModel = MaterialShadingModel.Lit, UsageFlags = MaterialUsageFlags.None, FeaturesFlags = MaterialFeaturesFlags.None, DecalBlendingMode = MaterialDecalBlendingMode.Translucent, PostFxLocation = MaterialPostFxLocation.AfterPostProcessingPass, MaskThreshold = 0.3f, OpacityThreshold = 0.12f, TessellationMode = TessellationMethod.None, MaxTessellationFactor = 15, }; } /// /// Implements the operator ==. /// /// The a. /// The b. /// The result of the operator. public static bool operator ==(MaterialInfo a, MaterialInfo b) { return a.Equals(b); } /// /// Implements the operator !=. /// /// The a. /// The b. /// The result of the operator. public static bool operator !=(MaterialInfo a, MaterialInfo b) { return !a.Equals(b); } /// /// Compares with the other material info and returns true if both values are equal. /// /// The other info. /// True if both objects are equal, otherwise false. public bool Equals(MaterialInfo other) { return Domain == other.Domain && BlendMode == other.BlendMode && ShadingModel == other.ShadingModel && UsageFlags == other.UsageFlags && FeaturesFlags == other.FeaturesFlags && DecalBlendingMode == other.DecalBlendingMode && PostFxLocation == other.PostFxLocation && Mathf.NearEqual(MaskThreshold, other.MaskThreshold) && Mathf.NearEqual(OpacityThreshold, other.OpacityThreshold) && TessellationMode == other.TessellationMode && MaxTessellationFactor == other.MaxTessellationFactor; } /// public override bool Equals(object obj) { return obj is MaterialInfo info && Equals(info); } /// public override int GetHashCode() { unchecked { var hashCode = (int)Domain; hashCode = (hashCode * 397) ^ (int)BlendMode; hashCode = (hashCode * 397) ^ (int)ShadingModel; hashCode = (hashCode * 397) ^ (int)UsageFlags; hashCode = (hashCode * 397) ^ (int)FeaturesFlags; hashCode = (hashCode * 397) ^ (int)PostFxLocation; hashCode = (hashCode * 397) ^ (int)DecalBlendingMode; hashCode = (hashCode * 397) ^ (int)(MaskThreshold * 1000.0f); hashCode = (hashCode * 397) ^ (int)(OpacityThreshold * 1000.0f); hashCode = (hashCode * 397) ^ (int)TessellationMode; hashCode = (hashCode * 397) ^ MaxTessellationFactor; return hashCode; } } } }