From 64d624d8611c878e49c7c3bc9a58be873116b9de Mon Sep 17 00:00:00 2001 From: Frederic Freyer Date: Mon, 16 Sep 2024 05:19:12 +0200 Subject: [PATCH] remove redundant split_mesh function --- src/io/obj.jl | 55 +-------------------------------------------------- 1 file changed, 1 insertion(+), 54 deletions(-) diff --git a/src/io/obj.jl b/src/io/obj.jl index 7f7e925..c9a4c0b 100644 --- a/src/io/obj.jl +++ b/src/io/obj.jl @@ -214,59 +214,6 @@ function save(f::Stream{format"OBJ"}, mesh::AbstractMesh) end -# Experimental stuff for loading .mtl files and working with multiple materials - -""" - MehsIO.split_mesh(mesh) - -Experimental function for splitting a mesh based material indices. -Also remaps vertices to avoid passing all vertices with a submesh. -""" -function split_mesh(mesh) - ps = coordinates(mesh) - ns = normals(mesh) - uvs = texturecoordinates(mesh) - ids = mesh.material - fs = faces(mesh) - - meshes = Dict{Int, Any}() - target_ids = unique(ids) - IndexType = eltype(eltype(fs)) - - for target_id in target_ids - _fs = eltype(fs)[] - indexmap = Dict{UInt32, UInt32}() - counter = MeshIO._typemin(IndexType) - - for f in fs - if any(ids[f] .== target_id) - f = map(f) do _i - i = GeometryBasics.value(_i) - if haskey(indexmap, i) - return indexmap[i] - else - indexmap[i] = counter - counter += 1 - return counter-1 - end - end - push!(_fs, f) - end - end - - indices = Vector{UInt32}(undef, counter-1) - for (old, new) in indexmap - indices[new] = old - end - - meshes[target_id] = GeometryBasics.Mesh( - meta(ps[indices], normals = ns[indices], uv = uvs[indices]), _fs - ) - end - - return meshes -end - function _load_mtl!(materials::Dict{String, Dict{String, Any}}, filename::String) endswith(filename, ".mtl") || error("Material Template Library $filename must be a .mtl file.") @@ -442,4 +389,4 @@ function parse_texture_info(parent_path::String, lines::Vector{SubString{String} end return output -end \ No newline at end of file +end