more sprites on airships

This commit is contained in:
Isse 2023-04-18 11:52:12 +02:00
parent 6674cce2cc
commit a35a1a34c4
8 changed files with 78 additions and 15 deletions

View File

@ -13,15 +13,22 @@
central: ("airship_human.propeller-r"),
),
bone3: (
offset: (-1.5, -11.0, -5.5),
offset: (-1.5, -10.0, -4.5),
central: ("airship_human.rudder"),
),
custom_indices: {
1: Air(ChairSingle, 4),
2: Air(Helm, 0),
3: Air(Door, 4),
8: Air(Door, 0),
3: Air(DoorWide, 4),
8: Air(DoorWide, 0),
9: Air(CraftingBench, 0),
11: Air(RepairBench, 0),
12: Air(DismantlingBench, 4),
15: Air(Anvil, 2),
17: Air(CookingPot, 0),
18: Air(WallLamp, 4),
23: Air(FireBowlGround, 4),
},
),
AirBalloon: (

Binary file not shown.

BIN
assets/voxygen/voxel/sprite/door/door-wide.vox (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -1871,6 +1871,16 @@ DoorDark: Some((
],
wind_sway: 0.0,
)),
DoorWide: Some((
variations: [
(
model: "voxygen.voxel.sprite.door.door-wide",
offset: (-5.5, -5.5, 0.0),
lod_axes: (1.0, 1.0, 1.0),
),
],
wind_sway: 0.0,
)),
// Bed
Bed: Some((
variations: [

View File

@ -243,7 +243,7 @@ pub mod figuredata {
AssetExt::load("common.manifests.ship_manifest")?;
let mut colliders = HashMap::new();
for (_, spec) in (manifest.read().0).0.iter() {
for bone in [&spec.bone0, &spec.bone1, &spec.bone2, &spec.bone3].iter() {
for (index, bone) in [&spec.bone0, &spec.bone1, &spec.bone2, &spec.bone3].iter().enumerate() {
// TODO: Currently both client and server load models and manifests from
// "common.voxel.". In order to support CSG procedural airships, we probably
// need to load them in the server and sync them as an ECS resource.
@ -254,7 +254,7 @@ pub mod figuredata {
let dyna = base_structure.vol.map_into(|cell| {
if let Some(i) = cell {
let color = base_structure.palette[u8::from(i) as usize];
if let Some(block) = spec.custom_indices.get(&i.into()) {
if let Some(block) = spec.custom_indices.get(&i.into()) && index == 0 {
block.to_block(color)
} else {
Block::new(BlockKind::Misc, color)

View File

@ -243,6 +243,7 @@ make_case_elim!(
CommonLockedChest = 0xD9,
RepairBench = 0xDA,
Helm = 0xDB,
DoorWide = 0xDC,
}
);
@ -376,6 +377,7 @@ impl SpriteKind {
SpriteKind::Bamboo => 9.0 / 11.0,
SpriteKind::MagicalBarrier => 3.0,
SpriteKind::MagicalSeal => 1.0,
SpriteKind::Helm => 1.7,
_ => return None,
})
}
@ -505,10 +507,12 @@ impl SpriteKind {
#[inline]
pub fn is_controller(&self) -> bool {
match self {
SpriteKind::Helm => true,
_ => false,
}
matches!(self, SpriteKind::Helm)
}
#[inline]
pub fn is_door(&self) -> bool {
matches!(self, SpriteKind::Door | SpriteKind::DoorWide | SpriteKind::DoorDark)
}
/// Which tool (if any) is needed to collect this sprite?
@ -640,7 +644,8 @@ impl SpriteKind {
| SpriteKind::Grave
| SpriteKind::Gravestone
| SpriteKind::MagicalBarrier
| SpriteKind::Helm,
| SpriteKind::Helm
| SpriteKind::DoorWide,
)
}
}

View File

@ -31,7 +31,7 @@ use crate::{
use client::Client;
use common::{
calendar::Calendar,
comp,
comp::{self, ship::figuredata::VOXEL_COLLIDER_MANIFEST},
outcome::Outcome,
resources::DeltaTime,
terrain::{BlockKind, TerrainChunk, TerrainGrid},
@ -667,6 +667,7 @@ impl Scene {
self.trail_mgr.maintain(renderer, scene_data);
// Update light constants
let max_light_dist = loaded_distance.powi(2) + LIGHT_DIST_RADIUS;
lights.extend(
(
&scene_data.state.ecs().read_storage::<comp::Pos>(),
@ -690,7 +691,7 @@ impl Scene {
light_anim.col != Rgb::zero()
&& light_anim.strength > 0.0
&& pos.0.distance_squared(viewpoint_pos)
< loaded_distance.powi(2) + LIGHT_DIST_RADIUS
< max_light_dist
&& h.map_or(true, |h| !h.is_dead)
})
.map(|(pos, interpolated, light_anim, _)| {
@ -704,6 +705,43 @@ impl Scene {
.map(|el| el.light.with_strength((el.fadeout)(el.timeout))),
),
);
let voxel_colliders_manifest = VOXEL_COLLIDER_MANIFEST.read();
let figure_mgr = &self.figure_mgr;
lights.extend(
(
&scene_data.state.ecs().entities(),
&scene_data.state.read_storage::<comp::Pos>(),
&scene_data.state.read_storage::<comp::Ori>(),
&scene_data.state.read_storage::<comp::Body>(),
&scene_data.state.read_storage::<comp::Collider>(),
).join().filter_map(|(entity, pos, ori, body, collider)| {
let vol = collider.get_vol(&voxel_colliders_manifest)?;
let mat = Mat4::from(ori.to_quat()).translated_3d(pos.0)
* Mat4::translation_3d(vol.translation);
let p = mat.inverted().mul_point(viewpoint_pos);
let aabb = Aabb {
min: Vec3::zero(),
max: vol.volume().sz.as_(),
};
if aabb.contains_point(p) || aabb.distance_to_point(p) < max_light_dist {
figure_mgr
.get_blocks_of_interest(entity, body, Some(collider))
.map(move |(blocks_of_interest, _)| {
blocks_of_interest.lights.iter().map(
move |(block_offset, level)| {
let wpos = mat.mul_point(block_offset.as_() + 0.5);
(wpos, level)
},
).filter(move |(wpos, _)| wpos.distance_squared(viewpoint_pos) < max_light_dist)
.map(|(wpos, level)| Light::new(wpos, Rgb::white(), *level as f32 / 7.0))
})
} else {
None
}
}).flatten()
);
lights.sort_by_key(|light| light.get_pos().distance_squared(viewpoint_pos) as i32);
lights.truncate(MAX_LIGHT_COUNT);
renderer.update_consts(&mut self.data.lights, lights);

View File

@ -302,7 +302,7 @@ pub fn get_sprite_instances<'a, I: 'a>(
light,
glow,
page,
matches!(sprite, SpriteKind::Door),
sprite.is_door(),
);
set_instance(lod_level, instance, wpos);
}