From 6b32e71971be6512a643b57142efd6cff73af1ed Mon Sep 17 00:00:00 2001 From: Lee-Orr Date: Wed, 7 Feb 2024 19:01:39 -0500 Subject: [PATCH] initial test --- Cargo.toml | 12 ++------ examples/simple_example.rs | 11 +++---- src/lib.rs | 61 ++++++++++++++++++++++++++++++++++---- 3 files changed, 62 insertions(+), 22 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c4b3eae..6bff243 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,19 +4,13 @@ version = "0.1.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - +[lib] [dependencies] bevy = { version = "0.12", default-features = false, features = ["bevy_pbr", "bevy_render", "bevy_asset", "animation", "bevy_animation"]} -serde = "1" +serde = { version = "1", features = ["derive"] } +csv = "1.3" [dev-dependencies] bevy = { version = "0.12", default-features = true } -dexterous_developer = "0.1" bevy-inspector-egui = "0.22" - - -[[example]] -name = "simple_example" -path = "examples/simple_example.rs" -crate-type = ["dylib"] \ No newline at end of file diff --git a/examples/simple_example.rs b/examples/simple_example.rs index b14ffd1..6d8824c 100644 --- a/examples/simple_example.rs +++ b/examples/simple_example.rs @@ -1,13 +1,11 @@ use bevy::{pbr::{CascadeShadowConfigBuilder, DirectionalLightShadowMap}, prelude::*}; use bevy_inspector_egui::quick::WorldInspectorPlugin; -use dexterous_developer::{hot_bevy_main, InitialPlugins}; -#[hot_bevy_main] -pub fn bevy_main(initial_plugins: impl InitialPlugins) { +fn main() { App::new() - .add_plugins(initial_plugins.initialize::()) - .add_plugins(WorldInspectorPlugin::new()) .insert_resource(DirectionalLightShadowMap { size: 4096 }) + .add_plugins(DefaultPlugins) + .add_plugins(WorldInspectorPlugin::new()) .add_systems(Startup, setup) .run(); } @@ -44,5 +42,4 @@ fn setup(mut commands: Commands, asset_server: Res) { scene: asset_server.load("example.gltf#Scene0"), ..default() }); -} - +} \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 7d12d9a..84cb9ca 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,14 +1,63 @@ -pub fn add(left: usize, right: usize) -> usize { - left + right +use std::{path::Display, sync::Arc}; + +use bevy::utils::{default, HashMap, Instant}; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)] +pub struct MorphID { + id: usize, + +} + +#[derive(Clone, Copy, Debug, PartialEq, PartialOrd, Serialize, Deserialize)] +pub struct RelativeFrameTime(f32); + +impl MorphID { + pub fn new(id: usize) -> Self { + Self { + id: id + } + } +} + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct CSVFrame { + timestamp: RelativeFrameTime, + morphs: HashMap, +} + + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct CSVAnimation { + frames: Vec, + morph_names: Vec +} + +#[derive(Debug, PartialEq, Eq, Clone, Copy)] +pub enum CSVParseError { + NoData +} + +impl std::fmt::Display for CSVParseError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + f.write_str(&format!("{self:?}")) + } +} + +impl std::error::Error for CSVParseError {} + +impl CSVAnimation { + pub fn parse(csv: &str) -> Result { + Err(CSVParseError::NoData) + } } #[cfg(test)] mod tests { - use super::*; + use crate::{CSVAnimation, CSVParseError}; #[test] - fn it_works() { - let result = add(2, 2); - assert_eq!(result, 4); + fn given_no_data_the_csv_doesnt_parse() { + assert_eq!(CSVAnimation::parse("").err().unwrap(), CSVParseError::NoData) } }