Skip to content

Instantly share code, notes, and snippets.

@rparrett
rparrett / has-two-approvals.jq
Last active February 19, 2024 14:05
Find Bevy PRs that have two approvals but lack the `S-Ready-For-Final-Review` label
def filter(cond): map(select(cond));
.[] | [
.number,
(.reviews | filter(.state=="APPROVED") | unique_by(.author.login) | length),
(.labels | any(.name == "S-Ready-For-Final-Review" or .name == "S-Blocked" or .name == "S-Needs-Benchmarking" or .name == "S-Needs-Design" or .name == "S-Adopt-Me" or .name == "S-Needs-RFC" ) | not)
] | select((.[1] >= 2) and .[2]) | ("<a href=\"https://github.com/bevyengine/bevy/pull/" + (.[0] | tostring) + "\">" + (.[0] | tostring) + "</a><br/>")
@rparrett
rparrett / debug_normals.rs
Last active February 14, 2024 19:54
Bevy 0.13 `3d_shapes.rs` but with normal debugging gizmos and wireframes
//! 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::PI;
use bevy::{
input::common_conditions::input_just_pressed,
pbr::wireframe::{Wireframe, WireframePlugin},
prelude::*,
render::{
@rparrett
rparrett / repeat.rs
Last active January 11, 2024 22:29
Bevy 0.12 2d Repeating Image
use bevy::{
prelude::*,
render::{
mesh::VertexAttributeValues,
texture::{ImageAddressMode, ImageLoaderSettings, ImageSampler, ImageSamplerDescriptor},
},
sprite::MaterialMesh2dBundle,
};
fn main() {
@rparrett
rparrett / hollow_circle.rs
Created December 10, 2023 20:57
Bevy 0.12 hollow circle mesh
pub fn hollow_circle(inner_radius: f32, thickness: f32, sides: usize) -> Mesh {
let outer_radius = inner_radius + thickness;
debug_assert!(sides > 2, "hollow_circle requires at least 3 sides.");
let vertices = sides * 2;
let mut positions = Vec::with_capacity(vertices);
let mut normals = Vec::with_capacity(vertices);
let mut uvs = Vec::with_capacity(vertices);
@rparrett
rparrett / modify_gltf_material.rs
Last active October 15, 2023 14:19
Bevy 0.11: Modify a material in GLTF file after spawning it without changing other GLTFs
use bevy::{prelude::*, scene::SceneInstance};
#[derive(Component)]
struct RedFox;
#[derive(Component)]
struct Decorated;
#[derive(Resource)]
struct RedMaterial(Handle<StandardMaterial>);
@rparrett
rparrett / no_focus_on_mac.patch
Last active August 31, 2023 14:24
(macos) Make new windows from bevy's example-showcase --screenshot not steal focus
diff --git a/crates/bevy_winit/src/lib.rs b/crates/bevy_winit/src/lib.rs
index 8c79494de..7bd737744 100644
--- a/crates/bevy_winit/src/lib.rs
+++ b/crates/bevy_winit/src/lib.rs
@@ -47,6 +47,9 @@ use bevy_window::{
#[cfg(target_os = "android")]
pub use winit::platform::android::activity::AndroidApp;
+#[cfg(target_os = "macos")]
+use winit::platform::macos::EventLoopBuilderExtMacOS;
@rparrett
rparrett / diff.diff
Created July 10, 2023 14:31
bevy_ecs_tilemap shaders 0.11
diff --git a/src/render/shaders/tilemap_fragment.wgsl b/src/render/shaders/tilemap_fragment.wgsl
index be535aa..e515117 100644
--- a/src/render/shaders/tilemap_fragment.wgsl
+++ b/src/render/shaders/tilemap_fragment.wgsl
@@ -1,15 +1,9 @@
+#import bevy_ecs_tilemap::vertex_output MeshVertexOutput
+#import bevy_ecs_tilemap::common tilemap_data
#import bevy_ecs_tilemap::common sprite_texture, sprite_sampler
-struct VertexOutput {
@rparrett
rparrett / change.diff
Last active March 14, 2023 18:11
bevy_mod_parallax scaling
diff --git a/examples/cyberpunk.rs b/examples/cyberpunk.rs
index 1d27172..45ff7eb 100644
--- a/examples/cyberpunk.rs
+++ b/examples/cyberpunk.rs
@@ -1,9 +1,11 @@
use bevy::prelude::*;
use bevy_parallax::{
- LayerData, LayerSpeed, ParallaxCameraComponent, ParallaxMoveEvent, ParallaxPlugin,
- ParallaxResource,
+ LayerComponent, LayerData, LayerSpeed, ParallaxCameraComponent, ParallaxMoveEvent,
@rparrett
rparrett / main.rs
Last active February 24, 2023 19:30
Bevy 0.9 + bevy_egui: changing a cube's color with sliders
// Mashup of
// https://github.com/mvlabat/bevy_egui/blob/v0.19.0/examples/simple.rs
// https://github.com/bevyengine/bevy/blob/v0.9.1/examples/3d/3d_scene.rs
// In cargo.toml:
// [dependencies]
// bevy = "0.9"
// bevy_egui = "0.19"
use bevy::prelude::*;
@rparrett
rparrett / main.rs
Last active February 23, 2023 22:24
Bevy 0.10-pre Directional Light Playground
use bevy::{
ecs::world::Ref,
pbr::{CascadeShadowConfig, CascadeShadowConfigBuilder},
prelude::*,
};
use std::f32::consts::PI;
#[derive(Component)]
struct LightRotation {
x: f32,