Skip to content

Commit c029a3e

Browse files
committed
don't convert if already of correct type
1 parent c0e1ee3 commit c029a3e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/meshes.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,18 @@ function mesh(polygon::AbstractPolygon{Dim,T}; pointtype=Point{Dim,T},
167167
return Mesh(positions, faces)
168168
end
169169

170+
pointtype(x::Mesh) = eltype(decompose(Point, x))
171+
facetype(x::Mesh) = eltype(faces(x))
172+
173+
function triangle_mesh(primitive::Mesh{N}) where {N}
174+
# already target type:
175+
if pointtype(primitive) === Point{N,Float32} && GLTriangleFace === facetype(primitive)
176+
return primitive
177+
else
178+
return mesh(primitive; pointtype=Point{N,Float32}, facetype=GLTriangleFace)
179+
end
180+
end
181+
170182
function triangle_mesh(primitive::Meshable{N}; nvertices=nothing) where {N}
171183
if nvertices !== nothing
172184
@warn("nvertices argument deprecated. Wrap primitive in `Tesselation(primitive, nvertices)`")

0 commit comments

Comments
 (0)