Mercurial > games > semicongine
changeset 997:fe48fb1bdfda
fix: ortho projection matrix (hopefully), better string output for matrix and vector
author | sam <sam@basx.dev> |
---|---|
date | Sat, 13 Apr 2024 00:22:45 +0700 |
parents | d91a810db920 |
children | 7e89c8fe57a8 |
files | semicongine/core/matrix.nim semicongine/core/vector.nim |
diffstat | 2 files changed, 6 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/semicongine/core/matrix.nim Fri Apr 12 19:44:27 2024 +0700 +++ b/semicongine/core/matrix.nim Sat Apr 13 00:22:45 2024 +0700 @@ -118,7 +118,7 @@ maxwidth = 0 for n in value.data: - let strval = &"{n:.2}" + let strval = &"{n:.4f}" strvalues.add(strval) if strval.len > maxwidth: maxwidth = strval.len @@ -131,7 +131,6 @@ if i mod T.columnCount == 0: result &= " " result &= filler & strvalues[i] & " " - result = $T & "\n" & result func `$`*(v: TMat2[SomeNumber]): string = toString[TMat2[SomeNumber]](v) func `$`*(v: TMat23[SomeNumber]): string = toString[TMat23[SomeNumber]](v) @@ -456,8 +455,8 @@ Mat4(data: [ 2 / (right - left), 0, 0, -(right + left) / (right - left), 0, 2 / (bottom - top), 0, -(bottom + top) / (bottom - top), - 0, 0, 1 / (zFar - zNear), -zNear / (zFar - zNear), - 0, 0, 1, 1, + 0, 0, 1 / (zFar - zNear), zNear / (zFar - zNear), + 0, 0, 0, 1, ]) # create an orthographic perspective that will map from -1 .. 1 on all axis and keep a 1:1 aspect ratio
--- a/semicongine/core/vector.nim Fri Apr 12 19:44:27 2024 +0700 +++ b/semicongine/core/vector.nim Sat Apr 13 00:22:45 2024 +0700 @@ -1,6 +1,7 @@ import std/random import std/math import std/strutils +import std/strformat import std/macros import std/typetraits import std/tables @@ -101,8 +102,8 @@ func toString[T](value: T): string = var items: seq[string] for item in value: - items.add($item) - $T & "(" & join(items, " ") & ")" + items.add(&"{item:.5f}") + & "(" & join(items, " ") & ")" func `$`*(v: TVec2[SomeNumber]): string = toString[TVec2[SomeNumber]](v) func `$`*(v: TVec3[SomeNumber]): string = toString[TVec3[SomeNumber]](v)