From 345290d530b18604210e86097a85e8a424c31aa3 Mon Sep 17 00:00:00 2001 From: Orchaldir Date: Sat, 23 Sep 2023 10:05:24 +0200 Subject: [PATCH] [#42] Start sole rendering --- rpg_tools_rendering/src/rendering/body/mod.rs | 12 ++++++------ .../src/rendering/config/body/mod.rs | 17 ++++++++++++++++- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/rpg_tools_rendering/src/rendering/body/mod.rs b/rpg_tools_rendering/src/rendering/body/mod.rs index 2b34e383..ebde5b6b 100644 --- a/rpg_tools_rendering/src/rendering/body/mod.rs +++ b/rpg_tools_rendering/src/rendering/body/mod.rs @@ -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); diff --git a/rpg_tools_rendering/src/rendering/config/body/mod.rs b/rpg_tools_rendering/src/rendering/config/body/mod.rs index 3779a0de..7d284c0b 100644 --- a/rpg_tools_rendering/src/rendering/config/body/mod.rs +++ b/rpg_tools_rendering/src/rendering/config/body/mod.rs @@ -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}; @@ -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 } @@ -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,