Use exact value comparison in caching related functions

(cherry picked from commit 9d7c6b26422e127719836944d8d473910190e7d4)
This commit is contained in:
2025-04-18 18:45:48 +03:00
parent 8986290b12
commit f09fd7ad34
51 changed files with 119 additions and 120 deletions

View File

@@ -145,7 +145,7 @@ namespace FlaxEditor.Content.GUI
set
{
value = Mathf.Clamp(value, 0.3f, 3.0f);
if (!Mathf.NearEqual(value, _viewScale))
if (value != _viewScale)
{
_viewScale = value;
ViewScaleChanged?.Invoke();

View File

@@ -45,7 +45,7 @@ namespace FlaxEditor.CustomEditors.GUI
set
{
value = Mathf.Clamp(value, 0.05f, 0.95f);
if (!Mathf.NearEqual(_splitterValue, value))
if (_splitterValue != value)
{
_splitterValue = value;
UpdateSplitRect();

View File

@@ -385,7 +385,7 @@ namespace FlaxEditor.GUI
get => _fps;
set
{
if (_fps.HasValue == value.HasValue && (!value.HasValue || Mathf.NearEqual(_fps.Value, value.Value)))
if (_fps.HasValue == value.HasValue && (!value.HasValue || _fps.Value == value.Value))
return;
_fps = value;

View File

@@ -41,7 +41,7 @@ namespace FlaxEditor.GUI.Input
get => _min;
set
{
if (!Mathd.NearEqual(_min, value))
if (_min != value)
{
if (value > _max)
throw new ArgumentException();
@@ -58,7 +58,7 @@ namespace FlaxEditor.GUI.Input
get => _max;
set
{
if (!Mathd.NearEqual(_max, value))
if (_max != value)
{
if (value < _min)
throw new ArgumentException();

View File

@@ -38,7 +38,7 @@ namespace FlaxEditor.GUI.Input
get => _min;
set
{
if (!Mathf.NearEqual(_min, value))
if (_min != value)
{
if (value > _max)
throw new ArgumentException();
@@ -54,7 +54,7 @@ namespace FlaxEditor.GUI.Input
get => _max;
set
{
if (!Mathf.NearEqual(_max, value))
if (_max != value)
{
if (value < _min)
throw new ArgumentException();

View File

@@ -54,7 +54,7 @@ namespace FlaxEditor.GUI.Input
set
{
value = Mathf.Clamp(value, Minimum, Maximum);
if (!Mathf.NearEqual(value, _value))
if (value != _value)
{
_value = value;
@@ -311,7 +311,7 @@ namespace FlaxEditor.GUI.Input
get => _min;
set
{
if (!Mathf.NearEqual(_min, value))
if (_min != value)
{
if (value > _max)
throw new ArgumentException();
@@ -330,7 +330,7 @@ namespace FlaxEditor.GUI.Input
get => _max;
set
{
if (!Mathf.NearEqual(_max, value))
if (_max != value)
{
if (value < _min)
throw new ArgumentException();

View File

@@ -28,7 +28,7 @@ namespace FlaxEditor.GUI
set
{
value = Mathf.Max(value, 1);
if (!Mathf.NearEqual(value, _headerHeight))
if (value != _headerHeight)
{
_headerHeight = value;
PerformLayout();

View File

@@ -692,7 +692,7 @@ namespace FlaxEditor.GUI
get => _fps;
set
{
if (_fps.HasValue == value.HasValue && (!value.HasValue || Mathf.NearEqual(_fps.Value, value.Value)))
if (_fps.HasValue == value.HasValue && (!value.HasValue || _fps.Value == value.Value))
return;
_fps = value;

View File

@@ -319,7 +319,7 @@ namespace FlaxEditor.GUI.Timeline
set
{
value = Mathf.Clamp(value, 0.1f, 1000.0f);
if (Mathf.NearEqual(_framesPerSecond, value))
if (_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 (Mathf.NearEqual(_zoom, value))
if (_zoom == value)
return;
_zoom = value;

View File

@@ -41,7 +41,7 @@ namespace FlaxEditor.GUI.Timeline.Tracks
get => Preview.ViewOffset;
set
{
if (Mathf.NearEqual(Preview.ViewOffset, value))
if (Preview.ViewOffset == value)
return;
Preview.ViewOffset = value;
Timeline?.MarkAsEdited();

View File

@@ -214,7 +214,7 @@ namespace FlaxEditor.GUI.Tree
get => _headerHeight;
set
{
if (!Mathf.NearEqual(_headerHeight, value))
if (_headerHeight != value)
{
_headerHeight = value;
PerformLayout();

View File

@@ -107,7 +107,7 @@ namespace FlaxEditor.Tools.Foliage
get => _type.CullDistance;
set
{
if (Mathf.NearEqual(_type.CullDistance, value))
if (_type.CullDistance == value)
return;
_type.CullDistance = value;
Foliage.UpdateCullDistance();
@@ -120,7 +120,7 @@ namespace FlaxEditor.Tools.Foliage
get => _type.CullDistanceRandomRange;
set
{
if (Mathf.NearEqual(_type.CullDistanceRandomRange, value))
if (_type.CullDistanceRandomRange == value)
return;
_type.CullDistanceRandomRange = value;
Foliage.UpdateCullDistance();
@@ -174,7 +174,7 @@ namespace FlaxEditor.Tools.Foliage
get => _type.DensityScalingScale;
set
{
if (Mathf.NearEqual(_type.DensityScalingScale, value))
if (_type.DensityScalingScale == value)
return;
_type.DensityScalingScale = value;
Foliage.RebuildClusters();

View File

@@ -95,7 +95,7 @@ namespace FlaxEditor.Viewport.Previews
get => _mipLevel;
set
{
if (!Mathf.NearEqual(_mipLevel, value))
if (_mipLevel == value)
{
_mipLevel = value;
_previewMaterial.SetParameterValue("Mip", value);

View File

@@ -42,7 +42,7 @@ namespace FlaxEditor.Viewport.Previews
set
{
value = Mathf.Clamp(value, 0.1f, 100000000000.0f);
if (Mathf.NearEqual(_playbackDuration, value))
if (_playbackDuration == value)
return;
_playbackDuration = value;

View File

@@ -303,7 +303,7 @@ namespace FlaxEditor.Viewport.Previews
get => _mipLevel;
set
{
if (!Mathf.NearEqual(_mipLevel, value))
if (_mipLevel != value)
{
_mipLevel = value;
_previewMaterial.SetParameterValue("Mip", value);

View File

@@ -219,7 +219,7 @@ void AudioService::Update()
// Mute audio if app has no user focus
masterVolume = 0.0f;
}
if (Math::NotNearEqual(Volume, masterVolume))
if (Volume != masterVolume)
{
Volume = masterVolume;
AudioBackend::SetVolume(masterVolume);

View File

@@ -29,7 +29,7 @@ AudioSource::AudioSource(const SpawnParams& params)
void AudioSource::SetVolume(float value)
{
value = Math::Saturate(value);
if (Math::NearEqual(_volume, value))
if (_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 (Math::NearEqual(_pitch, value))
if (_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 (Math::NearEqual(_pan, value))
if (_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 (Math::NearEqual(_minDistance, value))
if (_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 (Math::NearEqual(_attenuation, value))
if (_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 (Math::NearEqual(_dopplerFactor, value))
if (_dopplerFactor == value)
return;
_dopplerFactor = value;
if (SourceID)
@@ -401,7 +401,7 @@ void AudioSource::Update()
_startingToPlay = false;
}
if (!UseStreaming() && Math::NearEqual(GetTime(), 0.0f) && _isActuallyPlayingSth && !_startingToPlay)
if (!UseStreaming() && GetTime() == 0.0f && _isActuallyPlayingSth && !_startingToPlay)
{
int32 queuedBuffers;
AudioBackend::Source::GetQueuedBuffersCount(SourceID, queuedBuffers);

View File

@@ -20,7 +20,7 @@ namespace
template<typename T>
ShaderGraphNode<>* AddValueNode(MaterialLayer* layer, const float& value, const float& defaultValue)
{
if (Math::NearEqual(value, defaultValue))
if (value == defaultValue)
return nullptr;
auto& node = layer->Graph.Nodes.AddOne();
node.ID = layer->Graph.Nodes.Count();

View File

@@ -1013,7 +1013,7 @@ bool UpdateFoliageDensityScaling(Actor* actor)
void Foliage::SetGlobalDensityScale(float value)
{
value = Math::Saturate(value);
if (Math::NearEqual(value, GlobalDensityScale))
if (value == GlobalDensityScale)
return;
PROFILE_CPU();

View File

@@ -1216,7 +1216,7 @@ void InputService::Update()
{
for (auto i = Axes.Begin(); i.IsNotEnd(); ++i)
{
if (Math::NotNearEqual(i->Value.Value, i->Value.PrevValue))
if (i->Value.Value != i->Value.PrevValue)
{
Input::AxisValueChanged(i->Key);
}

View File

@@ -660,7 +660,7 @@ void Actor::SetStaticFlags(StaticFlags value)
void Actor::SetTransform(const Transform& value)
{
CHECK(!value.IsNanOrInfinity());
if (!(Vector3::NearEqual(_transform.Translation, value.Translation) && Quaternion::NearEqual(_transform.Orientation, value.Orientation, ACTOR_ORIENTATION_EPSILON) && Float3::NearEqual(_transform.Scale, value.Scale)))
if (_transform.Translation != value.Translation && _transform.Orientation != value.Orientation && _transform.Scale != value.Scale)
{
if (_parent)
_parent->_transform.WorldToLocal(value, _localTransform);
@@ -673,7 +673,7 @@ void Actor::SetTransform(const Transform& value)
void Actor::SetPosition(const Vector3& value)
{
CHECK(!value.IsNanOrInfinity());
if (!Vector3::NearEqual(_transform.Translation, value))
if (_transform.Translation != value)
{
if (_parent)
_localTransform.Translation = _parent->_transform.WorldToLocal(value);
@@ -686,7 +686,7 @@ void Actor::SetPosition(const Vector3& value)
void Actor::SetOrientation(const Quaternion& value)
{
CHECK(!value.IsNanOrInfinity());
if (!Quaternion::NearEqual(_transform.Orientation, value, ACTOR_ORIENTATION_EPSILON))
if (_transform.Orientation != value)
{
if (_parent)
_parent->_transform.WorldToLocal(value, _localTransform.Orientation);
@@ -699,7 +699,7 @@ void Actor::SetOrientation(const Quaternion& value)
void Actor::SetScale(const Float3& value)
{
CHECK(!value.IsNanOrInfinity());
if (!Float3::NearEqual(_transform.Scale, value))
if (_transform.Scale != value)
{
if (_parent)
Float3::Divide(value, _parent->_transform.Scale, _localTransform.Scale);
@@ -748,7 +748,7 @@ void Actor::ResetLocalTransform()
void Actor::SetLocalTransform(const Transform& value)
{
CHECK(!value.IsNanOrInfinity());
if (!(Vector3::NearEqual(_localTransform.Translation, value.Translation) && Quaternion::NearEqual(_localTransform.Orientation, value.Orientation, ACTOR_ORIENTATION_EPSILON) && Float3::NearEqual(_localTransform.Scale, value.Scale)))
if (_localTransform.Translation != value.Translation || _localTransform.Orientation != value.Orientation || _localTransform.Scale != value.Scale)
{
_localTransform = value;
OnTransformChanged();
@@ -758,7 +758,7 @@ void Actor::SetLocalTransform(const Transform& value)
void Actor::SetLocalPosition(const Vector3& value)
{
CHECK(!value.IsNanOrInfinity());
if (!Vector3::NearEqual(_localTransform.Translation, value))
if (_localTransform.Translation != value)
{
_localTransform.Translation = value;
OnTransformChanged();
@@ -770,7 +770,7 @@ void Actor::SetLocalOrientation(const Quaternion& value)
CHECK(!value.IsNanOrInfinity());
Quaternion v = value;
v.Normalize();
if (!Quaternion::NearEqual(_localTransform.Orientation, v, ACTOR_ORIENTATION_EPSILON))
if (_localTransform.Orientation != value)
{
_localTransform.Orientation = v;
OnTransformChanged();
@@ -780,7 +780,7 @@ void Actor::SetLocalOrientation(const Quaternion& value)
void Actor::SetLocalScale(const Float3& value)
{
CHECK(!value.IsNanOrInfinity());
if (!Float3::NearEqual(_localTransform.Scale, value))
if (_localTransform.Scale != value)
{
_localTransform.Scale = value;
OnTransformChanged();

View File

@@ -65,7 +65,7 @@ void BoxBrush::SetMode(BrushMode value)
void BoxBrush::SetCenter(const Vector3& value)
{
if (Vector3::NearEqual(value, _center))
if (value == _center)
return;
_center = value;
@@ -77,7 +77,7 @@ void BoxBrush::SetCenter(const Vector3& value)
void BoxBrush::SetSize(const Vector3& value)
{
if (Vector3::NearEqual(value, _size))
if (value == _size)
return;
_size = value;

View File

@@ -12,7 +12,7 @@ BoxVolume::BoxVolume(const SpawnParams& params)
void BoxVolume::SetSize(const Vector3& value)
{
if (!Vector3::NearEqual(value, _size))
if (value != _size)
{
const auto prevBounds = _box;
_size = value;

View File

@@ -70,7 +70,7 @@ float Camera::GetFieldOfView() const
void Camera::SetFieldOfView(float value)
{
value = Math::Clamp(value, 1.0f, 179.9f);
if (Math::NotNearEqual(_fov, value))
if (_fov != value)
{
_fov = value;
UpdateCache();
@@ -85,7 +85,7 @@ float Camera::GetCustomAspectRatio() const
void Camera::SetCustomAspectRatio(float value)
{
value = Math::Clamp(value, 0.0f, 100.0f);
if (Math::NotNearEqual(_customAspectRatio, value))
if (_customAspectRatio != value)
{
_customAspectRatio = value;
UpdateCache();
@@ -100,7 +100,7 @@ float Camera::GetNearPlane() const
void Camera::SetNearPlane(float value)
{
value = Math::Clamp(value, 0.001f, _far - 1.0f);
if (Math::NotNearEqual(_near, value))
if (_near != value)
{
_near = value;
UpdateCache();
@@ -115,7 +115,7 @@ float Camera::GetFarPlane() const
void Camera::SetFarPlane(float value)
{
value = Math::Max(value, _near + 1.0f);
if (Math::NotNearEqual(_far, value))
if (_far != value)
{
_far = value;
UpdateCache();
@@ -130,7 +130,7 @@ float Camera::GetOrthographicSize() const
void Camera::SetOrthographicSize(float value)
{
value = Math::Clamp(value, 0.0f, 1000000.0f);
if (Math::NotNearEqual(_orthoSize, value))
if (_orthoSize != value)
{
_orthoSize = value;
UpdateCache();
@@ -145,7 +145,7 @@ float Camera::GetOrthographicScale() const
void Camera::SetOrthographicScale(float value)
{
value = Math::Clamp(value, 0.0001f, 1000000.0f);
if (Math::NotNearEqual(_orthoScale, value))
if (_orthoScale != value)
{
_orthoScale = value;
UpdateCache();

View File

@@ -41,7 +41,7 @@ float EnvironmentProbe::GetRadius() const
void EnvironmentProbe::SetRadius(float value)
{
value = Math::Max(0.0f, value);
if (Math::NearEqual(value, _radius))
if (value == _radius)
return;
_radius = value;

View File

@@ -49,7 +49,7 @@ float PointLight::GetScaledRadius() const
void PointLight::SetRadius(float value)
{
value = Math::Max(0.0f, value);
if (Math::NearEqual(value, _radius))
if (value == _radius)
return;
_radius = value;

View File

@@ -26,7 +26,7 @@ SkyLight::SkyLight(const SpawnParams& params)
void SkyLight::SetRadius(float value)
{
value = Math::Max(0.0f, value);
if (Math::NearEqual(value, _radius))
if (value == _radius)
return;
_radius = value;

View File

@@ -59,7 +59,7 @@ float SplineModel::GetQuality() const
void SplineModel::SetQuality(float value)
{
value = Math::Clamp(value, 0.0f, 100.0f);
if (Math::NearEqual(value, _quality))
if (value == _quality)
return;
_quality = value;
OnSplineUpdated();
@@ -72,7 +72,7 @@ float SplineModel::GetBoundsScale() const
void SplineModel::SetBoundsScale(float value)
{
if (Math::NearEqual(_boundsScale, value))
if (_boundsScale == value)
return;
_boundsScale = value;
OnSplineUpdated();

View File

@@ -57,7 +57,7 @@ float SpotLight::GetScaledRadius() const
void SpotLight::SetRadius(float value)
{
value = Math::Max(0.0f, value);
if (Math::NearEqual(value, _radius))
if (value == _radius)
return;
_radius = value;
@@ -70,7 +70,7 @@ void SpotLight::SetOuterConeAngle(float value)
value = Math::Clamp(value, 0.0f, 89.0f);
// Check if value will change
if (!Math::NearEqual(value, _outerConeAngle))
if (value != _outerConeAngle)
{
// Change values
_innerConeAngle = Math::Min(_innerConeAngle, value - ZeroTolerance);
@@ -86,7 +86,7 @@ void SpotLight::SetInnerConeAngle(float value)
value = Math::Clamp(value, 0.0f, 89.0f);
// Check if value will change
if (!Math::NearEqual(value, _innerConeAngle))
if (value != _innerConeAngle)
{
// Change values
_innerConeAngle = value;

View File

@@ -60,7 +60,7 @@ float StaticModel::GetBoundsScale() const
void StaticModel::SetBoundsScale(float value)
{
if (Math::NearEqual(_boundsScale, value))
if (_boundsScale == value)
return;
_boundsScale = value;

View File

@@ -292,7 +292,7 @@ void NavMeshRuntime::SetTileSize(float tileSize)
ScopeLock lock(Locker);
// Skip if the same or invalid
if (Math::NearEqual(_tileSize, tileSize) || tileSize < 1)
if (_tileSize == tileSize || tileSize < 1)
return;
// Dispose the existing mesh (its invalid)

View File

@@ -44,7 +44,7 @@ void RigidBody::SetIsKinematic(const bool value)
void RigidBody::SetLinearDamping(float value)
{
if (Math::NearEqual(value, _linearDamping))
if (value == _linearDamping)
return;
_linearDamping = value;
if (_actor)
@@ -53,7 +53,7 @@ void RigidBody::SetLinearDamping(float value)
void RigidBody::SetAngularDamping(float value)
{
if (Math::NearEqual(value, _angularDamping))
if (value == _angularDamping)
return;
_angularDamping = value;
if (_actor)
@@ -108,7 +108,7 @@ void RigidBody::SetUpdateMassWhenScaleChanges(bool value)
void RigidBody::SetMaxAngularVelocity(float value)
{
if (Math::NearEqual(value, _maxAngularVelocity))
if (value == _maxAngularVelocity)
return;
_maxAngularVelocity = value;
if (_actor)
@@ -135,7 +135,7 @@ float RigidBody::GetMass() const
void RigidBody::SetMass(float value)
{
if (Math::NearEqual(value, _mass))
if (value == _mass)
return;
_mass = value;
_overrideMass = true;
@@ -149,7 +149,7 @@ float RigidBody::GetMassScale() const
void RigidBody::SetMassScale(float value)
{
if (Math::NearEqual(value, _massScale))
if (value == _massScale)
return;
_massScale = value;
UpdateMass();
@@ -157,7 +157,7 @@ void RigidBody::SetMassScale(float value)
void RigidBody::SetCenterOfMassOffset(const Float3& value)
{
if (Float3::NearEqual(value, _centerOfMassOffset))
if (value == _centerOfMassOffset)
return;
_centerOfMassOffset = value;
if (_actor)
@@ -380,7 +380,7 @@ void RigidBody::UpdateBounds()
void RigidBody::UpdateScale()
{
const Float3 scale = GetScale();
if (Float3::NearEqual(_cachedScale, scale))
if (_cachedScale == scale)
return;
_cachedScale = scale;

View File

@@ -12,7 +12,7 @@ BoxCollider::BoxCollider(const SpawnParams& params)
void BoxCollider::SetSize(const Float3& value)
{
if (Float3::NearEqual(value, _size))
if (value == _size)
return;
_size = value;

View File

@@ -11,7 +11,7 @@ CapsuleCollider::CapsuleCollider(const SpawnParams& params)
void CapsuleCollider::SetRadius(const float value)
{
if (Math::NearEqual(value, _radius))
if (value == _radius)
return;
_radius = value;
@@ -22,7 +22,7 @@ void CapsuleCollider::SetRadius(const float value)
void CapsuleCollider::SetHeight(const float value)
{
if (Math::NearEqual(value, _height))
if (value == _height)
return;
_height = value;

View File

@@ -33,7 +33,7 @@ float CharacterController::GetRadius() const
void CharacterController::SetRadius(const float value)
{
if (Math::NearEqual(value, _radius))
if (value == _radius)
return;
_radius = value;
@@ -49,7 +49,7 @@ float CharacterController::GetHeight() const
void CharacterController::SetHeight(const float value)
{
if (Math::NearEqual(value, _height))
if (value == _height)
return;
_height = value;
@@ -66,7 +66,7 @@ float CharacterController::GetSlopeLimit() const
void CharacterController::SetSlopeLimit(float value)
{
value = Math::Clamp(value, 0.0f, 89.0f);
if (Math::NearEqual(value, _slopeLimit))
if (value == _slopeLimit)
return;
_slopeLimit = value;
if (_controller)
@@ -94,7 +94,7 @@ float CharacterController::GetStepOffset() const
void CharacterController::SetStepOffset(float value)
{
if (Math::NearEqual(value, _stepOffset))
if (value == _stepOffset)
return;
_stepOffset = value;
@@ -384,7 +384,7 @@ void CharacterController::OnTransformChanged()
{
PhysicsBackend::SetControllerPosition(_controller, position);
const Float3 scale = GetScale();
if (!Float3::NearEqual(_cachedScale, scale))
if (_cachedScale != scale)
UpdateGeometry();
UpdateBounds();
}

View File

@@ -49,7 +49,7 @@ void Collider::SetIsTrigger(bool value)
void Collider::SetCenter(const Vector3& value)
{
if (Vector3::NearEqual(value, _center))
if (value == _center)
return;
_center = value;
if (_staticActor)
@@ -62,7 +62,7 @@ void Collider::SetCenter(const Vector3& value)
void Collider::SetContactOffset(float value)
{
value = Math::Clamp(value, 0.0f, 100.0f);
if (Math::NearEqual(value, _contactOffset))
if (value == _contactOffset)
return;
_contactOffset = value;
if (_shape)
@@ -428,7 +428,7 @@ void Collider::OnTransformChanged()
}
const Float3 scale = GetScale();
if (!Float3::NearEqual(_cachedScale, scale))
if (_cachedScale != scale)
UpdateGeometry();
UpdateBounds();
}

View File

@@ -10,7 +10,7 @@ SphereCollider::SphereCollider(const SpawnParams& params)
void SphereCollider::SetRadius(const float value)
{
if (Math::NearEqual(value, _radius))
if (value == _radius)
return;
_radius = value;

View File

@@ -25,7 +25,7 @@ void DistanceJoint::SetFlags(DistanceJointFlag value)
void DistanceJoint::SetMinDistance(float value)
{
value = Math::Clamp(value, 0.0f, _maxDistance);
if (Math::NearEqual(value, _minDistance))
if (value == _minDistance)
return;
_minDistance = value;
if (_joint)
@@ -35,7 +35,7 @@ void DistanceJoint::SetMinDistance(float value)
void DistanceJoint::SetMaxDistance(float value)
{
value = Math::Max(_minDistance, value);
if (Math::NearEqual(value, _maxDistance))
if (value == _maxDistance)
return;
_maxDistance = value;
if (_joint)
@@ -45,7 +45,7 @@ void DistanceJoint::SetMaxDistance(float value)
void DistanceJoint::SetTolerance(float value)
{
value = Math::Max(0.1f, value);
if (Math::NearEqual(value, _tolerance))
if (value == _tolerance)
return;
_tolerance = value;
if (_joint)

View File

@@ -24,7 +24,7 @@ Joint::Joint(const SpawnParams& params)
void Joint::SetBreakForce(float value)
{
if (Math::NearEqual(value, _breakForce))
if (value == _breakForce)
return;
_breakForce = value;
if (_joint)
@@ -33,7 +33,7 @@ void Joint::SetBreakForce(float value)
void Joint::SetBreakTorque(float value)
{
if (Math::NearEqual(value, _breakTorque))
if (value == _breakTorque)
return;
_breakTorque = value;
if (_joint)
@@ -61,7 +61,7 @@ void Joint::SetEnableAutoAnchor(bool value)
void Joint::SetTargetAnchor(const Vector3& value)
{
if (Vector3::NearEqual(value, _targetAnchor))
if (value == _targetAnchor)
return;
_targetAnchor = value;
if (_joint && !_enableAutoAnchor)

View File

@@ -236,9 +236,9 @@ struct ShadowAtlasLight
{
if (!Cache.StaticValid || !Cache.DynamicValid)
return;
if (!Math::NearEqual(Cache.Distance, light.ShadowsDistance) ||
!Math::NearEqual(Cache.ShadowsUpdateRate, light.ShadowsUpdateRate) ||
!Math::NearEqual(Cache.ShadowsUpdateRateAtDistance, light.ShadowsUpdateRateAtDistance) ||
if (Cache.Distance != light.ShadowsDistance ||
Cache.ShadowsUpdateRate != light.ShadowsUpdateRate ||
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) ||
!Float4::NearEqual(Cache.CascadeSplits, CascadeSplits) ||
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) ||
!Math::NearEqual(Cache.Radius, localLight.Radius))
Cache.Radius != localLight.Radius)
{
// Invalidate
Cache.StaticValid = false;
}
if (light.IsSpotLight && !Math::NearEqual(Cache.OuterConeAngle, ((const RenderSpotLightData&)light).OuterConeAngle))
if (light.IsSpotLight && Cache.OuterConeAngle != ((const RenderSpotLightData&)light).OuterConeAngle)
{
// Invalidate
Cache.StaticValid = false;

View File

@@ -260,7 +260,7 @@ void Terrain::SetScaleInLightmap(float value)
void Terrain::SetBoundsExtent(const Vector3& value)
{
if (Vector3::NearEqual(_boundsExtent, value))
if (_boundsExtent == value)
return;
_boundsExtent = value;
@@ -891,7 +891,7 @@ void Terrain::OnTransformChanged()
auto patch = _patches[i];
patch->UpdateTransform();
}
if (!Float3::NearEqual(_cachedScale, _transform.Scale))
if (_cachedScale != _transform.Scale)
{
_cachedScale = _transform.Scale;
for (int32 i = 0; i < _patches.Count(); i++)

View File

@@ -132,7 +132,7 @@ namespace FlaxEngine.GUI
get => _scaleFactor;
set
{
if (Mathf.NearEqual(_scaleFactor, value))
if (_scaleFactor == value)
return;
_scaleFactor = value;
PerformLayout();
@@ -175,7 +175,7 @@ namespace FlaxEngine.GUI
get => _physicalUnitSize;
set
{
if (Mathf.NearEqual(_physicalUnitSize, value))
if (_physicalUnitSize == value)
return;
_physicalUnitSize = value;
PerformLayout();
@@ -212,7 +212,7 @@ namespace FlaxEngine.GUI
set
{
value = Float2.Max(value, Float2.One);
if (Float2.NearEqual(ref _resolutionMin, ref value))
if (_resolutionMin == value)
return;
_resolutionMin = value;
PerformLayout();
@@ -231,7 +231,7 @@ namespace FlaxEngine.GUI
set
{
value = Float2.Max(value, Float2.One);
if (Float2.NearEqual(ref _resolutionMax, ref value))
if (_resolutionMax == value)
return;
_resolutionMax = value;
PerformLayout();

View File

@@ -140,7 +140,7 @@ namespace FlaxEngine.GUI
set
{
value = Mathf.Clamp(value, _minimum, _maximum);
if (!Mathf.NearEqual(value, _value))
if (value != _value)
{
_value = value;
if (!UseSmoothing || _firstUpdate)

View File

@@ -114,7 +114,7 @@ public class Slider : ContainerControl
value = Mathf.Clamp(value, Minimum, Maximum);
if (WholeNumbers)
value = Mathf.RoundToInt(value);
if (!Mathf.NearEqual(value, _value))
if (value != _value)
{
_value = value;

View File

@@ -189,7 +189,7 @@ namespace FlaxEngine.GUI
get => _bounds.Size.X;
set
{
if (Mathf.NearEqual(_bounds.Size.X, value))
if (_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 (Mathf.NearEqual(_bounds.Size.Y, value))
if (_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 (!Mathf.NearEqual(_rotation, value))
if (_rotation != value)
{
SetRotationInternal(value);
}
@@ -598,8 +598,7 @@ namespace FlaxEngine.GUI
var anchorMin = AnchorPresetsData[i].Min;
var anchorMax = AnchorPresetsData[i].Max;
var bounds = _bounds;
if (!Float2.NearEqual(ref _anchorMin, ref anchorMin) ||
!Float2.NearEqual(ref _anchorMax, ref anchorMax))
if (_anchorMin != anchorMin || _anchorMax != anchorMax)
{
// Disable scrolling for anchored controls (by default but can be manually restored)
if (!anchorMin.IsZero || !anchorMax.IsZero)

View File

@@ -71,7 +71,7 @@ namespace FlaxEngine.GUI
get => _headerHeight;
set
{
if (!Mathf.NearEqual(_headerHeight, value))
if (_headerHeight != value)
{
_headerHeight = value;
PerformLayout();

View File

@@ -129,7 +129,7 @@ namespace FlaxEngine.GUI
get => _scrollBarsSize;
set
{
if (Mathf.NearEqual(_scrollBarsSize, value))
if (_scrollBarsSize == value)
return;
_scrollBarsSize = value;
PerformLayout();

View File

@@ -44,7 +44,7 @@ namespace FlaxEngine.GUI
get => _margin.Left;
set
{
if (!Mathf.NearEqual(_margin.Left, value))
if (_margin.Left != value)
{
_margin.Left = value;
PerformLayout();
@@ -61,7 +61,7 @@ namespace FlaxEngine.GUI
get => _margin.Right;
set
{
if (!Mathf.NearEqual(_margin.Right, value))
if (_margin.Right != value)
{
_margin.Right = value;
PerformLayout();
@@ -78,7 +78,7 @@ namespace FlaxEngine.GUI
get => _margin.Top;
set
{
if (!Mathf.NearEqual(_margin.Top, value))
if (_margin.Top != value)
{
_margin.Top = value;
PerformLayout();
@@ -95,7 +95,7 @@ namespace FlaxEngine.GUI
get => _margin.Bottom;
set
{
if (!Mathf.NearEqual(_margin.Bottom, value))
if (_margin.Bottom != value)
{
_margin.Bottom = value;
PerformLayout();
@@ -112,7 +112,7 @@ namespace FlaxEngine.GUI
get => _spacing;
set
{
if (!Mathf.NearEqual(_spacing, value))
if (_spacing != value)
{
_spacing = value;
PerformLayout();
@@ -129,7 +129,7 @@ namespace FlaxEngine.GUI
get => _offset;
set
{
if (!Float2.NearEqual(ref _offset, ref value))
if (_offset != value)
{
_offset = value;
PerformLayout();

View File

@@ -132,7 +132,7 @@ namespace FlaxEngine.GUI
set
{
value = Mathf.Clamp(value, _minimum, _maximum);
if (!Mathf.NearEqual(value, _targetValue))
if (value != _targetValue)
{
_targetValue = value;
_startValue = _value;
@@ -163,7 +163,7 @@ namespace FlaxEngine.GUI
set
{
value = Mathf.Clamp(value, _minimum, _maximum);
if (!Mathf.NearEqual(value, _targetValue))
if (value != _targetValue)
{
_targetValue = value;
_value = value;
@@ -237,7 +237,7 @@ namespace FlaxEngine.GUI
/// </summary>
public void FastScroll()
{
if (!Mathf.NearEqual(_value, _targetValue))
if (_value != _targetValue)
{
_value = _targetValue = _startValue;
_scrollAnimationProgress = 0f;

View File

@@ -67,7 +67,7 @@ namespace FlaxEngine.GUI
set
{
value = Mathf.Saturate(value);
if (!Mathf.NearEqual(_splitterValue, value))
if (_splitterValue != value)
{
// Set new value
_splitterValue = value;

View File

@@ -42,7 +42,7 @@ void VideoPlayer::SetIsAudioSpatial(bool value)
void VideoPlayer::SetAudioVolume(float value)
{
value = Math::Saturate(value);
if (Math::NearEqual(_volume, value))
if (_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 (Math::NearEqual(_pan, value))
if (_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 (Math::NearEqual(_minDistance, value))
if (_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 (Math::NearEqual(_attenuation, value))
if (_attenuation == value)
return;
_attenuation = value;
UpdateInfo();