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.
This commit is contained in:
parent
e688ba0304
commit
9b359c1592
@ -160,7 +160,7 @@ def region_2d_to_location_3d(region, rv3d, coord, depth_location):
|
|||||||
)[0]
|
)[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.
|
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`
|
:type rv3d: :class:`bpy.types.RegionView3D`
|
||||||
:arg coord: 3d worldspace location.
|
:arg coord: 3d worldspace location.
|
||||||
:type coord: 3d vector
|
:type coord: 3d vector
|
||||||
|
:arg default: Return this value if ``coord``
|
||||||
|
is behind the origin of a perspective view.
|
||||||
:return: 2d location
|
:return: 2d location
|
||||||
:rtype: :class:`mathutils.Vector`
|
:rtype: :class:`mathutils.Vector` or ``default`` argument.
|
||||||
"""
|
"""
|
||||||
from mathutils import Vector
|
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),
|
height_half + height_half * (prj.y / prj.w),
|
||||||
))
|
))
|
||||||
else:
|
else:
|
||||||
return None
|
return default
|
||||||
|
Loading…
x
Reference in New Issue
Block a user