# HG changeset patch # User Sam # Date 1688825186 -25200 # Node ID 81949dafd8f436e1cd1e72a07728a139d9c91244 # Parent c73224f9d38fa5c44ae72f33260b8bb04cbd5177 fix: references dont need to be passed as "var", small error message improvment diff -r c73224f9d38f -r 81949dafd8f4 src/semicongine/audio.nim --- a/src/semicongine/audio.nim Sat Jul 08 18:52:34 2023 +0700 +++ b/src/semicongine/audio.nim Sat Jul 08 21:06:26 2023 +0700 @@ -77,7 +77,7 @@ proc play*(mixer: var Mixer, soundName: string, track="", stopOtherSounds=false, loop=false, levelLeft, levelRight: Level): uint64 = assert track in mixer.tracks - assert soundName in mixer.sounds + assert soundName in mixer.sounds, soundName & " not loaded" mixer.lock.withLock(): if stopOtherSounds: mixer.tracks[track].playing.clear() diff -r c73224f9d38f -r 81949dafd8f4 src/semicongine/mesh.nim --- a/src/semicongine/mesh.nim Sat Jul 08 18:52:34 2023 +0700 +++ b/src/semicongine/mesh.nim Sat Jul 08 21:06:26 2023 +0700 @@ -60,15 +60,15 @@ of Small: &"indices: {mesh.smallIndices}" of Big: &"indices: {mesh.bigIndices}") -proc setMeshData*[T: GPUType|int|uint|float](mesh: var Mesh, attribute: string, data: seq[T]) = +proc setMeshData*[T: GPUType|int|uint|float](mesh: Mesh, attribute: string, data: seq[T]) = assert not (attribute in mesh.data) mesh.data[attribute] = newDataList(data) -proc setMeshData*(mesh: var Mesh, attribute: string, data: DataList) = +proc setMeshData*(mesh: Mesh, attribute: string, data: DataList) = assert not (attribute in mesh.data) mesh.data[attribute] = data -proc setInstanceData*[T: GPUType|int|uint|float](mesh: var Mesh, attribute: string, data: seq[T]) = +proc setInstanceData*[T: GPUType|int|uint|float](mesh: Mesh, attribute: string, data: seq[T]) = assert uint32(data.len) == mesh.instanceCount assert not (attribute in mesh.data) mesh.data[attribute] = newDataList(data) @@ -155,7 +155,7 @@ assert attribute in mesh.data getValues[T](mesh.data[attribute]) -proc initData*(mesh: var Mesh, attribute: ShaderAttribute) = +proc initData*(mesh: Mesh, attribute: ShaderAttribute) = assert not (attribute.name in mesh.data) mesh.data[attribute.name] = newDataList(thetype=attribute.thetype) if attribute.perInstance: @@ -163,41 +163,41 @@ else: mesh.data[attribute.name].initData(mesh.vertexCount) -proc updateMeshData*[T: GPUType|int|uint|float](mesh: var Mesh, attribute: string, data: seq[T]) = +proc updateMeshData*[T: GPUType|int|uint|float](mesh: Mesh, attribute: string, data: seq[T]) = assert attribute in mesh.data mesh.changedAttributes.add attribute setValues(mesh.data[attribute], data) -proc updateMeshData*[T: GPUType|int|uint|float](mesh: var Mesh, attribute: string, i: uint32, value: T) = +proc updateMeshData*[T: GPUType|int|uint|float](mesh: Mesh, attribute: string, i: uint32, value: T) = assert attribute in mesh.data mesh.changedAttributes.add attribute setValue(mesh.data[attribute], i, value) -proc appendMeshData*[T: GPUType|int|uint|float](mesh: var Mesh, attribute: string, data: seq[T]) = +proc appendMeshData*[T: GPUType|int|uint|float](mesh: Mesh, attribute: string, data: seq[T]) = assert attribute in mesh.data mesh.changedAttributes.add attribute appendValues(mesh.data[attribute], data) # currently only used for loading from files, shouls -proc appendMeshData*(mesh: var Mesh, attribute: string, data: DataList) = +proc appendMeshData*(mesh: Mesh, attribute: string, data: DataList) = assert attribute in mesh.data assert data.thetype == mesh.data[attribute].thetype mesh.changedAttributes.add attribute appendValues(mesh.data[attribute], data) -proc updateInstanceData*[T: GPUType|int|uint|float](mesh: var Mesh, attribute: string, data: seq[T]) = +proc updateInstanceData*[T: GPUType|int|uint|float](mesh: Mesh, attribute: string, data: seq[T]) = assert uint32(data.len) == mesh.instanceCount assert attribute in mesh.data mesh.changedAttributes.add attribute setValues(mesh.data[attribute], data) -proc appendInstanceData*[T: GPUType|int|uint|float](mesh: var Mesh, attribute: string, data: seq[T]) = +proc appendInstanceData*[T: GPUType|int|uint|float](mesh: Mesh, attribute: string, data: seq[T]) = assert uint32(data.len) == mesh.instanceCount assert attribute in mesh.data mesh.changedAttributes.add attribute appendValues(mesh.data[attribute], data) -proc appendIndicesData*(mesh: var Mesh, v1, v2, v3: uint32) = +proc appendIndicesData*(mesh: Mesh, v1, v2, v3: uint32) = case mesh.indexType of None: raise newException(Exception, "Mesh does not support indexed data") of Tiny: mesh.tinyIndices.add([uint8(v1), uint8(v2), uint8(v3)]) @@ -207,10 +207,10 @@ func hasDataChanged*(mesh: Mesh, attribute: string): bool = attribute in mesh.changedAttributes -proc clearDataChanged*(mesh: var Mesh) = +proc clearDataChanged*(mesh: Mesh) = mesh.changedAttributes = @[] -proc transform*[T: GPUType](mesh: var Mesh, attribute: string, transform: Mat4) = +proc transform*[T: GPUType](mesh: Mesh, attribute: string, transform: Mat4) = assert attribute in mesh.data for v in getValues[T](mesh.data[attribute])[].mitems: v = transform * v @@ -265,16 +265,16 @@ setMeshData(result, "color", col) setInstanceData(result, "transform", @[Unit4F32]) -proc areInstanceTransformsDirty*(mesh: var Mesh): bool = +proc areInstanceTransformsDirty*(mesh: Mesh): bool = result = mesh.dirtyInstanceTransforms mesh.dirtyInstanceTransforms = false -proc setInstanceTransform*(mesh: var Mesh, i: uint32, mat: Mat4) = +proc setInstanceTransform*(mesh: Mesh, i: uint32, mat: Mat4) = assert 0 <= i and i < mesh.instanceCount mesh.instanceTransforms[i] = mat mesh.dirtyInstanceTransforms = true -proc setInstanceTransforms*(mesh: var Mesh, mat: seq[Mat4]) = +proc setInstanceTransforms*(mesh: Mesh, mat: seq[Mat4]) = mesh.instanceTransforms = mat mesh.dirtyInstanceTransforms = true