Skip to content

Commit

Permalink
Fix invalid WGSL for large u32 values (#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
pcwalton authored Feb 27, 2024
1 parent 5bf400f commit 70185ee
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Added a new `ScreenSpaceSizeModifier` which negates the effect of perspective projection, and makes the particle's size a pixel size in screen space, instead of a Bevy world unit size. This replaces the hard-coded behavior previously available on the `SetSizeModifier`.
- Added a new `ConformToSphereModifier` acting as an attractor applying a force toward a point (sphere center) to all particles in range, and making particles conform ("stick") to the sphere surface.
- Added `vec2` and `vec3` functions that allow construction of vectors from dynamic parts.

### Changed

Expand All @@ -23,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Fixed a panic in rendering randomly occurring when no effect is present.
- Fixed invalid WGSL being generated for large `u32` values.

## [0.10.0] 2024-02-24

Expand Down
4 changes: 2 additions & 2 deletions src/graph/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3425,8 +3425,8 @@ mod tests {
(sign, "sign", "vec3<f32>(1.,-3.1,6.99)"),
(sin, "sin", "vec3<f32>(1.,-3.1,6.99)"),
(tan, "tan", "vec3<f32>(1.,-3.1,6.99)"),
(unpack4x8snorm, "unpack4x8snorm", "0"),
(unpack4x8unorm, "unpack4x8unorm", "0"),
(unpack4x8snorm, "unpack4x8snorm", "0u"),
(unpack4x8unorm, "unpack4x8unorm", "0u"),
] {
let expr = ctx.eval(&m, expr);
assert!(expr.is_ok());
Expand Down
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ impl ToWgslString for IVec4 {

impl ToWgslString for u32 {
fn to_wgsl_string(&self) -> String {
format!("{}", self)
format!("{}u", self)
}
}

Expand Down Expand Up @@ -1532,11 +1532,11 @@ mod tests {
#[test]
fn to_wgsl_uvec() {
let s = UVec2::new(1, 2).to_wgsl_string();
assert_eq!(s, "vec2<u32>(1,2)");
assert_eq!(s, "vec2<u32>(1u,2u)");
let s = UVec3::new(1, 2, 42).to_wgsl_string();
assert_eq!(s, "vec3<u32>(1,2,42)");
assert_eq!(s, "vec3<u32>(1u,2u,42u)");
let s = UVec4::new(1, 2, 42, 5).to_wgsl_string();
assert_eq!(s, "vec4<u32>(1,2,42,5)");
assert_eq!(s, "vec4<u32>(1u,2u,42u,5u)");
}

#[test]
Expand Down

0 comments on commit 70185ee

Please sign in to comment.