7
7
8
8
use core:: f32:: consts:: PI ;
9
9
use core:: ops:: { Add , Mul , Sub } ;
10
- use spirv_std:: glam:: { Vec2 , Vec3 , Vec4 } ;
10
+ use spirv_std:: glam:: { vec2 , vec3 , Vec2 , Vec3 , Vec4 } ;
11
11
12
12
// Note: This cfg is incorrect on its surface, it really should be "are we compiling with std", but
13
13
// we tie #[no_std] above to the same condition, so it's fine.
@@ -34,11 +34,11 @@ pub fn saturate(x: f32) -> f32 {
34
34
}
35
35
36
36
pub fn pow ( v : Vec3 , power : f32 ) -> Vec3 {
37
- Vec3 :: new ( v. x . powf ( power) , v. y . powf ( power) , v. z . powf ( power) )
37
+ vec3 ( v. x . powf ( power) , v. y . powf ( power) , v. z . powf ( power) )
38
38
}
39
39
40
40
pub fn exp ( v : Vec3 ) -> Vec3 {
41
- Vec3 :: new ( v. x . exp ( ) , v. y . exp ( ) , v. z . exp ( ) )
41
+ vec3 ( v. x . exp ( ) , v. y . exp ( ) , v. z . exp ( ) )
42
42
}
43
43
44
44
/// Based on: https://seblagarde.wordpress.com/2014/12/01/inverse-trigonometric-functions-gpu-optimization-for-amd-gcn-architecture/
@@ -151,35 +151,35 @@ fn step(edge: f32, x: f32) -> f32 {
151
151
152
152
impl VecExt for Vec2 {
153
153
fn gl_fract ( self ) -> Vec2 {
154
- Vec2 :: new ( self . x . gl_fract ( ) , self . y . gl_fract ( ) )
154
+ vec2 ( self . x . gl_fract ( ) , self . y . gl_fract ( ) )
155
155
}
156
156
157
157
fn sin ( self ) -> Vec2 {
158
- Vec2 :: new ( self . x . sin ( ) , self . y . sin ( ) )
158
+ vec2 ( self . x . sin ( ) , self . y . sin ( ) )
159
159
}
160
160
161
161
fn cos ( self ) -> Vec2 {
162
- Vec2 :: new ( self . x . cos ( ) , self . y . cos ( ) )
162
+ vec2 ( self . x . cos ( ) , self . y . cos ( ) )
163
163
}
164
164
165
165
fn powf_vec ( self , p : Vec2 ) -> Vec2 {
166
- Vec2 :: new ( self . x . powf ( p. x ) , self . y . powf ( p. y ) )
166
+ vec2 ( self . x . powf ( p. x ) , self . y . powf ( p. y ) )
167
167
}
168
168
169
169
fn sqrt ( self ) -> Vec2 {
170
- Vec2 :: new ( self . x . sqrt ( ) , self . y . sqrt ( ) )
170
+ vec2 ( self . x . sqrt ( ) , self . y . sqrt ( ) )
171
171
}
172
172
173
173
fn ln ( self ) -> Vec2 {
174
- Vec2 :: new ( self . x . ln ( ) , self . y . ln ( ) )
174
+ vec2 ( self . x . ln ( ) , self . y . ln ( ) )
175
175
}
176
176
177
177
fn rem_euclid ( self , m : f32 ) -> Vec2 {
178
- Vec2 :: new ( self . x . rem_euclid ( m) , self . y . rem_euclid ( m) )
178
+ vec2 ( self . x . rem_euclid ( m) , self . y . rem_euclid ( m) )
179
179
}
180
180
181
181
fn step ( self , other : Vec2 ) -> Vec2 {
182
- Vec2 :: new ( step ( self . x , other. x ) , step ( self . y , other. y ) )
182
+ vec2 ( step ( self . x , other. x ) , step ( self . y , other. y ) )
183
183
}
184
184
185
185
fn reflect ( self , normal : Vec2 ) -> Vec2 {
@@ -191,45 +191,45 @@ impl VecExt for Vec2 {
191
191
}
192
192
193
193
fn gl_sign ( self ) -> Vec2 {
194
- Vec2 :: new ( self . x . gl_sign ( ) , self . y . gl_sign ( ) )
194
+ vec2 ( self . x . gl_sign ( ) , self . y . gl_sign ( ) )
195
195
}
196
196
}
197
197
198
198
impl VecExt for Vec3 {
199
199
fn gl_fract ( self ) -> Vec3 {
200
- Vec3 :: new ( self . x . gl_fract ( ) , self . y . gl_fract ( ) , self . z . gl_fract ( ) )
200
+ vec3 ( self . x . gl_fract ( ) , self . y . gl_fract ( ) , self . z . gl_fract ( ) )
201
201
}
202
202
203
203
fn sin ( self ) -> Vec3 {
204
- Vec3 :: new ( self . x . sin ( ) , self . y . sin ( ) , self . z . sin ( ) )
204
+ vec3 ( self . x . sin ( ) , self . y . sin ( ) , self . z . sin ( ) )
205
205
}
206
206
207
207
fn cos ( self ) -> Vec3 {
208
- Vec3 :: new ( self . x . cos ( ) , self . y . cos ( ) , self . z . cos ( ) )
208
+ vec3 ( self . x . cos ( ) , self . y . cos ( ) , self . z . cos ( ) )
209
209
}
210
210
211
211
fn powf_vec ( self , p : Vec3 ) -> Vec3 {
212
- Vec3 :: new ( self . x . powf ( p. x ) , self . y . powf ( p. y ) , self . z . powf ( p. z ) )
212
+ vec3 ( self . x . powf ( p. x ) , self . y . powf ( p. y ) , self . z . powf ( p. z ) )
213
213
}
214
214
215
215
fn sqrt ( self ) -> Vec3 {
216
- Vec3 :: new ( self . x . sqrt ( ) , self . y . sqrt ( ) , self . z . sqrt ( ) )
216
+ vec3 ( self . x . sqrt ( ) , self . y . sqrt ( ) , self . z . sqrt ( ) )
217
217
}
218
218
219
219
fn ln ( self ) -> Vec3 {
220
- Vec3 :: new ( self . x . ln ( ) , self . y . ln ( ) , self . z . ln ( ) )
220
+ vec3 ( self . x . ln ( ) , self . y . ln ( ) , self . z . ln ( ) )
221
221
}
222
222
223
223
fn rem_euclid ( self , m : f32 ) -> Vec3 {
224
- Vec3 :: new (
224
+ vec3 (
225
225
self . x . rem_euclid ( m) ,
226
226
self . y . rem_euclid ( m) ,
227
227
self . z . rem_euclid ( m) ,
228
228
)
229
229
}
230
230
231
231
fn step ( self , other : Vec3 ) -> Vec3 {
232
- Vec3 :: new (
232
+ vec3 (
233
233
step ( self . x , other. x ) ,
234
234
step ( self . y , other. y ) ,
235
235
step ( self . z , other. z ) ,
@@ -245,6 +245,6 @@ impl VecExt for Vec3 {
245
245
}
246
246
247
247
fn gl_sign ( self ) -> Vec3 {
248
- Vec3 :: new ( self . x . gl_sign ( ) , self . y . gl_sign ( ) , self . z . gl_sign ( ) )
248
+ vec3 ( self . x . gl_sign ( ) , self . y . gl_sign ( ) , self . z . gl_sign ( ) )
249
249
}
250
250
}
0 commit comments