[Bf-blender-cvs] [7fcf2e7d4af] blender-v2.83-release: Fix T74577: world_to_camera_view broken for off-axis projection

Sebastian Parborg noreply at git.blender.org
Tue May 19 17:07:47 CEST 2020


Commit: 7fcf2e7d4af1429b461dec92b6d66ff09e9be9f3
Author: Sebastian Parborg
Date:   Tue May 19 16:23:44 2020 +0200
Branches: blender-v2.83-release
https://developer.blender.org/rB7fcf2e7d4af1429b461dec92b6d66ff09e9be9f3

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.

===================================================================

M	release/scripts/modules/bpy_extras/object_utils.py

===================================================================

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)



More information about the Bf-blender-cvs mailing list