Fix warning spam on mesh2d_manual
example (#18433)
# Objective Fixes #18429 ## Solution Add syncing to the render world for the `ColoredMesh2d` component ## Testing Ran the example and it works as intended without the warning spam
This commit is contained in:
parent
0f446d49a1
commit
01ea702fb5
@ -25,7 +25,8 @@ use bevy::{
|
|||||||
SpecializedRenderPipeline, SpecializedRenderPipelines, StencilFaceState, StencilState,
|
SpecializedRenderPipeline, SpecializedRenderPipelines, StencilFaceState, StencilState,
|
||||||
TextureFormat, VertexBufferLayout, VertexFormat, VertexState, VertexStepMode,
|
TextureFormat, VertexBufferLayout, VertexFormat, VertexState, VertexStepMode,
|
||||||
},
|
},
|
||||||
sync_world::MainEntityHashMap,
|
sync_component::SyncComponentPlugin,
|
||||||
|
sync_world::{MainEntityHashMap, RenderEntity},
|
||||||
view::{ExtractedView, RenderVisibleEntities, ViewTarget},
|
view::{ExtractedView, RenderVisibleEntities, ViewTarget},
|
||||||
Extract, Render, RenderApp, RenderSet,
|
Extract, Render, RenderApp, RenderSet,
|
||||||
},
|
},
|
||||||
@ -300,6 +301,7 @@ impl Plugin for ColoredMesh2dPlugin {
|
|||||||
&COLORED_MESH2D_SHADER_HANDLE,
|
&COLORED_MESH2D_SHADER_HANDLE,
|
||||||
Shader::from_wgsl(COLORED_MESH2D_SHADER, file!()),
|
Shader::from_wgsl(COLORED_MESH2D_SHADER, file!()),
|
||||||
);
|
);
|
||||||
|
app.add_plugins(SyncComponentPlugin::<ColoredMesh2d>::default());
|
||||||
|
|
||||||
// Register our custom draw function, and add our render systems
|
// Register our custom draw function, and add our render systems
|
||||||
app.get_sub_app_mut(RenderApp)
|
app.get_sub_app_mut(RenderApp)
|
||||||
@ -329,12 +331,21 @@ pub fn extract_colored_mesh2d(
|
|||||||
// When extracting, you must use `Extract` to mark the `SystemParam`s
|
// When extracting, you must use `Extract` to mark the `SystemParam`s
|
||||||
// which should be taken from the main world.
|
// which should be taken from the main world.
|
||||||
query: Extract<
|
query: Extract<
|
||||||
Query<(Entity, &ViewVisibility, &GlobalTransform, &Mesh2d), With<ColoredMesh2d>>,
|
Query<
|
||||||
|
(
|
||||||
|
Entity,
|
||||||
|
RenderEntity,
|
||||||
|
&ViewVisibility,
|
||||||
|
&GlobalTransform,
|
||||||
|
&Mesh2d,
|
||||||
|
),
|
||||||
|
With<ColoredMesh2d>,
|
||||||
|
>,
|
||||||
>,
|
>,
|
||||||
mut render_mesh_instances: ResMut<RenderColoredMesh2dInstances>,
|
mut render_mesh_instances: ResMut<RenderColoredMesh2dInstances>,
|
||||||
) {
|
) {
|
||||||
let mut values = Vec::with_capacity(*previous_len);
|
let mut values = Vec::with_capacity(*previous_len);
|
||||||
for (entity, view_visibility, transform, handle) in &query {
|
for (entity, render_entity, view_visibility, transform, handle) in &query {
|
||||||
if !view_visibility.get() {
|
if !view_visibility.get() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -344,7 +355,7 @@ pub fn extract_colored_mesh2d(
|
|||||||
flags: MeshFlags::empty().bits(),
|
flags: MeshFlags::empty().bits(),
|
||||||
};
|
};
|
||||||
|
|
||||||
values.push((entity, ColoredMesh2d));
|
values.push((render_entity, ColoredMesh2d));
|
||||||
render_mesh_instances.insert(
|
render_mesh_instances.insert(
|
||||||
entity.into(),
|
entity.into(),
|
||||||
RenderMesh2dInstance {
|
RenderMesh2dInstance {
|
||||||
|
Loading…
Reference in New Issue
Block a user