Skip to content

Commit

Permalink
gudbye, fren
Browse files Browse the repository at this point in the history
  • Loading branch information
irate-devil committed Aug 30, 2022
1 parent c10625f commit b04a1b6
Show file tree
Hide file tree
Showing 23 changed files with 74 additions and 84 deletions.
4 changes: 2 additions & 2 deletions examples/2d/mesh2d_manual.rs
Expand Up @@ -3,7 +3,7 @@
//! It doesn't use the [`Material2d`] abstraction, but changes the vertex buffer to include vertex color.
//! Check out the "mesh2d" example for simpler / higher level 2d meshes.

use std::f32::consts::TAU;
use std::f32::consts::{ PI};

use bevy::{
core_pipeline::core_2d::Transparent2d,
Expand Down Expand Up @@ -65,7 +65,7 @@ fn star(
let mut v_pos = vec![[0.0, 0.0, 0.0]];
for i in 0..10 {
// The angle between each vertex is 1/10 of a full rotation.
let a = i as f32 * TAU / 10.0;
let a = i as f32 * PI / 5.0;
// The radius of inner vertices (even indices) is 100. For outer vertices (odd indices) it's 200.
let r = (1 - i % 2) as f32 * 100.0 + 100.0;
// Add the vertex position.
Expand Down
10 changes: 5 additions & 5 deletions examples/3d/lighting.rs
@@ -1,7 +1,7 @@
//! Illustrates different lights of various types and colors, some static, some moving over
//! a simple scene.

use std::f32::consts::TAU;
use std::f32::consts::PI;

use bevy::prelude::*;

Expand Down Expand Up @@ -36,7 +36,7 @@ fn setup(

// left wall
let mut transform = Transform::from_xyz(2.5, 2.5, 0.0);
transform.rotate_z(TAU / 4.);
transform.rotate_z(PI / 2.);
commands.spawn_bundle(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Box::new(5.0, 0.15, 5.0))),
transform,
Expand All @@ -49,7 +49,7 @@ fn setup(
});
// back (right) wall
let mut transform = Transform::from_xyz(0.0, 2.5, -2.5);
transform.rotate_x(TAU / 4.);
transform.rotate_x(PI / 2.);
commands.spawn_bundle(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Box::new(5.0, 0.15, 5.0))),
transform,
Expand Down Expand Up @@ -140,7 +140,7 @@ fn setup(
})
.with_children(|builder| {
builder.spawn_bundle(PbrBundle {
transform: Transform::from_rotation(Quat::from_rotation_x(TAU / 4.0)),
transform: Transform::from_rotation(Quat::from_rotation_x(PI / 2.0)),
mesh: meshes.add(Mesh::from(shape::Capsule {
depth: 0.125,
radius: 0.1,
Expand Down Expand Up @@ -202,7 +202,7 @@ fn setup(
},
transform: Transform {
translation: Vec3::new(0.0, 2.0, 0.0),
rotation: Quat::from_rotation_x(-TAU / 8.),
rotation: Quat::from_rotation_x(-PI / 4.),
..default()
},
..default()
Expand Down
6 changes: 3 additions & 3 deletions examples/3d/load_gltf.rs
@@ -1,6 +1,6 @@
//! Loads and renders a glTF file as a scene.

use std::f32::consts::TAU;
use std::f32::consts::PI;

use bevy::prelude::*;

Expand Down Expand Up @@ -52,8 +52,8 @@ fn animate_light_direction(
transform.rotation = Quat::from_euler(
EulerRot::ZYX,
0.0,
time.seconds_since_startup() as f32 * std::f32::consts::TAU / 10.0,
-TAU / 8.,
time.seconds_since_startup() as f32 * PI / 5.0,
-PI / 4.,
);
}
}
4 changes: 2 additions & 2 deletions examples/3d/render_to_texture.rs
@@ -1,6 +1,6 @@
//! Shows how to render to a texture. Useful for mirrors, UI, or exporting images.

use std::f32::consts::TAU;
use std::f32::consts::PI;

use bevy::{
core_pipeline::clear_color::ClearColorConfig,
Expand Down Expand Up @@ -128,7 +128,7 @@ fn setup(
mesh: cube_handle,
material: material_handle,
transform: Transform::from_xyz(0.0, 0.0, 1.5)
.with_rotation(Quat::from_rotation_x(-TAU / 10.0)),
.with_rotation(Quat::from_rotation_x(-PI / 5.0)),
..default()
})
.insert(MainPassCube);
Expand Down
8 changes: 4 additions & 4 deletions examples/3d/shadow_biases.rs
@@ -1,6 +1,6 @@
//! Demonstrates how shadow biases affect shadows in a 3d scene.

use std::f32::consts::TAU;
use std::f32::consts::PI;

use bevy::{input::mouse::MouseMotion, prelude::*};

Expand Down Expand Up @@ -83,8 +83,8 @@ fn setup(
transform: Transform::from_rotation(Quat::from_euler(
EulerRot::ZYX,
0.0,
TAU / 4.,
-TAU / 8.,
PI / 2.,
-PI / 4.,
)),
..default()
});
Expand Down Expand Up @@ -314,7 +314,7 @@ fn camera_controller(
if mouse_delta != Vec2::ZERO {
// Apply look update
options.pitch = (options.pitch - mouse_delta.y * 0.5 * options.sensitivity * dt)
.clamp(-TAU / 4., TAU / 4.);
.clamp(-PI / 2., PI / 2.);
options.yaw -= mouse_delta.x * options.sensitivity * dt;
transform.rotation = Quat::from_euler(EulerRot::ZYX, 0.0, options.yaw, options.pitch);
}
Expand Down
6 changes: 3 additions & 3 deletions examples/3d/shadow_caster_receiver.rs
@@ -1,6 +1,6 @@
//! Demonstrates how to prevent meshes from casting/receiving shadows in a 3d scene.

use std::f32::consts::TAU;
use std::f32::consts::PI;

use bevy::{
pbr::{NotShadowCaster, NotShadowReceiver},
Expand Down Expand Up @@ -109,8 +109,8 @@ fn setup(
transform: Transform::from_rotation(Quat::from_euler(
EulerRot::ZYX,
0.0,
TAU / 4.,
-TAU / 8.,
PI / 2.,
-PI / 4.,
)),
..default()
});
Expand Down
4 changes: 2 additions & 2 deletions examples/3d/shapes.rs
@@ -1,7 +1,7 @@
//! This example demonstrates the built-in 3d shapes in Bevy.
//! The scene includes a patterned texture and a rotation for visualizing the normals and UVs.

use std::f32::consts::TAU;
use std::f32::consts::PI;

use bevy::{
prelude::*,
Expand Down Expand Up @@ -55,7 +55,7 @@ fn setup(
2.0,
0.0,
)
.with_rotation(Quat::from_rotation_x(-TAU / 8.)),
.with_rotation(Quat::from_rotation_x(-PI / 4.)),
..default()
})
.insert(Shape);
Expand Down
6 changes: 3 additions & 3 deletions examples/3d/skybox.rs
@@ -1,6 +1,6 @@
//! Load a cubemap texture onto a cube like a skybox and cycle through different compressed texture formats

use std::f32::consts::TAU;
use std::f32::consts::PI;

use bevy::{
asset::LoadState,
Expand Down Expand Up @@ -69,7 +69,7 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
..default()
},
transform: Transform::from_xyz(0.0, 2.0, 0.0)
.with_rotation(Quat::from_rotation_x(-TAU / 8.)),
.with_rotation(Quat::from_rotation_x(-PI / 4.)),
..default()
});

Expand Down Expand Up @@ -410,7 +410,7 @@ pub fn camera_controller(
if mouse_delta != Vec2::ZERO {
// Apply look update
options.pitch = (options.pitch - mouse_delta.y * 0.5 * options.sensitivity * dt)
.clamp(-TAU / 4., TAU / 4.);
.clamp(-PI / 2., PI / 2.);
options.yaw -= mouse_delta.x * options.sensitivity * dt;
transform.rotation = Quat::from_euler(EulerRot::ZYX, 0.0, options.yaw, options.pitch);
}
Expand Down
4 changes: 2 additions & 2 deletions examples/3d/split_screen.rs
@@ -1,6 +1,6 @@
//! Renders two cameras to the same window to accomplish "split screen".

use std::f32::consts::TAU;
use std::f32::consts::PI;

use bevy::{
core_pipeline::clear_color::ClearColorConfig,
Expand Down Expand Up @@ -38,7 +38,7 @@ fn setup(

// Light
commands.spawn_bundle(DirectionalLightBundle {
transform: Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, 1.0, -TAU / 8.)),
transform: Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, 1.0, -PI / 4.)),
directional_light: DirectionalLight {
shadows_enabled: true,
..default()
Expand Down
10 changes: 5 additions & 5 deletions examples/3d/spotlight.rs
@@ -1,4 +1,4 @@
use std::f32::consts::TAU;
use std::f32::consts::PI;

use bevy::{
diagnostic::{FrameTimeDiagnosticsPlugin, LogDiagnosticsPlugin},
Expand Down Expand Up @@ -76,8 +76,8 @@ fn setup(
intensity: 200.0, // lumens
color: Color::WHITE,
shadows_enabled: true,
inner_angle: TAU / 8.0 * 0.85,
outer_angle: TAU / 8.0,
inner_angle: PI / 4.0 * 0.85,
outer_angle: PI / 4.0,
..default()
},
..default()
Expand Down Expand Up @@ -125,11 +125,11 @@ fn light_sway(time: Res<Time>, mut query: Query<(&mut Transform, &mut SpotLight)
for (mut transform, mut angles) in query.iter_mut() {
transform.rotation = Quat::from_euler(
EulerRot::XYZ,
-TAU / 4. + (time.seconds_since_startup() * 0.67 * 3.0).sin() as f32 * 0.5,
-PI / 2. + (time.seconds_since_startup() * 0.67 * 3.0).sin() as f32 * 0.5,
(time.seconds_since_startup() * 3.0).sin() as f32 * 0.5,
0.0,
);
let angle = ((time.seconds_since_startup() * 1.2).sin() as f32 + 1.0) * (TAU / 8. - 0.1);
let angle = ((time.seconds_since_startup() * 1.2).sin() as f32 + 1.0) * (PI / 4. - 0.1);
angles.inner_angle = angle * 0.8;
angles.outer_angle = angle;
}
Expand Down
22 changes: 6 additions & 16 deletions examples/3d/texture.rs
@@ -1,6 +1,6 @@
//! This example shows various ways to configure texture materials in 3D.

use std::f32::consts::TAU;
use std::f32::consts::PI;

use bevy::prelude::*;

Expand Down Expand Up @@ -59,33 +59,23 @@ fn setup(
commands.spawn_bundle(PbrBundle {
mesh: quad_handle.clone(),
material: material_handle,
transform: Transform {
translation: Vec3::new(0.0, 0.0, 1.5),
rotation: Quat::from_rotation_x(-TAU / 10.0),
..default()
},
transform: Transform::from_xyz(0.0, 0.0, 1.5)
.with_rotation(Quat::from_rotation_x(-PI / 5.0)),
..default()
});
// textured quad - modulated
commands.spawn_bundle(PbrBundle {
mesh: quad_handle.clone(),
material: red_material_handle,
transform: Transform {
translation: Vec3::new(0.0, 0.0, 0.0),
rotation: Quat::from_rotation_x(-TAU / 10.0),
..default()
},
transform: Transform::from_rotation(Quat::from_rotation_x(-PI / 5.0)),
..default()
});
// textured quad - modulated
commands.spawn_bundle(PbrBundle {
mesh: quad_handle,
material: blue_material_handle,
transform: Transform {
translation: Vec3::new(0.0, 0.0, -1.5),
rotation: Quat::from_rotation_x(-TAU / 10.0),
..default()
},
transform: Transform::from_xyz(0.0, 0.0, -1.5)
.with_rotation(Quat::from_rotation_x(-PI / 5.0)),
..default()
});
// camera
Expand Down
4 changes: 2 additions & 2 deletions examples/animation/animated_fox.rs
@@ -1,6 +1,6 @@
//! Plays animations from a skinned glTF.

use std::f32::consts::TAU;
use std::f32::consts::PI;

use bevy::prelude::*;

Expand Down Expand Up @@ -49,7 +49,7 @@ fn setup(

// Light
commands.spawn_bundle(DirectionalLightBundle {
transform: Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, 1.0, -TAU / 8.)),
transform: Transform::from_rotation(Quat::from_euler(EulerRot::ZYX, 0.0, 1.0, -PI / 4.)),
directional_light: DirectionalLight {
shadows_enabled: true,
..default()
Expand Down
14 changes: 7 additions & 7 deletions examples/animation/animated_transform.rs
@@ -1,6 +1,6 @@
//! Create and play an animation defined by code that operates on the `Transform` component.

use std::f32::consts::TAU;
use std::f32::consts::PI;

use bevy::prelude::*;

Expand Down Expand Up @@ -63,9 +63,9 @@ fn setup(
keyframe_timestamps: vec![0.0, 1.0, 2.0, 3.0, 4.0],
keyframes: Keyframes::Rotation(vec![
Quat::IDENTITY,
Quat::from_axis_angle(Vec3::Y, TAU / 4.),
Quat::from_axis_angle(Vec3::Y, TAU / 4. * 2.),
Quat::from_axis_angle(Vec3::Y, TAU / 4. * 3.),
Quat::from_axis_angle(Vec3::Y, PI / 2.),
Quat::from_axis_angle(Vec3::Y, PI / 2. * 2.),
Quat::from_axis_angle(Vec3::Y, PI / 2. * 3.),
Quat::IDENTITY,
]),
},
Expand Down Expand Up @@ -101,9 +101,9 @@ fn setup(
keyframe_timestamps: vec![0.0, 1.0, 2.0, 3.0, 4.0],
keyframes: Keyframes::Rotation(vec![
Quat::IDENTITY,
Quat::from_axis_angle(Vec3::Y, TAU / 4.),
Quat::from_axis_angle(Vec3::Y, TAU / 4. * 2.),
Quat::from_axis_angle(Vec3::Y, TAU / 4. * 3.),
Quat::from_axis_angle(Vec3::Y, PI / 2.),
Quat::from_axis_angle(Vec3::Y, PI / 2. * 2.),
Quat::from_axis_angle(Vec3::Y, PI / 2. * 3.),
Quat::IDENTITY,
]),
},
Expand Down
4 changes: 2 additions & 2 deletions examples/animation/custom_skinned_mesh.rs
@@ -1,7 +1,7 @@
//! Skinned mesh example with mesh and joints data defined in code.
//! Example taken from <https://github.com/KhronosGroup/glTF-Tutorials/blob/master/gltfTutorial/gltfTutorial_019_SimpleSkin.md>

use std::f32::consts::TAU;
use std::f32::consts::PI;

use bevy::{
pbr::AmbientLight,
Expand Down Expand Up @@ -165,6 +165,6 @@ fn setup(
fn joint_animation(time: Res<Time>, mut query: Query<&mut Transform, With<AnimatedJoint>>) {
for mut transform in &mut query {
transform.rotation =
Quat::from_rotation_z(TAU / 4. * time.time_since_startup().as_secs_f32().sin());
Quat::from_rotation_z(PI / 2. * time.time_since_startup().as_secs_f32().sin());
}
}
4 changes: 2 additions & 2 deletions examples/animation/gltf_skinned_mesh.rs
@@ -1,7 +1,7 @@
//! Skinned mesh example with mesh and joints data loaded from a glTF file.
//! Example taken from <https://github.com/KhronosGroup/glTF-Tutorials/blob/master/gltfTutorial/gltfTutorial_019_SimpleSkin.md>

use std::f32::consts::TAU;
use std::f32::consts::PI;

use bevy::{pbr::AmbientLight, prelude::*, render::mesh::skinning::SkinnedMesh};

Expand Down Expand Up @@ -67,6 +67,6 @@ fn joint_animation(
let mut second_joint_transform = transform_query.get_mut(second_joint_entity).unwrap();

second_joint_transform.rotation =
Quat::from_rotation_z(TAU / 4. * time.time_since_startup().as_secs_f32().sin());
Quat::from_rotation_z(PI / 2. * time.time_since_startup().as_secs_f32().sin());
}
}
6 changes: 3 additions & 3 deletions examples/ecs/hierarchy.rs
@@ -1,6 +1,6 @@
//! Creates a hierarchy of parents and children entities.

use std::f32::consts::TAU;
use std::f32::consts::PI;

use bevy::prelude::*;

Expand Down Expand Up @@ -66,14 +66,14 @@ fn rotate(
) {
for (parent, children) in &mut parents_query {
if let Ok(mut transform) = transform_query.get_mut(parent) {
transform.rotate_z(-TAU / 4. * time.delta_seconds());
transform.rotate_z(-PI / 2. * time.delta_seconds());
}

// To iterate through the entities children, just treat the Children component as a Vec
// Alternatively, you could query entities that have a Parent component
for child in children {
if let Ok(mut transform) = transform_query.get_mut(*child) {
transform.rotate_z(TAU / 2. * time.delta_seconds());
transform.rotate_z(PI * time.delta_seconds());
}
}

Expand Down

0 comments on commit b04a1b6

Please sign in to comment.