mirror of
https://github.com/kaosat-dev/Blender_bevy_components_workflow.git
synced 2024-12-22 07:34:10 +00:00
Bevy gltf blueprints fixes and tweaks (#24)
* fixed bad default path for library * added missing ComponentsFromGltfPlugin which causes the blueprint plugin not to work as expected if ComponentsFromGltfPlugin is not added elsewhere * all info! calls are now debug! for a less spammy debugging experience * refactor(examples:advanced): * removed ComponentsFromGltfPlugin as that is now included directly in the blueprints plugin * moved all physics (rapier) related code to the core/physics module
This commit is contained in:
parent
f41a315563
commit
bce6d43c50
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -721,7 +721,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "bevy_gltf_blueprints"
|
||||
version = "0.1.3"
|
||||
version = "0.1.4"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"bevy_gltf_components 0.1.2",
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "bevy_gltf_blueprints"
|
||||
version = "0.1.3"
|
||||
version = "0.1.4"
|
||||
authors = ["Mark 'kaosat-dev' Moissette"]
|
||||
description = "Adds the ability to define Blueprints/Prefabs for [Bevy](https://bevyengine.org/) inside gltf files and spawn them in Bevy."
|
||||
homepage = "https://github.com/kaosat-dev/Blender_bevy_components_workflow"
|
||||
|
@ -10,7 +10,7 @@ pub use clone_entity::*;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use bevy::prelude::*;
|
||||
use bevy_gltf_components::GltfComponentsSet;
|
||||
use bevy_gltf_components::{ComponentsFromGltfPlugin, GltfComponentsSet};
|
||||
|
||||
#[derive(SystemSet, Debug, Hash, PartialEq, Eq, Clone)]
|
||||
/// set for the two stages of blueprint based spawning :
|
||||
@ -49,14 +49,15 @@ pub struct BlueprintsPlugin {
|
||||
impl Default for BlueprintsPlugin {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
library_folder: PathBuf::from("assets/models/library"),
|
||||
library_folder: PathBuf::from("models/library"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Plugin for BlueprintsPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.register_type::<BlueprintName>()
|
||||
app.add_plugins(ComponentsFromGltfPlugin)
|
||||
.register_type::<BlueprintName>()
|
||||
.register_type::<SpawnHere>()
|
||||
.insert_resource(BluePrintsConfig {
|
||||
library_folder: self.library_folder.clone(),
|
||||
|
@ -51,13 +51,13 @@ pub(crate) fn spawn_from_blueprints(
|
||||
blueprints_config: Res<BluePrintsConfig>,
|
||||
) {
|
||||
for (entity, name, blupeprint_name, global_transform) in spawn_placeholders.iter() {
|
||||
info!("need to spawn {:?}", blupeprint_name.0);
|
||||
debug!("need to spawn {:?}", blupeprint_name.0);
|
||||
let what = &blupeprint_name.0;
|
||||
let model_file_name = format!("{}.glb", &what);
|
||||
let model_path =
|
||||
Path::new(&blueprints_config.library_folder).join(Path::new(model_file_name.as_str()));
|
||||
|
||||
info!("attempting to spawn {:?}", model_path);
|
||||
debug!("attempting to spawn {:?}", model_path);
|
||||
let scene: Handle<Gltf> = asset_server.load(model_path);
|
||||
// let scene = game_assets.models.get(&model_path).expect(&format!("no matching model {:?} found", model_path));
|
||||
|
||||
|
@ -124,12 +124,12 @@ pub(crate) fn cleanup_scene_instances(
|
||||
for (entity, children) in scene_instances.iter() {
|
||||
if children.len() == 0 {
|
||||
// it seems this does not happen ?
|
||||
info!("cleaning up emptied spawned scene instance");
|
||||
debug!("cleaning up emptied spawned scene instance");
|
||||
commands.entity(entity).despawn_recursive();
|
||||
}
|
||||
}
|
||||
for entity in without_children.iter() {
|
||||
info!("cleaning up emptied spawned scene instance");
|
||||
debug!("cleaning up emptied spawned scene instance");
|
||||
commands.entity(entity).despawn_recursive();
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,8 @@
|
||||
pub mod physics_replace_proxies;
|
||||
use bevy_rapier3d::{
|
||||
prelude::{NoUserData, RapierPhysicsPlugin},
|
||||
render::RapierDebugRenderPlugin,
|
||||
};
|
||||
pub use physics_replace_proxies::*;
|
||||
|
||||
pub mod utils;
|
||||
@ -14,16 +18,20 @@ use bevy_gltf_blueprints::GltfBlueprintsSet;
|
||||
pub struct PhysicsPlugin;
|
||||
impl Plugin for PhysicsPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.register_type::<AutoAABBCollider>()
|
||||
.register_type::<physics_replace_proxies::Collider>()
|
||||
// find a way to make serde's stuff serializable
|
||||
// .register_type::<bevy_rapier3d::dynamics::CoefficientCombineRule>()
|
||||
//bevy_rapier3d::dynamics::CoefficientCombineRule
|
||||
.add_systems(
|
||||
Update,
|
||||
physics_replace_proxies.after(GltfBlueprintsSet::AfterSpawn),
|
||||
)
|
||||
.add_systems(OnEnter(GameState::InGame), resume_physics)
|
||||
.add_systems(OnExit(GameState::InGame), pause_physics);
|
||||
app.add_plugins((
|
||||
RapierPhysicsPlugin::<NoUserData>::default(),
|
||||
RapierDebugRenderPlugin::default(),
|
||||
))
|
||||
.register_type::<AutoAABBCollider>()
|
||||
.register_type::<physics_replace_proxies::Collider>()
|
||||
// find a way to make serde's stuff serializable
|
||||
// .register_type::<bevy_rapier3d::dynamics::CoefficientCombineRule>()
|
||||
//bevy_rapier3d::dynamics::CoefficientCombineRule
|
||||
.add_systems(
|
||||
Update,
|
||||
physics_replace_proxies.after(GltfBlueprintsSet::AfterSpawn),
|
||||
)
|
||||
.add_systems(OnEnter(GameState::InGame), resume_physics)
|
||||
.add_systems(OnExit(GameState::InGame), pause_physics);
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,5 @@
|
||||
use bevy::{asset::ChangeWatcher, gltf::Gltf, prelude::*};
|
||||
use bevy::{asset::ChangeWatcher, prelude::*};
|
||||
use bevy_editor_pls::prelude::*;
|
||||
use bevy_gltf_components::ComponentsFromGltfPlugin;
|
||||
use bevy_rapier3d::prelude::*;
|
||||
use std::time::Duration;
|
||||
|
||||
mod core;
|
||||
use crate::core::*;
|
||||
@ -31,11 +28,7 @@ fn main() {
|
||||
}),
|
||||
// editor
|
||||
EditorPlugin::default(),
|
||||
// physics
|
||||
RapierPhysicsPlugin::<NoUserData>::default(),
|
||||
RapierDebugRenderPlugin::default(),
|
||||
// our custom plugins
|
||||
ComponentsFromGltfPlugin,
|
||||
StatePlugin,
|
||||
AssetsPlugin,
|
||||
CorePlugin, // reusable plugins
|
||||
|
Loading…
Reference in New Issue
Block a user