Mercurial > games > semicongine
view src/semicongine/scene.nim @ 328:8d0ffcacc7e3
did: some cleanup
author | Sam <sam@basx.dev> |
---|---|
date | Fri, 25 Aug 2023 01:14:04 +0700 |
parents | 4ec852355750 |
children | 69e18f69713b |
line wrap: on
line source
import std/strformat import std/strutils import std/tables import std/hashes import std/typetraits import ./core import ./animation import ./mesh type Scene* = object name*: string shaderGlobals*: Table[string, DataList] meshes*: seq[Mesh] func addShaderGlobal*[T](scene: var Scene, name: string, data: T) = scene.shaderGlobals[name] = newDataList(thetype=getDataType[T]()) setValues(scene.shaderGlobals[name], @[data]) func addShaderGlobalArray*[T](scene: var Scene, name: string, data: seq[T]) = scene.shaderGlobals[name] = newDataList(thetype=getDataType[T]()) setValues(scene.shaderGlobals[name], data) func getShaderGlobal*[T](scene: Scene, name: string): T = getValues[T](scene.shaderGlobals[name])[0] func getShaderGlobalArray*[T](scene: Scene, name: string): seq[T] = getValues[T](scene.shaderGlobals[name]) func setShaderGlobal*[T](scene: var Scene, name: string, value: T) = setValues[T](scene.shaderGlobals[name], @[value]) func setShaderGlobalArray*[T](scene: var Scene, name: string, value: seq[T]) = setValues[T](scene.shaderGlobals[name], value) func appendShaderGlobalArray*[T](scene: var Scene, name: string, value: seq[T]) = appendValues[T](scene.shaderGlobals[name], value) func hash*(scene: Scene): Hash = hash(scene.name) func `==`*(a, b: Scene): bool = a.name == b.name