From 8b88def9d05a1d9a8295777ab928dfe95821ec39 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 3 Jun 2025 17:43:01 +0200 Subject: [PATCH] Revert some changes from #3389 that are not relevant for world units --- Source/Editor/CustomEditors/GUI/PropertiesList.cs | 2 +- Source/Editor/GUI/CurveEditor.cs | 2 +- Source/Editor/GUI/Table.cs | 2 +- Source/Editor/GUI/Timeline/GUI/KeyframesEditor.cs | 2 +- Source/Editor/GUI/Timeline/Timeline.cs | 4 ++-- Source/Editor/GUI/Timeline/Tracks/AudioTrack.cs | 2 +- Source/Editor/GUI/Tree/TreeNode.cs | 2 +- Source/Editor/Tools/Foliage/FoliageTypesTab.cs | 6 +++--- .../Editor/Viewport/Previews/CubeTexturePreview.cs | 2 +- .../Viewport/Previews/ParticleEmitterPreview.cs | 2 +- Source/Editor/Viewport/Previews/TexturePreview.cs | 2 +- Source/Engine/Animations/Curve.h | 8 ++++---- Source/Engine/Audio/Audio.cpp | 2 +- Source/Engine/Audio/AudioSource.cpp | 14 +++++++------- Source/Engine/ContentImporters/CreateMaterial.cpp | 2 +- Source/Engine/Core/Math/Viewport.cs | 12 ++++++------ Source/Engine/Foliage/Foliage.cpp | 2 +- Source/Engine/Graphics/Materials/MaterialInfo.cs | 4 ++-- .../Engine/Graphics/Materials/MaterialParams.cpp | 12 ++++++------ .../Graphics/Textures/GPUSamplerDescription.cs | 6 +++--- Source/Engine/Render2D/TextLayoutOptions.h | 4 ++-- Source/Engine/Renderer/ShadowsPass.cpp | 12 ++++++------ Source/Engine/UI/GUI/CanvasScaler.cs | 8 ++++---- Source/Engine/UI/GUI/Common/ProgressBar.cs | 2 +- Source/Engine/UI/GUI/Common/Slider.cs | 2 +- Source/Engine/UI/GUI/Control.Bounds.cs | 9 +++++---- Source/Engine/UI/GUI/Margin.cs | 8 ++++---- Source/Engine/UI/GUI/Panels/DropPanel.cs | 2 +- Source/Engine/UI/GUI/Panels/Panel.cs | 2 +- Source/Engine/UI/GUI/Panels/PanelWithMargins.cs | 12 ++++++------ Source/Engine/UI/GUI/Panels/ScrollBar.cs | 6 +++--- Source/Engine/UI/GUI/Panels/SplitPanel.cs | 2 +- Source/Engine/Video/VideoPlayer.cpp | 8 ++++---- 33 files changed, 84 insertions(+), 83 deletions(-) diff --git a/Source/Editor/CustomEditors/GUI/PropertiesList.cs b/Source/Editor/CustomEditors/GUI/PropertiesList.cs index f9e6318b4..ef90fc706 100644 --- a/Source/Editor/CustomEditors/GUI/PropertiesList.cs +++ b/Source/Editor/CustomEditors/GUI/PropertiesList.cs @@ -38,7 +38,7 @@ namespace FlaxEditor.CustomEditors.GUI set { value = Mathf.Clamp(value, 0.05f, 0.95f); - if (_splitterValue != value) + if (!Mathf.NearEqual(_splitterValue, value)) { _splitterValue = value; UpdateSplitRect(); diff --git a/Source/Editor/GUI/CurveEditor.cs b/Source/Editor/GUI/CurveEditor.cs index de83151ab..706d07b32 100644 --- a/Source/Editor/GUI/CurveEditor.cs +++ b/Source/Editor/GUI/CurveEditor.cs @@ -385,7 +385,7 @@ namespace FlaxEditor.GUI get => _fps; set { - if (_fps.HasValue == value.HasValue && (!value.HasValue || _fps.Value == value.Value)) + if (_fps.HasValue == value.HasValue && (!value.HasValue || Mathf.NearEqual(_fps.Value, value.Value))) return; _fps = value; diff --git a/Source/Editor/GUI/Table.cs b/Source/Editor/GUI/Table.cs index 3e2de92c5..71b01aa0f 100644 --- a/Source/Editor/GUI/Table.cs +++ b/Source/Editor/GUI/Table.cs @@ -28,7 +28,7 @@ namespace FlaxEditor.GUI set { value = Mathf.Max(value, 1); - if (value != _headerHeight) + if (!Mathf.NearEqual(value, _headerHeight)) { _headerHeight = value; PerformLayout(); diff --git a/Source/Editor/GUI/Timeline/GUI/KeyframesEditor.cs b/Source/Editor/GUI/Timeline/GUI/KeyframesEditor.cs index f02936b8f..d6fa0e076 100644 --- a/Source/Editor/GUI/Timeline/GUI/KeyframesEditor.cs +++ b/Source/Editor/GUI/Timeline/GUI/KeyframesEditor.cs @@ -692,7 +692,7 @@ namespace FlaxEditor.GUI get => _fps; set { - if (_fps.HasValue == value.HasValue && (!value.HasValue || _fps.Value == value.Value)) + if (_fps.HasValue == value.HasValue && (!value.HasValue || Mathf.NearEqual(_fps.Value, value.Value))) return; _fps = value; diff --git a/Source/Editor/GUI/Timeline/Timeline.cs b/Source/Editor/GUI/Timeline/Timeline.cs index fb6e4cf07..15e7eb953 100644 --- a/Source/Editor/GUI/Timeline/Timeline.cs +++ b/Source/Editor/GUI/Timeline/Timeline.cs @@ -319,7 +319,7 @@ namespace FlaxEditor.GUI.Timeline set { value = Mathf.Clamp(value, 0.1f, 1000.0f); - if (_framesPerSecond == value) + if (Mathf.NearEqual(_framesPerSecond, value)) return; Undo?.AddAction(new EditFpsAction(this, _framesPerSecond, value)); @@ -508,7 +508,7 @@ namespace FlaxEditor.GUI.Timeline set { value = Mathf.Clamp(value, 0.00001f, 1000.0f); - if (_zoom == value) + if (Mathf.NearEqual(_zoom, value)) return; _zoom = value; diff --git a/Source/Editor/GUI/Timeline/Tracks/AudioTrack.cs b/Source/Editor/GUI/Timeline/Tracks/AudioTrack.cs index b17c18b8c..75c5788a7 100644 --- a/Source/Editor/GUI/Timeline/Tracks/AudioTrack.cs +++ b/Source/Editor/GUI/Timeline/Tracks/AudioTrack.cs @@ -41,7 +41,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks get => Preview.ViewOffset; set { - if (Preview.ViewOffset == value) + if (Mathf.NearEqual(Preview.ViewOffset, value)) return; Preview.ViewOffset = value; Timeline?.MarkAsEdited(); diff --git a/Source/Editor/GUI/Tree/TreeNode.cs b/Source/Editor/GUI/Tree/TreeNode.cs index a46d9ef96..40c276bf4 100644 --- a/Source/Editor/GUI/Tree/TreeNode.cs +++ b/Source/Editor/GUI/Tree/TreeNode.cs @@ -214,7 +214,7 @@ namespace FlaxEditor.GUI.Tree get => _headerHeight; set { - if (_headerHeight != value) + if (!Mathf.NearEqual(_headerHeight, value)) { _headerHeight = value; PerformLayout(); diff --git a/Source/Editor/Tools/Foliage/FoliageTypesTab.cs b/Source/Editor/Tools/Foliage/FoliageTypesTab.cs index 0d3b1ec95..3094d2a77 100644 --- a/Source/Editor/Tools/Foliage/FoliageTypesTab.cs +++ b/Source/Editor/Tools/Foliage/FoliageTypesTab.cs @@ -107,7 +107,7 @@ namespace FlaxEditor.Tools.Foliage get => _type.CullDistance; set { - if (_type.CullDistance == value) + if (Mathf.NearEqual(_type.CullDistance, value)) return; _type.CullDistance = value; Foliage.UpdateCullDistance(); @@ -120,7 +120,7 @@ namespace FlaxEditor.Tools.Foliage get => _type.CullDistanceRandomRange; set { - if (_type.CullDistanceRandomRange == value) + if (Mathf.NearEqual(_type.CullDistanceRandomRange, value)) return; _type.CullDistanceRandomRange = value; Foliage.UpdateCullDistance(); @@ -174,7 +174,7 @@ namespace FlaxEditor.Tools.Foliage get => _type.DensityScalingScale; set { - if (_type.DensityScalingScale == value) + if (Mathf.NearEqual(_type.DensityScalingScale, value)) return; _type.DensityScalingScale = value; Foliage.RebuildClusters(); diff --git a/Source/Editor/Viewport/Previews/CubeTexturePreview.cs b/Source/Editor/Viewport/Previews/CubeTexturePreview.cs index 9c7c9e6e9..f0b05c8e6 100644 --- a/Source/Editor/Viewport/Previews/CubeTexturePreview.cs +++ b/Source/Editor/Viewport/Previews/CubeTexturePreview.cs @@ -95,7 +95,7 @@ namespace FlaxEditor.Viewport.Previews get => _mipLevel; set { - if (_mipLevel == value) + if (!Mathf.NearEqual(_mipLevel, value)) { _mipLevel = value; _previewMaterial.SetParameterValue("Mip", value); diff --git a/Source/Editor/Viewport/Previews/ParticleEmitterPreview.cs b/Source/Editor/Viewport/Previews/ParticleEmitterPreview.cs index cb05016b9..023bd121f 100644 --- a/Source/Editor/Viewport/Previews/ParticleEmitterPreview.cs +++ b/Source/Editor/Viewport/Previews/ParticleEmitterPreview.cs @@ -42,7 +42,7 @@ namespace FlaxEditor.Viewport.Previews set { value = Mathf.Clamp(value, 0.1f, 100000000000.0f); - if (_playbackDuration == value) + if (Mathf.NearEqual(_playbackDuration, value)) return; _playbackDuration = value; diff --git a/Source/Editor/Viewport/Previews/TexturePreview.cs b/Source/Editor/Viewport/Previews/TexturePreview.cs index b8f801035..709bc953e 100644 --- a/Source/Editor/Viewport/Previews/TexturePreview.cs +++ b/Source/Editor/Viewport/Previews/TexturePreview.cs @@ -303,7 +303,7 @@ namespace FlaxEditor.Viewport.Previews get => _mipLevel; set { - if (_mipLevel != value) + if (!Mathf.NearEqual(_mipLevel, value)) { _mipLevel = value; _previewMaterial.SetParameterValue("Mip", value); diff --git a/Source/Engine/Animations/Curve.h b/Source/Engine/Animations/Curve.h index 8508d8751..11142d1e4 100644 --- a/Source/Engine/Animations/Curve.h +++ b/Source/Engine/Animations/Curve.h @@ -58,7 +58,7 @@ public: bool operator==(const StepCurveKeyframe& other) const { - return Time == other.Time && Value == other.Value; + return Math::NearEqual(Time, other.Time) && Math::NearEqual(Value, other.Value); } } PACK_END(); @@ -113,7 +113,7 @@ public: bool operator==(const LinearCurveKeyframe& other) const { - return Time == other.Time && Value == other.Value; + return Math::NearEqual(Time, other.Time) && Math::NearEqual(Value, other.Value); } } PACK_END(); @@ -188,7 +188,7 @@ public: bool operator==(const HermiteCurveKeyframe& other) const { - return Time == other.Time && Value == other.Value && TangentIn == other.TangentIn && TangentOut == other.TangentOut; + return Math::NearEqual(Time, other.Time) && Math::NearEqual(Value, other.Value) && Math::NearEqual(TangentIn, other.TangentIn) && Math::NearEqual(TangentOut, other.TangentOut); } } PACK_END(); @@ -276,7 +276,7 @@ public: bool operator==(const BezierCurveKeyframe& other) const { - return Time == other.Time && Value == other.Value && TangentIn == other.TangentIn && TangentOut == other.TangentOut; + return Math::NearEqual(Time, other.Time) && Math::NearEqual(Value, other.Value) && Math::NearEqual(TangentIn, other.TangentIn) && Math::NearEqual(TangentOut, other.TangentOut); } } PACK_END(); diff --git a/Source/Engine/Audio/Audio.cpp b/Source/Engine/Audio/Audio.cpp index 2a2d30d5c..e19efabf1 100644 --- a/Source/Engine/Audio/Audio.cpp +++ b/Source/Engine/Audio/Audio.cpp @@ -219,7 +219,7 @@ void AudioService::Update() // Mute audio if app has no user focus masterVolume = 0.0f; } - if (Volume != masterVolume) + if (Math::NotNearEqual(Volume, masterVolume)) { Volume = masterVolume; AudioBackend::SetVolume(masterVolume); diff --git a/Source/Engine/Audio/AudioSource.cpp b/Source/Engine/Audio/AudioSource.cpp index ab17910fd..cff89e7e1 100644 --- a/Source/Engine/Audio/AudioSource.cpp +++ b/Source/Engine/Audio/AudioSource.cpp @@ -29,7 +29,7 @@ AudioSource::AudioSource(const SpawnParams& params) void AudioSource::SetVolume(float value) { value = Math::Saturate(value); - if (_volume == value) + if (Math::NearEqual(_volume, value)) return; _volume = value; if (SourceID) @@ -39,7 +39,7 @@ void AudioSource::SetVolume(float value) void AudioSource::SetPitch(float value) { value = Math::Clamp(value, 0.5f, 2.0f); - if (_pitch == value) + if (Math::NearEqual(_pitch, value)) return; _pitch = value; if (SourceID) @@ -49,7 +49,7 @@ void AudioSource::SetPitch(float value) void AudioSource::SetPan(float value) { value = Math::Clamp(value, -1.0f, 1.0f); - if (_pan == value) + if (Math::NearEqual(_pan, value)) return; _pan = value; if (SourceID) @@ -80,7 +80,7 @@ void AudioSource::SetStartTime(float value) void AudioSource::SetMinDistance(float value) { value = Math::Max(0.0f, value); - if (_minDistance == value) + if (Math::NearEqual(_minDistance, value)) return; _minDistance = value; if (SourceID) @@ -90,7 +90,7 @@ void AudioSource::SetMinDistance(float value) void AudioSource::SetAttenuation(float value) { value = Math::Max(0.0f, value); - if (_attenuation == value) + if (Math::NearEqual(_attenuation, value)) return; _attenuation = value; if (SourceID) @@ -100,7 +100,7 @@ void AudioSource::SetAttenuation(float value) void AudioSource::SetDopplerFactor(float value) { value = Math::Max(0.0f, value); - if (_dopplerFactor == value) + if (Math::NearEqual(_dopplerFactor, value)) return; _dopplerFactor = value; if (SourceID) @@ -401,7 +401,7 @@ void AudioSource::Update() _startingToPlay = false; } - if (!UseStreaming() && GetTime() == 0.0f && _isActuallyPlayingSth && !_startingToPlay) + if (!UseStreaming() && Math::NearEqual(GetTime(), 0.0f) && _isActuallyPlayingSth && !_startingToPlay) { int32 queuedBuffers; AudioBackend::Source::GetQueuedBuffersCount(SourceID, queuedBuffers); diff --git a/Source/Engine/ContentImporters/CreateMaterial.cpp b/Source/Engine/ContentImporters/CreateMaterial.cpp index 4cedf0c85..3991585a3 100644 --- a/Source/Engine/ContentImporters/CreateMaterial.cpp +++ b/Source/Engine/ContentImporters/CreateMaterial.cpp @@ -20,7 +20,7 @@ namespace template ShaderGraphNode<>* AddValueNode(MaterialLayer* layer, const float& value, const float& defaultValue) { - if (value == defaultValue) + if (Math::NearEqual(value, defaultValue)) return nullptr; auto& node = layer->Graph.Nodes.AddOne(); node.ID = layer->Graph.Nodes.Count(); diff --git a/Source/Engine/Core/Math/Viewport.cs b/Source/Engine/Core/Math/Viewport.cs index f42c1f22a..f2be10457 100644 --- a/Source/Engine/Core/Math/Viewport.cs +++ b/Source/Engine/Core/Math/Viewport.cs @@ -173,12 +173,12 @@ namespace FlaxEngine /// true if the specified is equal to this instance; otherwise, false. public bool Equals(ref Viewport other) { - return X == other.X && - Y == other.Y && - Width == other.Width && - Height == other.Height && - MinDepth == other.MinDepth && - MaxDepth == other.MaxDepth; + return Mathf.NearEqual(X, other.X) && + Mathf.NearEqual(Y, other.Y) && + Mathf.NearEqual(Width, other.Width) && + Mathf.NearEqual(Height, other.Height) && + Mathf.NearEqual(MinDepth, other.MinDepth) && + Mathf.NearEqual(MaxDepth, other.MaxDepth); } /// diff --git a/Source/Engine/Foliage/Foliage.cpp b/Source/Engine/Foliage/Foliage.cpp index 051450297..a1cd046ae 100644 --- a/Source/Engine/Foliage/Foliage.cpp +++ b/Source/Engine/Foliage/Foliage.cpp @@ -1013,7 +1013,7 @@ bool UpdateFoliageDensityScaling(Actor* actor) void Foliage::SetGlobalDensityScale(float value) { value = Math::Saturate(value); - if (value == GlobalDensityScale) + if (Math::NearEqual(value, GlobalDensityScale)) return; PROFILE_CPU(); diff --git a/Source/Engine/Graphics/Materials/MaterialInfo.cs b/Source/Engine/Graphics/Materials/MaterialInfo.cs index b0a78a6eb..a8ff82665 100644 --- a/Source/Engine/Graphics/Materials/MaterialInfo.cs +++ b/Source/Engine/Graphics/Materials/MaterialInfo.cs @@ -64,8 +64,8 @@ namespace FlaxEngine && DecalBlendingMode == other.DecalBlendingMode && TransparentLightingMode == other.TransparentLightingMode && PostFxLocation == other.PostFxLocation - && MaskThreshold == other.MaskThreshold - && OpacityThreshold == other.OpacityThreshold + && Mathf.NearEqual(MaskThreshold, other.MaskThreshold) + && Mathf.NearEqual(OpacityThreshold, other.OpacityThreshold) && TessellationMode == other.TessellationMode && MaxTessellationFactor == other.MaxTessellationFactor; } diff --git a/Source/Engine/Graphics/Materials/MaterialParams.cpp b/Source/Engine/Graphics/Materials/MaterialParams.cpp index d2a4855b5..e31697f77 100644 --- a/Source/Engine/Graphics/Materials/MaterialParams.cpp +++ b/Source/Engine/Graphics/Materials/MaterialParams.cpp @@ -24,8 +24,8 @@ bool MaterialInfo8::operator==(const MaterialInfo8& other) const && TransparentLighting == other.TransparentLighting && DecalBlendingMode == other.DecalBlendingMode && PostFxLocation == other.PostFxLocation - && MaskThreshold == other.MaskThreshold - && OpacityThreshold == other.OpacityThreshold + && Math::NearEqual(MaskThreshold, other.MaskThreshold) + && Math::NearEqual(OpacityThreshold, other.OpacityThreshold) && Flags == other.Flags && TessellationMode == other.TessellationMode && MaxTessellationFactor == other.MaxTessellationFactor; @@ -89,8 +89,8 @@ bool MaterialInfo9::operator==(const MaterialInfo9& other) const && DecalBlendingMode == other.DecalBlendingMode && PostFxLocation == other.PostFxLocation && CullMode == other.CullMode - && MaskThreshold == other.MaskThreshold - && OpacityThreshold == other.OpacityThreshold + && Math::NearEqual(MaskThreshold, other.MaskThreshold) + && Math::NearEqual(OpacityThreshold, other.OpacityThreshold) && TessellationMode == other.TessellationMode && MaxTessellationFactor == other.MaxTessellationFactor; } @@ -123,8 +123,8 @@ bool MaterialInfo::operator==(const MaterialInfo& other) const && TransparentLightingMode == other.TransparentLightingMode && PostFxLocation == other.PostFxLocation && CullMode == other.CullMode - && MaskThreshold == other.MaskThreshold - && OpacityThreshold == other.OpacityThreshold + && Math::NearEqual(MaskThreshold, other.MaskThreshold) + && Math::NearEqual(OpacityThreshold, other.OpacityThreshold) && TessellationMode == other.TessellationMode && MaxTessellationFactor == other.MaxTessellationFactor; } diff --git a/Source/Engine/Graphics/Textures/GPUSamplerDescription.cs b/Source/Engine/Graphics/Textures/GPUSamplerDescription.cs index 425f28fe6..6a49ce49d 100644 --- a/Source/Engine/Graphics/Textures/GPUSamplerDescription.cs +++ b/Source/Engine/Graphics/Textures/GPUSamplerDescription.cs @@ -40,9 +40,9 @@ namespace FlaxEngine AddressU == other.AddressU && AddressV == other.AddressV && AddressW == other.AddressW && - MipBias == other.MipBias && - MinMipLevel == other.MinMipLevel && - MaxMipLevel == other.MaxMipLevel && + Mathf.NearEqual(MipBias, other.MipBias) && + Mathf.NearEqual(MinMipLevel, other.MinMipLevel) && + Mathf.NearEqual(MaxMipLevel, other.MaxMipLevel) && MaxAnisotropy == other.MaxAnisotropy && BorderColor == other.BorderColor && ComparisonFunction == other.ComparisonFunction; diff --git a/Source/Engine/Render2D/TextLayoutOptions.h b/Source/Engine/Render2D/TextLayoutOptions.h index 5aa84fe5a..75e3b1ea2 100644 --- a/Source/Engine/Render2D/TextLayoutOptions.h +++ b/Source/Engine/Render2D/TextLayoutOptions.h @@ -108,8 +108,8 @@ DECLARE_SCRIPTING_TYPE_MINIMAL(TextLayoutOptions); && HorizontalAlignment == other.HorizontalAlignment && VerticalAlignment == other.VerticalAlignment && TextWrapping == other.TextWrapping - && Scale == other.Scale - && BaseLinesGapScale == other.BaseLinesGapScale; + && Math::NearEqual(Scale, other.Scale) + && Math::NearEqual(BaseLinesGapScale, other.BaseLinesGapScale); } FORCE_INLINE bool operator!=(const TextLayoutOptions& other) const diff --git a/Source/Engine/Renderer/ShadowsPass.cpp b/Source/Engine/Renderer/ShadowsPass.cpp index 374b26347..3937f8554 100644 --- a/Source/Engine/Renderer/ShadowsPass.cpp +++ b/Source/Engine/Renderer/ShadowsPass.cpp @@ -236,9 +236,9 @@ struct ShadowAtlasLight { if (!Cache.StaticValid || !Cache.DynamicValid) return; - if (Cache.Distance != light.ShadowsDistance || - Cache.ShadowsUpdateRate != light.ShadowsUpdateRate || - Cache.ShadowsUpdateRateAtDistance != light.ShadowsUpdateRateAtDistance || + if (!Math::NearEqual(Cache.Distance, light.ShadowsDistance) || + !Math::NearEqual(Cache.ShadowsUpdateRate, light.ShadowsUpdateRate) || + !Math::NearEqual(Cache.ShadowsUpdateRateAtDistance, light.ShadowsUpdateRateAtDistance) || Cache.ShadowFrame != light.ShadowFrame || Cache.ShadowsResolution != light.ShadowsResolution || Float3::Dot(Cache.Direction, light.Direction) < SHADOWS_ROTATION_ERROR) @@ -250,7 +250,7 @@ struct ShadowAtlasLight { // Sun if (!Float3::NearEqual(Cache.Position, view.Position, SHADOWS_POSITION_ERROR) || - Cache.CascadeSplits != CascadeSplits || + !Float4::NearEqual(Cache.CascadeSplits, CascadeSplits) || Float3::Dot(Cache.ViewDirection, view.Direction) < SHADOWS_ROTATION_ERROR) { // Invalidate @@ -262,12 +262,12 @@ struct ShadowAtlasLight // Local light const auto& localLight = (const RenderLocalLightData&)light; if (!Float3::NearEqual(Cache.Position, light.Position, SHADOWS_POSITION_ERROR) || - Cache.Radius != localLight.Radius) + !Math::NearEqual(Cache.Radius, localLight.Radius)) { // Invalidate Cache.StaticValid = false; } - if (light.IsSpotLight && Cache.OuterConeAngle != ((const RenderSpotLightData&)light).OuterConeAngle) + if (light.IsSpotLight && !Math::NearEqual(Cache.OuterConeAngle, ((const RenderSpotLightData&)light).OuterConeAngle)) { // Invalidate Cache.StaticValid = false; diff --git a/Source/Engine/UI/GUI/CanvasScaler.cs b/Source/Engine/UI/GUI/CanvasScaler.cs index 463e13237..6bd18ea51 100644 --- a/Source/Engine/UI/GUI/CanvasScaler.cs +++ b/Source/Engine/UI/GUI/CanvasScaler.cs @@ -132,7 +132,7 @@ namespace FlaxEngine.GUI get => _scaleFactor; set { - if (_scaleFactor == value) + if (Mathf.NearEqual(_scaleFactor, value)) return; _scaleFactor = value; PerformLayout(); @@ -175,7 +175,7 @@ namespace FlaxEngine.GUI get => _physicalUnitSize; set { - if (_physicalUnitSize == value) + if (Mathf.NearEqual(_physicalUnitSize, value)) return; _physicalUnitSize = value; PerformLayout(); @@ -212,7 +212,7 @@ namespace FlaxEngine.GUI set { value = Float2.Max(value, Float2.One); - if (_resolutionMin == value) + if (Float2.NearEqual(ref _resolutionMin, ref value)) return; _resolutionMin = value; PerformLayout(); @@ -231,7 +231,7 @@ namespace FlaxEngine.GUI set { value = Float2.Max(value, Float2.One); - if (_resolutionMax == value) + if (Float2.NearEqual(ref _resolutionMax, ref value)) return; _resolutionMax = value; PerformLayout(); diff --git a/Source/Engine/UI/GUI/Common/ProgressBar.cs b/Source/Engine/UI/GUI/Common/ProgressBar.cs index 8abb87cc8..d569c3f4c 100644 --- a/Source/Engine/UI/GUI/Common/ProgressBar.cs +++ b/Source/Engine/UI/GUI/Common/ProgressBar.cs @@ -140,7 +140,7 @@ namespace FlaxEngine.GUI set { value = Mathf.Clamp(value, _minimum, _maximum); - if (value != _value) + if (!Mathf.NearEqual(value, _value)) { _value = value; if (!UseSmoothing || _firstUpdate) diff --git a/Source/Engine/UI/GUI/Common/Slider.cs b/Source/Engine/UI/GUI/Common/Slider.cs index 8bf6f867a..c1e7cd9f6 100644 --- a/Source/Engine/UI/GUI/Common/Slider.cs +++ b/Source/Engine/UI/GUI/Common/Slider.cs @@ -114,7 +114,7 @@ public class Slider : ContainerControl value = Mathf.Clamp(value, Minimum, Maximum); if (WholeNumbers) value = Mathf.RoundToInt(value); - if (value != _value) + if (!Mathf.NearEqual(value, _value)) { _value = value; diff --git a/Source/Engine/UI/GUI/Control.Bounds.cs b/Source/Engine/UI/GUI/Control.Bounds.cs index 2b517a9f0..62bffd6f7 100644 --- a/Source/Engine/UI/GUI/Control.Bounds.cs +++ b/Source/Engine/UI/GUI/Control.Bounds.cs @@ -189,7 +189,7 @@ namespace FlaxEngine.GUI get => _bounds.Size.X; set { - if (_bounds.Size.X == value) + if (Mathf.NearEqual(_bounds.Size.X, value)) return; var bounds = new Rectangle(_bounds.Location, value, _bounds.Size.Y); if (_pivotRelativeSizing) @@ -210,7 +210,7 @@ namespace FlaxEngine.GUI get => _bounds.Size.Y; set { - if (_bounds.Size.Y == value) + if (Mathf.NearEqual(_bounds.Size.Y, value)) return; var bounds = new Rectangle(_bounds.Location, _bounds.Size.X, value); if (_pivotRelativeSizing) @@ -412,7 +412,7 @@ namespace FlaxEngine.GUI get => _rotation; set { - if (_rotation != value) + if (!Mathf.NearEqual(_rotation, value)) { SetRotationInternal(value); } @@ -598,7 +598,8 @@ namespace FlaxEngine.GUI var anchorMin = AnchorPresetsData[i].Min; var anchorMax = AnchorPresetsData[i].Max; var bounds = _bounds; - if (_anchorMin != anchorMin || _anchorMax != anchorMax) + if (!Float2.NearEqual(ref _anchorMin, ref anchorMin) || + !Float2.NearEqual(ref _anchorMax, ref anchorMax)) { // Disable scrolling for anchored controls (by default but can be manually restored) if (!anchorMin.IsZero || !anchorMax.IsZero) diff --git a/Source/Engine/UI/GUI/Margin.cs b/Source/Engine/UI/GUI/Margin.cs index f04e13b0a..c19d06f09 100644 --- a/Source/Engine/UI/GUI/Margin.cs +++ b/Source/Engine/UI/GUI/Margin.cs @@ -251,10 +251,10 @@ namespace FlaxEngine.GUI /// true if the specified is equal to this instance; otherwise, false. public bool Equals(ref Margin other) { - return other.Left == Left && - other.Right == Right && - other.Top == Top && - other.Bottom == Bottom; + return Mathf.NearEqual(other.Left, Left) && + Mathf.NearEqual(other.Right, Right) && + Mathf.NearEqual(other.Top, Top) && + Mathf.NearEqual(other.Bottom, Bottom); } /// diff --git a/Source/Engine/UI/GUI/Panels/DropPanel.cs b/Source/Engine/UI/GUI/Panels/DropPanel.cs index 5e0bdb010..0bfa799c2 100644 --- a/Source/Engine/UI/GUI/Panels/DropPanel.cs +++ b/Source/Engine/UI/GUI/Panels/DropPanel.cs @@ -76,7 +76,7 @@ namespace FlaxEngine.GUI get => _headerHeight; set { - if (_headerHeight != value) + if (!Mathf.NearEqual(_headerHeight, value)) { _headerHeight = value; PerformLayout(); diff --git a/Source/Engine/UI/GUI/Panels/Panel.cs b/Source/Engine/UI/GUI/Panels/Panel.cs index 4a1cdffa2..ff5483d0f 100644 --- a/Source/Engine/UI/GUI/Panels/Panel.cs +++ b/Source/Engine/UI/GUI/Panels/Panel.cs @@ -130,7 +130,7 @@ namespace FlaxEngine.GUI get => _scrollBarsSize; set { - if (_scrollBarsSize == value) + if (Mathf.NearEqual(_scrollBarsSize, value)) return; _scrollBarsSize = value; PerformLayout(); diff --git a/Source/Engine/UI/GUI/Panels/PanelWithMargins.cs b/Source/Engine/UI/GUI/Panels/PanelWithMargins.cs index c613eb71e..52222946e 100644 --- a/Source/Engine/UI/GUI/Panels/PanelWithMargins.cs +++ b/Source/Engine/UI/GUI/Panels/PanelWithMargins.cs @@ -44,7 +44,7 @@ namespace FlaxEngine.GUI get => _margin.Left; set { - if (_margin.Left != value) + if (!Mathf.NearEqual(_margin.Left, value)) { _margin.Left = value; PerformLayout(); @@ -61,7 +61,7 @@ namespace FlaxEngine.GUI get => _margin.Right; set { - if (_margin.Right != value) + if (!Mathf.NearEqual(_margin.Right, value)) { _margin.Right = value; PerformLayout(); @@ -78,7 +78,7 @@ namespace FlaxEngine.GUI get => _margin.Top; set { - if (_margin.Top != value) + if (!Mathf.NearEqual(_margin.Top, value)) { _margin.Top = value; PerformLayout(); @@ -95,7 +95,7 @@ namespace FlaxEngine.GUI get => _margin.Bottom; set { - if (_margin.Bottom != value) + if (!Mathf.NearEqual(_margin.Bottom, value)) { _margin.Bottom = value; PerformLayout(); @@ -112,7 +112,7 @@ namespace FlaxEngine.GUI get => _spacing; set { - if (_spacing != value) + if (!Mathf.NearEqual(_spacing, value)) { _spacing = value; PerformLayout(); @@ -129,7 +129,7 @@ namespace FlaxEngine.GUI get => _offset; set { - if (_offset != value) + if (!Float2.NearEqual(ref _offset, ref value)) { _offset = value; PerformLayout(); diff --git a/Source/Engine/UI/GUI/Panels/ScrollBar.cs b/Source/Engine/UI/GUI/Panels/ScrollBar.cs index 9381dd0bb..756c698c5 100644 --- a/Source/Engine/UI/GUI/Panels/ScrollBar.cs +++ b/Source/Engine/UI/GUI/Panels/ScrollBar.cs @@ -132,7 +132,7 @@ namespace FlaxEngine.GUI set { value = Mathf.Clamp(value, _minimum, _maximum); - if (value != _targetValue) + if (!Mathf.NearEqual(value, _targetValue)) { _targetValue = value; _startValue = _value; @@ -163,7 +163,7 @@ namespace FlaxEngine.GUI set { value = Mathf.Clamp(value, _minimum, _maximum); - if (value != _targetValue) + if (!Mathf.NearEqual(value, _targetValue)) { _targetValue = value; _value = value; @@ -237,7 +237,7 @@ namespace FlaxEngine.GUI /// public void FastScroll() { - if (_value != _targetValue) + if (!Mathf.NearEqual(_value, _targetValue)) { _value = _targetValue = _startValue; _scrollAnimationProgress = 0f; diff --git a/Source/Engine/UI/GUI/Panels/SplitPanel.cs b/Source/Engine/UI/GUI/Panels/SplitPanel.cs index cfa6acf25..060459723 100644 --- a/Source/Engine/UI/GUI/Panels/SplitPanel.cs +++ b/Source/Engine/UI/GUI/Panels/SplitPanel.cs @@ -67,7 +67,7 @@ namespace FlaxEngine.GUI set { value = Mathf.Saturate(value); - if (_splitterValue != value) + if (!Mathf.NearEqual(_splitterValue, value)) { // Set new value _splitterValue = value; diff --git a/Source/Engine/Video/VideoPlayer.cpp b/Source/Engine/Video/VideoPlayer.cpp index dba1f0000..59f8d2438 100644 --- a/Source/Engine/Video/VideoPlayer.cpp +++ b/Source/Engine/Video/VideoPlayer.cpp @@ -42,7 +42,7 @@ void VideoPlayer::SetIsAudioSpatial(bool value) void VideoPlayer::SetAudioVolume(float value) { value = Math::Saturate(value); - if (_volume == value) + if (Math::NearEqual(_volume, value)) return; _volume = value; UpdateInfo(); @@ -51,7 +51,7 @@ void VideoPlayer::SetAudioVolume(float value) void VideoPlayer::SetAudioPan(float value) { value = Math::Clamp(value, -1.0f, 1.0f); - if (_pan == value) + if (Math::NearEqual(_pan, value)) return; _pan = value; UpdateInfo(); @@ -60,7 +60,7 @@ void VideoPlayer::SetAudioPan(float value) void VideoPlayer::SetAudioMinDistance(float value) { value = Math::Max(0.0f, value); - if (_minDistance == value) + if (Math::NearEqual(_minDistance, value)) return; _minDistance = value; UpdateInfo(); @@ -69,7 +69,7 @@ void VideoPlayer::SetAudioMinDistance(float value) void VideoPlayer::SetAudioAttenuation(float value) { value = Math::Max(0.0f, value); - if (_attenuation == value) + if (Math::NearEqual(_attenuation, value)) return; _attenuation = value; UpdateInfo();