@@ -37,9 +37,11 @@ void Model::load_textures() {
3737 // The pointer to the rgb data we read from.
3838 unsigned char *mem_source_rgb = &texture.image [0 ];
3939
40- for (size_t i = 0 ; i < texture.width * texture.height ; ++i) {
40+ for (std:: size_t i = 0 ; i < texture.width * texture.height ; ++i) {
4141 std::memcpy (mem_target_rgba, mem_source_rgb, sizeof (unsigned char ) * 3 );
42+ // TODO: Remove pointer arithmetic or add NOLINT
4243 mem_target_rgba += 4 ;
44+ // TODO: Remove pointer arithmetic or add NOLINT
4345 mem_source_rgb += 3 ;
4446 }
4547
@@ -49,7 +51,7 @@ void Model::load_textures() {
4951 m_textures.emplace_back (m_device, &texture.image [0 ], texture_size, texture.width , texture.height ,
5052 texture.component , 1 , " glTF2 model texture" );
5153 } else {
52- spdlog::error (" Can't load texture from model file {} " , m_file_name );
54+ spdlog::error (" Can't load texture with {} channels! " , texture. component );
5355
5456 // Generate an error texture (checkboard pattern of pink and black squares).
5557 m_textures.emplace_back (m_device, wrapper::CpuTexture ());
@@ -157,10 +159,13 @@ void Model::load_node(const tinygltf::Node &start_node, ModelNode *parent, std::
157159 }
158160
159161 // Append data to model's vertex buffer
160- for (size_t vertex_number = 0 ; vertex_number < vertex_count; vertex_number++) {
162+ for (std:: size_t vertex_number = 0 ; vertex_number < vertex_count; vertex_number++) {
161163 ModelVertex new_vertex{};
164+ // TODO: Remove pointer arithmetic or add NOLINT
162165 new_vertex.pos = glm::vec4 (glm::make_vec3 (&position_buffer[vertex_number * 3 ]), 1 .0f );
166+ // TODO: Remove pointer arithmetic or add NOLINT
163167 new_vertex.normal = glm::normalize (glm::vec3 (
168+ // TODO: Remove pointer arithmetic or add NOLINT
164169 normals_buffer != nullptr ? glm::make_vec3 (&normals_buffer[vertex_number * 3 ]) : glm::vec3 (0 .0f )));
165170 new_vertex.uv = texture_coordinate_buffer != nullptr
166171 ? glm::make_vec2 (&texture_coordinate_buffer[vertex_number * 2 ])
@@ -215,8 +220,8 @@ void Model::load_node(const tinygltf::Node &start_node, ModelNode *parent, std::
215220 break ;
216221 }
217222 default :
218- spdlog::error ( " Index component type {} not supported! " , accessor. componentType );
219- return ;
223+ // TODO: Is this worth an exception or not?
224+ spdlog::error ( " Index component type {} is not supported! " , accessor. componentType ) ;
220225 }
221226
222227 ModelPrimitive new_primitive{};
@@ -244,11 +249,8 @@ void Model::load_nodes() {
244249
245250 for (const auto &scene : m_model.scenes ) {
246251 for (const auto &node : scene.nodes ) {
247- auto vertices = m_scenes[scene_index].get_vertices ();
248- auto indices = m_scenes[scene_index].get_indices ();
249- load_node (m_model.nodes [node], nullptr , vertices, indices);
252+ load_node (m_model.nodes [node], nullptr , m_scenes[scene_index].vertices , m_scenes[scene_index].indices );
250253 }
251-
252254 scene_index++;
253255 }
254256}
0 commit comments