~~scuffed sorting?~~

This commit is contained in:
griffi-gh 2024-05-02 01:42:07 +02:00
parent dd6f52edb5
commit bb9107e912

View file

@ -1,21 +1,11 @@
use glam::{ivec3, IVec3, Mat4, Quat, Vec3}; use glam::{ivec3, IVec3, Mat4, Quat, Vec3};
use shipyard::{NonSendSync, UniqueView, UniqueViewMut, View, IntoIter, track}; use shipyard::{NonSendSync, UniqueView, UniqueViewMut, View, IntoIter, track};
use glium::{ use glium::{
implement_vertex, uniform,
Surface, DrawParameters,
uniforms::{
Sampler,
SamplerBehavior,
MinifySamplerFilter,
MagnifySamplerFilter,
SamplerWrapFunction
},
draw_parameters::{ draw_parameters::{
Depth, BackfaceCullingMode, Depth, DepthTest, PolygonMode
DepthTest, }, implement_vertex, uniform, uniforms::{
PolygonMode, MagnifySamplerFilter, MinifySamplerFilter, Sampler, SamplerBehavior, SamplerWrapFunction
BackfaceCullingMode, }, Blend, DrawParameters, Smooth, Surface
}, Blend
}; };
use crate::{ use crate::{
camera::Camera, camera::Camera,
@ -122,13 +112,13 @@ pub fn draw_world(
draw_parameters.blend = Blend::alpha_blending(); draw_parameters.blend = Blend::alpha_blending();
draw_parameters.backface_culling = BackfaceCullingMode::CullingDisabled; draw_parameters.backface_culling = BackfaceCullingMode::CullingDisabled;
draw_parameters.smooth = Some(glium::Smooth::DontCare); draw_parameters.smooth = Some(Smooth::Fastest);
enqueue_trans.sort_by_key(|k| -( // enqueue_trans.sort_by_key(|k| -(
(k.0.position + IVec3::splat((CHUNK_SIZE >> 1) as i32)).distance_squared(camera_position.as_ivec3()) // (k.0.position + IVec3::splat((CHUNK_SIZE >> 1) as i32)).distance_squared(camera_position.as_ivec3())
)); // ));
for (chunk, mesh) in enqueue_trans { for (chunk, mesh) in enqueue_trans.drain(..).rev() {
let world_position = chunk.position.as_vec3() * CHUNK_SIZE as f32; let world_position = chunk.position.as_vec3() * CHUNK_SIZE as f32;
target.0.draw( target.0.draw(
&mesh.trans_vertex_buffer, &mesh.trans_vertex_buffer,