Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-12-24 11:11:40 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-12-24 11:11:40 +0400
commit2cb8b12778f011e0413bc64ba4f0e3a90be604fb (patch)
treedf6f095f3407fca1c92ca09fc18e4eac24a411e3 /release
parent2a803680054506fd0e1edec73fa4f184df3a3bc8 (diff)
update bpy_extras.view3d_utils for matrix changes
AFAIK all trunk scripts are now updated for changes to matrix row/col.
Diffstat (limited to 'release')
-rw-r--r--release/scripts/modules/bpy_extras/view3d_utils.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/release/scripts/modules/bpy_extras/view3d_utils.py b/release/scripts/modules/bpy_extras/view3d_utils.py
index 32f7b654690..edc17c36c36 100644
--- a/release/scripts/modules/bpy_extras/view3d_utils.py
+++ b/release/scripts/modules/bpy_extras/view3d_utils.py
@@ -42,6 +42,7 @@ def region_2d_to_vector_3d(region, rv3d, coord):
"""
from mathutils import Vector
+ viewinv = rv3d.view_matrix.inverted()
if rv3d.is_perspective:
persinv = rv3d.perspective_matrix.inverted()
@@ -50,13 +51,11 @@ def region_2d_to_vector_3d(region, rv3d, coord):
-0.5
))
- w = ((out[0] * persinv[0][3]) +
- (out[1] * persinv[1][3]) +
- (out[2] * persinv[2][3]) + persinv[3][3])
+ w = out.dot(persinv[3].xyz) + persinv[3][3]
- return ((persinv * out) / w) - rv3d.view_matrix.inverted()[3].xyz
+ return ((persinv * out) / w) - viewinv.translation
else:
- return rv3d.view_matrix.inverted()[2].xyz.normalized()
+ return viewinv.col[2].xyz.normalized()
def region_2d_to_location_3d(region, rv3d, coord, depth_location):
@@ -81,15 +80,16 @@ def region_2d_to_location_3d(region, rv3d, coord, depth_location):
from mathutils.geometry import intersect_point_line
persmat = rv3d.perspective_matrix.copy()
+ viewinv = rv3d.view_matrix.inverted()
coord_vec = region_2d_to_vector_3d(region, rv3d, coord)
depth_location = Vector(depth_location)
if rv3d.is_perspective:
from mathutils.geometry import intersect_line_plane
- origin_start = rv3d.view_matrix.inverted()[3].to_3d()
+ origin_start = viewinv.translation.copy()
origin_end = origin_start + coord_vec
- view_vec = rv3d.view_matrix.inverted()[2]
+ view_vec = viewinv.col[2].copy()
return intersect_line_plane(origin_start,
origin_end,
depth_location,
@@ -100,8 +100,9 @@ def region_2d_to_location_3d(region, rv3d, coord, depth_location):
dy = (2.0 * coord[1] / region.height) - 1.0
persinv = persmat.inverted()
viewinv = rv3d.view_matrix.inverted()
- origin_start = ((persinv[0].xyz * dx) +
- (persinv[1].xyz * dy) + viewinv[3].xyz)
+ origin_start = ((persinv.col[0].xyz * dx) +
+ (persinv.col[1].xyz * dy) +
+ viewinv.translation)
origin_end = origin_start + coord_vec
return intersect_point_line(depth_location,
origin_start,