From f30e18681924015a915c0d729aca5cc8815912dd Mon Sep 17 00:00:00 2001 From: "R. N. West" <98110034+rnwst@users.noreply.github.com> Date: Sun, 9 Aug 2026 12:08:07 +0100 Subject: [PATCH] fix: avoid type var in Mesh constructor to enable JuliaC trimming The type variable in the `Mesh` constructor was preventing JuliaC from being able to statically resolve types for trimming. Only use a type variable when the deprecated `normals` attribute is provided. Also fix the attribute name substitution! The previous logic had a bug in it that resulted in the code not actually substituting `normals` for `normal`. --- src/basic_types.jl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/basic_types.jl b/src/basic_types.jl index 345e7f55..9a0eed13 100644 --- a/src/basic_types.jl +++ b/src/basic_types.jl @@ -509,7 +509,7 @@ struct Mesh{ Dim, T <: Real, FT <: AbstractFace, Names, - VAT <: Tuple{<: AbstractVector{Point{Dim, T}}, Vararg{VertexAttributeType}}, + VAT <: Tuple{<:AbstractVector{Point{Dim, T}}, Vararg{VertexAttributeType}}, FVT <: AbstractVector{FT} } <: AbstractMesh{Dim, T} @@ -527,17 +527,17 @@ struct Mesh{ } va = vertex_attributes - names = Names # verify type - if !haskey(va, :position ) + if !haskey(va, :position) error("Vertex attributes must have a :position attribute.") end if haskey(va, :normals) @warn "`normals` as a vertex attribute name has been deprecated in favor of `normal` to bring it in line with mesh.position and mesh.uv" - names = ntuple(i -> ifelse(names[i] == :normal, :normal, names[i]), length(names)) + names = ntuple(i -> ifelse(Names[i] == :normals, :normal, Names[i]), length(Names)) va = NamedTuple{names}(values(va)) + return new{Dim, T, FT, names, VAT, FVT}(va, fs, views) end # verify that all vertex attributes refer to the same number of vertices @@ -556,7 +556,7 @@ struct Mesh{ end end - return new{Dim, T, FT, names, VAT, FVT}(va, fs, views) + return new{Dim, T, FT, Names, VAT, FVT}(va, fs, views) end end