|
@@ -32,6 +32,44 @@ export enum NodeMaterialConnectionPointDirection {
|
|
|
* Defines a connection point for a block
|
|
|
*/
|
|
|
export class NodeMaterialConnectionPoint {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Checks if two types are equivalent
|
|
|
+ * @param type1 type 1 to check
|
|
|
+ * @param type2 type 2 to check
|
|
|
+ * @returns true if both types are equivalent, else false
|
|
|
+ */
|
|
|
+ public static AreEquivalentTypes(type1: number, type2: number): boolean {
|
|
|
+ switch (type1) {
|
|
|
+ case NodeMaterialBlockConnectionPointTypes.Vector3: {
|
|
|
+ if (type2 === NodeMaterialBlockConnectionPointTypes.Color3) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case NodeMaterialBlockConnectionPointTypes.Vector4: {
|
|
|
+ if (type2 === NodeMaterialBlockConnectionPointTypes.Color4) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case NodeMaterialBlockConnectionPointTypes.Color3: {
|
|
|
+ if (type2 === NodeMaterialBlockConnectionPointTypes.Vector3) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case NodeMaterialBlockConnectionPointTypes.Color4: {
|
|
|
+ if (type2 === NodeMaterialBlockConnectionPointTypes.Vector4) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
/** @hidden */
|
|
|
public _ownerBlock: NodeMaterialBlock;
|
|
|
/** @hidden */
|
|
@@ -47,6 +85,9 @@ export class NodeMaterialConnectionPoint {
|
|
|
/** @hidden */
|
|
|
public _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint> = null;
|
|
|
|
|
|
+ /** @hidden */
|
|
|
+ public _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint> = null;
|
|
|
+
|
|
|
private _type = NodeMaterialBlockConnectionPointTypes.Float;
|
|
|
|
|
|
/** @hidden */
|
|
@@ -367,35 +408,14 @@ export class NodeMaterialConnectionPoint {
|
|
|
|
|
|
if (this.type !== connectionPoint.type && connectionPoint.innerType !== NodeMaterialBlockConnectionPointTypes.AutoDetect) {
|
|
|
// Equivalents
|
|
|
- switch (this.type) {
|
|
|
- case NodeMaterialBlockConnectionPointTypes.Vector3: {
|
|
|
- if (connectionPoint.type === NodeMaterialBlockConnectionPointTypes.Color3) {
|
|
|
- return NodeMaterialConnectionPointCompatibilityStates.Compatible;
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- case NodeMaterialBlockConnectionPointTypes.Vector4: {
|
|
|
- if (connectionPoint.type === NodeMaterialBlockConnectionPointTypes.Color4) {
|
|
|
- return NodeMaterialConnectionPointCompatibilityStates.Compatible;
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- case NodeMaterialBlockConnectionPointTypes.Color3: {
|
|
|
- if (connectionPoint.type === NodeMaterialBlockConnectionPointTypes.Vector3) {
|
|
|
- return NodeMaterialConnectionPointCompatibilityStates.Compatible;
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- case NodeMaterialBlockConnectionPointTypes.Color4: {
|
|
|
- if (connectionPoint.type === NodeMaterialBlockConnectionPointTypes.Vector4) {
|
|
|
- return NodeMaterialConnectionPointCompatibilityStates.Compatible;
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
+ if (NodeMaterialConnectionPoint.AreEquivalentTypes(this.type, connectionPoint.type)) {
|
|
|
+ return NodeMaterialConnectionPointCompatibilityStates.Compatible;
|
|
|
}
|
|
|
|
|
|
// Accepted types
|
|
|
- if (connectionPoint.acceptedConnectionPointTypes && connectionPoint.acceptedConnectionPointTypes.indexOf(this.type) !== -1) {
|
|
|
+ if (connectionPoint.acceptedConnectionPointTypes && connectionPoint.acceptedConnectionPointTypes.indexOf(this.type) !== -1 ||
|
|
|
+ connectionPoint._acceptedConnectionPointType && NodeMaterialConnectionPoint.AreEquivalentTypes(connectionPoint._acceptedConnectionPointType.type, this.type))
|
|
|
+ {
|
|
|
return NodeMaterialConnectionPointCompatibilityStates.Compatible;
|
|
|
} else {
|
|
|
return NodeMaterialConnectionPointCompatibilityStates.TypeIncompatible;
|