Skip to content

Commit

Permalink
[#73] Fix rendering order
Browse files Browse the repository at this point in the history
  • Loading branch information
Orchaldir committed Nov 5, 2023
1 parent 6d830bf commit 3925d7c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
6 changes: 5 additions & 1 deletion rpg_tools_rendering/src/rendering/character/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ use crate::rendering::character::hair::{
render_hair_back, render_hair_before_head_from_front, render_hair_behind_head_from_front,
};
use crate::rendering::config::RenderConfig;
use crate::rendering::equipment::{render_clothing, render_clothing_over_hands};
use crate::rendering::equipment::{
render_clothing, render_clothing_behind_body, render_clothing_over_hands,
};
use ear::render_ears;
use eye::render_eyes;
use head::render_head_shape;
Expand Down Expand Up @@ -46,6 +48,7 @@ pub fn render_character_from_front(
Appearance::Humanoid { body, head, .. } => {
let head_aabb = calculate_head_aabb(config, &inner);
render_head_behind_body_from_front(renderer, config, head, &head_aabb);
render_clothing_behind_body(renderer, config, &inner, &body, true);
render_body(renderer, config, &inner, body);
render_clothing(renderer, config, &inner, body, true);
render_hands(renderer, config, &inner, body);
Expand All @@ -67,6 +70,7 @@ pub fn render_character_from_back(
render_head_from_back(renderer, config, &head, &inner);
}
Appearance::Humanoid { body, head, .. } => {
render_clothing_behind_body(renderer, config, &inner, &body, false);
render_body(renderer, config, &inner, &body);
render_clothing(renderer, config, &inner, &body, false);
render_hands(renderer, config, &inner, &body);
Expand Down
13 changes: 12 additions & 1 deletion rpg_tools_rendering/src/rendering/equipment/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,18 @@ pub mod pants;
pub mod part;
pub mod shirt;

pub fn render_clothing_behind_body(
renderer: &mut dyn Renderer,
config: &RenderConfig,
aabb: &AABB,
body: &Body,
from_front: bool,
) {
if let Clothing::Simple { outerwear, .. } = &body.clothing {
render_outerwear_behind_body(renderer, config, aabb, body, outerwear, from_front);
}
}

pub fn render_clothing(
renderer: &mut dyn Renderer,
config: &RenderConfig,
Expand All @@ -33,7 +45,6 @@ pub fn render_clothing(
outerwear,
} = &body.clothing
{
render_outerwear_behind_body(renderer, config, aabb, body, outerwear, from_front);
render_shirt(renderer, config, aabb, body, shirt, from_front);

if footwear.style.is_over_pants() {
Expand Down

0 comments on commit 3925d7c

Please sign in to comment.