mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'sharp/os-x-resize' into 'master'
Fix window resizing on OS X. See merge request veloren/veloren!1256
This commit is contained in:
commit
c118765477
@ -77,6 +77,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Animals run/turn at different speeds
|
- Animals run/turn at different speeds
|
||||||
- Updated windowing library (winit 0.19 -> 0.22)
|
- Updated windowing library (winit 0.19 -> 0.22)
|
||||||
- Bow M2 is now a charged attack that scales the longer it's held
|
- Bow M2 is now a charged attack that scales the longer it's held
|
||||||
|
- Fixed window resizing on Mac OS X.
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
|
@ -1,76 +0,0 @@
|
|||||||
pub mod biped_large;
|
|
||||||
pub mod bird_medium;
|
|
||||||
pub mod bird_small;
|
|
||||||
pub mod character;
|
|
||||||
pub mod critter;
|
|
||||||
pub mod dragon;
|
|
||||||
pub mod fish_medium;
|
|
||||||
pub mod fish_small;
|
|
||||||
pub mod fixture;
|
|
||||||
pub mod golem;
|
|
||||||
pub mod object;
|
|
||||||
pub mod quadruped_medium;
|
|
||||||
pub mod quadruped_small;
|
|
||||||
pub mod quadruped_low;
|
|
||||||
|
|
||||||
use crate::render::FigureBoneData;
|
|
||||||
use vek::*;
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
|
||||||
pub struct Bone {
|
|
||||||
pub offset: Vec3<f32>,
|
|
||||||
pub ori: Quaternion<f32>,
|
|
||||||
pub scale: Vec3<f32>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for Bone {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self {
|
|
||||||
offset: Vec3::zero(),
|
|
||||||
ori: Quaternion::identity(),
|
|
||||||
scale: Vec3::broadcast(1.0 / 11.0),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Bone {
|
|
||||||
pub fn compute_base_matrix(&self) -> Mat4<f32> {
|
|
||||||
Mat4::<f32>::translation_3d(self.offset)
|
|
||||||
* Mat4::scaling_3d(self.scale)
|
|
||||||
* Mat4::from(self.ori)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Change the current bone to be more like `target`.
|
|
||||||
fn interpolate(&mut self, target: &Bone, dt: f32) {
|
|
||||||
// TODO: Make configurable.
|
|
||||||
let factor = (15.0 * dt).min(1.0);
|
|
||||||
self.offset += (target.offset - self.offset) * factor;
|
|
||||||
self.ori = vek::Slerp::slerp(self.ori, target.ori, factor);
|
|
||||||
self.scale += (target.scale - self.scale) * factor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait Skeleton: Send + Sync + 'static {
|
|
||||||
type Attr;
|
|
||||||
|
|
||||||
fn bone_count(&self) -> usize { 16 }
|
|
||||||
|
|
||||||
fn compute_matrices(&self) -> ([FigureBoneData; 16], Vec3<f32>);
|
|
||||||
|
|
||||||
/// Change the current skeleton to be more like `target`.
|
|
||||||
fn interpolate(&mut self, target: &Self, dt: f32);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub trait Animation {
|
|
||||||
type Skeleton: Skeleton;
|
|
||||||
type Dependency;
|
|
||||||
|
|
||||||
/// Returns a new skeleton that is generated by the animation.
|
|
||||||
fn update_skeleton(
|
|
||||||
skeleton: &Self::Skeleton,
|
|
||||||
dependency: Self::Dependency,
|
|
||||||
anim_time: f64,
|
|
||||||
rate: &mut f32,
|
|
||||||
skeleton_attr: &<<Self as Animation>::Skeleton as Skeleton>::Attr,
|
|
||||||
) -> Self::Skeleton;
|
|
||||||
}
|
|
@ -180,6 +180,7 @@ impl PlayState for SessionState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn tick(&mut self, global_state: &mut GlobalState, events: Vec<Event>) -> PlayStateResult {
|
fn tick(&mut self, global_state: &mut GlobalState, events: Vec<Event>) -> PlayStateResult {
|
||||||
|
// NOTE: Not strictly necessary, but useful for hotloading translation changes.
|
||||||
self.voxygen_i18n = load_expect::<VoxygenLocalization>(&i18n_asset_key(
|
self.voxygen_i18n = load_expect::<VoxygenLocalization>(&i18n_asset_key(
|
||||||
&global_state.settings.language.selected_language,
|
&global_state.settings.language.selected_language,
|
||||||
));
|
));
|
||||||
|
@ -896,15 +896,20 @@ impl Window {
|
|||||||
|
|
||||||
match event {
|
match event {
|
||||||
WindowEvent::CloseRequested => self.events.push(Event::Close),
|
WindowEvent::CloseRequested => self.events.push(Event::Close),
|
||||||
WindowEvent::Resized(winit::dpi::PhysicalSize { width, height }) => {
|
WindowEvent::Resized(physical) => {
|
||||||
let (mut color_view, mut depth_view) = self.renderer.win_views_mut();
|
let (mut color_view, mut depth_view) = self.renderer.win_views_mut();
|
||||||
|
self.window.resize(physical);
|
||||||
self.window.update_gfx(&mut color_view, &mut depth_view);
|
self.window.update_gfx(&mut color_view, &mut depth_view);
|
||||||
self.renderer.on_resize().unwrap();
|
self.renderer.on_resize().unwrap();
|
||||||
// TODO: update users of this event with the fact that it is now the physical
|
// TODO: update users of this event with the fact that it is now the physical
|
||||||
// size
|
// size
|
||||||
|
let winit::dpi::PhysicalSize { width, height } = physical;
|
||||||
self.events
|
self.events
|
||||||
.push(Event::Resize(Vec2::new(width as u32, height as u32)));
|
.push(Event::Resize(Vec2::new(width as u32, height as u32)));
|
||||||
},
|
},
|
||||||
|
WindowEvent::ScaleFactorChanged { .. } => {
|
||||||
|
// TODO: Handle properly!
|
||||||
|
},
|
||||||
WindowEvent::ReceivedCharacter(c) => self.events.push(Event::Char(c)),
|
WindowEvent::ReceivedCharacter(c) => self.events.push(Event::Char(c)),
|
||||||
WindowEvent::MouseInput { button, state, .. } => {
|
WindowEvent::MouseInput { button, state, .. } => {
|
||||||
if let (true, Some(game_inputs)) =
|
if let (true, Some(game_inputs)) =
|
||||||
|
Loading…
Reference in New Issue
Block a user