- Cleanup

- Typo
This commit is contained in:
Nils Hausfeld
2023-10-19 14:14:51 +02:00
parent 41a7aff6d7
commit aafdc64b68
3 changed files with 30 additions and 32 deletions

View File

@@ -7,13 +7,11 @@ using Real = System.Single;
#endif
using System;
using System.Linq;
using System.Reflection;
using FlaxEditor.CustomEditors.Editors;
using FlaxEditor.GUI;
using FlaxEditor.Scripting;
using FlaxEditor.Surface.Elements;
using FlaxEditor.Surface.Undo;
using FlaxEngine;
using FlaxEngine.GUI;
using FlaxEngine.Utilities;
@@ -348,7 +346,7 @@ namespace FlaxEditor.Surface.Archetypes
SetValue(0, array);
}
}
/// <summary>
/// The nodes for that group.
/// </summary>
@@ -358,7 +356,7 @@ namespace FlaxEditor.Surface.Archetypes
{
TypeID = 1,
Title = "Bool",
Create = (id, context, arch, groupArch) => new ConvertableNode(id, context, arch, groupArch, new ScriptType(typeof(bool))),
Create = (id, context, arch, groupArch) => new ConvertibleNode(id, context, arch, groupArch, new ScriptType(typeof(bool))),
Description = "Constant boolean value",
Flags = NodeFlags.AllGraphs,
Size = new Float2(110, 20),
@@ -391,7 +389,7 @@ namespace FlaxEditor.Surface.Archetypes
{
TypeID = 2,
Title = "Integer",
Create = (id, context, arch, groupArch) => new ConvertableNode(id, context, arch, groupArch, new ScriptType(typeof(int))),
Create = (id, context, arch, groupArch) => new ConvertibleNode(id, context, arch, groupArch, new ScriptType(typeof(int))),
Description = "Constant integer value",
Flags = NodeFlags.AllGraphs,
Size = new Float2(110, 20),
@@ -419,7 +417,7 @@ namespace FlaxEditor.Surface.Archetypes
{
TypeID = 3,
Title = "Float",
Create = (id, context, arch, groupArch) => new ConvertableNode(id, context, arch, groupArch, new ScriptType(typeof(float))),
Create = (id, context, arch, groupArch) => new ConvertibleNode(id, context, arch, groupArch, new ScriptType(typeof(float))),
Description = "Constant floating point",
Flags = NodeFlags.AllGraphs,
Size = new Float2(110, 20),
@@ -447,7 +445,7 @@ namespace FlaxEditor.Surface.Archetypes
{
TypeID = 4,
Title = "Float2",
Create = (id, context, arch, groupArch) => new ConvertableNode(id, context, arch, groupArch, new ScriptType(typeof(Float2))),
Create = (id, context, arch, groupArch) => new ConvertibleNode(id, context, arch, groupArch, new ScriptType(typeof(Float2))),
Description = "Constant Float2",
Flags = NodeFlags.AllGraphs,
Size = new Float2(130, 60),
@@ -478,7 +476,7 @@ namespace FlaxEditor.Surface.Archetypes
{
TypeID = 5,
Title = "Float3",
Create = (id, context, arch, groupArch) => new ConvertableNode(id, context, arch, groupArch, new ScriptType(typeof(Float3))),
Create = (id, context, arch, groupArch) => new ConvertibleNode(id, context, arch, groupArch, new ScriptType(typeof(Float3))),
Description = "Constant Float3",
Flags = NodeFlags.AllGraphs,
Size = new Float2(130, 80),
@@ -511,7 +509,7 @@ namespace FlaxEditor.Surface.Archetypes
{
TypeID = 6,
Title = "Float4",
Create = (id, context, arch, groupArch) => new ConvertableNode(id, context, arch, groupArch, new ScriptType(typeof(Float4))),
Create = (id, context, arch, groupArch) => new ConvertibleNode(id, context, arch, groupArch, new ScriptType(typeof(Float4))),
Description = "Constant Float4",
Flags = NodeFlags.AllGraphs,
Size = new Float2(130, 100),
@@ -546,7 +544,7 @@ namespace FlaxEditor.Surface.Archetypes
{
TypeID = 7,
Title = "Color",
Create = (id, context, arch, groupArch) => new ConvertableNode(id, context, arch, groupArch, new ScriptType(typeof(Color))),
Create = (id, context, arch, groupArch) => new ConvertibleNode(id, context, arch, groupArch, new ScriptType(typeof(Color))),
Description = "RGBA color",
Flags = NodeFlags.AllGraphs,
Size = new Float2(70, 100),
@@ -581,7 +579,7 @@ namespace FlaxEditor.Surface.Archetypes
Title = "Rotation",
// TODO: Way too long and ugly - find a better way to add conversion
Create = (id, context, arch, groupArch) =>
new ConvertableNode(id, context, arch, groupArch, new ScriptType(typeof(Quaternion)),
new ConvertibleNode(id, context, arch, groupArch, new ScriptType(typeof(Quaternion)),
values => Quaternion.Euler((float)values[0], (float)values[1], (float)values[2])),
Description = "Euler angle rotation",
Flags = NodeFlags.AnimGraph | NodeFlags.VisualScriptGraph | NodeFlags.ParticleEmitterGraph,
@@ -607,7 +605,7 @@ namespace FlaxEditor.Surface.Archetypes
{
TypeID = 9,
Title = "String",
Create = (id, context, arch, groupArch) => new ConvertableNode(id, context, arch, groupArch, new ScriptType(typeof(string))),
Create = (id, context, arch, groupArch) => new ConvertibleNode(id, context, arch, groupArch, new ScriptType(typeof(string))),
Description = "Text",
Flags = NodeFlags.VisualScriptGraph | NodeFlags.AnimGraph,
Size = new Float2(200, 20),
@@ -658,7 +656,7 @@ namespace FlaxEditor.Surface.Archetypes
{
TypeID = 12,
Title = "Unsigned Integer",
Create = (id, context, arch, groupArch) => new ConvertableNode(id, context, arch, groupArch, new ScriptType(typeof(uint))),
Create = (id, context, arch, groupArch) => new ConvertibleNode(id, context, arch, groupArch, new ScriptType(typeof(uint))),
Description = "Constant unsigned integer value",
Flags = NodeFlags.AllGraphs,
Size = new Float2(170, 20),
@@ -698,7 +696,7 @@ namespace FlaxEditor.Surface.Archetypes
{
TypeID = 15,
Title = "Double",
Create = (id, context, arch, groupArch) => new ConvertableNode(id, context, arch, groupArch, new ScriptType(typeof(double))),
Create = (id, context, arch, groupArch) => new ConvertibleNode(id, context, arch, groupArch, new ScriptType(typeof(double))),
Description = "Constant floating point",
Flags = NodeFlags.AllGraphs,
Size = new Float2(110, 20),
@@ -716,7 +714,7 @@ namespace FlaxEditor.Surface.Archetypes
{
TypeID = 16,
Title = "Vector2",
Create = (id, context, arch, groupArch) => new ConvertableNode(id, context, arch, groupArch, new ScriptType(typeof(Vector2))),
Create = (id, context, arch, groupArch) => new ConvertibleNode(id, context, arch, groupArch, new ScriptType(typeof(Vector2))),
Description = "Constant Vector2",
Flags = NodeFlags.AllGraphs,
Size = new Float2(130, 60),
@@ -737,7 +735,7 @@ namespace FlaxEditor.Surface.Archetypes
{
TypeID = 17,
Title = "Vector3",
Create = (id, context, arch, groupArch) => new ConvertableNode(id, context, arch, groupArch, new ScriptType(typeof(Vector3))),
Create = (id, context, arch, groupArch) => new ConvertibleNode(id, context, arch, groupArch, new ScriptType(typeof(Vector3))),
Description = "Constant Vector3",
Flags = NodeFlags.AllGraphs,
Size = new Float2(130, 80),
@@ -760,7 +758,7 @@ namespace FlaxEditor.Surface.Archetypes
{
TypeID = 18,
Title = "Vector4",
Create = (id, context, arch, groupArch) => new ConvertableNode(id, context, arch, groupArch, new ScriptType(typeof(Vector4))),
Create = (id, context, arch, groupArch) => new ConvertibleNode(id, context, arch, groupArch, new ScriptType(typeof(Vector4))),
Description = "Constant Vector4",
Flags = NodeFlags.AllGraphs,
Size = new Float2(130, 100),

View File

@@ -9,15 +9,15 @@ using FlaxEngine;
namespace FlaxEditor.Surface.Archetypes;
/// <summary>
///
/// A special type of node that adds the functionality to convert nodes to parameters
/// </summary>
internal class ConvertableNode : SurfaceNode
internal class ConvertibleNode : SurfaceNode
{
private ScriptType _type;
private Func<object[], object> _convertFunction;
private readonly ScriptType _type;
private readonly Func<object[], object> _convertFunction;
/// <inheritdoc />
public ConvertableNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch, ScriptType type, Func<object[], object> convertFunction = null)
public ConvertibleNode(uint id, VisjectSurfaceContext context, NodeArchetype nodeArch, GroupArchetype groupArch, ScriptType type, Func<object[], object> convertFunction = null)
: base(id, context, nodeArch, groupArch)
{
_type = type;
@@ -37,7 +37,7 @@ internal class ConvertableNode : SurfaceNode
{
if(Surface.Owner is not IVisjectSurfaceWindow window)
throw new Exception("Surface owner is not a Visject Surface Window");
Asset asset = Surface.Owner.SurfaceAsset;
if (asset == null || !asset.IsLoaded)
{
@@ -60,7 +60,7 @@ internal class ConvertableNode : SurfaceNode
paramAction.Do();
Guid parameterGuid = Surface.Parameters[paramIndex].ID;
bool undoEnabled = Surface.Undo.Enabled;
Surface.Undo.Enabled = false;
NodeArchetype arch = Surface.GetParameterGetterNodeArchetype(out var groupId);
@@ -69,7 +69,7 @@ internal class ConvertableNode : SurfaceNode
if (node is not Parameters.SurfaceNodeParamsGet getNode)
throw new Exception("Node is not a ParamsGet node!");
// Recreate connections of constant node
// Constant nodes and parameter nodes should have the same ports, so we can just iterate through the connections
var boxes = GetBoxes();
@@ -81,7 +81,7 @@ internal class ConvertableNode : SurfaceNode
if (!getNode.TryGetBox(i, out Box paramBox))
continue;
// Iterating backwards, because the CreateConnection method deletes entries from the box connections when target box IsSingle is set to true
for (int k = box.Connections.Count-1; k >= 0; k--)
{
@@ -89,14 +89,14 @@ internal class ConvertableNode : SurfaceNode
paramBox.CreateConnection(connectedBox);
}
}
var spawnNodeAction = new AddRemoveNodeAction(getNode, true);
var removeConstantAction = new AddRemoveNodeAction(this, false);
Surface.AddBatchedUndoAction(new MultiUndoAction(paramAction, spawnNodeAction, removeConstantAction));
removeConstantAction.Do();
}
private bool OnParameterRenameValidate(RenamePopup popup, string value)
{
if(Surface.Owner is not IVisjectSurfaceWindow window)

View File

@@ -96,7 +96,7 @@ namespace FlaxEditor.Surface.Archetypes
{
TypeID = 1,
Title = "Texture",
Create = (id, context, arch, groupArch) => new ConvertableNode(id, context, arch, groupArch, new ScriptType(typeof(Texture))),
Create = (id, context, arch, groupArch) => new ConvertibleNode(id, context, arch, groupArch, new ScriptType(typeof(Texture))),
Description = "Two dimensional texture object",
Flags = NodeFlags.MaterialGraph,
Size = new Float2(140, 120),
@@ -133,7 +133,7 @@ namespace FlaxEditor.Surface.Archetypes
{
TypeID = 3,
Title = "Cube Texture",
Create = (id, context, arch, groupArch) => new ConvertableNode(id, context, arch, groupArch, new ScriptType(typeof(CubeTexture))),
Create = (id, context, arch, groupArch) => new ConvertibleNode(id, context, arch, groupArch, new ScriptType(typeof(CubeTexture))),
Description = "Set of 6 textures arranged in a cube",
Flags = NodeFlags.MaterialGraph,
Size = new Float2(140, 120),
@@ -157,7 +157,7 @@ namespace FlaxEditor.Surface.Archetypes
{
TypeID = 4,
Title = "Normal Map",
Create = (id, context, arch, groupArch) => new ConvertableNode(id, context, arch, groupArch, new ScriptType(typeof(NormalMap))),
Create = (id, context, arch, groupArch) => new ConvertibleNode(id, context, arch, groupArch, new ScriptType(typeof(NormalMap))),
Description = "Two dimensional texture object sampled as a normal map",
Flags = NodeFlags.MaterialGraph,
Size = new Float2(140, 120),