[go: up one dir, main page]

glam 0.11.3

A simple and fast 3D math library for games and graphics
Documentation
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog], and this project adheres to
[Semantic Versioning].

## [Unreleased]

## [0.11.3] - 2020-12-29

### Changed

* Made `Vec3` `repr(simd)` for `spriv` targets.

### Added

* Added `From<(Vec2, f32)>` for `Vec3` and `From<(Vec3, f32)` for `Vec4`.

## [0.11.2] - 2020-12-04

### Changed

* Compilation fixes for Rust 1.36.0.

## [0.11.1] - 2020-12-03

### Added

* Added support for the [Rust GPU]https://github.com/EmbarkStudios/rust-gpu
  SPIRV target architecture.

## [0.11.0] - 2020-11-26

### Added

* Added `is_finite` method to all types which returns `true` if, and only if,
  all contained elements are finite.
* Added `exp` and `powf` methods for all vector types.

### Changed

* The `is_nan` method now returns a `bool` to match the new `is_finite` method
  and to be consistent with the same methods on the `f32` and `f64` primitive
  types.
* Renamed `is_nan` which returns a vector mask to `is_nan_mask`.
* Don't use the `cfg` definitions added by `build.rs` for definining structs as
  `rust-analyzer` is not aware of them.

### Removed

* Removed deprecated accessor methods.

## [0.10.2] - 2020-11-17

### Changed

* Deprecated element accessor members `.x()`, `.x_mut()`, `.set_x()`, etc. on
  vector and quaternion types.
* Deprecated column accessor members `.x_axis()`, `.x_axis_mut()`,
  `.set_x_axis()`, etc. on matrix types.

## [0.10.1] - 2020-11-15

### Added

* Added the `Vec2::perp` method which returns a `Vec2` perpendicular to `self`.

### Changed

* `Vec2` and `Vec3` types were changed to use public named fields for `.x`,
  `.y`, and `.z` intead of accessors.
* `Quat`, `Vec3A` and `Vec4` implement `Deref` and `DerefMut` for the new `XYZ`
  and `XYZW` structs to emulate public named field access.
* `Mat3` and `Mat4` had their axis members made pubic intead of needing
  accessors.
* `Mat2` implements `Deref` and `DerefMut` for the new `XYAxes` struct to
  emulate public named field access.

### Removed

* Removed deprecated `length_reciprocal` and `sign` methods.

### Fixed

* Adding `glam` as a `no_std` dependency should now work as expected.

## [0.10.0] - 2020-10-31

### Added

* Added `From` implementations to truncate to narrower vector types, e.g.
  `Vec4` to `Vec3A`, `Vec3` and `Vec2` and from `Vec3A` and `Vec3` to `Vec2`.
* Added swizzles for `Vec4`, `Vec3A`, `Vec3` and `Vec2`. These can be used to
  reorder elements in the same type and also to create larger or smaller
  vectors from the given vectors elements.
* Added `Quat` operators `Add<Quat>`, `Sub<Quat>`, `Mul<f32>` and `Div<f32`.
  These are used by other crates for interpolation quaternions along splines.
  Note that these operations will not return unit length quaternions, thus the
  results must be normalized before performing other `Quat` operations.
* Added `Mat4::transform_point3a` and `Mat4::transform_vector3a`.
* Added `AsRef<[f32; 9]>` and `AsMut<[f32; 9]>` trait implementations to `Mat3`.
* Added optional `bytemuck` support primarily for casting types to `&[u8]`.
* Added support for compiling with `no_std` by disabling the default `std`
  feature and adding the `libm` feature.
* Added `distance` and `distance_squared` methods to `Vec2`, `Vec3`, `Vec3A`
  and `Vec4`.

### Changed

* Changed the return type of `Vec4::truncate` from `Vec3A` to `Vec3`. This is a
  breaking change.

## [0.9.5] - 2020-10-10

### Added

* `glam` uses SSE2 for some types which prevents constructor functions can not
  be made `const fn`. To work around this limitation the following macro
  functions have been added to support creating `const` values of `glam` types:
  `const_mat2`, `const_mat3`, `const_mat4`, `const_quat`, `const_vec2`,
  `const_vec3`, `const_vec3a` and `const_vec4`.
* Added `is_nan` methods to `Vec2`, `Vec3`, `Vec3A` and `Vec4` which return a
  mask.

## Changed

* Renamed the vector `reciprocal` and `length_reciprocal` methods to `recip`
  and `length_recip` to match the Rust standard library naming. The old methods
  have been deprecated.
* Renamed the vector `sign` methods to `signum` match the Rust standard library
  naming. The new methods now check for `NAN`. The old methods have been
  deprecated.
* Added SSE2 optimized implementations of `Mat4::determinant` and
  `Mat4::inverse`.

### Removed

* Removed deprecated function `Mat4::perspective_glu_rh`.

## [0.9.4] - 2020-08-31

### Fixed

* Fixed `Mat4::transform_point3` to account for homogeneous w coordinate.
  Previously this would have been incorrect when the resulting homogeneous
  coordinate was not 1.0, e.g. when transforming by a perspective projection.
* Fixed `Mat3::transform_point2` to account for homogeneous z coordinate.

## [0.9.3] - 2020-08-11

### Added

* Added `Mat4::perspective_rh`.

## [0.9.2] - 2020-07-09

### Added

* Added `Mat3::mul_vec3a` and `Quat::mul_vec3a`.

### Changed

* Changed `Quat::mul_vec3` to accept and return `Vec3` instead of `Vec3A`.

## [0.9.1] - 2020-07-01

### Added

* Added `Mat3 * Vec3A` implementation.
* Added `Vec3A` benches.

### Changed

* Some documentation improvements around the new `Vec3A` type.

## [0.9.0] - 2020-06-28

### Added

* `Vec3` has been split into scalar `Vec3` and 16 byte aligned `Vec3A` types.
  Only the `Vec3A` type currently uses SIMD optimizations.
* `Vec3Mask` has been split into scalar `Vec3Mask` and 16 byte aligned
  `Vec3AMask` types.
* Added `mut` column accessors to all matrix types, e.g. `Mat2::x_axis_mut()`.
* Added `From` trait implementations for `Vec3AMask` and `Vec4Mask` to `__m128`.

### Changed

* The `Mat3` type is using the scalar `Vec3` type for storage.
* Simplified `Debug` trait output for `Quat`, `Vec4` and `Vec3A`.

## Removed

* Removed the `packed-vec3` feature flag as it is now redundant.

## [0.8.7] - 2020-04-28

### Added

* Added `Quat::slerp` - note that this uses a `sin` approximation.
* Added `angle_between` method for `Vec2` and `Vec3`.
* Implemented `Debug`, `Display`, `PartialEq`, `Eq`, `PartialOrd`, `Ord`,
  `Hash`, and `AsRef` traits for `Vec2Mask`, `Vec3Mask` and `Vec4Mask`.
* Added conversion functions from `Vec2Mask`, `Vec3Mask` and `Vec4Mask` to an
  array of `[u32]`.
* Added `build.rs` to simplify conditional feature compilation.

### Changed

* Increased test coverage.

### Removed

* Removed `cfg-if` dependency.

## [0.8.6] - 2020-02-18

### Added

* Added the `packed-vec3` feature flag to disable using SIMD types for `Vec3`
  and `Mat3` types. This avoids wasting some space due to 16 byte alignment at
  the cost of some performance.
* Added `x_mut`, `y_mut`, `z_mut`, `w_mut` where appropriate to `Vec2`, `Vec3`
  and `Vec4`.
* Added implementation of `core::ops::Index` and `core::ops::IndexMut` for
  `Vec2`, `Vec3` and `Vec4`.

### Changed

* Merged SSE2 and scalar `Vec3` and `Vec4` implementations into single files
  using the `cfg-if` crate.

## [0.8.5] - 2020-01-02

### Added

* Added projection functions `Mat4::perspective_lh`,
  `Mat4::perspective_infinite_lh`, `Mat4::perspective_infinite_reverse_lh`,
  `Mat4::orthgraphic_lh` and `Mat4::orthographic_rh`.
* Added `round`, `ceil` and `floor` methods to `Vec2`, `Vec3` and `Vec4`.

## [0.8.4] - 2019-12-17

### Added

* Added `Mat4::to_scale_rotation_translation` for extracting scale, rotation and
  translation from a 4x4 homogeneous transformation matrix.
* Added `cargo-deny` GitHub Action.

### Changed

* Renamed `Quat::new` to `Quat::from_xyzw`.

## [0.8.3] - 2019-11-27

### Added

* Added `Mat4::orthographic_rh_gl`.

### Changed

* Renamed `Mat4::perspective_glu_rh` to `Mat4::perspective_rh_gl`.
* SSE2 optimizations for `Mat2::determinant`, `Mat2::inverse`,
  `Mat2::transpose`, `Mat3::transpose`, `Quat::conjugate`, `Quat::lerp`,
  `Quat::mul_vec3`, `Quat::mul_quat` and `Quat::from_rotation_ypr`.
* Disabled optimizations to `Mat4::transform_point3` and
  `Mat4::transform_vector3` as they are probably incorrect and need
  investigating.
* Added missing `#[repr(C)]` to `Mat2`, `Mat3` and `Mat4`.
* Benchmarks now store output of functions to better estimate the cost of a
  function call.

### Removed

* Removed deprecated functions `Mat2::new`, `Mat3::new` and `Mat4::new`.

## [0.8.2] - 2019-11-06

### Changed

* `glam_assert!` is no longer enabled by default in debug builds, it can be
  enabled in any configuration using the `glam-assert` feature or in debug
  builds only using the `debug-glam-assert` feature.

### Removed

* `glam_assert!`'s checking `lerp` is bounded between 0.0 and 1.0 and that
  matrix scales are non-zero have been removed.

## [0.8.1] - 2019-11-03

### Added

* Added `Display` trait implementations for `Mat2`, `Mat3` and `Mat4`.

### Changed

* Disabled `glam`'s SSE2 `sin_cos` implementation - it became less precise for
  large angle values.
* Reduced the default epsilon used by the `is_normalized!` macro from
  `std::f32::EPSILON` to `1e-6`.

## [0.8.0] - 2019-10-14

### Removed

* Removed the `approx` crate dependency. Each `glam` type has an `abs_diff_eq`
  method added which is used by unit tests for approximate floating point
  comparisons.
* Removed the `Angle` type. All angles are now `f32` and are expected to
  be in radians.
* Removed the deprecated `Vec2b`, `Vec3b` and `Vec4b` types and the `mask`
  methods on `Vec2Mask`, `Vec3Mask` and `Vec4Mask`.

### Changed

* The `rand` crate dependency has been removed from default features. This was
  required for benchmarking but a simple random number generator has been added
  to the benches `support` module instead.
* The `From` trait implementation converting between 1D and 2D `f32` arrays and
  matrix types have been removed. It was ambiguous how array data would map to
  matrix columns so these have been replaced with explicit methods
  `from_cols_array` and `from_cols_array_2d`.
* Matrix `new` methods have been renamed to `from_cols` to be consistent with
  the other methods that create matrices from data.
* Renamed `Mat4::perspective_glu` to `Mat4::perspective_glu_rh`.

## [0.7.2] - 2019-09-22

### Fixed

* Fixed incorrect projection matrix methods `Mat4::look_at_lh`
  and `Mat4::look_at_rh`.

### Added

* Added support for building infinite projection matrices, including both
  standard and reverse depth `Mat4::perspective_infinite_rh` and
  `Mat4::perspective_infinite_rh`.
* Added `Vec2Mask::new`, `Vec3Mask::new` and `Vec4Mask::new` methods.
* Implemented `std::ops` `BitAnd`, `BitAndAssign`, `BitOr`, `BitOrAssign`
  and `Not` traits for `Vec2Mask`, `Vec3Mask` and `Vec4Mask`.
* Added method documentation for `Vec4` and `Vec4Mask` types.
* Added missing `serde` implementations for `Mat2`, `Mat3` and `Mat4`.
* Updated `rand` and `criterion` versions.

## [0.7.1] - 2019-07-08

### Fixed

* The SSE2 implementation of `Vec4` `dot` was missing a shuffle, meaning the
  `dot`, `length`, `length_squared`, `length_reciprocal` and `normalize`
  methods were sometimes incorrect.

### Added

* Added the `glam_assert` macro which behaves like Rust's `debug_assert` but
  can be enabled separately to `debug_assert`. This is used to perform
  asserts on correctness.
* Added `is_normalized` method to `Vec2`, `Vec3` and `Vec4`.

### Changed

* Replaced usage of `std::mem::uninitialized` with `std::mem::MaybeUninit`. This
  change requires stable Rust 1.36.
* Renamed `Vec2b` to `Vec2Mask`, `Vec3b` to `Vec3Mask` and `Vec4b` to
  `Vec4Mask`. Old names are aliased to the new name and deprecated.
* Deprecate `VecNMask` `mask` method, use new `bitmask` method instead
* Made fallback version of `VecNMask` types the same size and alignment as the
  SIMD versions.
* Added `Default` support to `VecNMask` types, will add more common traits in
  the future.
* Added `#[inline]` to `mat2`, `mat3` and `mat4` functions.

## [0.7.0] - 2019-06-28

### Added

* Added `Mat2` into `[f32; 4]`, `Mat3` into `[f32; 9]` and `Mat4` into
  `[f32; 16]`.

### Removed

* Removed `impl Mul<&Vec2> for Mat2` and `impl Mul<&Vec3> for Vec3` as these
  don't exist for any other types.

## [0.6.1] - 2019-06-22

### Changed

* `Mat2` now uses a `Vec4` internally which gives it some performance
   improvements when SSE2 is available.

## 0.6.0 - 2019-06-13

### Changed

* Switched from row vectors to column vectors
* Vectors are now on the right of multiplications with matrices and quaternions.

[Keep a Changelog]: https://keepachangelog.com/
[Semantic Versioning]: https://semver.org/spec/v2.0.0.html
[Unreleased]: https://github.com/bitshifter/glam-rs/compare/0.11.3...HEAD
[0.11.2]: https://github.com/bitshifter/glam-rs/compare/0.11.2...0.11.3
[0.11.2]: https://github.com/bitshifter/glam-rs/compare/0.11.1...0.11.2
[0.11.1]: https://github.com/bitshifter/glam-rs/compare/0.11.0...0.11.1
[0.11.0]: https://github.com/bitshifter/glam-rs/compare/0.10.2...0.11.0
[0.10.2]: https://github.com/bitshifter/glam-rs/compare/0.10.1...0.10.2
[0.10.1]: https://github.com/bitshifter/glam-rs/compare/0.10.0...0.10.1
[0.10.0]: https://github.com/bitshifter/glam-rs/compare/0.9.5...0.10.0
[0.9.5]: https://github.com/bitshifter/glam-rs/compare/0.9.4...0.9.5
[0.9.4]: https://github.com/bitshifter/glam-rs/compare/0.9.3...0.9.4
[0.9.3]: https://github.com/bitshifter/glam-rs/compare/0.9.2...0.9.3
[0.9.2]: https://github.com/bitshifter/glam-rs/compare/0.9.1...0.9.2
[0.9.1]: https://github.com/bitshifter/glam-rs/compare/0.9.0...0.9.1
[0.9.0]: https://github.com/bitshifter/glam-rs/compare/0.8.7...0.9.0
[0.8.7]: https://github.com/bitshifter/glam-rs/compare/0.8.6...0.8.7
[0.8.6]: https://github.com/bitshifter/glam-rs/compare/0.8.5...0.8.6
[0.8.5]: https://github.com/bitshifter/glam-rs/compare/0.8.4...0.8.5
[0.8.4]: https://github.com/bitshifter/glam-rs/compare/0.8.3...0.8.4
[0.8.3]: https://github.com/bitshifter/glam-rs/compare/0.8.2...0.8.3
[0.8.2]: https://github.com/bitshifter/glam-rs/compare/0.8.1...0.8.2
[0.8.1]: https://github.com/bitshifter/glam-rs/compare/0.8.0...0.8.1
[0.8.0]: https://github.com/bitshifter/glam-rs/compare/0.7.2...0.8.0
[0.7.2]: https://github.com/bitshifter/glam-rs/compare/0.7.1...0.7.2
[0.7.1]: https://github.com/bitshifter/glam-rs/compare/0.7.0...0.7.1
[0.7.0]: https://github.com/bitshifter/glam-rs/compare/0.6.1...0.7.0
[0.6.1]: https://github.com/bitshifter/glam-rs/compare/0.6.0...0.6.1