Skip to content

Commit 966364b

Browse files
committed
model
1 parent 9c16fd7 commit 966364b

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

src/model/mesh/file/mesh_facet.h

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,18 @@ namespace ns::model::mesh::file
3131
namespace mesh_check_implementation
3232
{
3333
template <std::size_t N>
34-
void check_facet_indices(
35-
const unsigned index,
36-
const int vertex_count,
37-
const int texcoord_count,
38-
const int normal_count,
39-
const typename Mesh<N>::Facet& facet)
34+
void check_vertex_indices(const unsigned index, const int vertex_count, const typename Mesh<N>::Facet& facet)
4035
{
4136
if (facet.vertices[index] < 0 || facet.vertices[index] >= vertex_count)
4237
{
4338
error("Vertex index " + to_string(facet.vertices[index]) + " is out of bounds [0, "
4439
+ to_string(vertex_count) + ")");
4540
}
41+
}
4642

43+
template <std::size_t N>
44+
void check_texcoord_indices(const unsigned index, const int texcoord_count, const typename Mesh<N>::Facet& facet)
45+
{
4746
if (facet.has_texcoord)
4847
{
4948
if (facet.texcoords[index] < 0 || facet.texcoords[index] >= texcoord_count)
@@ -56,7 +55,11 @@ void check_facet_indices(
5655
{
5756
error("No texture but texture coordinate index is not set to -1");
5857
}
58+
}
5959

60+
template <std::size_t N>
61+
void check_normal_indices(const unsigned index, const int normal_count, const typename Mesh<N>::Facet& facet)
62+
{
6063
if (facet.has_normal)
6164
{
6265
if (facet.normals[index] < 0 || facet.normals[index] >= normal_count)
@@ -82,7 +85,9 @@ void check_facet_indices(const Mesh<N>& mesh)
8285
{
8386
for (std::size_t i = 0; i < N; ++i)
8487
{
85-
check_facet_indices<N>(i, vertex_count, texcoord_count, normal_count, facet);
88+
check_vertex_indices<N>(i, vertex_count, facet);
89+
check_texcoord_indices<N>(i, texcoord_count, facet);
90+
check_normal_indices<N>(i, normal_count, facet);
8691
}
8792
}
8893
}

0 commit comments

Comments
 (0)