Skip to content

Commit

Permalink
Adds LightOccluder2d component
Browse files Browse the repository at this point in the history
  • Loading branch information
malbernaz committed Jul 29, 2024
1 parent ea834d7 commit 5cf2870
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use bevy::{
color::Color,
ecs::{bundle::Bundle, component::Component},
math::Vec2,
reflect::Reflect,
render::view::{InheritedVisibility, ViewVisibility, Visibility},
transform::components::{GlobalTransform, Transform},
Expand Down Expand Up @@ -87,3 +88,34 @@ impl Default for AmbientLight2d {
}
}
}

/// A light occluder component
#[derive(Component, Default, Clone, Reflect)]
pub struct LightOccluder2d {
/// The half size of the occluder axis aligned bounding box (AABB)
pub half_size: Vec2,
}

impl LightOccluder2d {
/// Returns a new light occluder instance from a given half_size
pub fn new(half_size: Vec2) -> Self {
Self { half_size }
}
}

/// A bundle of components for rendering a [`LightOccluder2d`] entity.
#[derive(Bundle, Default)]
pub struct LightOccluder2dBundle {
/// Specifies the rendering properties of the light occluder
pub light_occluder: LightOccluder2d,
/// The local transform of the light occluder, relative to its parent.
pub transform: Transform,
/// The absolute transform of the light occluder. This should generally not be written to directly.
pub global_transform: GlobalTransform,
/// User indication of whether an entity is visible.
pub visibility: Visibility,
/// Inherited visibility of an entity.
pub inherited_visibility: InheritedVisibility,
/// Algorithmically-computed indication of whether an entity is visible and should be extracted for rendering.
pub view_visibility: ViewVisibility,
}

0 comments on commit 5cf2870

Please sign in to comment.