1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
use std::ffi::c_void;
use serde::{Deserialize, Serialize};
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
// --- Conversions
pub mod conversions {
use crate::{Mat4, Vec3, Vec4};
impl From<Vec3> for glam::Vec3 {
fn from(v: Vec3) -> Self {
Self {
x: v.x,
y: v.y,
z: v.z,
}
}
}
impl From<glam::Vec3> for Vec3 {
fn from(v: glam::Vec3) -> Self {
Self {
x: v.x,
y: v.y,
z: v.z,
}
}
}
impl From<Vec4> for glam::Vec4 {
fn from(v: Vec4) -> Self {
Self::new(v.x, v.y, v.z, v.w)
}
}
impl From<glam::Vec4> for Vec4 {
fn from(v: glam::Vec4) -> Self {
Vec4 {
x: v.x,
y: v.y,
z: v.z,
w: v.w,
}
}
}
impl From<Mat4> for glam::Mat4 {
fn from(m: Mat4) -> Self {
Self {
x_axis: glam::Vec4::new(m.data[0], m.data[1], m.data[2], m.data[3]),
y_axis: glam::Vec4::new(m.data[4], m.data[5], m.data[6], m.data[7]),
z_axis: glam::Vec4::new(m.data[8], m.data[9], m.data[10], m.data[11]),
w_axis: glam::Vec4::new(m.data[12], m.data[13], m.data[14], m.data[15]),
}
}
}
impl From<glam::Mat4> for Mat4 {
fn from(m: glam::Mat4) -> Self {
let mut slf = Self { data: [0.0; 16] };
m.write_cols_to_slice(&mut slf.data);
slf
}
}
}
impl Transform {
#[inline]
pub fn identity() -> Self {
Self {
position: Vec3 {
x: 0.,
y: 0.,
z: 0.,
},
rotation: Vec4 {
x: 0.,
y: 0.,
z: 0.,
w: 1.0,
},
scale: 1.,
is_dirty: true,
}
}
}
impl Default for ShaderBinding {
fn default() -> Self {
Self {
label: "static".as_ptr() as *const _,
kind: ShaderBindingKind_BINDING_COUNT,
vis: ShaderVisibility_VISIBILITY_VERTEX,
data: ShaderBinding__bindgen_ty_1 {
bytes: ShaderBinding__bindgen_ty_1__bindgen_ty_1 {
size: 0,
data: std::ptr::null_mut(),
},
},
}
}
}
impl Default for ShaderDataLayout {
fn default() -> Self {
Self {
bindings: [ShaderBinding::default(); 8],
binding_count: 0,
}
}
}
|