@@ -248,9 +248,9 @@ function Base.merge(meshes::AbstractVector{<:Mesh})
248248
249249 # Check that all meshes use the same VertexAttributes
250250 # Could also do this via typing the function, but maybe error is nice?
251- names = keys (m1 . vertex_attributes)
252- idx = findfirst (m -> keys (m . vertex_attributes) ! = names, meshes)
253- if idx != = nothing
251+ names = keys (vertex_attributes (m1) )
252+ if ! all (m -> keys (vertex_attributes (m)) = = names, meshes)
253+ idx = findfirst (m -> keys ( vertex_attributes (m)) != names, meshes)
254254 error (
255255 " Cannot merge meshes with different vertex attributes. " *
256256 " First missmatch between meshes[1] with $names and " *
@@ -276,16 +276,17 @@ function Base.merge(meshes::AbstractVector{<:Mesh})
276276 new_attribs = NamedTuple {names} (map (names) do name
277277 return reduce (vcat, getproperty .(meshes, name))
278278 end )
279+ # fs = reduce(vcat, faces.(meshes))
279280 fs = reduce (vcat, faces .(meshes))
280281
281282 # TODO : is the type difference in offset bad?
282283 idx = length (faces (m1))
283- offset = length (coordinates (m1)):: Int # TODO : unnecessary
284+ offset = length (coordinates (m1))
284285 views = isempty (m1. views) ? UnitRange{Int64}[1 : idx] : copy (m1. views)
285286
286- Ns = length .( faces .( meshes) )
287- Ms = length .( coordinates .(meshes)) :: Vector{Int} # TODO : unnecessary
288- for (mesh, N, M) in Iterators . drop ( zip (meshes, Ns, Ms), 1 )
287+ for mesh in Iterators . drop ( meshes, 1 )
288+ N = length ( faces (mesh))
289+
289290 # update face indices
290291 for i = idx .+ (1 : N)
291292 # TODO : face + Int changes type to Int
@@ -302,7 +303,7 @@ function Base.merge(meshes::AbstractVector{<:Mesh})
302303 end
303304
304305 idx += N
305- offset += M
306+ offset += length ( coordinates (mesh))
306307 end
307308
308309 return Mesh (new_attribs, fs, views)
0 commit comments