Skip to content

Commit acd4451

Browse files
authored
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
1 parent 398e011 commit acd4451

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

examples/2d/mesh2d_manual.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ use bevy::{
2525
SpecializedRenderPipeline, SpecializedRenderPipelines, StencilFaceState, StencilState,
2626
TextureFormat, VertexBufferLayout, VertexFormat, VertexState, VertexStepMode,
2727
},
28-
sync_world::MainEntityHashMap,
28+
sync_component::SyncComponentPlugin,
29+
sync_world::{MainEntityHashMap, RenderEntity},
2930
view::{ExtractedView, RenderVisibleEntities, ViewTarget},
3031
Extract, Render, RenderApp, RenderSet,
3132
},
@@ -300,6 +301,7 @@ impl Plugin for ColoredMesh2dPlugin {
300301
&COLORED_MESH2D_SHADER_HANDLE,
301302
Shader::from_wgsl(COLORED_MESH2D_SHADER, file!()),
302303
);
304+
app.add_plugins(SyncComponentPlugin::<ColoredMesh2d>::default());
303305

304306
// Register our custom draw function, and add our render systems
305307
app.get_sub_app_mut(RenderApp)
@@ -329,12 +331,21 @@ pub fn extract_colored_mesh2d(
329331
// When extracting, you must use `Extract` to mark the `SystemParam`s
330332
// which should be taken from the main world.
331333
query: Extract<
332-
Query<(Entity, &ViewVisibility, &GlobalTransform, &Mesh2d), With<ColoredMesh2d>>,
334+
Query<
335+
(
336+
Entity,
337+
RenderEntity,
338+
&ViewVisibility,
339+
&GlobalTransform,
340+
&Mesh2d,
341+
),
342+
With<ColoredMesh2d>,
343+
>,
333344
>,
334345
mut render_mesh_instances: ResMut<RenderColoredMesh2dInstances>,
335346
) {
336347
let mut values = Vec::with_capacity(*previous_len);
337-
for (entity, view_visibility, transform, handle) in &query {
348+
for (entity, render_entity, view_visibility, transform, handle) in &query {
338349
if !view_visibility.get() {
339350
continue;
340351
}
@@ -344,7 +355,7 @@ pub fn extract_colored_mesh2d(
344355
flags: MeshFlags::empty().bits(),
345356
};
346357

347-
values.push((entity, ColoredMesh2d));
358+
values.push((render_entity, ColoredMesh2d));
348359
render_mesh_instances.insert(
349360
entity.into(),
350361
RenderMesh2dInstance {

0 commit comments

Comments
 (0)