Skip to content

Commit

Permalink
ComputedVisibility -> InheritedVisibility, ViewVisibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Indy2222 committed Jan 26, 2024
1 parent 248ed1a commit 5e2bba7
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 16 deletions.
10 changes: 8 additions & 2 deletions crates/controller/src/hud/interaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ where
's,
(
&'static GlobalTransform,
&'static ComputedVisibility,
&'static ViewVisibility,
&'static Node,
),
F,
Expand All @@ -34,6 +34,7 @@ impl<'w, 's, F> HudNodes<'w, 's, F>
where
F: ReadOnlyWorldQuery + Sync + Send + 'static,
{
/// See [`Self::relative_position`].
pub(crate) fn contains_point(&self, point: Vec2) -> bool {
self.relative_position(point).is_some()
}
Expand All @@ -43,11 +44,16 @@ where
///
/// The returned point is between (0, 0) (top-left corner) and (1, 1)
/// (bottom-right corner).
///
/// The method relies on [`ViewVisibility`], therefore the results are
/// accurate with respect to the last rendered frame only iff called before
/// [`bevy::render::view::VisibilitySystems::VisibilityPropagate`] (during
/// `PostUpdate` schedule).
pub(crate) fn relative_position(&self, point: Vec2) -> Option<Vec2> {
self.hud
.iter()
.filter_map(|(box_transform, visibility, node)| {
if !visibility.is_visible() {
if !visibility.get() {
return None;
}

Expand Down
4 changes: 2 additions & 2 deletions crates/signs/src/pole.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ fn spawn_poles(
.spawn((
transform,
GlobalTransform::from(transform),
Visibility::Visible,
ComputedVisibility::default(),
// TODO test this
VisibilityBundle::default(),
DespawnOnGameExit,
scene.clone(),
))
Expand Down
8 changes: 2 additions & 6 deletions crates/spawner/src/draft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ pub struct DraftBundle {
object_type: ObjectTypeComponent,
transform: Transform,
global_transform: GlobalTransform,
visibility: Visibility,
computed_visibility: ComputedVisibility,
visibility: VisibilityBundle,
draft: DraftAllowed,
ready: DraftReady,
}
Expand All @@ -65,10 +64,7 @@ impl DraftBundle {
object_type: ObjectType::Active(ActiveObjectType::Building(building_type)).into(),
transform,
global_transform: transform.into(),
visibility: Visibility::Inherited,
computed_visibility: ComputedVisibility::HIDDEN,
draft: DraftAllowed::default(),
ready: DraftReady::default(),
..default()
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions crates/spawner/src/spawner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,7 @@ fn spawn(mut commands: Commands, scenes: Res<Scenes>, mut events: EventReader<Sp
entity_commands.insert((
event.transform,
GlobalTransform::from(event.transform),
Visibility::Inherited,
ComputedVisibility::default(),
VisibilityBundle::default(),
ObjectTypeComponent::from(event.object_type),
scenes.get(SceneType::Solid(event.object_type)).clone(),
DespawnOnGameExit,
Expand Down
9 changes: 5 additions & 4 deletions crates/terrain/src/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,15 @@ impl Marker for RectangleMarker {
}
}

// TODO test this
fn update_markers<M>(
mut materials: ResMut<Assets<TerrainMaterial>>,
solids: SolidObjects,
camera: Query<(&Transform, &Frustum), With<Camera3d>>,
terrains: Query<(&ComputedVisibility, &Handle<TerrainMaterial>)>,
terrains: Query<(&ViewVisibility, &Handle<TerrainMaterial>)>,
markers: Query<(
&ObjectTypeComponent,
&ComputedVisibility,
&ViewVisibility,
&GlobalTransform,
&M,
&MarkerVisibility,
Expand All @@ -140,7 +141,7 @@ fn update_markers<M>(

let mut candidates = Vec::new();
for (&object_type, circle_visibility, transform, marker, marker_visibility) in markers.iter() {
if !circle_visibility.is_visible_in_hierarchy() {
if !circle_visibility.get() {
continue;
}

Expand Down Expand Up @@ -171,7 +172,7 @@ fn update_markers<M>(
.collect();

for (terrain_visibility, material) in terrains.iter() {
if !terrain_visibility.is_visible_in_hierarchy() {
if !terrain_visibility.get() {
continue;
}

Expand Down

0 comments on commit 5e2bba7

Please sign in to comment.