Mercurial > games > semicongine
diff src/semicongine/renderer.nim @ 288:5af702c95b16
add: what seems like a working animation system, atm integrated with entities, will add more for meshes
author | Sam <sam@basx.dev> |
---|---|
date | Wed, 14 Jun 2023 22:55:00 +0700 |
parents | 563ca4a82931 |
children | c73224f9d38f |
line wrap: on
line diff
--- a/src/semicongine/renderer.nim Sat Jun 10 00:31:51 2023 +0700 +++ b/src/semicongine/renderer.nim Wed Jun 14 22:55:00 2023 +0700 @@ -80,9 +80,9 @@ # create index buffer if necessary var indicesBufferSize = 0'u64 for mesh in allMeshes: - if mesh.indexType != None: + if mesh.indexType != MeshIndexType.None: let indexAlignment = case mesh.indexType - of None: 0'u64 + of MeshIndexType.None: 0'u64 of Tiny: 1'u64 of Small: 2'u64 of Big: 4'u64 @@ -140,7 +140,7 @@ if perLocationOffsets[attribute.memoryPerformanceHint] mod VERTEX_ATTRIB_ALIGNMENT != 0: perLocationOffsets[attribute.memoryPerformanceHint] += VERTEX_ATTRIB_ALIGNMENT - (perLocationOffsets[attribute.memoryPerformanceHint] mod VERTEX_ATTRIB_ALIGNMENT) - let indexed = mesh.indexType != None + let indexed = mesh.indexType != MeshIndexType.None var drawable = Drawable( elementCount: if indexed: mesh.indicesCount else: mesh.vertexCount, bufferOffsets: offsets, @@ -149,7 +149,7 @@ ) if indexed: let indexAlignment = case mesh.indexType - of None: 0'u64 + of MeshIndexType.None: 0'u64 of Tiny: 1'u64 of Small: 2'u64 of Big: 4'u64 @@ -223,7 +223,7 @@ # if mesh transformation attribute is enabled, update the model matrix if renderer.scenedata[scene].transformAttribute != "": let transform = mesh.entity.getModelTransform() - if not (mesh in renderer.scenedata[scene].entityTransformationCache) or renderer.scenedata[scene].entityTransformationCache[mesh] != transform or mesh.areInstanceTransformsDirty: + if not (mesh in renderer.scenedata[scene].entityTransformationCache) or renderer.scenedata[scene].entityTransformationCache[mesh] != transform or mesh.areInstanceTransformsDirty : var updatedTransform = newSeq[Mat4](int(mesh.instanceCount)) for i in 0 ..< mesh.instanceCount: updatedTransform[i] = transform * mesh.getInstanceTransform(i) @@ -237,6 +237,10 @@ var m = mesh m.clearDataChanged() +proc updateAnimations*(renderer: var Renderer, scene: var Scene, dt: float32) = + for animation in allComponentsOfType[EntityAnimation](scene.root): + animation.update(dt) + proc updateUniformData*(renderer: var Renderer, scene: var Scene) = assert scene in renderer.scenedata