Compare commits

..

1 Commits

Author SHA1 Message Date
andriyDev
250bae4c96
Merge 9c7dfb5c76 into 06403153c3 2024-05-31 22:32:53 +00:00
42 changed files with 1886 additions and 3542 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "bevy_gltf_blueprints" name = "bevy_gltf_blueprints"
version = "0.11.0" version = "0.10.2"
authors = ["Mark 'kaosat-dev' Moissette"] authors = ["Mark 'kaosat-dev' Moissette"]
description = "Adds the ability to define Blueprints/Prefabs for Bevy inside gltf files and spawn them in Bevy." 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" homepage = "https://github.com/kaosat-dev/Blender_bevy_components_workflow"
@ -14,8 +14,8 @@ license = "MIT OR Apache-2.0"
workspace = true workspace = true
[dependencies] [dependencies]
bevy_gltf_components = { version = "0.6", path = "../bevy_gltf_components" } bevy_gltf_components = { version = "0.5", path = "../bevy_gltf_components" }
bevy = { version = "0.14", default-features = false, features = ["bevy_asset", "bevy_scene", "bevy_gltf", "bevy_animation", "animation"] } bevy = { version = "0.13", default-features = false, features = ["bevy_asset", "bevy_scene", "bevy_gltf", "bevy_animation", "animation"] }
[dev-dependencies] [dev-dependencies]
bevy = { version = "0.14", default-features = false, features = ["dynamic_linking"] } bevy = { version = "0.13", default-features = false, features = ["dynamic_linking"] }

View File

@ -3,9 +3,7 @@
[![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) [![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 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 (deprecated in favor of Blenvy) # bevy_gltf_blueprints
> 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. 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.
@ -29,8 +27,8 @@ Here's a minimal usage example:
```toml ```toml
# Cargo.toml # Cargo.toml
[dependencies] [dependencies]
bevy="0.14" bevy="0.13"
bevy_gltf_blueprints = { version = "0.11.0"} bevy_gltf_blueprints = { version = "0.10"}
``` ```
@ -68,7 +66,7 @@ fn spawn_blueprint(
Add the following to your `[dependencies]` section in `Cargo.toml`: Add the following to your `[dependencies]` section in `Cargo.toml`:
```toml ```toml
bevy_gltf_blueprints = "0.11.0" bevy_gltf_blueprints = "0.10"
``` ```
Or use `cargo add`: Or use `cargo add`:
@ -346,7 +344,6 @@ The main branch is compatible with the latest Bevy release, while the branch `be
Compatibility of `bevy_gltf_blueprints` versions: Compatibility of `bevy_gltf_blueprints` versions:
| `bevy_gltf_blueprints` | `bevy` | | `bevy_gltf_blueprints` | `bevy` |
| :-- | :-- | | :-- | :-- |
| `0.11` | `0.14` |
| `0.9 - 0.10` | `0.13` | | `0.9 - 0.10` | `0.13` |
| `0.3 - 0.8` | `0.12` | | `0.3 - 0.8` | `0.12` |
| `0.1 - 0.2` | `0.11` | | `0.1 - 0.2` | `0.11` |

View File

@ -6,8 +6,6 @@ use bevy::utils::HashMap;
/// storage for animations for a given entity (hierarchy), essentially a clone of gltf's `named_animations` /// storage for animations for a given entity (hierarchy), essentially a clone of gltf's `named_animations`
pub struct Animations { pub struct Animations {
pub named_animations: HashMap<String, Handle<AnimationClip>>, pub named_animations: HashMap<String, Handle<AnimationClip>>,
pub named_indices: HashMap<String, AnimationNodeIndex>,
pub graph: Handle<AnimationGraph>,
} }
#[derive(Component, Debug)] #[derive(Component, Debug)]

View File

@ -1,4 +1,5 @@
use bevy::{ecs::world::Command, prelude::*}; use bevy::ecs::system::Command;
use bevy::prelude::*;
use std::any::TypeId; use std::any::TypeId;
// originally based https://github.com/bevyengine/bevy/issues/1515, // originally based https://github.com/bevyengine/bevy/issues/1515,

View File

@ -89,6 +89,7 @@ pub struct BlueprintsPlugin {
pub library_folder: PathBuf, pub library_folder: PathBuf,
/// Automatically generate aabbs for the blueprints root objects /// Automatically generate aabbs for the blueprints root objects
pub aabbs: bool, pub aabbs: bool,
///
pub material_library: bool, pub material_library: bool,
pub material_library_folder: PathBuf, pub material_library_folder: PathBuf,
} }

View File

@ -172,10 +172,10 @@ pub(crate) fn materials_inject2(
let mat_gltf = assets_gltf let mat_gltf = assets_gltf
.get(model_handle.id()) .get(model_handle.id())
.expect("material should have been preloaded"); .expect("material should have been preloaded");
if mat_gltf.named_materials.contains_key(material_name as &str) { if mat_gltf.named_materials.contains_key(material_name) {
let material = mat_gltf let material = mat_gltf
.named_materials .named_materials
.get(material_name as &str) .get(material_name)
.expect("this material should have been loaded"); .expect("this material should have been loaded");
blueprints_config blueprints_config
.material_library_cache .material_library_cache

View File

@ -192,7 +192,6 @@ pub(crate) fn check_for_loaded(
} }
} }
#[allow(clippy::too_many_arguments)]
pub(crate) fn spawn_from_blueprints( pub(crate) fn spawn_from_blueprints(
spawn_placeholders: Query< spawn_placeholders: Query<
( (
@ -215,7 +214,6 @@ pub(crate) fn spawn_from_blueprints(
mut game_world: Query<Entity, With<GameWorldTag>>, mut game_world: Query<Entity, With<GameWorldTag>>,
assets_gltf: Res<Assets<Gltf>>, assets_gltf: Res<Assets<Gltf>>,
mut graphs: ResMut<Assets<AnimationGraph>>,
asset_server: Res<AssetServer>, asset_server: Res<AssetServer>,
blueprints_config: Res<BluePrintsConfig>, blueprints_config: Res<BluePrintsConfig>,
@ -275,18 +273,6 @@ pub(crate) fn spawn_from_blueprints(
original_children.push(*child); 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(( commands.entity(entity).insert((
SceneBundle { SceneBundle {
scene: scene.clone(), scene: scene.clone(),
@ -294,9 +280,7 @@ pub(crate) fn spawn_from_blueprints(
..Default::default() ..Default::default()
}, },
Animations { Animations {
named_animations, named_animations: gltf.named_animations.clone(),
named_indices,
graph,
}, },
Spawned, Spawned,
OriginalChildren(original_children), OriginalChildren(original_children),

View File

@ -1,6 +1,6 @@
[package] [package]
name = "bevy_gltf_components" name = "bevy_gltf_components"
version = "0.6.0" version = "0.5.1"
authors = ["Mark 'kaosat-dev' Moissette"] authors = ["Mark 'kaosat-dev' Moissette"]
description = "Allows you to define Bevy components direclty inside gltf files and instanciate the components on the Bevy side." 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" homepage = "https://github.com/kaosat-dev/Blender_bevy_components_workflow"
@ -14,9 +14,9 @@ license = "MIT OR Apache-2.0"
workspace = true workspace = true
[dependencies] [dependencies]
bevy = { version = "0.14", default-features = false, features = ["bevy_asset", "bevy_scene", "bevy_gltf"] } bevy = { version = "0.13", default-features = false, features = ["bevy_asset", "bevy_scene", "bevy_gltf"] }
serde = "1.0.188" serde = "1.0.188"
ron = "0.8.1" ron = "0.8.1"
[dev-dependencies] [dev-dependencies]
bevy = { version = "0.14", default-features = false, features = ["dynamic_linking"] } bevy = { version = "0.13", default-features = false, features = ["dynamic_linking"] }

View File

@ -4,9 +4,7 @@
[![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 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 (deprecated in favor of Blenvy) # bevy_gltf_components
> 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. This crate allows you to define [Bevy](https://bevyengine.org/) components direclty inside gltf files and instanciate the components on the Bevy side.
@ -25,8 +23,8 @@ Here's a minimal usage example:
```toml ```toml
# Cargo.toml # Cargo.toml
[dependencies] [dependencies]
bevy="0.14" bevy="0.13"
bevy_gltf_components = { version = "0.6"} bevy_gltf_components = { version = "0.5"}
``` ```
@ -62,7 +60,7 @@ bevy_gltf_components = { version = "0.6"}
Add the following to your `[dependencies]` section in `Cargo.toml`: Add the following to your `[dependencies]` section in `Cargo.toml`:
```toml ```toml
bevy_gltf_components = "0.6" bevy_gltf_components = "0.5"
``` ```
Or use `cargo add`: Or use `cargo add`:
@ -129,7 +127,6 @@ The main branch is compatible with the latest Bevy release, while the branch `be
Compatibility of `bevy_gltf_components` versions: Compatibility of `bevy_gltf_components` versions:
| `bevy_gltf_components` | `bevy` | | `bevy_gltf_components` | `bevy` |
| :-- | :-- | | :-- | :-- |
| `0.6` | `0.14` |
| `0.5` | `0.13` | | `0.5` | `0.13` |
| `0.2 - 0.4` | `0.12` | | `0.2 - 0.4` | `0.12` |
| `0.1` | `0.11` | | `0.1` | `0.11` |

View File

@ -1,5 +1,10 @@
use bevy::pbr::DirectionalLightShadowMap; use bevy::pbr::DirectionalLightShadowMap;
use bevy::prelude::*; 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; use crate::GltfComponentsSet;
@ -51,23 +56,17 @@ fn process_lights(
for (mut light, blender_light_shadows) in directional_lights.iter_mut() { for (mut light, blender_light_shadows) in directional_lights.iter_mut() {
if let Some(blender_light_shadows) = blender_light_shadows { if let Some(blender_light_shadows) = blender_light_shadows {
light.shadows_enabled = blender_light_shadows.enabled; light.shadows_enabled = blender_light_shadows.enabled;
} else {
light.shadows_enabled = true;
} }
} }
for (mut light, blender_light_shadows) in spot_lights.iter_mut() { for (mut light, blender_light_shadows) in spot_lights.iter_mut() {
if let Some(blender_light_shadows) = blender_light_shadows { if let Some(blender_light_shadows) = blender_light_shadows {
light.shadows_enabled = blender_light_shadows.enabled; light.shadows_enabled = blender_light_shadows.enabled;
} else {
light.shadows_enabled = true;
} }
} }
for (mut light, blender_light_shadows) in point_lights.iter_mut() { for (mut light, blender_light_shadows) in point_lights.iter_mut() {
if let Some(blender_light_shadows) = blender_light_shadows { if let Some(blender_light_shadows) = blender_light_shadows {
light.shadows_enabled = blender_light_shadows.enabled; light.shadows_enabled = blender_light_shadows.enabled;
} else {
light.shadows_enabled = true;
} }
} }
} }
@ -84,14 +83,66 @@ fn process_shadowmap(
} }
fn process_background_shader( fn process_background_shader(
background_shaders: Query<&BlenderBackgroundShader, Added<BlenderBackgroundShader>>, background_shaders: Query<Ref<BlenderBackgroundShader>>,
cameras: Query<(Entity, Ref<Camera3d>)>,
mut images: ResMut<Assets<Image>>,
mut commands: Commands, mut commands: Commands,
mut env_map_handle: Local<Option<Handle<Image>>>,
) { ) {
for background_shader in background_shaders.iter() { let Ok(background_shader) = background_shaders.get_single() else {
commands.insert_resource(AmbientLight { return;
color: background_shader.color, };
// Just a guess, see <https://github.com/bevyengine/bevy/issues/12280>
brightness: background_shader.strength * 400.0, 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,
}); });
} }
} }

View File

@ -1,5 +1,5 @@
use bevy::log::{debug, warn}; use bevy::log::{debug, warn};
use bevy::reflect::serde::ReflectDeserializer; use bevy::reflect::serde::UntypedReflectDeserializer;
use bevy::reflect::{Reflect, TypeInfo, TypeRegistration, TypeRegistry}; use bevy::reflect::{Reflect, TypeInfo, TypeRegistration, TypeRegistry};
use bevy::utils::HashMap; use bevy::utils::HashMap;
use ron::Value; use ron::Value;
@ -112,7 +112,7 @@ pub fn ronstring_to_reflect_component(
debug!("component data ron string {}", ron_string); debug!("component data ron string {}", ron_string);
let mut deserializer = ron::Deserializer::from_str(ron_string.as_str()) let mut deserializer = ron::Deserializer::from_str(ron_string.as_str())
.expect("deserialzer should have been generated from string"); .expect("deserialzer should have been generated from string");
let reflect_deserializer = ReflectDeserializer::new(type_registry); let reflect_deserializer = UntypedReflectDeserializer::new(type_registry);
let component = reflect_deserializer let component = reflect_deserializer
.deserialize(&mut deserializer) .deserialize(&mut deserializer)
.unwrap_or_else(|_| { .unwrap_or_else(|_| {

View File

@ -1,6 +1,6 @@
[package] [package]
name = "bevy_gltf_save_load" name = "bevy_gltf_save_load"
version = "0.5.0" version = "0.4.1"
authors = ["Mark 'kaosat-dev' Moissette"] authors = ["Mark 'kaosat-dev' Moissette"]
description = "Save & load your bevy games" description = "Save & load your bevy games"
homepage = "https://github.com/kaosat-dev/Blender_bevy_components_workflow" homepage = "https://github.com/kaosat-dev/Blender_bevy_components_workflow"
@ -14,8 +14,8 @@ license = "MIT OR Apache-2.0"
workspace = true workspace = true
[dependencies] [dependencies]
bevy = { version = "0.14", default-features = false, features = ["bevy_asset", "bevy_scene", "bevy_gltf"] } bevy = { version = "0.13", default-features = false, features = ["bevy_asset", "bevy_scene", "bevy_gltf"] }
bevy_gltf_blueprints = { version = "0.11", path = "../bevy_gltf_blueprints" } bevy_gltf_blueprints = { version = "0.10", path = "../bevy_gltf_blueprints" }
[dev-dependencies] [dev-dependencies]
bevy = { version = "0.14", default-features = false, features = ["dynamic_linking"] } bevy = { version = "0.13", default-features = false, features = ["dynamic_linking"] }

View File

@ -3,9 +3,7 @@
[![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) [![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 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 (deprecated in favor of Blenvy) # bevy_gltf_save_load
> 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/) . 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/) .
@ -36,9 +34,9 @@ Here's a minimal usage example:
```toml ```toml
# Cargo.toml # Cargo.toml
[dependencies] [dependencies]
bevy="0.14" bevy="0.13"
bevy_gltf_save_load = "0.5" bevy_gltf_save_load = "0.4"
bevy_gltf_blueprints = "0.11" // also needed bevy_gltf_blueprints = "0.10" // also needed
``` ```
```rust no_run ```rust no_run
@ -300,7 +298,6 @@ The main branch is compatible with the latest Bevy release, while the branch `be
Compatibility of `bevy_gltf_save_load` versions: Compatibility of `bevy_gltf_save_load` versions:
| `bevy_gltf_save_load` | `bevy` | | `bevy_gltf_save_load` | `bevy` |
| :-- | :-- | | :-- | :-- |
| `0.5 ` | `0.14` |
| `0.4 ` | `0.13` | | `0.4 ` | `0.13` |
| `0.1 -0.3` | `0.12` | | `0.1 -0.3` | `0.12` |
| branch `main` | `0.12` | | branch `main` | `0.12` |

View File

@ -32,7 +32,7 @@ pub(crate) fn mark_load_requested(
let mut save_path: String = "".into(); let mut save_path: String = "".into();
for load_request in load_requests.read() { for load_request in load_requests.read() {
if !load_request.path.is_empty() { if !load_request.path.is_empty() {
save_path.clone_from(&load_request.path); save_path = load_request.path.clone();
} }
} }
if !save_path.is_empty() { if !save_path.is_empty() {

View File

@ -80,7 +80,7 @@ pub(crate) fn save_game(world: &mut World) {
for event in events.get_reader().read(&events) { for event in events.get_reader().read(&events) {
info!("SAVE EVENT !! {:?}", event); info!("SAVE EVENT !! {:?}", event);
save_path.clone_from(&event.path); save_path = event.path.clone();
} }
events.clear(); events.clear();
@ -147,7 +147,7 @@ pub(crate) fn save_game(world: &mut World) {
// dyn_scene.resources.append(&mut dyn_scene_root.resources); // dyn_scene.resources.append(&mut dyn_scene_root.resources);
let serialized_scene = dyn_scene let serialized_scene = dyn_scene
.serialize(&world.resource::<AppTypeRegistry>().read()) .serialize_ron(world.resource::<AppTypeRegistry>())
.unwrap(); .unwrap();
let save_path = Path::new("assets") let save_path = Path::new("assets")

View File

@ -1,6 +1,6 @@
[package] [package]
name = "bevy_registry_export" name = "bevy_registry_export"
version = "0.4.0" version = "0.3.1"
authors = ["Mark 'kaosat-dev' Moissette", "Pascal 'Killercup' Hertleif"] authors = ["Mark 'kaosat-dev' Moissette", "Pascal 'Killercup' Hertleif"]
description = "Allows you to create a Json export of all your components/ registered types of your Bevy app/game" description = "Allows you to create a Json export of all your components/ registered types of your Bevy app/game"
homepage = "https://github.com/kaosat-dev/Blender_bevy_components_workflow" homepage = "https://github.com/kaosat-dev/Blender_bevy_components_workflow"
@ -11,11 +11,11 @@ edition = "2021"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
[dependencies] [dependencies]
bevy = { version = "0.14", default-features = false, features = ["bevy_scene"] } bevy = { version = "0.13", default-features = false, features = ["bevy_scene"] }
bevy_reflect = { version = "0.14", default-features = false } bevy_reflect = { version = "0.13", default-features = false }
bevy_app = { version = "0.14", default-features = false, features = ["bevy_reflect"] } bevy_app = { version = "0.13", default-features = false, features = ["bevy_reflect"] }
bevy_ecs = { version = "0.14", default-features = false, features = ["bevy_reflect"] } bevy_ecs = { version = "0.13", default-features = false, features = ["bevy_reflect"] }
serde_json = "1.0.108" serde_json = "1.0.108"
[dev-dependencies] [dev-dependencies]
bevy = { version = "0.14", default-features = false, features = ["dynamic_linking"] } bevy = { version = "0.13", default-features = false, features = ["dynamic_linking"] }

View File

@ -3,10 +3,7 @@
[![License](https://img.shields.io/crates/l/bevy_registry_export)](https://github.com/kaosat-dev/Blender_bevy_components_workflow/blob/main/crates/bevy_registry_export/License.md) [![License](https://img.shields.io/crates/l/bevy_registry_export)](https://github.com/kaosat-dev/Blender_bevy_components_workflow/blob/main/crates/bevy_registry_export/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 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_registry_export (deprecated in favor of Blenvy) # bevy_registry_export
> bevy_registry_export 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_registry_export. See [#194](https://github.com/kaosat-dev/Blenvy/issues/194) for background.
This plugin allows you to create a Json export of all your components/ registered types. This plugin allows you to create a Json export of all your components/ registered types.
Its main use case is as a backbone for the [```bevy_components``` Blender add-on](https://github.com/kaosat-dev/Blender_bevy_components_workflow/tree/main/tools/bevy_components), that allows you to add & edit components directly in Blender, using the actual type definitions from Bevy Its main use case is as a backbone for the [```bevy_components``` Blender add-on](https://github.com/kaosat-dev/Blender_bevy_components_workflow/tree/main/tools/bevy_components), that allows you to add & edit components directly in Blender, using the actual type definitions from Bevy
@ -20,8 +17,8 @@ Here's a minimal usage example:
```toml ```toml
# Cargo.toml # Cargo.toml
[dependencies] [dependencies]
bevy="0.14" bevy="0.13"
bevy_registry_export = "0.4" bevy_registry_export = "0.3"
``` ```
```rust no_run ```rust no_run
@ -47,7 +44,7 @@ take a look at the [example](https://github.com/kaosat-dev/Blender_bevy_componen
Add the following to your `[dependencies]` section in `Cargo.toml`: Add the following to your `[dependencies]` section in `Cargo.toml`:
```toml ```toml
bevy_registry_export = "0.4" bevy_registry_export = "0.3"
``` ```
@ -115,7 +112,6 @@ The main branch is compatible with the latest Bevy release, while the branch `be
Compatibility of `bevy_registry_export` versions: Compatibility of `bevy_registry_export` versions:
| `bevy_registry_export` | `bevy` | `bevy_components (Blender add-on)` | | `bevy_registry_export` | `bevy` | `bevy_components (Blender add-on)` |
| :-- | :-- |:-- | | :-- | :-- |:-- |
| `0.4 ` | `0.14` | `0.3` |
| `0.3 ` | `0.13` | `0.3` | | `0.3 ` | `0.13` | `0.3` |
| `0.2 ` | `0.12` | `0.3` | | `0.2 ` | `0.12` | `0.3` |
| `0.1 ` | `0.12` | `0.1 -0.2` | | `0.1 ` | `0.12` | `0.1 -0.2` |

View File

@ -5,8 +5,8 @@ edition = "2021"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
[dependencies] [dependencies]
bevy = { version = "0.14", features = ["dynamic_linking"] } bevy = { version = "0.13", features = ["dynamic_linking"] }
bevy_gltf_blueprints = { path = "../../../crates/bevy_gltf_blueprints" } bevy_gltf_blueprints = { path = "../../../crates/bevy_gltf_blueprints" }
bevy_gltf_worlflow_examples_common_rapier = { path = "../../common_rapier" } bevy_gltf_worlflow_examples_common_rapier = { path = "../../common_rapier" }
bevy_rapier3d = { version = "0.27.0", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"] } bevy_rapier3d = { version = "0.25.0", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"] }
rand = "0.8.5" rand = "0.8.5"

View File

@ -92,7 +92,7 @@ pub fn animation_change_on_proximity_foxes(
players: Query<&GlobalTransform, With<Player>>, players: Query<&GlobalTransform, With<Player>>,
animated_foxes: Query<(&GlobalTransform, &AnimationPlayerLink, &Animations), With<Fox>>, animated_foxes: Query<(&GlobalTransform, &AnimationPlayerLink, &Animations), With<Fox>>,
mut animation_players: Query<(&mut AnimationPlayer, &mut AnimationTransitions)>, mut animation_players: Query<&mut AnimationPlayer>,
) { ) {
for player_transforms in players.iter() { for player_transforms in players.iter() {
for (fox_tranforms, link, animations) in animated_foxes.iter() { for (fox_tranforms, link, animations) in animated_foxes.iter() {
@ -108,15 +108,14 @@ pub fn animation_change_on_proximity_foxes(
anim_name = "Survey"; anim_name = "Survey";
} }
// now play the animation based on the chosen animation name // now play the animation based on the chosen animation name
let (mut animation_player, mut animation_transitions) = let mut animation_player = animation_players.get_mut(link.0).unwrap();
animation_players.get_mut(link.0).unwrap(); animation_player
animation_transitions .play_with_transition(
.play( animations
&mut animation_player, .named_animations
*animations
.named_indices
.get(anim_name) .get(anim_name)
.expect("animation name should be in the list"), .expect("animation name should be in the list")
.clone(),
Duration::from_secs(3), Duration::from_secs(3),
) )
.repeat(); .repeat();
@ -129,7 +128,7 @@ pub fn animation_change_on_proximity_robots(
players: Query<&GlobalTransform, With<Player>>, players: Query<&GlobalTransform, With<Player>>,
animated_robots: Query<(&GlobalTransform, &AnimationPlayerLink, &Animations), With<Robot>>, animated_robots: Query<(&GlobalTransform, &AnimationPlayerLink, &Animations), With<Robot>>,
mut animation_players: Query<(&mut AnimationPlayer, &mut AnimationTransitions)>, mut animation_players: Query<&mut AnimationPlayer>,
) { ) {
for player_transforms in players.iter() { for player_transforms in players.iter() {
for (robot_tranforms, link, animations) in animated_robots.iter() { for (robot_tranforms, link, animations) in animated_robots.iter() {
@ -147,15 +146,14 @@ pub fn animation_change_on_proximity_robots(
} }
// now play the animation based on the chosen animation name // now play the animation based on the chosen animation name
let (mut animation_player, mut animation_transitions) = let mut animation_player = animation_players.get_mut(link.0).unwrap();
animation_players.get_mut(link.0).unwrap(); animation_player
animation_transitions .play_with_transition(
.play( animations
&mut animation_player, .named_animations
*animations
.named_indices
.get(anim_name) .get(anim_name)
.expect("animation name should be in the list"), .expect("animation name should be in the list")
.clone(),
Duration::from_secs(3), Duration::from_secs(3),
) )
.repeat(); .repeat();
@ -167,7 +165,7 @@ pub fn animation_control(
animated_enemies: Query<(&AnimationPlayerLink, &Animations), With<Robot>>, animated_enemies: Query<(&AnimationPlayerLink, &Animations), With<Robot>>,
animated_foxes: Query<(&AnimationPlayerLink, &Animations), With<Fox>>, animated_foxes: Query<(&AnimationPlayerLink, &Animations), With<Fox>>,
mut animation_players: Query<(&mut AnimationPlayer, &mut AnimationTransitions)>, mut animation_players: Query<&mut AnimationPlayer>,
keycode: Res<ButtonInput<KeyCode>>, keycode: Res<ButtonInput<KeyCode>>,
// mut entities_with_animations : Query<(&mut AnimationPlayer, &mut Animations)>, // mut entities_with_animations : Query<(&mut AnimationPlayer, &mut Animations)>,
@ -175,16 +173,15 @@ pub fn animation_control(
// robots // robots
if keycode.just_pressed(KeyCode::KeyB) { if keycode.just_pressed(KeyCode::KeyB) {
for (link, animations) in animated_enemies.iter() { for (link, animations) in animated_enemies.iter() {
let (mut animation_player, mut animation_transitions) = let mut animation_player = animation_players.get_mut(link.0).unwrap();
animation_players.get_mut(link.0).unwrap();
let anim_name = "Scan"; let anim_name = "Scan";
animation_transitions animation_player
.play( .play_with_transition(
&mut animation_player, animations
*animations .named_animations
.named_indices
.get(anim_name) .get(anim_name)
.expect("animation name should be in the list"), .expect("animation name should be in the list")
.clone(),
Duration::from_secs(5), Duration::from_secs(5),
) )
.repeat(); .repeat();
@ -194,16 +191,15 @@ pub fn animation_control(
// foxes // foxes
if keycode.just_pressed(KeyCode::KeyW) { if keycode.just_pressed(KeyCode::KeyW) {
for (link, animations) in animated_foxes.iter() { for (link, animations) in animated_foxes.iter() {
let (mut animation_player, mut animation_transitions) = let mut animation_player = animation_players.get_mut(link.0).unwrap();
animation_players.get_mut(link.0).unwrap();
let anim_name = "Walk"; let anim_name = "Walk";
animation_transitions animation_player
.play( .play_with_transition(
&mut animation_player, animations
*animations .named_animations
.named_indices
.get(anim_name) .get(anim_name)
.expect("animation name should be in the list"), .expect("animation name should be in the list")
.clone(),
Duration::from_secs(5), Duration::from_secs(5),
) )
.repeat(); .repeat();
@ -212,16 +208,15 @@ pub fn animation_control(
if keycode.just_pressed(KeyCode::KeyX) { if keycode.just_pressed(KeyCode::KeyX) {
for (link, animations) in animated_foxes.iter() { for (link, animations) in animated_foxes.iter() {
let (mut animation_player, mut animation_transitions) = let mut animation_player = animation_players.get_mut(link.0).unwrap();
animation_players.get_mut(link.0).unwrap();
let anim_name = "Run"; let anim_name = "Run";
animation_transitions animation_player
.play( .play_with_transition(
&mut animation_player, animations
*animations .named_animations
.named_indices
.get(anim_name) .get(anim_name)
.expect("animation name should be in the list"), .expect("animation name should be in the list")
.clone(),
Duration::from_secs(5), Duration::from_secs(5),
) )
.repeat(); .repeat();
@ -230,16 +225,15 @@ pub fn animation_control(
if keycode.just_pressed(KeyCode::KeyC) { if keycode.just_pressed(KeyCode::KeyC) {
for (link, animations) in animated_foxes.iter() { for (link, animations) in animated_foxes.iter() {
let (mut animation_player, mut animation_transitions) = let mut animation_player = animation_players.get_mut(link.0).unwrap();
animation_players.get_mut(link.0).unwrap();
let anim_name = "Survey"; let anim_name = "Survey";
animation_transitions animation_player
.play( .play_with_transition(
&mut animation_player, animations
*animations .named_animations
.named_indices
.get(anim_name) .get(anim_name)
.expect("animation name should be in the list"), .expect("animation name should be in the list")
.clone(),
Duration::from_secs(5), Duration::from_secs(5),
) )
.repeat(); .repeat();

View File

@ -5,8 +5,8 @@ edition = "2021"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
[dependencies] [dependencies]
bevy = { version = "0.14", features = ["dynamic_linking"] } bevy = { version = "0.13", features = ["dynamic_linking"] }
bevy_gltf_blueprints = { path = "../../../crates/bevy_gltf_blueprints" } bevy_gltf_blueprints = { path = "../../../crates/bevy_gltf_blueprints" }
bevy_gltf_worlflow_examples_common_rapier = { path = "../../common_rapier" } bevy_gltf_worlflow_examples_common_rapier = { path = "../../common_rapier" }
bevy_rapier3d = { version = "0.27.0", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"] } bevy_rapier3d = { version = "0.25.0", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"] }
rand = "0.8.5" rand = "0.8.5"

View File

@ -5,8 +5,8 @@ edition = "2021"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
[dependencies] [dependencies]
bevy = { version = "0.14", features = ["dynamic_linking"] } bevy = { version = "0.13", features = ["dynamic_linking"] }
bevy_gltf_blueprints = { path = "../../../crates/bevy_gltf_blueprints" } bevy_gltf_blueprints = { path = "../../../crates/bevy_gltf_blueprints" }
bevy_gltf_worlflow_examples_common_xpbd = { path = "../../common_xpbd" } bevy_gltf_worlflow_examples_common_xpbd = { path = "../../common_xpbd" }
bevy_xpbd_3d = "0.5" bevy_xpbd_3d = "0.4"
rand = "0.8.5" rand = "0.8.5"

View File

@ -5,8 +5,8 @@ edition = "2021"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
[dependencies] [dependencies]
bevy = { version = "0.14", features = ["dynamic_linking"] } bevy = { version = "0.13", features = ["dynamic_linking"] }
bevy_gltf_blueprints = { path = "../../../crates/bevy_gltf_blueprints" } bevy_gltf_blueprints = { path = "../../../crates/bevy_gltf_blueprints" }
bevy_gltf_worlflow_examples_common_rapier = { path = "../../common_rapier" } bevy_gltf_worlflow_examples_common_rapier = { path = "../../common_rapier" }
bevy_rapier3d = { version = "0.27.0", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"] } bevy_rapier3d = { version = "0.25.0", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"] }
rand = "0.8.5" rand = "0.8.5"

View File

@ -5,8 +5,8 @@ edition = "2021"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
[dependencies] [dependencies]
bevy = { version = "0.14", features = ["dynamic_linking"] } bevy = { version = "0.13", features = ["dynamic_linking"] }
bevy_gltf_blueprints = { path = "../../../crates/bevy_gltf_blueprints" } bevy_gltf_blueprints = { path = "../../../crates/bevy_gltf_blueprints" }
bevy_gltf_worlflow_examples_common_rapier = { path = "../../common_rapier" } bevy_gltf_worlflow_examples_common_rapier = { path = "../../common_rapier" }
bevy_rapier3d = { version = "0.27.0", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"] } bevy_rapier3d = { version = "0.25.0", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"] }
rand = "0.8.5" rand = "0.8.5"

View File

@ -5,6 +5,6 @@ edition = "2021"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
[dependencies] [dependencies]
bevy = { version = "0.14", features = ["dynamic_linking"] } bevy = { version = "0.13", features = ["dynamic_linking"] }
bevy_gltf_components = { path = "../../../crates/bevy_gltf_components" } bevy_gltf_components = { path = "../../../crates/bevy_gltf_components" }
bevy_gltf_worlflow_examples_common_rapier = { path = "../../common_rapier" } bevy_gltf_worlflow_examples_common_rapier = { path = "../../common_rapier" }

View File

@ -5,12 +5,12 @@ edition = "2021"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
[dependencies] [dependencies]
bevy = { version = "0.14", features = ["dynamic_linking"] } bevy = { version = "0.13", features = ["dynamic_linking"] }
bevy_gltf_blueprints = { path = "../../../crates/bevy_gltf_blueprints" } bevy_gltf_blueprints = { path = "../../../crates/bevy_gltf_blueprints" }
bevy_gltf_save_load = { path = "../../../crates/bevy_gltf_save_load" } bevy_gltf_save_load = { path = "../../../crates/bevy_gltf_save_load" }
bevy_gltf_worlflow_examples_common_rapier = { path = "../../common_rapier" } bevy_gltf_worlflow_examples_common_rapier = { path = "../../common_rapier" }
serde_json = "1.0.108" serde_json = "1.0.108"
serde = "1.0.193" serde = "1.0.193"
bevy_rapier3d = { version = "0.27.0", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"] } bevy_rapier3d = { version = "0.25.0", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"] }
rand = "0.8.5" rand = "0.8.5"

View File

@ -5,9 +5,9 @@ edition = "2021"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
[dependencies] [dependencies]
bevy = { version = "0.14", features = ["dynamic_linking"] } bevy = { version = "0.13", features = ["dynamic_linking"] }
bevy_gltf_blueprints = { path = "../../../crates/bevy_gltf_blueprints" } bevy_gltf_blueprints = { path = "../../../crates/bevy_gltf_blueprints" }
bevy_registry_export = { path = "../../../crates/bevy_registry_export" } bevy_registry_export = { path = "../../../crates/bevy_registry_export" }
bevy_gltf_worlflow_examples_common_rapier = { path = "../../common_rapier" } bevy_gltf_worlflow_examples_common_rapier = { path = "../../common_rapier" }
bevy_rapier3d = { version = "0.27.0", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"] } bevy_rapier3d = { version = "0.25.0", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"] }
rand = "0.8.5" rand = "0.8.5"

File diff suppressed because it is too large Load Diff

View File

@ -12,10 +12,10 @@ default = ["blueprints", "physics_rapier"]
[dependencies] [dependencies]
bevy = { version = "0.14", features = ["dynamic_linking"] } bevy = { version = "0.13", features = ["dynamic_linking"] }
bevy_gltf_blueprints = { path = "../../crates/bevy_gltf_blueprints", optional = true } bevy_gltf_blueprints = { path = "../../crates/bevy_gltf_blueprints", optional = true }
bevy_rapier3d = { version = "0.27", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"], optional = true } bevy_rapier3d = { version = "0.25", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"], optional = true }
bevy_xpbd_3d = { version = "0.5", optional = true } bevy_xpbd_3d = { version = "0.4", optional = true }
bevy_asset_loader = { version = "0.21", features = ["standard_dynamic_assets"] } bevy_asset_loader = { version = "0.20", features = ["standard_dynamic_assets"] }
#bevy_editor_pls = { version = "0.8" } bevy_editor_pls = { version = "0.8" }
rand = "0.8.5" rand = "0.8.5"

View File

@ -11,7 +11,7 @@ pub mod game;
pub use game::*; pub use game::*;
use bevy::prelude::*; use bevy::prelude::*;
//use bevy_editor_pls::prelude::*; use bevy_editor_pls::prelude::*;
pub struct CommonPlugin; pub struct CommonPlugin;
impl Plugin for CommonPlugin { impl Plugin for CommonPlugin {
@ -21,7 +21,7 @@ impl Plugin for CommonPlugin {
AssetsPlugin, AssetsPlugin,
CorePlugin, CorePlugin,
GamePlugin, GamePlugin,
//EditorPlugin::default(), EditorPlugin::default(),
)); ));
} }
} }

View File

@ -10,10 +10,10 @@ default = ["blueprints"]
[dependencies] [dependencies]
bevy = { version = "0.14", features = ["dynamic_linking"] } bevy = { version = "0.13", features = ["dynamic_linking"] }
bevy_gltf_worlflow_examples_common = { path = "../common" } bevy_gltf_worlflow_examples_common = { path = "../common" }
bevy_gltf_blueprints = { path = "../../crates/bevy_gltf_blueprints", optional = true } bevy_gltf_blueprints = { path = "../../crates/bevy_gltf_blueprints", optional = true }
bevy_rapier3d = { version = "0.27", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"] } bevy_rapier3d = { version = "0.25", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"] }
bevy_asset_loader = { version = "0.21", features = ["standard_dynamic_assets"] } bevy_asset_loader = { version = "0.20", features = ["standard_dynamic_assets"] }
#bevy_editor_pls = { version = "0.8" } bevy_editor_pls = { version = "0.8" }
rand = "0.8.5" rand = "0.8.5"

View File

@ -1,8 +1,54 @@
use bevy::prelude::*; use bevy::prelude::*;
use bevy::render::mesh::PrimitiveTopology; use bevy::render::mesh::{MeshVertexAttributeId, PrimitiveTopology, VertexAttributeValues};
// TAKEN VERBATIB FROM https://github.com/janhohenheim/foxtrot/blob/src/util/trait_extension.rs // TAKEN VERBATIB FROM https://github.com/janhohenheim/foxtrot/blob/src/util/trait_extension.rs
pub(crate) trait Vec3Ext: Copy {
fn is_approx_zero(self) -> bool;
fn split(self, up: Vec3) -> SplitVec3;
}
impl Vec3Ext for Vec3 {
#[inline]
fn is_approx_zero(self) -> bool {
self.length_squared() < 1e-5
}
#[inline]
fn split(self, up: Vec3) -> SplitVec3 {
let vertical = up * self.dot(up);
let horizontal = self - vertical;
SplitVec3 {
vertical,
horizontal,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub(crate) struct SplitVec3 {
pub(crate) vertical: Vec3,
pub(crate) horizontal: Vec3,
}
pub(crate) trait Vec2Ext: Copy {
fn is_approx_zero(self) -> bool;
fn x0y(self) -> Vec3;
}
impl Vec2Ext for Vec2 {
#[inline]
fn is_approx_zero(self) -> bool {
self.length_squared() < 1e-5
}
#[inline]
fn x0y(self) -> Vec3 {
Vec3::new(self.x, 0., self.y)
}
}
pub(crate) trait MeshExt { pub(crate) trait MeshExt {
fn transform(&mut self, transform: Transform);
fn transformed(&self, transform: Transform) -> Mesh;
fn read_coords_mut(&mut self, id: impl Into<MeshVertexAttributeId>) -> &mut Vec<[f32; 3]>;
fn search_in_children<'a>( fn search_in_children<'a>(
parent: Entity, parent: Entity,
children: &'a Query<&Children>, children: &'a Query<&Children>,
@ -12,6 +58,37 @@ pub(crate) trait MeshExt {
} }
impl MeshExt for Mesh { impl MeshExt for Mesh {
fn transform(&mut self, transform: Transform) {
for coords in self.read_coords_mut(Mesh::ATTRIBUTE_POSITION.clone()) {
let vec3 = (*coords).into();
let transformed = transform.transform_point(vec3);
*coords = transformed.into();
}
for normal in self.read_coords_mut(Mesh::ATTRIBUTE_NORMAL.clone()) {
let vec3 = (*normal).into();
let transformed = transform.rotation.mul_vec3(vec3);
*normal = transformed.into();
}
}
fn transformed(&self, transform: Transform) -> Mesh {
let mut mesh = self.clone();
mesh.transform(transform);
mesh
}
fn read_coords_mut(&mut self, id: impl Into<MeshVertexAttributeId>) -> &mut Vec<[f32; 3]> {
// Guaranteed by Bevy for the current usage
match self
.attribute_mut(id)
.expect("Failed to read unknown mesh attribute")
{
VertexAttributeValues::Float32x3(values) => values,
// Guaranteed by Bevy for the current usage
_ => unreachable!(),
}
}
fn search_in_children<'a>( fn search_in_children<'a>(
parent: Entity, parent: Entity,
children_query: &'a Query<&Children>, children_query: &'a Query<&Children>,
@ -48,3 +125,51 @@ impl MeshExt for Mesh {
} }
} }
} }
pub(crate) trait F32Ext: Copy {
fn is_approx_zero(self) -> bool;
fn squared(self) -> f32;
fn lerp(self, other: f32, ratio: f32) -> f32;
}
impl F32Ext for f32 {
#[inline]
fn is_approx_zero(self) -> bool {
self.abs() < 1e-5
}
#[inline]
fn squared(self) -> f32 {
self * self
}
#[inline]
fn lerp(self, other: f32, ratio: f32) -> f32 {
self.mul_add(1. - ratio, other * ratio)
}
}
pub(crate) trait TransformExt: Copy {
fn horizontally_looking_at(self, target: Vec3, up: Vec3) -> Transform;
fn lerp(self, other: Transform, ratio: f32) -> Transform;
}
impl TransformExt for Transform {
fn horizontally_looking_at(self, target: Vec3, up: Vec3) -> Transform {
let direction = target - self.translation;
let horizontal_direction = direction - up * direction.dot(up);
let look_target = self.translation + horizontal_direction;
self.looking_at(look_target, up)
}
fn lerp(self, other: Transform, ratio: f32) -> Transform {
let translation = self.translation.lerp(other.translation, ratio);
let rotation = self.rotation.slerp(other.rotation, ratio);
let scale = self.scale.lerp(other.scale, ratio);
Transform {
translation,
rotation,
scale,
}
}
}

View File

@ -10,10 +10,10 @@ default = ["blueprints"]
[dependencies] [dependencies]
bevy = { version = "0.14", features = ["dynamic_linking"] } bevy = { version = "0.13", features = ["dynamic_linking"] }
bevy_gltf_worlflow_examples_common = { path = "../common" } bevy_gltf_worlflow_examples_common = { path = "../common" }
bevy_gltf_blueprints = { path = "../../crates/bevy_gltf_blueprints", optional = true } bevy_gltf_blueprints = { path = "../../crates/bevy_gltf_blueprints", optional = true }
bevy_xpbd_3d = { version = "0.5" } bevy_xpbd_3d = { version = "0.4" }
bevy_asset_loader = { version = "0.21", features = ["standard_dynamic_assets"] } bevy_asset_loader = { version = "0.20", features = ["standard_dynamic_assets"] }
#bevy_editor_pls = { version = "0.8" } bevy_editor_pls = { version = "0.8" }
rand = "0.8.5" rand = "0.8.5"

View File

@ -1,8 +1,54 @@
use bevy::prelude::*; use bevy::prelude::*;
use bevy::render::mesh::PrimitiveTopology; use bevy::render::mesh::{MeshVertexAttributeId, PrimitiveTopology, VertexAttributeValues};
// TAKEN VERBATIB FROM https://github.com/janhohenheim/foxtrot/blob/src/util/trait_extension.rs // TAKEN VERBATIB FROM https://github.com/janhohenheim/foxtrot/blob/src/util/trait_extension.rs
pub(crate) trait Vec3Ext: Copy {
fn is_approx_zero(self) -> bool;
fn split(self, up: Vec3) -> SplitVec3;
}
impl Vec3Ext for Vec3 {
#[inline]
fn is_approx_zero(self) -> bool {
self.length_squared() < 1e-5
}
#[inline]
fn split(self, up: Vec3) -> SplitVec3 {
let vertical = up * self.dot(up);
let horizontal = self - vertical;
SplitVec3 {
vertical,
horizontal,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub(crate) struct SplitVec3 {
pub(crate) vertical: Vec3,
pub(crate) horizontal: Vec3,
}
pub(crate) trait Vec2Ext: Copy {
fn is_approx_zero(self) -> bool;
fn x0y(self) -> Vec3;
}
impl Vec2Ext for Vec2 {
#[inline]
fn is_approx_zero(self) -> bool {
self.length_squared() < 1e-5
}
#[inline]
fn x0y(self) -> Vec3 {
Vec3::new(self.x, 0., self.y)
}
}
pub(crate) trait MeshExt { pub(crate) trait MeshExt {
fn transform(&mut self, transform: Transform);
fn transformed(&self, transform: Transform) -> Mesh;
fn read_coords_mut(&mut self, id: impl Into<MeshVertexAttributeId>) -> &mut Vec<[f32; 3]>;
fn search_in_children<'a>( fn search_in_children<'a>(
parent: Entity, parent: Entity,
children: &'a Query<&Children>, children: &'a Query<&Children>,
@ -12,6 +58,37 @@ pub(crate) trait MeshExt {
} }
impl MeshExt for Mesh { impl MeshExt for Mesh {
fn transform(&mut self, transform: Transform) {
for coords in self.read_coords_mut(Mesh::ATTRIBUTE_POSITION.clone()) {
let vec3 = (*coords).into();
let transformed = transform.transform_point(vec3);
*coords = transformed.into();
}
for normal in self.read_coords_mut(Mesh::ATTRIBUTE_NORMAL.clone()) {
let vec3 = (*normal).into();
let transformed = transform.rotation.mul_vec3(vec3);
*normal = transformed.into();
}
}
fn transformed(&self, transform: Transform) -> Mesh {
let mut mesh = self.clone();
mesh.transform(transform);
mesh
}
fn read_coords_mut(&mut self, id: impl Into<MeshVertexAttributeId>) -> &mut Vec<[f32; 3]> {
// Guaranteed by Bevy for the current usage
match self
.attribute_mut(id)
.expect("Failed to read unknown mesh attribute")
{
VertexAttributeValues::Float32x3(values) => values,
// Guaranteed by Bevy for the current usage
_ => unreachable!(),
}
}
fn search_in_children<'a>( fn search_in_children<'a>(
parent: Entity, parent: Entity,
children_query: &'a Query<&Children>, children_query: &'a Query<&Children>,
@ -48,3 +125,51 @@ impl MeshExt for Mesh {
} }
} }
} }
pub(crate) trait F32Ext: Copy {
fn is_approx_zero(self) -> bool;
fn squared(self) -> f32;
fn lerp(self, other: f32, ratio: f32) -> f32;
}
impl F32Ext for f32 {
#[inline]
fn is_approx_zero(self) -> bool {
self.abs() < 1e-5
}
#[inline]
fn squared(self) -> f32 {
self * self
}
#[inline]
fn lerp(self, other: f32, ratio: f32) -> f32 {
self.mul_add(1. - ratio, other * ratio)
}
}
pub(crate) trait TransformExt: Copy {
fn horizontally_looking_at(self, target: Vec3, up: Vec3) -> Transform;
fn lerp(self, other: Transform, ratio: f32) -> Transform;
}
impl TransformExt for Transform {
fn horizontally_looking_at(self, target: Vec3, up: Vec3) -> Transform {
let direction = target - self.translation;
let horizontal_direction = direction - up * direction.dot(up);
let look_target = self.translation + horizontal_direction;
self.looking_at(look_target, up)
}
fn lerp(self, other: Transform, ratio: f32) -> Transform {
let translation = self.translation.lerp(other.translation, ratio);
let rotation = self.rotation.slerp(other.rotation, ratio);
let scale = self.scale.lerp(other.scale, ratio);
Transform {
translation,
rotation,
scale,
}
}
}

View File

@ -5,12 +5,12 @@ edition = "2021"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
[dependencies] [dependencies]
bevy = { version = "0.14", features = ["dynamic_linking"] } bevy = { version = "0.13", features = ["dynamic_linking"] }
bevy_gltf_blueprints = { path = "../../crates/bevy_gltf_blueprints" } bevy_gltf_blueprints = { path = "../../crates/bevy_gltf_blueprints" }
bevy_registry_export = { path = "../../crates/bevy_registry_export" } bevy_registry_export = { path = "../../crates/bevy_registry_export" }
bevy_gltf_worlflow_examples_common_rapier = { path = "../../examples/common_rapier" } bevy_gltf_worlflow_examples_common_rapier = { path = "../../examples/common_rapier" }
bevy_rapier3d = { version = "0.27.0", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"] } bevy_rapier3d = { version = "0.25.0", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"] }
bevy_asset_loader = { version = "0.21", features = ["standard_dynamic_assets"] } bevy_asset_loader = { version = "0.20", features = ["standard_dynamic_assets"] }
#bevy_editor_pls = { version = "0.8" } bevy_editor_pls = { version = "0.8" }
rand = "0.8.5" rand = "0.8.5"

View File

@ -94,7 +94,7 @@ fn generate_screenshot(
} }
fn exit_game(mut app_exit_events: ResMut<Events<bevy::app::AppExit>>) { fn exit_game(mut app_exit_events: ResMut<Events<bevy::app::AppExit>>) {
app_exit_events.send(AppExit::Success); app_exit_events.send(bevy::app::AppExit);
} }
pub struct GamePlugin; pub struct GamePlugin;

View File

@ -1,7 +1,7 @@
bl_info = { bl_info = {
"name": "bevy_components", "name": "bevy_components",
"author": "kaosigh", "author": "kaosigh",
"version": (0, 4, 2), "version": (0, 4, 1),
"blender": (3, 4, 0), "blender": (3, 4, 0),
"location": "VIEW_3D", "location": "VIEW_3D",
"description": "UI to help create Bevy blueprints and components", "description": "UI to help create Bevy blueprints and components",

View File

@ -22,9 +22,7 @@ conversion_tables = {
"glam::Quat": lambda value: "Quat(x:"+str(value[0])+ ", y:"+str(value[1])+ ", z:"+str(value[2])+ ", w:"+str(value[3])+")", "glam::Quat": lambda value: "Quat(x:"+str(value[0])+ ", y:"+str(value[1])+ ", z:"+str(value[2])+ ", w:"+str(value[3])+")",
"bevy_color::srgba::Srgba": lambda value: "Srgba(red:"+str(value[0])+ ", green:"+str(value[1])+ ", blue:"+str(value[2])+ ", alpha:"+str(value[3])+ ")", "bevy_render::color::Color": lambda value: "Rgba(red:"+str(value[0])+ ", green:"+str(value[1])+ ", blue:"+str(value[2])+ ", alpha:"+str(value[3])+ ")",
"bevy_color::linear_rgba::LinearRgba": lambda value: "LinearRgba(red:"+str(value[0])+ ", green:"+str(value[1])+ ", blue:"+str(value[2])+ ", alpha:"+str(value[3])+ ")",
"bevy_color::hsva::Hsva": lambda value: "Hsva(hue:"+str(value[0])+ ", saturation:"+str(value[1])+ ", value:"+str(value[2])+ ", alpha:"+str(value[3])+ ")",
} }
#converts the value of a property group(no matter its complexity) into a single custom property value #converts the value of a property group(no matter its complexity) into a single custom property value

View File

@ -118,14 +118,10 @@ def parse_vec4(value, caster, typeName):
parsed = parse_struct_string(value.replace(typeName,"").replace("(", "").replace(")","") ) parsed = parse_struct_string(value.replace(typeName,"").replace("(", "").replace(")","") )
return [caster(parsed['x']), caster(parsed['y']), caster(parsed['z']), caster(parsed['w'])] return [caster(parsed['x']), caster(parsed['y']), caster(parsed['z']), caster(parsed['w'])]
def parse_color_rgba(value, caster, typeName): def parse_color(value, caster, typeName):
parsed = parse_struct_string(value.replace(typeName,"").replace("(", "").replace(")","") ) parsed = parse_struct_string(value.replace(typeName,"").replace("(", "").replace(")","") )
return [caster(parsed['red']), caster(parsed['green']), caster(parsed['blue']), caster(parsed['alpha'])] return [caster(parsed['red']), caster(parsed['green']), caster(parsed['blue']), caster(parsed['alpha'])]
def parse_color_hsva(value, caster, typeName):
parsed = parse_struct_string(value.replace(typeName,"").replace("(", "").replace(")","") )
return [caster(parsed['hue']), caster(parsed['saturation']), caster(parsed['value']), caster(parsed['alpha'])]
def to_int(input): def to_int(input):
return int(float(input)) return int(float(input))
@ -167,10 +163,7 @@ type_mappings = {
'alloc::string::String': lambda value: str(value.replace('"', "")), 'alloc::string::String': lambda value: str(value.replace('"', "")),
'alloc::borrow::Cow<str>': lambda value: str(value.replace('"', "")), 'alloc::borrow::Cow<str>': lambda value: str(value.replace('"', "")),
"bevy_color::srgba::Srgba": lambda value: parse_color_rgba(value, float, "Srgba"), 'bevy_render::color::Color': lambda value: parse_color(value, float, "Rgba"),
"bevy_color::linear_rgba::LinearRgba": lambda value: parse_color_rgba(value, float, "LinearRgba"),
"bevy_color::hsva::Hsva": lambda value: parse_color_hsva(value, float, "Hsva"),
'bevy_ecs::entity::Entity': lambda value: int(value), 'bevy_ecs::entity::Entity': lambda value: int(value),
} }

View File

@ -140,9 +140,7 @@ class ComponentsRegistry(PropertyGroup):
"glam::Quat": {"type": FloatVectorProperty, "presets": {"size":4} }, "glam::Quat": {"type": FloatVectorProperty, "presets": {"size":4} },
"bevy_color::srgba::Srgba": dict(type = FloatVectorProperty, presets=dict(subtype='COLOR', size=4)), "bevy_render::color::Color": dict(type = FloatVectorProperty, presets=dict(subtype='COLOR', size=4)),
"bevy_color::linear_rgba::LinearRgba": dict(type = FloatVectorProperty, presets=dict(subtype='COLOR', size=4)),
"bevy_color::hsva::Hsva": dict(type = FloatVectorProperty, presets=dict(subtype='COLOR', size=4)),
"char": dict(type=StringProperty, presets=dict()), "char": dict(type=StringProperty, presets=dict()),
"str": dict(type=StringProperty, presets=dict()), "str": dict(type=StringProperty, presets=dict()),
@ -204,10 +202,8 @@ class ComponentsRegistry(PropertyGroup):
"glam::Quat": [0.0, 0.0, 0.0, 0.0], "glam::Quat": [0.0, 0.0, 0.0, 0.0],
"bevy_color::srgba::Srgba": [1.0, 1.0, 0.0, 1.0], "bevy_render::color::Color": [1.0, 1.0, 0.0, 1.0],
"bevy_color::linear_rgba::LinearRgba": [1.0, 1.0, 0.0, 1.0],
"bevy_color::hsva::Hsva": [1.0, 1.0, 0.0, 1.0],
'bevy_ecs::entity::Entity': 0,#4294967295, # this is the same as Bevy's Entity::Placeholder, too big for Blender..sigh 'bevy_ecs::entity::Entity': 0,#4294967295, # this is the same as Bevy's Entity::Placeholder, too big for Blender..sigh
'bevy_utils::Uuid': '"'+str(uuid.uuid4())+'"' 'bevy_utils::Uuid': '"'+str(uuid.uuid4())+'"'

View File

@ -61,10 +61,7 @@ type_mappings = {
"glam::Quat": lambda : random_vec(4, 'float'), "glam::Quat": lambda : random_vec(4, 'float'),
'bevy_color::srgba::Srgba': lambda : random_vec(4, 'float'), 'bevy_render::color::Color': lambda : random_vec(4, 'float'),
'bevy_color::linear_rgba::LinearRgba': lambda : random_vec(4, 'float'),
'bevy_color::hsva::Hsva': lambda : random_vec(4, 'float'),
'alloc::string::String': lambda : random_word(8), 'alloc::string::String': lambda : random_word(8),
'alloc::borrow::Cow<str>': lambda : random_word(8), 'alloc::borrow::Cow<str>': lambda : random_word(8),

View File

@ -1,7 +1,7 @@
bl_info = { bl_info = {
"name": "gltf_auto_export", "name": "gltf_auto_export",
"author": "kaosigh", "author": "kaosigh",
"version": (0, 16, 1), "version": (0, 16, 0),
"blender": (3, 4, 0), "blender": (3, 4, 0),
"location": "File > Import-Export", "location": "File > Import-Export",
"description": "glTF/glb auto-export", "description": "glTF/glb auto-export",

View File

@ -44,7 +44,7 @@ def ambient_color_to_component(world):
if color is not None and strength is not None: if color is not None and strength is not None:
colorRgba = f"LinearRgba((red: {color[0]}, green: {color[1]}, blue: {color[2]}, alpha: {color[3]}))" colorRgba = f"Rgba(red: {color[0]}, green: {color[1]}, blue: {color[2]}, alpha: {color[3]})"
component = f"( color: {colorRgba}, strength: {strength})" component = f"( color: {colorRgba}, strength: {strength})"
return component return component
return None return None