forked from bevyengine/bevy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into post-processing-example
- Loading branch information
Showing
159 changed files
with
5,384 additions
and
1,916 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Release | ||
|
||
# how to trigger: https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow | ||
on: | ||
workflow_dispatch: | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
|
||
jobs: | ||
ci: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Install cargo-release | ||
run: cargo install cargo-release | ||
|
||
- name: Setup release | ||
run: | | ||
git config user.name 'Bevy Auto Releaser' | ||
git config user.email 'bevy@users.noreply.github.com' | ||
# --workspace: updating all crates in the workspace | ||
# --no-publish: do not publish to crates.io | ||
# --execute: not a dry run | ||
# --no-tag: do not push tag for each new version | ||
# --no-push: do not push the update commits | ||
# --exclude: ignore those packages | ||
cargo release minor \ | ||
--workspace \ | ||
--no-publish \ | ||
--execute \ | ||
--no-tag \ | ||
--no-confirm \ | ||
--no-push \ | ||
--exclude ci \ | ||
--exclude errors \ | ||
--exclude bevy-ios-example | ||
- name: Create PR | ||
uses: peter-evans/create-pull-request@v3 | ||
with: | ||
delete-branch: true | ||
base: "main" | ||
title: "Preparing Next Release" | ||
body: | | ||
Preparing next release | ||
This PR has been auto-generated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use bevy_derive::{Deref, DerefMut}; | ||
use bevy_ecs::prelude::*; | ||
use bevy_reflect::{Reflect, ReflectDeserialize}; | ||
use bevy_render::{color::Color, extract_resource::ExtractResource}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Reflect, Serialize, Deserialize, Clone, Debug)] | ||
#[reflect_value(Serialize, Deserialize)] | ||
pub enum ClearColorConfig { | ||
Default, | ||
Custom(Color), | ||
None, | ||
} | ||
|
||
impl Default for ClearColorConfig { | ||
fn default() -> Self { | ||
ClearColorConfig::Default | ||
} | ||
} | ||
|
||
/// When used as a resource, sets the color that is used to clear the screen between frames. | ||
/// | ||
/// This color appears as the "background" color for simple apps, when | ||
/// there are portions of the screen with nothing rendered. | ||
#[derive(Component, Clone, Debug, Deref, DerefMut, ExtractResource)] | ||
pub struct ClearColor(pub Color); | ||
|
||
impl Default for ClearColor { | ||
fn default() -> Self { | ||
Self(Color::rgb(0.4, 0.4, 0.4)) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
use crate::clear_color::ClearColorConfig; | ||
use bevy_ecs::{prelude::*, query::QueryItem}; | ||
use bevy_reflect::Reflect; | ||
use bevy_render::{ | ||
camera::{ | ||
Camera, CameraProjection, CameraRenderGraph, DepthCalculation, OrthographicProjection, | ||
}, | ||
extract_component::ExtractComponent, | ||
primitives::Frustum, | ||
view::VisibleEntities, | ||
}; | ||
use bevy_transform::prelude::{GlobalTransform, Transform}; | ||
|
||
#[derive(Component, Default, Reflect, Clone)] | ||
#[reflect(Component)] | ||
pub struct Camera2d { | ||
pub clear_color: ClearColorConfig, | ||
} | ||
|
||
impl ExtractComponent for Camera2d { | ||
type Query = &'static Self; | ||
type Filter = With<Camera>; | ||
|
||
fn extract_component(item: QueryItem<Self::Query>) -> Self { | ||
item.clone() | ||
} | ||
} | ||
|
||
#[derive(Bundle)] | ||
pub struct Camera2dBundle { | ||
pub camera: Camera, | ||
pub camera_render_graph: CameraRenderGraph, | ||
pub projection: OrthographicProjection, | ||
pub visible_entities: VisibleEntities, | ||
pub frustum: Frustum, | ||
pub transform: Transform, | ||
pub global_transform: GlobalTransform, | ||
pub camera_2d: Camera2d, | ||
} | ||
|
||
impl Default for Camera2dBundle { | ||
fn default() -> Self { | ||
Self::new_with_far(1000.0) | ||
} | ||
} | ||
|
||
impl Camera2dBundle { | ||
/// Create an orthographic projection camera with a custom Z position. | ||
/// | ||
/// The camera is placed at `Z=far-0.1`, looking toward the world origin `(0,0,0)`. | ||
/// Its orthographic projection extends from `0.0` to `-far` in camera view space, | ||
/// corresponding to `Z=far-0.1` (closest to camera) to `Z=-0.1` (furthest away from | ||
/// camera) in world space. | ||
pub fn new_with_far(far: f32) -> Self { | ||
// we want 0 to be "closest" and +far to be "farthest" in 2d, so we offset | ||
// the camera's translation by far and use a right handed coordinate system | ||
let projection = OrthographicProjection { | ||
far, | ||
depth_calculation: DepthCalculation::ZDifference, | ||
..Default::default() | ||
}; | ||
let transform = Transform::from_xyz(0.0, 0.0, far - 0.1); | ||
let view_projection = | ||
projection.get_projection_matrix() * transform.compute_matrix().inverse(); | ||
let frustum = Frustum::from_view_projection( | ||
&view_projection, | ||
&transform.translation, | ||
&transform.back(), | ||
projection.far(), | ||
); | ||
Self { | ||
camera_render_graph: CameraRenderGraph::new(crate::core_2d::graph::NAME), | ||
projection, | ||
visible_entities: VisibleEntities::default(), | ||
frustum, | ||
transform, | ||
global_transform: Default::default(), | ||
camera: Camera::default(), | ||
camera_2d: Camera2d::default(), | ||
} | ||
} | ||
} |
Oops, something went wrong.