瀏覽代碼

Fixed raymath not applying matrix translations.

Translation matrices use the w components of the matrix to apply the
transform, and thus only work when the w component is 1. In the
original raymath implementation, the multiplication is done manually
and adds the translation components directly to the result, as if w is
1, but in the Odin binding this is done with a matrix multiplication.
However, the w component is set to 0 instead of 1, resulting in the
translation not being applied.
Barinzaya 9 月之前
父節點
當前提交
30cf3ed02f
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      vendor/raylib/raymath.odin

+ 2 - 2
vendor/raylib/raymath.odin

@@ -153,7 +153,7 @@ Vector2Normalize :: proc "c" (v: Vector2) -> Vector2 {
 // Transforms a Vector2 by a given Matrix
 // Transforms a Vector2 by a given Matrix
 @(require_results)
 @(require_results)
 Vector2Transform :: proc "c" (v: Vector2, m: Matrix) -> Vector2 {
 Vector2Transform :: proc "c" (v: Vector2, m: Matrix) -> Vector2 {
-	v4 := Vector4{v.x, v.y, 0, 0}
+	v4 := Vector4{v.x, v.y, 0, 1}
 	return (m * v4).xy
 	return (m * v4).xy
 }
 }
 // Calculate linear interpolation between two vectors
 // Calculate linear interpolation between two vectors
@@ -399,7 +399,7 @@ Vector3RotateByAxisAngle :: proc "c" (v: Vector3, axis: Vector3, angle: f32) ->
 // Transforms a Vector3 by a given Matrix
 // Transforms a Vector3 by a given Matrix
 @(require_results)
 @(require_results)
 Vector3Transform :: proc "c" (v: Vector3, m: Matrix) -> Vector3 {
 Vector3Transform :: proc "c" (v: Vector3, m: Matrix) -> Vector3 {
-	v4 := Vector4{v.x, v.y, v.z, 0}
+	v4 := Vector4{v.x, v.y, v.z, 1}
 	return (m * v4).xyz
 	return (m * v4).xyz
 }
 }
 // Calculate linear interpolation between two vectors
 // Calculate linear interpolation between two vectors