lifetime errors :є

This commit is contained in:
griffi-gh 2024-05-05 13:25:54 +02:00
parent df808610ef
commit 3f359f433c
2 changed files with 11 additions and 3 deletions

View file

@ -36,7 +36,7 @@ impl AssetPaths for BlockTexture {
} }
#[derive(Unique)] #[derive(Unique)]
pub struct Textures { pub struct TexturePrefabs {
pub block_diffuse_texture: wgpu::Texture, pub block_diffuse_texture: wgpu::Texture,
pub block_diffuse_bind_group: wgpu::BindGroup, pub block_diffuse_bind_group: wgpu::BindGroup,
} }
@ -105,7 +105,7 @@ pub fn load_prefabs(
} }
] ]
}); });
storages.add_unique_non_send_sync(Textures { storages.add_unique_non_send_sync(TexturePrefabs {
block_diffuse_texture, block_diffuse_texture,
block_diffuse_bind_group, block_diffuse_bind_group,
}); });

View file

@ -2,7 +2,13 @@ use bytemuck::{Pod, Zeroable};
use glam::{IVec3, Vec3}; use glam::{IVec3, Vec3};
use shipyard::{AllStoragesView, IntoIter, NonSendSync, Unique, UniqueView, UniqueViewMut, View}; use shipyard::{AllStoragesView, IntoIter, NonSendSync, Unique, UniqueView, UniqueViewMut, View};
use kubi_shared::{chunk::CHUNK_SIZE, transform::Transform}; use kubi_shared::{chunk::CHUNK_SIZE, transform::Transform};
use crate::{camera::Camera, settings::GameSettings, world::{ChunkMeshStorage, ChunkStorage}}; use wgpu::util::RenderEncoder;
use crate::{
camera::Camera,
prefabs::TexturePrefabs,
settings::GameSettings,
world::{ChunkMeshStorage, ChunkStorage},
};
use super::Renderer; use super::Renderer;
#[derive(Clone, Copy, Pod, Zeroable)] #[derive(Clone, Copy, Pod, Zeroable)]
@ -36,6 +42,7 @@ pub fn init_trans_chunk_queue(storages: AllStoragesView) {
pub fn draw_world( pub fn draw_world(
(render_pass, renderer): (&mut wgpu::RenderPass, &Renderer), (render_pass, renderer): (&mut wgpu::RenderPass, &Renderer),
textures: UniqueView<TexturePrefabs>,
chunks: UniqueView<ChunkStorage>, chunks: UniqueView<ChunkStorage>,
meshes: NonSendSync<UniqueView<ChunkMeshStorage>>, meshes: NonSendSync<UniqueView<ChunkMeshStorage>>,
transform: View<Transform>, transform: View<Transform>,
@ -66,6 +73,7 @@ pub fn draw_world(
//Draw chunk mesh //Draw chunk mesh
if mesh.main.index.size() > 0 { if mesh.main.index.size() > 0 {
//TODO //TODO
render_pass.set_bind_group(0, &textures.block_diffuse_bind_group, &[]);
} }
//TODO trans chunks //TODO trans chunks