tile manager

This commit is contained in:
2024-04-09 21:06:45 -04:00
parent 5dc4cdb5d4
commit 27193adf15
11 changed files with 137 additions and 58 deletions

View File

@@ -11,8 +11,6 @@ use bevy::{
},
};
use std::vec::Vec;
use bevy::render::mesh::MeshVertexAttribute;
use bevy::render::render_resource::VertexFormat;
const HEX_CORNERS: [Vec3; 6] = [
Vec3::new(0., 0., OUTER_RADIUS),
@@ -23,7 +21,6 @@ const HEX_CORNERS: [Vec3; 6] = [
Vec3::new(-INNER_RADIUS, 0., 0.5 * OUTER_RADIUS),
];
pub fn generate_chunk_mesh(chunk: &Chunk, map: &Map) -> Mesh {
let vertex_count: usize = Chunk::SIZE * Chunk::SIZE * 6;
let mut verts = Vec::with_capacity(vertex_count);
@@ -55,11 +52,11 @@ pub fn generate_chunk_mesh(chunk: &Chunk, map: &Map) -> Mesh {
PrimitiveTopology::TriangleList,
RenderAssetUsages::MAIN_WORLD | RenderAssetUsages::RENDER_WORLD,
)
.with_inserted_attribute(Mesh::ATTRIBUTE_POSITION, verts)
.with_inserted_attribute(Mesh::ATTRIBUTE_UV_0, uvs)
.with_inserted_indices(Indices::U32(indices))
.with_duplicated_vertices()
.with_computed_flat_normals();
.with_inserted_attribute(Mesh::ATTRIBUTE_POSITION, verts)
.with_inserted_attribute(Mesh::ATTRIBUTE_UV_0, uvs)
.with_inserted_indices(Indices::U32(indices))
.with_duplicated_vertices()
.with_computed_flat_normals();
return mesh;
}