mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Centred particle meshes correctly
This commit is contained in:
parent
7eff8ff0ad
commit
1b80f05e82
@ -217,7 +217,7 @@ void main() {
|
||||
);
|
||||
}
|
||||
|
||||
f_pos = (inst_pos - focus_off.xyz) + ((v_pos - 0.5) * attr.scale * SCALE * mat3(attr.rot) + attr.offs);
|
||||
f_pos = (inst_pos - focus_off.xyz) + (v_pos * attr.scale * SCALE * mat3(attr.rot) + attr.offs);
|
||||
|
||||
// First 3 normals are negative, next 3 are positive
|
||||
// TODO: Make particle normals match orientation
|
||||
|
@ -28,6 +28,9 @@ impl<P: Pipeline> Mesh<P> {
|
||||
/// Get a slice referencing the vertices of this mesh.
|
||||
pub fn vertices(&self) -> &[P::Vertex] { &self.verts }
|
||||
|
||||
/// Get a mutable slice referencing the vertices of this mesh.
|
||||
pub fn vertices_mut(&mut self) -> &mut [P::Vertex] { &mut self.verts }
|
||||
|
||||
/// Push a new vertex onto the end of this mesh.
|
||||
pub fn push(&mut self, vert: P::Vertex) { self.verts.push(vert); }
|
||||
|
||||
|
@ -14,7 +14,7 @@ use common::{
|
||||
spiral::Spiral2d,
|
||||
state::DeltaTime,
|
||||
terrain::TerrainChunk,
|
||||
vol::RectRasterableVol,
|
||||
vol::{RectRasterableVol, SizedVol},
|
||||
};
|
||||
use dot_vox::DotVoxData;
|
||||
use hashbrown::HashMap;
|
||||
@ -367,11 +367,16 @@ fn default_cache(renderer: &mut Renderer) -> HashMap<&'static str, Model<Particl
|
||||
guillotiere::Size::new(i32::from(max_texture_size), i32::from(max_texture_size));
|
||||
let mut greedy = GreedyMesh::new(max_size);
|
||||
|
||||
let mesh = Meshable::<ParticlePipeline, &mut GreedyMesh>::generate_mesh(
|
||||
Segment::from(vox.as_ref()),
|
||||
&mut greedy,
|
||||
)
|
||||
.0;
|
||||
let segment = Segment::from(vox.as_ref());
|
||||
let segment_size = segment.size();
|
||||
let mut mesh =
|
||||
Meshable::<ParticlePipeline, &mut GreedyMesh>::generate_mesh(segment, &mut greedy).0;
|
||||
// Center particle vertices around origin
|
||||
for vert in mesh.vertices_mut() {
|
||||
vert.pos[0] -= segment_size.x as f32 / 2.0;
|
||||
vert.pos[1] -= segment_size.y as f32 / 2.0;
|
||||
vert.pos[2] -= segment_size.z as f32 / 2.0;
|
||||
}
|
||||
|
||||
// NOTE: Ignoring coloring / lighting for now.
|
||||
drop(greedy);
|
||||
|
Loading…
Reference in New Issue
Block a user