@@ -23,7 +23,6 @@ export const InpaintMaskBboxAdjuster = memo(() => {
23
23
const canvasSlice = useAppSelector ( selectCanvasSlice ) ;
24
24
const maskBlur = useAppSelector ( selectMaskBlur ) ;
25
25
26
- // Get all inpaint mask entities and bbox
27
26
const inpaintMasks = canvasSlice . inpaintMasks . entities ;
28
27
const bboxRect = canvasSlice . bbox . rect ;
29
28
@@ -33,11 +32,9 @@ export const InpaintMaskBboxAdjuster = memo(() => {
33
32
return null ;
34
33
}
35
34
36
- // Use the current bbox as the reference container
37
35
const canvasWidth = bboxRect . width ;
38
36
const canvasHeight = bboxRect . height ;
39
37
40
- // Collect all mask objects and adjust their positions relative to the bbox
41
38
const allObjects : (
42
39
| CanvasBrushLineState
43
40
| CanvasBrushLineWithPressureState
@@ -51,7 +48,6 @@ export const InpaintMaskBboxAdjuster = memo(() => {
51
48
continue ;
52
49
}
53
50
54
- // Adjust object positions relative to the bbox (not the entity position)
55
51
for ( const obj of mask . objects ) {
56
52
if ( obj . type === 'rect' ) {
57
53
const adjustedObj = {
@@ -81,7 +77,6 @@ export const InpaintMaskBboxAdjuster = memo(() => {
81
77
allObjects . push ( adjustedObj ) ;
82
78
} else if ( obj . type === 'image' ) {
83
79
// For image objects, we need to handle them differently since they don't have rect or points
84
- // We'll skip them for now as they're not commonly used in masks
85
80
continue ;
86
81
}
87
82
}
@@ -95,7 +90,6 @@ export const InpaintMaskBboxAdjuster = memo(() => {
95
90
const bitmap = maskObjectsToBitmap ( allObjects , canvasWidth , canvasHeight ) ;
96
91
const { width, height, data } = bitmap ;
97
92
98
- // Find the actual bounds of the rendered mask
99
93
let maskMinX = width ;
100
94
let maskMinY = height ;
101
95
let maskMaxX = 0 ;
@@ -106,7 +100,6 @@ export const InpaintMaskBboxAdjuster = memo(() => {
106
100
const pixelIndex = ( y * width + x ) * 4 ;
107
101
const alpha = data [ pixelIndex + 3 ] ?? 0 ;
108
102
109
- // If this pixel has any opacity, it's part of the mask
110
103
if ( alpha > 0 ) {
111
104
maskMinX = Math . min ( maskMinX , x ) ;
112
105
maskMinY = Math . min ( maskMinY , y ) ;
@@ -116,18 +109,15 @@ export const InpaintMaskBboxAdjuster = memo(() => {
116
109
}
117
110
}
118
111
119
- // If no mask pixels found, return null
120
112
if ( maskMinX >= maskMaxX || maskMinY >= maskMaxY ) {
121
113
return null ;
122
114
}
123
115
124
- // Clamp the mask bounds to the bbox boundaries
125
116
maskMinX = Math . max ( 0 , maskMinX ) ;
126
117
maskMinY = Math . max ( 0 , maskMinY ) ;
127
118
maskMaxX = Math . min ( width - 1 , maskMaxX ) ;
128
119
maskMaxY = Math . min ( height - 1 , maskMaxY ) ;
129
120
130
- // Convert back to world coordinates relative to the bbox
131
121
return {
132
122
x : bboxRect . x + maskMinX ,
133
123
y : bboxRect . y + maskMinY ,
@@ -155,7 +145,6 @@ export const InpaintMaskBboxAdjuster = memo(() => {
155
145
dispatch ( bboxChangedFromCanvas ( adjustedBbox ) ) ;
156
146
} , [ dispatch , maskBbox , maskBlur ] ) ;
157
147
158
- // Only show if there are enabled inpaint masks with objects
159
148
const hasValidMasks = inpaintMasks . some ( ( mask ) => mask . isEnabled && mask . objects . length > 0 ) ;
160
149
if ( ! hasValidMasks ) {
161
150
return null ;
0 commit comments