Skip to content

Commit 67e2160

Browse files
committed
[gltf] Improved method argument names.
Signed-off-by: Johannes <johannesschneider@outlook.com>
1 parent 245bc4d commit 67e2160

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

include/inexor/vulkan-renderer/gltf2/gltf_loader.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ class Model {
105105
/// @param commandBuffer
106106
/// @param pipelineLayout
107107
/// @param node
108-
void draw_node(VkCommandBuffer commandBuffer, VkPipelineLayout pipelineLayout, std::shared_ptr<ModelNode> node);
108+
void draw_node(VkCommandBuffer cmd_buffer, VkPipelineLayout layout, std::shared_ptr<ModelNode> node);
109109

110110
/// @brief Draw the glTF scene starting at the top-level-nodes.
111111
/// @param commandBuffer
112112
/// @param pipelineLayout
113-
void draw(VkCommandBuffer commandBuffer, VkPipelineLayout pipelineLayout);
113+
void draw(VkCommandBuffer cmd_buffer, VkPipelineLayout layout);
114114
};
115115

116116
}; // namespace inexor::vulkan_renderer::gltf2

src/vulkan-renderer/gltf2/gltf_loader.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)