summaryrefslogtreecommitdiff
path: root/engine/src/material
diff options
context:
space:
mode:
Diffstat (limited to 'engine/src/material')
-rw-r--r--engine/src/material/asset.rs21
1 files changed, 10 insertions, 11 deletions
diff --git a/engine/src/material/asset.rs b/engine/src/material/asset.rs
index f87b768..f452f54 100644
--- a/engine/src/material/asset.rs
+++ b/engine/src/material/asset.rs
@@ -1,17 +1,9 @@
-use std::borrow::Cow;
-use std::collections::HashMap;
use std::fs::read_to_string;
use std::path::{Path, PathBuf};
-use crate::asset::{Assets, Handle as AssetHandle, Submitter as AssetSubmitter};
+use crate::asset::{Assets, Submitter as AssetSubmitter};
use crate::material::Material;
-#[derive(Debug, Clone)]
-pub struct Map
-{
- pub assets: HashMap<Cow<'static, str>, AssetHandle<Material>>,
-}
-
/// Material asset import settings.
#[derive(Debug)]
#[non_exhaustive]
@@ -19,15 +11,19 @@ pub struct Settings {}
pub fn add_importers(assets: &mut Assets)
{
- assets.set_importer(["mtl"], import_wavefront_mtl_asset);
+ assets.set_importer::<Material, Settings, Error>(import);
}
-fn import_wavefront_mtl_asset(
+fn import(
asset_submitter: &mut AssetSubmitter<'_>,
path: &Path,
_settings: Option<&'_ Settings>,
) -> Result<(), Error>
{
+ if path.extension().is_none_or(|ext| ext != "mtl") {
+ return Err(Error::UnsupportedFileType);
+ }
+
let parent_path = path
.parent()
.ok_or_else(|| Error::InvalidPath(path.to_path_buf()))?;
@@ -71,6 +67,9 @@ fn import_wavefront_mtl_asset(
#[derive(Debug, thiserror::Error)]
enum Error
{
+ #[error("File type is unsupported")]
+ UnsupportedFileType,
+
#[error("Invalid path '{}'", .0.display())]
InvalidPath(PathBuf),