Fixed a few errors

This commit is contained in:
Sam
2022-01-25 23:52:28 -05:00
parent 5018a9f476
commit d23dd6c9e9
24 changed files with 53 additions and 32 deletions

View File

@ -113,7 +113,7 @@ impl Skeleton for ArthropodSkeleton {
orientation: mount_orientation, orientation: mount_orientation,
scale: Vec3::one(), scale: Vec3::one(),
}, },
trail_points: None, relative_trail_points: None,
} }
} }
} }

View File

@ -137,7 +137,7 @@ impl Skeleton for BipedLargeSkeleton {
.into(), .into(),
..Default::default() ..Default::default()
}, },
trail_points: None, relative_trail_points: None,
} }
} }
} }

View File

@ -83,7 +83,7 @@ impl Skeleton for BipedSmallSkeleton {
.into(), .into(),
..Default::default() ..Default::default()
}, },
trail_points: None, relative_trail_points: None,
} }
} }
} }

View File

@ -106,7 +106,7 @@ impl Skeleton for BirdLargeSkeleton {
.into(), .into(),
..Default::default() ..Default::default()
}, },
trail_points: None, relative_trail_points: None,
} }
} }
} }

View File

@ -60,7 +60,7 @@ impl Skeleton for BirdMediumSkeleton {
.into(), .into(),
..Default::default() ..Default::default()
}, },
trail_points: None, relative_trail_points: None,
} }
} }
} }

View File

@ -156,7 +156,7 @@ impl Skeleton for CharacterSkeleton {
.into(), .into(),
..Default::default() ..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(),
(main_mat * Vec4::new(0.0, 0.5, -6.0, 1.0)).xyz() + Vec3::unit_z(), (main_mat * Vec4::new(0.0, 0.5, -6.0, 1.0)).xyz() + Vec3::unit_z(),
)), )),

View File

@ -81,7 +81,7 @@ impl Skeleton for DragonSkeleton {
.into(), .into(),
..Default::default() ..Default::default()
}, },
trail_points: None, relative_trail_points: None,
} }
} }
} }

View File

@ -60,7 +60,7 @@ impl Skeleton for FishMediumSkeleton {
.into(), .into(),
..Default::default() ..Default::default()
}, },
trail_points: None, relative_trail_points: None,
} }
} }
} }

View File

@ -51,7 +51,7 @@ impl Skeleton for FishSmallSkeleton {
.into(), .into(),
..Default::default() ..Default::default()
}, },
trail_points: None, relative_trail_points: None,
} }
} }
} }

View File

@ -37,7 +37,7 @@ impl Skeleton for FixtureSkeleton {
Offsets { Offsets {
lantern: None, lantern: None,
mount_bone: Transform::default(), mount_bone: Transform::default(),
trail_points: None, relative_trail_points: None,
} }
} }
} }

View File

@ -83,7 +83,7 @@ impl Skeleton for GolemSkeleton {
.into(), .into(),
..Default::default() ..Default::default()
}, },
trail_points: None, relative_trail_points: None,
} }
} }
} }

View File

@ -103,7 +103,7 @@ pub fn init() { lazy_static::initialize(&LIB); }
pub struct Offsets { pub struct Offsets {
pub lantern: Option<Vec3<f32>>, pub lantern: Option<Vec3<f32>>,
pub mount_bone: Transform<f32, f32, 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 { pub trait Skeleton: Send + Sync + 'static {

View File

@ -49,7 +49,7 @@ impl Skeleton for ObjectSkeleton {
.into(), .into(),
..Default::default() ..Default::default()
}, },
trail_points: None, relative_trail_points: None,
} }
} }
} }

View File

@ -97,7 +97,7 @@ impl Skeleton for QuadrupedLowSkeleton {
orientation: mount_orientation, orientation: mount_orientation,
scale: Vec3::one(), scale: Vec3::one(),
}, },
trail_points: None, relative_trail_points: None,
} }
} }
} }

View File

@ -109,7 +109,7 @@ impl Skeleton for QuadrupedMediumSkeleton {
orientation: mount_orientation, orientation: mount_orientation,
scale: Vec3::one(), scale: Vec3::one(),
}, },
trail_points: None, relative_trail_points: None,
} }
} }
} }

View File

@ -74,7 +74,7 @@ impl Skeleton for QuadrupedSmallSkeleton {
orientation: mount_orientation, orientation: mount_orientation,
scale: Vec3::one(), scale: Vec3::one(),
}, },
trail_points: None, relative_trail_points: None,
} }
} }
} }

View File

@ -53,7 +53,7 @@ impl Skeleton for ShipSkeleton {
), ),
..Default::default() ..Default::default()
}, },
trail_points: None, relative_trail_points: None,
} }
} }
} }

View File

@ -84,7 +84,7 @@ impl Skeleton for TheropodSkeleton {
.into(), .into(),
..Default::default() ..Default::default()
}, },
trail_points: None, relative_trail_points: None,
} }
} }
} }

View File

@ -64,7 +64,7 @@ impl TrailPipeline {
topology: wgpu::PrimitiveTopology::TriangleList, topology: wgpu::PrimitiveTopology::TriangleList,
strip_index_format: None, strip_index_format: None,
front_face: wgpu::FrontFace::Ccw, front_face: wgpu::FrontFace::Ccw,
cull_mode: Some(wgpu::Face::Back), cull_mode: None,
clamp_depth: false, clamp_depth: false,
polygon_mode: wgpu::PolygonMode::Fill, polygon_mode: wgpu::PolygonMode::Fill,
conservative: false, conservative: false,

View File

@ -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.set_vertex_buffer(0, model.buf().slice(..));
self.render_pass self.render_pass
// TODO: since we cast to u32 maybe this should returned by the len/count functions? // 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);
} }
} }

View File

@ -6189,7 +6189,7 @@ impl FigureColLights {
pub struct FigureStateMeta { pub struct FigureStateMeta {
lantern_offset: Option<anim::vek::Vec3<f32>>, 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 // Animation to be applied to rider of this entity
mount_transform: anim::vek::Transform<f32, f32, f32>, 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 // 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 { Self {
meta: FigureStateMeta { meta: FigureStateMeta {
lantern_offset: offsets.lantern, 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_transform: offsets.mount_bone,
mount_world_pos: anim::vek::Vec3::zero(), mount_world_pos: anim::vek::Vec3::zero(),
state_time: 0.0, 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]); renderer.update_consts(&mut self.meta.bound.1, &new_bone_consts[0..S::BONE_COUNT]);
self.lantern_offset = offsets.lantern; self.lantern_offset = offsets.lantern;
// Handle weapon trails // 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(trail_mgr) = trail_mgr {
if let Some(dynamic_model) = entity if let Some(dynamic_model) = entity
.as_ref() .as_ref()
.and_then(|e| trail_mgr.dynamic_models.get(e)) .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 { 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))); 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 // TODO: compute the mount bone only when it is needed
self.mount_transform = offsets.mount_bone; self.mount_transform = offsets.mount_bone;

View File

@ -49,7 +49,7 @@ impl anim::Skeleton for VolumeKey {
anim::Offsets { anim::Offsets {
lantern: None, lantern: None,
mount_bone: anim::vek::Transform::default(), mount_bone: anim::vek::Transform::default(),
trail_points: None, relative_trail_points: None,
} }
} }

View File

@ -1153,6 +1153,10 @@ impl Scene {
self.particle_mgr self.particle_mgr
.render(&mut first_pass.draw_particles(), scene_data); .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 // Render debug shapes
self.debug.render(&mut first_pass.draw_debug()); self.debug.render(&mut first_pass.draw_debug());
} }

View File

@ -1,5 +1,7 @@
use super::SceneData; 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::comp::CharacterState;
use common_base::span; use common_base::span;
use specs::{Entity as EcsEntity, Join, WorldExt}; use specs::{Entity as EcsEntity, Join, WorldExt};
@ -44,10 +46,17 @@ impl TrailMgr {
for (entity, _char_state) in for (entity, _char_state) in
(&ecs.entities(), &ecs.read_storage::<CharacterState>()).join() (&ecs.entities(), &ecs.read_storage::<CharacterState>()).join()
{ {
let _ = self.dynamic_models.try_insert( if let Ok(model) = self.dynamic_models.try_insert(
entity, entity,
renderer.create_dynamic_model(TRAIL_DYNAMIC_MODEL_SIZE * 4), 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 // Clear dynamic models for entities that no longer exist (is this even