|
3773 | 3773 |
|
3774 | 3774 | /** |
3775 | 3775 | * returns the bounding of the object, used for rendering purposes |
3776 | | - * bounding is: [topleft_cornerx, topleft_cornery, width, height] |
3777 | 3776 | * @method getBounding |
3778 | | - * @return {Float32Array[4]} the total size |
| 3777 | + * @param out {Float32Array[4]?} [optional] a place to store the output, to free garbage |
| 3778 | + * @param compute_outer {boolean?} [optional] set to true to include the shadow and connection points in the bounding calculation |
| 3779 | + * @return {Float32Array[4]} the bounding box in format of [topleft_cornerx, topleft_cornery, width, height] |
3779 | 3780 | */ |
3780 | | - LGraphNode.prototype.getBounding = function(out) { |
| 3781 | + LGraphNode.prototype.getBounding = function(out, compute_outer) { |
3781 | 3782 | out = out || new Float32Array(4); |
3782 | | - out[0] = this.pos[0] - 4; |
3783 | | - out[1] = this.pos[1] - LiteGraph.NODE_TITLE_HEIGHT; |
3784 | | - out[2] = this.size[0] + 4; |
3785 | | - out[3] = this.flags.collapsed ? LiteGraph.NODE_TITLE_HEIGHT : this.size[1] + LiteGraph.NODE_TITLE_HEIGHT; |
| 3783 | + const nodePos = this.pos; |
| 3784 | + const nodeFlags = this.flags; |
| 3785 | + const nodeSize = this.size; |
| 3786 | + |
| 3787 | + // 4 offset for collapsed node connection points |
| 3788 | + const left_offset = compute_outer ? 4 : 0; |
| 3789 | + // 6 offset for right shadow and collapsed node connection points, 1 offset due to how nodes are rendered |
| 3790 | + const right_offset = compute_outer ? 6 + left_offset : 1 ; |
| 3791 | + // 4 offset for collapsed nodes top connection points |
| 3792 | + const top_offset = compute_outer ? 4 : 0; |
| 3793 | + // 5 offset for bottom shadow and collapsed node connection points |
| 3794 | + const bottom_offset = compute_outer ? 5 + top_offset : 0; |
| 3795 | + |
| 3796 | + |
| 3797 | + out[0] = nodePos[0] - left_offset; |
| 3798 | + out[1] = nodePos[1] - LiteGraph.NODE_TITLE_HEIGHT - top_offset; |
| 3799 | + out[2] = nodeFlags.collapsed ? |
| 3800 | + (this._collapsed_width || LiteGraph.NODE_COLLAPSED_WIDTH) + right_offset : |
| 3801 | + nodeSize[0] + right_offset; |
| 3802 | + out[3] = nodeFlags.collapsed ? |
| 3803 | + LiteGraph.NODE_TITLE_HEIGHT + bottom_offset : |
| 3804 | + nodeSize[1] + LiteGraph.NODE_TITLE_HEIGHT + bottom_offset; |
3786 | 3805 |
|
3787 | 3806 | if (this.onBounding) { |
3788 | 3807 | this.onBounding(out); |
@@ -7667,7 +7686,7 @@ LGraphNode.prototype.executeAction = function(action) |
7667 | 7686 | continue; |
7668 | 7687 | } |
7669 | 7688 |
|
7670 | | - if (!overlapBounding(this.visible_area, n.getBounding(temp))) { |
| 7689 | + if (!overlapBounding(this.visible_area, n.getBounding(temp, true))) { |
7671 | 7690 | continue; |
7672 | 7691 | } //out of the visible area |
7673 | 7692 |
|
|
0 commit comments