mirror of
https://github.com/kaosat-dev/Blender_bevy_components_workflow.git
synced 2024-11-24 04:40:53 +00:00
chore(v0.14): upgraded all current crates, examples, testing setup etc to Bevy 0.14 (#195)
* chore(v0.14): upgraded all current crates, examples, testing setup etc to Bevy 0.14 * chore(Blender tools): some minor fixed for Bevy 0.14 & version bump
This commit is contained in:
parent
06403153c3
commit
9b50d77790
@ -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"
|
||||
@ -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"] }
|
@ -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.
|
||||
|
||||
@ -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"}
|
||||
|
||||
```
|
||||
|
||||
@ -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`:
|
||||
@ -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` |
|
||||
|
@ -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)]
|
||||
|
@ -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,
|
||||
|
@ -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,
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -192,6 +192,7 @@ pub(crate) fn check_for_loaded(
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub(crate) fn spawn_from_blueprints(
|
||||
spawn_placeholders: Query<
|
||||
(
|
||||
@ -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>,
|
||||
|
||||
@ -273,6 +275,18 @@ 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(),
|
||||
@ -280,7 +294,9 @@ pub(crate) fn spawn_from_blueprints(
|
||||
..Default::default()
|
||||
},
|
||||
Animations {
|
||||
named_animations: gltf.named_animations.clone(),
|
||||
named_animations,
|
||||
named_indices,
|
||||
graph,
|
||||
},
|
||||
Spawned,
|
||||
OriginalChildren(original_children),
|
||||
|
@ -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"
|
||||
@ -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"] }
|
@ -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.
|
||||
|
||||
@ -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"}
|
||||
|
||||
```
|
||||
|
||||
@ -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`:
|
||||
@ -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` |
|
||||
|
@ -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;
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
@ -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(|_| {
|
||||
|
@ -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"
|
||||
@ -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"] }
|
||||
|
@ -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/) .
|
||||
|
||||
@ -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
|
||||
@ -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` |
|
||||
|
@ -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() {
|
||||
|
@ -80,7 +80,7 @@ pub(crate) fn save_game(world: &mut World) {
|
||||
|
||||
for event in events.get_reader().read(&events) {
|
||||
info!("SAVE EVENT !! {:?}", event);
|
||||
save_path = event.path.clone();
|
||||
save_path.clone_from(&event.path);
|
||||
}
|
||||
events.clear();
|
||||
|
||||
@ -147,7 +147,7 @@ pub(crate) fn save_game(world: &mut World) {
|
||||
// dyn_scene.resources.append(&mut dyn_scene_root.resources);
|
||||
|
||||
let serialized_scene = dyn_scene
|
||||
.serialize_ron(world.resource::<AppTypeRegistry>())
|
||||
.serialize(&world.resource::<AppTypeRegistry>().read())
|
||||
.unwrap();
|
||||
|
||||
let save_path = Path::new("assets")
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "bevy_registry_export"
|
||||
version = "0.3.1"
|
||||
version = "0.4.0"
|
||||
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"
|
||||
homepage = "https://github.com/kaosat-dev/Blender_bevy_components_workflow"
|
||||
@ -11,11 +11,11 @@ edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
bevy = { version = "0.13", default-features = false, features = ["bevy_scene"] }
|
||||
bevy_reflect = { version = "0.13", default-features = false }
|
||||
bevy_app = { version = "0.13", default-features = false, features = ["bevy_reflect"] }
|
||||
bevy_ecs = { version = "0.13", default-features = false, features = ["bevy_reflect"] }
|
||||
bevy = { version = "0.14", default-features = false, features = ["bevy_scene"] }
|
||||
bevy_reflect = { version = "0.14", default-features = false }
|
||||
bevy_app = { version = "0.14", default-features = false, features = ["bevy_reflect"] }
|
||||
bevy_ecs = { version = "0.14", default-features = false, features = ["bevy_reflect"] }
|
||||
serde_json = "1.0.108"
|
||||
|
||||
[dev-dependencies]
|
||||
bevy = { version = "0.13", default-features = false, features = ["dynamic_linking"] }
|
||||
bevy = { version = "0.14", default-features = false, features = ["dynamic_linking"] }
|
@ -3,7 +3,10 @@
|
||||
[![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_registry_export
|
||||
# bevy_registry_export (deprecated in favor of Blenvy)
|
||||
|
||||
> 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.
|
||||
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
|
||||
@ -17,8 +20,8 @@ Here's a minimal usage example:
|
||||
```toml
|
||||
# Cargo.toml
|
||||
[dependencies]
|
||||
bevy="0.13"
|
||||
bevy_registry_export = "0.3"
|
||||
bevy="0.14"
|
||||
bevy_registry_export = "0.4"
|
||||
```
|
||||
|
||||
```rust no_run
|
||||
@ -44,7 +47,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`:
|
||||
|
||||
```toml
|
||||
bevy_registry_export = "0.3"
|
||||
bevy_registry_export = "0.4"
|
||||
|
||||
```
|
||||
|
||||
@ -112,6 +115,7 @@ 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.4 ` | `0.14` | `0.3` |
|
||||
| `0.3 ` | `0.13` | `0.3` |
|
||||
| `0.2 ` | `0.12` | `0.3` |
|
||||
| `0.1 ` | `0.12` | `0.1 -0.2` |
|
||||
|
@ -5,8 +5,8 @@ edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
bevy = { version = "0.13", features = ["dynamic_linking"] }
|
||||
bevy = { version = "0.14", features = ["dynamic_linking"] }
|
||||
bevy_gltf_blueprints = { path = "../../../crates/bevy_gltf_blueprints" }
|
||||
bevy_gltf_worlflow_examples_common_rapier = { path = "../../common_rapier" }
|
||||
bevy_rapier3d = { version = "0.25.0", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"] }
|
||||
bevy_rapier3d = { version = "0.27.0", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"] }
|
||||
rand = "0.8.5"
|
||||
|
@ -92,7 +92,7 @@ pub fn animation_change_on_proximity_foxes(
|
||||
players: Query<&GlobalTransform, With<Player>>,
|
||||
animated_foxes: Query<(&GlobalTransform, &AnimationPlayerLink, &Animations), With<Fox>>,
|
||||
|
||||
mut animation_players: Query<&mut AnimationPlayer>,
|
||||
mut animation_players: Query<(&mut AnimationPlayer, &mut AnimationTransitions)>,
|
||||
) {
|
||||
for player_transforms in players.iter() {
|
||||
for (fox_tranforms, link, animations) in animated_foxes.iter() {
|
||||
@ -108,14 +108,15 @@ pub fn animation_change_on_proximity_foxes(
|
||||
anim_name = "Survey";
|
||||
}
|
||||
// now play the animation based on the chosen animation name
|
||||
let mut animation_player = animation_players.get_mut(link.0).unwrap();
|
||||
animation_player
|
||||
.play_with_transition(
|
||||
animations
|
||||
.named_animations
|
||||
let (mut animation_player, mut animation_transitions) =
|
||||
animation_players.get_mut(link.0).unwrap();
|
||||
animation_transitions
|
||||
.play(
|
||||
&mut animation_player,
|
||||
*animations
|
||||
.named_indices
|
||||
.get(anim_name)
|
||||
.expect("animation name should be in the list")
|
||||
.clone(),
|
||||
.expect("animation name should be in the list"),
|
||||
Duration::from_secs(3),
|
||||
)
|
||||
.repeat();
|
||||
@ -128,7 +129,7 @@ pub fn animation_change_on_proximity_robots(
|
||||
players: Query<&GlobalTransform, With<Player>>,
|
||||
animated_robots: Query<(&GlobalTransform, &AnimationPlayerLink, &Animations), With<Robot>>,
|
||||
|
||||
mut animation_players: Query<&mut AnimationPlayer>,
|
||||
mut animation_players: Query<(&mut AnimationPlayer, &mut AnimationTransitions)>,
|
||||
) {
|
||||
for player_transforms in players.iter() {
|
||||
for (robot_tranforms, link, animations) in animated_robots.iter() {
|
||||
@ -146,14 +147,15 @@ pub fn animation_change_on_proximity_robots(
|
||||
}
|
||||
|
||||
// now play the animation based on the chosen animation name
|
||||
let mut animation_player = animation_players.get_mut(link.0).unwrap();
|
||||
animation_player
|
||||
.play_with_transition(
|
||||
animations
|
||||
.named_animations
|
||||
let (mut animation_player, mut animation_transitions) =
|
||||
animation_players.get_mut(link.0).unwrap();
|
||||
animation_transitions
|
||||
.play(
|
||||
&mut animation_player,
|
||||
*animations
|
||||
.named_indices
|
||||
.get(anim_name)
|
||||
.expect("animation name should be in the list")
|
||||
.clone(),
|
||||
.expect("animation name should be in the list"),
|
||||
Duration::from_secs(3),
|
||||
)
|
||||
.repeat();
|
||||
@ -165,7 +167,7 @@ pub fn animation_control(
|
||||
animated_enemies: Query<(&AnimationPlayerLink, &Animations), With<Robot>>,
|
||||
animated_foxes: Query<(&AnimationPlayerLink, &Animations), With<Fox>>,
|
||||
|
||||
mut animation_players: Query<&mut AnimationPlayer>,
|
||||
mut animation_players: Query<(&mut AnimationPlayer, &mut AnimationTransitions)>,
|
||||
|
||||
keycode: Res<ButtonInput<KeyCode>>,
|
||||
// mut entities_with_animations : Query<(&mut AnimationPlayer, &mut Animations)>,
|
||||
@ -173,15 +175,16 @@ pub fn animation_control(
|
||||
// robots
|
||||
if keycode.just_pressed(KeyCode::KeyB) {
|
||||
for (link, animations) in animated_enemies.iter() {
|
||||
let mut animation_player = animation_players.get_mut(link.0).unwrap();
|
||||
let (mut animation_player, mut animation_transitions) =
|
||||
animation_players.get_mut(link.0).unwrap();
|
||||
let anim_name = "Scan";
|
||||
animation_player
|
||||
.play_with_transition(
|
||||
animations
|
||||
.named_animations
|
||||
animation_transitions
|
||||
.play(
|
||||
&mut animation_player,
|
||||
*animations
|
||||
.named_indices
|
||||
.get(anim_name)
|
||||
.expect("animation name should be in the list")
|
||||
.clone(),
|
||||
.expect("animation name should be in the list"),
|
||||
Duration::from_secs(5),
|
||||
)
|
||||
.repeat();
|
||||
@ -191,15 +194,16 @@ pub fn animation_control(
|
||||
// foxes
|
||||
if keycode.just_pressed(KeyCode::KeyW) {
|
||||
for (link, animations) in animated_foxes.iter() {
|
||||
let mut animation_player = animation_players.get_mut(link.0).unwrap();
|
||||
let (mut animation_player, mut animation_transitions) =
|
||||
animation_players.get_mut(link.0).unwrap();
|
||||
let anim_name = "Walk";
|
||||
animation_player
|
||||
.play_with_transition(
|
||||
animations
|
||||
.named_animations
|
||||
animation_transitions
|
||||
.play(
|
||||
&mut animation_player,
|
||||
*animations
|
||||
.named_indices
|
||||
.get(anim_name)
|
||||
.expect("animation name should be in the list")
|
||||
.clone(),
|
||||
.expect("animation name should be in the list"),
|
||||
Duration::from_secs(5),
|
||||
)
|
||||
.repeat();
|
||||
@ -208,15 +212,16 @@ pub fn animation_control(
|
||||
|
||||
if keycode.just_pressed(KeyCode::KeyX) {
|
||||
for (link, animations) in animated_foxes.iter() {
|
||||
let mut animation_player = animation_players.get_mut(link.0).unwrap();
|
||||
let (mut animation_player, mut animation_transitions) =
|
||||
animation_players.get_mut(link.0).unwrap();
|
||||
let anim_name = "Run";
|
||||
animation_player
|
||||
.play_with_transition(
|
||||
animations
|
||||
.named_animations
|
||||
animation_transitions
|
||||
.play(
|
||||
&mut animation_player,
|
||||
*animations
|
||||
.named_indices
|
||||
.get(anim_name)
|
||||
.expect("animation name should be in the list")
|
||||
.clone(),
|
||||
.expect("animation name should be in the list"),
|
||||
Duration::from_secs(5),
|
||||
)
|
||||
.repeat();
|
||||
@ -225,15 +230,16 @@ pub fn animation_control(
|
||||
|
||||
if keycode.just_pressed(KeyCode::KeyC) {
|
||||
for (link, animations) in animated_foxes.iter() {
|
||||
let mut animation_player = animation_players.get_mut(link.0).unwrap();
|
||||
let (mut animation_player, mut animation_transitions) =
|
||||
animation_players.get_mut(link.0).unwrap();
|
||||
let anim_name = "Survey";
|
||||
animation_player
|
||||
.play_with_transition(
|
||||
animations
|
||||
.named_animations
|
||||
animation_transitions
|
||||
.play(
|
||||
&mut animation_player,
|
||||
*animations
|
||||
.named_indices
|
||||
.get(anim_name)
|
||||
.expect("animation name should be in the list")
|
||||
.clone(),
|
||||
.expect("animation name should be in the list"),
|
||||
Duration::from_secs(5),
|
||||
)
|
||||
.repeat();
|
||||
|
@ -5,8 +5,8 @@ edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
bevy = { version = "0.13", features = ["dynamic_linking"] }
|
||||
bevy = { version = "0.14", features = ["dynamic_linking"] }
|
||||
bevy_gltf_blueprints = { path = "../../../crates/bevy_gltf_blueprints" }
|
||||
bevy_gltf_worlflow_examples_common_rapier = { path = "../../common_rapier" }
|
||||
bevy_rapier3d = { version = "0.25.0", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"] }
|
||||
bevy_rapier3d = { version = "0.27.0", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"] }
|
||||
rand = "0.8.5"
|
||||
|
@ -5,8 +5,8 @@ edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
bevy = { version = "0.13", features = ["dynamic_linking"] }
|
||||
bevy = { version = "0.14", features = ["dynamic_linking"] }
|
||||
bevy_gltf_blueprints = { path = "../../../crates/bevy_gltf_blueprints" }
|
||||
bevy_gltf_worlflow_examples_common_xpbd = { path = "../../common_xpbd" }
|
||||
bevy_xpbd_3d = "0.4"
|
||||
bevy_xpbd_3d = "0.5"
|
||||
rand = "0.8.5"
|
@ -5,8 +5,8 @@ edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
bevy = { version = "0.13", features = ["dynamic_linking"] }
|
||||
bevy = { version = "0.14", features = ["dynamic_linking"] }
|
||||
bevy_gltf_blueprints = { path = "../../../crates/bevy_gltf_blueprints" }
|
||||
bevy_gltf_worlflow_examples_common_rapier = { path = "../../common_rapier" }
|
||||
bevy_rapier3d = { version = "0.25.0", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"] }
|
||||
bevy_rapier3d = { version = "0.27.0", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"] }
|
||||
rand = "0.8.5"
|
@ -5,8 +5,8 @@ edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
bevy = { version = "0.13", features = ["dynamic_linking"] }
|
||||
bevy = { version = "0.14", features = ["dynamic_linking"] }
|
||||
bevy_gltf_blueprints = { path = "../../../crates/bevy_gltf_blueprints" }
|
||||
bevy_gltf_worlflow_examples_common_rapier = { path = "../../common_rapier" }
|
||||
bevy_rapier3d = { version = "0.25.0", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"] }
|
||||
bevy_rapier3d = { version = "0.27.0", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"] }
|
||||
rand = "0.8.5"
|
@ -5,6 +5,6 @@ edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
bevy = { version = "0.13", features = ["dynamic_linking"] }
|
||||
bevy = { version = "0.14", features = ["dynamic_linking"] }
|
||||
bevy_gltf_components = { path = "../../../crates/bevy_gltf_components" }
|
||||
bevy_gltf_worlflow_examples_common_rapier = { path = "../../common_rapier" }
|
||||
|
@ -5,12 +5,12 @@ edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
bevy = { version = "0.13", features = ["dynamic_linking"] }
|
||||
bevy = { version = "0.14", features = ["dynamic_linking"] }
|
||||
bevy_gltf_blueprints = { path = "../../../crates/bevy_gltf_blueprints" }
|
||||
bevy_gltf_save_load = { path = "../../../crates/bevy_gltf_save_load" }
|
||||
bevy_gltf_worlflow_examples_common_rapier = { path = "../../common_rapier" }
|
||||
|
||||
serde_json = "1.0.108"
|
||||
serde = "1.0.193"
|
||||
bevy_rapier3d = { version = "0.25.0", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"] }
|
||||
bevy_rapier3d = { version = "0.27.0", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"] }
|
||||
rand = "0.8.5"
|
@ -5,9 +5,9 @@ edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
bevy = { version = "0.13", features = ["dynamic_linking"] }
|
||||
bevy = { version = "0.14", features = ["dynamic_linking"] }
|
||||
bevy_gltf_blueprints = { path = "../../../crates/bevy_gltf_blueprints" }
|
||||
bevy_registry_export = { path = "../../../crates/bevy_registry_export" }
|
||||
bevy_gltf_worlflow_examples_common_rapier = { path = "../../common_rapier" }
|
||||
bevy_rapier3d = { version = "0.25.0", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"] }
|
||||
bevy_rapier3d = { version = "0.27.0", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"] }
|
||||
rand = "0.8.5"
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -12,10 +12,10 @@ default = ["blueprints", "physics_rapier"]
|
||||
|
||||
|
||||
[dependencies]
|
||||
bevy = { version = "0.13", features = ["dynamic_linking"] }
|
||||
bevy = { version = "0.14", features = ["dynamic_linking"] }
|
||||
bevy_gltf_blueprints = { path = "../../crates/bevy_gltf_blueprints", optional = true }
|
||||
bevy_rapier3d = { version = "0.25", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"], optional = true }
|
||||
bevy_xpbd_3d = { version = "0.4", optional = true }
|
||||
bevy_asset_loader = { version = "0.20", features = ["standard_dynamic_assets"] }
|
||||
bevy_editor_pls = { version = "0.8" }
|
||||
bevy_rapier3d = { version = "0.27", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"], optional = true }
|
||||
bevy_xpbd_3d = { version = "0.5", optional = true }
|
||||
bevy_asset_loader = { version = "0.21", features = ["standard_dynamic_assets"] }
|
||||
#bevy_editor_pls = { version = "0.8" }
|
||||
rand = "0.8.5"
|
||||
|
@ -11,7 +11,7 @@ pub mod game;
|
||||
pub use game::*;
|
||||
|
||||
use bevy::prelude::*;
|
||||
use bevy_editor_pls::prelude::*;
|
||||
//use bevy_editor_pls::prelude::*;
|
||||
|
||||
pub struct CommonPlugin;
|
||||
impl Plugin for CommonPlugin {
|
||||
@ -21,7 +21,7 @@ impl Plugin for CommonPlugin {
|
||||
AssetsPlugin,
|
||||
CorePlugin,
|
||||
GamePlugin,
|
||||
EditorPlugin::default(),
|
||||
//EditorPlugin::default(),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -10,10 +10,10 @@ default = ["blueprints"]
|
||||
|
||||
|
||||
[dependencies]
|
||||
bevy = { version = "0.13", features = ["dynamic_linking"] }
|
||||
bevy = { version = "0.14", features = ["dynamic_linking"] }
|
||||
bevy_gltf_worlflow_examples_common = { path = "../common" }
|
||||
bevy_gltf_blueprints = { path = "../../crates/bevy_gltf_blueprints", optional = true }
|
||||
bevy_rapier3d = { version = "0.25", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"] }
|
||||
bevy_asset_loader = { version = "0.20", features = ["standard_dynamic_assets"] }
|
||||
bevy_editor_pls = { version = "0.8" }
|
||||
bevy_rapier3d = { version = "0.27", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"] }
|
||||
bevy_asset_loader = { version = "0.21", features = ["standard_dynamic_assets"] }
|
||||
#bevy_editor_pls = { version = "0.8" }
|
||||
rand = "0.8.5"
|
||||
|
@ -1,54 +1,8 @@
|
||||
use bevy::prelude::*;
|
||||
use bevy::render::mesh::{MeshVertexAttributeId, PrimitiveTopology, VertexAttributeValues};
|
||||
use bevy::render::mesh::PrimitiveTopology;
|
||||
// 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 {
|
||||
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>(
|
||||
parent: Entity,
|
||||
children: &'a Query<&Children>,
|
||||
@ -58,37 +12,6 @@ pub(crate) trait MeshExt {
|
||||
}
|
||||
|
||||
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>(
|
||||
parent: Entity,
|
||||
children_query: &'a Query<&Children>,
|
||||
@ -125,51 +48,3 @@ 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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,10 +10,10 @@ default = ["blueprints"]
|
||||
|
||||
|
||||
[dependencies]
|
||||
bevy = { version = "0.13", features = ["dynamic_linking"] }
|
||||
bevy = { version = "0.14", features = ["dynamic_linking"] }
|
||||
bevy_gltf_worlflow_examples_common = { path = "../common" }
|
||||
bevy_gltf_blueprints = { path = "../../crates/bevy_gltf_blueprints", optional = true }
|
||||
bevy_xpbd_3d = { version = "0.4" }
|
||||
bevy_asset_loader = { version = "0.20", features = ["standard_dynamic_assets"] }
|
||||
bevy_editor_pls = { version = "0.8" }
|
||||
bevy_xpbd_3d = { version = "0.5" }
|
||||
bevy_asset_loader = { version = "0.21", features = ["standard_dynamic_assets"] }
|
||||
#bevy_editor_pls = { version = "0.8" }
|
||||
rand = "0.8.5"
|
||||
|
@ -1,54 +1,8 @@
|
||||
use bevy::prelude::*;
|
||||
use bevy::render::mesh::{MeshVertexAttributeId, PrimitiveTopology, VertexAttributeValues};
|
||||
use bevy::render::mesh::PrimitiveTopology;
|
||||
// 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 {
|
||||
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>(
|
||||
parent: Entity,
|
||||
children: &'a Query<&Children>,
|
||||
@ -58,37 +12,6 @@ pub(crate) trait MeshExt {
|
||||
}
|
||||
|
||||
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>(
|
||||
parent: Entity,
|
||||
children_query: &'a Query<&Children>,
|
||||
@ -125,51 +48,3 @@ 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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,12 +5,12 @@ edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
bevy = { version = "0.13", features = ["dynamic_linking"] }
|
||||
bevy = { version = "0.14", features = ["dynamic_linking"] }
|
||||
bevy_gltf_blueprints = { path = "../../crates/bevy_gltf_blueprints" }
|
||||
bevy_registry_export = { path = "../../crates/bevy_registry_export" }
|
||||
bevy_gltf_worlflow_examples_common_rapier = { path = "../../examples/common_rapier" }
|
||||
|
||||
bevy_rapier3d = { version = "0.25.0", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"] }
|
||||
bevy_asset_loader = { version = "0.20", features = ["standard_dynamic_assets"] }
|
||||
bevy_editor_pls = { version = "0.8" }
|
||||
bevy_rapier3d = { version = "0.27.0", features = ["serde-serialize", "debug-render-3d", "enhanced-determinism"] }
|
||||
bevy_asset_loader = { version = "0.21", features = ["standard_dynamic_assets"] }
|
||||
#bevy_editor_pls = { version = "0.8" }
|
||||
rand = "0.8.5"
|
||||
|
@ -94,7 +94,7 @@ fn generate_screenshot(
|
||||
}
|
||||
|
||||
fn exit_game(mut app_exit_events: ResMut<Events<bevy::app::AppExit>>) {
|
||||
app_exit_events.send(bevy::app::AppExit);
|
||||
app_exit_events.send(AppExit::Success);
|
||||
}
|
||||
|
||||
pub struct GamePlugin;
|
||||
|
@ -1,7 +1,7 @@
|
||||
bl_info = {
|
||||
"name": "bevy_components",
|
||||
"author": "kaosigh",
|
||||
"version": (0, 4, 1),
|
||||
"version": (0, 4, 2),
|
||||
"blender": (3, 4, 0),
|
||||
"location": "VIEW_3D",
|
||||
"description": "UI to help create Bevy blueprints and components",
|
||||
|
@ -22,7 +22,9 @@ conversion_tables = {
|
||||
|
||||
"glam::Quat": lambda value: "Quat(x:"+str(value[0])+ ", y:"+str(value[1])+ ", z:"+str(value[2])+ ", w:"+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::srgba::Srgba": lambda value: "Srgba(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
|
||||
|
@ -118,10 +118,14 @@ def parse_vec4(value, caster, typeName):
|
||||
parsed = parse_struct_string(value.replace(typeName,"").replace("(", "").replace(")","") )
|
||||
return [caster(parsed['x']), caster(parsed['y']), caster(parsed['z']), caster(parsed['w'])]
|
||||
|
||||
def parse_color(value, caster, typeName):
|
||||
def parse_color_rgba(value, caster, typeName):
|
||||
parsed = parse_struct_string(value.replace(typeName,"").replace("(", "").replace(")","") )
|
||||
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):
|
||||
return int(float(input))
|
||||
|
||||
@ -163,7 +167,10 @@ type_mappings = {
|
||||
'alloc::string::String': lambda value: str(value.replace('"', "")),
|
||||
'alloc::borrow::Cow<str>': lambda value: str(value.replace('"', "")),
|
||||
|
||||
'bevy_render::color::Color': lambda value: parse_color(value, float, "Rgba"),
|
||||
"bevy_color::srgba::Srgba": lambda value: parse_color_rgba(value, float, "Srgba"),
|
||||
"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),
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,9 @@ class ComponentsRegistry(PropertyGroup):
|
||||
|
||||
"glam::Quat": {"type": FloatVectorProperty, "presets": {"size":4} },
|
||||
|
||||
"bevy_render::color::Color": dict(type = FloatVectorProperty, presets=dict(subtype='COLOR', size=4)),
|
||||
"bevy_color::srgba::Srgba": 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()),
|
||||
"str": dict(type=StringProperty, presets=dict()),
|
||||
@ -202,7 +204,9 @@ class ComponentsRegistry(PropertyGroup):
|
||||
|
||||
"glam::Quat": [0.0, 0.0, 0.0, 0.0],
|
||||
|
||||
"bevy_render::color::Color": [1.0, 1.0, 0.0, 1.0],
|
||||
"bevy_color::srgba::Srgba": [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_utils::Uuid': '"'+str(uuid.uuid4())+'"'
|
||||
|
@ -61,7 +61,10 @@ type_mappings = {
|
||||
|
||||
"glam::Quat": lambda : random_vec(4, 'float'),
|
||||
|
||||
'bevy_render::color::Color': lambda : random_vec(4, 'float'),
|
||||
'bevy_color::srgba::Srgba': 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::borrow::Cow<str>': lambda : random_word(8),
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
bl_info = {
|
||||
"name": "gltf_auto_export",
|
||||
"author": "kaosigh",
|
||||
"version": (0, 16, 0),
|
||||
"version": (0, 16, 1),
|
||||
"blender": (3, 4, 0),
|
||||
"location": "File > Import-Export",
|
||||
"description": "glTF/glb auto-export",
|
||||
|
@ -44,7 +44,7 @@ def ambient_color_to_component(world):
|
||||
|
||||
|
||||
if color is not None and strength is not None:
|
||||
colorRgba = f"Rgba(red: {color[0]}, green: {color[1]}, blue: {color[2]}, alpha: {color[3]})"
|
||||
colorRgba = f"LinearRgba((red: {color[0]}, green: {color[1]}, blue: {color[2]}, alpha: {color[3]}))"
|
||||
component = f"( color: {colorRgba}, strength: {strength})"
|
||||
return component
|
||||
return None
|
||||
|
Loading…
Reference in New Issue
Block a user