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