fn apply_occluder(occluder: &Box2D<f32>, rects: &mut SmallVec<[Box2D<f32>; 16]>) {
    // Iterate in reverse order so that we can push new rects at the back without
    // visiting them;
    let mut i = rects.len() - 1;
    loop {
        let r = rects[i];

        if r.intersects(occluder) {
            let top = r.min.y < occluder.min.y && r.max.y > occluder.min.y;
            let bottom = r.max.y > occluder.max.y && r.min.y < occluder.max.y;
            let left = r.min.x < occluder.min.x && r.max.x > occluder.min.x;
            let right = r.max.x > occluder.max.x && r.min.x < occluder.max.x;

            if top {
                rects.push(Box2D {
                    min: r.min,
                    max: point2(r.max.x, occluder.min.y),
                });
            }

            if bottom {
                rects.push(Box2D {
                    min: point2(r.min.x, occluder.max.y),
                    max: r.max,
                });
            }

            if left {
                let min_y = r.min.y.max(occluder.min.y);
                let max_y = r.max.y.min(occluder.max.y);
                rects.push(Box2D {
                    min: point2(r.min.x, min_y),
                    max: point2(occluder.min.x, max_y),
                });
            }

            if right {
                let min_y = r.min.y.max(occluder.min.y);
                let max_y = r.max.y.min(occluder.max.y);
                rects.push(Box2D {
                    min: point2(occluder.max.x, min_y),
                    max: point2(r.max.x, max_y),
                });
            }

            // Remove the original rectangle, replacing it with
            // one of the new ones we just added, or popping it
            // if it is the last item.
            if i == rects.len() {
                rects.pop();
            } else {
                rects.swap_remove(i);
            }
        }

        if i == 0 {
            break;
        }

        i -= 1;
    }
}
// Split out the parts of the rects in the provided vector
Split out the parts of the rects in the provided vector
Split out the parts of the rects in the provided vector
fn apply_occluder(occluder: &Box2D<f32>, rects: &mut SmallVec<[Box2D<f32>; 16]>) {
    // Iterate in reverse order so that we can push new rects at the back without
    // visiting them;
    let mut i = rects.len() - 1;
    loop {
        let r = rects[i];
        if r.intersects(occluder) {
            let top = r.min.y < occluder.min.y && r.max.y > occluder.min.y;
            let bottom = r.max.y > occluder.max.y && r.min.y < occluder.max.y;
            let left = r.min.x < occluder.min.x && r.max.x > occluder.min.x;
            let right = r.max.x > occluder.max.x && r.min.x < occluder.max.x;
            if top {
                rects.push(Box2D {
                    min: r.min,
                    max: point2(r.max.x, occluder.min.y),
                });
            }
            if bottom {
                rects.push(Box2D {
                    min: point2(r.min.x, occluder.max.y),
                    max: r.max,
                });
            }
            if left {
                let min_y = r.min.y.max(occluder.min.y);
                let max_y = r.max.y.min(occluder.max.y);
                rects.push(Box2D {
                    min: point2(r.min.x, min_y),
                    max: point2(occluder.min.x, max_y),
                });
            }
            if right {
                let min_y = r.min.y.max(occluder.min.y);
                let max_y = r.max.y.min(occluder.max.y);
                rects.push(Box2D {
                    min: point2(occluder.max.x, min_y),
                    max: point2(r.max.x, max_y),
                });
            }
            // Remove the original rectangle, replacing it with
            // one of the new ones we just added, or popping it
            // if it is the last item.
            if i == rects.len() {
                rects.pop();
            } else {
                rects.swap_remove(i);
            }
        }
        if i == 0 {
            break;
        }
        i -= 1;
    }
}
fn apply_occluder ( occluder : & Box2D < f32 > , rects : & mut SmallVec < [ Box2D < f32 > ; 16 ] > ) { // Iterate in reverse order so that we can push new rects at the back without // visiting them; let mut i = rects . len ( ) - 1 ; loop { let r = rects [ i ] ; if r . intersects ( occluder ) { let top = r . min . y < occluder . min . y && r . max . y > occluder . min . y ; let bottom = r . max . y > occluder . max . y && r . min . y < occluder . max . y ; let left = r . min . x < occluder . min . x && r . max . x > occluder . min . x ; let right = r . max . x > occluder . max . x && r . min . x < occluder . max . x ; if top { rects . push ( Box2D { min : r . min , max : point2 ( r . max . x , occluder . min . y ) , } ) ; } if bottom { rects . push ( Box2D { min : point2 ( r . min . x , occluder . max . y ) , max : r . max , } ) ; } if left { let min_y = r . min . y . max ( occluder . min . y ) ; let max_y = r . max . y . min ( occluder . max . y ) ; rects . push ( Box2D { min : point2 ( r . min . x , min_y ) , max : point2 ( occluder . min . x , max_y ) , } ) ; } if right { let min_y = r . min . y . max ( occluder . min . y ) ; let max_y = r . max . y . min ( occluder . max . y ) ; rects . push ( Box2D { min : point2 ( occluder . max . x , min_y ) , max : point2 ( r . max . x , max_y ) , } ) ; } // Remove the original rectangle, replacing it with // one of the new ones we just added, or popping it // if it is the last item. if i == rects . len ( ) { rects . pop ( ) ; } else { rects . swap_remove ( i ) ; } } if i == 0 { break ; } i -= 1 ; } }
Split out the parts of the rects in the provided vector
Split out the parts of the rects in the provided vector
occluder
&Box2D<f32>
rects
&mut SmallVec<[Box2D<f32>; 16]>