spirv_backend: remove Vec3Std and use coremem_types::Vec3 everywhere
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
use crate::support::{Optional, Vec3Std};
|
||||
use crate::support::Optional;
|
||||
use coremem_types::vec::Vec3;
|
||||
|
||||
pub trait Material: Sized {
|
||||
fn conductivity(&self) -> Vec3Std {
|
||||
fn conductivity(&self) -> Vec3<f32> {
|
||||
Default::default()
|
||||
}
|
||||
/// returns the new M vector for this material
|
||||
fn move_b_vec(&self, m: Vec3Std, _target_b: Vec3Std) -> Vec3Std {
|
||||
fn move_b_vec(&self, m: Vec3<f32>, _target_b: Vec3<f32>) -> Vec3<f32> {
|
||||
// XXX could return either 0, or `m`. they should be the same, but one might be more
|
||||
// optimizable than the other (untested).
|
||||
m
|
||||
@@ -14,18 +15,18 @@ pub trait Material: Sized {
|
||||
|
||||
#[derive(Copy, Clone, Default, PartialEq)]
|
||||
pub struct Conductor<T>(pub T);
|
||||
pub type AnisomorphicConductor = Conductor<Vec3Std>;
|
||||
pub type AnisomorphicConductor = Conductor<Vec3<f32>>;
|
||||
pub type IsomorphicConductor = Conductor<f32>;
|
||||
|
||||
impl Material for AnisomorphicConductor {
|
||||
fn conductivity(&self) -> Vec3Std {
|
||||
fn conductivity(&self) -> Vec3<f32> {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl Material for IsomorphicConductor {
|
||||
fn conductivity(&self) -> Vec3Std {
|
||||
Vec3Std::uniform(self.0)
|
||||
fn conductivity(&self) -> Vec3<f32> {
|
||||
Vec3::uniform(self.0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,8 +80,8 @@ impl MBPgram {
|
||||
}
|
||||
|
||||
impl Material for MBPgram {
|
||||
fn move_b_vec(&self, m: Vec3Std, target_b: Vec3Std) -> Vec3Std {
|
||||
Vec3Std::new(
|
||||
fn move_b_vec(&self, m: Vec3<f32>, target_b: Vec3<f32>) -> Vec3<f32> {
|
||||
Vec3::new(
|
||||
self.move_b(m.x(), target_b.x()),
|
||||
self.move_b(m.y(), target_b.y()),
|
||||
self.move_b(m.z(), target_b.z()),
|
||||
@@ -167,8 +168,8 @@ impl MHPgram {
|
||||
}
|
||||
|
||||
impl Material for MHPgram {
|
||||
fn move_b_vec(&self, m: Vec3Std, target_b: Vec3Std) -> Vec3Std {
|
||||
Vec3Std::new(
|
||||
fn move_b_vec(&self, m: Vec3<f32>, target_b: Vec3<f32>) -> Vec3<f32> {
|
||||
Vec3::new(
|
||||
self.move_b(m.x(), target_b.x()),
|
||||
self.move_b(m.y(), target_b.y()),
|
||||
self.move_b(m.z(), target_b.z()),
|
||||
@@ -178,16 +179,16 @@ impl Material for MHPgram {
|
||||
|
||||
#[derive(Copy, Clone, Default, PartialEq)]
|
||||
pub struct FullyGenericMaterial {
|
||||
pub conductivity: Vec3Std,
|
||||
pub conductivity: Vec3<f32>,
|
||||
pub m_b_curve: Optional<MBPgram>,
|
||||
pub m_h_curve: Optional<MHPgram>,
|
||||
}
|
||||
|
||||
impl Material for FullyGenericMaterial {
|
||||
fn conductivity(&self) -> Vec3Std {
|
||||
fn conductivity(&self) -> Vec3<f32> {
|
||||
self.conductivity
|
||||
}
|
||||
fn move_b_vec(&self, m: Vec3Std, target_b: Vec3Std) -> Vec3Std {
|
||||
fn move_b_vec(&self, m: Vec3<f32>, target_b: Vec3<f32>) -> Vec3<f32> {
|
||||
if self.m_b_curve.is_some() {
|
||||
self.m_b_curve.unwrap().move_b_vec(m, target_b)
|
||||
} else if self.m_h_curve.is_some() {
|
||||
@@ -210,7 +211,7 @@ impl Into<MHPgram> for Ferroxcube3R1MH {
|
||||
}
|
||||
|
||||
impl Material for Ferroxcube3R1MH {
|
||||
fn move_b_vec(&self, m: Vec3Std, target_b: Vec3Std) -> Vec3Std {
|
||||
fn move_b_vec(&self, m: Vec3<f32>, target_b: Vec3<f32>) -> Vec3<f32> {
|
||||
let curve: MHPgram = (*self).into();
|
||||
curve.move_b_vec(m, target_b)
|
||||
}
|
||||
@@ -241,10 +242,10 @@ impl<M: Default> IsoConductorOr<M> {
|
||||
}
|
||||
|
||||
impl<M: Material + Copy> Material for IsoConductorOr<M> {
|
||||
fn conductivity(&self) -> Vec3Std {
|
||||
Vec3Std::uniform(self.value.max(0.0))
|
||||
fn conductivity(&self) -> Vec3<f32> {
|
||||
Vec3::uniform(self.value.max(0.0))
|
||||
}
|
||||
fn move_b_vec(&self, m: Vec3Std, target_b: Vec3Std) -> Vec3Std {
|
||||
fn move_b_vec(&self, m: Vec3<f32>, target_b: Vec3<f32>) -> Vec3<f32> {
|
||||
if self.value < 0.0 {
|
||||
let mat = self.mat; //< XXX hack for ZST
|
||||
mat.move_b_vec(m, target_b)
|
||||
|
Reference in New Issue
Block a user