@@ -133,6 +133,7 @@ void Model::load_node(const tinygltf::Node &inputNode, const tinygltf::Model &in
133133 uint32_t firstIndex = static_cast <uint32_t >(indexBuffer.size ());
134134 uint32_t vertexStart = static_cast <uint32_t >(vertexBuffer.size ());
135135 uint32_t indexCount = 0 ;
136+
136137 // Vertices
137138 {
138139 const float *positionBuffer = nullptr ;
@@ -178,6 +179,7 @@ void Model::load_node(const tinygltf::Node &inputNode, const tinygltf::Model &in
178179 vertexBuffer.push_back (vert);
179180 }
180181 }
182+
181183 // Indices
182184 {
183185 const tinygltf::Accessor &accessor = input.accessors [glTFPrimitive.indices ];
@@ -243,7 +245,7 @@ void Model::load_node(const tinygltf::Node &inputNode, const tinygltf::Model &in
243245 }
244246}
245247
246- void Model::draw_node (VkCommandBuffer commandBuffer , VkPipelineLayout pipelineLayout , std::shared_ptr<ModelNode> node) {
248+ void Model::draw_node (VkCommandBuffer cmd_buffer , VkPipelineLayout layout , std::shared_ptr<ModelNode> node) {
247249 if (node->mesh .primitives .size () > 0 ) {
248250 // Pass the node's matrix via push constants
249251 // Traverse the node hierarchy to the top-most parent to get the final matrix of the current node
@@ -256,8 +258,7 @@ void Model::draw_node(VkCommandBuffer commandBuffer, VkPipelineLayout pipelineLa
256258 }
257259
258260 // Pass the final matrix to the vertex shader using push constants
259- vkCmdPushConstants (commandBuffer, pipelineLayout, VK_SHADER_STAGE_VERTEX_BIT, 0 , sizeof (glm::mat4),
260- &nodeMatrix);
261+ vkCmdPushConstants (cmd_buffer, layout, VK_SHADER_STAGE_VERTEX_BIT, 0 , sizeof (glm::mat4), &nodeMatrix);
261262
262263 for (ModelPrimitive &primitive : node->mesh .primitives ) {
263264 if (primitive.index_count > 0 ) {
@@ -273,28 +274,28 @@ void Model::draw_node(VkCommandBuffer commandBuffer, VkPipelineLayout pipelineLa
273274
274275 // TODO: Fix this!
275276
276- vkCmdDrawIndexed (commandBuffer , primitive.index_count , 1 , primitive.first_index , 0 , 0 );
277+ vkCmdDrawIndexed (cmd_buffer , primitive.index_count , 1 , primitive.first_index , 0 , 0 );
277278 }
278279 }
279280 }
280281 for (auto &child : node->children ) {
281- draw_node (commandBuffer, pipelineLayout , child);
282+ draw_node (cmd_buffer, layout , child);
282283 }
283284}
284285
285- void Model::draw (VkCommandBuffer commandBuffer , VkPipelineLayout pipelineLayout ) {
286+ void Model::draw (VkCommandBuffer cmd_buffer , VkPipelineLayout layout ) {
286287 // All vertices and indices are stored in single buffers, so we only need to bind once
287288 VkDeviceSize offsets[1 ] = {0 };
288289
289290 const auto &vertex_buffer = m_model_mesh->get_vertex_buffer ();
290291 const auto &index_buffer = m_model_mesh->get_index_buffer ();
291292
292- vkCmdBindVertexBuffers (commandBuffer , 0 , 1 , &vertex_buffer, offsets);
293- vkCmdBindIndexBuffer (commandBuffer , index_buffer, 0 , VK_INDEX_TYPE_UINT32);
293+ vkCmdBindVertexBuffers (cmd_buffer , 0 , 1 , &vertex_buffer, offsets);
294+ vkCmdBindIndexBuffer (cmd_buffer , index_buffer, 0 , VK_INDEX_TYPE_UINT32);
294295
295296 // Render all nodes at top-level
296297 for (auto &node : m_model_nodes) {
297- draw_node (commandBuffer, pipelineLayout , node);
298+ draw_node (cmd_buffer, layout , node);
298299 }
299300}
300301
0 commit comments