Skip to content

Commit

Permalink
[#72] Fix arms
Browse files Browse the repository at this point in the history
  • Loading branch information
Orchaldir committed Sep 20, 2023
1 parent 8c0cac7 commit a891229
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
3 changes: 1 addition & 2 deletions rpg_tools_rendering/examples/pants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use rpg_tools_core::model::color::Color;
use rpg_tools_core::model::equipment::appearance::pants::{Pants, PantsStyle};
use rpg_tools_core::model::equipment::appearance::Clothing;
use rpg_tools_core::model::length::Length;
use rpg_tools_core::model::width::Width;

pub mod utils;

Expand Down Expand Up @@ -39,7 +38,7 @@ fn create_appearance(height: Length, pants: &Pants, shape: &BodyShape) -> Appear
Appearance::humanoid(
Body {
shape: *shape,
width: Width::default(),
width: Default::default(),
skin: Default::default(),
clothing: Clothing::Simple {
pants: *pants,
Expand Down
3 changes: 1 addition & 2 deletions rpg_tools_rendering/examples/shirts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use rpg_tools_core::model::color::Color;
use rpg_tools_core::model::equipment::appearance::shirt::{Neckline, Shirt, SleeveStyle};
use rpg_tools_core::model::equipment::appearance::Clothing;
use rpg_tools_core::model::length::Length;
use rpg_tools_core::model::width::Width;

pub mod utils;

Expand Down Expand Up @@ -38,7 +37,7 @@ fn create_appearance(height: Length, shirt: &Shirt, shape: &BodyShape) -> Appear
Appearance::humanoid(
Body {
shape: *shape,
width: Width::default(),
width: Default::default(),
skin: Default::default(),
clothing: Clothing::Simple {
pants: Default::default(),
Expand Down
15 changes: 11 additions & 4 deletions rpg_tools_rendering/src/rendering/body/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ fn render_arms(
}

pub fn get_left_arm(config: &RenderConfig, aabb: &AABB, body: &Body) -> Polygon2dBuilder {
let mut builder = get_left_arm_short(config, aabb, body);
let mut builder = get_left_arm_short(config, aabb, body, false);
let width = config.body.get_arm_width(body);
let bottom_x = get_end_x(config.body.get_torso_width(body));
let y = config.body.get_arm_y() + config.body.height_arm;
Expand All @@ -88,17 +88,24 @@ pub fn get_left_arm(config: &RenderConfig, aabb: &AABB, body: &Body) -> Polygon2
builder
}

pub fn get_left_arm_short(config: &RenderConfig, aabb: &AABB, body: &Body) -> Polygon2dBuilder {
pub fn get_left_arm_short(
config: &RenderConfig,
aabb: &AABB,
body: &Body,
bottom_sharp: bool,
) -> Polygon2dBuilder {
let mut builder = Polygon2dBuilder::new();
let width = config.body.get_arm_width(body);
let top_x = get_end_x(config.body.get_shoulder_width(body) * 0.94);
let bottom_x = get_end_x(config.body.get_torso_width(body));
let y = config.body.get_arm_y();
let mid_y = y + 0.2;

builder.add_point(aabb.get_point(top_x, y), true);
builder.add_point_cw(aabb.get_point(top_x + width, y), false);
builder.add_point(aabb.get_point(top_x, mid_y), true);
builder.add_point_cw(aabb.get_point(top_x + width, mid_y), true);
builder.add_point(aabb.get_point(top_x, y + 0.1), true);
builder.add_point(aabb.get_point(bottom_x, mid_y), bottom_sharp);
builder.add_point_cw(aabb.get_point(bottom_x + width, mid_y), bottom_sharp);

builder
}
Expand Down
2 changes: 1 addition & 1 deletion rpg_tools_rendering/src/rendering/equipment/shirt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn render_sleeves(
let polygon = match shirt.sleeve_style {
SleeveStyle::Long => get_left_arm(config, aabb, body),
SleeveStyle::None => return,
SleeveStyle::Short => get_left_arm_short(config, aabb, body),
SleeveStyle::Short => get_left_arm_short(config, aabb, body, true),
}
.build();

Expand Down

0 comments on commit a891229

Please sign in to comment.