mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 04:33:37 +00:00
Alternative fix for mesh2d_manual
example (#15883)
# Objective Fixes #15847 Alternative to #15862. Would appreciate a rendering person signaling preference for one or the other. ## Solution Partially revert the changes made to this example in #15524. Add comment explaining that the non-usage of the built-in color vertex attribute is intentional. ## Testing `cargo run --example mesh2d_manual`
This commit is contained in:
parent
93fc2d12cf
commit
9dd6f42b32
1 changed files with 9 additions and 5 deletions
|
@ -11,7 +11,7 @@ use bevy::{
|
|||
math::{ops, FloatOrd},
|
||||
prelude::*,
|
||||
render::{
|
||||
mesh::{Indices, RenderMesh},
|
||||
mesh::{Indices, MeshVertexAttribute, RenderMesh},
|
||||
render_asset::{RenderAssetUsages, RenderAssets},
|
||||
render_phase::{
|
||||
AddRenderCommand, DrawFunctions, PhaseItemExtraIndex, SetItemPipeline,
|
||||
|
@ -84,10 +84,14 @@ fn star(
|
|||
}
|
||||
// Set the position attribute
|
||||
star.insert_attribute(Mesh::ATTRIBUTE_POSITION, v_pos);
|
||||
// And a RGB color attribute as well
|
||||
let mut v_color: Vec<[f32; 4]> = vec![LinearRgba::BLACK.to_f32_array()];
|
||||
v_color.extend_from_slice(&[LinearRgba::from(YELLOW).to_f32_array(); 10]);
|
||||
star.insert_attribute(Mesh::ATTRIBUTE_COLOR, v_color);
|
||||
// And a RGB color attribute as well. A built-in `Mesh::ATTRIBUTE_COLOR` exists, but we
|
||||
// use a custom vertex attribute here for demonstration purposes.
|
||||
let mut v_color: Vec<u32> = vec![LinearRgba::BLACK.as_u32()];
|
||||
v_color.extend_from_slice(&[LinearRgba::from(YELLOW).as_u32(); 10]);
|
||||
star.insert_attribute(
|
||||
MeshVertexAttribute::new("Vertex_Color", 1, VertexFormat::Uint32),
|
||||
v_color,
|
||||
);
|
||||
|
||||
// Now, we specify the indices of the vertex that are going to compose the
|
||||
// triangles in our star. Vertices in triangles have to be specified in CCW
|
||||
|
|
Loading…
Reference in a new issue