Skip to content

Commit

Permalink
merge main@upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
jrobsonchase committed Oct 1, 2024
2 parents fe173a1 + 956d9cc commit 5315590
Show file tree
Hide file tree
Showing 315 changed files with 12,165 additions and 5,595 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/docs_improvement.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ assignees: ''

Provide a link to the documentation and describe how it could be improved. In what ways is it incomplete, incorrect, or misleading?

If you have suggestions on exactly what the new docs should say, feel free to include them here. Or alternatively, make the changes yourself and [create a pull request](https://bevyengine.org/learn/book/contributing/code/) instead.
If you have suggestions on exactly what the new docs should say, feel free to include them here. Alternatively, make the changes yourself and [create a pull request](https://bevyengine.org/learn/book/contributing/code/) instead.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Feature Request
about: Propose a new feature!
title: ''
labels: C-Enhancement, S-Needs-Triage
labels: C-Feature, S-Needs-Triage
assignees: ''
---

Expand Down
43 changes: 38 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,17 @@ description = "Loads and renders a glTF file as a scene, including the gltf extr
category = "3D Rendering"
wasm = true

[[example]]
name = "query_gltf_primitives"
path = "examples/3d/query_gltf_primitives.rs"
doc-scrape-examples = true

[package.metadata.example.query_gltf_primitives]
name = "Query glTF primitives"
description = "Query primitives in a glTF scene"
category = "3D Rendering"
wasm = true

[[example]]
name = "motion_blur"
path = "examples/3d/motion_blur.rs"
Expand Down Expand Up @@ -1146,7 +1157,7 @@ setup = [
"curl",
"-o",
"assets/models/bunny.meshlet_mesh",
"https://raw.githubusercontent.com/JMS55/bevy_meshlet_asset/e3da1533b4c69fb967f233c817e9b0921134d317/bunny.meshlet_mesh",
"https://raw.githubusercontent.com/JMS55/bevy_meshlet_asset/854eb98353ad94aea1104f355fc24dbe4fda679d/bunny.meshlet_mesh",
],
]

Expand Down Expand Up @@ -1892,6 +1903,17 @@ description = "Run systems only when one or multiple conditions are met"
category = "ECS (Entity Component System)"
wasm = false

[[example]]
name = "fallible_params"
path = "examples/ecs/fallible_params.rs"
doc-scrape-examples = true

[package.metadata.example.fallible_params]
name = "Fallible System Parameters"
description = "Systems are skipped if their parameters cannot be acquired"
category = "ECS (Entity Component System)"
wasm = false

[[example]]
name = "startup_system"
path = "examples/ecs/startup_system.rs"
Expand Down Expand Up @@ -2445,13 +2467,24 @@ category = "Shaders"
wasm = true

[[example]]
name = "shader_instancing"
path = "examples/shader/shader_instancing.rs"
name = "custom_shader_instancing"
path = "examples/shader/custom_shader_instancing.rs"
doc-scrape-examples = true

[package.metadata.example.custom_shader_instancing]
name = "Instancing"
description = "A shader that renders a mesh multiple times in one draw call using low level rendering api"
category = "Shaders"
wasm = true

[[example]]
name = "automatic_instancing"
path = "examples/shader/automatic_instancing.rs"
doc-scrape-examples = true

[package.metadata.example.shader_instancing]
[package.metadata.example.automatic_instancing]
name = "Instancing"
description = "A shader that renders a mesh multiple times in one draw call"
description = "Shows that multiple instances of a cube are automatically instanced in one draw call"
category = "Shaders"
wasm = true

Expand Down
Binary file added assets/models/GltfPrimitives/gltf_primitives.glb
Binary file not shown.
3 changes: 3 additions & 0 deletions assets/shaders/gpu_readback.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@

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

@compute @workgroup_size(1)
fn main(@builtin(global_invocation_id) global_id: vec3<u32>) {
// We use the global_id to index the array to make sure we don't
// access data used in another workgroup
data[global_id.x] += 1u;
// Write the same data to the texture
textureStore(texture, vec2<i32>(i32(global_id.x), 0), vec4<u32>(data[global_id.x], 0, 0, 0));
}
86 changes: 2 additions & 84 deletions crates/bevy_animation/src/animatable.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Traits and type for interpolating between values.
use crate::{util, AnimationEvaluationError, Interpolation};
use crate::util;
use bevy_color::{Laba, LinearRgba, Oklaba, Srgba, Xyza};
use bevy_math::*;
use bevy_reflect::Reflect;
Expand Down Expand Up @@ -188,93 +188,11 @@ impl Animatable for Quat {
}
}

/// An abstraction over a list of keyframes.
///
/// Using this abstraction instead of `Vec<T>` enables more flexibility in how
/// keyframes are stored. In particular, morph weights use this trait in order
/// to flatten the keyframes for all morph weights into a single vector instead
/// of nesting vectors.
pub(crate) trait GetKeyframe {
/// The type of the property to be animated.
type Output;
/// Retrieves the value of the keyframe at the given index.
fn get_keyframe(&self, index: usize) -> Option<&Self::Output>;
}

/// Interpolates between keyframes and stores the result in `dest`.
///
/// This is factored out so that it can be shared between implementations of
/// [`crate::keyframes::Keyframes`].
pub(crate) fn interpolate_keyframes<T>(
dest: &mut T,
keyframes: &(impl GetKeyframe<Output = T> + ?Sized),
interpolation: Interpolation,
step_start: usize,
time: f32,
weight: f32,
duration: f32,
) -> Result<(), AnimationEvaluationError>
where
T: Animatable + Clone,
{
let value = match interpolation {
Interpolation::Step => {
let Some(start_keyframe) = keyframes.get_keyframe(step_start) else {
return Err(AnimationEvaluationError::KeyframeNotPresent(step_start));
};
(*start_keyframe).clone()
}

Interpolation::Linear => {
let (Some(start_keyframe), Some(end_keyframe)) = (
keyframes.get_keyframe(step_start),
keyframes.get_keyframe(step_start + 1),
) else {
return Err(AnimationEvaluationError::KeyframeNotPresent(step_start + 1));
};

T::interpolate(start_keyframe, end_keyframe, time)
}

Interpolation::CubicSpline => {
let (
Some(start_keyframe),
Some(start_tangent_keyframe),
Some(end_tangent_keyframe),
Some(end_keyframe),
) = (
keyframes.get_keyframe(step_start * 3 + 1),
keyframes.get_keyframe(step_start * 3 + 2),
keyframes.get_keyframe(step_start * 3 + 3),
keyframes.get_keyframe(step_start * 3 + 4),
)
else {
return Err(AnimationEvaluationError::KeyframeNotPresent(
step_start * 3 + 4,
));
};

interpolate_with_cubic_bezier(
start_keyframe,
start_tangent_keyframe,
end_tangent_keyframe,
end_keyframe,
time,
duration,
)
}
};

*dest = T::interpolate(dest, &value, weight);

Ok(())
}

/// Evaluates a cubic Bézier curve at a value `t`, given two endpoints and the
/// derivatives at those endpoints.
///
/// The derivatives are linearly scaled by `duration`.
fn interpolate_with_cubic_bezier<T>(p0: &T, d0: &T, d3: &T, p3: &T, t: f32, duration: f32) -> T
pub fn interpolate_with_cubic_bezier<T>(p0: &T, d0: &T, d3: &T, p3: &T, t: f32, duration: f32) -> T
where
T: Animatable + Clone,
{
Expand Down
Loading

0 comments on commit 5315590

Please sign in to comment.