forked from 1b-agent/opencadstudio-upstream
style: apply cargo fmt across workspace
This commit is contained in:
1 parent
85710e5454
commit
9cf9ff2c5c
531 files changed
+57740
-33906
No files matched your search
@@ -89,8 +89,7 @@ impl MeshMaterialMapper {
|
||||
+ self.normal_basis[2][1] * normal[1] as f64
|
||||
+ self.normal_basis[2][2] * normal[2] as f64,
|
||||
];
|
||||
let length =
|
||||
(mapped[0] * mapped[0] + mapped[1] * mapped[1] + mapped[2] * mapped[2]).sqrt();
|
||||
let length = (mapped[0] * mapped[0] + mapped[1] * mapped[1] + mapped[2] * mapped[2]).sqrt();
|
||||
if length > f64::EPSILON {
|
||||
[
|
||||
(mapped[0] / length) as f32,
|
||||
@@ -183,8 +182,7 @@ impl MeshTextureMap {
|
||||
source: map.source,
|
||||
file_name: map.file_name.clone(),
|
||||
procedural: map.texture.is_some(),
|
||||
image: load_map_image(map, base_dir)
|
||||
.or_else(|| procedural_map_image(map)),
|
||||
image: load_map_image(map, base_dir).or_else(|| procedural_map_image(map)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,8 +323,7 @@ impl MeshMaterial {
|
||||
.flat_map(|lod| lod.triangle_material_handles.iter().flatten().copied())
|
||||
.collect();
|
||||
for handle in handles {
|
||||
let material =
|
||||
resolve_material_handle_with_base(document, handle, self, base_dir);
|
||||
let material = resolve_material_handle_with_base(document, handle, self, base_dir);
|
||||
set.face_materials.insert(handle, material);
|
||||
}
|
||||
}
|
||||
@@ -368,9 +365,7 @@ fn procedural_map_image(map: &MaterialMap) -> Option<Arc<MaterialImage>> {
|
||||
} else {
|
||||
color2
|
||||
};
|
||||
rgba.extend(color.map(|channel| {
|
||||
(channel.clamp(0.0, 1.0) * 255.0).round() as u8
|
||||
}));
|
||||
rgba.extend(color.map(|channel| (channel.clamp(0.0, 1.0) * 255.0).round() as u8));
|
||||
}
|
||||
}
|
||||
Some(Arc::new(MaterialImage {
|
||||
@@ -443,21 +438,9 @@ fn entity_material_mapper(entity: &EntityType) -> Option<MeshMaterialMapper> {
|
||||
let y = positions.next()?;
|
||||
let z = positions.next()?;
|
||||
let basis = glam::DMat3::from_cols(
|
||||
glam::DVec3::from_array([
|
||||
x[0] - origin[0],
|
||||
x[1] - origin[1],
|
||||
x[2] - origin[2],
|
||||
]),
|
||||
glam::DVec3::from_array([
|
||||
y[0] - origin[0],
|
||||
y[1] - origin[1],
|
||||
y[2] - origin[2],
|
||||
]),
|
||||
glam::DVec3::from_array([
|
||||
z[0] - origin[0],
|
||||
z[1] - origin[1],
|
||||
z[2] - origin[2],
|
||||
]),
|
||||
glam::DVec3::from_array([x[0] - origin[0], x[1] - origin[1], x[2] - origin[2]]),
|
||||
glam::DVec3::from_array([y[0] - origin[0], y[1] - origin[1], y[2] - origin[2]]),
|
||||
glam::DVec3::from_array([z[0] - origin[0], z[1] - origin[1], z[2] - origin[2]]),
|
||||
);
|
||||
if basis.determinant().abs() <= f64::EPSILON {
|
||||
return None;
|
||||
@@ -627,6 +610,9 @@ mod tests {
|
||||
line.common.extended_data.add_record(record);
|
||||
let mapper = entity_material_mapper(&EntityType::Line(line)).expect("valid mapper");
|
||||
|
||||
assert_eq!(mapper.map_position([4.0, 22.0, 42.0], [0.0; 3]), [1.0, 2.0, 3.0]);
|
||||
assert_eq!(
|
||||
mapper.map_position([4.0, 22.0, 42.0], [0.0; 3]),
|
||||
[1.0, 2.0, 3.0]
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user