# HG changeset patch # User Sam # Date 1695485122 -25200 # Node ID 407bb5a965a9e3e065a27afabdab98394497816d # Parent 2942ec187cbe4f50b78ebb779f18865d534d10e7 add: some not-null assertions diff -r 2942ec187cbe -r 407bb5a965a9 src/semicongine/scene.nim --- a/src/semicongine/scene.nim Sat Sep 23 22:10:33 2023 +0700 +++ b/src/semicongine/scene.nim Sat Sep 23 23:05:22 2023 +0700 @@ -17,11 +17,18 @@ scene.meshes.add tmp proc add*(scene: var Scene, mesh: Mesh) = + assert not mesh.isNil, "Cannot add a mesh that is 'nil'" scene.meshes.add mesh # generic way to add objects that have a mesh-attribute proc add*[T](scene: var Scene, obj: T) = - scene.meshes.add obj.mesh + for name, value in obj.fieldPairs: + when typeof(value) is Mesh: + assert not value.isNil, &"Cannot add a mesh that is 'nil': " & name + scene.meshes.add value + when typeof(value) is seq[Mesh]: + assert not value.isNil, &"Cannot add a mesh that is 'nil': " & name + scene.meshes.add value proc addShaderGlobal*[T](scene: var Scene, name: string, data: T) = scene.shaderGlobals[name] = newDataList(thetype=getDataType[T]())