Cleanup: style, spelling

This commit is contained in:
Campbell Barton
2019-09-07 21:08:20 +10:00
parent ed779333bb
commit 1b0dd5a215
18 changed files with 85 additions and 64 deletions

View File

@@ -47,10 +47,11 @@ def region_2d_to_vector_3d(region, rv3d, coord):
if rv3d.is_perspective:
persinv = rv3d.perspective_matrix.inverted()
out = Vector(((2.0 * coord[0] / region.width) - 1.0,
(2.0 * coord[1] / region.height) - 1.0,
-0.5
))
out = Vector((
(2.0 * coord[0] / region.width) - 1.0,
(2.0 * coord[1] / region.height) - 1.0,
-0.5
))
w = out.dot(persinv[3].xyz) + persinv[3][3]
@@ -99,9 +100,11 @@ def region_2d_to_origin_3d(region, rv3d, coord, clamp=None):
dx = (2.0 * coord[0] / region.width) - 1.0
dy = (2.0 * coord[1] / region.height) - 1.0
persinv = persmat.inverted()
origin_start = ((persinv.col[0].xyz * dx) +
(persinv.col[1].xyz * dy) +
persinv.translation)
origin_start = (
(persinv.col[0].xyz * dx) +
(persinv.col[1].xyz * dy) +
persinv.translation
)
if clamp != 0.0:
if rv3d.view_perspective != 'CAMERA':
@@ -149,17 +152,19 @@ def region_2d_to_location_3d(region, rv3d, coord, depth_location):
from mathutils.geometry import intersect_line_plane
viewinv = rv3d.view_matrix.inverted()
view_vec = viewinv.col[2].copy()
return intersect_line_plane(origin_start,
origin_end,
depth_location,
view_vec, 1,
)
return intersect_line_plane(
origin_start,
origin_end,
depth_location,
view_vec, 1,
)
else:
from mathutils.geometry import intersect_point_line
return intersect_point_line(depth_location,
origin_start,
origin_end,
)[0]
return intersect_point_line(
depth_location,
origin_start,
origin_end,
)[0]
def location_3d_to_region_2d(region, rv3d, coord, default=None):
@@ -184,8 +189,9 @@ def location_3d_to_region_2d(region, rv3d, coord, default=None):
width_half = region.width / 2.0
height_half = region.height / 2.0
return Vector((width_half + width_half * (prj.x / prj.w),
height_half + height_half * (prj.y / prj.w),
))
return Vector((
width_half + width_half * (prj.x / prj.w),
height_half + height_half * (prj.y / prj.w),
))
else:
return default