diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-04-13 07:35:16 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-04-13 07:35:16 +0300 |
commit | 9b359c1592057ae9296b4f0a4b543b1b783a232c (patch) | |
tree | 007de6777a58d67e8a33c645befc039a24a927a7 /release/scripts/modules/bpy_extras/view3d_utils.py | |
parent | e688ba0304907d7e8d77a3d9dcb27d06dabc8a62 (diff) |
Py API: default arg for location_3d_to_region_2d
This function could return None for points behind the view,
note this in the doc-string and add an optional fallback argument.
Diffstat (limited to 'release/scripts/modules/bpy_extras/view3d_utils.py')
-rw-r--r-- | release/scripts/modules/bpy_extras/view3d_utils.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/release/scripts/modules/bpy_extras/view3d_utils.py b/release/scripts/modules/bpy_extras/view3d_utils.py index ec4a395f1e1..b8f9bc730f7 100644 --- a/release/scripts/modules/bpy_extras/view3d_utils.py +++ b/release/scripts/modules/bpy_extras/view3d_utils.py @@ -160,7 +160,7 @@ def region_2d_to_location_3d(region, rv3d, coord, depth_location): )[0] -def location_3d_to_region_2d(region, rv3d, coord): +def location_3d_to_region_2d(region, rv3d, coord, default=None): """ Return the *region* relative 2d location of a 3d position. @@ -170,8 +170,10 @@ def location_3d_to_region_2d(region, rv3d, coord): :type rv3d: :class:`bpy.types.RegionView3D` :arg coord: 3d worldspace location. :type coord: 3d vector + :arg default: Return this value if ``coord`` + is behind the origin of a perspective view. :return: 2d location - :rtype: :class:`mathutils.Vector` + :rtype: :class:`mathutils.Vector` or ``default`` argument. """ from mathutils import Vector @@ -184,4 +186,4 @@ def location_3d_to_region_2d(region, rv3d, coord): height_half + height_half * (prj.y / prj.w), )) else: - return None + return default |