Skip to content

Commit

Permalink
[#42] Start sole rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
Orchaldir committed Sep 23, 2023
1 parent 43a5107 commit 345290d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
12 changes: 6 additions & 6 deletions rpg_tools_rendering/src/rendering/body/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,21 @@ fn render_legs(
body: &Body,
options: &RenderOptions,
) {
let legs_width = config.body.get_legs_width(body);
let leg_width = config.body.get_leg_width(body);
let leg_y = config.body.get_leg_y();
let foot_y = config.body.get_foot_y();
let left_leg_start_x = config.body.get_left_leg_x(body);
let right_leg_x = config.body.get_right_leg_x(body);

let left_leg_start_x = get_end_x(legs_width) - leg_width;
let left_leg_start = aabb.get_point(left_leg_start_x, leg_y);
let leg_size = aabb.size().scale(leg_width, 1.0 - leg_y);
let right_leg_x = get_start_x(legs_width);
let right_leg_start = aabb.get_point(right_leg_x, leg_y);
let leg_size = aabb.size().scale(leg_width, foot_y - leg_y);

render_leg(renderer, options, left_leg_start, leg_size);
render_leg(renderer, options, right_leg_start, leg_size);

let left_foot_center = aabb.get_point(left_leg_start_x + leg_width / 2.0, 1.0);
let right_foot_center = aabb.get_point(right_leg_x + leg_width / 2.0, 1.0);
let left_foot_center = aabb.get_point(left_leg_start_x + leg_width / 2.0, foot_y);
let right_foot_center = aabb.get_point(right_leg_x + leg_width / 2.0, foot_y);
let foot_radius = config.body.get_foot_radius(body, aabb);
let offset = Orientation::from_degree(0.0);
let angle = Orientation::from_degree(180.0);
Expand Down
17 changes: 16 additions & 1 deletion rpg_tools_rendering/src/rendering/config/body/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::math::aabb2d::{get_start_x, AABB};
use crate::math::aabb2d::{get_end_x, get_start_x, AABB};
use crate::rendering::config::body::torso::TorsoConfig;
use crate::rendering::config::width::WidthConfig;
use rpg_tools_core::model::character::appearance::body::{Body, BodyShape};
Expand Down Expand Up @@ -91,6 +91,10 @@ impl BodyConfig {
self.get_torso_bottom() - 0.05
}

pub fn get_foot_y(&self) -> f32 {
1.0
}

pub fn get_distance_between_hands(&self, body: &Body) -> f32 {
self.get_torso_width(body) + 0.08
}
Expand All @@ -113,6 +117,17 @@ impl BodyConfig {
* self.get_torso_config(body.shape).legs_width
}

pub fn get_left_leg_x(&self, body: &Body) -> f32 {
let legs_width = self.get_legs_width(body);
let leg_width = self.get_leg_width(body);
get_end_x(legs_width) - leg_width
}

pub fn get_right_leg_x(&self, body: &Body) -> f32 {
let legs_width = self.get_legs_width(body);
get_start_x(legs_width)
}

pub fn get_torso_config(&self, shape: BodyShape) -> &TorsoConfig {
match shape {
BodyShape::Fat => &self.fat,
Expand Down

0 comments on commit 345290d

Please sign in to comment.