From 35bfaedf31b5e6d1c89c8235730804254222d8a6 Mon Sep 17 00:00:00 2001 From: Ruiqi Niu Date: Mon, 30 Sep 2024 08:59:27 -0400 Subject: [PATCH 1/4] More handy workspace setup. --- .gitignore | 8 ++++++++ .vscode/settings.json | 1 + 2 files changed, 9 insertions(+) diff --git a/.gitignore b/.gitignore index 4fffb2f..0db77a6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,10 @@ +# Rust /target /Cargo.lock + +# Inochi2D project/model file +*.inp +*.inx + +# renderdoc capture file +*.cap diff --git a/.vscode/settings.json b/.vscode/settings.json index c8a8b11..6a43b55 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,5 +3,6 @@ "no-inline-html": false, "first-line-heading": false }, + "cSpell.enabled": false, // "rust-analyzer.cargo.target": "wasm32-unknown-unknown" } \ No newline at end of file From f6811a61241bab44616dcc883f145a09d97dbc64 Mon Sep 17 00:00:00 2001 From: Ruiqi Niu Date: Mon, 30 Sep 2024 09:01:37 -0400 Subject: [PATCH 2/4] Physics param map mode `YX`. --- inox2d/src/formats/payload.rs | 1 + inox2d/src/node/components.rs | 1 + inox2d/src/physics/pendulum.rs | 8 ++++++++ 3 files changed, 10 insertions(+) diff --git a/inox2d/src/formats/payload.rs b/inox2d/src/formats/payload.rs index dc8d041..887e40b 100644 --- a/inox2d/src/formats/payload.rs +++ b/inox2d/src/formats/payload.rs @@ -157,6 +157,7 @@ fn deserialize_simple_physics(obj: JsonObject) -> InoxParseResult map_mode: match obj.get_str("map_mode")? { "AngleLength" => PhysicsParamMapMode::AngleLength, "XY" => PhysicsParamMapMode::XY, + "YX" => PhysicsParamMapMode::YX, unknown => return Err(InoxParseError::UnknownParamMapMode(unknown.to_owned())), }, diff --git a/inox2d/src/node/components.rs b/inox2d/src/node/components.rs index 7d1c252..7f77be8 100644 --- a/inox2d/src/node/components.rs +++ b/inox2d/src/node/components.rs @@ -130,6 +130,7 @@ pub enum PhysicsModel { pub enum PhysicsParamMapMode { AngleLength, XY, + YX, } #[derive(Clone)] diff --git a/inox2d/src/physics/pendulum.rs b/inox2d/src/physics/pendulum.rs index 6228b5a..5c346bd 100644 --- a/inox2d/src/physics/pendulum.rs +++ b/inox2d/src/physics/pendulum.rs @@ -62,6 +62,14 @@ impl SimplePhysicsCtx for T { result.y = -result.y; // Y goes up for params result } + PhysicsParamMapMode::YX => { + let local_pos_norm = local_angle * relative_length; + let mut result = local_pos_norm - Vec2::Y; + result.y = -result.y; // Y goes up for params + + use glam::Vec2Swizzles; + result.yx() + } PhysicsParamMapMode::AngleLength => { let a = f32::atan2(-local_angle.x, local_angle.y) / PI; Vec2::new(a, relative_length) From ac500323979bb0f5f3f1c31699401f5216453045 Mon Sep 17 00:00:00 2001 From: Ruiqi Niu Date: Mon, 30 Sep 2024 09:03:11 -0400 Subject: [PATCH 3/4] Dummy deser for param binding of `opacity`. To load Grillo's model properly. --- inox2d/src/formats/payload.rs | 2 ++ inox2d/src/params.rs | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/inox2d/src/formats/payload.rs b/inox2d/src/formats/payload.rs index 887e40b..7d310be 100644 --- a/inox2d/src/formats/payload.rs +++ b/inox2d/src/formats/payload.rs @@ -455,6 +455,8 @@ fn deserialize_binding_values(param_name: &str, values: &[JsonValue]) -> InoxPar BindingValues::Deform(Matrix2d::from_slice_vecs(&parsed, true)?) } + // TODO + "opacity" => BindingValues::Opacity, param_name => return Err(InoxParseError::UnknownParamName(param_name.to_owned())), }) } diff --git a/inox2d/src/params.rs b/inox2d/src/params.rs index a7727ae..9219a1c 100644 --- a/inox2d/src/params.rs +++ b/inox2d/src/params.rs @@ -32,6 +32,8 @@ pub enum BindingValues { TransformRY(Matrix2d), TransformRZ(Matrix2d), Deform(Matrix2d>), + // TODO + Opacity, } #[derive(Debug, Clone)] @@ -219,6 +221,8 @@ impl Param { .expect("Nodes being deformed must have a DeformStack component.") .push(DeformSource::Param(self.uuid), Deform::Direct(direct_deform)); } + // TODO + BindingValues::Opacity => {} } } } From 6a5663473cc9c33650ef38994f7e10836128fc8e Mon Sep 17 00:00:00 2001 From: Ruiqi Niu Date: Mon, 30 Sep 2024 09:04:35 -0400 Subject: [PATCH 4/4] Whitespaces. --- inox2d/src/params.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/inox2d/src/params.rs b/inox2d/src/params.rs index 9219a1c..2b17a91 100644 --- a/inox2d/src/params.rs +++ b/inox2d/src/params.rs @@ -201,19 +201,19 @@ impl Param { .expect("Deform param target must have an associated Mesh."); let vert_len = mesh.vertices.len(); - let mut direct_deform: Vec = Vec::with_capacity(vert_len); - direct_deform.resize(vert_len, Vec2::ZERO); - - bi_interpolate_vec2s_additive( - val_normed, - range_in, - out_top, - out_bottom, - binding.interpolate_mode, - &mut direct_deform, - ); - - direct_deform + let mut direct_deform: Vec = Vec::with_capacity(vert_len); + direct_deform.resize(vert_len, Vec2::ZERO); + + bi_interpolate_vec2s_additive( + val_normed, + range_in, + out_top, + out_bottom, + binding.interpolate_mode, + &mut direct_deform, + ); + + direct_deform }; comps