Upgrade to Bevy 0.19 and harden editor workflows
CI / Format, lint, test, build (push) Has been cancelled
CI / Format, lint, test, build (push) Has been cancelled
This commit is contained in:
1 parent
3f85d25cc7
commit
b5e561904c
204 files changed
+6972
-29907
No files matched your search
@@ -67,6 +67,10 @@ pub fn hydrate_brushes(
|
||||
}
|
||||
}
|
||||
|
||||
#[expect(
|
||||
clippy::too_many_arguments,
|
||||
reason = "hydration keeps Bevy asset stores and authored brush inputs explicit"
|
||||
)]
|
||||
pub fn spawn_brush_mesh(
|
||||
commands: &mut Commands,
|
||||
asset_server: &AssetServer,
|
||||
@@ -243,7 +247,12 @@ fn append_face(
|
||||
for vertex in &face.vertices {
|
||||
positions.push([vertex.x, vertex.y, vertex.z]);
|
||||
normals.push([normal.x, normal.y, normal.z]);
|
||||
let uv = Vec2::new(vertex.dot(u_axis), vertex.dot(v_axis)) * face.uv_scale + face.uv_offset;
|
||||
let uv = transform_face_uv(
|
||||
Vec2::new(vertex.dot(u_axis), vertex.dot(v_axis)),
|
||||
face.uv_scale,
|
||||
face.uv_rotation,
|
||||
face.uv_offset,
|
||||
);
|
||||
uvs.push([uv.x, uv.y]);
|
||||
}
|
||||
|
||||
@@ -262,6 +271,29 @@ fn append_face(
|
||||
Some(())
|
||||
}
|
||||
|
||||
fn transform_face_uv(base: Vec2, scale: Vec2, rotation_degrees: f32, offset: Vec2) -> Vec2 {
|
||||
let scale = if scale.is_finite() { scale } else { Vec2::ONE };
|
||||
let rotation_degrees = if rotation_degrees.is_finite() {
|
||||
rotation_degrees
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
let offset = if offset.is_finite() {
|
||||
offset
|
||||
} else {
|
||||
Vec2::ZERO
|
||||
};
|
||||
let scaled = base * scale;
|
||||
if rotation_degrees == 0.0 {
|
||||
return scaled + offset;
|
||||
}
|
||||
let (sin, cos) = rotation_degrees.to_radians().sin_cos();
|
||||
Vec2::new(
|
||||
scaled.x * cos - scaled.y * sin,
|
||||
scaled.x * sin + scaled.y * cos,
|
||||
) + offset
|
||||
}
|
||||
|
||||
fn face_axes(normal: Vec3) -> (Vec3, Vec3) {
|
||||
let tangent_seed = if normal.y.abs() > 0.9 {
|
||||
Vec3::X
|
||||
@@ -319,6 +351,27 @@ mod tests {
|
||||
}));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn brush_face_uv_transform_applies_scale_rotation_and_offset() {
|
||||
let uv = transform_face_uv(
|
||||
Vec2::new(2.0, 1.0),
|
||||
Vec2::new(2.0, 3.0),
|
||||
90.0,
|
||||
Vec2::new(0.25, -0.5),
|
||||
);
|
||||
|
||||
assert!((uv.x + 2.75).abs() < 0.0001);
|
||||
assert!((uv.y - 3.5).abs() < 0.0001);
|
||||
|
||||
let sanitized = transform_face_uv(
|
||||
Vec2::new(2.0, 1.0),
|
||||
Vec2::new(f32::NAN, 3.0),
|
||||
f32::INFINITY,
|
||||
Vec2::new(0.25, f32::NAN),
|
||||
);
|
||||
assert_eq!(sanitized, Vec2::new(2.0, 1.0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid_brush_returns_none() {
|
||||
let mut brush = BrushDesc::default();
|
||||
|
||||
Reference in new issue
Block a user