From 01ea702fb517015a3ea0f799835bf8ccfc6ca5f6 Mon Sep 17 00:00:00 2001 From: Lucas Franca Date: Thu, 20 Mar 2025 17:05:57 -0300 Subject: [PATCH] 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 --- examples/2d/mesh2d_manual.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/examples/2d/mesh2d_manual.rs b/examples/2d/mesh2d_manual.rs index b6c27a2e62..82da9392c7 100644 --- a/examples/2d/mesh2d_manual.rs +++ b/examples/2d/mesh2d_manual.rs @@ -25,7 +25,8 @@ use bevy::{ SpecializedRenderPipeline, SpecializedRenderPipelines, StencilFaceState, StencilState, TextureFormat, VertexBufferLayout, VertexFormat, VertexState, VertexStepMode, }, - sync_world::MainEntityHashMap, + sync_component::SyncComponentPlugin, + sync_world::{MainEntityHashMap, RenderEntity}, view::{ExtractedView, RenderVisibleEntities, ViewTarget}, Extract, Render, RenderApp, RenderSet, }, @@ -300,6 +301,7 @@ impl Plugin for ColoredMesh2dPlugin { &COLORED_MESH2D_SHADER_HANDLE, Shader::from_wgsl(COLORED_MESH2D_SHADER, file!()), ); + app.add_plugins(SyncComponentPlugin::::default()); // Register our custom draw function, and add our render systems 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 // which should be taken from the main world. query: Extract< - Query<(Entity, &ViewVisibility, &GlobalTransform, &Mesh2d), With>, + Query< + ( + Entity, + RenderEntity, + &ViewVisibility, + &GlobalTransform, + &Mesh2d, + ), + With, + >, >, mut render_mesh_instances: ResMut, ) { 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() { continue; } @@ -344,7 +355,7 @@ pub fn extract_colored_mesh2d( flags: MeshFlags::empty().bits(), }; - values.push((entity, ColoredMesh2d)); + values.push((render_entity, ColoredMesh2d)); render_mesh_instances.insert( entity.into(), RenderMesh2dInstance {