# HG changeset patch # User Sam # Date 1694965456 -25200 # Node ID 7df73da8518106abd76ed4fd4acd6c1459459ee3 # Parent 67081fbaf636f7cdf9bc7835489e2784f7a6b45e did: formatting and better mesh-toString diff -r 67081fbaf636 -r 7df73da85181 src/semicongine/mesh.nim --- a/src/semicongine/mesh.nim Sun Sep 17 21:09:38 2023 +0700 +++ b/src/semicongine/mesh.nim Sun Sep 17 22:44:16 2023 +0700 @@ -39,12 +39,15 @@ textures*: Table[string, Texture] index*: uint16 # optional, may be used to index into uniform arrays in shader -let DEFAULT_MATERIAL = Material( +let DEFAULT_MATERIAL* = Material( name: "default material" ) +func instanceCount*(mesh: MeshObject): int = + mesh.instanceTransforms.len + func `$`*(mesh: MeshObject): string = - &"Mesh(vertexCount: {mesh.vertexCount}, vertexData: {mesh.vertexData.keys().toSeq()}, instanceData: {mesh.instanceData.keys().toSeq()}, indexType: {mesh.indexType})" + &"Mesh(vertexCount: {mesh.vertexCount}, instanceCount: {mesh.instanceCount}, vertexData: {mesh.vertexData.keys().toSeq()}, instanceData: {mesh.instanceData.keys().toSeq()}, indexType: {mesh.indexType})" func `$`*(mesh: Mesh): string = $mesh[] @@ -72,9 +75,6 @@ func hash*(mesh: Mesh): Hash = hash(cast[ptr MeshObject](mesh)) -func instanceCount*(mesh: MeshObject): int = - mesh.instanceTransforms.len - converter toVulkan*(indexType: MeshIndexType): VkIndexType = case indexType: of None: VK_INDEX_TYPE_NONE_KHR diff -r 67081fbaf636 -r 7df73da85181 src/semicongine/renderer.nim --- a/src/semicongine/renderer.nim Sun Sep 17 21:09:38 2023 +0700 +++ b/src/semicongine/renderer.nim Sun Sep 17 22:44:16 2023 +0700 @@ -429,7 +429,7 @@ commandBuffer.vkCmdBindPipeline(renderer.renderPass.subpasses[i].pipelineBindPoint, pipeline.vk) commandBuffer.vkCmdBindDescriptorSets(renderer.renderPass.subpasses[i].pipelineBindPoint, pipeline.layout, 0, 1, addr(renderer.scenedata[scene].descriptorSets[pipeline.vk][renderer.swapchain.currentInFlight].vk), 0, nil) for (drawable, mesh) in renderer.scenedata[scene].drawables.filterIt(it[1].visible and it[1].material.name == materialName): - drawable.draw(commandBuffer, vertexBuffers=renderer.scenedata[scene].vertexBuffers, indexBuffer=renderer.scenedata[scene].indexBuffer, pipeline.vk) + drawable.draw(commandBuffer, vertexBuffers=renderer.scenedata[scene].vertexBuffers, indexBuffer=renderer.scenedata[scene].indexBuffer, pipeline.vk) if i < renderer.renderPass.subpasses.len - 1: commandBuffer.vkCmdNextSubpass(VK_SUBPASS_CONTENTS_INLINE)