Mercurial > games > semicongine
comparison src/zamikongine/math/matrix.nim @ 24:71bbe11d8de8
did: change shader compilation to run during program compilation, maybe add dynamic version later
author | Sam <sam@basx.dev> |
---|---|
date | Wed, 11 Jan 2023 11:15:02 +0700 |
parents | b45a5d338cd0 |
children | c3c963e7c1a6 |
comparison
equal
deleted
inserted
replaced
23:0ffdf1f4ecf4 | 24:71bbe11d8de8 |
---|---|
29 Mat44*[T: SomeNumber] = object | 29 Mat44*[T: SomeNumber] = object |
30 data: array[16, T] | 30 data: array[16, T] |
31 MatMM* = Mat22|Mat33|Mat44 | 31 MatMM* = Mat22|Mat33|Mat44 |
32 MatMN* = Mat23|Mat32|Mat34|Mat43 | 32 MatMN* = Mat23|Mat32|Mat34|Mat43 |
33 Mat* = MatMM|MatMN | 33 Mat* = MatMM|MatMN |
34 IntegerMat = Mat22[SomeInteger]|Mat33[SomeInteger]|Mat44[SomeInteger]|Mat23[SomeInteger]|Mat32[SomeInteger]|Mat34[SomeInteger]|Mat43[SomeInteger] | |
35 FloatMat = Mat22[SomeFloat]|Mat33[SomeFloat]|Mat44[SomeFloat]|Mat23[SomeFloat]|Mat32[SomeFloat]|Mat34[SomeFloat]|Mat43[SomeFloat] | |
36 | 34 |
37 func unit22[T: SomeNumber](): auto {.compiletime.} = Mat22[T](data:[ | 35 func unit22[T: SomeNumber](): auto {.compiletime.} = Mat22[T](data:[ |
38 T(1), T(0), | 36 T(1), T(0), |
39 T(0), T(1), | 37 T(0), T(1), |
40 ]) | 38 ]) |
202 newEmptyNode(), | 200 newEmptyNode(), |
203 newEmptyNode(), | 201 newEmptyNode(), |
204 resultVec | 202 resultVec |
205 ) | 203 ) |
206 | 204 |
207 proc createVecMatMultiplicationOperator1(vecType: typedesc, matType: typedesc): NimNode = | |
208 var data = nnkBracket.newTree() | |
209 for i in 0 ..< matType.columnCount: | |
210 data.add(newCall( | |
211 ident("sum"), | |
212 infix( | |
213 ident("v"), | |
214 "*", | |
215 newCall(newDotExpr(ident("m"), ident("col")), newLit(i)) | |
216 ) | |
217 )) | |
218 let resultVec = nnkObjConstr.newTree( | |
219 nnkBracketExpr.newTree(ident(vecType.name), ident("float")), | |
220 nnkExprColonExpr.newTree(ident("data"), data) | |
221 ) | |
222 | |
223 return nnkFuncDef.newTree( | |
224 ident("test"), | |
225 newEmptyNode(), | |
226 newEmptyNode(), | |
227 newEmptyNode(), | |
228 newEmptyNode(), | |
229 newEmptyNode(), | |
230 resultVec, | |
231 ) | |
232 | 205 |
233 proc createMatScalarOperator(matType: typedesc, op: string): NimNode = | 206 proc createMatScalarOperator(matType: typedesc, op: string): NimNode = |
234 result = newStmtList() | 207 result = newStmtList() |
235 | 208 |
236 var data = nnkBracket.newTree() | 209 var data = nnkBracket.newTree() |