@@ -183,10 +183,24 @@ public bool Intersects(IBound other)
183183 if ( Contains ( other . Min ) && Contains ( other . Max ) )
184184 return true ; // Full containment
185185
186- // General intersection logic (allowing for overlap)
187- return ! ( Max . x <= other . Min . x || Min . x >= other . Max . x ||
188- Max . y <= other . Min . y || Min . y >= other . Max . y ||
189- Max . z <= other . Min . z || Min . z >= other . Max . z ) ;
186+ // Determine which axis is "flat" (thickness zero)
187+ bool flatX = Min . x == Max . x && other . Min . x == other . Max . x ;
188+ bool flatY = Min . y == Max . y && other . Min . y == other . Max . y ;
189+ bool flatZ = Min . z == Max . z && other . Min . z == other . Max . z ;
190+
191+ if ( flatZ ) // Rectangle in XY
192+ return ! ( Max . x < other . Min . x || Min . x > other . Max . x ||
193+ Max . y < other . Min . y || Min . y > other . Max . y ) ;
194+ else if ( flatY ) // Rectangle in XZ
195+ return ! ( Max . x < other . Min . x || Min . x > other . Max . x ||
196+ Max . z < other . Min . z || Min . z > other . Max . z ) ;
197+ else if ( flatX ) // Rectangle in YZ
198+ return ! ( Max . y < other . Min . y || Min . y > other . Max . y ||
199+ Max . z < other . Min . z || Min . z > other . Max . z ) ;
200+ else // fallback to 3D volume logic
201+ return ! ( Max . x < other . Min . x || Min . x > other . Max . x ||
202+ Max . y < other . Min . y || Min . y > other . Max . y ||
203+ Max . z < other . Min . z || Min . z > other . Max . z ) ;
190204 }
191205 case BoundingSphere sphere :
192206 // Find the closest point on the area to the sphere's center
0 commit comments