@@ -86,6 +86,17 @@ const GLNormalUVWMesh{Dim} = NormalUVWMesh{Dim,Float32}
86
86
const GLNormalUVWMesh2D = GLNormalUVWMesh{2 }
87
87
const GLNormalUVWMesh3D = GLNormalUVWMesh{3 }
88
88
89
+ function decompose_triangulate_fallback (primitive:: Meshable ; pointtype, facetype)
90
+ positions = decompose (pointtype, primitive)
91
+ faces = decompose (facetype, primitive)
92
+ # If faces returns nothing for primitive, we try to triangulate!
93
+ if faces === nothing
94
+ # triangulation.jl
95
+ faces = decompose (facetype, positions)
96
+ end
97
+ return positions, faces
98
+ end
99
+
89
100
"""
90
101
mesh(primitive::GeometryPrimitive;
91
102
pointtype=Point, facetype=GLTriangle,
@@ -101,13 +112,7 @@ It also only losely correlates to the number of vertices, depending on the algor
101
112
function mesh (primitive:: Meshable ; pointtype= Point, facetype= GLTriangleFace, uv= nothing ,
102
113
normaltype= nothing )
103
114
104
- positions = decompose (pointtype, primitive)
105
- faces = decompose (facetype, primitive)
106
- # If faces returns nothing for primitive, we try to triangulate!
107
- if faces === nothing
108
- # triangulation.jl
109
- faces = decompose (facetype, positions)
110
- end
115
+ positions, faces = decompose_triangulate_fallback (primitive; pointtype, facetype)
111
116
112
117
# We want to preserve any existing attributes!
113
118
attrs = attributes (primitive)
151
156
function mesh (polygon:: AbstractPolygon{Dim,T} ; pointtype= Point{Dim,T},
152
157
facetype= GLTriangleFace, normaltype= nothing ) where {Dim,T}
153
158
154
- faces = decompose (facetype, polygon)
155
- positions = decompose (pointtype, polygon)
159
+ positions, faces = decompose_triangulate_fallback (polygon; pointtype, facetype)
156
160
157
161
if normaltype != = nothing
158
162
n = normals (positions, faces; normaltype= normaltype)
0 commit comments