Compare commits

..

2 Commits

Author SHA1 Message Date
andriyDev
d50fb4508d
Merge b04db12c37 into 06403153c3 2024-05-25 08:52:27 +00:00
andriyDev
b04db12c37 Add a feature flag for using bevy_gltf_blueprints. 2024-05-25 01:50:07 -07:00
2 changed files with 24 additions and 9 deletions

View File

@ -14,8 +14,12 @@ license = "MIT OR Apache-2.0"
workspace = true workspace = true
[dependencies] [dependencies]
bevy = { version = "0.13", default-features = false, features = ["bevy_scene"] } bevy = { version = "0.13", default-features = false, features = [
"bevy_asset",
"bevy_scene",
] }
bevy_gltf_components = { version = "0.5", path = "../bevy_gltf_components" } bevy_gltf_components = { version = "0.5", path = "../bevy_gltf_components" }
bevy_gltf_blueprints = { version = "0.10", path = "../bevy_gltf_blueprints", optional = true }
[dev-dependencies] [dev-dependencies]
bevy = { version = "0.13", default-features = false, features = [ bevy = { version = "0.13", default-features = false, features = [

View File

@ -1,9 +1,10 @@
use bevy::{ use bevy::{
app::{App, Plugin}, app::{App, Plugin},
asset::Handle,
ecs::{ ecs::{
component::Component, component::Component,
entity::Entity, entity::Entity,
query::With, query::{Or, With},
reflect::ReflectComponent, reflect::ReflectComponent,
schedule::{IntoSystemConfigs, IntoSystemSetConfigs, SystemSet}, schedule::{IntoSystemConfigs, IntoSystemSetConfigs, SystemSet},
system::{Commands, Query, Res, ResMut, Resource, SystemParam}, system::{Commands, Query, Res, ResMut, Resource, SystemParam},
@ -12,12 +13,15 @@ use bevy::{
log::warn, log::warn,
prelude::Update, prelude::Update,
reflect::{Reflect, TypePath}, reflect::{Reflect, TypePath},
scene::SceneInstance, scene::Scene,
utils::HashMap, utils::HashMap,
}; };
use bevy_gltf_components::GltfComponentsSet; use bevy_gltf_components::GltfComponentsSet;
use std::marker::PhantomData; use std::marker::PhantomData;
#[cfg(feature = "bevy_gltf_blueprints")]
use bevy_gltf_blueprints::{BlueprintName, GltfBlueprintsSet};
/// Plugin for keeping the GltfRefMap in sync. /// Plugin for keeping the GltfRefMap in sync.
pub struct GltfRefMapPlugin; pub struct GltfRefMapPlugin;
@ -25,12 +29,16 @@ impl Plugin for GltfRefMapPlugin {
fn build(&self, app: &mut App) { fn build(&self, app: &mut App) {
app.register_type::<GltfRefTarget>() app.register_type::<GltfRefTarget>()
.init_resource::<GltfRefMap>() .init_resource::<GltfRefMap>()
.configure_sets( .configure_sets(Update, {
Update, let set = (GltfRefsSet::CreateRefMap, GltfRefsSet::ResolveRefs)
(GltfRefsSet::CreateRefMap, GltfRefsSet::ResolveRefs)
.chain() .chain()
.after(GltfComponentsSet::Injection), .after(GltfComponentsSet::Injection);
)
#[cfg(feature = "bevy_gltf_blueprints")]
let set = set.after(GltfBlueprintsSet::Spawn);
set
})
.add_systems( .add_systems(
Update, Update,
GltfRefMap::create_ref_map.in_set(GltfRefsSet::CreateRefMap), GltfRefMap::create_ref_map.in_set(GltfRefsSet::CreateRefMap),
@ -156,7 +164,10 @@ impl<T: Component + FromGltfRef> Default for GltfRefPlugin<T> {
/// SystemParam to find the Gltf that an entity belongs to. /// SystemParam to find the Gltf that an entity belongs to.
#[derive(SystemParam)] #[derive(SystemParam)]
pub struct GltfForEntity<'w, 's> { pub struct GltfForEntity<'w, 's> {
gltfs: Query<'w, 's, (), With<SceneInstance>>, #[cfg(not(feature = "bevy_gltf_blueprints"))]
gltfs: Query<'w, 's, (), With<Handle<Scene>>>,
#[cfg(feature = "bevy_gltf_blueprints")]
gltfs: Query<'w, 's, (), Or<(With<Handle<Scene>>, With<BlueprintName>)>>,
hierarchy: Query<'w, 's, &'static Parent>, hierarchy: Query<'w, 's, &'static Parent>,
} }