Abstract over simd vs. repr_c vectors.

Also some minor improvements to Event size.
This commit is contained in:
Joshua Yanovski 2020-08-03 04:55:31 +02:00
parent d4d4956e92
commit 125d7fc6c4
87 changed files with 379 additions and 297 deletions

View File

@ -1,6 +1,8 @@
use super::{super::Animation, BipedLargeSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
BipedLargeSkeleton, SkeletonAttr,
};
use std::{f32::consts::PI, ops::Mul};
use vek::*;
pub struct IdleAnimation;

View File

@ -1,6 +1,6 @@
use super::{super::Animation, BipedLargeSkeleton, SkeletonAttr};
//use std::f32::consts::PI;
use vek::*;
use super::super::vek::*;
pub struct JumpAnimation;

View File

@ -8,9 +8,8 @@ pub use self::{
idle::IdleAnimation, jump::JumpAnimation, run::RunAnimation, wield::WieldAnimation,
};
use super::{Bone, FigureBoneData, Skeleton};
use super::{vek::Vec3, Bone, FigureBoneData, Skeleton};
use common::comp::{self};
use vek::Vec3;
#[derive(Clone, Default)]
pub struct BipedLargeSkeleton {

View File

@ -1,6 +1,8 @@
use super::{super::Animation, BipedLargeSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
BipedLargeSkeleton, SkeletonAttr,
};
use std::f32::consts::PI;
use vek::*;
pub struct RunAnimation;

View File

@ -1,6 +1,8 @@
use super::{super::Animation, BipedLargeSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
BipedLargeSkeleton, SkeletonAttr,
};
use std::{f32::consts::PI, ops::Mul};
use vek::*;
pub struct WieldAnimation;

View File

@ -1,6 +1,8 @@
use super::{super::Animation, BirdMediumSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
BirdMediumSkeleton, SkeletonAttr,
};
use std::ops::Mul;
use vek::*;
pub struct FeedAnimation;

View File

@ -1,6 +1,8 @@
use super::{super::Animation, BirdMediumSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
BirdMediumSkeleton, SkeletonAttr,
};
use std::f32::consts::PI;
use vek::*;
pub struct FlyAnimation;

View File

@ -1,6 +1,8 @@
use super::{super::Animation, BirdMediumSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
BirdMediumSkeleton, SkeletonAttr,
};
use std::ops::Mul;
use vek::*;
pub struct IdleAnimation;

View File

@ -6,9 +6,8 @@ pub mod run;
// Reexports
pub use self::{feed::FeedAnimation, fly::FlyAnimation, idle::IdleAnimation, run::RunAnimation};
use super::{Bone, FigureBoneData, Skeleton};
use super::{vek::Vec3, Bone, FigureBoneData, Skeleton};
use common::comp::{self};
use vek::Vec3;
#[derive(Clone, Default)]
pub struct BirdMediumSkeleton {

View File

@ -1,6 +1,8 @@
use super::{super::Animation, BirdMediumSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
BirdMediumSkeleton, SkeletonAttr,
};
use std::f32::consts::PI;
use vek::*;
pub struct RunAnimation;

View File

@ -1,6 +1,6 @@
use super::{super::Animation, BirdSmallSkeleton, SkeletonAttr};
//use std::{f32::consts::PI, ops::Mul};
use vek::*;
use super::super::vek::*;
pub struct IdleAnimation;

View File

@ -1,6 +1,6 @@
use super::{super::Animation, BirdSmallSkeleton, SkeletonAttr};
//use std::f32::consts::PI;
use vek::*;
use super::super::vek::*;
pub struct JumpAnimation;

View File

@ -5,9 +5,8 @@ pub mod run;
// Reexports
pub use self::{idle::IdleAnimation, jump::JumpAnimation, run::RunAnimation};
use super::{Bone, FigureBoneData, Skeleton};
use super::{vek::Vec3, Bone, FigureBoneData, Skeleton};
use common::comp::{self};
use vek::Vec3;
#[derive(Clone)]
pub struct BirdSmallSkeleton {

View File

@ -1,6 +1,6 @@
use super::{super::Animation, BirdSmallSkeleton, SkeletonAttr};
//use std::{f32::consts::PI, ops::Mul};
use vek::*;
use super::super::vek::*;
pub struct RunAnimation;

View File

@ -1,7 +1,9 @@
use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr,
};
use common::comp::item::{Hands, ToolKind};
use std::f32::consts::PI;
use vek::*;
pub struct AlphaAnimation;

View File

@ -1,6 +1,8 @@
use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr,
};
use common::comp::item::{Hands, ToolKind};
use vek::*;
pub struct BetaAnimation;

View File

@ -1,7 +1,9 @@
use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr,
};
use common::comp::item::{Hands, ToolKind};
use std::{f32::consts::PI, ops::Mul};
use vek::*;
pub struct Input {
pub attack: bool,

View File

@ -1,7 +1,9 @@
use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr,
};
use common::comp::item::{Hands, ToolKind};
use std::{f32::consts::PI, ops::Mul};
use vek::*;
pub struct Input {
pub attack: bool,

View File

@ -1,7 +1,9 @@
use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr,
};
use common::comp::item::{Hands, ToolKind};
use std::f32::consts::PI;
use vek::*;
pub struct ChargeAnimation;
@ -62,7 +64,7 @@ impl Animation for ChargeAnimation {
let ori: Vec2<f32> = Vec2::from(orientation);
let last_ori = Vec2::from(last_ori);
let tilt = if Vec2::new(ori, last_ori)
let tilt = if ::vek::Vec2::new(ori, last_ori)
.map(|o| o.magnitude_squared())
.map(|m| m > 0.001 && m.is_finite())
.reduce_and()

View File

@ -1,7 +1,9 @@
use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr,
};
use common::comp::item::{Hands, ToolKind};
use std::f32::consts::PI;
use vek::*;
pub struct ClimbAnimation;

View File

@ -1,7 +1,9 @@
use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr,
};
use common::comp::item::{Hands, ToolKind};
use std::{f32::consts::PI, ops::Mul};
use vek::*;
pub struct DanceAnimation;

View File

@ -1,6 +1,8 @@
use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr,
};
use common::comp::item::{Hands, ToolKind};
use vek::*;
pub struct Input {
pub attack: bool,

View File

@ -2,7 +2,7 @@ use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
use common::comp::item::{Hands, ToolKind};
use std::{f32::consts::PI, ops::Mul};
use vek::*;
use super::super::vek::*;
pub struct EquipAnimation;

View File

@ -1,7 +1,9 @@
use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr,
};
use common::comp::item::{Hands, ToolKind};
use std::{f32::consts::PI, ops::Mul};
use vek::*;
pub struct GlideWieldAnimation;
@ -96,7 +98,7 @@ impl Animation for GlideWieldAnimation {
let ori: Vec2<f32> = Vec2::from(orientation);
let last_ori = Vec2::from(last_ori);
let tilt = if Vec2::new(ori, last_ori)
let tilt = if ::vek::Vec2::new(ori, last_ori)
.map(|o| o.magnitude_squared())
.map(|m| m > 0.001 && m.is_finite())
.reduce_and()

View File

@ -1,7 +1,9 @@
use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr,
};
use common::comp::item::{Hands, ToolKind};
use std::{f32::consts::PI, ops::Mul};
use vek::*;
pub struct GlidingAnimation;
@ -56,7 +58,7 @@ impl Animation for GlidingAnimation {
let ori: Vec2<f32> = Vec2::from(orientation);
let last_ori = Vec2::from(last_ori);
let tilt = if Vec2::new(ori, last_ori)
let tilt = if ::vek::Vec2::new(ori, last_ori)
.map(|o| o.magnitude_squared())
.map(|m| m > 0.0001 && m.is_finite())
.reduce_and()

View File

@ -1,7 +1,9 @@
use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr,
};
use common::comp::item::{Hands, ToolKind};
use std::f32::consts::PI;
use vek::*;
pub struct IdleAnimation;

View File

@ -1,7 +1,9 @@
use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr,
};
use common::comp::item::{Hands, ToolKind};
use std::f32::consts::PI;
use vek::*;
pub struct JumpAnimation;
impl Animation for JumpAnimation {
@ -41,7 +43,7 @@ impl Animation for JumpAnimation {
let ori: Vec2<f32> = Vec2::from(orientation);
let last_ori = Vec2::from(last_ori);
let tilt = if Vec2::new(ori, last_ori)
let tilt = if ::vek::Vec2::new(ori, last_ori)
.map(|o| o.magnitude_squared())
.map(|m| m > 0.001 && m.is_finite())
.reduce_and()

View File

@ -1,7 +1,7 @@
use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
use common::comp::item::{Hands, ToolKind};
/* use std::f32::consts::PI; */
use vek::*;
use super::super::vek::*;
pub struct LeapAnimation;

View File

@ -33,9 +33,11 @@ pub use self::{
stand::StandAnimation, swim::SwimAnimation, wield::WieldAnimation,
};
use super::{Bone, FigureBoneData, Skeleton};
use super::{
vek::{Vec3, Vec4},
Bone, FigureBoneData, Skeleton,
};
use common::comp;
use vek::{Vec3, Vec4};
#[derive(Clone, Default)]
pub struct CharacterSkeleton {

View File

@ -1,7 +1,9 @@
use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr,
};
use common::comp::item::{Hands, ToolKind};
use std::f32::consts::PI;
use vek::*;
pub struct RollAnimation;
@ -33,7 +35,7 @@ impl Animation for RollAnimation {
let spin = anim_time as f32;
let ori: Vec2<f32> = Vec2::from(orientation);
let last_ori = Vec2::from(last_ori);
let tilt = if Vec2::new(ori, last_ori)
let tilt = if ::vek::Vec2::new(ori, last_ori)
.map(|o| o.magnitude_squared())
.map(|m| m > 0.0001 && m.is_finite())
.reduce_and()

View File

@ -1,7 +1,9 @@
use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr,
};
use common::comp::item::{Hands, ToolKind};
use std::{f32::consts::PI, ops::Mul};
use vek::*;
pub struct RunAnimation;
@ -98,7 +100,7 @@ impl Animation for RunAnimation {
let ori: Vec2<f32> = Vec2::from(orientation);
let last_ori = Vec2::from(last_ori);
let tilt = if Vec2::new(ori, last_ori)
let tilt = if ::vek::Vec2::new(ori, last_ori)
.map(|o| o.magnitude_squared())
.map(|m| m > 0.001 && m.is_finite())
.reduce_and()

View File

@ -1,6 +1,8 @@
use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr,
};
use common::comp::item::{Hands, ToolKind};
use vek::*;
pub struct ShootAnimation;

View File

@ -1,7 +1,9 @@
use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr,
};
use common::comp::item::{Hands, ToolKind};
use std::{f32::consts::PI, ops::Mul};
use vek::*;
pub struct SitAnimation;

View File

@ -1,7 +1,9 @@
use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr,
};
use common::comp::item::{Hands, ToolKind};
use std::f32::consts::PI;
use vek::*;
pub struct Input {
pub attack: bool,

View File

@ -1,7 +1,9 @@
use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr,
};
use common::comp::item::{Hands, ToolKind};
use std::f32::consts::PI;
use vek::*;
pub struct SpinMeleeAnimation;

View File

@ -1,7 +1,9 @@
use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr,
};
use common::comp::item::{Hands, ToolKind};
use std::{f32::consts::PI, ops::Mul};
use vek::*;
pub struct StandAnimation;

View File

@ -1,7 +1,9 @@
use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr,
};
use common::comp::item::{Hands, ToolKind};
use std::{f32::consts::PI, ops::Mul};
use vek::*;
pub struct SwimAnimation;
@ -59,7 +61,7 @@ impl Animation for SwimAnimation {
);
let ori: Vec2<f32> = Vec2::from(orientation);
let last_ori = Vec2::from(last_ori);
let tilt = if Vec2::new(ori, last_ori)
let tilt = if ::vek::Vec2::new(ori, last_ori)
.map(|o| o.magnitude_squared())
.map(|m| m > 0.001 && m.is_finite())
.reduce_and()

View File

@ -1,7 +1,9 @@
use super::{super::Animation, CharacterSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
CharacterSkeleton, SkeletonAttr,
};
use common::comp::item::{Hands, ToolKind};
use std::{f32::consts::PI, ops::Mul};
use vek::*;
pub struct WieldAnimation;

View File

@ -1,7 +1,7 @@
use super::{super::Animation, CritterAttr, CritterSkeleton};
//use std::{f32::consts::PI, ops::Mul};
use super::super::vek::*;
use std::{f32::consts::PI, ops::Mul};
use vek::*;
pub struct IdleAnimation;

View File

@ -1,6 +1,6 @@
use super::{super::Animation, CritterAttr, CritterSkeleton};
//use std::f32::consts::PI;
use vek::*;
use super::super::vek::*;
pub struct JumpAnimation;

View File

@ -5,9 +5,8 @@ pub mod run;
// Reexports
pub use self::{idle::IdleAnimation, jump::JumpAnimation, run::RunAnimation};
use super::{Bone, FigureBoneData, Skeleton};
use super::{vek::Vec3, Bone, FigureBoneData, Skeleton};
use common::comp::{self};
use vek::Vec3;
#[derive(Clone, Default)]
pub struct CritterSkeleton {

View File

@ -1,7 +1,7 @@
use super::{super::Animation, CritterAttr, CritterSkeleton};
//use std::{f32::consts::PI, ops::Mul};
use super::super::vek::*;
use std::f32::consts::PI;
use vek::*;
pub struct RunAnimation;

View File

@ -1,6 +1,8 @@
use super::{super::Animation, DragonSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
DragonSkeleton, SkeletonAttr,
};
use std::f32::consts::PI;
use vek::*;
pub struct FlyAnimation;

View File

@ -1,6 +1,8 @@
use super::{super::Animation, DragonSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
DragonSkeleton, SkeletonAttr,
};
use std::{f32::consts::PI, ops::Mul};
use vek::*;
pub struct IdleAnimation;

View File

@ -5,9 +5,8 @@ pub mod run;
// Reexports
pub use self::{fly::FlyAnimation, idle::IdleAnimation, run::RunAnimation};
use super::{Bone, FigureBoneData, Skeleton};
use super::{vek::Vec3, Bone, FigureBoneData, Skeleton};
use common::comp::{self};
use vek::Vec3;
#[derive(Clone, Default)]
pub struct DragonSkeleton {

View File

@ -1,6 +1,8 @@
use super::{super::Animation, DragonSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
DragonSkeleton, SkeletonAttr,
};
use std::f32::consts::PI;
use vek::*;
pub struct RunAnimation;
@ -37,7 +39,7 @@ impl Animation for RunAnimation {
//
let ori: Vec2<f32> = Vec2::from(orientation);
let last_ori = Vec2::from(last_ori);
let tilt = if Vec2::new(ori, last_ori)
let tilt = if ::vek::Vec2::new(ori, last_ori)
.map(|o| o.magnitude_squared())
.map(|m| m > 0.001 && m.is_finite())
.reduce_and()

View File

@ -1,6 +1,6 @@
use super::{super::Animation, FishMediumSkeleton, SkeletonAttr};
//use std::{f32::consts::PI, ops::Mul};
use vek::*;
use super::super::vek::*;
pub struct IdleAnimation;

View File

@ -1,6 +1,6 @@
use super::{super::Animation, FishMediumSkeleton, SkeletonAttr};
//use std::f32::consts::PI;
use vek::*;
use super::super::vek::*;
pub struct JumpAnimation;

View File

@ -5,9 +5,8 @@ pub mod run;
// Reexports
pub use self::{idle::IdleAnimation, jump::JumpAnimation, run::RunAnimation};
use super::{Bone, FigureBoneData, Skeleton};
use super::{vek::Vec3, Bone, FigureBoneData, Skeleton};
use common::comp::{self};
use vek::Vec3;
#[derive(Clone)]
pub struct FishMediumSkeleton {

View File

@ -1,6 +1,6 @@
use super::{super::Animation, FishMediumSkeleton, SkeletonAttr};
//use std::f32::consts::PI;
use vek::*;
use super::super::vek::*;
pub struct RunAnimation;

View File

@ -1,6 +1,6 @@
use super::{super::Animation, FishSmallSkeleton, SkeletonAttr};
//use std::{f32::consts::PI, ops::Mul};
use vek::*;
use super::super::vek::*;
pub struct IdleAnimation;

View File

@ -1,6 +1,6 @@
use super::{super::Animation, FishSmallSkeleton, SkeletonAttr};
//use std::f32::consts::PI;
use vek::*;
use super::super::vek::*;
pub struct JumpAnimation;

View File

@ -5,9 +5,8 @@ pub mod run;
// Reexports
pub use self::{idle::IdleAnimation, jump::JumpAnimation, run::RunAnimation};
use super::{Bone, FigureBoneData, Skeleton};
use super::{vek::Vec3, Bone, FigureBoneData, Skeleton};
use common::comp::{self};
use vek::Vec3;
#[derive(Clone)]
pub struct FishSmallSkeleton {

View File

@ -1,6 +1,6 @@
use super::{super::Animation, FishSmallSkeleton, SkeletonAttr};
//use std::{f32::consts::PI, ops::Mul};
use vek::*;
use super::super::vek::*;
pub struct RunAnimation;

View File

@ -1,5 +1,7 @@
use super::{FigureBoneData, Skeleton};
use vek::Vec3;
use super::{
vek::{Mat4, Vec3},
FigureBoneData, Skeleton,
};
#[derive(Clone)]
pub struct FixtureSkeleton;
@ -24,22 +26,22 @@ impl Skeleton for FixtureSkeleton {
fn compute_matrices_inner(&self) -> ([FigureBoneData; 16], Vec3<f32>) {
(
[
FigureBoneData::new(vek::Mat4::identity()), // <-- This is actually a bone!
FigureBoneData::new(vek::Mat4::identity()),
FigureBoneData::new(vek::Mat4::identity()),
FigureBoneData::new(vek::Mat4::identity()),
FigureBoneData::new(vek::Mat4::identity()),
FigureBoneData::new(vek::Mat4::identity()),
FigureBoneData::new(vek::Mat4::identity()),
FigureBoneData::new(vek::Mat4::identity()),
FigureBoneData::new(vek::Mat4::identity()),
FigureBoneData::new(vek::Mat4::identity()),
FigureBoneData::new(vek::Mat4::identity()),
FigureBoneData::new(vek::Mat4::identity()),
FigureBoneData::new(vek::Mat4::identity()),
FigureBoneData::new(vek::Mat4::identity()),
FigureBoneData::new(vek::Mat4::identity()),
FigureBoneData::new(vek::Mat4::identity()),
FigureBoneData::new(Mat4::identity()), // <-- This is actually a bone!
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
],
Vec3::default(),
)

View File

@ -1,6 +1,8 @@
use super::{super::Animation, GolemSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
GolemSkeleton, SkeletonAttr,
};
use std::{f32::consts::PI, ops::Mul};
use vek::*;
pub struct IdleAnimation;

View File

@ -1,6 +1,6 @@
use super::{super::Animation, GolemSkeleton, SkeletonAttr};
//use std::f32::consts::PI;
use vek::*;
use super::super::vek::*;
pub struct JumpAnimation;

View File

@ -5,9 +5,8 @@ pub mod run;
// Reexports
pub use self::{idle::IdleAnimation, jump::JumpAnimation, run::RunAnimation};
use super::{Bone, FigureBoneData, Skeleton};
use super::{vek::Vec3, Bone, FigureBoneData, Skeleton};
use common::comp::{self};
use vek::Vec3;
#[derive(Clone, Default)]
pub struct GolemSkeleton {

View File

@ -1,6 +1,8 @@
use super::{super::Animation, GolemSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
GolemSkeleton, SkeletonAttr,
};
use std::f32::consts::PI;
use vek::*;
pub struct RunAnimation;

View File

@ -16,13 +16,15 @@ pub mod object;
pub mod quadruped_low;
pub mod quadruped_medium;
pub mod quadruped_small;
pub mod vek;
#[cfg(feature = "use-dyn-lib")]
pub use dyn_lib::init;
#[cfg(feature = "use-dyn-lib")]
use std::ffi::CStr;
use vek::*;
use self::vek::*;
// TODO: replace with inner type everywhere
pub struct FigureBoneData(pub Mat4<f32>);

View File

@ -1,5 +1,4 @@
use super::{FigureBoneData, Skeleton};
use vek::*;
use super::{vek::*, FigureBoneData, Skeleton};
#[derive(Clone)]
pub struct ObjectSkeleton;
@ -25,21 +24,21 @@ impl Skeleton for ObjectSkeleton {
(
[
FigureBoneData::new(Mat4::scaling_3d(Vec3::broadcast(SCALE))),
FigureBoneData::new(vek::Mat4::identity()),
FigureBoneData::new(vek::Mat4::identity()),
FigureBoneData::new(vek::Mat4::identity()),
FigureBoneData::new(vek::Mat4::identity()),
FigureBoneData::new(vek::Mat4::identity()),
FigureBoneData::new(vek::Mat4::identity()),
FigureBoneData::new(vek::Mat4::identity()),
FigureBoneData::new(vek::Mat4::identity()),
FigureBoneData::new(vek::Mat4::identity()),
FigureBoneData::new(vek::Mat4::identity()),
FigureBoneData::new(vek::Mat4::identity()),
FigureBoneData::new(vek::Mat4::identity()),
FigureBoneData::new(vek::Mat4::identity()),
FigureBoneData::new(vek::Mat4::identity()),
FigureBoneData::new(vek::Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
FigureBoneData::new(Mat4::identity()),
],
Vec3::default(),
)

View File

@ -1,6 +1,8 @@
use super::{super::Animation, QuadrupedLowSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
QuadrupedLowSkeleton, SkeletonAttr,
};
use std::f32::consts::PI;
use vek::*;
pub struct AlphaAnimation;

View File

@ -1,6 +1,8 @@
use super::{super::Animation, QuadrupedLowSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
QuadrupedLowSkeleton, SkeletonAttr,
};
use std::{f32::consts::PI, ops::Mul};
use vek::*;
pub struct IdleAnimation;

View File

@ -1,5 +1,7 @@
use super::{super::Animation, QuadrupedLowSkeleton, SkeletonAttr};
use vek::*;
use super::{
super::{vek::*, Animation},
QuadrupedLowSkeleton, SkeletonAttr,
};
pub struct JumpAnimation;

View File

@ -8,9 +8,8 @@ pub use self::{
alpha::AlphaAnimation, idle::IdleAnimation, jump::JumpAnimation, run::RunAnimation,
};
use super::{Bone, FigureBoneData, Skeleton};
use super::{vek::Vec3, Bone, FigureBoneData, Skeleton};
use common::comp::{self};
use vek::Vec3;
#[derive(Clone, Default)]
pub struct QuadrupedLowSkeleton {

View File

@ -1,6 +1,8 @@
use super::{super::Animation, QuadrupedLowSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
QuadrupedLowSkeleton, SkeletonAttr,
};
use std::f32::consts::PI;
use vek::*;
pub struct RunAnimation;
@ -72,7 +74,7 @@ impl Animation for RunAnimation {
let ori: Vec2<f32> = Vec2::from(orientation);
let last_ori = Vec2::from(last_ori);
let tilt = if Vec2::new(ori, last_ori)
let tilt = if ::vek::Vec2::new(ori, last_ori)
.map(|o| o.magnitude_squared())
.map(|m| m > 0.001 && m.is_finite())
.reduce_and()

View File

@ -1,6 +1,8 @@
use super::{super::Animation, QuadrupedMediumSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
QuadrupedMediumSkeleton, SkeletonAttr,
};
use std::f32::consts::PI;
use vek::*;
pub struct AlphaAnimation;

View File

@ -1,6 +1,8 @@
use super::{super::Animation, QuadrupedMediumSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
QuadrupedMediumSkeleton, SkeletonAttr,
};
use std::{f32::consts::PI, ops::Mul};
use vek::*;
pub struct IdleAnimation;

View File

@ -1,5 +1,7 @@
use super::{super::Animation, QuadrupedMediumSkeleton, SkeletonAttr};
use vek::*;
use super::{
super::{vek::*, Animation},
QuadrupedMediumSkeleton, SkeletonAttr,
};
pub struct JumpAnimation;

View File

@ -8,9 +8,8 @@ pub use self::{
alpha::AlphaAnimation, idle::IdleAnimation, jump::JumpAnimation, run::RunAnimation,
};
use super::{Bone, FigureBoneData, Skeleton};
use super::{vek::Vec3, Bone, FigureBoneData, Skeleton};
use common::comp::{self};
use vek::Vec3;
#[derive(Clone, Default)]
pub struct QuadrupedMediumSkeleton {

View File

@ -1,6 +1,8 @@
use super::{super::Animation, QuadrupedMediumSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
QuadrupedMediumSkeleton, SkeletonAttr,
};
use std::f32::consts::PI;
use vek::*;
pub struct RunAnimation;
@ -59,7 +61,7 @@ impl Animation for RunAnimation {
//
let ori: Vec2<f32> = Vec2::from(orientation);
let last_ori = Vec2::from(last_ori);
let tilt = if Vec2::new(ori, last_ori)
let tilt = if ::vek::Vec2::new(ori, last_ori)
.map(|o| o.magnitude_squared())
.map(|m| m > 0.001 && m.is_finite())
.reduce_and()

View File

@ -1,6 +1,8 @@
use super::{super::Animation, QuadrupedSmallSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
QuadrupedSmallSkeleton, SkeletonAttr,
};
use std::{f32::consts::PI, ops::Mul};
use vek::*;
pub struct FeedAnimation;

View File

@ -1,6 +1,8 @@
use super::{super::Animation, QuadrupedSmallSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
QuadrupedSmallSkeleton, SkeletonAttr,
};
use std::{f32::consts::PI, ops::Mul};
use vek::*;
pub struct IdleAnimation;

View File

@ -1,5 +1,7 @@
use super::{super::Animation, QuadrupedSmallSkeleton, SkeletonAttr};
use vek::*;
use super::{
super::{vek::*, Animation},
QuadrupedSmallSkeleton, SkeletonAttr,
};
pub struct JumpAnimation;

View File

@ -6,9 +6,8 @@ pub mod run;
// Reexports
pub use self::{feed::FeedAnimation, idle::IdleAnimation, jump::JumpAnimation, run::RunAnimation};
use super::{Bone, FigureBoneData, Skeleton};
use super::{vek::Vec3, Bone, FigureBoneData, Skeleton};
use common::comp::{self};
use vek::Vec3;
#[derive(Clone, Default)]
pub struct QuadrupedSmallSkeleton {

View File

@ -1,6 +1,8 @@
use super::{super::Animation, QuadrupedSmallSkeleton, SkeletonAttr};
use super::{
super::{vek::*, Animation},
QuadrupedSmallSkeleton, SkeletonAttr,
};
use std::f32::consts::PI;
use vek::*;
pub struct RunAnimation;
@ -35,7 +37,7 @@ impl Animation for RunAnimation {
let ori: Vec2<f32> = Vec2::from(orientation);
let last_ori = Vec2::from(last_ori);
let tilt = if Vec2::new(ori, last_ori)
let tilt = if vek::Vec2::new(ori, last_ori)
.map(|o| o.magnitude_squared())
.map(|m| m > 0.001 && m.is_finite())
.reduce_and()

View File

@ -288,15 +288,15 @@ pub enum Event {
UseSlot(comp::slot::Slot),
SwapSlots(comp::slot::Slot, comp::slot::Slot),
DropSlot(comp::slot::Slot),
ChangeHotbarState(HotbarState),
ChangeHotbarState(Box<HotbarState>),
Ability3(bool),
Logout,
Quit,
ChangeLanguage(LanguageMetadata),
ChangeLanguage(Box<LanguageMetadata>),
ChangeBinding(GameInput),
ResetBindings,
ChangeFreeLookBehavior(PressBehavior),
ChangeRenderMode(RenderMode),
ChangeRenderMode(Box<RenderMode>),
ChangeAutoWalkBehavior(PressBehavior),
ChangeStopAutoWalkOnInput(bool),
CraftRecipe(String),
@ -2006,10 +2006,10 @@ impl Hud {
events.push(Event::SwapSlots(a, b));
} else if let (Inventory(i), Hotbar(h)) = (a, b) {
self.hotbar.add_inventory_link(h, i.0);
events.push(Event::ChangeHotbarState(self.hotbar.to_owned()));
events.push(Event::ChangeHotbarState(Box::new(self.hotbar.to_owned())));
} else if let (Hotbar(a), Hotbar(b)) = (a, b) {
self.hotbar.swap(a, b);
events.push(Event::ChangeHotbarState(self.hotbar.to_owned()));
events.push(Event::ChangeHotbarState(Box::new(self.hotbar.to_owned())));
}
},
slot::Event::Dropped(from) => {
@ -2018,7 +2018,7 @@ impl Hud {
events.push(Event::DropSlot(from));
} else if let Hotbar(h) = from {
self.hotbar.clear_slot(h);
events.push(Event::ChangeHotbarState(self.hotbar.to_owned()));
events.push(Event::ChangeHotbarState(Box::new(self.hotbar.to_owned())));
}
},
slot::Event::Used(from) => {

View File

@ -245,7 +245,7 @@ pub enum Event {
AdjustGamma(f32),
AdjustWindowSize([u16; 2]),
ToggleFullscreen,
ChangeRenderMode(RenderMode),
ChangeRenderMode(Box<RenderMode>),
AdjustMusicVolume(f32),
AdjustSfxVolume(f32),
ChangeAudioDevice(String),
@ -260,7 +260,7 @@ pub enum Event {
SctDamageBatch(bool),
SpeechBubbleDarkMode(bool),
SpeechBubbleIcon(bool),
ChangeLanguage(LanguageMetadata),
ChangeLanguage(Box<LanguageMetadata>),
ChangeBinding(GameInput),
ResetBindings,
ChangeFreeLookBehavior(PressBehavior),
@ -1226,7 +1226,9 @@ impl<'a> Widget for SettingsWindow<'a> {
.label_font_id(self.fonts.cyri.conrod_id)
.set(state.ids.languages_list, ui)
{
events.push(Event::ChangeLanguage(language_list[clicked].to_owned()));
events.push(Event::ChangeLanguage(Box::new(
language_list[clicked].to_owned(),
)));
}
}
@ -1942,7 +1944,7 @@ impl<'a> Widget for SettingsWindow<'a> {
.color(TEXT_COLOR)
.set(state.ids.figure_dist_value, ui);
let render_mode = self.global_state.settings.graphics.render_mode;
let render_mode = &self.global_state.settings.graphics.render_mode;
// AaMode
Text::new(&self.localized_strings.get("hud.settings.antialiasing_mode"))
@ -1980,10 +1982,10 @@ impl<'a> Widget for SettingsWindow<'a> {
.down_from(state.ids.aa_mode_text, 8.0)
.set(state.ids.aa_mode_list, ui)
{
events.push(Event::ChangeRenderMode(RenderMode {
events.push(Event::ChangeRenderMode(Box::new(RenderMode {
aa: mode_list[clicked],
..render_mode
}));
..render_mode.clone()
})));
}
// CloudMode
@ -2017,10 +2019,10 @@ impl<'a> Widget for SettingsWindow<'a> {
.down_from(state.ids.cloud_mode_text, 8.0)
.set(state.ids.cloud_mode_list, ui)
{
events.push(Event::ChangeRenderMode(RenderMode {
events.push(Event::ChangeRenderMode(Box::new(RenderMode {
cloud: mode_list[clicked],
..render_mode
}));
..render_mode.clone()
})));
}
// FluidMode
@ -2056,10 +2058,10 @@ impl<'a> Widget for SettingsWindow<'a> {
.down_from(state.ids.fluid_mode_text, 8.0)
.set(state.ids.fluid_mode_list, ui)
{
events.push(Event::ChangeRenderMode(RenderMode {
events.push(Event::ChangeRenderMode(Box::new(RenderMode {
fluid: mode_list[clicked],
..render_mode
}));
..render_mode.clone()
})));
}
// LightingMode
@ -2102,10 +2104,10 @@ impl<'a> Widget for SettingsWindow<'a> {
.down_from(state.ids.lighting_mode_text, 8.0)
.set(state.ids.lighting_mode_list, ui)
{
events.push(Event::ChangeRenderMode(RenderMode {
events.push(Event::ChangeRenderMode(Box::new(RenderMode {
lighting: mode_list[clicked],
..render_mode
}));
..render_mode.clone()
})));
}
// ShadowMode
@ -2149,10 +2151,10 @@ impl<'a> Widget for SettingsWindow<'a> {
.down_from(state.ids.shadow_mode_text, 8.0)
.set(state.ids.shadow_mode_list, ui)
{
events.push(Event::ChangeRenderMode(RenderMode {
events.push(Event::ChangeRenderMode(Box::new(RenderMode {
shadow: mode_list[clicked],
..render_mode
}));
..render_mode.clone()
})));
}
if let Some(shadow_map_mode) = shadow_map_mode {
@ -2182,12 +2184,12 @@ impl<'a> Widget for SettingsWindow<'a> {
.pad_track((5.0, 5.0))
.set(state.ids.shadow_mode_map_resolution_slider, ui)
{
events.push(Event::ChangeRenderMode(RenderMode {
events.push(Event::ChangeRenderMode(Box::new(RenderMode {
shadow: ShadowMode::Map(ShadowMapMode {
resolution: 2.0f32.powf(f32::from(new_val) / 4.0),
}),
..render_mode
}));
..render_mode.clone()
})));
}
// TODO: Consider fixing to avoid allocation (it's probably not a bottleneck but

View File

@ -247,7 +247,7 @@ impl ShadowMode {
}
/// Render modes
#[derive(PartialEq, Clone, Copy, Debug, Default, Serialize, Deserialize)]
#[derive(PartialEq, Clone, Debug, Default, Serialize, Deserialize)]
pub struct RenderMode {
#[serde(default)]
pub aa: AaMode,

View File

@ -64,41 +64,11 @@ gfx_defines! {
}
}
impl Vertex {
#[allow(clippy::collapsible_if)]
pub fn new(pos: Vec3<f32>, norm: Vec3<f32>, col: Rgb<f32>, ao: f32, bone_idx: u8) -> Self {
let norm_bits = if norm.x != 0.0 {
if norm.x < 0.0 { 0 } else { 1 }
} else if norm.y != 0.0 {
if norm.y < 0.0 { 2 } else { 3 }
} else {
if norm.z < 0.0 { 4 } else { 5 }
};
Self {
pos_norm: pos
.map2(Vec3::new(0, 9, 18), |e, shift| {
(((e * 2.0 + 256.0) as u32) & 0x3FF) << shift
})
.reduce_bitor()
| (norm_bits << 29),
col: col
.map2(Rgb::new(0, 8, 16), |e, shift| ((e * 255.0) as u32) << shift)
.reduce_bitor(),
ao_bone: (bone_idx << 2) | ((ao * 3.9999) as u8),
}
}
pub fn with_bone_idx(mut self, bone_idx: u8) -> Self {
self.ao_bone = (self.ao_bone & 0b11) | (bone_idx << 2);
self
}
}
impl Locals {
pub fn new(
model_mat: Mat4<f32>,
model_mat: anim::vek::Mat4<f32>,
col: Rgba<f32>,
pos: Vec3<f32>,
pos: anim::vek::Vec3<f32>,
atlas_offs: Vec2<i32>,
is_player: bool,
) -> Self {
@ -118,9 +88,9 @@ impl Locals {
impl Default for Locals {
fn default() -> Self {
Self::new(
Mat4::identity(),
anim::vek::Mat4::identity(),
Rgba::broadcast(1.0),
Vec3::default(),
anim::vek::Vec3::default(),
Vec2::default(),
false,
)
@ -128,7 +98,7 @@ impl Default for Locals {
}
impl BoneData {
pub fn new(bone_mat: Mat4<f32>, normals_mat: Mat4<f32>) -> Self {
pub fn new(bone_mat: anim::vek::Mat4<f32>, normals_mat: anim::vek::Mat4<f32>) -> Self {
Self {
bone_mat: bone_mat.into_col_arrays(),
normals_mat: normals_mat.into_col_arrays(),
@ -137,7 +107,7 @@ impl BoneData {
}
impl Default for BoneData {
fn default() -> Self { Self::new(Mat4::identity(), Mat4::identity()) }
fn default() -> Self { Self::new(anim::vek::Mat4::identity(), anim::vek::Mat4::identity()) }
}
pub struct FigurePipeline;

View File

@ -43,7 +43,6 @@ use guillotiere::AtlasAllocator;
use hashbrown::HashMap;
use specs::{Entity as EcsEntity, Join, LazyUpdate, WorldExt};
use treeculler::{BVol, BoundingSphere};
use vek::*;
const DAMAGE_FADE_COEFFICIENT: f64 = 5.0;
const MOVING_THRESHOLD: f32 = 0.7;
@ -348,7 +347,11 @@ impl FigureMgr {
self.golem_model_cache.clean(&mut self.col_lights, tick);
}
#[allow(clippy::redundant_pattern_matching)] // TODO: Pending review in #587
#[allow(clippy::redundant_pattern_matching)]
// TODO: Pending review in #587
// NOTE: All of the "useless" conversion reported here allow us to abstract over repr_c vs.
// simd vectors, so fixing this warning would make the code worse in this case.
#[allow(clippy::useless_conversion)]
pub fn update_lighting(&mut self, scene_data: &SceneData) {
let ecs = scene_data.state.ecs();
for (entity, light_emitter) in (&ecs.entities(), &ecs.read_storage::<LightEmitter>()).join()
@ -357,7 +360,7 @@ impl FigureMgr {
let mut anim_storage = ecs.write_storage::<LightAnimation>();
if let None = anim_storage.get_mut(entity) {
let anim = LightAnimation {
offset: Vec3::zero(), //Vec3::new(0.0, 0.0, 2.0),
offset: vek::Vec3::zero(), //Vec3::new(0.0, 0.0, 2.0),
col: light_emitter.col,
strength: 0.0,
};
@ -387,13 +390,13 @@ impl FigureMgr {
emitter.animated,
)
} else {
(Rgb::zero(), 0.0, 0.0, true)
(vek::Rgb::zero(), 0.0, 0.0, true)
};
if let Some(_) = waypoint {
light_anim.offset = Vec3::unit_z() * 0.5;
light_anim.offset = vek::Vec3::unit_z() * 0.5;
}
if let Some(state) = self.states.character_states.get(&entity) {
light_anim.offset = state.lantern_offset;
light_anim.offset = vek::Vec3::from(state.lantern_offset);
}
if !light_anim.strength.is_normal() {
light_anim.strength = 0.0;
@ -424,7 +427,11 @@ impl FigureMgr {
}
}
#[allow(clippy::or_fun_call)] // TODO: Pending review in #587
#[allow(clippy::or_fun_call)]
// TODO: Pending review in #587
// NOTE: All of the "useless" conversion reported here allow us to abstract over repr_c vs.
// simd vectors, so fixing this warning would make the code worse in this case.
#[allow(clippy::useless_conversion)]
pub fn maintain(
&mut self,
renderer: &mut Renderer,
@ -432,7 +439,7 @@ impl FigureMgr {
// Visible chunk data.
visible_psr_bounds: math::Aabr<f32>,
camera: &Camera,
) -> Aabb<f32> {
) -> anim::vek::Aabb<f32> {
let state = scene_data.state;
let time = state.get_time();
let tick = scene_data.tick;
@ -496,7 +503,7 @@ impl FigureMgr {
a.min.partial_cmple(&b.max).reduce_and() && a.max.partial_cmpge(&b.min).reduce_and()
};
// println!("Aabr: {:?}", visible_bounds);
move |pos: Pos, radius: f32| {
move |pos: (anim::vek::Vec3<f32>,), radius: f32| {
// Short circuit when there are no shadows to cast.
if !can_shadow_sun {
return false;
@ -519,12 +526,14 @@ impl FigureMgr {
let player_pos = ecs
.read_storage::<Pos>()
.get(scene_data.player_entity)
.map_or(Vec3::zero(), |pos| pos.0);
let mut visible_aabb = Aabb {
.map_or(anim::vek::Vec3::zero(), |pos| anim::vek::Vec3::from(pos.0));
let visible_aabb = anim::vek::Aabb {
min: player_pos - 2.0,
max: player_pos + 2.0,
};
let focus_pos = anim::vek::Vec3::<f32>::from(camera.get_focus_pos());
for (
i,
(
@ -556,10 +565,19 @@ impl FigureMgr {
.join()
.enumerate()
{
let vel = (anim::vek::Vec3::<f32>::from(vel.0),);
let is_player = scene_data.player_entity == entity;
let (pos, ori) = interpolated
.map(|i| (Pos(i.pos), *i.ori))
.unwrap_or((*pos, Vec3::unit_y()));
.map(|i| {
(
(anim::vek::Vec3::from(i.pos),),
anim::vek::Vec3::from(*i.ori),
)
})
.unwrap_or((
(anim::vek::Vec3::<f32>::from(pos.0),),
anim::vek::Vec3::<f32>::unit_y(),
));
// Maintaining figure data and sending new figure data to the GPU turns out to
// be a very expensive operation. We want to avoid doing it as much
@ -571,7 +589,7 @@ impl FigureMgr {
const MIN_PERFECT_RATE_DIST: f32 = 50.0;
if (i as u64 + tick)
% (1 + ((pos.0.distance_squared(camera.get_focus_pos()).powf(0.25)
% (1 + ((pos.0.distance_squared(focus_pos).powf(0.25)
- MIN_PERFECT_RATE_DIST.powf(0.5))
.max(0.0)
/ 3.0) as u64)
@ -588,10 +606,11 @@ impl FigureMgr {
.unwrap_or(false);
// Don't process figures outside the vd
let vd_frac = Vec2::from(pos.0 - player_pos)
.map2(TerrainChunk::RECT_SIZE, |d: f32, sz| {
d.abs() as f32 / sz as f32
})
let vd_frac = anim::vek::Vec2::from(pos.0 - player_pos)
.map2(
anim::vek::Vec2::<u32>::from(TerrainChunk::RECT_SIZE),
|d: f32, sz| d.abs() as f32 / sz as f32,
)
.magnitude()
/ view_distance as f32;
@ -620,11 +639,11 @@ impl FigureMgr {
meta.visible = in_frustum;
meta.lpindex = lpindex;
if in_frustum {
// Update visible bounds.
/* // Update visible bounds.
visible_aabb.expand_to_contain(Aabb {
min: pos.0 - radius,
max: pos.0 + radius,
});
}); */
} else {
// Check whether we can shadow.
meta.can_shadow_sun = can_shadow_sun(pos, radius);
@ -637,12 +656,12 @@ impl FigureMgr {
// Change in health as color!
let col = stats
.map(|s| {
Rgba::broadcast(1.0)
+ Rgba::new(2.0, 2.0, 2., 0.00).map(|c| {
vek::Rgba::broadcast(1.0)
+ vek::Rgba::new(2.0, 2.0, 2., 0.00).map(|c| {
(c / (1.0 + DAMAGE_FADE_COEFFICIENT * s.health.last_change.0)) as f32
})
})
.unwrap_or(Rgba::broadcast(1.0));
.unwrap_or(vek::Rgba::broadcast(1.0));
let scale = scale.map(|s| s.0).unwrap_or(1.0);
@ -1968,7 +1987,6 @@ impl FigureMgr {
.entry(entity)
.or_insert_with(|| FigureState::new(renderer, ObjectSkeleton::new()));
state.skeleton = state.skeleton_mut().clone();
state.update(
renderer,
pos.0,
@ -2226,7 +2244,7 @@ impl FigureMgr {
loadout: Option<&Loadout>,
is_player: bool,
// is_shadow: bool,
pos: Vec3<f32>,
pos: vek::Vec3<f32>,
figure_lod_render_distance: f32,
filter_state: impl Fn(&FigureStateMeta) -> bool,
) -> Option<(
@ -2593,11 +2611,11 @@ impl FigureColLights {
// println!("Allocation {:?} for {:?} (original size = {:?}... ugh)",
// allocation, response.pos, tex_size); NOTE: Cast is safe since the
// origin was a u16.
let atlas_offs = Vec2::new(
let atlas_offs = vek::Vec2::new(
allocation.rectangle.min.x as u16,
allocation.rectangle.min.y as u16,
);
if atlas_offs == Vec2::zero() {
if atlas_offs == vek::Vec2::zero() {
// println!("Model: {:?}", &response.opaque_mesh.vertices());
// println!("Texture: {:?}", tex);
}
@ -2689,14 +2707,14 @@ impl FigureColLights {
pub struct FigureStateMeta {
bone_consts: Consts<FigureBoneData>,
locals: Consts<FigureLocals>,
lantern_offset: Vec3<f32>,
lantern_offset: anim::vek::Vec3<f32>,
state_time: f64,
last_ori: Vec3<f32>,
last_ori: anim::vek::Vec3<f32>,
lpindex: u8,
can_shadow_sun: bool,
visible: bool,
last_pos: Option<Vec3<f32>>,
avg_vel: Vec3<f32>,
last_pos: Option<anim::vek::Vec3<f32>>,
avg_vel: anim::vek::Vec3<f32>,
}
impl FigureStateMeta {
@ -2735,12 +2753,12 @@ impl<S: Skeleton> FigureState<S> {
locals: renderer.create_consts(&[FigureLocals::default()]).unwrap(),
lantern_offset,
state_time: 0.0,
last_ori: Vec3::zero(),
last_ori: anim::vek::Vec3::zero(),
lpindex: 0,
visible: false,
can_shadow_sun: false,
last_pos: None,
avg_vel: Vec3::zero(),
avg_vel: anim::vek::Vec3::zero(),
},
skeleton,
}
@ -2750,10 +2768,10 @@ impl<S: Skeleton> FigureState<S> {
pub fn update(
&mut self,
renderer: &mut Renderer,
pos: Vec3<f32>,
ori: Vec3<f32>,
pos: anim::vek::Vec3<f32>,
ori: anim::vek::Vec3<f32>,
scale: f32,
col: Rgba<f32>,
col: vek::Rgba<f32>,
dt: f32,
state_animation_rate: f32,
model: &FigureModel,
@ -2778,16 +2796,16 @@ impl<S: Skeleton> FigureState<S> {
self.visible = visible; */
// What is going on here?
// (note: that ori is now the slerped ori)
self.last_ori = Lerp::lerp(self.last_ori, ori, 15.0 * dt);
self.last_ori = vek::Lerp::lerp(self.last_ori, ori, 15.0 * dt);
self.state_time += (dt * state_animation_rate) as f64;
let _focus_off = camera.get_focus_pos().map(|e| e.trunc());
let mat = Mat4::<f32>::identity()
// let _focus_off = camera.get_focus_pos().map(|e| e.trunc());
let mat = anim::vek::Mat4::<f32>::identity()
// * Mat4::translation_3d(pos - focus_off)
* Mat4::rotation_z(-ori.x.atan2(ori.y))
* Mat4::rotation_x(ori.z.atan2(Vec2::from(ori).magnitude()))
* Mat4::scaling_3d(Vec3::from(0.8 * scale));
* anim::vek::Mat4::rotation_z(-ori.x.atan2(ori.y))
* anim::vek::Mat4::rotation_x(ori.z.atan2(anim::vek::Vec2::from(ori).magnitude()))
* anim::vek::Mat4::scaling_3d(anim::vek::Vec3::from(0.8 * scale));
/* let dependents = camera.get_dependents();
let all_mat = dependents.proj_mat * dependents.view_mat; */
@ -2797,7 +2815,7 @@ impl<S: Skeleton> FigureState<S> {
mat,
col,
pos,
Vec2::new(atlas_offs.x, atlas_offs.y),
vek::Vec2::new(atlas_offs.x, atlas_offs.y),
is_player,
);
renderer.update_consts(&mut self.locals, &[locals]).unwrap();
@ -2833,7 +2851,7 @@ impl<S: Skeleton> FigureState<S> {
fn figure_bone_data_from_anim(
mats: [anim::FigureBoneData; 16],
mut make_bone: impl FnMut(Mat4<f32>) -> FigureBoneData,
mut make_bone: impl FnMut(anim::vek::Mat4<f32>) -> FigureBoneData,
) -> [FigureBoneData; 16] {
[
make_bone(mats[0].0),

View File

@ -1,9 +1,9 @@
use core::{iter, mem};
use hashbrown::HashMap;
use num::traits::Float;
pub use vek::{geom::repr_simd::*, mat::repr_simd::column_major::Mat4, ops::*, vec::repr_simd::*};
// pub use vek::{geom::repr_c::*, mat::repr_c::column_major::Mat4, ops::*,
// vec::repr_c::*};
// pub use vek::{geom::repr_simd::*, mat::repr_simd::column_major::Mat4, ops::*,
// vec::repr_simd::*};
pub use vek::{geom::repr_c::*, mat::repr_c::column_major::Mat4, ops::*, vec::repr_c::*};
pub fn aabb_to_points<T: Float>(bounds: Aabb<T>) -> [Vec3<T>; 8] {
[

View File

@ -358,6 +358,9 @@ impl Scene {
/// Maintain data such as GPU constant buffers, models, etc. To be called
/// once per tick.
// NOTE: All of the "useless" conversion reported here allow us to abstract over repr_c vs.
// simd vectors, so fixing this warning would make the code worse in this case.
#[allow(clippy::useless_conversion)]
pub fn maintain(
&mut self,
renderer: &mut Renderer,

View File

@ -159,8 +159,8 @@ impl Scene {
let model = col_lights.create_figure(renderer, greedy, mesh).unwrap();
state.update(
renderer,
Vec3::zero(),
Vec3::new(start_angle.sin(), -start_angle.cos(), 0.0),
anim::vek::Vec3::zero(),
anim::vek::Vec3::new(start_angle.sin(), -start_angle.cos(), 0.0),
1.0,
Rgba::broadcast(1.0),
15.0, // Want to get there immediately.
@ -310,8 +310,8 @@ impl Scene {
.0;
self.figure_state.update(
renderer,
Vec3::zero(),
Vec3::new(self.char_ori.sin(), -self.char_ori.cos(), 0.0),
anim::vek::Vec3::zero(),
anim::vek::Vec3::new(self.char_ori.sin(), -self.char_ori.cos(), 0.0),
1.0,
Rgba::broadcast(1.0),
scene_data.delta_time,

View File

@ -2439,6 +2439,9 @@ impl<V: RectRasterableVol> Terrain<V> {
}
/// Maintain terrain data. To be called once per tick.
// NOTE: All of the "useless" conversion reported here allow us to abstract over repr_c vs.
// simd vectors, so fixing this warning would make the code worse in this case.
#[allow(clippy::useless_conversion)]
#[allow(clippy::for_loops_over_fallibles)] // TODO: Pending review in #587
#[allow(clippy::len_zero)] // TODO: Pending review in #587
pub fn maintain(

View File

@ -731,7 +731,9 @@ impl PlayState for SessionState {
// Look for changes in the localization files
if global_state.localization_watcher.reloaded() {
hud_events.push(HudEvent::ChangeLanguage(self.voxygen_i18n.metadata.clone()));
hud_events.push(HudEvent::ChangeLanguage(Box::new(
self.voxygen_i18n.metadata.clone(),
)));
}
// Maintain the UI.
@ -930,9 +932,9 @@ impl PlayState for SessionState {
global_state
.window
.renderer_mut()
.set_render_mode(new_render_mode)
.set_render_mode((&*new_render_mode).clone())
.unwrap();
global_state.settings.graphics.render_mode = new_render_mode;
global_state.settings.graphics.render_mode = *new_render_mode;
global_state.settings.save_to_file_warn();
},
HudEvent::ChangeLanguage(new_language) => {

View File

@ -570,7 +570,7 @@ impl Window {
factory,
win_color_view,
win_depth_view,
settings.graphics.render_mode,
settings.graphics.render_mode.clone(),
)?,
window,
cursor_grabbed: false,