From a4a9f5dce3c4c572fce9310821e689f7166969df Mon Sep 17 00:00:00 2001 From: Orchaldir Date: Sun, 17 Sep 2023 14:57:44 +0200 Subject: [PATCH] [#72] Render neckline --- .../src/rendering/body/torso.rs | 8 ++--- .../src/rendering/equipment/shirt.rs | 35 +++++++++++++++---- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/rpg_tools_rendering/src/rendering/body/torso.rs b/rpg_tools_rendering/src/rendering/body/torso.rs index 3cc87fff..c1c86270 100644 --- a/rpg_tools_rendering/src/rendering/body/torso.rs +++ b/rpg_tools_rendering/src/rendering/body/torso.rs @@ -26,11 +26,11 @@ pub fn render_torso( pub fn create_torso(aabb: &AABB, config: &BodyConfig, torso: &TorsoConfig) -> Polygon2dBuilder { let mut builder = Polygon2dBuilder::new(); - builder.add_mirrored_points(&aabb, torso.shoulder_width, 0.0, false); - builder.add_mirrored_points(&aabb, torso.shoulder_width, config.y_upper, false); - builder.add_mirrored_points(&aabb, torso.waist_width, config.y_waist, false); - builder.add_mirrored_points(&aabb, torso.hip_width, config.y_lower, false); builder.add_mirrored_points(&aabb, torso.hip_width, 1.0, false); + builder.add_mirrored_points(&aabb, torso.hip_width, config.y_lower, false); + builder.add_mirrored_points(&aabb, torso.waist_width, config.y_waist, false); + builder.add_mirrored_points(&aabb, torso.shoulder_width, config.y_upper, false); + builder.add_mirrored_points(&aabb, torso.shoulder_width, 0.0, false); builder } diff --git a/rpg_tools_rendering/src/rendering/equipment/shirt.rs b/rpg_tools_rendering/src/rendering/equipment/shirt.rs index 879343d8..8ab877a5 100644 --- a/rpg_tools_rendering/src/rendering/equipment/shirt.rs +++ b/rpg_tools_rendering/src/rendering/equipment/shirt.rs @@ -1,9 +1,12 @@ use crate::math::aabb2d::AABB; +use crate::math::polygon2d::builder::Polygon2dBuilder; use crate::renderer::Renderer; use crate::rendering::body::torso::create_torso; +use crate::rendering::config::body::torso::TorsoConfig; +use crate::rendering::config::body::BodyConfig; use crate::rendering::config::RenderConfig; use rpg_tools_core::model::character::appearance::body::Body; -use rpg_tools_core::model::equipment::appearance::shirt::Shirt; +use rpg_tools_core::model::equipment::appearance::shirt::{Neckline, Shirt}; pub fn render_shirt( renderer: &mut dyn Renderer, @@ -14,11 +17,29 @@ pub fn render_shirt( ) { let options = config.get_options(shirt.color); let torso_aabb = config.body.get_torso_aabb(body, aabb); - let polygon = create_torso( - &torso_aabb, - &config.body, - config.body.get_torso_config(body.shape), - ) - .build(); + let torso = config.body.get_torso_config(body.shape); + let mut builder = create_torso(&torso_aabb, &config.body, torso); + add_neckline(config, &torso_aabb, torso, shirt, &mut builder); + let polygon = builder.build(); renderer.render_rounded_polygon(&polygon, &options); } + +fn add_neckline( + config: &RenderConfig, + aabb: &AABB, + torso: &TorsoConfig, + shirt: &Shirt, + builder: &mut Polygon2dBuilder, +) { + match shirt.neckline { + Neckline::Boat => {} + Neckline::Crew => { + let crew_width = torso.shoulder_width / 3.0; + builder.add_mirrored_points(&aabb, crew_width, 0.0, true); + builder.add_mirrored_points(&aabb, crew_width, 0.1, false); + } + Neckline::DeepV => {} + Neckline::Scoop => {} + Neckline::V => {} + } +}