Skip to content

Commit

Permalink
rust 2024 edition
Browse files Browse the repository at this point in the history
  • Loading branch information
rectalogic committed Feb 20, 2025
1 parent 398e684 commit f9ce8ad
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 55 deletions.
79 changes: 40 additions & 39 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "terp"
version = "0.1.2"
edition = "2021"
edition = "2024"

[lib]
crate-type = ["cdylib", "lib"]
Expand Down
6 changes: 3 additions & 3 deletions src/app.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
use bevy::{
DefaultPlugins,
app::App,
prelude::*,
winit::{WakeUp, WinitPlugin},
DefaultPlugins,
};

#[cfg(target_arch = "wasm32")]
use crate::webgpu;
use crate::{
animation, camera, cli, draw, points,
AppState, animation, camera, cli, draw, points,
project::{self, LoadProjectData},
ui, AppState,
ui,
};

pub enum AppPlugin {
Expand Down
2 changes: 1 addition & 1 deletion src/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use bevy::{
render::{camera::Viewport, view::RenderLayers},
};

use crate::{ui::CameraLayout, Interpolated};
use crate::{Interpolated, ui::CameraLayout};

pub(crate) const SOURCE_LAYER: RenderLayers = RenderLayers::layer(1);
pub(crate) const TARGET_LAYER: RenderLayers = RenderLayers::layer(2);
Expand Down
2 changes: 1 addition & 1 deletion src/draw.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::{
AppState, Interpolated,
animation::Animatable,
camera::{SOURCE_LAYER, TARGET_LAYER},
error_handler,
points::{Points, PointsMaterial, PointsMeshBuilder, PointsSettings},
project::LoadProject,
util::window_position_to_world,
AppState, Interpolated,
};
use anyhow::Result;
use bevy::{
Expand Down
12 changes: 7 additions & 5 deletions src/points/mesh.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::cmp::Ordering;

use super::ATTRIBUTE_TARGET_POSITION;
use anyhow::{anyhow, Result};
use anyhow::{Result, anyhow};
use bevy::{asset::RenderAssetUsages, prelude::*, render::mesh::VertexAttributeValues};
use serde::{Deserialize, Serialize};

Expand All @@ -10,7 +10,7 @@ pub(crate) struct Points(pub Vec<Vec2>);

impl Points {
pub(crate) fn append(mesh: &mut Mesh, point: Vec2) {
if let Some(VertexAttributeValues::Float32x3(ref mut positions)) =
if let Some(VertexAttributeValues::Float32x3(positions)) =
mesh.attribute_mut(Mesh::ATTRIBUTE_POSITION)
{
positions.reserve(3);
Expand All @@ -23,12 +23,12 @@ impl Points {

// Merge target into source interpolated
pub(crate) fn interpolate(source: &mut Mesh, target: &Mesh) {
let Some(VertexAttributeValues::Float32x3(ref mut source_positions)) =
let Some(VertexAttributeValues::Float32x3(source_positions)) =
source.attribute_mut(Mesh::ATTRIBUTE_POSITION)
else {
return;
};
let Some(VertexAttributeValues::Float32x3(ref target_positions)) =
let Some(VertexAttributeValues::Float32x3(target_positions)) =
target.attribute(Mesh::ATTRIBUTE_POSITION)
else {
return;
Expand Down Expand Up @@ -241,7 +241,9 @@ mod tests {
fn test_padding() {
assert_eq!(
Points::pad_positions(&[1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4], 7 * 3),
vec![1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4,]
vec![
1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4,
]
);
assert_eq!(
Points::pad_positions(&[1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4], 14 * 3),
Expand Down
2 changes: 1 addition & 1 deletion src/ui.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{draw::UndoEvent, AppState, Interpolated};
use crate::{AppState, Interpolated, draw::UndoEvent};
use bevy::{asset::embedded_asset, prelude::*, render::view::RenderLayers};

mod brush_color;
Expand Down
4 changes: 2 additions & 2 deletions src/ui/brush_color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ use bevy::{
};

use crate::{
AppState,
draw::Brush,
util::{window_position_to_world, window_to_world},
AppState,
};

use super::{ControlsCamera, CONTROLS_LAYER};
use super::{CONTROLS_LAYER, ControlsCamera};

const RADIUS: f32 = 50.0;

Expand Down
4 changes: 2 additions & 2 deletions src/ui/brush_size.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use bevy::{prelude::*, window::PrimaryWindow};

use crate::{
AppState,
draw::Brush,
util::{window_position_to_world, window_to_world},
AppState,
};

use super::{ControlsCamera, CONTROLS_LAYER};
use super::{CONTROLS_LAYER, ControlsCamera};

#[derive(Component)]
struct BrushSizeControl;
Expand Down

0 comments on commit f9ce8ad

Please sign in to comment.