blender: add tentative triangle support

This commit is contained in:
Zack Buhman 2025-06-26 22:18:52 -05:00
parent cb8fd7e345
commit a37ec7eb2c
2 changed files with 15 additions and 2 deletions

View File

@ -46,12 +46,14 @@ def render_polygons(f, name, polygons):
uv_ix = 0
for i, polygon in enumerate(polygons):
indices = [*polygon.vertices, polygon.material_index, uv_ix]
if len(polygon.vertices) == 3:
indices = [*polygon.vertices, -1, polygon.material_index, uv_ix]
uv_ix += len(polygon.vertices)
s = ", ".join(map(str, indices))
if len(polygon.vertices) == 4:
if len(polygon.vertices) in {3, 4}:
f.write(f" {{{s}}},\n")
else:
f.write(f" {{0, 0, 0, 0, -1}}, // {{{s}}}\n")
f.write(f" {{-1, -1, -1, -1, -1, -1}}, // {{{s}}}\n")
f.write("};\n\n")
def render_polygon_edge_pairs(f, name, polygons):

View File

@ -22,6 +22,17 @@ inline constexpr mat<4, 4, T> scale(vec<3, T> s)
};
}
template <typename T>
inline constexpr mat<4, 4, T> scale(T s)
{
return {
s, 0, 0, 0,
0, s, 0, 0,
0, 0, s, 0,
0, 0, 0, 1
};
}
template <typename T>
inline constexpr mat<4, 4, T> rotate_x(T t)
{