changeset 349:7df73da85181

did: formatting and better mesh-toString
author Sam <sam@basx.dev>
date Sun, 17 Sep 2023 22:44:16 +0700
parents 67081fbaf636
children b75760e1a77b
files src/semicongine/mesh.nim src/semicongine/renderer.nim
diffstat 2 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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)