mirror of
https://github.com/storytold/texturecraft.git
synced 2026-11-26 17:30:45 +01:00
Space the UV layout guards
This commit is contained in:
1 parent
8f60ded96f
commit
a59e29bea1
3 files changed
+5
No files matched your search
@@ -550,6 +550,7 @@ fn apply_corner_uvs(mesh: &mut Mesh, layout: &[Vec2]) -> Result<()> {
|
||||
if layout.len() != mesh.indices.len() {
|
||||
return Err(FormatError::Invalid(format!("the saved UV layout has {} corners but the mesh has {}", layout.len(), mesh.indices.len())));
|
||||
}
|
||||
|
||||
if layout.iter().any(|uv| !uv.is_finite()) {
|
||||
return Err(FormatError::Invalid("the saved UV layout has non-finite UVs".into()));
|
||||
}
|
||||
|
||||
@@ -531,6 +531,7 @@ fn load_archive<R: Read + Seek>(mut zip: ZipArchive<R>, mut budget: LoadBudget)
|
||||
if pf.project.mesh_rebuild_uvs && pf.mesh.is_some() && pf.mesh_uvs.is_none() {
|
||||
return Err(malformed(KIND, "the mesh UVs were rebuilt but the project holds no saved UV layout"));
|
||||
}
|
||||
|
||||
if version < TANGENT_BENT_NORMAL_VERSION {
|
||||
drop_world_space_bent_normals(&mut pf);
|
||||
}
|
||||
|
||||
@@ -49,9 +49,11 @@ pub fn read_uv_layout(bytes: &[u8]) -> Result<Vec<Vec2>> {
|
||||
if magic != UV_LAYOUT_MAGIC {
|
||||
return Err(bad("bad magic"));
|
||||
}
|
||||
|
||||
if u32::from_le_bytes(*version) != UV_LAYOUT_VERSION {
|
||||
return Err(bad("unsupported version"));
|
||||
}
|
||||
|
||||
let corners = u32::from_le_bytes(*corners) as usize;
|
||||
if corners.checked_mul(CORNER_BYTES) != Some(body.len()) {
|
||||
return Err(bad("the corner count does not match the entry size"));
|
||||
@@ -69,5 +71,6 @@ pub fn read_uv_layout(bytes: &[u8]) -> Result<Vec<Vec2>> {
|
||||
if layout.iter().any(|uv| !uv.is_finite()) {
|
||||
return Err(bad("non-finite UVs"));
|
||||
}
|
||||
|
||||
Ok(layout)
|
||||
}
|
||||
Reference in new issue
Block a user