- Test environment and first tests

This commit is contained in:
Nils Hausfeld
2023-10-26 20:33:07 +02:00
parent 806590d1c3
commit ff64fdb503
3 changed files with 16 additions and 11 deletions

View File

@@ -13,6 +13,11 @@ namespace FlaxEditor.Surface.Archetypes
public static class Math
{
private static NodeArchetype Op1(ushort id, string title, string desc, ConnectionsHint hints = ConnectionsHint.Numeric, Type type = null)
{
return Op1(id, title, desc, null, hints, type);
}
private static NodeArchetype Op1(ushort id, string title, string desc, string[] altTitles, ConnectionsHint hints = ConnectionsHint.Numeric, Type type = null)
{
return new NodeArchetype
{
@@ -20,6 +25,7 @@ namespace FlaxEditor.Surface.Archetypes
Title = title,
Description = desc,
Flags = NodeFlags.AllGraphs,
AlternativeTitles = altTitles,
Size = new Float2(110, 20),
DefaultType = new ScriptType(type),
ConnectionsHints = hints,
@@ -92,6 +98,7 @@ namespace FlaxEditor.Surface.Archetypes
{
TypeID = 11,
Title = "Length",
AlternativeTitles = new[] { "Magnitude", "Mag" },
Description = "Returns the length of A vector",
Flags = NodeFlags.AllGraphs,
Size = new Float2(110, 20),
@@ -107,10 +114,10 @@ namespace FlaxEditor.Surface.Archetypes
Op1(13, "Round", "Rounds A to the nearest integer"),
Op1(14, "Saturate", "Clamps A to the range [0, 1]"),
Op1(15, "Sine", "Returns sine of A"),
Op1(16, "Sqrt", "Returns square root of A"),
Op1(16, "Sqrt", "Returns square root of A", new [] { "Square Root", "Square", "Root" }),
Op1(17, "Tangent", "Returns tangent of A"),
Op2(18, "Cross", "Returns the cross product of A and B", ConnectionsHint.None, typeof(Float3)),
Op2(19, "Distance", "Returns a distance scalar between A and B", ConnectionsHint.Vector, null, typeof(float), false),
Op2(19, "Distance", "Returns a distance scalar between A and B", new [] { "Magnitude", "Mag", "Length" }, ConnectionsHint.Vector, null, typeof(float), false),
Op2(20, "Dot", "Returns the dot product of A and B", ConnectionsHint.Vector, null, typeof(float), false),
Op2(21, "Max", "Selects the greater of A and B"),
Op2(22, "Min", "Selects the lesser of A and B"),
@@ -185,7 +192,7 @@ namespace FlaxEditor.Surface.Archetypes
}
},
//
Op1(27, "Negate", "Returns opposite value"),
Op1(27, "Negate", "Returns opposite value", new [] { "Invert" }),
Op1(28, "One Minus", "Returns 1 - value"),
//
new NodeArchetype
@@ -225,6 +232,7 @@ namespace FlaxEditor.Surface.Archetypes
{
TypeID = 31,
Title = "Mad",
AlternativeTitles = new [] { "Multiply", "Add", "*+" },
Description = "Performs value multiplication and addition at once",
Flags = NodeFlags.AllGraphs,
Size = new Float2(160, 60),

View File

@@ -72,9 +72,7 @@ namespace FlaxEditor.Surface.ContextMenu
public void UpdateScore(Box selectedBox)
{
SortScore = 0;
if (!(_highlights?.Count > 0))
return;
if (!Visible)
return;

View File

@@ -140,8 +140,7 @@ namespace FlaxEditor.Utilities
// Check if start the matching sequence
if (matchStartPos == -1)
{
if (ranges == null)
ranges = new List<Range>();
ranges ??= new List<Range>();
matchStartPos = textPos;
}
}
@@ -152,7 +151,7 @@ namespace FlaxEditor.Utilities
{
var length = textPos - matchStartPos;
if (length >= MinLength)
ranges.Add(new Range(matchStartPos, length));
ranges!.Add(new Range(matchStartPos, length));
textPos = matchStartPos + length;
matchStartPos = -1;
}
@@ -165,13 +164,13 @@ namespace FlaxEditor.Utilities
{
var length = endPos - matchStartPos;
if (length >= MinLength)
ranges.Add(new Range(matchStartPos, length));
ranges!.Add(new Range(matchStartPos, length));
textPos = matchStartPos + length;
}
}
// Check if has any range
if (ranges != null && ranges.Count > 0)
if (ranges is { Count: > 0 })
{
matches = ranges.ToArray();
return true;