Skip to content

Commit fbeb509

Browse files
committed
Merge branch 'main' into migrate_bevy_sprite
2 parents 7d955e4 + da50f7d commit fbeb509

File tree

263 files changed

+9636
-4405
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

263 files changed

+9636
-4405
lines changed

Cargo.toml

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,17 @@ description = "Loads and renders a glTF file as a scene, including the gltf extr
910910
category = "3D Rendering"
911911
wasm = true
912912

913+
[[example]]
914+
name = "query_gltf_primitives"
915+
path = "examples/3d/query_gltf_primitives.rs"
916+
doc-scrape-examples = true
917+
918+
[package.metadata.example.query_gltf_primitives]
919+
name = "Query glTF primitives"
920+
description = "Query primitives in a glTF scene"
921+
category = "3D Rendering"
922+
wasm = true
923+
913924
[[example]]
914925
name = "motion_blur"
915926
path = "examples/3d/motion_blur.rs"
@@ -2456,13 +2467,24 @@ category = "Shaders"
24562467
wasm = true
24572468

24582469
[[example]]
2459-
name = "shader_instancing"
2460-
path = "examples/shader/shader_instancing.rs"
2470+
name = "custom_shader_instancing"
2471+
path = "examples/shader/custom_shader_instancing.rs"
24612472
doc-scrape-examples = true
24622473

2463-
[package.metadata.example.shader_instancing]
2474+
[package.metadata.example.custom_shader_instancing]
24642475
name = "Instancing"
2465-
description = "A shader that renders a mesh multiple times in one draw call"
2476+
description = "A shader that renders a mesh multiple times in one draw call using low level rendering api"
2477+
category = "Shaders"
2478+
wasm = true
2479+
2480+
[[example]]
2481+
name = "automatic_instancing"
2482+
path = "examples/shader/automatic_instancing.rs"
2483+
doc-scrape-examples = true
2484+
2485+
[package.metadata.example.automatic_instancing]
2486+
name = "Instancing"
2487+
description = "Shows that multiple instances of a cube are automatically instanced in one draw call"
24662488
category = "Shaders"
24672489
wasm = true
24682490

@@ -3408,6 +3430,17 @@ description = "Demonstrates screen space reflections with water ripples"
34083430
category = "3D Rendering"
34093431
wasm = false
34103432

3433+
[[example]]
3434+
name = "camera_sub_view"
3435+
path = "examples/3d/camera_sub_view.rs"
3436+
doc-scrape-examples = true
3437+
3438+
[package.metadata.example.camera_sub_view]
3439+
name = "Camera sub view"
3440+
description = "Demonstrates using different sub view effects on a camera"
3441+
category = "3D Rendering"
3442+
wasm = true
3443+
34113444
[[example]]
34123445
name = "color_grading"
34133446
path = "examples/3d/color_grading.rs"
4.32 KB
Binary file not shown.

assets/shaders/gpu_readback.wgsl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33

44
// This is the data that lives in the gpu only buffer
55
@group(0) @binding(0) var<storage, read_write> data: array<u32>;
6+
@group(0) @binding(1) var texture: texture_storage_2d<r32uint, write>;
67

78
@compute @workgroup_size(1)
89
fn main(@builtin(global_invocation_id) global_id: vec3<u32>) {
910
// We use the global_id to index the array to make sure we don't
1011
// access data used in another workgroup
1112
data[global_id.x] += 1u;
13+
// Write the same data to the texture
14+
textureStore(texture, vec2<i32>(i32(global_id.x), 0), vec4<u32>(data[global_id.x], 0, 0, 0));
1215
}

crates/bevy_animation/src/animatable.rs

Lines changed: 2 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Traits and type for interpolating between values.
22
3-
use crate::{util, AnimationEvaluationError, Interpolation};
3+
use crate::util;
44
use bevy_color::{Laba, LinearRgba, Oklaba, Srgba, Xyza};
55
use bevy_math::*;
66
use bevy_reflect::Reflect;
@@ -188,93 +188,11 @@ impl Animatable for Quat {
188188
}
189189
}
190190

191-
/// An abstraction over a list of keyframes.
192-
///
193-
/// Using this abstraction instead of `Vec<T>` enables more flexibility in how
194-
/// keyframes are stored. In particular, morph weights use this trait in order
195-
/// to flatten the keyframes for all morph weights into a single vector instead
196-
/// of nesting vectors.
197-
pub(crate) trait GetKeyframe {
198-
/// The type of the property to be animated.
199-
type Output;
200-
/// Retrieves the value of the keyframe at the given index.
201-
fn get_keyframe(&self, index: usize) -> Option<&Self::Output>;
202-
}
203-
204-
/// Interpolates between keyframes and stores the result in `dest`.
205-
///
206-
/// This is factored out so that it can be shared between implementations of
207-
/// [`crate::keyframes::Keyframes`].
208-
pub(crate) fn interpolate_keyframes<T>(
209-
dest: &mut T,
210-
keyframes: &(impl GetKeyframe<Output = T> + ?Sized),
211-
interpolation: Interpolation,
212-
step_start: usize,
213-
time: f32,
214-
weight: f32,
215-
duration: f32,
216-
) -> Result<(), AnimationEvaluationError>
217-
where
218-
T: Animatable + Clone,
219-
{
220-
let value = match interpolation {
221-
Interpolation::Step => {
222-
let Some(start_keyframe) = keyframes.get_keyframe(step_start) else {
223-
return Err(AnimationEvaluationError::KeyframeNotPresent(step_start));
224-
};
225-
(*start_keyframe).clone()
226-
}
227-
228-
Interpolation::Linear => {
229-
let (Some(start_keyframe), Some(end_keyframe)) = (
230-
keyframes.get_keyframe(step_start),
231-
keyframes.get_keyframe(step_start + 1),
232-
) else {
233-
return Err(AnimationEvaluationError::KeyframeNotPresent(step_start + 1));
234-
};
235-
236-
T::interpolate(start_keyframe, end_keyframe, time)
237-
}
238-
239-
Interpolation::CubicSpline => {
240-
let (
241-
Some(start_keyframe),
242-
Some(start_tangent_keyframe),
243-
Some(end_tangent_keyframe),
244-
Some(end_keyframe),
245-
) = (
246-
keyframes.get_keyframe(step_start * 3 + 1),
247-
keyframes.get_keyframe(step_start * 3 + 2),
248-
keyframes.get_keyframe(step_start * 3 + 3),
249-
keyframes.get_keyframe(step_start * 3 + 4),
250-
)
251-
else {
252-
return Err(AnimationEvaluationError::KeyframeNotPresent(
253-
step_start * 3 + 4,
254-
));
255-
};
256-
257-
interpolate_with_cubic_bezier(
258-
start_keyframe,
259-
start_tangent_keyframe,
260-
end_tangent_keyframe,
261-
end_keyframe,
262-
time,
263-
duration,
264-
)
265-
}
266-
};
267-
268-
*dest = T::interpolate(dest, &value, weight);
269-
270-
Ok(())
271-
}
272-
273191
/// Evaluates a cubic Bézier curve at a value `t`, given two endpoints and the
274192
/// derivatives at those endpoints.
275193
///
276194
/// The derivatives are linearly scaled by `duration`.
277-
fn interpolate_with_cubic_bezier<T>(p0: &T, d0: &T, d3: &T, p3: &T, t: f32, duration: f32) -> T
195+
pub fn interpolate_with_cubic_bezier<T>(p0: &T, d0: &T, d3: &T, p3: &T, t: f32, duration: f32) -> T
278196
where
279197
T: Animatable + Clone,
280198
{

0 commit comments

Comments
 (0)