mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fixed a few errors
This commit is contained in:
parent
5018a9f476
commit
d23dd6c9e9
@ -113,7 +113,7 @@ impl Skeleton for ArthropodSkeleton {
|
||||
orientation: mount_orientation,
|
||||
scale: Vec3::one(),
|
||||
},
|
||||
trail_points: None,
|
||||
relative_trail_points: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ impl Skeleton for BipedLargeSkeleton {
|
||||
.into(),
|
||||
..Default::default()
|
||||
},
|
||||
trail_points: None,
|
||||
relative_trail_points: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ impl Skeleton for BipedSmallSkeleton {
|
||||
.into(),
|
||||
..Default::default()
|
||||
},
|
||||
trail_points: None,
|
||||
relative_trail_points: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ impl Skeleton for BirdLargeSkeleton {
|
||||
.into(),
|
||||
..Default::default()
|
||||
},
|
||||
trail_points: None,
|
||||
relative_trail_points: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ impl Skeleton for BirdMediumSkeleton {
|
||||
.into(),
|
||||
..Default::default()
|
||||
},
|
||||
trail_points: None,
|
||||
relative_trail_points: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -156,7 +156,7 @@ impl Skeleton for CharacterSkeleton {
|
||||
.into(),
|
||||
..Default::default()
|
||||
},
|
||||
trail_points: Some((
|
||||
relative_trail_points: Some((
|
||||
(main_mat * Vec4::new(0.0, 0.5, -6.0, 1.0)).xyz(),
|
||||
(main_mat * Vec4::new(0.0, 0.5, -6.0, 1.0)).xyz() + Vec3::unit_z(),
|
||||
)),
|
||||
|
@ -81,7 +81,7 @@ impl Skeleton for DragonSkeleton {
|
||||
.into(),
|
||||
..Default::default()
|
||||
},
|
||||
trail_points: None,
|
||||
relative_trail_points: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ impl Skeleton for FishMediumSkeleton {
|
||||
.into(),
|
||||
..Default::default()
|
||||
},
|
||||
trail_points: None,
|
||||
relative_trail_points: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ impl Skeleton for FishSmallSkeleton {
|
||||
.into(),
|
||||
..Default::default()
|
||||
},
|
||||
trail_points: None,
|
||||
relative_trail_points: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ impl Skeleton for FixtureSkeleton {
|
||||
Offsets {
|
||||
lantern: None,
|
||||
mount_bone: Transform::default(),
|
||||
trail_points: None,
|
||||
relative_trail_points: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ impl Skeleton for GolemSkeleton {
|
||||
.into(),
|
||||
..Default::default()
|
||||
},
|
||||
trail_points: None,
|
||||
relative_trail_points: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ pub fn init() { lazy_static::initialize(&LIB); }
|
||||
pub struct Offsets {
|
||||
pub lantern: Option<Vec3<f32>>,
|
||||
pub mount_bone: Transform<f32, f32, f32>,
|
||||
pub trail_points: Option<(Vec3<f32>, Vec3<f32>)>,
|
||||
pub relative_trail_points: Option<(Vec3<f32>, Vec3<f32>)>,
|
||||
}
|
||||
|
||||
pub trait Skeleton: Send + Sync + 'static {
|
||||
|
@ -49,7 +49,7 @@ impl Skeleton for ObjectSkeleton {
|
||||
.into(),
|
||||
..Default::default()
|
||||
},
|
||||
trail_points: None,
|
||||
relative_trail_points: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ impl Skeleton for QuadrupedLowSkeleton {
|
||||
orientation: mount_orientation,
|
||||
scale: Vec3::one(),
|
||||
},
|
||||
trail_points: None,
|
||||
relative_trail_points: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ impl Skeleton for QuadrupedMediumSkeleton {
|
||||
orientation: mount_orientation,
|
||||
scale: Vec3::one(),
|
||||
},
|
||||
trail_points: None,
|
||||
relative_trail_points: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ impl Skeleton for QuadrupedSmallSkeleton {
|
||||
orientation: mount_orientation,
|
||||
scale: Vec3::one(),
|
||||
},
|
||||
trail_points: None,
|
||||
relative_trail_points: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ impl Skeleton for ShipSkeleton {
|
||||
),
|
||||
..Default::default()
|
||||
},
|
||||
trail_points: None,
|
||||
relative_trail_points: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ impl Skeleton for TheropodSkeleton {
|
||||
.into(),
|
||||
..Default::default()
|
||||
},
|
||||
trail_points: None,
|
||||
relative_trail_points: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ impl TrailPipeline {
|
||||
topology: wgpu::PrimitiveTopology::TriangleList,
|
||||
strip_index_format: None,
|
||||
front_face: wgpu::FrontFace::Ccw,
|
||||
cull_mode: Some(wgpu::Face::Back),
|
||||
cull_mode: None,
|
||||
clamp_depth: false,
|
||||
polygon_mode: wgpu::PolygonMode::Fill,
|
||||
conservative: false,
|
||||
|
@ -881,7 +881,7 @@ impl<'pass_ref, 'pass: 'pass_ref> TrailDrawer<'pass_ref, 'pass> {
|
||||
self.render_pass.set_vertex_buffer(0, model.buf().slice(..));
|
||||
self.render_pass
|
||||
// TODO: since we cast to u32 maybe this should returned by the len/count functions?
|
||||
.draw_indexed(0..model.len() as u32 / 4 * 6, 0, 0..0);
|
||||
.draw_indexed(0..model.len() as u32 / 4 * 6, 0, 0..1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6189,7 +6189,7 @@ impl FigureColLights {
|
||||
|
||||
pub struct FigureStateMeta {
|
||||
lantern_offset: Option<anim::vek::Vec3<f32>>,
|
||||
trail_points: Option<(anim::vek::Vec3<f32>, anim::vek::Vec3<f32>)>,
|
||||
abs_trail_points: Option<(anim::vek::Vec3<f32>, anim::vek::Vec3<f32>)>,
|
||||
// Animation to be applied to rider of this entity
|
||||
mount_transform: anim::vek::Transform<f32, f32, f32>,
|
||||
// Contains the position of this figure or if it is a rider it will contain the mount's
|
||||
@ -6266,7 +6266,9 @@ impl<S: Skeleton> FigureState<S> {
|
||||
Self {
|
||||
meta: FigureStateMeta {
|
||||
lantern_offset: offsets.lantern,
|
||||
trail_points: offsets.trail_points,
|
||||
abs_trail_points: offsets.relative_trail_points, /* No position to add and make
|
||||
* absolute, also doesn't matter
|
||||
* here */
|
||||
mount_transform: offsets.mount_bone,
|
||||
mount_world_pos: anim::vek::Vec3::zero(),
|
||||
state_time: 0.0,
|
||||
@ -6435,24 +6437,30 @@ impl<S: Skeleton> FigureState<S> {
|
||||
renderer.update_consts(&mut self.meta.bound.1, &new_bone_consts[0..S::BONE_COUNT]);
|
||||
self.lantern_offset = offsets.lantern;
|
||||
// Handle weapon trails
|
||||
let offsets_abs_trail_points = offsets
|
||||
.relative_trail_points
|
||||
.map(|(a, b)| (a + pos, b + pos));
|
||||
if let Some(trail_mgr) = trail_mgr {
|
||||
if let Some(dynamic_model) = entity
|
||||
.as_ref()
|
||||
.and_then(|e| trail_mgr.dynamic_models.get(e))
|
||||
{
|
||||
if let (Some((p1, p2)), Some((p3, p4))) = (self.trail_points, offsets.trail_points)
|
||||
let mut quad_mesh = Mesh::new();
|
||||
if let (Some((p1, p2)), Some((p4, p3))) =
|
||||
(self.abs_trail_points, offsets_abs_trail_points)
|
||||
{
|
||||
let vertex = |p: anim::vek::Vec3<f32>| trail::Vertex {
|
||||
pos: (p + pos).into_array(),
|
||||
pos: p.into_array(),
|
||||
};
|
||||
let mut quad_mesh = Mesh::new();
|
||||
// TODO: Figure out how to get
|
||||
quad_mesh.push_quad(Quad::new(vertex(p1), vertex(p2), vertex(p3), vertex(p4)));
|
||||
renderer.update_model(dynamic_model, &quad_mesh, trail_mgr.offset * 4);
|
||||
} else {
|
||||
let zero = trail::Vertex { pos: [0.0; 3] };
|
||||
quad_mesh.push_quad(Quad::new(zero, zero, zero, zero));
|
||||
}
|
||||
renderer.update_model(dynamic_model, &quad_mesh, trail_mgr.offset * 4);
|
||||
}
|
||||
}
|
||||
self.trail_points = offsets.trail_points;
|
||||
self.abs_trail_points = offsets_abs_trail_points;
|
||||
|
||||
// TODO: compute the mount bone only when it is needed
|
||||
self.mount_transform = offsets.mount_bone;
|
||||
|
@ -49,7 +49,7 @@ impl anim::Skeleton for VolumeKey {
|
||||
anim::Offsets {
|
||||
lantern: None,
|
||||
mount_bone: anim::vek::Transform::default(),
|
||||
trail_points: None,
|
||||
relative_trail_points: None,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1153,6 +1153,10 @@ impl Scene {
|
||||
self.particle_mgr
|
||||
.render(&mut first_pass.draw_particles(), scene_data);
|
||||
|
||||
// Render weapon trails.
|
||||
self.trail_mgr
|
||||
.render(&mut first_pass.draw_trails(), scene_data);
|
||||
|
||||
// Render debug shapes
|
||||
self.debug.render(&mut first_pass.draw_debug());
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
use super::SceneData;
|
||||
use crate::render::{DynamicModel, Renderer, TrailDrawer, TrailVertex};
|
||||
use crate::render::{
|
||||
pipelines::trail, DynamicModel, Mesh, Quad, Renderer, TrailDrawer, TrailVertex,
|
||||
};
|
||||
use common::comp::CharacterState;
|
||||
use common_base::span;
|
||||
use specs::{Entity as EcsEntity, Join, WorldExt};
|
||||
@ -44,10 +46,17 @@ impl TrailMgr {
|
||||
for (entity, _char_state) in
|
||||
(&ecs.entities(), &ecs.read_storage::<CharacterState>()).join()
|
||||
{
|
||||
let _ = self.dynamic_models.try_insert(
|
||||
if let Ok(model) = self.dynamic_models.try_insert(
|
||||
entity,
|
||||
renderer.create_dynamic_model(TRAIL_DYNAMIC_MODEL_SIZE * 4),
|
||||
);
|
||||
) {
|
||||
let mut mesh = Mesh::new();
|
||||
let zero = trail::Vertex { pos: [0.0; 3] };
|
||||
for _ in 0..TRAIL_DYNAMIC_MODEL_SIZE {
|
||||
mesh.push_quad(Quad::new(zero, zero, zero, zero));
|
||||
}
|
||||
renderer.update_model(model, &mesh, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// Clear dynamic models for entities that no longer exist (is this even
|
||||
|
Loading…
Reference in New Issue
Block a user