Skip to content

chore(v0.14): upgraded all current crates, examples, testing setup etc to Bevy 0.14 #195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions crates/bevy_gltf_blueprints/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bevy_gltf_blueprints"
version = "0.10.2"
version = "0.11.0"
authors = ["Mark 'kaosat-dev' Moissette"]
description = "Adds the ability to define Blueprints/Prefabs for Bevy inside gltf files and spawn them in Bevy."
homepage = "https://github.com/kaosat-dev/Blender_bevy_components_workflow"
Expand All @@ -14,8 +14,8 @@ license = "MIT OR Apache-2.0"
workspace = true

[dependencies]
bevy_gltf_components = { version = "0.5", path = "../bevy_gltf_components" }
bevy = { version = "0.13", default-features = false, features = ["bevy_asset", "bevy_scene", "bevy_gltf", "bevy_animation", "animation"] }
bevy_gltf_components = { version = "0.6", path = "../bevy_gltf_components" }
bevy = { version = "0.14", default-features = false, features = ["bevy_asset", "bevy_scene", "bevy_gltf", "bevy_animation", "animation"] }

[dev-dependencies]
bevy = { version = "0.13", default-features = false, features = ["dynamic_linking"] }
bevy = { version = "0.14", default-features = false, features = ["dynamic_linking"] }
11 changes: 7 additions & 4 deletions crates/bevy_gltf_blueprints/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
[![License](https://img.shields.io/crates/l/bevy_gltf_blueprints)](https://github.com/kaosat-dev/Blender_bevy_components_workflow/blob/main/crates/bevy_gltf_blueprints/License.md)
[![Bevy tracking](https://img.shields.io/badge/Bevy%20tracking-released%20version-lightblue)](https://github.com/bevyengine/bevy/blob/main/docs/plugins_guidelines.md#main-branch-tracking)

# bevy_gltf_blueprints
# bevy_gltf_blueprints (deprecated in favor of Blenvy)

> bevy_gltf_blueprints has been deprecated in favor of its successor [Blenvy](https://crates.io/crates/blenvy), part of the [Blenvy project](https://github.com/kaosat-dev/Blenvy). No further development or maintenance will be done for Bevy bevy_gltf_blueprints. See [#194](https://github.com/kaosat-dev/Blenvy/issues/194) for background.

Built on [bevy_gltf_components](https://crates.io/crates/bevy_gltf_components) this crate adds the ability to define Blueprints/Prefabs for [Bevy](https://bevyengine.org/) inside gltf files and spawn them in Bevy.

Expand All @@ -27,8 +29,8 @@ Here's a minimal usage example:
```toml
# Cargo.toml
[dependencies]
bevy="0.13"
bevy_gltf_blueprints = { version = "0.10"}
bevy="0.14"
bevy_gltf_blueprints = { version = "0.11.0"}

```

Expand Down Expand Up @@ -66,7 +68,7 @@ fn spawn_blueprint(
Add the following to your `[dependencies]` section in `Cargo.toml`:

```toml
bevy_gltf_blueprints = "0.10"
bevy_gltf_blueprints = "0.11.0"
```

Or use `cargo add`:
Expand Down Expand Up @@ -344,6 +346,7 @@ The main branch is compatible with the latest Bevy release, while the branch `be
Compatibility of `bevy_gltf_blueprints` versions:
| `bevy_gltf_blueprints` | `bevy` |
| :-- | :-- |
| `0.11` | `0.14` |
| `0.9 - 0.10` | `0.13` |
| `0.3 - 0.8` | `0.12` |
| `0.1 - 0.2` | `0.11` |
Expand Down
2 changes: 2 additions & 0 deletions crates/bevy_gltf_blueprints/src/animation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use bevy::utils::HashMap;
/// storage for animations for a given entity (hierarchy), essentially a clone of gltf's `named_animations`
pub struct Animations {
pub named_animations: HashMap<String, Handle<AnimationClip>>,
pub named_indices: HashMap<String, AnimationNodeIndex>,
pub graph: Handle<AnimationGraph>,
}

#[derive(Component, Debug)]
Expand Down
3 changes: 1 addition & 2 deletions crates/bevy_gltf_blueprints/src/copy_components.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use bevy::ecs::system::Command;
use bevy::prelude::*;
use bevy::{ecs::world::Command, prelude::*};
use std::any::TypeId;

// originally based https://github.com/bevyengine/bevy/issues/1515,
Expand Down
1 change: 0 additions & 1 deletion crates/bevy_gltf_blueprints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ pub struct BlueprintsPlugin {
pub library_folder: PathBuf,
/// Automatically generate aabbs for the blueprints root objects
pub aabbs: bool,
///
pub material_library: bool,
pub material_library_folder: PathBuf,
}
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_gltf_blueprints/src/materials.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ pub(crate) fn materials_inject2(
let mat_gltf = assets_gltf
.get(model_handle.id())
.expect("material should have been preloaded");
if mat_gltf.named_materials.contains_key(material_name) {
if mat_gltf.named_materials.contains_key(material_name as &str) {
let material = mat_gltf
.named_materials
.get(material_name)
.get(material_name as &str)
.expect("this material should have been loaded");
blueprints_config
.material_library_cache
Expand Down
18 changes: 17 additions & 1 deletion crates/bevy_gltf_blueprints/src/spawn_from_blueprints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ pub(crate) fn check_for_loaded(
}
}

#[allow(clippy::too_many_arguments)]
pub(crate) fn spawn_from_blueprints(
spawn_placeholders: Query<
(
Expand All @@ -214,6 +215,7 @@ pub(crate) fn spawn_from_blueprints(
mut game_world: Query<Entity, With<GameWorldTag>>,

assets_gltf: Res<Assets<Gltf>>,
mut graphs: ResMut<Assets<AnimationGraph>>,
asset_server: Res<AssetServer>,
blueprints_config: Res<BluePrintsConfig>,

Expand Down Expand Up @@ -273,14 +275,28 @@ pub(crate) fn spawn_from_blueprints(
original_children.push(*child);
}
}

let mut graph = AnimationGraph::new();
let mut named_animations: HashMap<String, Handle<AnimationClip>> = HashMap::new();
let mut named_indices: HashMap<String, AnimationNodeIndex> = HashMap::new();

for (key, clip) in gltf.named_animations.iter() {
named_animations.insert(key.to_string(), clip.clone());
let animation_index = graph.add_clip(clip.clone(), 1.0, graph.root);
named_indices.insert(key.to_string(), animation_index);
}
let graph = graphs.add(graph);

commands.entity(entity).insert((
SceneBundle {
scene: scene.clone(),
transform: transforms,
..Default::default()
},
Animations {
named_animations: gltf.named_animations.clone(),
named_animations,
named_indices,
graph,
},
Spawned,
OriginalChildren(original_children),
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_gltf_components/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bevy_gltf_components"
version = "0.5.1"
version = "0.6.0"
authors = ["Mark 'kaosat-dev' Moissette"]
description = "Allows you to define Bevy components direclty inside gltf files and instanciate the components on the Bevy side."
homepage = "https://github.com/kaosat-dev/Blender_bevy_components_workflow"
Expand All @@ -14,9 +14,9 @@ license = "MIT OR Apache-2.0"
workspace = true

[dependencies]
bevy = { version = "0.13", default-features = false, features = ["bevy_asset", "bevy_scene", "bevy_gltf"] }
bevy = { version = "0.14", default-features = false, features = ["bevy_asset", "bevy_scene", "bevy_gltf"] }
serde = "1.0.188"
ron = "0.8.1"

[dev-dependencies]
bevy = { version = "0.13", default-features = false, features = ["dynamic_linking"] }
bevy = { version = "0.14", default-features = false, features = ["dynamic_linking"] }
11 changes: 7 additions & 4 deletions crates/bevy_gltf_components/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
[![Bevy tracking](https://img.shields.io/badge/Bevy%20tracking-released%20version-lightblue)](https://github.com/bevyengine/bevy/blob/main/docs/plugins_guidelines.md#main-branch-tracking)


# bevy_gltf_components
# bevy_gltf_components (deprecated in favor of Blenvy)

> bevy_gltf_components has been deprecated in favor of its successor [Blenvy](https://crates.io/crates/blenvy), part of the [Blenvy project](https://github.com/kaosat-dev/Blenvy). No further development or maintenance will be done for Bevy bevy_gltf_components. See [#194](https://github.com/kaosat-dev/Blenvy/issues/194) for background.

This crate allows you to define [Bevy](https://bevyengine.org/) components direclty inside gltf files and instanciate the components on the Bevy side.

Expand All @@ -23,8 +25,8 @@ Here's a minimal usage example:
```toml
# Cargo.toml
[dependencies]
bevy="0.13"
bevy_gltf_components = { version = "0.5"}
bevy="0.14"
bevy_gltf_components = { version = "0.6"}

```

Expand Down Expand Up @@ -60,7 +62,7 @@ bevy_gltf_components = { version = "0.5"}
Add the following to your `[dependencies]` section in `Cargo.toml`:

```toml
bevy_gltf_components = "0.5"
bevy_gltf_components = "0.6"
```

Or use `cargo add`:
Expand Down Expand Up @@ -127,6 +129,7 @@ The main branch is compatible with the latest Bevy release, while the branch `be
Compatibility of `bevy_gltf_components` versions:
| `bevy_gltf_components` | `bevy` |
| :-- | :-- |
| `0.6` | `0.14` |
| `0.5` | `0.13` |
| `0.2 - 0.4` | `0.12` |
| `0.1` | `0.11` |
Expand Down
75 changes: 12 additions & 63 deletions crates/bevy_gltf_components/src/blender_settings/lighting.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
use bevy::pbr::DirectionalLightShadowMap;
use bevy::prelude::*;
use bevy::render::render_asset::RenderAssetUsages;
use bevy::render::render_resource::{
Extent3d, TextureDimension, TextureFormat, TextureViewDescriptor, TextureViewDimension,
};
use std::iter;

use crate::GltfComponentsSet;

Expand Down Expand Up @@ -56,17 +51,23 @@ fn process_lights(
for (mut light, blender_light_shadows) in directional_lights.iter_mut() {
if let Some(blender_light_shadows) = blender_light_shadows {
light.shadows_enabled = blender_light_shadows.enabled;
} else {
light.shadows_enabled = true;
}
}
for (mut light, blender_light_shadows) in spot_lights.iter_mut() {
if let Some(blender_light_shadows) = blender_light_shadows {
light.shadows_enabled = blender_light_shadows.enabled;
} else {
light.shadows_enabled = true;
}
}

for (mut light, blender_light_shadows) in point_lights.iter_mut() {
if let Some(blender_light_shadows) = blender_light_shadows {
light.shadows_enabled = blender_light_shadows.enabled;
} else {
light.shadows_enabled = true;
}
}
}
Expand All @@ -83,66 +84,14 @@ fn process_shadowmap(
}

fn process_background_shader(
background_shaders: Query<Ref<BlenderBackgroundShader>>,
cameras: Query<(Entity, Ref<Camera3d>)>,
mut images: ResMut<Assets<Image>>,
background_shaders: Query<&BlenderBackgroundShader, Added<BlenderBackgroundShader>>,
mut commands: Commands,
mut env_map_handle: Local<Option<Handle<Image>>>,
) {
let Ok(background_shader) = background_shaders.get_single() else {
return;
};

let env_map_handle = env_map_handle.get_or_insert_with(|| {
let size = Extent3d {
width: 1,
height: 6,
depth_or_array_layers: 1,
};
let dimension = TextureDimension::D2;
const SIDES_PER_CUBE: usize = 6;
let data: Vec<_> = iter::repeat(background_shader.color.as_rgba_u8())
.take(SIDES_PER_CUBE)
.flatten()
.collect();
let format = TextureFormat::Rgba8UnormSrgb;
let asset_usage = RenderAssetUsages::RENDER_WORLD;

let mut image = Image::new(size, dimension, data, format, asset_usage);

// Source: https://github.com/bevyengine/bevy/blob/85b488b73d6f6e75690962fba67a144d9beb6b88/examples/3d/skybox.rs#L152-L160
image.reinterpret_stacked_2d_as_array(image.height() / image.width());
image.texture_view_descriptor = Some(TextureViewDescriptor {
dimension: Some(TextureViewDimension::Cube),
..default()
});

images.add(image)
});
// Don't need the handle to be &mut
let env_map_handle = &*env_map_handle;

if background_shader.is_added() {
// We're using an environment map, so we don't need the ambient light
commands.remove_resource::<AmbientLight>();
}

let is_bg_outdated = background_shader.is_changed();
if is_bg_outdated {
let color = background_shader.color * background_shader.strength;
commands.insert_resource(ClearColor(color));
}
let camera_entities = cameras
.iter()
.filter_map(|(entity, cam)| (is_bg_outdated || cam.is_changed()).then_some(entity));

for camera_entity in camera_entities {
// See https://github.com/KhronosGroup/glTF-Blender-IO/blob/8573cc0dfb612091bfc1bcf6df55c18a44b9668a/addons/io_scene_gltf2/blender/com/gltf2_blender_conversion.py#L19
const PBR_WATTS_TO_LUMENS: f32 = 683.0;
commands.entity(camera_entity).insert(EnvironmentMapLight {
diffuse_map: env_map_handle.clone(),
specular_map: env_map_handle.clone(),
intensity: background_shader.strength * PBR_WATTS_TO_LUMENS,
for background_shader in background_shaders.iter() {
commands.insert_resource(AmbientLight {
color: background_shader.color,
// Just a guess, see <https://github.com/bevyengine/bevy/issues/12280>
brightness: background_shader.strength * 400.0,
});
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bevy::log::{debug, warn};
use bevy::reflect::serde::UntypedReflectDeserializer;
use bevy::reflect::serde::ReflectDeserializer;
use bevy::reflect::{Reflect, TypeInfo, TypeRegistration, TypeRegistry};
use bevy::utils::HashMap;
use ron::Value;
Expand Down Expand Up @@ -112,7 +112,7 @@ pub fn ronstring_to_reflect_component(
debug!("component data ron string {}", ron_string);
let mut deserializer = ron::Deserializer::from_str(ron_string.as_str())
.expect("deserialzer should have been generated from string");
let reflect_deserializer = UntypedReflectDeserializer::new(type_registry);
let reflect_deserializer = ReflectDeserializer::new(type_registry);
let component = reflect_deserializer
.deserialize(&mut deserializer)
.unwrap_or_else(|_| {
Expand Down
8 changes: 4 additions & 4 deletions crates/bevy_gltf_save_load/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bevy_gltf_save_load"
version = "0.4.1"
version = "0.5.0"
authors = ["Mark 'kaosat-dev' Moissette"]
description = "Save & load your bevy games"
homepage = "https://github.com/kaosat-dev/Blender_bevy_components_workflow"
Expand All @@ -14,8 +14,8 @@ license = "MIT OR Apache-2.0"
workspace = true

[dependencies]
bevy = { version = "0.13", default-features = false, features = ["bevy_asset", "bevy_scene", "bevy_gltf"] }
bevy_gltf_blueprints = { version = "0.10", path = "../bevy_gltf_blueprints" }
bevy = { version = "0.14", default-features = false, features = ["bevy_asset", "bevy_scene", "bevy_gltf"] }
bevy_gltf_blueprints = { version = "0.11", path = "../bevy_gltf_blueprints" }

[dev-dependencies]
bevy = { version = "0.13", default-features = false, features = ["dynamic_linking"] }
bevy = { version = "0.14", default-features = false, features = ["dynamic_linking"] }
11 changes: 7 additions & 4 deletions crates/bevy_gltf_save_load/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
[![License](https://img.shields.io/crates/l/bevy_gltf_save_load)](https://github.com/kaosat-dev/Blender_bevy_components_workflow/blob/main/crates/bevy_gltf_save_load/License.md)
[![Bevy tracking](https://img.shields.io/badge/Bevy%20tracking-released%20version-lightblue)](https://github.com/bevyengine/bevy/blob/main/docs/plugins_guidelines.md#main-branch-tracking)

# bevy_gltf_save_load
# bevy_gltf_save_load (deprecated in favor of Blenvy)

> bevy_gltf_save_load has been deprecated in favor of its successor [Blenvy](https://crates.io/crates/blenvy), part of the [Blenvy project](https://github.com/kaosat-dev/Blenvy). No further development or maintenance will be done for Bevy bevy_gltf_save_load. See [#194](https://github.com/kaosat-dev/Blenvy/issues/194) for background.

Built upon [bevy_gltf_blueprints](https://crates.io/crates/bevy_gltf_blueprints) this crate adds the ability to easilly **save** and **load** your game worlds for [Bevy](https://bevyengine.org/) .

Expand Down Expand Up @@ -34,9 +36,9 @@ Here's a minimal usage example:
```toml
# Cargo.toml
[dependencies]
bevy="0.13"
bevy_gltf_save_load = "0.4"
bevy_gltf_blueprints = "0.10" // also needed
bevy="0.14"
bevy_gltf_save_load = "0.5"
bevy_gltf_blueprints = "0.11" // also needed
```

```rust no_run
Expand Down Expand Up @@ -298,6 +300,7 @@ The main branch is compatible with the latest Bevy release, while the branch `be
Compatibility of `bevy_gltf_save_load` versions:
| `bevy_gltf_save_load` | `bevy` |
| :-- | :-- |
| `0.5 ` | `0.14` |
| `0.4 ` | `0.13` |
| `0.1 -0.3` | `0.12` |
| branch `main` | `0.12` |
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_gltf_save_load/src/loading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub(crate) fn mark_load_requested(
let mut save_path: String = "".into();
for load_request in load_requests.read() {
if !load_request.path.is_empty() {
save_path = load_request.path.clone();
save_path.clone_from(&load_request.path);
}
}
if !save_path.is_empty() {
Expand Down
Loading
Loading