Constant Material nodes added

This commit is contained in:
barsdeveloper
2023-05-06 18:38:29 +02:00
parent 90f19e1bca
commit f7abd7ff6e
25 changed files with 563 additions and 177 deletions

View File

@@ -103,6 +103,7 @@ export default class Configuration {
enumLiteral: "/Script/BlueprintGraph.K2Node_EnumLiteral",
eSearchCase: "/Script/CoreUObject.ESearchCase",
eSearchDir: "/Script/CoreUObject.ESearchDir",
eSpawnActorCollisionHandlingMethod: "/Script/Engine.ESpawnActorCollisionHandlingMethod",
eTraceTypeQuery: "/Script/Engine.ETraceTypeQuery",
event: "/Script/BlueprintGraph.K2Node_Event",
executionSequence: "/Script/BlueprintGraph.K2Node_ExecutionSequence",
@@ -128,10 +129,13 @@ export default class Configuration {
makeArray: "/Script/BlueprintGraph.K2Node_MakeArray",
makeMap: "/Script/BlueprintGraph.K2Node_MakeMap",
makeSet: "/Script/BlueprintGraph.K2Node_MakeSet",
materialExpressionConstant: "/Script/Engine.MaterialExpressionConstant",
materialExpressionConstant2Vector: "/Script/Engine.MaterialExpressionConstant2Vector",
materialExpressionConstant3Vector: "/Script/Engine.MaterialExpressionConstant3Vector",
materialExpressionConstant4Vector: "/Script/Engine.MaterialExpressionConstant4Vector",
materialExpressionTextureCoordinate: "/Script/Engine.MaterialExpressionTextureCoordinate",
materialGraphNodeComment: "/Script/UnrealEd.MaterialGraphNode_Comment",
materialGraphNode: "/Script/UnrealEd.MaterialGraphNode",
materialGraphNodeComment: "/Script/UnrealEd.MaterialGraphNode_Comment",
multiGate: "/Script/BlueprintGraph.K2Node_MultiGate",
pawn: "/Script/Engine.Pawn",
promotableOperator: "/Script/BlueprintGraph.K2Node_PromotableOperator",
@@ -222,6 +226,13 @@ export default class Configuration {
static windowCancelButtonText = "Cancel"
static windowCloseEventName = "ueb-window-close"
static CommonEnums = {
[this.paths.eSpawnActorCollisionHandlingMethod]: [
["Undefined", "Default"],
["AlwaysSpawn", "Always Spawn, Ignore Collisions"],
["AdjustIfPossibleButAlwaysSpawn", "Try To Adjust Location, But Always Spawn"],
["AdjustIfPossibleButDontSpawnIfColliding", "Try To Adjust Location, Don't Spawn If Still Colliding"],
["DontSpawnIfColliding", "Do Not Spawn"],
],
[this.paths.eSearchCase]: ["CaseSensitive", "IgnoreCase"],
[this.paths.eSearchDir]: ["FromStart", "FromEnd"],
[this.paths.eDrawDebugTrace]: ["None", "ForOneFrame", "ForDuration", "Persistent"],

View File

@@ -98,6 +98,37 @@ export default class Utility {
return Math.round(num * power) / power
}
/** @param {Number} num */
static printNumber(num) {
if (num == Number.POSITIVE_INFINITY) {
return "inf"
} else if (num == Number.NEGATIVE_INFINITY) {
return "-inf"
}
return Utility.minDecimals(num)
}
/** @param {Number} num */
static printExponential(num) {
if (num == Number.POSITIVE_INFINITY) {
return "inf"
} else if (num == Number.NEGATIVE_INFINITY) {
return "-inf"
}
const int = Math.round(num)
if (int >= 1000) {
const exp = Math.floor(Math.log10(int))
const dec = Math.round(num / 10 ** (exp - 2)) / 100
// Not using num.toExponential() because of the omitted leading 0 on the exponential
return `${dec}e+${exp < 10 ? "0" : ""}${exp}`
}
const intPart = Math.floor(num)
if (intPart == 0) {
return num.toString()
}
return this.roundDecimals(num, Math.max(0, 3 - Math.floor(num).toString().length)).toString()
}
/**
* @param {Number} a
* @param {Number} b

View File

@@ -2,6 +2,7 @@ import IElement from "./IElement.js"
import InputTemplate from "../template/pin/InputTemplate.js"
import Utility from "../Utility.js"
/** @extends {IElement<Object, InputTemplate>} */
export default class InputElement extends IElement {
static properties = {

View File

@@ -1,7 +1,6 @@
import IEntity from "./IEntity.js"
import Utility from "../Utility.js"
export default class RealUnitEntity extends IEntity {
export default class ColorChannelEntity extends IEntity {
static attributes = {
value: {
@@ -15,7 +14,7 @@ export default class RealUnitEntity extends IEntity {
constructor(values = 0) {
super(values)
this.value = Utility.clamp(this.value, 0, 1)
/** @type {Number} */ this.value
}
valueOf() {

View File

@@ -1,42 +1,42 @@
import ColorChannelEntity from "./ColorChannelEntity.js"
import IEntity from "./IEntity.js"
import RealUnitEntity from "./UnitRealEntity.js"
import Utility from "../Utility.js"
export default class LinearColorEntity extends IEntity {
static attributes = {
R: {
type: RealUnitEntity,
default: () => new RealUnitEntity(),
type: ColorChannelEntity,
default: () => new ColorChannelEntity(),
expected: true,
},
G: {
type: RealUnitEntity,
default: () => new RealUnitEntity(),
type: ColorChannelEntity,
default: () => new ColorChannelEntity(),
expected: true,
},
B: {
type: RealUnitEntity,
default: () => new RealUnitEntity(),
type: ColorChannelEntity,
default: () => new ColorChannelEntity(),
expected: true,
},
A: {
type: RealUnitEntity,
default: () => new RealUnitEntity(1),
type: ColorChannelEntity,
default: () => new ColorChannelEntity(1),
},
H: {
type: RealUnitEntity,
default: () => new RealUnitEntity(),
type: ColorChannelEntity,
default: () => new ColorChannelEntity(),
ignored: true,
},
S: {
type: RealUnitEntity,
default: () => new RealUnitEntity(),
type: ColorChannelEntity,
default: () => new ColorChannelEntity(),
ignored: true,
},
V: {
type: RealUnitEntity,
default: () => new RealUnitEntity(),
type: ColorChannelEntity,
default: () => new ColorChannelEntity(),
ignored: true,
},
}
@@ -89,13 +89,13 @@ export default class LinearColorEntity extends IEntity {
}
}
super(values)
/** @type {RealUnitEntity} */ this.R
/** @type {RealUnitEntity} */ this.G
/** @type {RealUnitEntity} */ this.B
/** @type {RealUnitEntity} */ this.A
/** @type {RealUnitEntity} */ this.H
/** @type {RealUnitEntity} */ this.S
/** @type {RealUnitEntity} */ this.V
/** @type {ColorChannelEntity} */ this.R
/** @type {ColorChannelEntity} */ this.G
/** @type {ColorChannelEntity} */ this.B
/** @type {ColorChannelEntity} */ this.A
/** @type {ColorChannelEntity} */ this.H
/** @type {ColorChannelEntity} */ this.S
/** @type {ColorChannelEntity} */ this.V
this.#updateHSV()
}

View File

@@ -16,6 +16,8 @@ import UnknownPinEntity from "./UnknownPinEntity.js"
import Utility from "../Utility.js"
import VariableReferenceEntity from "./VariableReferenceEntity.js"
/** @typedef {import("./VectorEntity.js").default} VectorEntity */
export default class ObjectEntity extends IEntity {
static attributes = {
@@ -122,6 +124,9 @@ export default class ObjectEntity extends IEntity {
MaterialExpression: {
type: ObjectReferenceEntity,
},
MaterialExpressionComment: {
type: ObjectReferenceEntity,
},
MoveMode: {
type: SymbolEntity,
},
@@ -514,6 +519,7 @@ export default class ObjectEntity extends IEntity {
/** @returns {String} */
nodeDisplayName() {
let input
switch (this.getType()) {
case Configuration.paths.componentBoundEvent:
return `${Utility.formatStringName(this.DelegatePropertyName)} (${this.ComponentPropertyName})`
@@ -542,6 +548,32 @@ export default class ObjectEntity extends IEntity {
return "Construction Script"
case Configuration.paths.ifThenElse:
return "Branch"
case Configuration.paths.materialExpressionConstant:
input ??= [this.getCustomproperties().find(pinEntity => pinEntity.PinName == "Value")?.DefaultValue]
case Configuration.paths.materialExpressionConstant2Vector:
input ??= [
this.getCustomproperties().find(pinEntity => pinEntity.PinName == "X")?.DefaultValue,
this.getCustomproperties().find(pinEntity => pinEntity.PinName == "Y")?.DefaultValue,
]
case Configuration.paths.materialExpressionConstant3Vector:
if (!input) {
/** @type {VectorEntity} */
const vector = this.getCustomproperties()
.find(pinEntity => pinEntity.PinName == "Constant")
?.DefaultValue
input = [vector.X, vector.Y, vector.Z]
}
case Configuration.paths.materialExpressionConstant4Vector:
if (!input) {
/** @type {LinearColorEntity} */
const vector = this.getCustomproperties()
.find(pinEntity => pinEntity.PinName == "Constant")
?.DefaultValue
input = [vector.R, vector.G, vector.B, vector.A].map(v => v.valueOf())
}
if (input.length > 0) {
return input.map(v => Utility.printExponential(v)).reduce((acc, cur) => acc + "," + cur)
}
case Configuration.paths.spawnActorFromClass:
return `SpawnActor ${Utility.formatStringName(
this.getCustomproperties().find(pinEntity => pinEntity.getType() == "class")?.DefaultObject?.getName()
@@ -563,6 +595,9 @@ export default class ObjectEntity extends IEntity {
}
return `Switch on ${switchTarget}`
}
if (this.isComment()) {
return this.NodeComment
}
const keyNameSymbol = this.getHIDAttribute()
if (keyNameSymbol) {
const keyName = keyNameSymbol.toString()
@@ -654,6 +689,8 @@ export default class ObjectEntity extends IEntity {
nodeColor() {
switch (this.getType()) {
case Configuration.paths.materialExpressionConstant2Vector:
case Configuration.paths.materialExpressionConstant3Vector:
case Configuration.paths.materialExpressionConstant4Vector:
return Configuration.nodeColors.yellow
case Configuration.paths.materialExpressionTextureCoordinate:
return Configuration.nodeColors.red

View File

@@ -156,8 +156,14 @@ export default class PinEntity extends IEntity {
if (category === "struct" || category === "object") {
return this.PinType.PinSubCategoryObject.path
}
if (category === "optional" && this.PinType.PinSubCategory === "red") {
return "real"
if (category === "optional") {
if (this.PinType.PinSubCategory === "red") {
return "real"
} else if (this.PinType.PinSubCategory === "rgb") {
return Configuration.paths.vector
} else if (this.PinType.PinSubCategory === "rgba") {
return Configuration.paths.linearColor
}
}
if (this.isEnum()) {
return "enum"

View File

@@ -1,4 +1,5 @@
import ByteEntity from "../entity/ByteEntity.js"
import ColorChannelEntity from "../entity/ColorChannelEntity.js"
import Configuration from "../Configuration.js"
import EnumDisplayValueEntity from "../entity/EnumDisplayValueEntity.js"
import EnumEntity from "../entity/EnumEntity.js"
@@ -22,7 +23,6 @@ import Parsimmon from "parsimmon"
import PathSymbolEntity from "../entity/PathSymbolEntity.js"
import PinEntity from "../entity/PinEntity.js"
import PinReferenceEntity from "../entity/PinReferenceEntity.js"
import RealUnitEntity from "../entity/UnitRealEntity.js"
import RotatorEntity from "../entity/RotatorEntity.js"
import SimpleSerializationRotatorEntity from "../entity/SimpleSerializationRotatorEntity.js"
import SimpleSerializationVector2DEntity from "../entity/SimpleSerializationVector2DEntity.js"
@@ -83,7 +83,16 @@ export default class Grammar {
static true = P.lazy(() => P.regex(/true/i).map(() => true))
static false = P.lazy(() => P.regex(/false/i).map(() => false))
static boolean = P.lazy(() => Grammar.regexMap(/(true)|false/i, v => v[1] ? true : false))
static number = P.lazy(() => P.regex(Grammar.Regex.Number).map(Number))
static number = P.lazy(() =>
this.regexMap(new RegExp(`(${Grammar.Regex.Number.source})|(\\+?inf)|(-inf)`), result => {
if (result[2] !== undefined) {
return Number.POSITIVE_INFINITY
} else if (result[3] !== undefined) {
return Number.NEGATIVE_INFINITY
}
return Number(result[1])
})
)
static integer = P.lazy(() => P.regex(Grammar.Regex.Integer).map(Number))
static bigInt = P.lazy(() => P.regex(Grammar.Regex.Integer).map(BigInt))
static realUnit = P.lazy(() => P.regex(Grammar.Regex.RealUnit).map(Number))
@@ -189,6 +198,9 @@ export default class Grammar {
case ByteEntity:
result = this.byteEntity
break
case ColorChannelEntity:
result = this.colorChannelEntity
break
case EnumDisplayValueEntity:
result = this.enumDisplayValueEntity
break
@@ -246,9 +258,6 @@ export default class Grammar {
case TerminalTypeEntity:
result = this.pinTypeEntity
break
case RealUnitEntity:
result = this.realUnitEntity
break
case RotatorEntity:
result = this.rotatorEntity
break
@@ -384,6 +393,8 @@ export default class Grammar {
static byteEntity = P.lazy(() => this.byteNumber.map(v => new ByteEntity(v)))
static colorChannelEntity = P.lazy(() => this.number.map(value => new ColorChannelEntity(value)))
static enumDisplayValueEntity = P.lazy(() =>
P.regex(this.Regex.InsideString).map(v => new EnumDisplayValueEntity(v))
)
@@ -505,8 +516,6 @@ export default class Grammar {
static pinTypeEntity = P.lazy(() => this.createEntityGrammar(TerminalTypeEntity))
static realUnitEntity = P.lazy(() => this.realUnit.map(value => new RealUnitEntity(value)))
static rotatorEntity = P.lazy(() => this.createEntityGrammar(RotatorEntity, false))
static simpleSerializationRotatorEntity = P.lazy(() =>

View File

@@ -1,4 +1,5 @@
import ByteEntity from "../entity/ByteEntity.js"
import ColorChannelEntity from "../entity/ColorChannelEntity.js"
import CustomSerializer from "./CustomSerializer.js"
import EnumDisplayValueEntity from "../entity/EnumDisplayValueEntity.js"
import EnumEntity from "../entity/EnumEntity.js"
@@ -20,7 +21,6 @@ import ObjectSerializer from "./ObjectSerializer.js"
import PathSymbolEntity from "../entity/PathSymbolEntity.js"
import PinEntity from "../entity/PinEntity.js"
import PinReferenceEntity from "../entity/PinReferenceEntity.js"
import RealUnitEntity from "../entity/UnitRealEntity.js"
import RotatorEntity from "../entity/RotatorEntity.js"
import Serializer from "./Serializer.js"
import SerializerFactory from "./SerializerFactory.js"
@@ -88,6 +88,11 @@ export default function initializeSerializerFactory() {
new ToStringSerializer(ByteEntity)
)
SerializerFactory.registerSerializer(
ColorChannelEntity,
new ToStringSerializer(ColorChannelEntity)
)
SerializerFactory.registerSerializer(
EnumDisplayValueEntity,
new ToStringSerializer(EnumDisplayValueEntity)
@@ -212,11 +217,6 @@ export default function initializeSerializerFactory() {
new Serializer(TerminalTypeEntity, Serializer.bracketsWrapped)
)
SerializerFactory.registerSerializer(
RealUnitEntity,
new ToStringSerializer(RealUnitEntity)
)
SerializerFactory.registerSerializer(
RotatorEntity,
new Serializer(RotatorEntity, Serializer.bracketsWrapped)

View File

@@ -16,7 +16,7 @@ export default class RealPinTemplate extends INumericPinTemplate {
return html`
<div class="ueb-pin-input-wrapper ueb-pin-input">
<ueb-input .singleLine="${true}"
.innerText="${Utility.minDecimals(this.element.getDefaultValue() ?? 0)}">
.innerText="${Utility.printNumber(this.element.getDefaultValue() ?? 0)}">
</ueb-input>
</div>
`

View File

@@ -9,15 +9,15 @@ import Utility from "../../Utility.js"
export default class RotatorPinTemplate extends INumericPinTemplate {
#getR() {
return Utility.minDecimals(this.element.getDefaultValue()?.R ?? 0)
return Utility.printNumber(this.element.getDefaultValue()?.R ?? 0)
}
#getP() {
return Utility.minDecimals(this.element.getDefaultValue()?.P ?? 0)
return Utility.printNumber(this.element.getDefaultValue()?.P ?? 0)
}
#getY() {
return Utility.minDecimals(this.element.getDefaultValue()?.Y ?? 0)
return Utility.printNumber(this.element.getDefaultValue()?.Y ?? 0)
}
setDefaultValue(values = [], rawValues = values) {

View File

@@ -9,11 +9,11 @@ import Vector2DEntity from "../../entity/Vector2DEntity.js"
export default class VectorInputPinTemplate extends INumericPinTemplate {
#getX() {
return Utility.minDecimals(this.element.getDefaultValue()?.X ?? 0)
return Utility.printNumber(this.element.getDefaultValue()?.X ?? 0)
}
#getY() {
return Utility.minDecimals(this.element.getDefaultValue()?.Y ?? 0)
return Utility.printNumber(this.element.getDefaultValue()?.Y ?? 0)
}
/**

View File

@@ -9,15 +9,15 @@ import VectorEntity from "../../entity/VectorEntity.js"
export default class VectorPinTemplate extends INumericPinTemplate {
#getX() {
return Utility.minDecimals(this.element.getDefaultValue()?.X ?? 0)
return Utility.printNumber(this.element.getDefaultValue()?.X ?? 0)
}
#getY() {
return Utility.minDecimals(this.element.getDefaultValue()?.Y ?? 0)
return Utility.printNumber(this.element.getDefaultValue()?.Y ?? 0)
}
#getZ() {
return Utility.minDecimals(this.element.getDefaultValue()?.Z ?? 0)
return Utility.printNumber(this.element.getDefaultValue()?.Z ?? 0)
}
/**

View File

@@ -249,7 +249,7 @@ export default class ColorPickerWindowTemplate extends WindowTemplate {
<div>
<div class="ueb-horizontal-slider">
<span class="ueb-horizontal-slider-text"
.innerText="${Utility.minDecimals(Utility.roundDecimals(channelValue, 3))}">
.innerText="${Utility.printNumber(Utility.roundDecimals(channelValue, 3))}">
</span>
<ueb-ui-slider></ueb-ui-slider>
</div>