Merge branch 'ViewportIconsMoreCustomization' of https://github.com/xxSeys1/FlaxEngine into xxSeys1-ViewportIconsMoreCustomization
This commit is contained in:
@@ -150,5 +150,26 @@ namespace FlaxEditor.Options
|
|||||||
[DefaultValue(typeof(Color), "0.5,0.5,0.5,1.0")]
|
[DefaultValue(typeof(Color), "0.5,0.5,0.5,1.0")]
|
||||||
[EditorDisplay("Grid"), EditorOrder(310), Tooltip("The color for the viewport grid.")]
|
[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);
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,13 +65,14 @@ public:
|
|||||||
|
|
||||||
ViewportIconsRendererService ViewportIconsRendererServiceInstance;
|
ViewportIconsRendererService ViewportIconsRendererServiceInstance;
|
||||||
float ViewportIconsRenderer::Scale = 1.0f;
|
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)
|
void ViewportIconsRenderer::GetBounds(const Vector3& position, const Vector3& viewPosition, BoundingSphere& bounds)
|
||||||
{
|
{
|
||||||
constexpr Real minSize = 7.0;
|
Real scale = Math::Square(Vector3::Distance(position, viewPosition) / MaxSizeDistance);
|
||||||
constexpr Real maxSize = 30.0;
|
Real radius = MinSize + Math::Min<Real>(scale, 1.0f) * (MaxSize - MinSize);
|
||||||
Real scale = Math::Square(Vector3::Distance(position, viewPosition) / 1000.0f);
|
|
||||||
Real radius = minSize + Math::Min<Real>(scale, 1.0f) * (maxSize - minSize);
|
|
||||||
bounds = BoundingSphere(position, radius * Scale);
|
bounds = BoundingSphere(position, radius * Scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,21 @@ public:
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
API_FIELD() static float Scale;
|
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>
|
/// <summary>
|
||||||
/// Draws the icons for the actors in the given scene (or actor tree).
|
/// Draws the icons for the actors in the given scene (or actor tree).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1292,6 +1292,11 @@ namespace FlaxEditor.Viewport
|
|||||||
_mouseSensitivity = options.Viewport.MouseSensitivity;
|
_mouseSensitivity = options.Viewport.MouseSensitivity;
|
||||||
_maxSpeedSteps = options.Viewport.TotalCameraSpeedSteps;
|
_maxSpeedSteps = options.Viewport.TotalCameraSpeedSteps;
|
||||||
_cameraEasingDegree = options.Viewport.CameraEasingDegree;
|
_cameraEasingDegree = options.Viewport.CameraEasingDegree;
|
||||||
|
|
||||||
|
ViewportIconsRenderer.MinSize = options.Viewport.IconsMinimumSize;
|
||||||
|
ViewportIconsRenderer.MaxSize = options.Viewport.IconsMaximumSize;
|
||||||
|
ViewportIconsRenderer.MaxSizeDistance = options.Viewport.MaxSizeDistance;
|
||||||
|
|
||||||
OnCameraMovementProgressChanged();
|
OnCameraMovementProgressChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user