소스 검색

deleteing code

Pamela Wolf 4 년 전
부모
커밋
3f7aa825da
3개의 변경된 파일2개의 추가작업 그리고 202개의 파일을 삭제
  1. 1 170
      guiEditor/src/diagram/graphCanvas.tsx
  2. 1 31
      guiEditor/src/diagram/graphNode.ts
  3. 0 1
      guiEditor/src/graphEditor.tsx

+ 1 - 170
guiEditor/src/diagram/graphCanvas.tsx

@@ -351,8 +351,6 @@ export class GraphCanvasComponent extends React.Component<IGraphCanvasComponentP
         const link = new NodeLink(this, portA, nodeA, portB, nodeB);
         this._links.push(link);
 
-        nodeA.links.push(link);
-        nodeB.links.push(link);
     }
 
     removeLink(link: NodeLink) {
@@ -647,8 +645,7 @@ export class GraphCanvasComponent extends React.Component<IGraphCanvasComponentP
         this._oldY = -1; 
 
         if (this._candidateLink) {       
-            if (this._candidateLinkedHasMoved) {
-                this.processCandidatePort();          
+            if (this._candidateLinkedHasMoved) {       
                 this.props.globalState.onCandidateLinkMoved.notifyObservers(null);
             } else { // is a click event on NodePort
                 if(this._candidateLink.portA instanceof FrameNodePort) { //only on Frame Node Ports
@@ -758,172 +755,6 @@ export class GraphCanvasComponent extends React.Component<IGraphCanvasComponentP
         this.y = 0;
     }
 
-    processCandidatePort() {
-        let pointB = this._candidateLink!.portA.connectionPoint;
-        let nodeB = this._candidateLink!.portA.node;
-        let pointA: NodeMaterialConnectionPoint;
-        let nodeA: GraphNode;
-
-        if (this._candidatePort) {
-            pointA = this._candidatePort.connectionPoint;
-            nodeA = this._candidatePort.node;
-        } else {
-            if (pointB.direction === NodeMaterialConnectionPointDirection.Output) {
-                return;
-            }
-
-            // No destination so let's spin a new input block
-            let pointName = "output", inputBlock;
-            let customInputBlock = this._candidateLink!.portA.connectionPoint.createCustomInputBlock();
-            if (!customInputBlock) {
-                inputBlock = new InputBlock(NodeMaterialBlockConnectionPointTypes[this._candidateLink!.portA.connectionPoint.type], undefined, this._candidateLink!.portA.connectionPoint.type);
-            } else {
-                [inputBlock, pointName] = customInputBlock;
-            }
-            this.props.globalState.nodeMaterial.attachedBlocks.push(inputBlock);
-            pointA = (inputBlock as any)[pointName];
-            nodeA = this.appendBlock(inputBlock);
-            
-            nodeA.x = this._dropPointX - 200;
-            nodeA.y = this._dropPointY - 50;    
-        }
-
-        if (pointA.direction === NodeMaterialConnectionPointDirection.Input) {
-            let temp = pointB;
-            pointB = pointA;
-            pointA = temp;
-
-            let tempNode = nodeA;
-            nodeA = nodeB;
-            nodeB = tempNode;
-        }
-
-        if (pointB.connectedPoint === pointA) {
-            return;
-        }
-
-        if (pointB === pointA) {
-            return;
-        }
-
-        if (pointB.direction === pointA.direction) {
-            return;
-        }
-
-        if (pointB.ownerBlock === pointA.ownerBlock) {
-            return;
-        }
-
-        // Check compatibility
-        let isFragmentOutput = pointB.ownerBlock.getClassName() === "FragmentOutputBlock";
-        let compatibilityState = pointA.checkCompatibilityState(pointB);
-        if ((pointA.needDualDirectionValidation || pointB.needDualDirectionValidation) && compatibilityState === NodeMaterialConnectionPointCompatibilityStates.Compatible && !(pointA instanceof InputBlock)) {
-            compatibilityState = pointB.checkCompatibilityState(pointA);
-        }
-        if (compatibilityState === NodeMaterialConnectionPointCompatibilityStates.Compatible) {
-            if (isFragmentOutput) {
-                let fragmentBlock = pointB.ownerBlock as FragmentOutputBlock;
-
-                if (pointB.name === "rgb" && fragmentBlock.rgba.isConnected) {
-                    nodeB.getLinksForConnectionPoint(fragmentBlock.rgba)[0].dispose();
-                } else if (pointB.name === "rgba" && fragmentBlock.rgb.isConnected) {
-                    nodeB.getLinksForConnectionPoint(fragmentBlock.rgb)[0].dispose();
-                }                     
-            }
-        } else {
-            let message = "";
-
-            switch (compatibilityState) {
-                case NodeMaterialConnectionPointCompatibilityStates.TypeIncompatible:
-                    message = "Cannot connect two different connection types";
-                    break;
-                case NodeMaterialConnectionPointCompatibilityStates.TargetIncompatible:
-                    message = "Source block can only work in fragment shader whereas destination block is currently aimed for the vertex shader";
-                    break;
-            }
-
-            this.props.globalState.onErrorMessageDialogRequiredObservable.notifyObservers(message);             
-            return;
-        }
-
-        let linksToNotifyForDispose: Nullable<NodeLink[]> = null;
-
-        if (pointB.isConnected) {
-            let links = nodeB.getLinksForConnectionPoint(pointB);
-
-            linksToNotifyForDispose = links.slice();
-
-            links.forEach(link => {
-                link.dispose(false);
-            });
-        }
-
-        if (pointB.ownerBlock.inputsAreExclusive) { // Disconnect all inputs if block has exclusive inputs
-            pointB.ownerBlock.inputs.forEach(i => {
-                let links = nodeB.getLinksForConnectionPoint(i);
-
-                if (!linksToNotifyForDispose) {
-                    linksToNotifyForDispose = links.slice();
-                } else {
-                    linksToNotifyForDispose.push(...links.slice());
-                }
-
-                links.forEach(link => {
-                    link.dispose(false);
-                });
-            })
-        }
-
-        pointA.connectTo(pointB);
-        this.connectPorts(pointA, pointB);
-
-        if (pointB.innerType === NodeMaterialBlockConnectionPointTypes.AutoDetect) {
-            // need to potentially propagate the type of pointA to other ports of blocks connected to owner of pointB
-
-            const refreshNode = (node: GraphNode) => {
-                node.refresh();
-
-                const links = node.links;
-
-                // refresh first the nodes so that the right types are assigned to the auto-detect ports
-                links.forEach((link) => {
-                    const nodeA = link.nodeA, nodeB = link.nodeB;
-
-                    if (!visitedNodes.has(nodeA)) {
-                        visitedNodes.add(nodeA);
-                        refreshNode(nodeA);
-                    }
-
-                    if (nodeB && !visitedNodes.has(nodeB)) {
-                        visitedNodes.add(nodeB);
-                        refreshNode(nodeB);
-                    }
-                });
-
-                // then refresh the links to display the right color between ports
-                links.forEach((link) => {
-                    if (!visitedLinks.has(link)) {
-                        visitedLinks.add(link);
-                        link.update();
-                    }
-                });
-            };
-
-            const visitedNodes = new Set<GraphNode>([nodeA]);
-            const visitedLinks = new Set<NodeLink>([nodeB.links[nodeB.links.length - 1]]);
-
-            refreshNode(nodeB);
-        } else {
-            nodeB.refresh();
-        }
-
-        linksToNotifyForDispose?.forEach((link) => {
-            link.onDisposedObservable.notifyObservers(link);
-            link.onDisposedObservable.clear();
-        });
-
-        this.props.globalState.onRebuildRequiredObservable.notifyObservers();
-    }
 
     processEditorData(editorData: IEditorData) {
         const frames = this._frames.splice(0);

+ 1 - 31
guiEditor/src/diagram/graphNode.ts

@@ -23,8 +23,7 @@ export class GraphNode {
     private _content: HTMLDivElement;    
     private _comments: HTMLDivElement;
     private _inputPorts: NodePort[] = [];
-    private _outputPorts: NodePort[] = [];
-    private _links: NodeLink[] = [];    
+    private _outputPorts: NodePort[] = []; 
     private _x = 0;
     private _y = 0;
     private _gridAlignedX = 0;
@@ -55,12 +54,6 @@ export class GraphNode {
             this._visual.classList.remove("hidden");
             this._upateNodePortNames();
         }
-
-        for (var link of this._links) {
-            link.isVisible = value;
-        }
-
-        this._refreshLinks();
     }
 
     private _upateNodePortNames(){
@@ -79,9 +72,6 @@ export class GraphNode {
         return this._inputPorts;
     }
 
-    public get links() {
-        return this._links;
-    }
 
     public get gridAlignedX() {
         return this._gridAlignedX;
@@ -103,8 +93,6 @@ export class GraphNode {
         
         this._gridAlignedX = this._ownerCanvas.getGridPosition(value);
         this._visual.style.left = `${this._gridAlignedX}px`;
-
-        this._refreshLinks();
         this._refreshFrames();
     }
 
@@ -122,7 +110,6 @@ export class GraphNode {
         this._gridAlignedY = this._ownerCanvas.getGridPosition(value);
         this._visual.style.top = `${this._gridAlignedY}px`;
 
-        this._refreshLinks();
         this._refreshFrames();
     }
 
@@ -264,9 +251,6 @@ export class GraphNode {
         return null;
     }
 
-    public getLinksForConnectionPoint(point: NodeMaterialConnectionPoint) {
-        return this._links.filter(link => link.portA.connectionPoint === point || link.portB!.connectionPoint === point);
-    }
     
     private _refreshFrames() {       
         if (this._ownerCanvas._frameIsMoving || this._ownerCanvas._isLoading) {
@@ -279,15 +263,6 @@ export class GraphNode {
         }
     }
 
-    public _refreshLinks() {
-        if (this._ownerCanvas._isLoading) {
-            return;
-        }
-        for (var link of this._links) {
-            link.update();
-        }
-    }
-
     public refresh() {
         if (this._displayManager) {
             this._header.innerHTML = this._displayManager.getHeaderText(this.block);
@@ -507,11 +482,6 @@ export class GraphNode {
             port.dispose();
         }
 
-        let links = this._links.slice(0);
-        for (var link of links) {
-            link.dispose();           
-        }
-
         this.block.dispose();
     }
 }

+ 0 - 1
guiEditor/src/graphEditor.tsx

@@ -516,7 +516,6 @@ export class GraphEditor extends React.Component<IGraphEditorProps, IGraphEditor
 
             this._graphCanvas._isLoading = false;
             for (var node of this._graphCanvas.nodes) {
-                node._refreshLinks();
             }
             this.hideWaitScreen();
         });