mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
realize zesterers proposal
This commit is contained in:
parent
f4a87e9f0b
commit
e60aace448
@ -20,14 +20,6 @@ use vek::*;
|
|||||||
/// Figures are used to represent things like characters, NPCs, mobs, etc.
|
/// Figures are used to represent things like characters, NPCs, mobs, etc.
|
||||||
pub type Segment = Dyna<Cell, ()>;
|
pub type Segment = Dyna<Cell, ()>;
|
||||||
|
|
||||||
impl From<&DotVoxData> for Segment {
|
|
||||||
fn from(dot_vox_data: &DotVoxData) -> Self { Segment::from_vox(dot_vox_data, false, 0) }
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<(&DotVoxData, usize)> for Segment {
|
|
||||||
fn from(spec: (&DotVoxData, usize)) -> Self { Segment::from_vox(spec.0, false, spec.1) }
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Segment {
|
impl Segment {
|
||||||
/// Take a list of voxel data, offsets, and x-mirror flags, and assembled
|
/// Take a list of voxel data, offsets, and x-mirror flags, and assembled
|
||||||
/// them into a combined segment
|
/// them into a combined segment
|
||||||
@ -39,6 +31,10 @@ impl Segment {
|
|||||||
union.unify()
|
union.unify()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn from_vox_model_index(dot_vox_data: &DotVoxData, model_index: usize) -> Self {
|
||||||
|
Self::from_vox(dot_vox_data, false, model_index)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn from_vox(dot_vox_data: &DotVoxData, flipped: bool, model_index: usize) -> Self {
|
pub fn from_vox(dot_vox_data: &DotVoxData, flipped: bool, model_index: usize) -> Self {
|
||||||
if let Some(model) = dot_vox_data.models.get(model_index) {
|
if let Some(model) = dot_vox_data.models.get(model_index) {
|
||||||
let palette = dot_vox_data
|
let palette = dot_vox_data
|
||||||
@ -206,6 +202,10 @@ impl MatSegment {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn from_vox_model_index(dot_vox_data: &DotVoxData, model_index: usize) -> Self {
|
||||||
|
Self::from_vox(dot_vox_data, false, model_index)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn from_vox(dot_vox_data: &DotVoxData, flipped: bool, model_index: usize) -> Self {
|
pub fn from_vox(dot_vox_data: &DotVoxData, flipped: bool, model_index: usize) -> Self {
|
||||||
if let Some(model) = dot_vox_data.models.get(model_index) {
|
if let Some(model) = dot_vox_data.models.get(model_index) {
|
||||||
let palette = dot_vox_data
|
let palette = dot_vox_data
|
||||||
@ -266,11 +266,3 @@ impl MatSegment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&DotVoxData> for MatSegment {
|
|
||||||
fn from(dot_vox_data: &DotVoxData) -> Self { Self::from_vox(dot_vox_data, false, 0) }
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<(&DotVoxData, usize)> for MatSegment {
|
|
||||||
fn from(spec: (&DotVoxData, usize)) -> Self { Self::from_vox(spec.0, false, spec.1) }
|
|
||||||
}
|
|
||||||
|
@ -167,7 +167,10 @@ fn graceful_load_img(specifier: &str) -> Arc<DynamicImage> {
|
|||||||
|
|
||||||
fn graceful_load_segment_no_skin(specifier: &str, model_index: u32) -> Arc<Segment> {
|
fn graceful_load_segment_no_skin(specifier: &str, model_index: u32) -> Arc<Segment> {
|
||||||
use common::figure::{mat_cell::MatCell, MatSegment};
|
use common::figure::{mat_cell::MatCell, MatSegment};
|
||||||
let mat_seg = MatSegment::from((&graceful_load_vox(specifier).read().0, model_index as usize));
|
let mat_seg = MatSegment::from_vox_model_index(
|
||||||
|
&graceful_load_vox(specifier).read().0,
|
||||||
|
model_index as usize,
|
||||||
|
);
|
||||||
let seg = mat_seg
|
let seg = mat_seg
|
||||||
.map(|mat_cell| match mat_cell {
|
.map(|mat_cell| match mat_cell {
|
||||||
MatCell::None => None,
|
MatCell::None => None,
|
||||||
|
@ -38,7 +38,10 @@ const DEFAULT_INDEX: u32 = 0;
|
|||||||
|
|
||||||
fn load_segment(mesh_name: &str) -> Segment {
|
fn load_segment(mesh_name: &str) -> Segment {
|
||||||
let full_specifier: String = ["voxygen.voxel.", mesh_name].concat();
|
let full_specifier: String = ["voxygen.voxel.", mesh_name].concat();
|
||||||
Segment::from(&DotVoxAsset::load_expect(&full_specifier).read().0)
|
Segment::from_vox_model_index(
|
||||||
|
&DotVoxAsset::load_expect(&full_specifier).read().0,
|
||||||
|
DEFAULT_INDEX as usize,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
fn graceful_load_vox(mesh_name: &str) -> AssetHandle<DotVoxAsset> {
|
fn graceful_load_vox(mesh_name: &str) -> AssetHandle<DotVoxAsset> {
|
||||||
let full_specifier: String = ["voxygen.voxel.", mesh_name].concat();
|
let full_specifier: String = ["voxygen.voxel.", mesh_name].concat();
|
||||||
@ -54,13 +57,13 @@ fn graceful_load_vox_fullspec(full_specifier: &str) -> AssetHandle<DotVoxAsset>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn graceful_load_segment(mesh_name: &str, model_index: u32) -> Segment {
|
fn graceful_load_segment(mesh_name: &str, model_index: u32) -> Segment {
|
||||||
Segment::from((&graceful_load_vox(mesh_name).read().0, model_index as usize))
|
Segment::from_vox_model_index(&graceful_load_vox(mesh_name).read().0, model_index as usize)
|
||||||
}
|
}
|
||||||
fn graceful_load_segment_fullspec(full_specifier: &str, model_index: u32) -> Segment {
|
fn graceful_load_segment_fullspec(full_specifier: &str, model_index: u32) -> Segment {
|
||||||
Segment::from((
|
Segment::from_vox_model_index(
|
||||||
&graceful_load_vox_fullspec(full_specifier).read().0,
|
&graceful_load_vox_fullspec(full_specifier).read().0,
|
||||||
model_index as usize,
|
model_index as usize,
|
||||||
))
|
)
|
||||||
}
|
}
|
||||||
fn graceful_load_segment_flipped(mesh_name: &str, flipped: bool, model_index: u32) -> Segment {
|
fn graceful_load_segment_flipped(mesh_name: &str, flipped: bool, model_index: u32) -> Segment {
|
||||||
Segment::from_vox(
|
Segment::from_vox(
|
||||||
@ -70,7 +73,7 @@ fn graceful_load_segment_flipped(mesh_name: &str, flipped: bool, model_index: u3
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
fn graceful_load_mat_segment(mesh_name: &str, model_index: u32) -> MatSegment {
|
fn graceful_load_mat_segment(mesh_name: &str, model_index: u32) -> MatSegment {
|
||||||
MatSegment::from((&graceful_load_vox(mesh_name).read().0, model_index as usize))
|
MatSegment::from_vox_model_index(&graceful_load_vox(mesh_name).read().0, model_index as usize)
|
||||||
}
|
}
|
||||||
fn graceful_load_mat_segment_flipped(mesh_name: &str, model_index: u32) -> MatSegment {
|
fn graceful_load_mat_segment_flipped(mesh_name: &str, model_index: u32) -> MatSegment {
|
||||||
MatSegment::from_vox(
|
MatSegment::from_vox(
|
||||||
@ -5153,15 +5156,16 @@ impl ItemDropCentralSpec {
|
|||||||
} {
|
} {
|
||||||
let full_spec: String = ["voxygen.", spec.as_str()].concat();
|
let full_spec: String = ["voxygen.", spec.as_str()].concat();
|
||||||
let segment = match item_drop {
|
let segment = match item_drop {
|
||||||
item_drop::Body::Armor(_) => {
|
item_drop::Body::Armor(_) => MatSegment::from_vox_model_index(
|
||||||
MatSegment::from(&graceful_load_vox_fullspec(&full_spec).read().0)
|
&graceful_load_vox_fullspec(&full_spec).read().0,
|
||||||
.map(|mat_cell| match mat_cell {
|
0,
|
||||||
MatCell::None => None,
|
)
|
||||||
MatCell::Mat(_) => Some(MatCell::None),
|
.map(|mat_cell| match mat_cell {
|
||||||
MatCell::Normal(data) => data.is_hollow().then_some(MatCell::None),
|
MatCell::None => None,
|
||||||
})
|
MatCell::Mat(_) => Some(MatCell::None),
|
||||||
.to_segment(|_| Default::default())
|
MatCell::Normal(data) => data.is_hollow().then_some(MatCell::None),
|
||||||
},
|
})
|
||||||
|
.to_segment(|_| Default::default()),
|
||||||
_ => graceful_load_segment_fullspec(&full_spec, DEFAULT_INDEX),
|
_ => graceful_load_segment_fullspec(&full_spec, DEFAULT_INDEX),
|
||||||
};
|
};
|
||||||
let offset = segment_center(&segment).unwrap_or_default();
|
let offset = segment_center(&segment).unwrap_or_default();
|
||||||
@ -5234,7 +5238,7 @@ fn mesh_ship_bone<K: fmt::Debug + Eq + Hash, V, F: Fn(&V) -> &ShipCentralSubSpec
|
|||||||
};
|
};
|
||||||
let bone = f(spec);
|
let bone = f(spec);
|
||||||
let central = graceful_load_segment_fullspec(
|
let central = graceful_load_segment_fullspec(
|
||||||
&["common.voxel.", &bone.central.0].concat(),
|
&format!("common.voxel.{}", &bone.central.0),
|
||||||
bone.model_index,
|
bone.model_index,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1977,7 +1977,7 @@ fn default_cache(renderer: &mut Renderer) -> HashMap<&'static str, Model<Particl
|
|||||||
let max_size = Vec2::from(u16::try_from(max_texture_size).unwrap_or(u16::MAX));
|
let max_size = Vec2::from(u16::try_from(max_texture_size).unwrap_or(u16::MAX));
|
||||||
let mut greedy = GreedyMesh::new(max_size, crate::mesh::greedy::general_config());
|
let mut greedy = GreedyMesh::new(max_size, crate::mesh::greedy::general_config());
|
||||||
|
|
||||||
let segment = Segment::from(&vox.read().0);
|
let segment = Segment::from_vox_model_index(&vox.read().0, 0);
|
||||||
let segment_size = segment.size();
|
let segment_size = segment.size();
|
||||||
let mut mesh = generate_mesh_base_vol_particle(segment, &mut greedy).0;
|
let mut mesh = generate_mesh_base_vol_particle(segment, &mut greedy).0;
|
||||||
// Center particle vertices around origin
|
// Center particle vertices around origin
|
||||||
|
@ -571,7 +571,8 @@ impl SpriteRenderContext {
|
|||||||
// Mesh generation exclusively acts using side effects; it
|
// Mesh generation exclusively acts using side effects; it
|
||||||
// has no interesting return value, but updates the mesh.
|
// has no interesting return value, but updates the mesh.
|
||||||
generate_mesh_base_vol_sprite(
|
generate_mesh_base_vol_sprite(
|
||||||
Segment::from(&model.read().0).scaled_by(lod_scale),
|
Segment::from_vox_model_index(&model.read().0, 0)
|
||||||
|
.scaled_by(lod_scale),
|
||||||
(greedy, sprite_mesh, false),
|
(greedy, sprite_mesh, false),
|
||||||
offset.map(|e: f32| e.floor()) * lod_scale,
|
offset.map(|e: f32| e.floor()) * lod_scale,
|
||||||
);
|
);
|
||||||
|
@ -37,7 +37,7 @@ pub enum VoxelPixArtGraphic {}
|
|||||||
|
|
||||||
fn load_segment(specifier: &str) -> Result<Arc<Segment>, Error> {
|
fn load_segment(specifier: &str) -> Result<Arc<Segment>, Error> {
|
||||||
let dot_vox = DotVoxAsset::load(specifier)?;
|
let dot_vox = DotVoxAsset::load(specifier)?;
|
||||||
let seg = Segment::from(&dot_vox.read().0);
|
let seg = Segment::from_vox_model_index(&dot_vox.read().0, 0);
|
||||||
Ok(Arc::new(seg))
|
Ok(Arc::new(seg))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user