From f925ec15078d3e3008e0b3519a0b7ad5bf72513d Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Sun, 21 Nov 2010 00:09:50 +0000 Subject: [PATCH] Modified TransformPerspective to work correctly with orthographic projection matrices. Fixes issue [#1827]: "OpenTK.Vector3.TransformPerspective code is wrong". --- Source/OpenTK/Math/Vector3.cs | 2 +- Source/OpenTK/Math/Vector3d.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/OpenTK/Math/Vector3.cs b/Source/OpenTK/Math/Vector3.cs index f48d745b..5ce13d85 100644 --- a/Source/OpenTK/Math/Vector3.cs +++ b/Source/OpenTK/Math/Vector3.cs @@ -1154,7 +1154,7 @@ namespace OpenTK /// The transformed vector public static void TransformPerspective(ref Vector3 vec, ref Matrix4 mat, out Vector3 result) { - Vector4 v = new Vector4(vec); + Vector4 v = new Vector4(vec, 1); Vector4.Transform(ref v, ref mat, out v); result.X = v.X / v.W; result.Y = v.Y / v.W; diff --git a/Source/OpenTK/Math/Vector3d.cs b/Source/OpenTK/Math/Vector3d.cs index cec1cbc8..f61c3ec8 100644 --- a/Source/OpenTK/Math/Vector3d.cs +++ b/Source/OpenTK/Math/Vector3d.cs @@ -1152,7 +1152,7 @@ namespace OpenTK /// The transformed vector public static void TransformPerspective(ref Vector3d vec, ref Matrix4d mat, out Vector3d result) { - Vector4d v = new Vector4d(vec); + Vector4d v = new Vector4d(vec, 1); Vector4d.Transform(ref v, ref mat, out v); result.X = v.X / v.W; result.Y = v.Y / v.W;