Skip to content

Commit

Permalink
fix #98
Browse files Browse the repository at this point in the history
  • Loading branch information
planetis-m committed Jul 2, 2024
1 parent 49afd06 commit c237ea0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
6 changes: 4 additions & 2 deletions src/raylib.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ const raylibDir = currentSourcePath().Path.parentDir / Path"raylib"
{.passC: "-I" & string(raylibDir / Path"external/glfw/deps/mingw").}
{.passC: "-Wall -D_GNU_SOURCE -Wno-missing-braces -Werror=pointer-arith".}
when defined(emscripten):
{.passC: "-DPLATFORM_WEB -DGRAPHICS_API_OPENGL_ES2".}
{.passC: "-DPLATFORM_WEB -std=gnu99".}
when defined(GraphicsApiOpenGlEs3): {.passC: "-DGRAPHICS_API_OPENGL_ES3".}
else: {.passC: "-DGRAPHICS_API_OPENGL_ES2".}
{.passL: "-sUSE_GLFW=3 -sWASM=1 -sASYNCIFY -sTOTAL_MEMORY=67108864".}
{.passL: "-sGL_ENABLE_GET_PROC_ADDRESS".}
{.passL: "-sGL_ENABLE_GET_PROC_ADDRESS -sEXPORTED_RUNTIME_METHODS=ccall".}
when defined(NaylibWebResources):
const NaylibWebResourcesPath {.strdefine.} = "resources"
{.passL: "-sFORCE_FILESYSTEM=1 --preload-file " & NaylibWebResourcesPath.}
Expand Down
7 changes: 0 additions & 7 deletions src/raymath.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1609,7 +1609,6 @@ func decompose*(mat: Matrix, translation: var Vector3, rotation: var Quaternion,
translation.x = mat.m12
translation.y = mat.m13
translation.z = mat.m14

# Extract upper-left for determinant computation
let
a = mat.m0
Expand All @@ -1624,32 +1623,26 @@ func decompose*(mat: Matrix, translation: var Vector3, rotation: var Quaternion,
A = e*i - f*h
B = f*g - d*i
C = d*h - e*g

# Extract scale
let det = a*A + b*B + c*C
let
abc = Vector3(x: a, y: b, z: c)
def = Vector3(x: d, y: e, z: f)
ghi = Vector3(x: g, y: h, z: i)

let
scalex = length(abc)
scaley = length(def)
scalez = length(ghi)
var s = Vector3(x: scalex, y: scaley, z: scalez)

if det < 0:
s = negate(s)

scale = s

# Remove scale from the matrix if it is not close to zero
var clone = mat
if not equals(det, 0):
clone.m0 /= s.x
clone.m5 /= s.y
clone.m10 /= s.z

# Extract rotation
rotation = fromMatrix(clone)
else:
Expand Down
6 changes: 4 additions & 2 deletions tools/raylib_gen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ const raylibDir = currentSourcePath().Path.parentDir / Path"raylib"
{.passC: "-I" & string(raylibDir / Path"external/glfw/deps/mingw").}
{.passC: "-Wall -D_GNU_SOURCE -Wno-missing-braces -Werror=pointer-arith".}
when defined(emscripten):
{.passC: "-DPLATFORM_WEB -DGRAPHICS_API_OPENGL_ES2".}
{.passC: "-DPLATFORM_WEB -std=gnu99".}
when defined(GraphicsApiOpenGlEs3): {.passC: "-DGRAPHICS_API_OPENGL_ES3".}
else: {.passC: "-DGRAPHICS_API_OPENGL_ES2".}
{.passL: "-sUSE_GLFW=3 -sWASM=1 -sASYNCIFY -sTOTAL_MEMORY=67108864".}
{.passL: "-sGL_ENABLE_GET_PROC_ADDRESS".}
{.passL: "-sGL_ENABLE_GET_PROC_ADDRESS -sEXPORTED_RUNTIME_METHODS=ccall".}
when defined(NaylibWebResources):
const NaylibWebResourcesPath {.strdefine.} = "resources"
{.passL: "-sFORCE_FILESYSTEM=1 --preload-file " & NaylibWebResourcesPath.}
Expand Down

0 comments on commit c237ea0

Please sign in to comment.