refactor(mesh): move Mesh3d and Mesh2d into bevy_mesh (#19943)
# Objective - another step towards splitting out bevy_camera, this is needed by visibility systems ## Solution - move mesh stuff into mesh place ## Testing - 3d_scene looks fine No migration needed because of the re-export, that can be another PR after i split bevy_camera
This commit is contained in:
parent
b01de70bdd
commit
58feca9b32
@ -34,6 +34,7 @@ serde = { version = "1", default-features = false, features = [
|
||||
hexasphere = "15.0"
|
||||
thiserror = { version = "2", default-features = false }
|
||||
tracing = { version = "0.1", default-features = false, features = ["std"] }
|
||||
derive_more = { version = "2", default-features = false, features = ["from"] }
|
||||
|
||||
[dev-dependencies]
|
||||
serde_json = "1.0.140"
|
||||
|
@ -1,7 +1,4 @@
|
||||
use crate::{
|
||||
mesh::Mesh,
|
||||
view::{self, Visibility, VisibilityClass},
|
||||
};
|
||||
use crate::mesh::Mesh;
|
||||
use bevy_asset::{AsAssetId, AssetEvent, AssetId, Handle};
|
||||
use bevy_derive::{Deref, DerefMut};
|
||||
use bevy_ecs::{
|
||||
@ -42,8 +39,7 @@ use derive_more::derive::From;
|
||||
/// ```
|
||||
#[derive(Component, Clone, Debug, Default, Deref, DerefMut, Reflect, PartialEq, Eq, From)]
|
||||
#[reflect(Component, Default, Clone, PartialEq)]
|
||||
#[require(Transform, Visibility, VisibilityClass)]
|
||||
#[component(on_add = view::add_visibility_class::<Mesh2d>)]
|
||||
#[require(Transform)]
|
||||
pub struct Mesh2d(pub Handle<Mesh>);
|
||||
|
||||
impl From<Mesh2d> for AssetId<Mesh> {
|
||||
@ -98,8 +94,7 @@ impl AsAssetId for Mesh2d {
|
||||
/// ```
|
||||
#[derive(Component, Clone, Debug, Default, Deref, DerefMut, Reflect, PartialEq, Eq, From)]
|
||||
#[reflect(Component, Default, Clone, PartialEq)]
|
||||
#[require(Transform, Visibility, VisibilityClass)]
|
||||
#[component(on_add = view::add_visibility_class::<Mesh3d>)]
|
||||
#[require(Transform)]
|
||||
pub struct Mesh3d(pub Handle<Mesh>);
|
||||
|
||||
impl From<Mesh3d> for AssetId<Mesh> {
|
@ -3,6 +3,7 @@
|
||||
extern crate alloc;
|
||||
extern crate core;
|
||||
|
||||
mod components;
|
||||
mod conversions;
|
||||
mod index;
|
||||
mod mesh;
|
||||
@ -12,6 +13,7 @@ pub mod primitives;
|
||||
pub mod skinning;
|
||||
mod vertex;
|
||||
use bitflags::bitflags;
|
||||
pub use components::*;
|
||||
pub use index::*;
|
||||
pub use mesh::*;
|
||||
pub use mikktspace::*;
|
||||
|
@ -2,7 +2,6 @@ use bevy_math::Vec3;
|
||||
pub use bevy_mesh::*;
|
||||
use morph::{MeshMorphWeights, MorphWeights};
|
||||
pub mod allocator;
|
||||
mod components;
|
||||
use crate::{
|
||||
primitives::Aabb,
|
||||
render_asset::{PrepareAssetError, RenderAsset, RenderAssetPlugin, RenderAssets},
|
||||
@ -21,7 +20,7 @@ use bevy_ecs::{
|
||||
SystemParamItem,
|
||||
},
|
||||
};
|
||||
pub use components::{mark_3d_meshes_as_changed_if_their_assets_changed, Mesh2d, Mesh3d, MeshTag};
|
||||
pub use bevy_mesh::{mark_3d_meshes_as_changed_if_their_assets_changed, Mesh2d, Mesh3d, MeshTag};
|
||||
use wgpu::IndexFormat;
|
||||
|
||||
/// Registers all [`MeshBuilder`] types.
|
||||
|
@ -2,6 +2,7 @@ pub mod visibility;
|
||||
pub mod window;
|
||||
|
||||
use bevy_diagnostic::FrameCount;
|
||||
use bevy_mesh::{Mesh2d, Mesh3d};
|
||||
pub use visibility::*;
|
||||
pub use window::*;
|
||||
|
||||
@ -109,6 +110,10 @@ impl Plugin for ViewPlugin {
|
||||
.register_type::<VisibleEntities>()
|
||||
.register_type::<ColorGrading>()
|
||||
.register_type::<OcclusionCulling>()
|
||||
.register_required_components::<Mesh3d, Visibility>()
|
||||
.register_required_components::<Mesh3d, VisibilityClass>()
|
||||
.register_required_components::<Mesh2d, Visibility>()
|
||||
.register_required_components::<Mesh2d, VisibilityClass>()
|
||||
// NOTE: windows.is_changed() handles cases where a window was resized
|
||||
.add_plugins((
|
||||
ExtractComponentPlugin::<Hdr>::default(),
|
||||
@ -117,6 +122,12 @@ impl Plugin for ViewPlugin {
|
||||
VisibilityPlugin,
|
||||
VisibilityRangePlugin,
|
||||
));
|
||||
app.world_mut()
|
||||
.register_component_hooks::<Mesh3d>()
|
||||
.on_add(add_visibility_class::<Mesh3d>);
|
||||
app.world_mut()
|
||||
.register_component_hooks::<Mesh2d>()
|
||||
.on_add(add_visibility_class::<Mesh2d>);
|
||||
|
||||
if let Some(render_app) = app.get_sub_app_mut(RenderApp) {
|
||||
render_app.add_systems(
|
||||
|
Loading…
Reference in New Issue
Block a user