# HG changeset patch # User Sam # Date 1695485122 -25200 # Node ID 4c8bab2d1cc51236e196a11baa84cb98fe0f7b12 # Parent 2fb719f13a98a742227bc75f5d09cc2f30bdb361 add: some not-null assertions diff -r 2fb719f13a98 -r 4c8bab2d1cc5 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]())