Fixed scaling of airships

This commit is contained in:
Joshua Barretto 2022-10-30 00:12:28 +01:00
parent 7e9474ab70
commit 0b4d3c9e20
5 changed files with 30 additions and 16 deletions

View File

@ -220,7 +220,7 @@ impl Body {
_ => 2.0, _ => 2.0,
}, },
Body::Ship(ship) if ship.has_water_thrust() => 0.1, Body::Ship(ship) if ship.has_water_thrust() => 0.1,
Body::Ship(_) => 0.035, Body::Ship(_) => 0.12,
Body::Arthropod(_) => 3.5, Body::Arthropod(_) => 3.5,
} }
} }

View File

@ -1102,19 +1102,21 @@ impl<'a> PhysicsData<'a> {
// TODO: Cache the matrices here to avoid recomputing // TODO: Cache the matrices here to avoid recomputing
let transform_last_from = Mat4::<f32>::translation_3d( let transform_last_from =
previous_cache_other.pos.unwrap_or(*pos_other).0 Mat4::<f32>::translation_3d(
- previous_cache.pos.unwrap_or(Pos(wpos)).0, previous_cache_other.pos.unwrap_or(*pos_other).0
) * Mat4::from( - previous_cache.pos.unwrap_or(Pos(wpos)).0,
previous_cache_other.ori, ) * Mat4::from(previous_cache_other.ori)
) * Mat4::<f32>::translation_3d( * Mat4::<f32>::scaling_3d(previous_cache_other.scale)
voxel_collider.translation, * Mat4::<f32>::translation_3d(
); voxel_collider.translation,
);
let transform_last_to = transform_last_from.inverted(); let transform_last_to = transform_last_from.inverted();
let transform_from = let transform_from =
Mat4::<f32>::translation_3d(pos_other.0 - wpos) Mat4::<f32>::translation_3d(pos_other.0 - wpos)
* Mat4::from(ori_other.to_quat()) * Mat4::from(ori_other.to_quat())
* Mat4::<f32>::scaling_3d(previous_cache_other.scale)
* Mat4::<f32>::translation_3d( * Mat4::<f32>::translation_3d(
voxel_collider.translation, voxel_collider.translation,
); );

View File

@ -351,7 +351,6 @@ impl StateExt for State {
.with(body.density()) .with(body.density())
.with(make_collider(ship)) .with(make_collider(ship))
.with(body) .with(body)
.with(comp::Scale(comp::ship::AIRSHIP_SCALE))
.with(comp::Controller::default()) .with(comp::Controller::default())
.with(Inventory::with_empty()) .with(Inventory::with_empty())
.with(comp::CharacterState::default()) .with(comp::CharacterState::default())

View File

@ -31,7 +31,8 @@ impl Skeleton for ShipSkeleton {
buf: &mut [FigureBoneData; super::MAX_BONE_COUNT], buf: &mut [FigureBoneData; super::MAX_BONE_COUNT],
body: Self::Body, body: Self::Body,
) -> Offsets { ) -> Offsets {
let scale_mat = Mat4::scaling_3d(1.0 / 11.0); // Ships are normal scale
let scale_mat = Mat4::scaling_3d(1.0);
let bone0_mat = base_mat * scale_mat * Mat4::<f32>::from(self.bone0); let bone0_mat = base_mat * scale_mat * Mat4::<f32>::from(self.bone0);

View File

@ -33,7 +33,7 @@ use common::{
comp::{ comp::{
inventory::slot::EquipSlot, inventory::slot::EquipSlot,
item::{tool::AbilityContext, Hands, ItemKind, ToolKind}, item::{tool::AbilityContext, Hands, ItemKind, ToolKind},
Body, CharacterState, Collider, Controller, Health, Inventory, Item, ItemKey, Last, ship, Body, CharacterState, Collider, Controller, Health, Inventory, Item, ItemKey, Last,
LightAnimation, LightEmitter, Ori, PhysicsState, PoiseState, Pos, Scale, SkillSet, Stance, LightAnimation, LightEmitter, Ori, PhysicsState, PoiseState, Pos, Scale, SkillSet, Stance,
Vel, Vel,
}, },
@ -6709,10 +6709,22 @@ impl FigureMgr {
} { } {
let model_entry = model_entry?; let model_entry = model_entry?;
let figure_low_detail_distance = let figure_low_detail_distance = figure_lod_render_distance
figure_lod_render_distance * scale.map_or(1.0, |s| s.0) * 0.75; * if matches!(body, Body::Ship(_)) {
let figure_mid_detail_distance = ship::AIRSHIP_SCALE
figure_lod_render_distance * scale.map_or(1.0, |s| s.0) * 0.5; } else {
1.0
}
* scale.map_or(1.0, |s| s.0)
* 0.75;
let figure_mid_detail_distance = figure_lod_render_distance
* if matches!(body, Body::Ship(_)) {
ship::AIRSHIP_SCALE
} else {
1.0
}
* scale.map_or(1.0, |s| s.0)
* 0.5;
let model = if pos.distance_squared(cam_pos) > figure_low_detail_distance.powi(2) { let model = if pos.distance_squared(cam_pos) > figure_low_detail_distance.powi(2) {
model_entry.lod_model(2) model_entry.lod_model(2)