(value)
| 38 | }; |
| 39 | } |
| 40 | bridge(value) { |
| 41 | const { dag, cfg } = this.strandsContext; |
| 42 | const orig = getNodeDataFromID(dag, this.id); |
| 43 | const baseType = orig?.baseType ?? BaseType.FLOAT; |
| 44 | |
| 45 | let newValueID; |
| 46 | if (value?.isStrandsNode) { |
| 47 | newValueID = value.id; |
| 48 | } else { |
| 49 | const newVal = primitiveConstructorNode( |
| 50 | this.strandsContext, |
| 51 | { baseType, dimension: this.dimension }, |
| 52 | value |
| 53 | ); |
| 54 | newValueID = newVal.id; |
| 55 | } |
| 56 | |
| 57 | // For varying variables, we need both assignment generation AND a way to reference by identifier |
| 58 | if (this._originalIdentifier) { |
| 59 | // Create a variable node for the target (the varying variable) |
| 60 | const { id: targetVarID } = variableNode( |
| 61 | this.strandsContext, |
| 62 | { baseType: this._originalBaseType, dimension: this._originalDimension }, |
| 63 | this._originalIdentifier |
| 64 | ); |
| 65 | |
| 66 | // Create assignment node for GLSL generation |
| 67 | const assignmentNode = createNodeData({ |
| 68 | nodeType: NodeType.ASSIGNMENT, |
| 69 | dependsOn: [targetVarID, newValueID], |
| 70 | phiBlocks: [] |
| 71 | }); |
| 72 | const assignmentID = getOrCreateNode(dag, assignmentNode); |
| 73 | recordInBasicBlock(cfg, cfg.currentBlock, assignmentID); |
| 74 | |
| 75 | // Simply update this node to be a variable node with the identifier |
| 76 | // This ensures it always generates the variable name in expressions |
| 77 | const variableNodeData = createNodeData({ |
| 78 | nodeType: NodeType.VARIABLE, |
| 79 | baseType: this._originalBaseType, |
| 80 | dimension: this._originalDimension, |
| 81 | identifier: this._originalIdentifier |
| 82 | }); |
| 83 | const variableID = getOrCreateNode(dag, variableNodeData); |
| 84 | |
| 85 | this.id = variableID; // Point to the variable node for expression generation |
| 86 | } else { |
| 87 | this.id = newValueID; // For non-varying variables, just update to new value |
| 88 | } |
| 89 | |
| 90 | return this; |
| 91 | } |
| 92 | bridgeSwizzle(swizzlePattern, value) { |
| 93 | const { dag, cfg } = this.strandsContext; |
| 94 | const orig = getNodeDataFromID(dag, this.id); |
nothing calls this directly
no test coverage detected