Skip to content

Commit

Permalink
fix(bevy components): fix handling of unit/empty structs (kaosat-dev#151
Browse files Browse the repository at this point in the history
)

* closes kaosat-dev#133 
* fix(gltf_auto_export): corrected ron value for "spawnHere" components
* fix(bevy_components): fixed handling of empty/ unit structs
   * updated to/from prop_groups
   * updated tests/ expected files
   * bumped version
   * removed verbose "watching schema file for changes"
* fix(bevy_gltf_components): fixed issue of incorect handling of empty component values in non legacy mode:
   * aka: replacing empty component values (ron strings) with '()' should ONLY happen in legacy mode
   * even more aka: ron strings for component values should not be altered when not in legacy mode (provided ron
  strings should be valid)
* tests():
   * changed bevy_component tests to use testing/bevy_example as source for registry data
   * removed testing/bevy_registry_export, as it is redudant
   * related tweaks & cleanups
* chore(crates): bumped up versions because of breaking change
* chore(examples): updated registry export example to use up-to-date / fixed components data
* chore(bevy_gltf_components): added back warning about legacy mode, in a less spammy way
* docs(bevy_components): added notes about v0.3 breaking changes
  • Loading branch information
kaosat-dev authored Mar 4, 2024
1 parent b40ab49 commit 9cb9dda
Show file tree
Hide file tree
Showing 51 changed files with 145 additions and 11,404 deletions.
2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ members = [
"examples/bevy_gltf_save_load/basic/",
"examples/bevy_registry_export/basic",

"testing/bevy_registry_export/basic",
"testing/bevy_example"

]
resolver = "2"

Expand Down
4 changes: 2 additions & 2 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.7.3"
version = "0.8.0"
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"
Expand All @@ -17,6 +17,6 @@ workspace = true
bevy = { version = "0.12", default-features = false, features = ["bevy_asset", "bevy_scene", "bevy_gltf", "bevy_animation", "animation"] }

[dependencies]
bevy_gltf_components = "0.3"
bevy_gltf_components = "0.4"
#bevy_gltf_components = { path = "../bevy_gltf_components" }
bevy = { version = "0.12", default-features = false, features = ["bevy_asset", "bevy_scene", "bevy_gltf", "bevy_animation", "animation"] }
6 changes: 3 additions & 3 deletions crates/bevy_gltf_blueprints/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Here's a minimal usage example:
# Cargo.toml
[dependencies]
bevy="0.12"
bevy_gltf_blueprints = { version = "0.7"}
bevy_gltf_blueprints = { version = "0.8"}

```

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

```toml
bevy_gltf_blueprints = "0.7"
bevy_gltf_blueprints = "0.8"
```

Or use `cargo add`:
Expand Down Expand Up @@ -346,7 +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.3 - 0.7` | `0.12` |
| `0.3 - 0.8` | `0.12` |
| `0.1 - 0.2` | `0.11` |
| branch `main` | `0.12` |
| branch `bevy_main` | `main` |
Expand Down
2 changes: 1 addition & 1 deletion 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.3.2"
version = "0.4.0"
authors = ["Mark 'kaosat-dev' Moissette"]
description = "Allows you to define [Bevy](https://bevyengine.org/) components direclty inside gltf files and instanciate the components on the Bevy side."
homepage = "https://github.com/kaosat-dev/Blender_bevy_components_workflow"
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_gltf_components/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Here's a minimal usage example:
# Cargo.toml
[dependencies]
bevy="0.12"
bevy_gltf_components = { version = "0.3"}
bevy_gltf_components = { version = "0.4"}

```

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

```toml
bevy_gltf_components = "0.3"
bevy_gltf_components = "0.4"
```

Or use `cargo add`:
Expand Down Expand Up @@ -117,7 +117,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.2 - 0.3` | `0.12` |
| `0.2 - 0.4` | `0.12` |
| `0.1` | `0.11` |
| branch `main` | `0.12` |
| branch `bevy_main` | `main` |
Expand Down
11 changes: 10 additions & 1 deletion crates/bevy_gltf_components/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ pub mod process_gltfs;
pub use process_gltfs::*;

use bevy::{
ecs::system::Resource,
app::Startup,
ecs::system::{Res, Resource},
log::warn,
prelude::{App, IntoSystemConfigs, Plugin, SystemSet, Update},
};

Expand Down Expand Up @@ -66,11 +68,18 @@ impl Default for ComponentsFromGltfPlugin {
}
}

fn check_for_legacy_mode(gltf_components_config: Res<GltfComponentsConfig>) {
if gltf_components_config.legacy_mode {
warn!("using simplified component definitions is deprecated since 0.3, prefer defining components with real ron values (use the bevy_components tool for Blender for simplicity) ");
}
}

impl Plugin for ComponentsFromGltfPlugin {
fn build(&self, app: &mut App) {
app.insert_resource(GltfComponentsConfig {
legacy_mode: self.legacy_mode,
})
.add_systems(Startup, check_for_legacy_mode)
.add_systems(
Update,
(add_components_from_gltf_extras).in_set(GltfComponentsSet::Injection),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,19 @@ pub fn ronstring_to_reflect_component(
parsed_value = format!("({formated})");
}
}
}

// FIXME: waaait this should be part of the legacy mode as it modifies the ron data ???
// so it means the values generated by the Blende add-on are incomplete (trivial to fix, but still)
if parsed_value.is_empty() {
parsed_value = "()".to_string();
if parsed_value.is_empty() {
parsed_value = "()".to_string();
}
}

let ron_string = format!(
"{{ \"{}\":{} }}",
type_registration.type_info().type_path(),
parsed_value
);

// usefull to determine what an entity looks like Serialized
/*let test_struct = VecOfColors(vec![Color::Rgba { red: 0., green: 0.0, blue: 0.0, alpha: 0.0 }]);//TuppleTestColor(Color::Rgba { red: 0., green: 0.0, blue: 0.0, alpha: 0.0 });
/*let test_struct = CameraRenderGraph::new("name");
let serializer = ReflectSerializer::new(&test_struct, &type_registry);
let serialized =
ron::ser::to_string_pretty(&serializer, ron::ser::PrettyConfig::default()).unwrap();
Expand Down
5 changes: 3 additions & 2 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.2.1"
version = "0.3.0"
authors = ["Mark 'kaosat-dev' Moissette"]
description = "Save & load your bevy games"
homepage = "https://github.com/kaosat-dev/Blender_bevy_components_workflow"
Expand All @@ -18,4 +18,5 @@ bevy = { version = "0.12", default-features = false, features = ["bevy_asset", "

[dependencies]
bevy = { version = "0.12", default-features = false, features = ["bevy_asset", "bevy_scene", "bevy_gltf"] }
bevy_gltf_blueprints = "0.7"
bevy_gltf_blueprints = "0.8"
#bevy_gltf_blueprints = { path = "../bevy_gltf_blueprints" }
6 changes: 3 additions & 3 deletions crates/bevy_gltf_save_load/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Here's a minimal usage example:
# Cargo.toml
[dependencies]
bevy="0.12"
bevy_gltf_save_load = "0.1"
bevy_gltf_save_load = "0.3"
bevy_gltf_blueprints = "0.6" // also needed
```

Expand Down Expand Up @@ -141,7 +141,7 @@ take a look at the [example]('https://github.com/kaosat-dev/Blender_bevy_compone
Add the following to your `[dependencies]` section in `Cargo.toml`:

```toml
bevy_gltf_save_load = "0.1"
bevy_gltf_save_load = "0.3"
bevy_gltf_blueprints = "0.6" // also needed, as bevy_gltf_save_load does not re-export it at this time

```
Expand Down Expand Up @@ -299,7 +299,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.1 ` | `0.12` |
| `0.1 -0.3` | `0.12` |
| branch `main` | `0.12` |
| branch `bevy_main` | `main` |

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_registry_export/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bevy_registry_export"
version = "0.1.1"
version = "0.2.0"
authors = ["Mark 'kaosat-dev' Moissette", "Pascal 'Killercup' Hertleif"]
description = "Allows you to define [Bevy](https://bevyengine.org/) components direclty inside gltf files and instanciate the components on the Bevy side."
homepage = "https://github.com/kaosat-dev/Blender_bevy_components_workflow"
Expand Down
9 changes: 5 additions & 4 deletions crates/bevy_registry_export/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Here's a minimal usage example:
# Cargo.toml
[dependencies]
bevy="0.12"
bevy_registry_export = "0.1"
bevy_registry_export = "0.2"
```

```rust no_run
Expand All @@ -44,7 +44,7 @@ take a look at the [example]('https://github.com/kaosat-dev/Blender_bevy_compone
Add the following to your `[dependencies]` section in `Cargo.toml`:

```toml
bevy_registry_export = "0.1"
bevy_registry_export = "0.2"

```

Expand Down Expand Up @@ -112,8 +112,9 @@ The main branch is compatible with the latest Bevy release, while the branch `be
Compatibility of `bevy_registry_export` versions:
| `bevy_registry_export` | `bevy` | `bevy_components (Blender add-on)` |
| :-- | :-- |:-- |
| `0.1 ` | `0.12` | `0.1.0` |
| branch `main` | `0.12` | `0.1.0` |
| `0.2 ` | `0.12` | `0.3` |
| `0.1 ` | `0.12` | `0.1 -0.2` |
| branch `main` | `0.12` | `0.1` |
| branch `bevy_main` | `main` | `n/a` |


Expand Down
Binary file modified examples/bevy_registry_export/basic/assets/basic.blend
Binary file not shown.
Binary file modified examples/bevy_registry_export/basic/assets/models/World.glb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
16 changes: 0 additions & 16 deletions testing/bevy_registry_export/basic/Cargo.toml

This file was deleted.

15 changes: 0 additions & 15 deletions testing/bevy_registry_export/basic/README.md

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 9cb9dda

Please sign in to comment.