Skip to content

Commit c977d59

Browse files
committed
still can't fucking see anything....
1 parent af20561 commit c977d59

File tree

5 files changed

+26
-13
lines changed

5 files changed

+26
-13
lines changed

Diff for: src/main.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,23 @@ fn main() {
2323
ShadPlayPlugin,
2424
))
2525
.add_systems(
26-
Update,
26+
PostUpdate,
2727
(
28-
UserSession::runtime_updater.run_if(on_event::<KeyboardInput>),
29-
UserSession::runtime_updater.run_if(on_event::<WindowResized>),
28+
UserSession::runtime_updater
29+
.run_if(on_event::<WindowResized>)
30+
.run_if(time_passed(1.0)), // Rate limit the speed at which we write to the config file...
31+
32+
//
3033
),
31-
//
3234
);
3335

3436
shadplay.run();
3537
}
38+
39+
// https://github.com/bevyengine/bevy/blob/b9123e74b6838b58c33badff73d176441f8a33cc/examples/ecs/run_conditions.rs
40+
fn time_passed(t: f32) -> impl FnMut(Local<f32>, Res<Time>) -> bool {
41+
move |mut timer: Local<f32>, time: Res<Time>| {
42+
*timer += time.delta_secs();
43+
*timer >= t
44+
}
45+
}

Diff for: src/plugin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub struct ShadPlayPlugin;
1111

1212
impl Plugin for ShadPlayPlugin {
1313
fn build(&self, app: &mut bevy::prelude::App) {
14-
app.insert_state(AppState::TwoD)
14+
app.insert_state(AppState::TwoD) // we start always in 2d mode
1515
.add_plugins(ShadplayShaderLibrary) // Something of a library with common functions.
1616
.add_plugins(crate::system::ScreenshotPlugin) //NOTE: this is not Bevy's one!
1717
.add_plugins(ColourPickerPlugin)

Diff for: src/shader_utils/mod.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
//!
22
//! Most of the boilerplate to make a custom shader work lives here.
33
//!
4-
use std::path::PathBuf;
5-
pub mod texture_tooling;
6-
74
use bevy::{prelude::*, reflect::TypePath, render::render_resource::*, sprite::Material2d};
5+
use std::path::PathBuf;
86

97
pub mod common;
8+
pub mod texture_tooling;
109

1110
/// Event: for facilitating the drag-n-drop of a .wgsl shader onto Shadplay.
1211
#[derive(Event, Debug, Deref, DerefMut)]
@@ -18,7 +17,7 @@ pub struct DragNDropShader {
1817
// 3D //
1918
// ************************************ //
2019
/// The 3D shader.
21-
#[derive(Asset, AsBindGroup, TypePath, Debug, Clone, Component)]
20+
#[derive(Asset, AsBindGroup, TypePath, Debug, Clone)]
2221
// #[uuid = "a3d71c04-d054-4946-80f8-ba6cfbc90cad"]
2322
pub struct YourShader {
2423
#[uniform(100)]
@@ -39,7 +38,7 @@ impl Material for YourShader {
3938
// 2D //
4039
// ************************************ //
4140
/// The 2D shadertoy like shader
42-
#[derive(Asset, AsBindGroup, TypePath, Debug, Clone, Component)]
41+
#[derive(Asset, AsBindGroup, TypePath, Debug, Clone)]
4342
// #[uuid = "f528511f-dcf2-4b0b-9522-a9df3a1a795b"]
4443
pub struct YourShader2D {
4544
#[uniform(100)]

Diff for: src/shader_utils/texture_tooling.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,6 @@ pub fn swap_2d_tex_from_idx(
111111
}
112112
}
113113
});
114-
break; // Exit after processing the first shader.
114+
return; // Exit after processing the first shader.
115115
}
116116
}

Diff for: src/utils.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,14 @@ pub struct ShapeOptions(
112112
);
113113

114114
/// Resource: Tracking whether or not we're rotating our shapes. 3d only.
115-
#[derive(Resource, Default, PartialEq)]
115+
#[derive(Debug, Resource, Default, PartialEq)]
116116
pub struct Rotating(pub bool);
117117

118118
/// System: to toggle on/off the rotating, 3d only.
119119
pub fn toggle_rotate(input: Res<ButtonInput<KeyCode>>, mut toggle: ResMut<Rotating>) {
120120
if input.just_pressed(KeyCode::KeyR) {
121121
toggle.0 = !toggle.0;
122+
info!("Togling rotate to {toggle:#?}");
122123
}
123124
}
124125

@@ -185,7 +186,9 @@ pub fn switch_shape(
185186
mut commands: Commands,
186187
query: Query<Entity, With<Shape>>,
187188
) {
189+
info!("Switch shape system is running...");
188190
if input.just_pressed(KeyCode::KeyS) {
191+
info!("Shape change requested...");
189192
// Old
190193
let Some(idx) = shape_options.0.iter().position(|v| v.0) else {
191194
return;
@@ -197,6 +200,7 @@ pub fn switch_shape(
197200
let next = (idx + 1) % shape_options.0.len();
198201
commands.spawn(shape_options.0[next].1.clone());
199202
shape_options.0[next].0 = true;
203+
info!("shape change complete");
200204
}
201205
}
202206

@@ -250,7 +254,7 @@ pub fn init_shapes(
250254
minor_radius: 0.2,
251255
}))),
252256
MeshMaterial3d(mat.clone_weak()),
253-
Transform::from_xyz(0.0, 0.0, 0.0),
257+
Transform::from_xyz(0.0, 0.3, 0.0),
254258
Shape,
255259
));
256260
info!("Torus added");

0 commit comments

Comments
 (0)