Repository: bevyengine/bevy
File: crates/bevy_sprite/src/picking_backend.rs (Rust)

Code before:
                        &texture_atlas_layout,
                    ) else {
                        return None;
                    };

                    // Since the pixel space coordinate is `Ok`, we know the cursor is in the bounds of
                    // the sprite.

                    let cursor_in_valid_pixels_of_sprite = 'valid_pixel: {
                        match settings.picking_mode {
                            SpritePickingMode::AlphaThreshold(cutoff) => {
                                let Some(image) = images.get(&sprite.image) else {
                                    // [`Sprite::from_color`] returns a defaulted handle.
                                    // This handle doesn't return a valid image, so returning false here would make picking "color sprites" impossible
                                    break 'valid_pixel true;
                                };
                                // grab pixel and check alpha
                                let color = match image.get_color_at(
                                    cursor_pixel_space.x as u32,
                                    cursor_pixel_space.y as u32,
                                ) {
                                    Ok(color) => color,
                                    Err(err) => {
                                        warn!(
                                            "Failed to get pixel color for sprite picking on entity {:?}: {:?}. \
                                            This is probably caused by the use of a compressed texture format. \
                                            Consider using `SpritePickingMode::BoundingBox`.",
                                            entity,
                                            err
                                        );
                                        break 'valid_pixel false;
                                    }
                                };
                                // Check the alpha is above the cutoff.
                                color.alpha() > cutoff
                            }
                            SpritePickingMode::BoundingBox => true,
                        }
                    };

                    blocked = cursor_in_valid_pixels_of_sprite && pickable.should_block_lower;

                    cursor_in_valid_pixels_of_sprite.then(|| {
                        let hit_pos_world =
                            sprite_transform.transform_point(cursor_pos_sprite.extend(0.0));
                        // Transform point from world to camera space to get the Z distance
                        let hit_pos_cam = cam_transform
                            .affine()
                            .inverse()
                            .transform_point3(hit_pos_world);
                        // HitData requires a depth as calculated from the camera's near clipping plane

Review comment (suggestion):
```suggestion
                                            This is often caused by the use of a compressed texture format. \
```

Code after:
                        &texture_atlas_layout,
                    ) else {
                        return None;
                    };

                    // Since the pixel space coordinate is `Ok`, we know the cursor is in the bounds of
                    // the sprite.

                    let cursor_in_valid_pixels_of_sprite = 'valid_pixel: {
                        match settings.picking_mode {
                            SpritePickingMode::AlphaThreshold(cutoff) => {
                                let Some(image) = images.get(&sprite.image) else {
                                    // [`Sprite::from_color`] returns a defaulted handle.
                                    // This handle doesn't return a valid image, so returning false here would make picking "color sprites" impossible
                                    break 'valid_pixel true;
                                };
                                // grab pixel and check alpha
                                let color = match image.get_color_at(
                                    cursor_pixel_space.x as u32,
                                    cursor_pixel_space.y as u32,
                                ) {
                                    Ok(color) => color,
                                    Err(TextureAccessError::UnsupportedTextureFormat(format)) => {
                                        warn!(
                                            "Failed to get pixel color for sprite picking on entity {:?}: unsupported texture format {:?}. \
                                            This is often caused by the use of a compressed texture format. \
                                            Consider using `SpritePickingMode::BoundingBox`.",
                                            entity,
                                            format
                                        );
                                        break 'valid_pixel false;
                                    }
                                    Err(_) => break 'valid_pixel false,
                                };
                                // Check the alpha is above the cutoff.
                                color.alpha() > cutoff
                            }
                            SpritePickingMode::BoundingBox => true,
                        }
                    };

                    blocked = cursor_in_valid_pixels_of_sprite && pickable.should_block_lower;

                    cursor_in_valid_pixels_of_sprite.then(|| {
                        let hit_pos_world =
                            sprite_transform.transform_point(cursor_pos_sprite.extend(0.0));
                        // Transform point from world to camera space to get the Z distance
                        let hit_pos_cam = cam_transform
                            .affine()
                            .inverse()
                            .transform_point3(hit_pos_world);