1
0
Fork 0
mirror of https://github.com/doukutsu-rs/doukutsu-rs synced 2024-09-28 21:19:24 +00:00

Improved texture scaling logic

This commit is contained in:
dawnDus 2022-03-06 11:01:23 -05:00
parent 05b9d9ebe0
commit 067bcc5c8b
No known key found for this signature in database
GPG key ID: 972AABDE81848F21

View file

@ -6,7 +6,7 @@ use itertools::Itertools;
use log::info;
use crate::common;
use crate::common::{FILE_TYPES, Rect};
use crate::common::{Rect, FILE_TYPES};
use crate::engine_constants::EngineConstants;
use crate::framework::backend::{BackendTexture, SpriteBatchCommand};
use crate::framework::context::Context;
@ -470,7 +470,20 @@ impl TextureSet {
let size = batch.dimensions();
let orig_dimensions = constants.tex_sizes.get(name).unwrap_or(&size);
let scale = orig_dimensions.0 as f32 / size.0 as f32;
let scale =
if f32::abs((orig_dimensions.0 as f32 / size.0 as f32) - (orig_dimensions.1 as f32 / size.1 as f32))
<= f32::EPSILON
{
orig_dimensions.0 as f32 / size.0 as f32
} else if constants.is_cs_plus && constants.base_paths.iter().any(|p| p.contains("/ogph")) {
1.0
} else if constants.is_cs_plus {
0.5
} else {
1.0
};
let width = (size.0 as f32 * scale) as _;
let height = (size.1 as f32 * scale) as _;