[Bf-blender-cvs] [9b359c1] master: Py API: default arg for location_3d_to_region_2d
Campbell Barton
noreply at git.blender.org
Mon Apr 13 06:37:52 CEST 2015
Commit: 9b359c1592057ae9296b4f0a4b543b1b783a232c
Author: Campbell Barton
Date: Mon Apr 13 14:35:16 2015 +1000
Branches: master
https://developer.blender.org/rB9b359c1592057ae9296b4f0a4b543b1b783a232c
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.
===================================================================
M release/scripts/modules/bpy_extras/view3d_utils.py
===================================================================
diff --git a/release/scripts/modules/bpy_extras/view3d_utils.py b/release/scripts/modules/bpy_extras/view3d_utils.py
index ec4a395..b8f9bc7 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
More information about the Bf-blender-cvs
mailing list