Skip to content

Commit

Permalink
Make more things pub in the renderer (bevyengine#12053)
Browse files Browse the repository at this point in the history
# Objective

- Some properties of public types are private but sometimes it's useful
to be able to set those

## Solution

- Make more stuff pub

---

## Changelog

- `MaterialBindGroupId` internal id is now pub and added a new()
constructor
- `ExtractedPointLight` and `ExtractedDirectionalLight` properties are
now all pub

---------

Co-authored-by: James Liu <[email protected]>
  • Loading branch information
2 people authored and msvbg committed Feb 26, 2024
1 parent cba2592 commit b34ca1e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 20 deletions.
14 changes: 13 additions & 1 deletion crates/bevy_pbr/src/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,19 @@ pub struct PreparedMaterial<T: Material> {
}

#[derive(Component, Clone, Copy, Default, PartialEq, Eq, Deref, DerefMut)]
pub struct MaterialBindGroupId(Option<BindGroupId>);
pub struct MaterialBindGroupId(pub Option<BindGroupId>);

impl MaterialBindGroupId {
pub fn new(id: BindGroupId) -> Self {
Self(Some(id))
}
}

impl From<BindGroup> for MaterialBindGroupId {
fn from(value: BindGroup) -> Self {
Self::new(value.id())
}
}

/// An atomic version of [`MaterialBindGroupId`] that can be read from and written to
/// safely from multiple threads.
Expand Down
38 changes: 19 additions & 19 deletions crates/bevy_pbr/src/render/light.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,30 @@ use crate::*;

#[derive(Component)]
pub struct ExtractedPointLight {
color: Color,
pub color: Color,
/// luminous intensity in lumens per steradian
intensity: f32,
range: f32,
radius: f32,
transform: GlobalTransform,
shadows_enabled: bool,
shadow_depth_bias: f32,
shadow_normal_bias: f32,
spot_light_angles: Option<(f32, f32)>,
pub intensity: f32,
pub range: f32,
pub radius: f32,
pub transform: GlobalTransform,
pub shadows_enabled: bool,
pub shadow_depth_bias: f32,
pub shadow_normal_bias: f32,
pub spot_light_angles: Option<(f32, f32)>,
}

#[derive(Component, Debug)]
pub struct ExtractedDirectionalLight {
color: Color,
illuminance: f32,
transform: GlobalTransform,
shadows_enabled: bool,
shadow_depth_bias: f32,
shadow_normal_bias: f32,
cascade_shadow_config: CascadeShadowConfig,
cascades: EntityHashMap<Vec<Cascade>>,
frusta: EntityHashMap<Vec<Frustum>>,
render_layers: RenderLayers,
pub color: Color,
pub illuminance: f32,
pub transform: GlobalTransform,
pub shadows_enabled: bool,
pub shadow_depth_bias: f32,
pub shadow_normal_bias: f32,
pub cascade_shadow_config: CascadeShadowConfig,
pub cascades: EntityHashMap<Vec<Cascade>>,
pub frusta: EntityHashMap<Vec<Frustum>>,
pub render_layers: RenderLayers,
}

#[derive(Copy, Clone, ShaderType, Default, Debug)]
Expand Down

0 comments on commit b34ca1e

Please sign in to comment.