# HG changeset patch # User sam # Date 1712942565 -25200 # Node ID fe48fb1bdfda2e893f7fe5bd6290efb8d4bd8bf4 # Parent d91a810db920d8423c09607539eb886e7291ec5e fix: ortho projection matrix (hopefully), better string output for matrix and vector diff -r d91a810db920 -r fe48fb1bdfda semicongine/core/matrix.nim --- 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 diff -r d91a810db920 -r fe48fb1bdfda semicongine/core/vector.nim --- 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)