mirror of
https://codeberg.org/icewind/vmdl.git
synced 2026-06-03 16:44:11 +02:00
clippy fixes
This commit is contained in:
parent
01f24876a0
commit
3175e0840c
4 changed files with 16 additions and 18 deletions
|
|
@ -83,7 +83,7 @@ pub fn load_material(
|
||||||
|
|
||||||
let bump_map = material.bump_map().and_then(|path| {
|
let bump_map = material.bump_map().and_then(|path| {
|
||||||
Some(TextureData {
|
Some(TextureData {
|
||||||
image: load_texture(&path, loader).ok()?,
|
image: load_texture(path, loader).ok()?,
|
||||||
name: path.into(),
|
name: path.into(),
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
@ -107,10 +107,10 @@ fn load_texture(name: &str, loader: &Loader) -> Result<DynamicImage, Error> {
|
||||||
"materials/{}.vtf",
|
"materials/{}.vtf",
|
||||||
name.trim_end_matches(".vtf").trim_start_matches('/')
|
name.trim_end_matches(".vtf").trim_start_matches('/')
|
||||||
);
|
);
|
||||||
let mut raw = loader
|
let raw = loader
|
||||||
.load(&path)?
|
.load(&path)?
|
||||||
.ok_or(Error::Other(format!("Can't find file {}", path)))?;
|
.ok_or(Error::Other(format!("Can't find file {}", path)))?;
|
||||||
let vtf = VTF::read(&mut raw)?;
|
let vtf = VTF::read(&raw)?;
|
||||||
let image = vtf.highres_image.decode(0)?;
|
let image = vtf.highres_image.decode(0)?;
|
||||||
Ok(image)
|
Ok(image)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ impl From<&vmdl::vvd::Vertex> for Vertex {
|
||||||
fn from(vertex: &vmdl::vvd::Vertex) -> Self {
|
fn from(vertex: &vmdl::vvd::Vertex) -> Self {
|
||||||
Vertex {
|
Vertex {
|
||||||
position: vertex.position.into(),
|
position: vertex.position.into(),
|
||||||
uv: vertex.texture_coordinates.into(),
|
uv: vertex.texture_coordinates,
|
||||||
normal: vertex.normal.into(),
|
normal: vertex.normal.into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -115,11 +115,9 @@ fn main() -> Result<(), Error> {
|
||||||
);
|
);
|
||||||
directional[0].intensity = directional_intensity;
|
directional[0].intensity = directional_intensity;
|
||||||
directional[1].intensity = directional_intensity;
|
directional[1].intensity = directional_intensity;
|
||||||
if ui.checkbox(&mut shadows_enabled, "Shadows").clicked() {
|
if ui.checkbox(&mut shadows_enabled, "Shadows").clicked() && !shadows_enabled {
|
||||||
if !shadows_enabled {
|
directional[0].clear_shadow_map();
|
||||||
directional[0].clear_shadow_map();
|
directional[1].clear_shadow_map();
|
||||||
directional[1].clear_shadow_map();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ui.label("Debug options");
|
ui.label("Debug options");
|
||||||
|
|
@ -175,8 +173,10 @@ fn main() -> Result<(), Error> {
|
||||||
lights,
|
lights,
|
||||||
),
|
),
|
||||||
DebugType::DEPTH => {
|
DebugType::DEPTH => {
|
||||||
let mut depth_material = DepthMaterial::default();
|
let depth_material = DepthMaterial {
|
||||||
depth_material.max_distance = Some(depth_max);
|
max_distance: Some(depth_max),
|
||||||
|
..DepthMaterial::default()
|
||||||
|
};
|
||||||
target.render_with_material(
|
target.render_with_material(
|
||||||
&depth_material,
|
&depth_material,
|
||||||
&camera,
|
&camera,
|
||||||
|
|
|
||||||
|
|
@ -214,7 +214,7 @@ struct FrameValues<'a> {
|
||||||
data: &'a [u8], // data starting at self.header
|
data: &'a [u8], // data starting at self.header
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> FrameValues<'a> {
|
impl FrameValues<'_> {
|
||||||
pub fn get(&self, index: u8) -> Result<u16, ModelError> {
|
pub fn get(&self, index: u8) -> Result<u16, ModelError> {
|
||||||
if self.header.total <= index {
|
if self.header.total <= index {
|
||||||
let offset_count = self.header.valid + 1;
|
let offset_count = self.header.valid + 1;
|
||||||
|
|
@ -368,12 +368,10 @@ fn read_animation(
|
||||||
header_offset: usize,
|
header_offset: usize,
|
||||||
frames: usize,
|
frames: usize,
|
||||||
) -> Result<(Animation, usize), ModelError> {
|
) -> Result<(Animation, usize), ModelError> {
|
||||||
let data = data
|
let data = data.get(header_offset..).ok_or(ModelError::OutOfBounds {
|
||||||
.get(header_offset..)
|
data: "animation data",
|
||||||
.ok_or_else(|| ModelError::OutOfBounds {
|
offset: header_offset,
|
||||||
data: "animation data",
|
})?;
|
||||||
offset: header_offset,
|
|
||||||
})?;
|
|
||||||
let header = <AnimationHeader as Readable>::read(data)?;
|
let header = <AnimationHeader as Readable>::read(data)?;
|
||||||
|
|
||||||
let offset = size_of::<AnimationHeader>();
|
let offset = size_of::<AnimationHeader>();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue