Cleanup code #2213
This commit is contained in:
@@ -4,7 +4,6 @@ using System.Linq;
|
||||
using FlaxEditor.CustomEditors.Elements;
|
||||
using FlaxEngine;
|
||||
using FlaxEngine.GUI;
|
||||
using Utils = FlaxEngine.Utils;
|
||||
|
||||
namespace FlaxEditor.CustomEditors.Editors
|
||||
{
|
||||
|
||||
@@ -5,7 +5,6 @@ using System.Reflection;
|
||||
using FlaxEditor.GUI.Input;
|
||||
using FlaxEngine;
|
||||
using FlaxEngine.GUI;
|
||||
using Utils = FlaxEngine.Utils;
|
||||
|
||||
namespace FlaxEditor.CustomEditors.Elements
|
||||
{
|
||||
@@ -53,9 +52,9 @@ namespace FlaxEditor.CustomEditors.Elements
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the value category of this float element
|
||||
/// Sets the editor value category.
|
||||
/// </summary>
|
||||
/// <param name="category"></param>
|
||||
/// <param name="category">The category.</param>
|
||||
public void SetCategory(Utils.ValueCategory category)
|
||||
{
|
||||
ValueBox.Category = category;
|
||||
|
||||
@@ -5,7 +5,6 @@ using System.Reflection;
|
||||
using FlaxEditor.GUI.Input;
|
||||
using FlaxEngine;
|
||||
using FlaxEngine.GUI;
|
||||
using Utils = FlaxEngine.Utils;
|
||||
|
||||
namespace FlaxEditor.CustomEditors.Elements
|
||||
{
|
||||
@@ -53,9 +52,9 @@ namespace FlaxEditor.CustomEditors.Elements
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the value category of this float element
|
||||
/// Sets the editor value category.
|
||||
/// </summary>
|
||||
/// <param name="category"></param>
|
||||
/// <param name="category">The category.</param>
|
||||
public void SetCategory(Utils.ValueCategory category)
|
||||
{
|
||||
ValueBox.Category = category;
|
||||
|
||||
@@ -14,6 +14,8 @@ namespace FlaxEditor.GUI.Input
|
||||
[HideInEditor]
|
||||
public class DoubleValueBox : ValueBox<double>
|
||||
{
|
||||
private Utils.ValueCategory _category = Utils.ValueCategory.None;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override double Value
|
||||
{
|
||||
@@ -131,9 +133,19 @@ namespace FlaxEditor.GUI.Input
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get or set the category of the value. This can either be none for just a number, a distance or an angle.
|
||||
/// Gets or sets the category of the value. This can be none for just a number or a more specific one like a distance.
|
||||
/// </summary>
|
||||
public Utils.ValueCategory Category = Utils.ValueCategory.None;
|
||||
public Utils.ValueCategory Category
|
||||
{
|
||||
get => _category;
|
||||
set
|
||||
{
|
||||
if (_category == value)
|
||||
return;
|
||||
_category = value;
|
||||
UpdateText();
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected sealed override void UpdateText()
|
||||
|
||||
@@ -14,6 +14,8 @@ namespace FlaxEditor.GUI.Input
|
||||
[HideInEditor]
|
||||
public class FloatValueBox : ValueBox<float>
|
||||
{
|
||||
private Utils.ValueCategory _category = Utils.ValueCategory.None;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override float Value
|
||||
{
|
||||
@@ -137,14 +139,19 @@ namespace FlaxEditor.GUI.Input
|
||||
Value = Value;
|
||||
}
|
||||
|
||||
private Utils.ValueCategory _category = Utils.ValueCategory.None;
|
||||
|
||||
/// <summary>
|
||||
/// Get or set the category of the value. This can be none for just a number or a more specific one like a distance.
|
||||
/// Gets or sets the category of the value. This can be none for just a number or a more specific one like a distance.
|
||||
/// </summary>
|
||||
public Utils.ValueCategory Category {
|
||||
public Utils.ValueCategory Category
|
||||
{
|
||||
get => _category;
|
||||
set { _category = value; UpdateText(); }
|
||||
set
|
||||
{
|
||||
if (_category == value)
|
||||
return;
|
||||
_category = value;
|
||||
UpdateText();
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -118,22 +118,24 @@ namespace FlaxEditor.Options
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Options for formatting numerical values
|
||||
/// Options for formatting numerical values.
|
||||
/// </summary>
|
||||
public enum ValueFormattingType
|
||||
{
|
||||
/// <summary>
|
||||
/// No formatting
|
||||
/// No formatting.
|
||||
/// </summary>
|
||||
None,
|
||||
|
||||
/// <summary>
|
||||
/// Format using the base SI unit
|
||||
/// Format using the base SI unit.
|
||||
/// </summary>
|
||||
BaseUnit,
|
||||
|
||||
/// <summary>
|
||||
/// Format using a unit that matches the value best
|
||||
/// Format using a unit that matches the value best.
|
||||
/// </summary>
|
||||
AutoUnit
|
||||
AutoUnit,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -214,7 +216,7 @@ namespace FlaxEditor.Options
|
||||
private bool _spaceNumberAndUnits = false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the option to put a space between numbers and units for unit formatting
|
||||
/// Gets or sets the option to put a space between numbers and units for unit formatting.
|
||||
/// </summary>
|
||||
[DefaultValue(false)]
|
||||
[EditorDisplay("Interface"), EditorOrder(310), Tooltip("Put a space between numbers and units.")]
|
||||
|
||||
@@ -141,19 +141,17 @@ namespace FlaxEditor.Utilities
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// List known units which cannot be handled as a variable easily because they contain operator
|
||||
/// symbols (mostly a forward slash). The value is the factor to calculate game units.
|
||||
/// List known units which cannot be handled as a variable easily because they contain operator symbols (mostly a forward slash). The value is the factor to calculate game units.
|
||||
/// </summary>
|
||||
// Nm is here because these values are compared case-sensitive and we don't want to confuse
|
||||
// nanometers and Newtonmeters
|
||||
private static readonly IDictionary<string, double> UnitSymbols = new Dictionary<string, double>
|
||||
{
|
||||
["cm/s"] = Units.Meters2Units / 100,
|
||||
["cm/s²"] = Units.Meters2Units / 100,
|
||||
["m/s"] = Units.Meters2Units,
|
||||
["m/s²"] = Units.Meters2Units,
|
||||
["km/h"] = 1/3.6 * Units.Meters2Units,
|
||||
["Nm"] = Units.Meters2Units * Units.Meters2Units
|
||||
["km/h"] = 1 / 3.6 * Units.Meters2Units,
|
||||
// Nm is here because these values are compared case-sensitive, and we don't want to confuse nanometers and Newtonmeters
|
||||
["Nm"] = Units.Meters2Units * Units.Meters2Units,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@@ -189,7 +187,7 @@ namespace FlaxEditor.Utilities
|
||||
if (Operators.ContainsKey(str))
|
||||
return TokenType.Operator;
|
||||
|
||||
if (char.IsLetter(c) || c=='²' || c=='³')
|
||||
if (char.IsLetter(c) || c == '²' || c == '³')
|
||||
return TokenType.Variable;
|
||||
|
||||
throw new ParsingException("wrong character");
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved.
|
||||
|
||||
namespace FlaxEditor.Utilities;
|
||||
|
||||
/// <summary>
|
||||
/// Units display utilities for Editor.
|
||||
/// </summary>
|
||||
public class Units
|
||||
{
|
||||
/// <summary>
|
||||
@@ -8,7 +13,7 @@ public class Units
|
||||
public static readonly float Meters2Units = 100f;
|
||||
|
||||
/// <summary>
|
||||
/// Set it to false to always show game units without any postfix.
|
||||
/// False to always show game units without any postfix.
|
||||
/// </summary>
|
||||
public static bool UseUnitsFormatting = true;
|
||||
|
||||
@@ -25,8 +30,8 @@ public class Units
|
||||
/// <summary>
|
||||
/// Return the unit according to user settings.
|
||||
/// </summary>
|
||||
/// <param name="unit"></param>
|
||||
/// <returns></returns>
|
||||
/// <param name="unit">The unit name.</param>
|
||||
/// <returns>The formatted text.</returns>
|
||||
public static string Unit(string unit)
|
||||
{
|
||||
if (SpaceNumberAndUnits)
|
||||
|
||||
@@ -1248,38 +1248,37 @@ namespace FlaxEditor.Utilities
|
||||
{
|
||||
switch (category)
|
||||
{
|
||||
case FlaxEngine.Utils.ValueCategory.Distance:
|
||||
if (!Units.AutomaticUnitsFormatting)
|
||||
return (value / Units.Meters2Units).ToString(format, CultureInfo.InvariantCulture) + Units.Unit("m");
|
||||
var absValue = Mathf.Abs(value);
|
||||
// in case a unit != cm this would be (value / Meters2Units * 100)
|
||||
if (absValue < Units.Meters2Units)
|
||||
return value.ToString(format, CultureInfo.InvariantCulture) + Units.Unit("cm");
|
||||
if (absValue < Units.Meters2Units * 1000)
|
||||
return (value / Units.Meters2Units).ToString(format, CultureInfo.InvariantCulture) + Units.Unit("m");
|
||||
return (value / 1000 / Units.Meters2Units).ToString(format, CultureInfo.InvariantCulture) + Units.Unit("km");
|
||||
case FlaxEngine.Utils.ValueCategory.Angle: return value.ToString(format, CultureInfo.InvariantCulture) + "°";
|
||||
case FlaxEngine.Utils.ValueCategory.Time: return value.ToString(format, CultureInfo.InvariantCulture) + Units.Unit("s");
|
||||
// some fonts have a symbol for that: "\u33A7"
|
||||
case FlaxEngine.Utils.ValueCategory.Speed: return (value / Units.Meters2Units).ToString(format, CultureInfo.InvariantCulture) + Units.Unit("m/s");
|
||||
case FlaxEngine.Utils.ValueCategory.Acceleration: return (value / Units.Meters2Units).ToString(format, CultureInfo.InvariantCulture) + Units.Unit("m/s²");
|
||||
case FlaxEngine.Utils.ValueCategory.Area: return (value / Units.Meters2Units / Units.Meters2Units).ToString(format, CultureInfo.InvariantCulture) + Units.Unit("m²");
|
||||
case FlaxEngine.Utils.ValueCategory.Volume: return (value / Units.Meters2Units / Units.Meters2Units / Units.Meters2Units).ToString(format, CultureInfo.InvariantCulture) + Units.Unit("m³");
|
||||
case FlaxEngine.Utils.ValueCategory.Mass: return value.ToString(format, CultureInfo.InvariantCulture) + Units.Unit("kg");
|
||||
case FlaxEngine.Utils.ValueCategory.Force: return (value / Units.Meters2Units).ToString(format, CultureInfo.InvariantCulture) + Units.Unit("N");
|
||||
case FlaxEngine.Utils.ValueCategory.Torque: return (value / Units.Meters2Units / Units.Meters2Units).ToString(format, CultureInfo.InvariantCulture) + Units.Unit("Nm");
|
||||
case FlaxEngine.Utils.ValueCategory.None:
|
||||
default:
|
||||
return FormatFloat(value);
|
||||
case FlaxEngine.Utils.ValueCategory.Distance:
|
||||
if (!Units.AutomaticUnitsFormatting)
|
||||
return (value / Units.Meters2Units).ToString(format, CultureInfo.InvariantCulture) + Units.Unit("m");
|
||||
var absValue = Mathf.Abs(value);
|
||||
// in case a unit != cm this would be (value / Meters2Units * 100)
|
||||
if (absValue < Units.Meters2Units)
|
||||
return value.ToString(format, CultureInfo.InvariantCulture) + Units.Unit("cm");
|
||||
if (absValue < Units.Meters2Units * 1000)
|
||||
return (value / Units.Meters2Units).ToString(format, CultureInfo.InvariantCulture) + Units.Unit("m");
|
||||
return (value / 1000 / Units.Meters2Units).ToString(format, CultureInfo.InvariantCulture) + Units.Unit("km");
|
||||
case FlaxEngine.Utils.ValueCategory.Angle: return value.ToString(format, CultureInfo.InvariantCulture) + "°";
|
||||
case FlaxEngine.Utils.ValueCategory.Time: return value.ToString(format, CultureInfo.InvariantCulture) + Units.Unit("s");
|
||||
// some fonts have a symbol for that: "\u33A7"
|
||||
case FlaxEngine.Utils.ValueCategory.Speed: return (value / Units.Meters2Units).ToString(format, CultureInfo.InvariantCulture) + Units.Unit("m/s");
|
||||
case FlaxEngine.Utils.ValueCategory.Acceleration: return (value / Units.Meters2Units).ToString(format, CultureInfo.InvariantCulture) + Units.Unit("m/s²");
|
||||
case FlaxEngine.Utils.ValueCategory.Area: return (value / Units.Meters2Units / Units.Meters2Units).ToString(format, CultureInfo.InvariantCulture) + Units.Unit("m²");
|
||||
case FlaxEngine.Utils.ValueCategory.Volume: return (value / Units.Meters2Units / Units.Meters2Units / Units.Meters2Units).ToString(format, CultureInfo.InvariantCulture) + Units.Unit("m³");
|
||||
case FlaxEngine.Utils.ValueCategory.Mass: return value.ToString(format, CultureInfo.InvariantCulture) + Units.Unit("kg");
|
||||
case FlaxEngine.Utils.ValueCategory.Force: return (value / Units.Meters2Units).ToString(format, CultureInfo.InvariantCulture) + Units.Unit("N");
|
||||
case FlaxEngine.Utils.ValueCategory.Torque: return (value / Units.Meters2Units / Units.Meters2Units).ToString(format, CultureInfo.InvariantCulture) + Units.Unit("Nm");
|
||||
case FlaxEngine.Utils.ValueCategory.None:
|
||||
default: return FormatFloat(value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Format a float value either as-is, with a distance unit or with a degree sign
|
||||
/// Format a float value either as-is, with a distance unit or with a degree sign.
|
||||
/// </summary>
|
||||
/// <param name="value">the value to format</param>
|
||||
/// <param name="category">the value type: none means just a number, distance will format in cm/m/km, angle with an appended degree sign</param>
|
||||
/// <returns>the formatted string</returns>
|
||||
/// <param name="value">The value to format.</param>
|
||||
/// <param name="category">The value type: none means just a number, distance will format in cm/m/km, angle with an appended degree sign.</param>
|
||||
/// <returns>The formatted string.</returns>
|
||||
public static string FormatFloat(float value, FlaxEngine.Utils.ValueCategory category)
|
||||
{
|
||||
if (float.IsPositiveInfinity(value) || value == float.MaxValue)
|
||||
@@ -1295,9 +1294,9 @@ namespace FlaxEditor.Utilities
|
||||
/// <summary>
|
||||
/// Format a double value either as-is, with a distance unit or with a degree sign
|
||||
/// </summary>
|
||||
/// <param name="value">the value to format</param>
|
||||
/// <param name="category">the value type: none means just a number, distance will format in cm/m/km, angle with an appended degree sign</param>
|
||||
/// <returns>the formatted string</returns>
|
||||
/// <param name="value">The value to format.</param>
|
||||
/// <param name="category">The value type: none means just a number, distance will format in cm/m/km, angle with an appended degree sign.</param>
|
||||
/// <returns>The formatted string.</returns>
|
||||
public static string FormatFloat(double value, FlaxEngine.Utils.ValueCategory category)
|
||||
{
|
||||
if (double.IsPositiveInfinity(value) || value == double.MaxValue)
|
||||
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
/// <summary>
|
||||
/// Gets the camera's field of view (in degrees).
|
||||
/// </summary>
|
||||
API_PROPERTY(Attributes="EditorOrder(20), DefaultValue(60.0f), Limit(0, 179), EditorDisplay(\"Camera\", \"Field Of View\"), VisibleIf(nameof(UsePerspective))")
|
||||
API_PROPERTY(Attributes="EditorOrder(20), DefaultValue(60.0f), Limit(0, 179), EditorDisplay(\"Camera\", \"Field Of View\"), VisibleIf(nameof(UsePerspective)), ValueCategory(Utils.ValueCategory.Angle)")
|
||||
float GetFieldOfView() const;
|
||||
|
||||
/// <summary>
|
||||
@@ -99,7 +99,7 @@ public:
|
||||
/// <summary>
|
||||
/// Gets camera's near plane distance.
|
||||
/// </summary>
|
||||
API_PROPERTY(Attributes="EditorOrder(30), DefaultValue(10.0f), Limit(0, 1000, 0.05f), EditorDisplay(\"Camera\")")
|
||||
API_PROPERTY(Attributes="EditorOrder(30), DefaultValue(10.0f), Limit(0, 1000, 0.05f), EditorDisplay(\"Camera\"), ValueCategory(Utils.ValueCategory.Distance)")
|
||||
float GetNearPlane() const;
|
||||
|
||||
/// <summary>
|
||||
@@ -110,7 +110,7 @@ public:
|
||||
/// <summary>
|
||||
/// Gets camera's far plane distance.
|
||||
/// </summary>
|
||||
API_PROPERTY(Attributes="EditorOrder(40), DefaultValue(40000.0f), Limit(0, float.MaxValue, 5), EditorDisplay(\"Camera\")")
|
||||
API_PROPERTY(Attributes="EditorOrder(40), DefaultValue(40000.0f), Limit(0, float.MaxValue, 5), EditorDisplay(\"Camera\"), ValueCategory(Utils.ValueCategory.Distance)")
|
||||
float GetFarPlane() const;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -181,7 +181,7 @@ public:
|
||||
/// <summary>
|
||||
/// Gets the mass value measured in kilograms (use override value only if OverrideMass is checked).
|
||||
/// </summary>
|
||||
API_PROPERTY(Attributes="EditorOrder(110), Limit(0), EditorDisplay(\"Rigid Body\"), NumberCategory(Utils.ValueCategory.Mass)")
|
||||
API_PROPERTY(Attributes="EditorOrder(110), Limit(0), EditorDisplay(\"Rigid Body\"), ValueCategory(Utils.ValueCategory.Mass)")
|
||||
float GetMass() const;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -23,7 +23,7 @@ public:
|
||||
/// Gets the size of the box, measured in the object's local space.
|
||||
/// </summary>
|
||||
/// <remarks>The box size will be scaled by the actor's world scale. </remarks>
|
||||
API_PROPERTY(Attributes="EditorOrder(100), DefaultValue(typeof(Float3), \"100,100,100\"), EditorDisplay(\"Collider\"), NumberCategory(Utils.ValueCategory.Distance)")
|
||||
API_PROPERTY(Attributes="EditorOrder(100), DefaultValue(typeof(Float3), \"100,100,100\"), EditorDisplay(\"Collider\"), ValueCategory(Utils.ValueCategory.Distance)")
|
||||
FORCE_INLINE Float3 GetSize() const
|
||||
{
|
||||
return _size;
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
/// Gets the radius of the sphere, measured in the object's local space.
|
||||
/// </summary>
|
||||
/// <remarks>The sphere radius will be scaled by the actor's world scale.</remarks>
|
||||
API_PROPERTY(Attributes="EditorOrder(100), DefaultValue(20.0f), EditorDisplay(\"Collider\"), NumberCategory(Utils.ValueCategory.Distance)")
|
||||
API_PROPERTY(Attributes="EditorOrder(100), DefaultValue(20.0f), EditorDisplay(\"Collider\"), ValueCategory(Utils.ValueCategory.Distance)")
|
||||
FORCE_INLINE float GetRadius() const
|
||||
{
|
||||
return _radius;
|
||||
@@ -41,7 +41,7 @@ public:
|
||||
/// Gets the height of the capsule, measured in the object's local space between the centers of the hemispherical ends.
|
||||
/// </summary>
|
||||
/// <remarks>The capsule height will be scaled by the actor's world scale.</remarks>
|
||||
API_PROPERTY(Attributes="EditorOrder(110), DefaultValue(100.0f), EditorDisplay(\"Collider\"), NumberCategory(Utils.ValueCategory.Distance)")
|
||||
API_PROPERTY(Attributes="EditorOrder(110), DefaultValue(100.0f), EditorDisplay(\"Collider\"), ValueCategory(Utils.ValueCategory.Distance)")
|
||||
FORCE_INLINE float GetHeight() const
|
||||
{
|
||||
return _height;
|
||||
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
/// <summary>
|
||||
/// Gets the radius of the sphere, measured in the object's local space. The sphere radius will be scaled by the actor's world scale.
|
||||
/// </summary>
|
||||
API_PROPERTY(Attributes="EditorOrder(100), DefaultValue(50.0f), EditorDisplay(\"Collider\"), NumberCategory(Utils.ValueCategory.Distance)")
|
||||
API_PROPERTY(Attributes="EditorOrder(100), DefaultValue(50.0f), EditorDisplay(\"Collider\"), ValueCategory(Utils.ValueCategory.Distance)")
|
||||
float GetRadius() const;
|
||||
|
||||
/// <summary>
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
/// <summary>
|
||||
/// Gets the height of the capsule, measured in the object's local space. The capsule height will be scaled by the actor's world scale.
|
||||
/// </summary>
|
||||
API_PROPERTY(Attributes="EditorOrder(110), DefaultValue(150.0f), EditorDisplay(\"Collider\"), NumberCategory(Utils.ValueCategory.Distance)")
|
||||
API_PROPERTY(Attributes="EditorOrder(110), DefaultValue(150.0f), EditorDisplay(\"Collider\"), ValueCategory(Utils.ValueCategory.Distance)")
|
||||
float GetHeight() const;
|
||||
|
||||
/// <summary>
|
||||
@@ -95,7 +95,7 @@ public:
|
||||
/// <summary>
|
||||
/// Gets the slope limit (in degrees). Limits the collider to only climb slopes that are less steep (in degrees) than the indicated value.
|
||||
/// </summary>
|
||||
API_PROPERTY(Attributes="EditorOrder(210), DefaultValue(45.0f), Limit(0, 100), EditorDisplay(\"Character Controller\"), NumberCategory(Utils.ValueCategory.Angle)")
|
||||
API_PROPERTY(Attributes="EditorOrder(210), DefaultValue(45.0f), Limit(0, 100), EditorDisplay(\"Character Controller\"), ValueCategory(Utils.ValueCategory.Angle)")
|
||||
float GetSlopeLimit() const;
|
||||
|
||||
/// <summary>
|
||||
@@ -117,7 +117,7 @@ public:
|
||||
/// <summary>
|
||||
/// Gets the step height. The character will step up a stair only if it is closer to the ground than the indicated value. This should not be greater than the Character Controller’s height or it will generate an error.
|
||||
/// </summary>
|
||||
API_PROPERTY(Attributes="EditorOrder(220), DefaultValue(30.0f), Limit(0), EditorDisplay(\"Character Controller\"), NumberCategory(Utils.ValueCategory.Distance)")
|
||||
API_PROPERTY(Attributes="EditorOrder(220), DefaultValue(30.0f), Limit(0), EditorDisplay(\"Character Controller\"), ValueCategory(Utils.ValueCategory.Distance)")
|
||||
float GetStepOffset() const;
|
||||
|
||||
/// <summary>
|
||||
@@ -139,7 +139,7 @@ public:
|
||||
/// <summary>
|
||||
/// Gets the minimum move distance of the character controller. The minimum traveled distance to consider. If traveled distance is smaller, the character doesn't move. This is used to stop the recursive motion algorithm when remaining distance to travel is small.
|
||||
/// </summary>
|
||||
API_PROPERTY(Attributes="EditorOrder(230), DefaultValue(0.0f), Limit(0, 1000), EditorDisplay(\"Character Controller\"), NumberCategory(Utils.ValueCategory.Distance)")
|
||||
API_PROPERTY(Attributes="EditorOrder(230), DefaultValue(0.0f), Limit(0, 1000), EditorDisplay(\"Character Controller\"), ValueCategory(Utils.ValueCategory.Distance)")
|
||||
float GetMinMoveDistance() const;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
/// <summary>
|
||||
/// Gets the center of the collider, measured in the object's local space.
|
||||
/// </summary>
|
||||
API_PROPERTY(Attributes="EditorOrder(10), DefaultValue(typeof(Vector3), \"0,0,0\"), EditorDisplay(\"Collider\"), NumberCategory(Utils.ValueCategory.Distance)")
|
||||
API_PROPERTY(Attributes="EditorOrder(10), DefaultValue(typeof(Vector3), \"0,0,0\"), EditorDisplay(\"Collider\"), ValueCategory(Utils.ValueCategory.Distance)")
|
||||
FORCE_INLINE Vector3 GetCenter() const
|
||||
{
|
||||
return _center;
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
/// <summary>
|
||||
/// Gets the contact offset. Colliders whose distance is less than the sum of their ContactOffset values will generate contacts. The contact offset must be positive. Contact offset allows the collision detection system to predictively enforce the contact constraint even when the objects are slightly separated.
|
||||
/// </summary>
|
||||
API_PROPERTY(Attributes="EditorOrder(1), DefaultValue(2.0f), Limit(0, 100), EditorDisplay(\"Collider\"), NumberCategory(Utils.ValueCategory.Distance)")
|
||||
API_PROPERTY(Attributes="EditorOrder(1), DefaultValue(2.0f), Limit(0, 100), EditorDisplay(\"Collider\"), ValueCategory(Utils.ValueCategory.Distance)")
|
||||
FORCE_INLINE float GetContactOffset() const
|
||||
{
|
||||
return _contactOffset;
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
/// Gets the radius of the sphere, measured in the object's local space.
|
||||
/// </summary>
|
||||
/// <remarks>The sphere radius will be scaled by the actor's world scale.</remarks>
|
||||
API_PROPERTY(Attributes="EditorOrder(100), DefaultValue(50.0f), EditorDisplay(\"Collider\"), NumberCategory(Utils.ValueCategory.Distance)")
|
||||
API_PROPERTY(Attributes="EditorOrder(100), DefaultValue(50.0f), EditorDisplay(\"Collider\"), ValueCategory(Utils.ValueCategory.Distance)")
|
||||
FORCE_INLINE float GetRadius() const
|
||||
{
|
||||
return _radius;
|
||||
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
/// Gets the allowed minimum distance for the joint.
|
||||
/// </summary>
|
||||
/// <remarks>Used only when DistanceJointFlag.MinDistance flag is set. The minimum distance must be no more than the maximum distance. Default: 0, Range: [0, float.MaxValue].</remarks>
|
||||
API_PROPERTY(Attributes="EditorOrder(110), DefaultValue(0.0f), Limit(0.0f), EditorDisplay(\"Joint\"), NumberCategory(Utils.ValueCategory.Distance)")
|
||||
API_PROPERTY(Attributes="EditorOrder(110), DefaultValue(0.0f), Limit(0.0f), EditorDisplay(\"Joint\"), ValueCategory(Utils.ValueCategory.Distance)")
|
||||
FORCE_INLINE float GetMinDistance() const
|
||||
{
|
||||
return _minDistance;
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
/// Gets the allowed maximum distance for the joint.
|
||||
/// </summary>
|
||||
/// <remarks>Used only when DistanceJointFlag.MaxDistance flag is set. The maximum distance must be no less than the minimum distance. Default: 0, Range: [0, float.MaxValue].</remarks>
|
||||
API_PROPERTY(Attributes="EditorOrder(120), DefaultValue(10.0f), Limit(0.0f), EditorDisplay(\"Joint\"), NumberCategory(Utils.ValueCategory.Distance)")
|
||||
API_PROPERTY(Attributes="EditorOrder(120), DefaultValue(10.0f), Limit(0.0f), EditorDisplay(\"Joint\"), ValueCategory(Utils.ValueCategory.Distance)")
|
||||
FORCE_INLINE float GetMaxDistance() const
|
||||
{
|
||||
return _maxDistance;
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
/// <summary>
|
||||
/// Gets the break force. Determines the maximum force the joint can apply before breaking. Broken joints no longer participate in physics simulation.
|
||||
/// </summary>
|
||||
API_PROPERTY(Attributes="EditorOrder(10), DefaultValue(float.MaxValue), EditorDisplay(\"Joint\"), NumberCategory(Utils.ValueCategory.Force)")
|
||||
API_PROPERTY(Attributes="EditorOrder(10), DefaultValue(float.MaxValue), EditorDisplay(\"Joint\"), ValueCategory(Utils.ValueCategory.Force)")
|
||||
FORCE_INLINE float GetBreakForce() const
|
||||
{
|
||||
return _breakForce;
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
/// <summary>
|
||||
/// Gets the break torque. Determines the maximum torque the joint can apply before breaking. Broken joints no longer participate in physics simulation.
|
||||
/// </summary>
|
||||
API_PROPERTY(Attributes="EditorOrder(20), DefaultValue(float.MaxValue), EditorDisplay(\"Joint\"), NumberCategory(Utils.ValueCategory.Torque)")
|
||||
API_PROPERTY(Attributes="EditorOrder(20), DefaultValue(float.MaxValue), EditorDisplay(\"Joint\"), ValueCategory(Utils.ValueCategory.Torque)")
|
||||
FORCE_INLINE float GetBreakTorque() const
|
||||
{
|
||||
return _breakTorque;
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
|
||||
// Copyright (c) 2012-2024 Wojciech Figat. All rights reserved.
|
||||
|
||||
using System;
|
||||
|
||||
namespace FlaxEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to specify the value category of a numeric value as either as-is (a scalar), a distance (formatted as cm/m/km) or an angle (formatted with a degree sign).
|
||||
/// Specifies the value category of a numeric value as either as-is (a scalar), a distance (formatted as cm/m/km) or an angle (formatted with a degree sign).
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Attribute" />
|
||||
[Serializable]
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
||||
public sealed class ValueCategoryAttribute : Attribute
|
||||
@@ -17,6 +16,9 @@ namespace FlaxEngine
|
||||
/// </summary>
|
||||
public Utils.ValueCategory Category;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ValueCategoryAttribute"/> class.
|
||||
/// </summary>
|
||||
private ValueCategoryAttribute()
|
||||
{
|
||||
Category = Utils.ValueCategory.None;
|
||||
|
||||
@@ -257,6 +257,7 @@ namespace FlaxEngine
|
||||
{
|
||||
public static FieldInfo itemsField;
|
||||
}
|
||||
|
||||
internal static T[] ExtractArrayFromList<T>(List<T> list)
|
||||
{
|
||||
if (list == null)
|
||||
@@ -1040,21 +1041,64 @@ namespace FlaxEngine
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A category of number values used for formatting and input boxes
|
||||
/// A category of number values used for formatting and input fields.
|
||||
/// </summary>
|
||||
public enum ValueCategory
|
||||
{
|
||||
/// <summary>
|
||||
/// Nothing.
|
||||
/// </summary>
|
||||
None,
|
||||
|
||||
/// <summary>
|
||||
/// Distance (eg. meters).
|
||||
/// </summary>
|
||||
Distance,
|
||||
|
||||
/// <summary>
|
||||
/// Area (eg. m^2).
|
||||
/// </summary>
|
||||
Area,
|
||||
|
||||
/// <summary>
|
||||
/// Volume (eg. m^3).
|
||||
/// </summary>
|
||||
Volume,
|
||||
|
||||
/// <summary>
|
||||
/// Mass (eg. kilograms).
|
||||
/// </summary>
|
||||
Mass,
|
||||
|
||||
/// <summary>
|
||||
/// Angle (eg. degrees).
|
||||
/// </summary>
|
||||
Angle,
|
||||
|
||||
/// <summary>
|
||||
/// Speed (distance / time).
|
||||
/// </summary>
|
||||
Speed,
|
||||
|
||||
/// <summary>
|
||||
/// Acceleration (distance^2 / time).
|
||||
/// </summary>
|
||||
Acceleration,
|
||||
|
||||
/// <summary>
|
||||
/// Time (eg. seconds).
|
||||
/// </summary>
|
||||
Time,
|
||||
|
||||
/// <summary>
|
||||
/// Force (mass * distance / time^2).
|
||||
/// </summary>
|
||||
Force,
|
||||
Torque
|
||||
|
||||
/// <summary>
|
||||
/// Torque (mass * distance^2 / time^2).
|
||||
/// </summary>
|
||||
Torque,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user