Vendor dependencies for 0.3.0 release

This commit is contained in:
2025-09-27 10:29:08 -05:00
parent 0c8d39d483
commit 82ab7f317b
26803 changed files with 16134934 additions and 0 deletions

25
vendor/bevy_scene/src/reflect_utils.rs vendored Normal file
View File

@@ -0,0 +1,25 @@
use bevy_reflect::{PartialReflect, ReflectFromReflect, TypeRegistration};
/// Attempts to clone a [`PartialReflect`] value using various methods.
///
/// This first attempts to clone via [`PartialReflect::reflect_clone`].
/// then falls back to [`ReflectFromReflect::from_reflect`],
/// and finally [`PartialReflect::to_dynamic`] if the first two methods fail.
///
/// This helps ensure that the original type and type data is retained,
/// and only returning a dynamic type if all other methods fail.
pub(super) fn clone_reflect_value(
value: &dyn PartialReflect,
type_registration: &TypeRegistration,
) -> Box<dyn PartialReflect> {
value
.reflect_clone()
.map(PartialReflect::into_partial_reflect)
.unwrap_or_else(|_| {
type_registration
.data::<ReflectFromReflect>()
.and_then(|fr| fr.from_reflect(value.as_partial_reflect()))
.map(PartialReflect::into_partial_reflect)
.unwrap_or_else(|| value.to_dynamic())
})
}