remove bevy_derive from bevy crate and export derives from specific crates
This commit is contained in:
parent
4a71cd128d
commit
70e9892e00
@ -24,7 +24,6 @@ bevy_app = { path = "crates/bevy_app" }
|
||||
bevy_asset = { path = "crates/bevy_asset" }
|
||||
bevy_type_registry = { path = "crates/bevy_type_registry" }
|
||||
bevy_core = { path = "crates/bevy_core" }
|
||||
bevy_derive = { path = "crates/bevy_derive" }
|
||||
bevy_diagnostic = { path = "crates/bevy_diagnostic" }
|
||||
bevy_gltf = { path = "crates/bevy_gltf" }
|
||||
bevy_input = { path = "crates/bevy_input" }
|
||||
|
@ -5,6 +5,7 @@ authors = ["Carter Anderson <mcanders1@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
bevy_derive = { path = "../bevy_derive" }
|
||||
legion = { path = "../bevy_legion", features = ["serialize"] }
|
||||
libloading = "0.5.2"
|
||||
log = { version = "0.4", features = ["release_max_level_info"] }
|
||||
|
@ -17,3 +17,4 @@ pub use event::*;
|
||||
pub use plugin::*;
|
||||
pub use resources::*;
|
||||
pub use system::*;
|
||||
pub use bevy_derive::{DynamicAppPlugin, EntityArchetype, FromResources};
|
||||
|
@ -6,6 +6,7 @@ edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
bevy_app = { path = "../bevy_app" }
|
||||
bevy_derive = { path = "../bevy_derive" }
|
||||
bevy_property = { path = "../bevy_property" }
|
||||
bevy_type_registry = { path = "../bevy_type_registry" }
|
||||
bevy_transform = { path = "../bevy_transform" }
|
||||
|
@ -2,6 +2,8 @@ pub mod bytes;
|
||||
pub mod time;
|
||||
pub mod transform;
|
||||
|
||||
pub use bevy_derive::Bytes;
|
||||
|
||||
use bevy_app::{stage, AppBuilder, AppPlugin};
|
||||
use bevy_transform::{
|
||||
components::{
|
||||
|
@ -2,7 +2,7 @@ use proc_macro::TokenStream;
|
||||
use quote::quote;
|
||||
use syn::{parse_macro_input, DeriveInput};
|
||||
|
||||
pub fn derive_app_plugin(input: TokenStream) -> TokenStream {
|
||||
pub fn derive_dynamic_app_plugin(input: TokenStream) -> TokenStream {
|
||||
let ast = parse_macro_input!(input as DeriveInput);
|
||||
let struct_name = &ast.ident;
|
||||
|
||||
|
@ -10,8 +10,8 @@ mod uniforms;
|
||||
use proc_macro::TokenStream;
|
||||
|
||||
#[proc_macro_derive(FromResources, attributes(module))]
|
||||
pub fn derive_resource(input: TokenStream) -> TokenStream {
|
||||
resource::derive_resource(input)
|
||||
pub fn derive_from_resources(input: TokenStream) -> TokenStream {
|
||||
resource::derive_from_resources(input)
|
||||
}
|
||||
|
||||
#[proc_macro_derive(Bytes, attributes(module))]
|
||||
@ -36,5 +36,5 @@ pub fn derive_uniforms(input: TokenStream) -> TokenStream {
|
||||
|
||||
#[proc_macro_derive(DynamicAppPlugin)]
|
||||
pub fn derive_app_plugin(input: TokenStream) -> TokenStream {
|
||||
app_plugin::derive_app_plugin(input)
|
||||
app_plugin::derive_dynamic_app_plugin(input)
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ use proc_macro::TokenStream;
|
||||
use quote::quote;
|
||||
use syn::{parse_macro_input, Data, DataStruct, DeriveInput, Fields};
|
||||
|
||||
pub fn derive_resource(input: TokenStream) -> TokenStream {
|
||||
pub fn derive_from_resources(input: TokenStream) -> TokenStream {
|
||||
let ast = parse_macro_input!(input as DeriveInput);
|
||||
let fields = match &ast.data {
|
||||
Data::Struct(DataStruct {
|
||||
|
@ -198,7 +198,7 @@ pub fn derive_uniforms(input: TokenStream) -> TokenStream {
|
||||
}
|
||||
});
|
||||
|
||||
impl #bevy_render_path::shader::AsUniforms for #struct_name {
|
||||
impl #bevy_render_path::shader::Uniforms for #struct_name {
|
||||
fn get_field_infos() -> &'static [#bevy_render_path::shader::FieldInfo] {
|
||||
#field_infos_ident
|
||||
}
|
||||
@ -275,7 +275,7 @@ pub fn derive_uniform(input: TokenStream) -> TokenStream {
|
||||
let struct_name_string = struct_name.to_string();
|
||||
|
||||
TokenStream::from(quote! {
|
||||
impl #impl_generics #bevy_render_path::shader::AsUniforms for #struct_name#ty_generics {
|
||||
impl #impl_generics #bevy_render_path::shader::Uniforms for #struct_name#ty_generics {
|
||||
fn get_field_infos() -> &'static [#bevy_render_path::shader::FieldInfo] {
|
||||
static FIELD_INFOS: &[#bevy_render_path::shader::FieldInfo] = &[
|
||||
#bevy_render_path::shader::FieldInfo {
|
||||
|
@ -25,6 +25,7 @@ mod renderable;
|
||||
pub mod texture;
|
||||
|
||||
pub use once_cell;
|
||||
pub use bevy_derive::{Uniform, Uniforms};
|
||||
|
||||
use self::{
|
||||
mesh::Mesh,
|
||||
|
@ -5,7 +5,7 @@ use crate::{
|
||||
},
|
||||
render_resource::{BufferInfo, BufferUsage},
|
||||
renderer::{RenderResourceContext, RenderResources},
|
||||
shader::AsUniforms,
|
||||
shader::Uniforms,
|
||||
Renderable, Vertex,
|
||||
};
|
||||
use bevy_app::{EventReader, Events};
|
||||
@ -431,7 +431,7 @@ pub fn mesh_resource_provider_system(resources: &mut Resources) -> Box<dyn Sched
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{Mesh, VertexAttribute};
|
||||
use crate::{pipeline::state_descriptors::PrimitiveTopology, shader::AsUniforms, Vertex};
|
||||
use crate::{pipeline::state_descriptors::PrimitiveTopology, shader::Uniforms, Vertex};
|
||||
use bevy_core::bytes::AsBytes;
|
||||
|
||||
#[test]
|
||||
|
@ -6,7 +6,7 @@ use crate::{
|
||||
RenderResourceAssignment, RenderResourceAssignments, RenderResourceAssignmentsId,
|
||||
},
|
||||
renderer::{RenderContext, RenderResourceContext, RenderResources},
|
||||
shader::{AsUniforms, FieldBindType},
|
||||
shader::{Uniforms, FieldBindType},
|
||||
texture, Renderable,
|
||||
};
|
||||
|
||||
@ -54,7 +54,7 @@ impl BufferArrayStatus {
|
||||
|
||||
struct UniformBufferArrays<T>
|
||||
where
|
||||
T: AsUniforms,
|
||||
T: Uniforms,
|
||||
{
|
||||
uniform_arrays: Vec<Option<(String, BufferArrayStatus)>>,
|
||||
_marker: PhantomData<T>,
|
||||
@ -62,7 +62,7 @@ where
|
||||
|
||||
impl<T> UniformBufferArrays<T>
|
||||
where
|
||||
T: AsUniforms,
|
||||
T: Uniforms,
|
||||
{
|
||||
fn new() -> Self {
|
||||
let mut uniform_arrays = Vec::new();
|
||||
@ -348,7 +348,7 @@ where
|
||||
#[derive(Default)]
|
||||
pub struct UniformNode<T>
|
||||
where
|
||||
T: AsUniforms,
|
||||
T: Uniforms,
|
||||
{
|
||||
command_queue: CommandQueue,
|
||||
dynamic_uniforms: bool,
|
||||
@ -357,7 +357,7 @@ where
|
||||
|
||||
impl<T> UniformNode<T>
|
||||
where
|
||||
T: AsUniforms,
|
||||
T: Uniforms,
|
||||
{
|
||||
pub fn new(dynamic_uniforms: bool) -> Self {
|
||||
UniformNode {
|
||||
@ -370,7 +370,7 @@ where
|
||||
|
||||
impl<T> Node for UniformNode<T>
|
||||
where
|
||||
T: AsUniforms,
|
||||
T: Uniforms,
|
||||
{
|
||||
fn update(
|
||||
&mut self,
|
||||
@ -386,7 +386,7 @@ where
|
||||
|
||||
impl<T> SystemNode for UniformNode<T>
|
||||
where
|
||||
T: AsUniforms,
|
||||
T: Uniforms,
|
||||
{
|
||||
fn get_system(&self) -> Box<dyn Schedulable> {
|
||||
let mut command_queue = self.command_queue.clone();
|
||||
@ -506,7 +506,7 @@ where
|
||||
#[derive(Default)]
|
||||
pub struct AssetUniformNode<T>
|
||||
where
|
||||
T: AsUniforms,
|
||||
T: Uniforms,
|
||||
{
|
||||
command_queue: CommandQueue,
|
||||
dynamic_uniforms: bool,
|
||||
@ -515,7 +515,7 @@ where
|
||||
|
||||
impl<T> AssetUniformNode<T>
|
||||
where
|
||||
T: AsUniforms,
|
||||
T: Uniforms,
|
||||
{
|
||||
pub fn new(dynamic_uniforms: bool) -> Self {
|
||||
AssetUniformNode {
|
||||
@ -528,7 +528,7 @@ where
|
||||
|
||||
impl<T> Node for AssetUniformNode<T>
|
||||
where
|
||||
T: AsUniforms,
|
||||
T: Uniforms,
|
||||
{
|
||||
fn update(
|
||||
&mut self,
|
||||
@ -544,7 +544,7 @@ where
|
||||
|
||||
impl<T> SystemNode for AssetUniformNode<T>
|
||||
where
|
||||
T: AsUniforms,
|
||||
T: Uniforms,
|
||||
{
|
||||
fn get_system(&self) -> Box<dyn Schedulable> {
|
||||
let mut command_queue = self.command_queue.clone();
|
||||
@ -674,7 +674,7 @@ where
|
||||
#[allow(dead_code)]
|
||||
fn initialize_vertex_buffer_descriptor<T>(vertex_buffer_descriptors: &mut VertexBufferDescriptors)
|
||||
where
|
||||
T: AsUniforms,
|
||||
T: Uniforms,
|
||||
{
|
||||
let vertex_buffer_descriptor = T::get_vertex_buffer_descriptor();
|
||||
if let Some(vertex_buffer_descriptor) = vertex_buffer_descriptor {
|
||||
@ -691,7 +691,7 @@ fn setup_uniform_texture_resources<T>(
|
||||
entities_waiting_for_assets: &EntitiesWaitingForAssets,
|
||||
render_resource_assignments: &mut RenderResourceAssignments,
|
||||
) where
|
||||
T: AsUniforms,
|
||||
T: Uniforms,
|
||||
{
|
||||
for field_info in T::get_field_infos().iter() {
|
||||
let bind_type = uniforms.get_field_bind_type(&field_info.name);
|
||||
|
@ -9,7 +9,7 @@ use bevy_asset::{Assets, Handle};
|
||||
use bevy_core::bytes::Bytes;
|
||||
use legion::prelude::*;
|
||||
|
||||
pub trait AsUniforms: Send + Sync + 'static {
|
||||
pub trait Uniforms: Send + Sync + 'static {
|
||||
fn get_field_infos() -> &'static [FieldInfo];
|
||||
fn write_uniform_bytes(&self, name: &str, buffer: &mut [u8]);
|
||||
fn uniform_byte_len(&self, name: &str) -> usize;
|
||||
@ -21,7 +21,7 @@ pub trait AsUniforms: Send + Sync + 'static {
|
||||
|
||||
pub fn shader_def_system<T>(uniforms: Com<T>, mut renderable: ComMut<Renderable>)
|
||||
where
|
||||
T: AsUniforms + Send + Sync + 'static,
|
||||
T: Uniforms + Send + Sync + 'static,
|
||||
{
|
||||
if let Some(shader_defs) = uniforms.get_shader_defs() {
|
||||
renderable
|
||||
@ -38,7 +38,7 @@ pub fn asset_shader_def_system<T>(
|
||||
asset_handle: Com<Handle<T>>,
|
||||
mut renderable: ComMut<Renderable>,
|
||||
) where
|
||||
T: AsUniforms + Send + Sync + 'static,
|
||||
T: Uniforms + Send + Sync + 'static,
|
||||
{
|
||||
if !renderable.is_visible || renderable.is_instanced {
|
||||
return;
|
||||
|
@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
pipeline::{InputStepMode, VertexAttributeDescriptor, VertexBufferDescriptor, VertexFormat},
|
||||
shader::{AsUniforms, FieldBindType, FieldInfo, GetFieldBindType},
|
||||
shader::{Uniforms, FieldBindType, FieldInfo, GetFieldBindType},
|
||||
texture::Texture,
|
||||
};
|
||||
use bevy_asset::Handle;
|
||||
@ -48,7 +48,7 @@ static VERTEX_BUFFER_DESCRIPTOR: Lazy<VertexBufferDescriptor> =
|
||||
stride: 64,
|
||||
});
|
||||
|
||||
impl AsUniforms for bevy_transform::prelude::LocalToWorld {
|
||||
impl Uniforms for bevy_transform::prelude::LocalToWorld {
|
||||
fn get_field_infos() -> &'static [FieldInfo] {
|
||||
LOCAL_TO_WORLD_FIELD_INFOS
|
||||
}
|
||||
|
@ -49,7 +49,6 @@ pub use legion;
|
||||
|
||||
pub use bevy_asset as asset;
|
||||
pub use bevy_core as core;
|
||||
pub use bevy_derive as derive;
|
||||
pub use bevy_diagnostic as diagnostic;
|
||||
pub use bevy_gltf as gltf;
|
||||
pub use bevy_input as input;
|
||||
|
@ -1,14 +1,13 @@
|
||||
pub use crate::{
|
||||
app::{
|
||||
schedule_runner::ScheduleRunnerPlugin, stage, App, AppBuilder, AppPlugin, EntityArchetype,
|
||||
EventReader, Events, FromResources, System,
|
||||
EventReader, Events, FromResources, System, DynamicAppPlugin
|
||||
},
|
||||
asset::{AddAsset, AssetEvent, AssetServer, Assets, Handle},
|
||||
core::{
|
||||
time::{Time, Timer},
|
||||
transform::{CommandBufferBuilderSource, WorldBuilder, WorldBuilderSource},
|
||||
},
|
||||
derive::*,
|
||||
diagnostic::DiagnosticsPlugin,
|
||||
input::{keyboard::KeyCode, mouse::MouseButton, Input},
|
||||
math::{self, Mat3, Mat4, Quat, Vec2, Vec3, Vec4},
|
||||
@ -29,6 +28,7 @@ pub use crate::{
|
||||
shader::{Shader, ShaderDefSuffixProvider, ShaderStage, ShaderStages},
|
||||
texture::Texture,
|
||||
Camera, Color, ColorSource, OrthographicProjection, PerspectiveProjection, Renderable,
|
||||
Uniforms, Uniform,
|
||||
},
|
||||
scene::{Scene, SceneSpawner},
|
||||
sprite::{
|
||||
|
Loading…
Reference in New Issue
Block a user