@@ -133,6 +133,7 @@ void Model::load_node(const tinygltf::Node &inputNode, const tinygltf::Model &in
133
133
uint32_t firstIndex = static_cast <uint32_t >(indexBuffer.size ());
134
134
uint32_t vertexStart = static_cast <uint32_t >(vertexBuffer.size ());
135
135
uint32_t indexCount = 0 ;
136
+
136
137
// Vertices
137
138
{
138
139
const float *positionBuffer = nullptr ;
@@ -178,6 +179,7 @@ void Model::load_node(const tinygltf::Node &inputNode, const tinygltf::Model &in
178
179
vertexBuffer.push_back (vert);
179
180
}
180
181
}
182
+
181
183
// Indices
182
184
{
183
185
const tinygltf::Accessor &accessor = input.accessors [glTFPrimitive.indices ];
@@ -243,7 +245,7 @@ void Model::load_node(const tinygltf::Node &inputNode, const tinygltf::Model &in
243
245
}
244
246
}
245
247
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) {
247
249
if (node->mesh .primitives .size () > 0 ) {
248
250
// Pass the node's matrix via push constants
249
251
// 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
256
258
}
257
259
258
260
// 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);
261
262
262
263
for (ModelPrimitive &primitive : node->mesh .primitives ) {
263
264
if (primitive.index_count > 0 ) {
@@ -273,28 +274,28 @@ void Model::draw_node(VkCommandBuffer commandBuffer, VkPipelineLayout pipelineLa
273
274
274
275
// TODO: Fix this!
275
276
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 );
277
278
}
278
279
}
279
280
}
280
281
for (auto &child : node->children ) {
281
- draw_node (commandBuffer, pipelineLayout , child);
282
+ draw_node (cmd_buffer, layout , child);
282
283
}
283
284
}
284
285
285
- void Model::draw (VkCommandBuffer commandBuffer , VkPipelineLayout pipelineLayout ) {
286
+ void Model::draw (VkCommandBuffer cmd_buffer , VkPipelineLayout layout ) {
286
287
// All vertices and indices are stored in single buffers, so we only need to bind once
287
288
VkDeviceSize offsets[1 ] = {0 };
288
289
289
290
const auto &vertex_buffer = m_model_mesh->get_vertex_buffer ();
290
291
const auto &index_buffer = m_model_mesh->get_index_buffer ();
291
292
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);
294
295
295
296
// Render all nodes at top-level
296
297
for (auto &node : m_model_nodes) {
297
- draw_node (commandBuffer, pipelineLayout , node);
298
+ draw_node (cmd_buffer, layout , node);
298
299
}
299
300
}
300
301
0 commit comments