mirror of
https://codeberg.org/icewind/vmdl.git
synced 2026-06-03 16:44:11 +02:00
add into/from cgmath vec3
This commit is contained in:
parent
b3d0343b11
commit
92a15fb4db
2 changed files with 29 additions and 7 deletions
|
|
@ -4,6 +4,7 @@ use bytemuck::{Pod, Zeroable};
|
|||
use std::fmt;
|
||||
use std::fmt::{Display, Formatter};
|
||||
use std::ops::Add;
|
||||
use cgmath::Vector3;
|
||||
|
||||
#[derive(Debug, Clone, Copy, Zeroable, Pod)]
|
||||
#[repr(C)]
|
||||
|
|
@ -13,6 +14,26 @@ pub struct Vector {
|
|||
pub z: f32,
|
||||
}
|
||||
|
||||
impl From<Vector> for Vector3<f32> {
|
||||
fn from(v: Vector) -> Self {
|
||||
Self {
|
||||
x: v.x,
|
||||
y: v.y,
|
||||
z: v.z,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Vector3<f32>> for Vector {
|
||||
fn from(v: Vector3<f32>) -> Self {
|
||||
Self {
|
||||
x: v.x,
|
||||
y: v.y,
|
||||
z: v.z,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Vector {
|
||||
pub fn iter(&self) -> impl Iterator<Item = f32> {
|
||||
[self.x, self.y, self.z].into_iter()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue