From 7fcf2e7d4af1429b461dec92b6d66ff09e9be9f3 Mon Sep 17 00:00:00 2001 From: Sebastian Parborg Date: Tue, 19 May 2020 16:23:44 +0200 Subject: Fix T74577: world_to_camera_view broken for off-axis projection The issue was that the projection would be inverted. So if you shifted 0.1 along the y axis, world_to_camera_view would act as if you had shited it -0.1 along the y axis. --- release/scripts/modules/bpy_extras/object_utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'release/scripts/modules') diff --git a/release/scripts/modules/bpy_extras/object_utils.py b/release/scripts/modules/bpy_extras/object_utils.py index 540bc75cece..5b7f26ff89c 100644 --- a/release/scripts/modules/bpy_extras/object_utils.py +++ b/release/scripts/modules/bpy_extras/object_utils.py @@ -256,15 +256,15 @@ def world_to_camera_view(scene, obj, coord): z = -co_local.z camera = obj.data - frame = [-v for v in camera.view_frame(scene=scene)[:3]] + frame = [v for v in camera.view_frame(scene=scene)[:3]] if camera.type != 'ORTHO': if z == 0.0: return Vector((0.5, 0.5, 0.0)) else: - frame = [(v / (v.z / z)) for v in frame] + frame = [-(v / (v.z / z)) for v in frame] - min_x, max_x = frame[1].x, frame[2].x - min_y, max_y = frame[0].y, frame[1].y + min_x, max_x = frame[2].x, frame[1].x + min_y, max_y = frame[1].y, frame[0].y x = (co_local.x - min_x) / (max_x - min_x) y = (co_local.y - min_y) / (max_y - min_y) -- cgit v1.2.3