diff --git a/Source/Editor/Options/ViewportOptions.cs b/Source/Editor/Options/ViewportOptions.cs
index 13ab2a8b0..aed633672 100644
--- a/Source/Editor/Options/ViewportOptions.cs
+++ b/Source/Editor/Options/ViewportOptions.cs
@@ -150,5 +150,26 @@ namespace FlaxEditor.Options
[DefaultValue(typeof(Color), "0.5,0.5,0.5,1.0")]
[EditorDisplay("Grid"), EditorOrder(310), Tooltip("The color for the viewport grid.")]
public Color ViewportGridColor { get; set; } = new Color(0.5f, 0.5f, 0.5f, 1.0f);
+
+ ///
+ /// Gets or sets the minimum size used for viewport icons.
+ ///
+ [DefaultValue(7.0f), Limit(1.0f, 1000.0f, 5.0f)]
+ [EditorDisplay("Viewport Icons"), EditorOrder(400)]
+ public float IconsMinimumSize { get; set; } = 7.0f;
+
+ ///
+ /// Gets or sets the maximum size used for viewport icons.
+ ///
+ [DefaultValue(30.0f), Limit(1.0f, 1000.0f, 5.0f)]
+ [EditorDisplay("Viewport Icons"), EditorOrder(410)]
+ public float IconsMaximumSize { get; set; } = 30.0f;
+
+ ///
+ /// Gets or sets the distance towards the camera at which the max icon scale will be applied. Set to 0 to disable scaling the icons based on the distance to the camera.
+ ///
+ [DefaultValue(1000.0f), Limit(0.0f, 20000.0f, 5.0f)]
+ [EditorDisplay("Viewport Icons"), EditorOrder(410)]
+ public float MaxSizeDistance { get; set; } = 1000.0f;
}
}
diff --git a/Source/Editor/Utilities/ViewportIconsRenderer.cpp b/Source/Editor/Utilities/ViewportIconsRenderer.cpp
index 1f721d289..690c55424 100644
--- a/Source/Editor/Utilities/ViewportIconsRenderer.cpp
+++ b/Source/Editor/Utilities/ViewportIconsRenderer.cpp
@@ -65,13 +65,14 @@ public:
ViewportIconsRendererService ViewportIconsRendererServiceInstance;
float ViewportIconsRenderer::Scale = 1.0f;
+Real ViewportIconsRenderer::MinSize = 7.0f;
+Real ViewportIconsRenderer::MaxSize = 30.0f;
+Real ViewportIconsRenderer::MaxSizeDistance = 1000.0f;
void ViewportIconsRenderer::GetBounds(const Vector3& position, const Vector3& viewPosition, BoundingSphere& bounds)
{
- constexpr Real minSize = 7.0;
- constexpr Real maxSize = 30.0;
- Real scale = Math::Square(Vector3::Distance(position, viewPosition) / 1000.0f);
- Real radius = minSize + Math::Min(scale, 1.0f) * (maxSize - minSize);
+ Real scale = Math::Square(Vector3::Distance(position, viewPosition) / MaxSizeDistance);
+ Real radius = MinSize + Math::Min(scale, 1.0f) * (MaxSize - MinSize);
bounds = BoundingSphere(position, radius * Scale);
}
diff --git a/Source/Editor/Utilities/ViewportIconsRenderer.h b/Source/Editor/Utilities/ViewportIconsRenderer.h
index c7bf7e1c3..a1e1538b8 100644
--- a/Source/Editor/Utilities/ViewportIconsRenderer.h
+++ b/Source/Editor/Utilities/ViewportIconsRenderer.h
@@ -22,6 +22,21 @@ public:
///
API_FIELD() static float Scale;
+ ///
+ /// The minimum size of the icons.
+ ///
+ API_FIELD() static Real MinSize;
+
+ ///
+ /// The maximum size of the icons.
+ ///
+ API_FIELD() static Real MaxSize;
+
+ ///
+ /// The distance to the camera at which the icons will be drawn at their maximum size.
+ ///
+ API_FIELD() static Real MaxSizeDistance;
+
///
/// Draws the icons for the actors in the given scene (or actor tree).
///
diff --git a/Source/Editor/Viewport/EditorViewport.cs b/Source/Editor/Viewport/EditorViewport.cs
index b4af43281..0f9fce7c0 100644
--- a/Source/Editor/Viewport/EditorViewport.cs
+++ b/Source/Editor/Viewport/EditorViewport.cs
@@ -1292,6 +1292,11 @@ namespace FlaxEditor.Viewport
_mouseSensitivity = options.Viewport.MouseSensitivity;
_maxSpeedSteps = options.Viewport.TotalCameraSpeedSteps;
_cameraEasingDegree = options.Viewport.CameraEasingDegree;
+
+ ViewportIconsRenderer.MinSize = options.Viewport.IconsMinimumSize;
+ ViewportIconsRenderer.MaxSize = options.Viewport.IconsMaximumSize;
+ ViewportIconsRenderer.MaxSizeDistance = options.Viewport.MaxSizeDistance;
+
OnCameraMovementProgressChanged();
}