mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-12-22 11:58:21 -06:00
fix a memory leak and most warnings
This commit is contained in:
parent
04e4b246fe
commit
e11302c4c0
|
@ -1,4 +1,3 @@
|
|||
use glam::Vec3;
|
||||
use shipyard::{UniqueViewMut, UniqueView, View, IntoIter};
|
||||
use crate::{
|
||||
player::MainPlayer,
|
||||
|
|
|
@ -51,7 +51,6 @@ pub fn render_selection_box(
|
|||
lookat: View<LookingAtBlock>,
|
||||
camera: View<Camera>,
|
||||
mut target: NonSendSync<UniqueViewMut<RenderTarget>>,
|
||||
display: NonSendSync<UniqueView<Renderer>>,
|
||||
program: NonSendSync<UniqueView<SelBoxShaderPrefab>>,
|
||||
buffers: NonSendSync<UniqueView<SelectionBoxBuffers>>,
|
||||
) {
|
||||
|
|
|
@ -85,6 +85,7 @@ impl ChunkMeshStorage {
|
|||
}
|
||||
pub fn insert(&mut self, mesh: ChunkMesh) -> usize {
|
||||
let index = self.index;
|
||||
debug_assert!(self.meshes.get(&index).is_none());
|
||||
self.meshes.insert_unique_unchecked(index, mesh);
|
||||
self.index += 1;
|
||||
index
|
||||
|
|
|
@ -210,11 +210,16 @@ fn process_completed_tasks(
|
|||
//apply the mesh
|
||||
let vertex_buffer = VertexBuffer::new(&renderer.display, &vertices).unwrap();
|
||||
let index_buffer = IndexBuffer::new(&renderer.display, PrimitiveType::TrianglesList, &indexes).unwrap();
|
||||
let mesh_index = meshes.insert(ChunkMesh {
|
||||
let mesh = ChunkMesh {
|
||||
vertex_buffer,
|
||||
index_buffer,
|
||||
});
|
||||
chunk.mesh_index = Some(mesh_index);
|
||||
};
|
||||
if let Some(index) = chunk.mesh_index {
|
||||
meshes.update(index, mesh).expect("Mesh update failed");
|
||||
} else {
|
||||
let mesh_index = meshes.insert(mesh);
|
||||
chunk.mesh_index = Some(mesh_index);
|
||||
}
|
||||
|
||||
//update chunk state
|
||||
chunk.current_state = CurrentChunkState::Rendered;
|
||||
|
|
Loading…
Reference in a new issue