Merge branch 'xxSeys1-ViewportIconsMoreCustomization'

This commit is contained in:
Wojtek Figat
2025-09-22 18:10:38 +02:00
4 changed files with 46 additions and 4 deletions

View File

@@ -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);
/// <summary>
/// Gets or sets the minimum size used for viewport icons.
/// </summary>
[DefaultValue(7.0f), Limit(1.0f, 1000.0f, 5.0f)]
[EditorDisplay("Viewport Icons"), EditorOrder(400)]
public float IconsMinimumSize { get; set; } = 7.0f;
/// <summary>
/// Gets or sets the maximum size used for viewport icons.
/// </summary>
[DefaultValue(30.0f), Limit(1.0f, 1000.0f, 5.0f)]
[EditorDisplay("Viewport Icons"), EditorOrder(410)]
public float IconsMaximumSize { get; set; } = 30.0f;
/// <summary>
/// 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.
/// </summary>
[DefaultValue(1000.0f), Limit(0.0f, 20000.0f, 5.0f)]
[EditorDisplay("Viewport Icons"), EditorOrder(410)]
public float MaxSizeDistance { get; set; } = 1000.0f;
}
}

View File

@@ -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<Real>(scale, 1.0f) * (maxSize - minSize);
Real scale = Math::Square(Vector3::Distance(position, viewPosition) / MaxSizeDistance);
Real radius = MinSize + Math::Min<Real>(scale, 1.0f) * (MaxSize - MinSize);
bounds = BoundingSphere(position, radius * Scale);
}

View File

@@ -22,6 +22,21 @@ public:
/// </summary>
API_FIELD() static float Scale;
/// <summary>
/// The minimum size of the icons.
/// </summary>
API_FIELD() static Real MinSize;
/// <summary>
/// The maximum size of the icons.
/// </summary>
API_FIELD() static Real MaxSize;
/// <summary>
/// The distance to the camera at which the icons will be drawn at their maximum size.
/// </summary>
API_FIELD() static Real MaxSizeDistance;
/// <summary>
/// Draws the icons for the actors in the given scene (or actor tree).
/// </summary>

View File

@@ -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();
}