diff options
Diffstat (limited to 'source/blender/freestyle/intern/geometry/GeomUtils.cpp')
-rwxr-xr-x | source/blender/freestyle/intern/geometry/GeomUtils.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/source/blender/freestyle/intern/geometry/GeomUtils.cpp b/source/blender/freestyle/intern/geometry/GeomUtils.cpp index fd36e81ca77..88aafeed598 100755 --- a/source/blender/freestyle/intern/geometry/GeomUtils.cpp +++ b/source/blender/freestyle/intern/geometry/GeomUtils.cpp @@ -619,11 +619,21 @@ namespace GeomUtils { void fromRetinaToCamera(const Vec3r& p, Vec3r& q, - real z, + real focal, const real projection_matrix[4][4]) { - q[0] = (-p[0] * z) / projection_matrix[0][0]; - q[1] = (-p[1] * z) / projection_matrix[1][1]; - q[2] = z; + + if( projection_matrix[3][3] == 0.0 ) // perspective + { + q[0] = (-p[0] * focal) / projection_matrix[0][0]; + q[1] = (-p[1] * focal) / projection_matrix[1][1]; + q[2] = focal; + } + else // orthogonal + { + q[0] = p[0] / projection_matrix[0][0]; + q[1] = p[1] / projection_matrix[1][1]; + q[2] = focal; + } } void fromCameraToWorld(const Vec3r& p, |